0% found this document useful (0 votes)
5 views6 pages

Graph Plotter For Two Mathematical Functions

The document outlines a flowchart and algorithm for a graph plotter that visualizes two mathematical functions based on user input. It includes steps for accepting range values, defining functions, generating data points, computing values, plotting graphs, and displaying the plot. Additionally, it provides a sample source code using Python's NumPy and Matplotlib libraries to implement the described functionality.

Uploaded by

catsaware
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views6 pages

Graph Plotter For Two Mathematical Functions

The document outlines a flowchart and algorithm for a graph plotter that visualizes two mathematical functions based on user input. It includes steps for accepting range values, defining functions, generating data points, computing values, plotting graphs, and displaying the plot. Additionally, it provides a sample source code using Python's NumPy and Matplotlib libraries to implement the described functionality.

Uploaded by

catsaware
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Graph Plotter for Two Mathematical

Functions

Flowchart:
Algorithm:
1.​Input:​

○​ Accept the starting and ending values for the range.


○​ Accept the number of data points to be used.
○​ Accept the two mathematical functions as input.
2.​Define Functions:​

○​ Define a function to calculate the value of the first


mathematical expression.
○​ Define a function to calculate the value of the second
mathematical expression.
3.​Generate Data:​

○​ Create a sequence of data points within the specified


range using the chosen number of points.
4.​Compute Values:​

○​ Compute the values of the first function for each data


point.
○​ Compute the values of the second function for each
data point.
5.​Plot the Graphs:​

○​ Plot the graph for the first function with appropriate


markers and line styles.
○​ Plot the graph for the second function with appropriate
markers and line styles.
○​ Add a grid to the plot.
○​ Label the axes and set the plot title.
○​ Add a legend to differentiate between the two
functions.
6.​Display the Plot:​

○​ Show the plot with the two functions visualized.


Program Source Code:
#Assignment9
#UME20241002
import numpy as np
import matplotlib.pyplot as plt

a=int(input("enter the initial value of x: "))


b=int(input("enter the final value of x: "))
n=int(input("enter the data points to be added: "))

s=input("enter the first function to be plotted: ")


s2=input("enter the second function to be plotted: ")

def F(x):
f=eval(s)
return(f)

def G(x):
g=eval(s2)
return(g)
x=np.linspace(a,b,n)

y=F(x)
z=G(x)

plt.plot(x,y,color='orange',marker='o',linestyle='dotted')
plt.plot(x,z,color='purple',marker='o',linestyle='dotted')
plt.grid()
plt.xlabel("x")
plt.ylabel(f"{s} and {s2}")
plt.title(f"graph of {s} and {s2} vs x")
plt.legend([f"{s}",f"{s2}"])
plt.show()

Sample output:

enter the initial value of x: 0


enter the final value of x: 9
enter the data points to be added: 101
enter the first function to be plotted: np.sin(x)
enter the second function to be plotted: np.cos(x)

You might also like