solving Quadratic equation.

I've seen the example of solving quadratic equation. [a^x^x + b^x +c = 0].
from http://www.cplusplus.com/forum/general/36313/.
It work on real solution.
is it possible to calculate the imaginary solution ? I mean is it possible to calculate squared root of (-(b-4ac)). I don't talk to use sqrt() function, But any way.
Last edited on
Yep, you can use the complex number class provided by the standard library: http://www.cplusplus.com/reference/complex/

For example, you can use this func to do the square root:
http://www.cplusplus.com/reference/complex/sqrt/
Hi,

There's also an example on this site at: http://www.cplusplus.com/forum/beginner/480/

Larry
yes.

1
2
3
4
5
6
7
8
9
10
11
12
13
switch(((b^2) - (4 * a * c)) >= 0)
{
    case true:
    {
         //You hahve a non-imagneary
    }
    break;
    case false:
    {
        //you have an imaginary.  Do the math
    }
    break;
}


It's really quite simple.
Last edited on
Topic archived. No new replies allowed.