shani2775

15 Reputation

One Badge

9 years, 216 days

MaplePrimes Activity


These are questions asked by shani2775

hy

i have to develop a code i which i have system of nonlinear equation 

i have to generate the matrix of that nonlinear equation then i want to do or apply any method say newton method and make a loop which help us to find a solution using some tolerance 

at the end i get a result in form of a table which give nth matrix then value of function matrix at nth value then error i-e xn-x(n-1) 

thanx in advance

hy 
need help 
i made this code but i can not get the answer ,help me to find out where i did wrong.

thanx in advance




restart;
f:=x->(x^3+3*x^2-1);
n:=30;
tol:=1e-9;
a[0]:=0;
b[0]:=10;
Digits :=15;

 

printf("No root F(x) abs(x[i+1]-x[i])\n");

for i from 1 to n do
t[i-1] :=evalf( (b[i-1]-a[i-1])/(f(b[i-1])-f(a[i-1])));
c[i-1] := evalf((a[i-1]*f(b[i-1])-b[i-1]*f(a[i-1]))/(f(b[i-1])-f(a[i-1])));
x[i] :=evalf( x[i-1]-t[i-1]*f(x[i-1])^2/(f(x[i-1])-f(c[i-1])));

printf("%d %10.15f %10.15f %10.15e \n",i,x[i],f(x[i]),abs(x[i]-x[i-1]));
if f(a[i-1])*f(c[i-1])<0 then
a[i]:=a[i-1];
b[i]:=c[i-1];
else
a[i]:=c[i-1];
b[i]:=b[i-1];
if abs(f(x[i]))<tol then
print("approximate solution"= x[i]);
print("No of iterations"= i);
break;
end if;
end if;
end do:

cannot find the error in loop

 

 

> restart; u[0] := (4/3)*c^2*cos((1/4)*x)^2; alpha := 2;
 
> iteration := 3;
> for k from 0 while k <= Iteration do u[s] := eval(u[k], t = xi); u[k+1] := simplify(u[k]-(int(diff(u[s], [`$`(xi, alpha)])+diff(u[s]*u[s], x)+diff(u[s]*u[s], x, x, x), xi = 0 .. t))) end do;

a1:= f(x) :
> T1 :=simplify((taylor(a1,x=alpha,N+3))):
> E1:=subs([seq(((D@@i)(f))(alpha) = 0,i=1..m-1),f(alpha)=0,x=e[n]+alpha],T1):
> g1 :=(convert(simplify(series((E1,e[n]=0,N))),polynom));

 

let γ be the root 

i have to apply taylor series on f(x) and then do some substitution like (helped by a member of Mapleprime)

restart;
taylor(f(x), x = gamma, 8);
f(x[n]) := subs([x-gamma = e[n], f(gamma) = 0, seq(((D@@k)(f))(gamma) = factorial(k)*c[k]*(D(f))(gamma), k = 1 .. 1000)], %)

then find the derivative of result from above output

i do

b := diff((x[n]), e[n])

basically i have to find the value of newton method which is

yn=xn-f(xn)/D(f)(xn)

here we substitute xn=γ and D(f)(xn)=b

and then want to apply f on yn

there are to problem which i face 

1  f(xn)/D(f)(xn) is not in simplified form i-e O(e[n]^8) and O(e[n]^7) is appeared in numerator and denominator respectively. how we get the simplified result.

2 wht step should i do to find f(yn)

plx help me to do this 

thanx in advance

1 2 Page 1 of 2