Max d'une fonction

ishak -  
 iutlo -
Bonjour,

S'il vous plait comment chercher le maximum de cette fonction sur un compact [0,K] par matlab


p + log(p + 1) + (2^(1/2)*(p - (20*(p + 1)^(1/2)*(p + 4))/3 + 83/3))/10 - (2^(1/2)*(p/2 + 1/2))/5
et merci
A voir également:

1 réponse

iutlo
 
Voici la réponse à votre question.
---------------------------------------

function Unt
clc
clear all;
syms x
figure (1);
ezplot('x + log(x + 1) + (2^(1/2)*(x - (20*(x + 1)^(1/2)*(x + 4))/3 + 83/3))/10 - (2^(1/2)*(x/2 + 1/2))/5')
hold on;
axis([-1 1 -2 2])

df = myfunc; % compute f'(p)

t = -1:0.1:1;
dft = subs(df,{x},{t});
plot(t,dft,'r'); grid on; % plot the derivative ...
hold on;

root = fzero(@(x) 1/(x + 1) - ...
(2^(1/2)*((20*(x + 1)^(1/2))/3 + ...
(10*(x + 4))/(3*(x + 1)^(1/2)) - 1))/10 - 2^(1/2)/10 + 1, 1);
plot(root,0,'o','MarkerFaceColor','k') % plot x where f'(x) = 0
legend ('f(x)', 'df(x)', 'x where f(x) = max or ... df(x) = 0')
end

function df = myfunc(x)
%
% The initial function f(p)
% Compute the derivative of df(p) = f'(p)
%
syms x
f = x + log(x + 1) + ...
(2^(1/2)*(x - (20*(x + 1)^(1/2)*(x + ...
4))/3 + 83/3))/10 - (2^(1/2)*(x/2 + 1/2))/5;
df = diff(f,x);
end
0