1-4-20: Finding the root of a unary two-second equation

Source: Internet
Author: User
Describe

Use the formula X1 = (-B + sqrt (b*b-4*a*c))/(2*a), x2 = (-b-sqrt (b*b-4*a*c))/(2*a) to find a unary two-time equation ax2+ bx + c =0 Root, where a is not equal to 0.

Input
Enter a row containing three floating-point numbers A, B, C (they are separated by a space), representing the coefficients of the equation ax2 + bx + C =0, respectively.
Output
Outputs a line that represents the solution of the equation.
If two real roots are equal, the output form is: x1=x2= ....
If two real roots range, then the output form is: x1= ...; x2 = ..., where x1<x2.
If two virtual root, then output: x1= real part + imaginary Part I; x2= Real-imaginary Part I, where x1,x2 satisfies one of the following two conditions:
1. The real part of X1 is greater than the real part of X2
2. The real part of the X1 is equal to the real part of the X2 and the imaginary part of the X1 is greater than or equal to X2.

All real numbers are required to be accurate to 5 digits after the decimal point, with no spaces between the numbers and symbols.
Sample input
1.0 2.0 8.0
Sample output
x1=-1.00000+2.64575i;x2=-1.00000-2.64575i
Source
1709

1-4-20: Finding the root of a unary two-second equation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.