Answer to Question #272438 in C++ for print

Question #272438

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


1
Expert's answer
2021-11-28T05:26:08-0500
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

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS