Answer to Question #188316 in Quantitative Methods for Salah yahye

Question #188316

(a) Solve the following equation correct to 5 significant figures using Newton’s Method. 4x−sin(x 2 ) +e −2x −x 3 −x 2 +2 = 0 Take the initial guess as x0 = 1.75.

(b) Solve the following equation correct to 5 significant figures using Secant Method. e 2x −x 2 −x−7 = 0 The root must be in the interval [1,1.3].

(c) Solve the following equation correct to 5 significant figures using Bisection Method. x sin(2x) +e 2x +3x−3 = 0 The root must be in the interval [0,0.5].

(d) [ The Newton-Raphson Method ] Perform two iterations to find a real root of the equations y 2 −5y+4 = 0 3yx2 −10x+7 = 0 using the Newton-Rhaphson method and let x0 = y0 = 0.5.

(e) Find a recurrence formula for solving √7 6 and hence approximate its value correct to 5 significant figure. HINT: Apply Newton-Raphson Method


1
Expert's answer
2021-05-07T10:33:17-0400

(a)

#include <iostream>

#include<math.h>
using namespace std;
double f(double x)
{
    return (4*x-sin(x*x)+pow(M_E,-2*x)-x*x*x -x*x +2);
}
double df(double x)
{
    return (4-cos(x*x)*2*x+pow(M_E,-2*x)*(-2)-3*x*x -2*x );
}


int main() {
    double x0=1.75;
    double epsilon=5e-6;
    double xn,xn_1;
    xn=100;xn_1=x0;
    xn=xn_1-f(xn_1)/df(xn_1);
    cout<<xn<<'\n';
    while(abs(xn-xn_1)>epsilon)
    {
        xn_1=xn;
        xn=xn_1-f(xn_1)/df(xn_1);
        cout<<xn<<'\n';
    }


  
}

"x_1=1.85065;x_2=1.84194;x_3=1.84185;x_5=1.84185;"

answer:1.84185

(b)

#include <iostream>
#include<math.h>
using namespace std;
double f(double x)
{
    return (pow(M_E,2*x)-x*x-x-7);
}


int main() {
    double x0=1;
    double x1=1.3;
    double epsilon=5e-6;
    double xn,xn_1,xn_2;
    xn=100;xn_2=x0;xn_1=x1;
    xn=(xn_2*f(xn_1)-xn_1*f(xn_2))/(f(xn_1)-f(xn_2));
    cout<<xn<<'\n';
    while(abs(xn-xn_1)>epsilon)
    {   
        xn_2=xn_1;
        xn_1=xn;
        xn=(xn_2*f(xn_1)-xn_1*f(xn_2))/(f(xn_1)-f(xn_2));
        cout<<xn<<'\n';
    }


  
}

"x_2=1.09505;x_3=1.1142;x_4=1.11891;x_5=1.11878;x_6=1.11878;"

answer:1.11878

(c)

#include <iostream>
#include<math.h>
using namespace std;
double f(double x)
{
    return (x*sin(2*x)+pow(M_E,2*x)+3*x-3);
}


int main() {
    double left=0.0;
    double right=0.5;
    double epsilon=1e-6;
    double midle=(left+right)/2;
    cout<<midle<<'\n';
    while(abs(right-midle)>epsilon)
    {   
        if(abs(f(midle))<epsilon)
        {
            break;
        }
        if(f(right)*f(midle)<=0.0)
        {
            left=midle;
        }
        else
        {
            right=midle;
        }
        midle=(left+right)/2;
        cout<<midle<<'\n';
    }


  

}

midle series:

0.25

0.375

0.3125

0.34375

0.328125

0.320312

0.316406

0.314453

0.313477

0.313965

0.313721

0.313843

0.313904

0.313934

0.31395

0.313957

0.313953

0.313955

0.313956

answer :0.313956

(d)

