Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Computational Methods Homework: Solving Non-linear Equations using False Position Method, Assignments of Mechanical Engineering

Guidelines and three problems for mae 107 - computational methods summer session ii 2009 homework #3. Students are required to write functions for the false position method to find the roots of a non-linear equation, test the function, and use it to find the roots of a given function. The document also includes a problem to find the roots of a specific function using the provided function and different segment numbers.

Typology: Assignments

2009/2010

Uploaded on 03/28/2010

koofers-user-yck
koofers-user-yck 🇺🇸

10 documents

1 / 3

Toggle sidebar

Related documents


Partial preview of the text

Download Computational Methods Homework: Solving Non-linear Equations using False Position Method and more Assignments Mechanical Engineering in PDF only on Docsity! MAE 107 – Computational Methods Summer Session II 2009 Homework # 3 due on Wednesday, August 26 in class 3 problems – 20 points Guidelines: Please turn in a neat homework that gives all the formulae that you have used and all the necessary information for the grader to understand your solution. Also, if the problem requires you to write a MATLAB code, please turn in a copy of the code you used, carefully documented with comments and using proper indentation, as well as the requested ouputs and graphs, along with the written explanation of your solution. Use the codes presented in class only as a guide: just copying them or using them directly to compute the solution is not an acceptable answer. You need to write a code that does specifically what the questions ask you to do (be careful: in general, the homework problems ask something rather different than what the codes used in class were doing). Problem 1 – 10 points 1. Create a function FalsePos.m that solves the non-linear equation f(x) = 0 using the False Position method on a bracket [a, b]. Your function should have four inputs: a function handle f , the lower limit of the bracket a, its upper limit b and a maximum approximate relative error r. It should first test that [a, b] is indeed a bracket (that means that f changes sign on this interval). If that is not the case, the function should return an error message. If [a, b] is a bracket, the function should perform as many iterations as necessary to obtain an approximate solution xn with an approximate relative error less than r. Finally, your function should have two outputs: the last value xN for the root and the number of iterations performed. Test this function to find the value of √ 5 by solving for the root of f(x) = x2 − 5 over the bracket [0, 4]. 2. Create a second function find_roots.m that finds the roots of a function f on an interval [A,B] using successively incremental search and the False Position method. Your function should take the following arguments: the function handle f corresponding to the function whose roots you are looking for, the lower and upper bounds A and B, the number Ns of segments for the incremental search and the approximate relative error r for the False Position method. It should perform the following steps: − Perform the incremental search on the prescribed number of segments. − If some brackets where f changes of sign are located, it should use the function FalsePos.m defined in the previous question to find one root on this bracket with the prescribed approximate relative error. If no bracket was found during the incremental search, your function should display a message at the command line. − Return as output a vector with the different roots found and display a message indicating the number of roots (including the case where no root was found). Test this function by finding the roots of f(x) = cos(x) on [0, 2π]. 1 3. We now will use this function find_roots.m to find the roots of the function g(x) = cos(10π/x) for 0.1 ≤ x ≤ 10 ( you should use an error threshold r = 10−6): (a) Prove mathematically (without using MATLAB), that the exact solutions of g(x) = 0 are xn = 20 1 + 2n with 1 ≤ n ≤ 99. (b) Using find_roots.m with A = 0.1, B = 10, Ns = 50 and g(x) = cos(10π/x) (remember that you need to create the function handle corresponding to g using for example g=@(x) cos(10*pi./x)), how many roots can you find? (c) Repeat the previous question with Ns = 200, Ns = 1000, Ns = 5000 and Ns = 10000. (d) Why should Ns not be taken too small? You can illustrate your answer by plotting the function g(x). What would be the disadvantage of taking N very large? (e) Propose a strategy to modify the function find_roots.m so that fewer segments are necessary in the incremental search to find all the roots (you do not need to actually modify the function, just explain what you would do and why). Problem 2 – 7 points Consider the following equation: f(x) = ex − 3x2 = 0 1. Show graphically that f(x) = 0 has three real solutions located respectively near x = −1/2, 1 and 4. 2. Consider the fixed point iteration scheme of the form x(n+1) = g(x(n)) for finding the roots of the equation. Two obvious choices for g(x) are g−(x) = − √ ex 3 and g+(x) = √ ex 3 . Show that g− and g+ will converge to the roots located respectively near x = −1/2 and x = 1 for a choice of initial guess sufficiently close to these roots. Prove also that none of these fixed-point iteration schemes will converge to the root located near x = 4. 3. Find another scheme of the form x(n+1) = g(x(n)) that will converge quadratically for all the roots, for an initial guess close enough from each of the roots. 4. Create a MATLAB script based on the scheme obtained in the previous question and find the roots of f(x) with an approximate relative error less than 10−6 (you will need to use different initial guesses to find each of the three roots – you are not asked here to write a function that solves a general non-linear equation but a script specific to this problem). 2
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved