Question

Use bisection to solve for the root of: f(x) = x + ln(x) It is known...

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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

%%equation is x + ln(x)

%%initial guesses
disp('when x range between 0.1 and 1.0 ');
xl = 0.1;
xu= 1.0 ;
fl = xl + log(xl)/log(exp(1));
fu = xu + log(xu)/log(exp(1));


%now check if the sign of fl and fu are same or different
if(fl*fu >0)
error('initial guessus must evaluate function with different sign');

end
%%ITERATION SOLUTION USING BISECTION METHOD
max_iterration = 50;
accepted_tolerance = 1e-5;

for i = 1 :max_iterration
err = abs(xl - xu);
%finding the new co-ordiante
xnew = (xl + xu)/2;

fnew = xnew + log(xnew)/log(exp(1));

if(fl*fnew > 0 )
xl = xnew
fl = fnew;
else
xu = xnew
fu = fnew;
end

if(abs(err) < accepted_tolerance)
break;
end

end


Add a comment
Know the answer?
Add Answer to:
Use bisection to solve for the root of: f(x) = x + ln(x) It is known...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT