Está en la página 1de 3

function maximo2022

syms x
f=input('ingrese la funcion f(x)=')
df=diff(f,x)
X=solve(df,x)
df2=diff(df,x)
n=length(x)
for i=1:1:n
y=subs(f,x,X(i))
p=subs(df2,x,X(i))
if p>0
disp('El valor siguiente es un mínimo')
disp([X(i),y])
end
if p<0
disp('El valor siguiente es un máximo')
disp([X(i),y])
end
end

maximo2022

ingrese la funcion f(x)=x^3-3*x^2

f = x^3 - 3*x^2

df = 3*x^2 - 6*x

X=

df2 =6*x - 6

n= 1

y=0

p =-6

El valor siguiente es un máximo

[ 0, 0]
x=1:0.1:3;

>> y=x.^3-3.*x.^2;

>> plot(x,y)
x=1:0.1:3;

>> y=x.^3-3.*x.^2;

>> plot(x,y,'m'),grid, title('Función de máximos y mínimos')

>>

También podría gustarte