Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
approximation
#6
You have two issues with your code:
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 corresponding
to x-values. This is why I add a line y = .....
Reply


Messages In This Thread
approximation - by mcgrim - Apr-13-2019, 08:22 PM
RE: approximation - by scidam - Apr-14-2019, 10:14 AM
RE: approximation - by mcgrim - Apr-14-2019, 11:38 AM
RE: approximation - by scidam - Apr-14-2019, 12:06 PM
RE: approximation - by mcgrim - Apr-15-2019, 10:19 AM
RE: approximation - by scidam - Apr-15-2019, 11:13 PM
RE: approximation - by mcgrim - Apr-17-2019, 08:13 PM
RE: approximation - by scidam - Apr-18-2019, 04:13 AM
RE: approximation - by mcgrim - Apr-18-2019, 07:20 AM
RE: approximation - by mcgrim - Apr-19-2019, 07:32 AM
RE: approximation - by mcgrim - Apr-19-2019, 08:08 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020