Question
Write a function that solves a cubic equation (ax^3+bx^2+cx+d=0, where a,b,c,d are integers) by finding a rational root first, then the remaining two complex solutions.
Write a function that solves a cubic equation (ax^3+bx^2+cx+d=0, where a,b,c,d are integers) by finding a rational root first, then the remaining two complex solutions. Note that your function should work for any cubic equation, not just for the equation in the example, that is, it should find the solutions for a cubic equation with any integer coefficients a, b, c and d. The main body of your function should consist of the following parts:
1. The first step is to find a rational root if there is one. Write a codes that finds a rational root. See the example posted on how to find a rational root. If there is no rational root, stop the entire process.
2. The next step is to find the depressed (quadratic) equation. Write a code that finds the depressed quadratic equation using synthetic division. See the example posted on how to find the depressed equation using synthetic division.
3. Solve the depressed equation. For this part, you can just copy and paste the codes that solves a quadratic equation in complex numbers.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started