Question
MATLAB

5. Given the recurrence formula In+1 = g(n), where g(x) = 1.2 + €0.52 repeat the evaluation of the recurrence formula until t
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

g = @(x) 1/(1.2 + exp(0.5 * x)); ... Defining the given function g(x) in MATLAB

n=0; ... Initializing n to 0

x_n = 1; ... Initializing x0 to 1

x_n1 = g(1); ... Initializing x n+1 to g(x) (Here x n+1 is g(1) )

while(abs(x_n1 - x_n) > 10^-6) ... Using while to loop until the given codition fails ( till x n+1 - x <= 10^-6)
  
n=n+1; ... Updating n as the loop progreses
  
x_n = x_n1; ... Updating x_n as x_n1 (x n+1) the loop progreses
  
x_n1 = g(x_n); ... Updating x_n1 as g(x_n) (g(x n)) the loop progreses
  
end

disp(n) ... Displaying the scalar value of n

disp(x_n1)

Code :

g = @(x) 1/(1.2 + exp(0.5 * x)); -- Defining the given function g(x) in MATLAB n=0; * Initializing n to o x_n = 1; - Initiali

Output:

disp (n) ** Displaying the scalar value of n disp (x_nl) 0.4118

Add a comment
Know the answer?
Add Answer to:
MATLAB 5. Given the recurrence formula In+1 = g(n), where g(x) = 1.2 + €0.52 repeat...
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