(a) Develop a matlab code to implement the fixed point algorithm. Algorithm: (Exactly as given in...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
(a) Develop a matlab code to implement the fixed point algorithm. Algorithm: (Exactly as given in the textbook) START PROGRAM INPUT/INITIALIZATION : Input approximation po; Tolerance TOL; maximum number of iterations No. Set NO=300, TOL=1e-5 OUTPUT: Approximate Solution p or message of failure. STEP 1 Set i = 1. STEP 2 While i ≤ No repeat Steps 3 - 6: STEP 3 Set p = g(po). Compute pi STEP 4 If | p - Po |< TOL then OUTPUT (p and 'After i iterations') the procedure was successful STOP STEP 5 Set i = i + 1. STEP 6 Set p = p. Update Po STEP 7 If i=NO+1 then OUTPUT('The method failed after N iterations, No, No); END PROGRAM The procedure was unsuccessful. You may use a "for" loop or a "while" loop to implement the iteration. Also output your error in the form a graph to easily visualize the iteration and con- vergence. (b) Develop a matlab code to implement Newton's method. Algorithm: (Exactly as given in the textbook) START PROGRAM INPUT/INITIALIZATION : Input approximation po; Tolerance TOL; maximum number of iterations No. OUTPUT: Approximate Solution p or message of failure. STEP 1 Set i = 1. STEP 2 While i ≤ No repeat Steps 3 - 6: STEP 3 Set p = Po - f(po)/f'(po). Compute pi STEP 4 If | p-Po |< TOL then OUTPUT (p and 'After i iterations') the procedure was successful STOP STEP 5 Set i=i+1. STEP 6 Set po = p. Update po STEP 7 OUTPUT ('The method failed after No iterations, No =', No); The procedure was unsuccessful. END PROGRAM (c) Use the iteration method, and Newton's method to find the fixed point of g(x) = x/2+1/x in [1,2] to approximate √2 accurately to within 10-5. Which method converges faster? Try p0=1 Some new commands: Example 1 : Commands for printing in Matlab. output = sprintf('Any text you want'); disp(output); This will print the string of characters 'Any text you want' on the command window. Example 2 : To print character strings with number: p = 1.45637798423; output= sprintf('Any text you want %f",p); disp(output); When you use %f you instruct matlab to replace with the number in p showing only 6 digits past the decimal point with a round off. This will print on the command window: Any text you want 1.456378 Example 3 : p = 1.45637798423; output = sprintf('Any text you want %0.10f",p); disp(output); This will print on the command window : Any text you want 1.45637798423; When you use %0.10f you instruct matlab to replace with the number in p showing the first 10 significant digits. Example 3 : p = 0.000012345; output= sprintf('Any text you want %e',p); disp(output); This will print on the command window: Any text you want 1.234500e-5; (a) Develop a matlab code to implement the fixed point algorithm. Algorithm: (Exactly as given in the textbook) START PROGRAM INPUT/INITIALIZATION : Input approximation po; Tolerance TOL; maximum number of iterations No. Set NO=300, TOL=1e-5 OUTPUT: Approximate Solution p or message of failure. STEP 1 Set i = 1. STEP 2 While i ≤ No repeat Steps 3 - 6: STEP 3 Set p = g(po). Compute pi STEP 4 If | p - Po |< TOL then OUTPUT (p and 'After i iterations') the procedure was successful STOP STEP 5 Set i = i + 1. STEP 6 Set p = p. Update Po STEP 7 If i=NO+1 then OUTPUT('The method failed after N iterations, No, No); END PROGRAM The procedure was unsuccessful. You may use a "for" loop or a "while" loop to implement the iteration. Also output your error in the form a graph to easily visualize the iteration and con- vergence. (b) Develop a matlab code to implement Newton's method. Algorithm: (Exactly as given in the textbook) START PROGRAM INPUT/INITIALIZATION : Input approximation po; Tolerance TOL; maximum number of iterations No. OUTPUT: Approximate Solution p or message of failure. STEP 1 Set i = 1. STEP 2 While i ≤ No repeat Steps 3 - 6: STEP 3 Set p = Po - f(po)/f'(po). Compute pi STEP 4 If | p-Po |< TOL then OUTPUT (p and 'After i iterations') the procedure was successful STOP STEP 5 Set i=i+1. STEP 6 Set po = p. Update po STEP 7 OUTPUT ('The method failed after No iterations, No =', No); The procedure was unsuccessful. END PROGRAM (c) Use the iteration method, and Newton's method to find the fixed point of g(x) = x/2+1/x in [1,2] to approximate √2 accurately to within 10-5. Which method converges faster? Try p0=1 Some new commands: Example 1 : Commands for printing in Matlab. output = sprintf('Any text you want'); disp(output); This will print the string of characters 'Any text you want' on the command window. Example 2 : To print character strings with number: p = 1.45637798423; output= sprintf('Any text you want %f",p); disp(output); When you use %f you instruct matlab to replace with the number in p showing only 6 digits past the decimal point with a round off. This will print on the command window: Any text you want 1.456378 Example 3 : p = 1.45637798423; output = sprintf('Any text you want %0.10f",p); disp(output); This will print on the command window : Any text you want 1.45637798423; When you use %0.10f you instruct matlab to replace with the number in p showing the first 10 significant digits. Example 3 : p = 0.000012345; output= sprintf('Any text you want %e',p); disp(output); This will print on the command window: Any text you want 1.234500e-5;
Expert Answer:
Answer rating: 100% (QA)
Certainly Lets use the given iteration method and Newtons method to appro... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Describe how to organize yourself at the end of the day. Suggest at least five ways to organize and inventory the office supplies and the workstation.
-
Companies that operate in different industries may have very different financial ratio values. These differences may grow even wider when we compare companies located in different countries. (Click...
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
A team of workers will build a wall of 400 m in 15 days if they work 8 hours every day. How long will they take if the wall has 600 m and they work 10 hours every day?
-
Ajax Limited reported the following information (in millions) at December 31, 2015: net sales $14,000; profit $550; total assets at December 31, 2015, $7,200; and total assets at December 31, 2014,...
-
The following amortization and interest schedule reflects the issuance of 10-year bonds by Capulet SpA on January 1, 2016, and the subsequent interest payments and charges. The companys year-end is...
-
What are the three basic items all motions must include?
-
The futures price of gold is $650. Futures contracts are for 100 ounces of gold, and the margin requirement is $5,000 a contract. The maintenance margin requirement is $1,500. You expect the price of...
-
Experience in human resources management practices, policies and procedures is required. Please explain how you meet this criterion using examples
-
A business financial agency earned 90% of net income 90% of 2,500,000 baht of sales and there are a total 10,000 of common shares. If the board wishes to pay out 95% of earnings in the form of...
-
The radius of our Sun is 6.96x108 m, and its total power output is 3.85x1026 W. a. Assuming the Sun's surface emits as a blackbody, calculate its surface temperature. b. What is the Sun's peak...
-
How can IKEA minimize its weaknesses to protect itself from external threats ?
-
-x+3 if x < 2 #62 Consider the function G(x) = Find the value of each. If a limit does not x+1 if x 2 exist, state DNE. (Using the domain to figure out which rule to use) a) lim G(x)= x-2- b) lim...
-
Write a program that implements and uses a class called MyRectangle. Data items should include: length, width, color, and label. Define properties with appropriate accessor functions for each of the...
-
1. Roberta thinks that cycling is the best way to explore a new city. On her visit to Paris, she cycled 75 kilometers to get to her next Airbnb in the neighboring town. The town was due east of...
-
Mention five conditions to be met by an officer that needs to be promoted in the civil service?
-
What is the maximum volume of 0.25 M sodium hypochlorite solution (NaOCl, laundry bleach) that can be prepared by dilution of 1.00 L of 0.80 M NaOCl?
-
What are the design issues for all iterative control statements?
-
What are the arguments for the inclusion of enumeration types in C#, although they were not in the first few versions of Java?
-
Write Programming Exercise 3 using Java. Data From Exercise 3: Define semaphores in Ada and use them to provide both cooperation and competition synchronization in the shared-buffer example.
-
A steel cylinder containing air has a closely fitted piston and a set of stops as shown in Fig. 3.7. The piston is loaded with certain weights. The air inside the cylinder is initially at...
-
What is the difference between compressed liquid and saturated liquid?
-
Explain the significance of critical point and triple point.
Study smarter with the SolutionInn App