Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(b) It is required to solve a cubic equation of the form x3 - bx - c0. AC rogram

ID: 3913828 • Letter: #

Question

(b) It is required to solve a cubic equation of the form x3 - bx - c0. AC rogram is expressing to be developed to find one of the three roots of the cubic equation by the cubic equation as follows: This form can be used to find one of the roots iteratively as follows: Tn-1 Where the subscript n has been used to denote the result at a given iterative step Write a program to solve the equation by performing a suitable number of iterations. You need to set suitable conditions to decide when to stop iterating without causing undue computational load while obtaining a result of acceptable accuracy. The condition for stopping to iterate should also take care of situations that do not converge, and should report such cases to the user. The user should be requested to enter an initial value xo to start the iterations. [15 marks

Explanation / Answer

Please find the code below.

CODE

===============

#include <stdio.h>

#include <math.h>

#define ERROR 0.00001 // error threshold

int main() {

double b, c, x0;

printf("Enter the value of b and c (for eq. x^3 -bc - c = 0) : ");

scanf("%lf%lf", &b, &c);

printf("Enter the value of x0 : ");

scanf("%lf", &x0);

double xn;

while(1) {

xn = sqrt(b + c/x0);

if(abs(xn - x0) < ERROR) {

printf("The error margin is less than %lf, hence stop iterating now!!", ERROR);

printf("The root is : %lf", xn);

break;

}

x0 = xn;

}

return 0;

}