5ce5316a33 2021-03-01 1: % function analysis
5ce5316a33 2021-03-01 2: % Function f (x) is defined ?
5ce5316a33 2021-03-01 3: if (freeof(f,x)) then << write "first define function f(x)"; end; >>
5ce5316a33 2021-03-01 4:
5ce5316a33 2021-03-01 5: fp:=df (f, x);
5ce5316a33 2021-03-01 6: fpp:=df (fp, x);
5ce5316a33 2021-03-01 7:
5ce5316a33 2021-03-01 8: % zeroes
5ce5316a33 2021-03-01 9: xz:=solve (f, x);
5ce5316a33 2021-03-01 10:
5ce5316a33 2021-03-01 11: % extremes
5ce5316a33 2021-03-01 12: xe:=solve (fp, x);
5ce5316a33 2021-03-01 13:
5ce5316a33 2021-03-01 14: % reversal points
5ce5316a33 2021-03-01 15: xr:=solve (fpp, x);
5ce5316a33 2021-03-01 16:
5ce5316a33 2021-03-01 17: % extreme values
5ce5316a33 2021-03-01 18: x1:=first (xe);
5ce5316a33 2021-03-01 19: y1:=sub (x1, f);
5ce5316a33 2021-03-01 20: y2:=sub (x1, fpp);
5ce5316a33 2021-03-01 21:
5ce5316a33 2021-03-01 22: on rounded;
5ce5316a33 2021-03-01 23:
5ce5316a33 2021-03-01 24: if numberp(y2) then
5ce5316a33 2021-03-01 25: if y2<0 then write "local maximum" else
5ce5316a33 2021-03-01 26: if y2=0 then write "reversal point"
5ce5316a33 2021-03-01 27: else write "local minimum";
5ce5316a33 2021-03-01 28:
5ce5316a33 2021-03-01 29: off rounded;
5ce5316a33 2021-03-01 30:
5ce5316a33 2021-03-01 31: % integration of 2nd derivative
5ce5316a33 2021-03-01 32: f1:=int (fpp, x);
5ce5316a33 2021-03-01 33: % integration of 1st derivative
5ce5316a33 2021-03-01 34: f0:=int (f1, x);
5ce5316a33 2021-03-01 35: f0:=int (fp, x);
5ce5316a33 2021-03-01 36:
5ce5316a33 2021-03-01 37: end;