Solve a nonlinear equation using fixed-point iteration in MATLAB

Click For Summary

Discussion Overview

The discussion revolves around solving a nonlinear equation using fixed-point iteration in MATLAB. Participants are sharing their attempts, code snippets, and issues encountered during the plotting and calculation processes.

Discussion Character

  • Technical explanation
  • Homework-related

Main Points Raised

  • One participant shares their attempt to solve the equation but notes that nothing appears in the output despite no errors being reported.
  • Another participant points out that the plotting code only generates a single point and suggests modifications to plot the function ##g(x)## correctly before performing the fixed-point iteration.
  • There are multiple reports of errors when participants attempt to define or use the function ##g##, indicating potential issues with the code or syntax.

Areas of Agreement / Disagreement

Participants have not reached a consensus on the correct approach to plotting and solving the equation, as there are differing reports of errors and confusion regarding the implementation.

Contextual Notes

Limitations include unclear definitions of variables and potential syntax errors in the MATLAB code that have not been resolved. The discussion does not clarify the specific nature of the errors encountered.

Fatima Hasan
Messages
315
Reaction score
14
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
 
Physics news on Phys.org
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');
 
Jaime_mc2 said:
g = x^5-3*x^3-2*x^2+2;
I got an error .
error.jpg
 
Jaime_mc2 said:
g = x^5-3*x^3-2*x^2+2;
I got an error .
error.jpg
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 10 ·
Replies
10
Views
2K
Replies
2
Views
2K
  • · Replies 20 ·
Replies
20
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K