Numerical Analysis Matlab Use single variable method write

Numerical Analysis

Matlab

Use single - variable method write a matlab code to show how do you run this algorithm

Given the function ƒ(x) = sin(x) - e^x + 2 Find the minimum value in [a, b]=[-1, 3]. Starting from the leftmost end point and move toward to rightmost end point (i.e forth) with your first x = (b - a)/4 = (3 - (-1))/4 = 1 Stop the iteration when your x 0.01

Solution

clear all

clc

a=-1;

b=3;

dx=(b-a)/4;

fa=sin(a*57.2958)-exp(a)+2

fb=sin(b*57.2958)-exp(b)+2

fdx=sin(57.2958)-exp(dx)+2

if fa*fdx<0

    disp(\'minimum lies between a and dx\')

    b=dx

    a=a

    dx=(b-a)/4

else

   disp(\'minimum does not lies between a and dx\')

end

    fa=sin(a*57.2958)-exp(a)+2

    fb=sin(b*57.2958)-exp(b)+2

    fdx=sin(dx*57.2958)-exp(dx)+2

    if fa*fdx<0

    disp(\'minimum lies between a and dx\')

    b=dx

    a=a

    dx=(b-a)/4

else

   disp(\'minimum does lies between dx and b\')

   a=dx

   b=b

   dx=(b-a)/4

    end

    fb=sin(b*57.2958)-exp(b)+2

    fdx=sin(dx*57.2958)-exp(dx)+2

    if fa*fdx<0

    disp(\'minimum lies between a and dx\')

    b=dx

    a=a

    dx=(b-a)/4

else

   disp(\'minimum does lies between dx and b\')

   a=dx

   b=b

   dx=(b-a)/4

    end

    fa=sin(a*57.2958)-exp(a)+2

    fb=sin(b*57.2958)-exp(b)+2

    fdx=sin(dx*57.2958)-exp(dx)+2

    if fa*fdx<0

    disp(\'minimum lies between a and dx\')

    b=dx

    a=a

    dx=(b-a)/4

else

   disp(\'minimum does lies between dx and b\')

   a=dx

   b=b

   dx=(b-a)/4

    end

    fa=sin(a*57.2958)-exp(a)+2

    fb=sin(b*57.2958)-exp(b)+2

    fdx=sin(dx*57.2958)-exp(dx)+2

    if fa*fdx<0

    disp(\'minimum lies between a and dx\')

    b=dx

    a=a

    dx=(b-a)/4

else

   disp(\'minimum does lies between dx and b\')

   a=dx

   b=b

   dx=(b-a)/4

    end

fdx=sin(dx*57.2958)-exp(dx)+2

fa=sin(a*57.2958)-exp(a)+2

    fb=sin(b*57.2958)-exp(b)+2

    fdx=sin(dx*57.2958)-exp(dx)+2

    if fa*fdx<0

    disp(\'minimum lies between a and dx\')

    b=dx

    a=a

    dx=(b-a)/4

else

   disp(\'minimum does lies between dx and b\')

   a=dx

   b=b

   dx=(b-a)/4

    end

fdx=sin(dx*57.2958)-exp(dx)+2

fa=sin(a*57.2958)-exp(a)+2

    fb=sin(b*57.2958)-exp(b)+2

    fdx=sin(dx*57.2958)-exp(dx)+2

    if fa*fdx<0

    disp(\'minimum lies between a and dx\')

    b=dx

    a=a

    dx=(b-a)/4

else

   disp(\'minimum does lies between dx and b\')

   a=dx

   b=b

   dx=(b-a)/4

    end

fdx=sin(dx*57.2958)-exp(dx)+2

fa=sin(a*57.2958)-exp(a)+2

    fb=sin(b*57.2958)-exp(b)+2

    fdx=sin(dx*57.2958)-exp(dx)+2

    if fa*fdx<0

    disp(\'minimum lies between a and dx\')

    b=dx

    a=a

    dx=(b-a)/4

else

   disp(\'minimum does lies between dx and b\')

   a=dx

   b=b

   dx=(b-a)/4

    end

fdx=sin(dx*57.2958)-exp(dx)+2

fa=sin(a*57.2958)-exp(a)+2

    fb=sin(b*57.2958)-exp(b)+2

    fdx=sin(dx*57.2958)-exp(dx)+2

    if fa*fdx<0

    disp(\'minimum lies between a and dx\')

    b=dx

    a=a

    dx=(b-a)/4

else

   disp(\'minimum does lies between dx and b\')

   a=dx

   b=b

   dx=(b-a)/4

    end

fdx=sin(dx*57.2958)-exp(dx)+2

fa=sin(a*57.2958)-exp(a)+2

    fb=sin(b*57.2958)-exp(b)+2

    fdx=sin(dx*57.2958)-exp(dx)+2

    if fa*fdx<0

    disp(\'minimum lies between a and dx\')

    b=dx

    a=a

    dx=(b-a)/4

else

   disp(\'minimum does lies between dx and b\')

   a=dx

   b=b

   dx=(b-a)/4

    end

fdx=sin(dx*57.2958)-exp(dx)+2

Numerical Analysis Matlab Use single - variable method write a matlab code to show how do you run this algorithm Given the function ƒ(x) = sin(x) - e^x + 2 Find
Numerical Analysis Matlab Use single - variable method write a matlab code to show how do you run this algorithm Given the function ƒ(x) = sin(x) - e^x + 2 Find
Numerical Analysis Matlab Use single - variable method write a matlab code to show how do you run this algorithm Given the function ƒ(x) = sin(x) - e^x + 2 Find
Numerical Analysis Matlab Use single - variable method write a matlab code to show how do you run this algorithm Given the function ƒ(x) = sin(x) - e^x + 2 Find
Numerical Analysis Matlab Use single - variable method write a matlab code to show how do you run this algorithm Given the function ƒ(x) = sin(x) - e^x + 2 Find

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site