bongiman

133 Reputation

2 Badges

14 years, 169 days

MaplePrimes Activity


These are replies submitted by bongiman

Thank you for your answer. Very well explained and extremely helpful. I've only been working on Maple for about 3 weeks now and it makes me wonder how on earth i'm actually going get my head around it all :).

Thank you for your answer. Very well explained and extremely helpful. I've only been working on Maple for about 3 weeks now and it makes me wonder how on earth i'm actually going get my head around it all :).

Thank you for your response. I have a second query:

If i want to modify NR1 above to NR2(f,x0,N,eps) where eps is a real number so that it returns the first iterate xk for which |x[k]-x[k-1]|<eps and k<=N. However, if |x[k]-x[k-1]|>=eps for k=1,...,N, then an error message should be displayed.

If the procedure is correct then for f:= x-> x^5-1 i should get an answer when x0=0.60+0.20i and the error message when x0=0.60+0.16i.

The code i've written so far is incorrect but i'm not sure where i'm going wrong. Would you be able to give me some pointers?

NR2:=proc(f::mathfunc,x0::complex,N::posint,eps)
> local x,k:
> x := x0:
> for k to N do:
>   if abs(x[k]-x[k-1]) >= eps then
>   print("Convergence has not been achieved!"):
>   return :
> end if:
> x := x-f(x)/D(f)(x)
> end do:
>  evalf(x):
> end proc:f:= x-> x^5-1:
> NR2(f,0.6+I*0.16,10,0.00001);
Error, (in NR2) cannot determine if this expression is true or false: .1e-4 <= abs((.6+.16*I)[1]-(.6+.16*I)[0])

> NR2(f,0.6+I*0.20,10,0.00001);
Error, (in NR2) cannot determine if this expression is true or false: .1e-4 < abs((.6+.20*I)[1]-(.6+.20*I)[0])
 

Thanks in advance.

Thank you for your response. I have a second query:

If i want to modify NR1 above to NR2(f,x0,N,eps) where eps is a real number so that it returns the first iterate xk for which |x[k]-x[k-1]|<eps and k<=N. However, if |x[k]-x[k-1]|>=eps for k=1,...,N, then an error message should be displayed.

If the procedure is correct then for f:= x-> x^5-1 i should get an answer when x0=0.60+0.20i and the error message when x0=0.60+0.16i.

The code i've written so far is incorrect but i'm not sure where i'm going wrong. Would you be able to give me some pointers?

NR2:=proc(f::mathfunc,x0::complex,N::posint,eps)
> local x,k:
> x := x0:
> for k to N do:
>   if abs(x[k]-x[k-1]) >= eps then
>   print("Convergence has not been achieved!"):
>   return :
> end if:
> x := x-f(x)/D(f)(x)
> end do:
>  evalf(x):
> end proc:f:= x-> x^5-1:
> NR2(f,0.6+I*0.16,10,0.00001);
Error, (in NR2) cannot determine if this expression is true or false: .1e-4 <= abs((.6+.16*I)[1]-(.6+.16*I)[0])

> NR2(f,0.6+I*0.20,10,0.00001);
Error, (in NR2) cannot determine if this expression is true or false: .1e-4 < abs((.6+.20*I)[1]-(.6+.20*I)[0])
 

Thanks in advance.

Ha ha, looks like i was heading completely in the wrong direction!

This opens up a whole new world. Thanks.

 

Ha ha, looks like i was heading completely in the wrong direction!

This opens up a whole new world. Thanks.

 

Brilliant! That is a much neater solution than the one i came up with. Thanks a million!

Brilliant! That is a much neater solution than the one i came up with. Thanks a million!

Interesting, your answer gave the opposite of what i needed. This what i came up with after a while of pulling my hair out before newton's apple struck me!

S:= {seq(i, i = 1 .. 66)};


> coprime66:= x-> igcd(x,66)=1;


> select(coprime66,S);


I've learnt from your response though; it shows there are so many diff ways to do the same thing. I'll probably asking another query fairly soon as i'm such a novice at Maple!

Thank you

 

Interesting, your answer gave the opposite of what i needed. This what i came up with after a while of pulling my hair out before newton's apple struck me!

S:= {seq(i, i = 1 .. 66)};


> coprime66:= x-> igcd(x,66)=1;


> select(coprime66,S);


I've learnt from your response though; it shows there are so many diff ways to do the same thing. I'll probably asking another query fairly soon as i'm such a novice at Maple!

Thank you

 

Page 1 of 1