[comp.sys.handhelds] Bug in QUAD

adkins@tortoise.cis.ohio-state.edu (Brian Adkins) (03/01/91)

I've discovered a possible bug in the QUAD function.  Consider the
equation:

      x^2
  ----------- = .58    QUAD returns 'x=s1*76.15.../5000'  neither one of these
  (.02 - x)^2           roots is correct.

If the equation is re-written as x^2 = .58*(.02 - x)^2 it works fine.
HP tech support said it looked like it wasn't working "very well" and to call
back in 6 months to see if anything was done!  I have revision E.
My opinion is that it not only doesn't work very well in this case, but it
just doesn't work.  Any other ideas?

bob@dolores.Stanford.EDU (Bob Lodenkamper) (03/01/91)

In article <89355@tut.cis.ohio-state.edu> adkins@tortoise.cis.ohio-state.edu (Brian Adkins) writes:

   I've discovered a possible bug in the QUAD function.  Consider the
   equation:

	 x^2
     ----------- = .58    QUAD returns 'x=s1*76.15.../5000'  neither one of these
     (.02 - x)^2           roots is correct.

   If the equation is re-written as x^2 = .58*(.02 - x)^2 it works fine.
   HP tech support said it looked like it wasn't working "very well" and to call
   back in 6 months to see if anything was done!  I have revision E.
   My opinion is that it not only doesn't work very well in this case, but it
   just doesn't work.  Any other ideas?

My fearless guess is that QUAD will only work if the equation is in a
polynomial format.  If a quadratic is expressed as a rational
function, trignometric mess, whatever, the 48 merrily expands to
second order and solves the resulting polynomial.  This is what
happens, according to the manual, should one attempt to use QUAD to
solve tan(x) = x.  If this is correct, the behavior you describe is
precisely what one would expect - after all, how can the 48 be
expected to recognize all algebraic messes that are quadratics?  I'd
be happy if it could, but then again I want symbolic integration, a
special function library and other goodies that I'll have to wait 5 or
10 years for.

- Bob

edp@jareth.enet.dec.com (Eric Postpischil (Always mount a scratch monkey.)) (03/01/91)

In article <89355@tut.cis.ohio-state.edu>, adkins@tortoise.cis.ohio-state.edu
(Brian Adkins) writes:

>      x^2
>  ----------- = .58    QUAD returns 'x=s1*76.15.../5000'  neither one of these
>  (.02 - x)^2           roots is correct.

QUAD works only on quadratic expressions; your equation contains the ratio of
two polynomials, but it is not itself a quadratic expression.

I suspect that the way QUAD works is to find the second order Taylor's
polynomial of the expression you give it.  That forces the expression into a
known form, which can then be dissected to give the quadratic coefficients.

To support this theory, observe that if you use QUAD on an expression containing
a function whose derivative is not known to the 48, you get an expression
contain "der" in it.  E.g., try 'X^2-RE(C)' 'X' QUAD.

As another test, I entered your expression and then 'x' 2 TAYLR COLCT to get
'2500*X^2=.58'.  Taking the QUAD of that produces 'x'=s1*76.1577310586/5000',
which is identical to what you got and is the correct solution for the root of
the Taylor's polynomial.


				-- edp (Eric Postpischil)
				"Always mount a scratch monkey."
				edp@jareth.enet.dec.com

akcs.dnickel@hpcvbbs.UUCP (Derek S. Nickel) (03/02/91)

Brian,

My first thought is that your equation is not really a quadratic
polynomial.  whereas the rewitten form is closer.

        Derek S. Nickel