Write a c++ program to plot a graph of function f(x) = x
n + xn-1
. Your program should take a maximum
absolute value of x as well as a positive integer n as input. You will plot a graph for the range [0, x]. You
should label the y-axis according to the maximum value of x.
Sample Output: For x = 3 and n = 2, you should have the following output
12 *
10
08
06 *
04
02 *
00 *
0 1 2 3
import matplotlib.pyplot as plt
x = 4
list1 = [i for i in range(0,x)]
n = 4
list2 = []
for i in list1:
list2.append( n + i * n -1)
plt.plot(list1,list2)
plt.title('title name')
plt.xlabel('X')
plt.ylabel('n + i * n -1
Comments
Leave a comment