Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MuPAD 3.0 code gives strange result

1 view
Skip to first unread message

Brad Cooper

unread,
Apr 9, 2006, 5:03:21 AM4/9/06
to
A question about MuPAD 3.0

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


John O'Flaherty

unread,
Apr 15, 2006, 12:30:26 PM4/15/06
to

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

0 new messages