Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Solving quadratic equation' topicStudent Support Forum > General > Archives > "Solving quadratic equation"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
Author Comment/Response
Bill Simpson
02/02/13 11:41pm

Can you apply something like this?

Some made up b values

In[2]:= b=RandomReal[{-2,2},5]

Out[2]= {-1.60966,0.503958,-1.05172,1.00248,-0.911008}

A made up quadratic that uses one b value each time

In[3]:= sols=t/.Map[Solve[2t^2+# t-6==0,t]&,b]

Out[3]= {{-1.37577,2.1806},{-1.86262,1.61064},{-1.48896,2.01482},{-2.00071,1.49947},{-1.51921,1.97471}}

In[4]:= positivesols=DeleteCases[Flatten[sols],t_/;t<0]

Out[4]= {2.1806,1.61064,2.01482,1.49947,1.97471}

Test this carefully before you depend on it. Note that it doesn't let you know if there were zero, one or two positive roots, it just gives you the positive values.

URL: ,

Subject (listing for 'Solving quadratic equation')
Author Date Posted
Solving quadratic equation matt 02/02/13 3:19pm
Re: Solving quadratic equation Bill Simpson 02/02/13 11:41pm
Re: Solving quadratic equation yehuda 02/03/13 03:23am
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic