/* ** 1-Variable Scalar-Valued Function ** f: R -> R */ fn f(x)=ln(x)-x^2; @ 1-variable scalar-valued function @ fn f1(x)=1/x-2*x; @ 1st analytic derivative of f(x) @ fn f2(x)=-1/(x^2)-2; @ 2nd analytic derivative of f(x) @ v=4; @ function evaluation at point v=4 @ print f(v); @ f(4) @ print f1(v); @ f1(4) @ print f2(v); @ f2(4) @ /* Numeric Derivatives */ print gradp(&f,v); @ 1st numeric derivative of f(x) @ print hessp(&f,v); @ 2nd numeric derivative of f(x) @ @ find maximum of f(x) at x=sqrt(0.5): @ @ check: f1=0 and f2<0 @ /* Using graph to find the maximum: Make sure that your GAUSS is configured correctly with your equipment: monitor and printer in particular. Modify the file PQGRUN.CFG if necessary, according to the instruction in the file. */ library pgraph; graphset; x=seqa(0.0001,0.1,40); y=f(x); call xtics(0,4,0.5,0); call ytics(-15,0,1,0); call xy(x,y); end;