If I execute this code, the numeric solution returned is
1.0339735, for all values of t, including t=PI/6.
reset():
t := PI/6:
c := 9: d := 4: r := 2:
s := sqrt(c^2*sin(x)^2+d^2*cos(x)^2):
f := tan(t)-tan(x)*(c^2-r*s)/(d^2-r*s):
//plotfunc2d(tan(x)*(c^2-r*s)/(d^2-r*s),x=0..PI/2);
numeric::solve(f,x=0..PI/2,RestrictedSearch);
If I include the plot by removing the // and execute it
again, the numeric solution is 0.062740333399
which I think is correct and the solution varies as t
is changed.
My question is - why does the solution to the function
change if I plot something first?
Cheers, Brad
It seems to be a bug. The same behavior can be demonstrated more
simply:
reset()
numeric::solve(tan(x),x=PI/2..PI)
result is {1.570796327} , or PI/2. It incorrectly calls the sign
change from plus infinity to minus infinity a solution.
If you then change the search range
numeric::solve(tan(x),x=PI/2-.0001..PI)
it gives
Warning: Package redefined [package]
{3.141592654}
( the correct answer).
It then continues to give the right answer even if the range is set to
the original range, PI/2..PI.
--
john