Answer to Question #286763 in Discrete Mathematics for Ravi

Question #286763

Assume that the function y(x) = f (x) + g(x) has a single local minimum in the

interval 0 <= x <= 1, at x = xm. Write

(i) a function M-file (called funct.m) and

(ii) a MATLAB statement (using the fminbnd command)

that together will compute xm and the value of y at xm.



1
Expert's answer
2022-01-20T11:30:27-0500

i)

Matlab function code('func.m'):

function fun = func (x)

"\\mathrm{f}=@(\\mathrm{x}) \\mathrm{x}^3 ;" g=@(x) 2^{*} x+1 ;

"fun =f(x)-g(x);"

end

ii) Main Program:

"\\mathrm{clc}"

"\\mathrm{f}=@(\\mathrm{x}) func (\\mathrm{x}) ;"

"c=f z e r o(f,-1) ;"

fprintf('The zero of the function is, c=% 4.2f \n', c);

Output:

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS