Transforming a polynomial into a trigonometric format tia sal2

Discussion in 'Mathematica' started by ratullochjk2, Apr 28, 2008.

  1. ratullochjk2

    ratullochjk2 Guest

    Transforming a polynomial into a trigonometric format tia sal2

    Greetings All

    I'm using mathematica 6 and I have a polynomial and would like to
    convert it into
    a Trigonometric format. Is this possible?

    Example:
    I have a polynomial
    0.00154991- 4.01371 x + 1.81197 x^2 + 8.00183 x^3 - 9.3462 x^4

    How can I transform this into a trigonometric format
    Example:
    0.00596679 Cos[6.98132 x] + 0.00358397 Cos[7.21403 x] +
    2.25013 Sin[0.232711 x] - 4.51511 Sin[0.465421 x]

    Note: these aren't correct answers I just wanted to include and
    example

    tia sal2
     
    ratullochjk2, Apr 28, 2008
    #1
    1. Advertisements

  2. ratullochjk2

    dh Guest

    Hi,

    I do not understand what you mean by:

    "Transforming a polynomial into a trigonometric format"

    Daniel



     
    dh, Apr 29, 2008
    #2
    1. Advertisements

  3. Hello tia sal2,

    I am not sure I understand the question ... Is this what you mean?

    In[175]:= poly =
    0.00154991 - 4.01371 x + 1.81197 x^2 + 8.00183 x^3 - 9.3462 x^4

    Out[175]= 0.00154991- 4.01371 x + 1.81197 x^2 + 8.00183 x^3 -
    9.3462 x^4

    In[176]:= TrigReduce[poly /. x -> Cos[y]]

    Out[176]= -2.59729 + 1.98766 Cos[y] - 3.76711 Cos[2 y] +
    2.00046 Cos[3 y] - 1.16828 Cos[4 y]

    Szabolcs
     
    Szabolcs Horvát, Apr 29, 2008
    #3
  4. Well, as stated, I do not understand what you are trying to do.

    Fourier Series expansion? But your function must be periodic... Anyway,
    you should have a look at the "FourierSeries`" package, it might help
    clarifying what your goal is.

    Non linear approximation? You need to specify an interval... Perhaps
    FindFit is what you are looking for (you may have to try different
    models and intervals, though). For instance,

    poly = 0.00154991 - 4.01371 x + 1.81197 x^2 + 8.00183 x^3 -
    9.3462 x^4;
    data = Table[{x, poly}, {x, -1, 1, .1}];
    model = a Sin[b + c x] + d Cos[e + f x] + g;
    params = {a, b, c, d, e, f, g};
    vars = x;
    sol = FindFit[data, model, params, vars]
    ft = model /. sol
    Plot[{poly, ft}, {x, -1, 1}]

    -740.092 + 1176.29 Cos[0.11808- 0.581571 x] -
    436.92 Sin[1.36856+ 0.965664 x]

    Regards,
    -- Jean-Marc
     
    Jean-Marc Gulliet, Apr 29, 2008
    #4
  5. ratullochjk2

    ratullochjk2 Guest

    I'm sorry if I didn't explain myself better I hope this clarifies it
    better

    when I test for x =3 x= 7 for equation:
    21 - 10 x + x^2 I get zero for both answers

    I used another math program using the ChebyshevT command and I
    got this
    1/2 Cos[2 ArcCos[x]] + 43/2 - 10 x I tested with x=3 and x=7 and I
    also got zero for both

    but when I do a TrigReduce

    In[148] := 21 - 10 x + x^2 /. x -> Cos[y] // TrigReduce

    I get

    Out[149]:= 1/2 (43 - 20 Cos[x] + Cos[2 x])
    x=3 gives me 31.88
    x=7 gives me 14.0293

    I would like to use the ChebyshevT in mathematica 6 because I prefer
    that software but I'm not sure
    how to get the 1/2 Cos[2 ArcCos[x]] + 43/2 - 10 x answer in
    mathematica 6

    Am I doing something wrong with the TrigReduce function or leaving a
    part out why are the answers not even close?

    tia sal2
     
    ratullochjk2, May 1, 2008
    #5
  6. [snip]

    The function you obtain by the replacement rule x -> cos[y] (Note that
    whether TrigReduce is applied or not does not change the overall result)
    is equivalent neither to the original polynomial nor to the Chebyshev
    polynomial.

    Below, you can easily see that the graph of the original polynomial p[x]
    intersects the graph of the "approximation" tt[x] only in two points.
    Note that former is a quadratic whereas the latter is a sinusoid! So the
    transformation does not work.

    In[1]:= p[x_] = 21 - 10 x + x^2
    t[x_] = 1/2 Cos[2 ArcCos[x]] + 43/2 - 10 x // Simplify
    tt[x_] = (21 - 10 x + x^2 /. x -> Cos[y] // TrigReduce) /. y -> x
    Plot[{p[x], t[x], tt[x]}, {x, -10, 10}, PlotStyle -> {Red, Blue, Orange}]
    FindRoot[p[x] == tt[x], {x, 1}]
    FindRoot[p[x] == tt[x], {x, 10}]

    Out[1]=
    2
    21 - 10 x + x

    Out[2]=
    1
    - (43 - 20 x + Cos[2 ArcCos[x]])
    2

    Out[3]=
    1
    - (43 - 20 Cos[x] + Cos[2 x])
    2

    Out[4]= [... plot deleted ...]

    Out[5]= {x -> 0.739085}

    Out[6]= {x -> 10.487}


    Regards,
    -- Jean-Marc
     
    Jean-Marc Gulliet, May 2, 2008
    #6
  7. It is slightly better to localize the symbol a:

    Chebyshev[f_, x_] :=
    Module[{a, n = Exponent[f, x]},
    Sum[a*Cos[i ArcCos[x]], {i, 0, n}] /.
    SolveAlways[f == Sum[a*ChebyshevT[i, x], {i, 0, n}], x][[1]]]

    Andrzej Kozlowski

     
    Andrzej Kozlowski, May 2, 2008
    #7
  8. Hi,

    Actually the TrigReduce approach I posted does the same thing, one
    just has to substitute ArcCos[x] for the y variable. Here's a
    complete function:

    chebyshev2[f_, x_] :=
    Module[{y}, [email protected][f /. x -> Cos[y]] /. y -> ArcCos[x]]

    (Applying Expand is not really necessary. In this case it ensures
    that chebyshev[] will give the result in the same form as
    Chebyshev[].)

    Szabolcs

     
    Szabolcs Horvát, May 2, 2008
    #8
  9. I think what you want is this function:


    Chebyshev[f_, x_] :=
    With[{n = Exponent[f, x]},
    Sum[a*Cos[i ArcCos[x]], {i, 0, n}] /.
    SolveAlways[f == Sum[a*ChebyshevT[i, x], {i, 0, n}], x][[1]]]

    So now, for example:

    Chebyshev[21 - 10*x + x^2, x]
    -10*x + (1/2)*Cos[2*ArcCos[x]] + 43/2

    TrigExpand[%]
    x^2 - 10*x + 21

    Chebyshev[21 - 10*x + x^2 + 3*x^3, x]
    -((31*x)/4) + (1/2)*Cos[2*ArcCos[x]] + (3/4)*Cos[3*ArcCos[x]] + 43/2


    and so on.

    Andrzej Kozlowski


     
    Andrzej Kozlowski, May 2, 2008
    #9
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.