MathGroup Archive 2008

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

Search the Archive

Re: Creation and evaluation of polynomials

  • To: mathgroup at smc.vnet.net
  • Subject: [mg89450] Re: Creation and evaluation of polynomials
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Tue, 10 Jun 2008 03:38:26 -0400 (EDT)
  • Organization: Uni Leipzig
  • References: <g2j05j$510$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de

Hi,

imaging that *we* have no function that is able to create
the polynomial p^5 + 3p^2 from the invalid Mathematica
input.

All your ToString[]/ ToExpression[] is complete nonsense.

But imaging that

polynomial[lst_, var_: x] := Plus @@ MapIndexed[#1*var^(#2[[1]]-1) &, lst]

create a polynomial, than

D[polynomial[{1, 0, 0, 0, 1, 0, 1}], x]

compute the derivative

and

NSolve[polynomial[{0, 2, 1}] == x, x]

will find the numerical roots.

Regards
   Jens


jmgomezgoo at gmail.com wrote:
> Hi!
> 
> Image we have a function that create a Polynomial:
> 
> polynomial[{1,0,0,0,1,0,1,}] -> p^5 + 3p^2
> 
> And we want to calulate roots and the derivate of this polynomial.
> 
> I try with ToString[polynomial[{1,0,0,0,1,0,1}]] in order to use
> convert the polynomial expression to string first and later use
> 
> ToExpression[]
> 
> and calculate roots
> 
> D[ToExpression[ToString[polynomial[{1,0,0,0,1,0,1}]], x]
> 
> like the next examples:
> 
> D[ToExpression["x^2+2x"], x]
> 
> or
> 
> NSolve[ToExpression["x^2+2x==x"], x]
> 
> 
> But ToString erase ^ symbol.
> 
> Somebody knows how to solve it?
> 
> 
> Warm regards
> -jm
> 
> 
> 


  • Prev by Date: Re: ListAnimate or movie with No AppearanceElements
  • Next by Date: Re: ListAnimate or movie with No AppearanceElements
  • Previous by thread: Re: Creation and evaluation of polynomials
  • Next by thread: Re: Creation and evaluation of polynomials