Solve a nonlinear equation using fixed-point iteration in MATLAB

  • #1
Fatima Hasan
319
13
Homework Statement:
The statement is attached below.
Relevant Equations:
-
My attempt is attached below.
When I tried to solve it , nothing comes up. However, there are no errors !
p1.JPG

attempt.JPG
 

Answers and Replies

  • #2
Jaime_mc2
8
9
You are plotting just one point at the end, with coordinates (maxiter + 1, x(maxiter + 1)).

If you want to plot ##g(x)##, you should do something like this (for example before calculating the fixed-point):
Matlab:
x= -10:0.01:10;
g = x^5-3*x^3-2*x^2+2;
plot(x, g);

After this, you should calculate the fixed-point. If you call it ##x## in your code, you can do the following after the fixed-point iteration:
Matlab:
hold on;
fixed_g = x^5-3*x^3-2*x^2+2;
plot(x, fixed_g, 'o');
 
  • #3
Fatima Hasan
319
13
g = x^5-3*x^3-2*x^2+2;
I got an error .
error.jpg
 
  • #4
Fatima Hasan
319
13

Suggested for: Solve a nonlinear equation using fixed-point iteration in MATLAB

  • Last Post
Replies
9
Views
2K
Replies
2
Views
397
  • Last Post
Replies
10
Views
690
  • Last Post
Replies
18
Views
868
  • Last Post
Replies
1
Views
338
  • Last Post
Replies
0
Views
470
Replies
11
Views
502
  • Last Post
Replies
5
Views
662
  • Last Post
Replies
1
Views
561
Top