In: Computer Science
Here , since it is Computer Science question , So Done with the help of python language
Here first 6 terms of taylor series is printed first
after then the value at each terms for 3.52 is printed
SInce ln(x) , so its 1st value will always be 0.
Code:->
START
import math
n = 6
x = "x"
print("First 6 terms of Taylor Series for ln(x) given x=1 ")
print("1 0")
for i in range(1,n):
f = str(((-1)**(i-1)))
f = f + "(x-1)"*i + "/" + str(i)
print(i+1,f)
print("Now calculating for 3.52 value")
print("1 0")
x = 3.52
taylor_sum = 0
for i in range(1,n):
z = ((-1)**(i-1))*((x-1)**(i))/i
taylor_sum = taylor_sum + z
print(i+1,z)
print("Value of ln(3.52) using taylor series till 6th term :
",taylor_sum)
print("Actual Value of ln(3.52) : ",math.log(3.52))
print("Absolute error for ln(3.52) using taylor series till 6th
term is : " ,math.log(3.52)-taylor_sum)
END
OUTPUT :->
First 6 terms of Taylor Series for ln(x) given x=1
1. 0
2. 1(x-1)/1
3. -1(x-1)(x-1)/2
4. 1(x-1)(x-1)(x-1)/3
5. -1(x-1)(x-1)(x-1)(x-1)/4
6. 1(x-1)(x-1)(x-1)(x-1)(x-1)/5
Now calculating for 3.52 value
1. 0
2. 2.52
3. -3.1752000000000002
4. 5.334336
5. -10.081895040000001
6. 20.32510040064
Value of ln(3.52) using taylor series till 6th term :
14.922341360639999
Actual Value of ln(3.52) : 1.2584609896100056
Absolute error for ln(3.52) using taylor series till 6th term is :
-13.663880371029993
Reason for such large difference in absolute error is because
taylor series works for n= infinity
And, here we are working for only first 6 parts .