3
\$\begingroup\$

Input

  • Your program will take in the integer coefficients of the equation \$ax^3+bx^2+cx+d=0\$ as inputs (a, b, c, and d).

Output

  • All real solutions of the input equation, with an accuracy of at least the thousandths place, sorted from smallest to largest.

Rules

  • Built-in equation solver are not allowed
  • Native math libraries that do not solve equations may be used
  • If you have any questions, please ask in comment

Examples

  1. .

    Input:

    1 2 3 4
    

    Output:

    -1.651
    
  2. .

    Input:

    1 3 0 -1
    

    Output:

    -2.879 -0.653 0.532
    
\$\endgroup\$
9
  • 6
    \$\begingroup\$ Challenges must have an objective scoring criterion. I would recommend code-golf. In future, please post your questions in the Sandbox first to get feedback. Also, disallowing built-in methods tends to lead to a less fun challenge \$\endgroup\$ – pxeger Jan 9 at 13:13
  • 13
    \$\begingroup\$ Also, I'd recommend against strict input/output methods like "separated by spaces", as it makes less of the challenge about solving the problem, but more boring boilerplate I/O logic \$\endgroup\$ – pxeger Jan 9 at 13:22
  • 18
    \$\begingroup\$ I'd strongly suggest loosening the challenge by removing the rules about space-separated input/output, required rounding, and output needing to be sorted. \$\endgroup\$ – xnor Jan 9 at 14:17
  • 4
    \$\begingroup\$ Does the output have to be uniqified, or can numbers repeat multiple times? \$\endgroup\$ – Command Master Jan 9 at 16:49
  • 4
    \$\begingroup\$ This is badly in need of a full explanation and a worked example. \$\endgroup\$ – Shaggy Jan 10 at 0:18

Browse other questions tagged or ask your own question.