Question

Using Matlab, write an .M code program:2. Write a program for numerical solution of nonlinear equation by Fixed-Point Iteration method with given accuracy . Test Problem 2. Solve the equation. Try 3 different representations of the equation in the form x = g(x). For every representation solve the problem with initial approximations 2, and c and with t ie accuracy f(x)e-3r4-40-10 0.

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

Copyable Code:

%function f(x)

f = @(x)exp(x)-3*x.^4-40*x-10;

% initial value

x0 = 0; %change the value here x0 = 2 and x0 = 10

%initialize the iteration

i = 0;

%initialize the no. of iterations

t_iter = 5;

% initialize array to save iterations

xa = NaN(1,t_iter);

%assign the accuracy

acc = 1e-8;

%initialize the error

x_error = inf;

%check the while loop

while (i < t_iter) && (x_error > acc)

i = i + 1;

x_value = f(x0);

%store every iteration

xa(i) = x_value;

%find difference of initial value and x_value

x_error = abs(x_value - x0);

x0 = x_value;

end

%fixed iteration value

xa = xa(1:i);

%display the all iteration value

fprintf('%15.8e\n', xa);

Add a comment
Know the answer?
Add Answer to:
Using Matlab, write an .M code program: Write a program for numerical solution of nonlinear equation...
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