
-----------------------------------
SucreTeen123
Tue Apr 17, 2012 8:14 am

Function Help
-----------------------------------
Write a function nsolutions that takes in three real variables a, b, and c as parameters and returns the number of solutions that the quadratic equation ax2+bx+c=0 has. 

please help!!!!

-----------------------------------
smool
Tue Apr 17, 2012 8:16 am

RE:Function Help
-----------------------------------
Well how would you do it on paper?

-----------------------------------
Raknarg
Tue Apr 17, 2012 9:56 am

RE:Function Help
-----------------------------------
Exactly as smool said. A question like this can be completed the exact same way you would in math class.

-----------------------------------
Dreadnought
Tue Apr 17, 2012 1:00 pm

RE:Function Help
-----------------------------------
Are complex solutions allowed? (I'm guessing they aren't because that would seem too easy)

Also, to add to what has been said, make sure your careful with the case where a (and perhaps b) are zero.

-----------------------------------
evildaddy911
Tue Apr 17, 2012 2:47 pm

RE:Function Help
-----------------------------------
do you know the quadratic formula? use it.

-----------------------------------
D_homes
Tue Apr 17, 2012 4:40 pm

RE:Function Help
-----------------------------------
You could use the remainder/factor theorem.

x is a factor (solution) if f(x) = 0

To find the values for x where f(x) could possibly equal zero, divide all the factors of 'a' by all the factors of 'c', and plug those values into the equation.

See: http://www.purplemath.com/modules/factrthm.htm

-----------------------------------
Dreadnought
Tue Apr 17, 2012 5:05 pm

Re: Function Help
-----------------------------------
You could use the remainder/factor theorem.

x is a factor (solution) if f(x) = 0

To find the values for x where f(x) could possibly equal zero, divide all the factors of 'a' by all the factors of 'c', and plug those values into the equation.

He want's to find the number of solutions, not necessarily what they are. Also, we're talking real numbers here, trial and error is not a good idea. For this same reason, factoring is also not possible.

For example, consider x^2 + 0*x - 5. This is a simple polynomial (I'm even using integers), yet trying to get a computer to find the exact values of the solution by trial and error is no walk in the park.

There are easy ways to know how many real solutions exist for a polynomial of at most degree 2.
