Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

function [val] = f(x) val = ( x .^ 6 ) - 5 * ( x .^ 2 ) + 3; end f_0 = f

function [val] = f(x)

val = ( x .^ 6 ) - 5 * ( x .^ 2 ) + 3;

end

f_0 = f(0); f_1 = f(1);

fprintf('f(0) : %f f(2) : %f ' , f_0 , f_1);

if f_0 * f_1 0

a = 0;

b = 2;

error = 0.5 * ( 10^-5 );

pre = 0.0;

x = ( a + b ) / 2;

while true

if abs( x - pre ) error

break;

end

f_x = f(x);

if f(a) >= 0 && f(b) 0

if f_x > 0

a = x;

else

b = x;

end

else

if f_x > 0

b = x

else

a = x;

end

end

pre = x

x = ( a + b ) / 2;

end

fprintf('Root lies at x = %f ' , x);

else

fprintf('As the sign of f(0) and f(1) is same. SO, no root exists between [0 , 1] ');

end

image text in transcribed

Question2 8 pts Write no more than two lines of MATLAB find the root of the function fx)-xA6-5xA2+3 that is between 0 and 1. Your code should have a call to your bisection code which you wrote for this lab but you do not need to include the bisection code. code (including 1 for an anonymous function) that will approximately HTML Editor Paragraph

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

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions