- #1
gelbehahn
- 2
- 0
Hello,
I'm making now a simple program (in Fortran 77) to find the roots of the quadratic function. When the discriminant is negative, imaginary numbers are to be used and the solution of the function is a complex number.
I'd like to define a complex variable so that:
complex x
x = ((-b)/(2*a),sqrt(disc)/(2*a))
where a and b are the variables of the quadratic function, and disc is the discriminant, previously calculated. But when I try to compile it, it says 'invalid complex constant', for what I guess it takes x as a constant and not as a variable... How can I define a complex variable or how can I solve the equation considering complex solutions? I'm doing something wrong but I do not realize...
Thanks a lot for your help!
Alfonso
I'm making now a simple program (in Fortran 77) to find the roots of the quadratic function. When the discriminant is negative, imaginary numbers are to be used and the solution of the function is a complex number.
I'd like to define a complex variable so that:
complex x
x = ((-b)/(2*a),sqrt(disc)/(2*a))
where a and b are the variables of the quadratic function, and disc is the discriminant, previously calculated. But when I try to compile it, it says 'invalid complex constant', for what I guess it takes x as a constant and not as a variable... How can I define a complex variable or how can I solve the equation considering complex solutions? I'm doing something wrong but I do not realize...
Thanks a lot for your help!
Alfonso