Apr-15-2019, 11:13 PM
You have two issues with your code:
1)
2)You need to add the following lines to your code:
E.g. after applying
So, if don't want to use
to x-values. This is why I add a line
1)
def applog(a,x):
should be def applog(n,x):
2)You need to add the following lines to your code:
y = [applog(4, _) for _ in x] plt.plot(x, y,color='blue', label='approx ln(x)' )In my code, I used
np.vectorize
decorator to be able to pass vectors to the applog
function.E.g. after applying
np.vectorize
we are able to pass vectors to applog: e.g. applog(4, [1,2,3,4,5])
is allowed now.So, if don't want to use
np.vectorize
you need to precompute y-values correspondingto x-values. This is why I add a line
y = ....
.