MathGroup Archive 2008

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

Search the Archive

Re: Creation and evaluation of polynomials


> 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

Why are you converting to strings and back? This is not only wasting CPU
time but also asking for problems which the one you report is one...

> 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.

since I can't try your could without knowing the/a definition of your
function polynomial, I can only guess: Try

D[ToExpression[ToString[polynomial[{1,0,0,0,1,0,1}],InputForm], x]

If that also doesn't work, check what the string looks like and see
whether that gives a hint about what the problem could be.

> Somebody knows how to solve it?

Other than the above: Don't convert to strings and back, it doesn't seem
to make sense at all.



  • Prev by Date: Kernel crash: Array with NaN elements via NETLink
  • Next by Date: Re: Creation and evaluation of polynomials
  • Previous by thread: Re: Creation and evaluation of polynomials
  • Next by thread: Re: Creation and evaluation of polynomials