Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Template files find next.m and findq.m were placed in the directory hw3 of your github repository. Add your code following the instructions in the comments
Template files find next.m and findq.m were placed in the directory hw3 of your github repository. 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. find next.m: For a given 2, compute the smallest number y such that y > 2. All numbers are of type double, which is IEEE 64bit floating point. Hint: Note that the smallest number that can be added to x to make the next larger number is always an integer power of 2 (even for negative x), then search for such number. findq.m: Given natural number n and a > n, compute q >1 such that 1+2+...+q"-1 = a. 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. Your files are submitted when you commit and push to your git repository. You can submit the files multiple times. The result will be evaluated by calling your code on various arguments. The functions need to be in your repository and work correctly on all inputs tested for you to receive credit for this homework. 1 3 1 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 5 5 7 3 * your code here end function q=findqa, n, tol, maxit) % q=findq(a, n, tol) % find a such that 1+9+9^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>') end
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started