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