MATLAB Answers

0

Hi. I have been asked to iterate a function 100 times with an initial guess of x=4, but i am unsure how to go around it. I have been given the following function:

Asked by Sam Thorpe on 25 Feb 2019
Latest activity Commented on by Sam Thorpe on 25 Feb 2019
function y=function_for_Ex6a(x)
for x=(127.0526);
y=4*(1-cos(x)).^2+x.^3;
end

  3 Comments

Why do you think you need to use a for loop, just to define the variable x=127.0526? Where does 127.0256 come from anyway?
You do apparently want to loop 100 times, so you would want to use a for loop.
But what is the purpose of the iteration? Is this an iteration to solve for y==0, so a root finding problem? What iteration were you told to do? A fixed point iteration, perhaps? Or is this just an iteration where you plug the output, y, back into the function? In that case, it will very rapidly diverge to infinity.
Give more information. What do you want to do whit this loop? Your function now is overwriting the value of x and it is just doing one iteration with x = 127.0526
the question is very vague. it just asks for us to iterate the function 100 times. i shall try and get some more clarity.

Sign in to comment.

0 Answers