Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
approximation
#3
Thanks,
I understand what you are saying,
I came up with a correction to my code, however
my graphs are still empty.
I'd like to know why so and what I should do in order
to solve this issue.

def applog(n,x):
    a0=(1+x)/2
    b0=sqrt(x)
    for i in range(n):
        a0=(a0+b0)/2
        b0=sqrt((a0)*b0)
    return (x-1)/a0
 



print("the log approximation is: " , ((applog(100,4)))) 
print("log value-------------------:" , (np.log(4)) )
                  
error=(abs( applog(100,4)- (np.log(4))   ) )                    
print("the error is : ", error)   
    
 
plt.show()
plt.plot((applog(100,4)) )
plt.plot(np.log(4))
plt.show()          #should plot both funtctions in the same graph
plt.plot(error )
plt.show()         # should plot the difference of both functions
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