Subject: find minima and maxima points of a function
From: Luigi Marino
Date: Sun, 1 Feb 2009 19:05:38 +0100
Last my work for Maxima, the block
find minima and maxima points of a function.
The block use solve of Maxima and points are
discovered if solve works.
load(descriptive);
stud_funz(f):=block([p,fs,fp],
p:solve(diff(f,x,1),x),
fs:diff(f,x,2),
fp:ev(fs,x:p),
for i:1 thru length(float(p)) do
if rhs(fp[i])>0 then print("minimo",[p[i],rhs(ev(f,x:p[i]))])
else print("massimo",[p[i],rhs(ev(f,x:p[i]))]))$
Example:
f:x^3/(1-x^2);
stud_funz(f);
minimo[x=-sqrt(3),(3*sqrt(3))/2]
massimo[x=sqrt(3),-(3*sqrt(3))/2]
massimo[x=0,0]
f:x*sqrt(1-x^2);
stud_funz(f);
minimo[x=-1/sqrt(2),-1/2]
massimo[x=1/sqrt(2),1/2]
f:trigexpand(cos(2*x)+2*sin(x));
stud_funz(f);
`solve' is using arc-trig functions to get a solution.
Some solutions will be lost.
massimo[x=%pi/6,0]
massimo[x=%pi/2,0]
Best wishes.
Luigi Marino