Dec-17-2019, 06:37 PM
Hello folks,
I've put together the following code for a series expansion for the function ln(1+x):
calculate and print out the value of ln(1 + x) calculated using the above series expansion using a while loop and including all terms whose magnitude are bigger than 10−8. Print out the sum to each number of terms.
Can anyone help explain how to do this?
I've put together the following code for a series expansion for the function ln(1+x):
import numpy as np x = float(input('Please input a number x between 0 and 1 ')) logx = np.log(x+1) while x<=0 or x>=1: float(input('Please input a number between 0 and 1 ')) for n in range(1, 13): term1 = x term = ((-1)**(n+1))*(x**n)/n term1 += term print('The sum of the Taylor expansion for ln(1+x) upto x^12 is: ', term1)I'm stuck on the following task:
calculate and print out the value of ln(1 + x) calculated using the above series expansion using a while loop and including all terms whose magnitude are bigger than 10−8. Print out the sum to each number of terms.
Can anyone help explain how to do this?