Computer Science Canada Function Help |
Author: | SucreTeen123 [ Tue Apr 17, 2012 8:14 am ] |
Post subject: | 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!!!! |
Author: | smool [ Tue Apr 17, 2012 8:16 am ] |
Post subject: | RE:Function Help |
Well how would you do it on paper? |
Author: | Raknarg [ Tue Apr 17, 2012 9:56 am ] |
Post subject: | RE:Function Help |
Exactly as smool said. A question like this can be completed the exact same way you would in math class. |
Author: | Dreadnought [ Tue Apr 17, 2012 1:00 pm ] |
Post subject: | 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. |
Author: | evildaddy911 [ Tue Apr 17, 2012 2:47 pm ] |
Post subject: | RE:Function Help |
do you know the quadratic formula? use it. |
Author: | D_homes [ Tue Apr 17, 2012 4:40 pm ] |
Post subject: | 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 |
Author: | Dreadnought [ Tue Apr 17, 2012 5:05 pm ] |
Post subject: | Re: Function Help |
D_homes wrote: 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. |