How to plot polynomial equation numerically?

I have a polynomial that I want to plot (x vs t) from t=0:0.01:1 for the following equation:
2*x*(1-x^-3)+sin(t)*(x-1)+3*sin(t)*(x-1)=0
Is there a simple way to do this?

4 commentaires

James Tursa
James Tursa le 31 Mar 2015
Modifié(e) : James Tursa le 31 Mar 2015
Do you mean you want to solve for the roots of the equation (in x) as a function of t? Also, you have x^-3 so strictly speaking this isn't a polynomial to begin with, although you can multiply through by x^3 to get one. (And then (x-1) will be a common factor to all terms that can be factored out giving one obvious root of x = 1)
Tony Earl
Tony Earl le 31 Mar 2015
Yes, but then I want to be able to plot x=x(t).
James Tursa
James Tursa le 31 Mar 2015
Why do you have sin(t)*(x-1) + 3*sin(t)*(x-1)? Isn't this just 4*sin(t)*(x-1) or is this a typo?
Tony Earl
Tony Earl le 31 Mar 2015
Sorry, you are correct. The full equation I'm trying to solve is really long so I tried simplifying it, but incorrectly did that. How about:
2*x*(x^2+x^-1)*(1-x^-3)+sin(t)*(x/sin(t)-1)+3*(x-1)=0
Thanks for your help and patience.

Connectez-vous pour commenter.

Réponses (2)

Image Analyst
Image Analyst le 31 Mar 2015

0 votes

So how about making up 2 arrays, one for t and one for x, then create a 2D array with a double "for" loop - basically an image of the values - then use imshow() to display it? Use contour of thresholding to show where the function is above or below zero.
James Tursa
James Tursa le 31 Mar 2015

0 votes

Using your latest equation I don't see any obvious simplifications. So maybe just multiply the whole thing by x^4 (to give you a polynomial in x), collect terms on powers of x, then write a loop over t=0:0.01:1 to evaluate the coefficient vector and feed this to the roots function to get your values. Then plot the results.

Catégories

En savoir plus sur Polynomials dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by