(C++)
Solve the following polynomial using Newton’s method.
X4+ 2x3-9x2-2x +8 = 0
For a root that lies between x=-2 and x= -10.
Print out for each iteration the current x, stop when the solution is within 10-5
// f( x(n) )
// x(n+1) = x(n) - -----------------
// f'( x(n) )
// find root of f(x) = x^4 + 2x^3 -9x^2 -2x +8 upto 3 decimal places
// So, f'(x) = 4x^3 + 6x^2 - 18x
// f(-10) = 7128
// f(-2) = -24
// as the sign is different, so the root lies in between [ -10 , -2 ]
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int n = 5;
// initially set the x(n) root to right bound
double x_n = -10;
// calculate f(x(n))
double f_x = pow( x_n, 4 ) + 2 * pow( x_n, 3 ) - 9 * pow( x_n, 2 ) - 2 * x_n + 8;
// calculate f'(x(n))
double f_der_x = 4 * pow( x_n, 3 ) + 6 * pow( x_n, 2 ) - 18 * x_n;
// calculate x(n+1)
double x_n_1 = x_n - ( f_x / f_der_x );
while(true)
{
// if the root is correct upto n decimal places
if( abs( x_n_1 - x_n ) < pow( 0.1, n ) )
break;
// set x(n+1) as the x(n) th root
x_n = x_n_1;
cout<<"x : "<<x_n<<endl;
// calculate f(x(n))
f_x = pow( x_n, 4 ) + 2 * pow( x_n, 3 ) - 9 * pow( x_n, 2 ) - 2 * x_n + 8;
// calculate f'(x(n))
f_der_x = 4 * pow( x_n, 3 ) + 6 * pow( x_n, 2 ) - 18 * x_n;
// calculate x(n+1)
x_n_1 = x_n - ( f_x / f_der_x );
}
cout<<"Root lies at x = "<<x_n;
return 0;
}
Sample Output
(C++) Solve the following polynomial using Newton’s method. X4+ 2x3-9x2-2x +8 = 0 For a root...
Use bisection to solve for the root of: f(x) = x + ln(x) It is known that the solution lies between 0.1 and 1.0 Print out your solution at each iteration.
Solve the following system of equations using Gauss-Seidel method. 3x1 +6x2 +2x3 = 9 12% + 7x2 +3x,-17 2x, +7x2 -11x, 49 Conduct 3 iterations. Calculate the maximum absolute relative approximate error at the end of each iteration, and Choose [x, ]-l 3 5las your initial guess.
Use factoring and the root method to solve the polynomial equation 0.1x3-9x = 0 (U c) 0.3 10
Find solution using Simplex method (BigM method) MAX Z = 5x1 + 3x2 + 2x3 + 4x4 subject to 5x1 + x2 + x3 + 8x4 = 10 2x1 + 4x2 + 3x3 + 2x4 = 10 X j > 0, j=1,2,3,4 a) make the necessary row reductions to have the tableau ready for iteration 0. On this tableau identify the corresponding initial (artificial) basic feasible solution. b) Following the result obtained in (a) solve by the Simplex method, using...
3. Solve the following systems of equations using Gaussian elimination. (a) 2x 3x2 + 2x3 = 0 (d) 2x + 4x2 2.xz 4 *- x2 + x3 = 7 X; - 2x2 · 4x3 = -1 -X, + 5x2 + 4x3 = 4 - 2x - X2 3x3 = -4
true or false numarical method rd wneh the correct answer for the following statements: 1 Errors resulting from pressing a wrong button are called blunders 2. Using the bisection method to solve fx)-+5 between x -2 and x 0, there is surely a root between -2 and-1. 3. )Single application of the trapezoidal rule is the most accurate method of numerical integration. 4. Newton-Raphson method is always convergent. 5. ()The graphical method is the most acurate method to solve systems...
Use the Gaussian elimination method to solve each of the following systems of linear equations. In each case, indicate whether the system is consistent or inconsistent. Give the complete solution set, and if the solution set is infinite, specify three particular solutions. 1-5x1 – 2x2 + 2x3 = 14 *(a) 3x1 + x2 – x3 = -8 2x1 + 2x2 – x3 = -3 3x1 – 3x2 – 2x3 = (b) -6x1 + 4x2 + 3x3 = -38 1-2x1 +...
Q.1 Using the method of Triangular Decomposition solve the set of equations. Xı - 2x2 + 3x3 - X4 = -3 3x1 + x2-3x3 +2x4 = 14 5xi +3x2+2x3 + 3x4 = 21 2x1 - 4x2 – 2x3 + 4x4 = -10 If Ax = 2x, determine the eigenvalues and corresponding eigenvectors of -3 0 6 4 10 - 8 A 4 5 3 B= 1 2 1 1 2 1 -1 2 3 Q.2
Problem 1. In each part solve the linear system using the Gauss-Jordan method (i.e., reduce the coefficent matrix to Reduced Row Ech- elon Form). Show the augmented matrix you start with and the augmented matrix you finish with. It's not necessary to show individual row operations, you can just hit the RREF key on your calculator 2x 1 + 3x2 + 2x3 = -6 21 +22-23 = -1 2.1 + 22 - 4.03 = 0 x + 3x2 + 4x3...
Using the Bisection method, find an approximate root of the equation sin(x)=1/x that lies between x=1 and x=1.5 (in radians). Compute upto 5 iterations. Determine the approximate error in each iteration. Give the final answer in a tabular form.