next up previous contents index
Next: Calculus Plotting Up: Domains and Plotting Previous: Domains and Plotting   Contents   Index

Utility Functions

In this section, f and g are double-valued functions of one variable. ePiX defines numerical functions that return the maximum or minimum value on an interval, approximate the location of roots, and perform calculations with derivatives and definite integrals.

  sup(f, a, b);     // max/min of f on [a,b]
  inf(f, a, b);
  newton(f, g, x0); // find approximate crossing point
Newton's method returns the crossing point of the given functions, starting from the specified seed. If a critical point is hit or 20 iterations pass, a warning is issued and the current result (probably incorrect) is returned. The second function $ g$ defaults to the zero function if omitted.

The classes D and I are used to calculate values of derivatives and integrals, and to plot these functions.

  D df=D(f);   // data structure representing the derivative
  df.eval(t);  // return f'(t)
  df.left(t);  // deriv from left at t:  (f(t)-f(t-dt))/dt
  df.right(t); // deriv from right at t: (f(t+dt)-f(t))/dt

  I prim=I(f,a); // representation of the integral from a
  prim.eval(b);  // numerical integral of f over [a,b]
  double val=I(f).eval(1);   // \int_0^1 f
The lower limit on an integral is 0 by default.

Tangent lines and envelopes (families of tangent lines) are drawn with

  tan_line(f, t);                // f real- or vector-valued
  envelope(f, t_min, t_max, n);  // family of tangent lines
  tan_field(f1, f2, t_min, t_max, n); // field of tangents
The sample files conic.xp and lissajous.xp illustrate these features.



Andrew D. Hwang 2004-09-04