#2114 Incorrect solution to equation

closed
nobody
5
2010-12-17
2010-11-30
quwerty
No

I have the foolowing code:
c:3e+8$
mu_r1:1$
mu_r2:1$
sigma_1:0$
sigma_2:0$
eps_r1:3.3$
eps_r2:1.6$
h:1e-6$
f:180e+12$
P2:0.01e-3$
eps_0:8.85e-12$
mu_0:4*%pi*1e-7$
eps_a1:eps_r1*eps_0$
eps_a2:eps_r2*eps_0$
mu_a1:mu_0*mu_r1$
mu_a2:mu_0*mu_r2$
omega:2*%pi*f$
/* [wxMaxima: input end ] */
/* [wxMaxima: input start ] */
kill(x, y)$
x:find_root(sqrt(omega^2*h^2*(eps_a1*mu_a1-eps_a2*mu_a2)-x^2)+eps_a2/eps_a1*x*tan(x)=0, x, 0, 5);
y:float(sqrt(omega^2*h^2*(eps_a1*mu_a1-eps_a2*mu_a2)-%^2));
y1:float(-eps_a2/eps_a1*x*tan(x))$

With these limits y!=y1. If I run

x:find_root(..., x, 1.7, 2);

I get correct answer. This seems a little strange. May this be of tan(x)'s behaviour at x=%pi/2?

Discussion

  • Dieter Kaiser

    Dieter Kaiser - 2010-12-03

    At first, it is very helpful to have a small example. I think the function of interest for this example is

    eqn: 0.4848484848484849*x*tan(x)+sqrt(0.7799327999999998*%pi^3-x^2)

    One important and documented restriction of the algorithm of find_root is, that the function has to be continuous over the interval, which is given as an argument to find_root. If I do a plot of the function for the interval [0,5] with the command

    plot2d(eqn,[x,0,5],[y,-100,100])

    I can see that the function is not continuous at two points and that the function has one root. Furthermore, the root is near the value 1.75.

    If I take the function of this example and the interval [1.6,2.0] I get the desired root:

    (%i1) eqn:.4848484848484849*x*tan(x)+sqrt(.7799327999999998*%pi^3-x^2);
    (%o1) .4848484848484849*x*tan(x)+sqrt(.7799327999999998*%pi^3-x^2)

    This is the root of the equation:

    (%i2) result:find_root(eqn,x,1.6,2);
    (%o2) 1.753812411159384

    Backsubstitution shows that the result is a root within an expected accuracy

    (%i3) float(subst(result,x,eqn));
    (%o3) -1.77635683940025e-15

    The algorithm of find_root fails in the interval [0,5] because the function is not continuous over the interval.

    I think we do not have a bug. The numerical routine find_root has documented limitations. Setting the status to pending and the resolution to "works for me".

    Dieter Kaiser

     
  • Dieter Kaiser

    Dieter Kaiser - 2010-12-03
    • status: open --> pending
     
  • SourceForge Robot

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

     
  • SourceForge Robot

    • status: pending --> closed
     

Log in to post a comment.