analyse a function in stack/maxima

Re: analyse a function in stack/maxima

by Björn Gerß -
Number of replies: 3
Thanks for the answer, I tried to find a way in maxima.
I did not find a function to make three sets containing either the maxima, minima or saddle points. It seams to be a bad idea for complex functions to work with solve().
In my case it is sufficient and works, to find out the type of one specific point. I implemented it in the way shown underneath. I am not sure yet, if it always works or in which cases it does or does not.

f:-x^4;
xvalue:0;
a: subst(x=xvalue,diff(f,x));
b: if a=0 then limit((1/diff(f,x)),x,xvalue,plus);
c: if a=0 then limit((1/diff(f,x)),x,xvalue,minus) else c:diffnotzero;
j: if (b=inf and c=inf) or (q=minf and p=minf) then saddle
elseif (b=minf and c=inf) then maximum
elseif (b=inf and c=minf) then minimum
elseif (c=diffnotzero) then diffnotzero
else udef;

So, I do not know the limitations – maybe someone has a idea – but it does work for x^(2*n) this time.
It’s maybe not the best coding-style, but solves the question for more functions than before.
I’m happy to hear ideas about it.
In reply to Björn Gerß

Re: analyse a function in stack/maxima

by Björn Gerß -
Hi,
I did change the code I used before to:

isitminmaxorsad(f,xvalue):=block (errcatch (d: notdiffable,
a: subst(x=xvalue,diff(f,x)),
b: if a=0 then limit((1/diff(f,x)),x,xvalue,plus) else diffnotzero,
c: if a=0 then limit((1/diff(f,x)),x,xvalue,minus) else diffnotzero,
d: if (b=inf and c=inf) or (q=minf and p=minf) then saddle
elseif (b=minf and c=inf) then maximum
elseif (b=inf and c=minf) then minimum
elseif (c=diffnotzero) then diffnotzero
else undefined),
return (d));

With this code, the function “isitminmaxorsad(f,x)” becomes available.
This function (“isitminmaxorsad”) takes a first argument “f” which is a function and the second argument “x” which the corresponding x-value.
It checks for the characteristic of the function at the given x-value, for if it is either maxima, minima a saddle point or neither of those.
return values are:
maximum
minimum
diffnotzero
notdiffable
undefined

I would be happy to know if someone finds functions with points that are classified wrong or as undefined even if they are not.
Removable definition gaps are accepted as maxima, minima or saddle point by the code.

Björn
In reply to Björn Gerß

Re: analyse a function in stack/maxima

by Björn Gerß -
Hi,
just some corrections on the code. There was a p and q that was wrong, and stack forbids errcatch. 

So I changed that:

isitminmaxorsad(f,xvalue):=block (
a: subst(x=xvalue,diff(f,x)),
b: if a=0 then limit((1/diff(f,x)),x,xvalue,plus) else diffnotzero,
c: if a=0 then limit((1/diff(f,x)),x,xvalue,minus) else diffnotzero,
d: if (b=inf and c=inf) or (b=minf and c=minf) then saddle
        elseif (b=minf and c=inf) then maximum
            elseif (b=inf and c=minf) then minimum
                elseif (c=diffnotzero) then diffnotzero
                else undefined,
return (d));

Just if someone likes to use it,
Björn
In reply to Björn Gerß

Re: analyse a function in stack/maxima

by Carl Stensfer -
I am a student and I often have problems with function analysis. I'm interested to know if I can use your experience to simplify my tasks.
This is very important for me, because I can rarely turn to someone for help, but I found https://plainmath.net/secondary/calculus-and-analysis/calculus-1 when it was difficult for me to solve equations, I did not understand them , but at that moment no one could explain anything to me. Therefore, this resource can be useful for students who do not understand something.