Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

6. (7 points) Your Algebra I teacher probably drilled the quadratic formula into your head, which allows you to solve quadratic equations of the form

image text in transcribed
6. (7 points) Your Algebra I teacher probably drilled the quadratic formula into your head, which allows you to solve quadratic equations of the form ax2 + bx + c = 0. Not many people are aware that a formula also exists to solve cubic equations of the form x + px +q = 0 Using some algebraic wizardry, any cubic equation in the general form ax3 + bx2 + cx + d = 0 can be reduced to the form of equation (1). But let's not worry about how to do that here. Equation (1) is solvable using Cardano's formula, named after the Italian mathematician who allegedly derived it during the 1500s. The formula states that the solution is: (1) 27 27 (2) For now, let's consider only the real (i.e., non-imaginary) values of the quantities in (2). This means the formula will give only one of the three roots to (1). Write a program named CubicSolver.java that allows the user to enter values (potentially including decimals) for the coefficients p and q from (1). Your program should then compute and display the value of the solution x according to (2). Note that although using Math.pow with an exponent of 1.0/3 works for computing cube roots of positive numbers, Math.pow gives a result of NaN ("not a number") when computing the cube root of a negative number. Use Math.cbrt() instead; you can replace x with whatever you're trying to find the cube root of Example program run (underlined parts indicate what the user enters) Cubic Equation Solver Enter your coefficients: What is the value of p? 1 What is the value of q? 30 The solution X is -2.9999999999999742

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Language in Context?

Answered: 1 week ago