Student Support Forum: 'Finding roots of a third degree polynomial' topicStudent Support Forum > General > Archives > "Finding roots of a third degree polynomial"

 < Previous Comment | Next Comment > Help | Reply To Comment | Reply To Topic
 Author Comment/Response Bill Simpson 08/02/13 12:19pm It looks like your picture is gone from the website so I have to guess a little, but perhaps you can see how to apply this to your actual problem. Any time, almost every time, you "want to do the same thing to every item in a list" the thing to think of is the Map[] function. That takes items out of a list one at a time, does what you define to the item and then gives you back a list of all the results. Example: In[28]:= A = {1, 3, 5}; B = {2, 2, 4}; cubic[coeffs_] := First[coeffs]*x^3 + x^2 - x + Last[coeffs] == 0; Map[{N[Reduce[cubic[#], x, Cubics -> True]]} &, Transpose[{A, B}]] Out[31]= { {x == -2. || x == 0.5 + 0.866025 I || x == 0.5 - 0.866025 I}, {x == -1.1394 || x == 0.403034 + 0.650128 I || x == 0.403034 - 0.650128 I}, {x == -1.07635 || x == 0.438174 + 0.742468 I || x == 0.438174 - 0.742468 I} } So I was guessing you had separate lists A and B, but you want to use corresponding elements from both lists to solve a cubic. Transpose[] will pair up those coefficients. You want to do the same thing to every pair of coefficients, so Map[]. There are multiple different ways to find the roots of a cubic, Reduce[] is one, but you can substitute others and gain experience with each. The last detail is how to get the two coefficients into a cubic equation. Transpose is going to give you {{a1,b1},{a2,b2},...}. Map is going to hand your function {a1,b1} the first time and {a2,b2} the second time,... There are several different notations that can be used for the function inside Map[] and that can be confusing until you have used it enough to see how it works. I just picked one method. That defines the function cubic[] which accepts a list of two items {a1,b1}, extracts a1 and b1 and forms your cubic to find the roots. Experiment with this, change it to match your actual data and equation, even try different functions inside the Map[] until you have mastered this. URL: ,

 Subject (listing for 'Finding roots of a third degree polynomial') Author Date Posted Finding roots of a third degree polynomial Tibor Kuna 08/01/13 5:32pm Re: Finding roots of a third degree polynomial Bill Simpson 08/02/13 12:19pm Re: Re: Finding roots of a third degree polynom... Tibor Kuna 08/05/13 07:23am
 < Previous Comment | Next Comment > Help | Reply To Comment | Reply To Topic