Hello,

Im meant to create a program to compute inverse tan - tan(^-1)(x)

to a given accuracy. They gave examples in class of how to do it for

1+1/2+1/3+...
1+1/2+1/4+1/8+...
sin(x)

like to 8 decimal places or whatever.

here's what i got on my screen.

http://kr.cs.ait.ac.th/~radok/math/mat6/calc6.htm
This sort of has an explanation on how to get the taylor series for inverse tan. basically i was gonna try to copy and paste the output for the sin(x) eg. and just swap the taylor series to see if it would work.

ANY HELP WOULD BE APPRECIATED.
OUTPUT:

> sum_ex1:=proc(x)

> local sum_n, i:

> sum_n:=0:

> for i from 1 to x do

> sum_n:=sum_n+1/i:

> od:

> evalf(sum_n);

> end:

> sum_ex1(20);





3.597739657

> sum_ex2:=proc(x)

> local sum_n, i:

> sum_n:=0:

> for i from 1 to x do

> sum_n:=sum_n+1/2^(i-1):

> od:

> evalf(sum_n);

> end:

> sum_ex2(40);



2.000000000

question 3

> sinx:=proc(x,n)

> local sum_n,i:

> sum_n:=0:

> for i from 1 to n do

> sum_n:=sum_n+(-1)^(i-1)*x^(2*i-1)/(2*i-1)!:

> od:

> RETURN(sum_n,evalf(sum_n));

> end:

>

> sinx(0,2);



0, 0.

> sinx(Pi/2,10);





1 1 3 1 5 1 7 1 9 1 11

- Pi - -- Pi + ---- Pi - ------ Pi + --------- Pi - ----------- Pi

2 48 3840 645120 185794560 81749606400



1 13 1 15 1 17

+ -------------- Pi - ----------------- Pi + -------------------- Pi

51011754393600 42849873690624000 46620662575398912000



1 19

- ----------------------- Pi ,

63777066403145711616000



1.000000000

> evalf(%);



1.000000000, 1.000000000

> sinxacc:=proc(x,maxit,acc)

> local sum_n,i, terms:

> sum_n:=0:

> terms:=0:

> i:=1:

> while i < maxit do

> sum_n:=sum_n+(-1)^(i-1)*x^(2*i-1)/(2*i-1)!:

> if abs(terms-sum_n) RETURN(`convergence reached`,

> evalf(sum_n),`terms=` + i);

> else

> i:=i+1;

> terms:=sum_n:

> fi:

> od:

> RETURN(`max iterations reached`,evalf(sum_n));

> end:

>

> sinxacc(1.5,10,1e-8);



convergence reached, 0.9974949867, terms= + 8

> sin(1.5);



0.9974949866

> ex2_6:=proc(x,accuracy)

> local i,term,sum1;

> sum1:=0;

> i:=1;

> term:=x;

> while abs(term)>accuracy do;

> sum1:=sum1+term;

> print(i,evalf(term),sum1);

> i:=i+1;

> term:=abs(x)^(2*n+1)/(2*n+1);

> od;

> end;

> ex2_6(1,0.0001);



ex2_6 := proc(x, accuracy)

local i, term, sum1;

sum1 := 0;

i := 1;

term := x;

while accuracy < `abs`(term) do

sum1 := sum1 + term;

print(i, evalf(term), sum1);

i := i + 1;

term := `abs`(x)^(2*n + 1)/(2*n + 1)

end do

end proc



1, 1., 1

Error, (in ex2_6) cannot determine if this expression is true or false: -1/abs(2*n+1) < -0.1e-3







Please Wait...