MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Solve

  • To: mathgroup at smc.vnet.net
  • Subject: [mg57901] Re: [mg57886] Solve
  • From: Andrzej Kozlowski <andrzej at akikoz.net>
  • Date: Sun, 12 Jun 2005 04:34:22 -0400 (EDT)
  • References: <200506110735.DAA16863@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On 11 Jun 2005, at 16:35, R T wrote:

> I'm generating 9th degree polynomials with Mathematica
> from real world data. Then I'm using them in an
> application I'm writing in Xcode. This works
> beautifully!
>
> I get an equation like...
>
> -0.13249751088801668 + 0.06632187456026009*r^1
> +0.06629492661634432*r^2 - 0.00005387198125569*r^3
> -0.00002692675947693*r^4 + 0.00000001324872853*r^5
> +0.00000000435988550*r^6 - 0.00000000000037184*r^7
> -0.00000000000043768*r^8 + 0.00000000000000172*r^9
>
> ...and in a function I wrote in Xcode, I supply r, say
>  r = 5, and the answer 1.83303 is generated . BUT I
> need to start with the answer and solve for r.
>
> In Mathematica...
>
> answer = Solve[
> -0.13249751088801668 + 0.06632187456026009*r^1
> +0.06629492661634432*r^2 - 0.00005387198125569*r^3
> -0.00002692675947693*r^4 + 0.00000001324872853*r^5
> +0.00000000435988550*r^6 - 0.00000000000037184*r^7
> -0.00000000000043768*r^8 + 0.00000000000000172*r^9 ==
> 1.83303, r]
>
> ...solves to...
>
> {r -> -61.9036 - 40.911 I}, {r -> -61.9036 + 40.911
> I},      {r -> -59.8256}, {r-> -6.}, {r -> 5},  {r ->
> 73.5579}, {r -> 82.3158 - 32.3924 I}, {r -> 82.3158 +
> 32.3924 I},
> {r -> 200.908}}
>
> and knowing from the origional real world data that r
> is in a range between 0 and 16 .... the solution is
> {r -> 5}.
> _________________________________________________________________
>
> Mathmatically how does the "Solve" function do this?
> My application needs to dynamically "Solve" the
> equation, so I need to write something in "C".
>
> Any leads greatly appreciated.
> Thanks,
> Rick T.
>


What happens is (roughly) this. You are applying Solve, which is an  
exact algebraic solve to a polynomial with numerical (approximate)  
coefficients. Mathematica first rationalizes the coefficients, then  
uses exact methods to solve the exact equation, and finally applies N  
to return numerical solutions. To obtain exact solutions mathematica  
uses a whole range of algebraic techniques, including factoring of  
polynomials and root isolation. Unless you are an expert on  
polynomial algebra there is virtually no chance that you could  
implement this in C. Oo the other hand, if you were an expert you  
wouldl not be asking this ...
The alternative approach is to use NSolve instead of Solve. Solving  
numerically univariate polynomial equations is relatively simple, it  
reduces to computing eigenvalue of so called Frobenius matrices. This  
probably could be implemented in a few pages of C code, once you have  
implemented an a program for determining eigenvalues of matrices. You  
can find the information on the required numerical polynomial algebra  
in Hans. J. Stetter, "Numerical Polynomial Algebra", SIAM 2004  
chapters 2 and 5.

Andrzej Kozlowski


  • References:
    • Solve
      • From: R T <chromaticspace@yahoo.com>
  • Prev by Date: Re: Attempt to generalize a constant
  • Next by Date: Re: Re: Mouse controlled 3D rotations
  • Previous by thread: Solve
  • Next by thread: Re: Solve