About a matlab mathematic problem from applied numerical method

52 Views Asked by At

enter image description here

enter image description here

Can you help me,please to solve this problem with the help of Matlab. Thanks!

1

There are 1 best solutions below

0
On BEST ANSWER

For an analytical solution simply run max( 0.4 / sqrt(1+x^2) - sqrt(1+x^2) * (1 - 0.4 / (1+x^2)) + x) on Wolfram Alpha (or a similar expression in any symbolical language, even Matlab provides a symbolic toolbox). An analytical solution should always be preferred, if applicable.

But I suppose you are interested in a purely numerical approach?

So, let us at first define the function (inline):

f = @(x) 0.4 / sqrt(1+x^2) - sqrt(1+x^2) * (1 - 0.4 / (1+x^2)) + x;

Plot it (play with the range) to get an impression on it:

fplot(f, [0 2])

The function seems to have a global optimum somewhere near to 1. So now negate it

fneg = @(x) -f(x)

to make it compatible with the built-in numerical minimization functions. Now just minimize fneg. For example by:

fminsearch(fneg, 1)

where 1 is passed as starting position for the local search. Take a look at

doc fminsearch

Alternatively use

fminbnd(fneg, 0, 2)

in order to search for a minimum in the interval [0,2]. The result is x=1.0519, which also matches the result at Wolfram Alpha.