Question: Add your code following the instructions in the comments in the files. Do not change the function statement or your function may not work. Note
Add your code following the instructions in the comments in the files. Do not change the function statement or your function may not work. Note that the inputs are given to you in the arguments of the functions. Do not make additional assumptions on the values of the arguments, your code needs to work for various inputs. You may want to write for your own use a script that calls each of the functions on various inputs, for development and testing.
Your result must satisfy this equation up to a given tolerance. Hint: use the formula for the sum of finite geometric sequence, and reformulate the equation as a fixed point problem.
| function y=find_next(x) | |
| % b=find_next(a) | |
| % find the smallest number y such that y>x | |
| % in: | |
| % x size (1,1), double | |
| % out: | |
| % y size(1,1), double | |
| % your code here | |
| end |
| function q=findq(a,n,tol,maxit) | |
| % q=findq(a,n,tol) | |
| % find q such that 1+q+q^2 +...+q^(n-1)=a with difference at most tol | |
| % by at most maxit iterations of fixed point method | |
| % in: | |
| % a,n,tol,maxit size (1,1), must have a>n and tol>0 | |
| % out: | |
| % q size (1,1) | |
| if a>n & tol > 0, | |
| % your code here | |
| else | |
| a,tol,error('must have a>n and tol>0') | |
| end |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