#include <iostream>
#include<math.h>
using namespace std;
double f1(double x, double y)
{
    return (y*y-5*y+4);
}
double f2(double x, double y)
{
    return (3*x*x*y-10*x+7);
}
double df1_dx(double x, double y)
{
    return (0);
}
double df1_dy(double x, double y)
{
    return (2*y-5);
}
double df2_dx(double x, double y)
{
    return (6*x*y-10);
}
double df2_dy(double x, double y)
{
    return (3*x*x);
}
int main() {
    double x0=0.5;
    double y0=0.5;
    double epsilon=1e-6;
    double xn,yn,xn_1=x0,yn_1=y0;
    double W[2][2];
    double W_1[2][2];
    W[0][0]=df1_dx(xn_1,yn_1);
    W[0][1]=df1_dy(xn_1,yn_1);
    W[1][0]=df2_dx(xn_1,yn_1);
    W[1][1]=df2_dy(xn_1,yn_1);


    double detW=W[0][0]*W[1][1]-W[0][1]*W[1][0];


    W_1[0][0]=W[1][1]/detW;
    W_1[0][1]=-W[0][1]/detW;
    W_1[1][0]=-W[1][0]/detW;
    W_1[1][1]=W[0][0]/detW;
    
    xn=xn_1-W_1[0][0]*f1(xn_1,yn_1)-W_1[0][1]*f2(xn_1,yn_1);
    yn=yn_1-W_1[1][0]*f1(xn_1,yn_1)-W_1[1][1]*f2(xn_1,yn_1);


    cout<<xn<<"    "<<yn<<'\n';
    int i=2-1;
    while(i>0)
    {   
        xn_1=xn;
        yn_1=yn;
    W[0][0]=df1_dx(xn_1,yn_1);
    W[0][1]=df1_dy(xn_1,yn_1);
    W[1][0]=df2_dx(xn_1,yn_1);
    W[1][1]=df2_dy(xn_1,yn_1);


    double detW=W[0][0]*W[1][1]-W[0][1]*W[1][0];


    W_1[0][0]=W[1][1]/detW;
    W_1[0][1]=-W[0][1]/detW;
    W_1[1][0]=-W[1][0]/detW;
    W_1[1][1]=W[0][0]/detW;
    
    xn=xn_1-W_1[0][0]*f1(xn_1,yn_1)-W_1[0][1]*f2(xn_1,yn_1);
    yn=yn_1-W_1[1][0]*f1(xn_1,yn_1)-W_1[1][1]*f2(xn_1,yn_1);


    cout<<xn<<"    "<<yn<<'\n';
    i--;
    }


  
}

"x_1=0.818015 ,x_2=0.970791,y_1=0.9375y2=0.99875"

(e)

"x^2-76=0;x_0=8;"

#include <iostream>
#include<math.h>
using namespace std;
double f(double x)
{
    return (x*x-76);
}


double df_dx(double x)
{
    return (2*x);
}
int main() {
    double x0=8;
    double epsilon=1e-6;
    double xn,xn_1=x0;
    double W[1][1];
    double W_1[1][1];
    W[0][0]=df_dx(xn_1);
    



    W_1[0][0]=1/W[0][0];
    
    xn=xn_1-W_1[0][0]*f(xn_1);
    cout<<xn<<'\n';
    while(abs(xn-xn_1)>epsilon)
    {   
        xn_1=xn;
    W[0][0]=df_dx(xn_1);
    
    


    W_1[0][0]=1/W[0][0];
    
    xn=xn_1-W_1[0][0]*f(xn_1);


    cout<<xn<<'\n';
    }


  
}

"x_1=8.75;x_2=8.71786;x_3=8.7178;x_4=8.7178;"

answer:8.7178




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
15.07.21, 23:43

Dear Salah Yahya, please use the panel for submitting a new question.


Salah yahye
26.06.21, 15:42

Analyze factors that cause and maintain global stratification

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS