I have a Matlab question:
What expression is calculated by the following command in Matlab? Code: fminbnd(@(x) (sin(x).^2-1),0,pi) Minimum of: (a) f(x)=1-sin x^2 or (b)1-sin^2x.
fminbnd(@(x) (sin(x).^2-1),0,pi)
I am not really sure. I have pluged the x values into both of my options and the one that returns the matching y value is the correct function. BUt for both equations i get 1, so i don't know what is right a) or b)?
Function evaluations have higher precedence than raising to a power. So
sin(x).^2-1
is the same as
(sin(x)).^2-1
I.e., you do the sin(x) first, then square this result. Which is not the same as
sin(x.^2)-1
1.4m articles
1.4m replys
5 comments
56.9k users