I am working on a problem to find the discriminant of the quadratic equation b2-4ac and have encountered difficulties in finding the complex solution when the discriminant is less than 0 and only complex solutions exist.
If the discriminant is less than 0 i am supposed to get an imaginary number consisting of two parts, real part and imaginary part written as x + jy, where x and y are real value j is defined as the square root of -1.
I am completely stuck at this point and have no idea what is expected of me other than the fact that I am supposed to design a class for the calculation of the complex number.
I would really appreciate it if someone could give me a pointer as to how I could go about this. below is the code that I have so far
I am completely stuck at this point and have no idea what is expected of me other than the fact that I am supposed to design a class for the calculation of the complex number
Why not use std::complex?
Other than that, where is your problem? Do you know how complex numbers "work", i.e. can you perform calculations with them on the paper? Do you know what the root of a polynomial is, and why you might find some in C?
Hi there thank you for your reply, to be honest I have only come across complex numbers for the first time this week and other than the fact that come in two parts real and imaginary i am not sure of much else.
what is std::complex?
My question really is how I would go about calculating the values of x1 and x2 in the NoSolution() function.
std::complex is the C++ standard type for complex numbers.
My question really is how I would go about calculating the values of x1 and x2 in the NoSolution() function.
Why are there (2) solutions? (hint: fundamental theorem of algebra).
What is (in respect to your polynomial) the property of the two solutions?
It pretty much seems to me that your problem is not C++ related, but rather math-related. Since I assume that you are expected to understand the math, which you won't if someone just posts the solution, I'll let you try a little. If you hit trouble, just say what exactly it is you don't understand or where you are stuck. (Yes, that's mean, but that's what I am)