;; Define the function f using the "func" command: (func f(x) 5*cos(2*x)-2*x*sin(2*x)) ;; Calculate f's derivative, and call it g: (derfunc g f x) (what g) ;; If we just ask for the roots of g, they may not be in the interval of interest: (roots g 1) (roots g 2) ;; Using bisection assures that our root is in the given interval... (g 1) (g 2) ;; the values differ in sign, so, since g is continuous, there's a root! (bisection (function g) 1 2) ;; now let's find a root of the derivative on the interval [1,2]: (def root (roots g 1)) root (g root) ;; our minimum value.... (f root) (def xvals (rseq 1 2 100)) (xgobips "ex4.ps" 1 ;; red level 0 ;; green 0 ;; blue xvals (f xvals) :x-axis t :morelines (list (list 0 0 1 xvals (g xvals) "lndashed" ) ) :xtics (rseq 1 2 5) :xmin 1 :xmax 2 :ymin -6 :ymax 2 )