Re: Creation and evaluation of polynomials

*To*: mathgroup at smc.vnet.net*Subject*: [mg89454] Re: Creation and evaluation of polynomials*From*: Albert Retey <awnl at arcor.net>*Date*: Tue, 10 Jun 2008 03:39:12 -0400 (EDT)*References*: <g2j05j$510$1@smc.vnet.net>

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 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. hth, albert