Python programming language is ideal for doing scientific and engineering calculation and plotting graph of functions. Here is how one can get the y-axis values for linearly spaced x values.

import matplotlib.pyplot as plt
from math import exp

y = []
x = []

for u in range(-10,10):
    v = exp(u)
plt.plot(x, y)

In the python code above, we have used the exponential function in the y axis. Using the for loop we have defined the range of the x values and for each x value we computed the exponential value y.

Here is the plot:

The range function is not particularly useful because it accepts integer as the stepping value and this hinders to use smaller x values.


Post a Comment