On 9 Ășn, 11:22, Giovanni Lanzani <[email protected]> wrote:
> Dear all
>
> I have the following sage code
>
> sage: gamma,r,gangle,dz2,Nstep,Nrib,b=var('gamma,r,gangle,dz2,Nstep,Nrib,b')
> sage: a=11.5; b=6;#this is fixed
> sage: Nstep=2;Nrib=5;Diam=33;gangle=30*2*3.1415/360;gamma=40*0.33+20*0.33;
> sage: #these have all to be changed when using different structure
> sage: r=(Diam-2*a)/2;th=2*3.1415*Nstep/Nrib;
> sage: def theta(dz):
> ...       return 2*arcsin(dz*tan(gangle)/2/r);
> ...
> sage: def dz2(dz):
> ...       return (-(Nrib+1)/(Nrib-1)*dz+b*cos(gangle)*2/(Nrib-1));
> sage: def erseno(x):
> ...       return 
> 2*arcsin(b*sin(gangle)/2/r)-(Nrib-1)*theta(dz2(x))/2-(Nrib+1)*theta(x)/2;
> sage: find_root(erseno(x)==0,2,gamma,xtol=0.01)
> 0.0
>

You look for the zero on the interval which is not subset of the
domain of the function.  Try erseno(gamma) ....
Do not know why Sage returns result which is not true, but you can try
this:

sage:
gamma,r,gangle,dz2,Nstep,Nrib,b=var('gamma,r,gangle,dz2,Nstep,Nrib,b')
sage: a=11.5; b=6;#this is fixed
sage:
Nstep=2;Nrib=5;Diam=33;gangle=30*2*3.1415/360;gamma=40*0.33+20*0.33;
sage: r=(Diam-2*a)/2;th=2*3.1415*Nstep/Nrib;
sage: def theta(dz):
....:     return 2*arcsin(dz*tan(gangle)/2/r);
....:
sage: def dz2(dz):
....:     return (-(Nrib+1)/(Nrib-1)*dz+b*cos(gangle)*2/(Nrib-1));
....:
sage: def erseno(x):
....:     return 2*arcsin(b*sin(gangle)/2/r)-(Nrib-1)*theta(dz2(x))/2-
(Nrib+1)*theta(x)/2;
....:
sage: erseno(gamma)
NaN
sage: find_root(erseno(x),2,10,xtol=0.01)
5.1961985254756655


Robert



> So it says that the root of the function can only be achieved when
> x=0. However solving the root with Mathematica gives x=5.19... and in
> fact
>
> sage: erseno(5.19615)
> 4.10615985657614e-12
>
> Is there any reason this is happening? Am I doing something wrong?
>
> Thanks
>
> Giovanni Lanzani

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to