maple10 code

How do i get 20th iteration for following fixed pt problem

x = exp(-x/2)

Please help.

one possibility

x := 2.: # try with a rational!
to 20 do
    x := exp(-x/2);
end do:
x;

which one is more accurate?better?

> restart:
> n:=1:
> x[n]:=exp(1)^(-1/2):
> while n<21 do
> x[n+1]:=exp(1)^(-x[n]/2):
> n:=n+1:
> od:
> evalf(%%);

OR

> x := 1: # try with a rational!
> to 20 do
>     x := exp(-x/2);
> end do:
> evalf(x);

 

 

Thanks
 

Robert Israel's picture

Which one?

One of the easiest ways to make Maple crash is to iterate a function only slightly more complicated than this one using exact expressions rather than floats.  Just about any function that contains the variable x in more than one place will do.  The iterates rapidly get more and more complicated, eventually using up all available memory.   So, in general, it's much better to insert an evalf into your loop, e.g.

to 20 do
  x := evalf(f(x))
end do:

 

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}