JXG.Math.ImplicitPlot

Class

Plotting of curves which are given implicitly as the set of points solving an equation $f(x,y) = 0$.

The main class initializes a new implicit plot instance.

The algorithm should be able to plot most implicit curves as long as the equations are not too complex. We are aware of the paper by Oliver Labs, A List of Challenges for Real Algebraic Plane Curve Visualization Software which contains many equations where this algorithm may fail. For example, at the time being there is no attempt to detect solitary points. Also, it is always a trade off to find all components of the curve and keep the construction responsive.

Methods

Own

curveContainsPoint(p, dataX, dataY, tol, eps)

Test if the data points contain a given coordinate, i.e. if the given coordinate is close enough to the polygonal chain through the data points.

Parameters

Name Type Description
p Array

Homogenous coordinates [1, x, y] of the coordinate point

dataX Array

x-coordinates of points so far

dataY Array

y-coordinates of points so far

tol Number

Maximal distance of p from the polygonal chain through the data points

eps Number

Helper tolerance used for the quadtree

Returns

Boolean

Details

Source
math/implicitplot.js, line 446

(private) handleCriticalPoint(u, t_u, r, omega) → {Array}

Search in an arc around a critical point for a further point on the curve. Unused for the moment.

Parameters

Name Type Description
u Array

Critical point [x, y]

t_u Array

Tangent at u

r Number

Radius

omega Number

angle

Returns

Coordinates [x, y] of a new point.

Type
Array

Details

Source
math/implicitplot.js, line 940

(private) isBifurcation(u, tol)

If both eigenvalues of the Hessian are different from zero, the critical point at u is a simple bifurcation point.

Parameters

Name Type Description
u Array

Critical point [x, y]

tol Number

Tolerance of the eigenvalues to be zero.

Returns

Boolean True if the point is a simple bifurcation point.

Details

Source
math/implicitplot.js, line 890

plot() → {Array}

Implicit plotting method.

Returns

consisting of [dataX, dataY, number_of_components]

Type
Array

Details

Source
math/implicitplot.js, line 228

(private) searchLine(fmi, fma, fix, interval, dir, num_components, dataX, dataY, level) → {Array}

Recursively search a horizontal or vertical line for points on the fulfilling the given equation.

Parameters

Name Type Description
fmi function

Minimization function

fma function

Maximization function

fix Number

Value of the fixed variable

interval Array

Search interval of the free variable

dir String

'vertical' or 'horizontal'

num_components Number

Number of components before search

dataX Array

x-coordinates of points so far

dataY Array

y-coordinates of points so far

level Number

Recursion level

Returns

consisting of [dataX, dataY, number_of_components]-

Type
Array

Details

Source
math/implicitplot.js, line 319

(private) tangent(u)

Tangent of norm 1 at point u.

Parameters

Name Type Description
u Array

Point [x, y]

Returns

Array

Details

Source
math/implicitplot.js, line 1007

(private) tangent_A(A)

Approximate tangent (of norm 1) with Quasi-Newton method

Parameters

Name Type Description
A Array

Returns

Array

Details

Source
math/implicitplot.js, line 991

(private) traceComponent(u0)

Starting at an initial point the curve is traced with a Euler-Newton method. After tracing in one direction the algorithm stops if the component is a closed loop. Otherwise, the curved is traced in the opposite direction, starting from the same initial point. Finally, the two components are glued together.

Parameters

Name Type Description
u0 Array

Initial point in homogenous coordinates [1, x, y].

Returns

Array [dataX, dataY] containing a new component.

Details

Source
math/implicitplot.js, line 477

(private) tracing(u0, direction)

Starting at a point \(u_0\), this routine traces the curve \(f(u)=0\) until a loop is detected, a critical point is reached, the curve leaves the bounding box, or the maximum number of points is reached.

The method is a predictor / corrector method consisting of Euler and Newton steps together with step width adaption.

The algorithm is an adaption of the algorithm in Eugene L. Allgower, Kurt Georg: Introduction to Numerical Continuation methods.

Parameters

Name Type Description
u0 Array

Starting point in homogenous coordinates [1, x, y].

direction Number

1 or -1

Returns

Array [pathX, pathY, loop_closed] or []

Details

Source
math/implicitplot.js, line 538

(private) updateA(A, u0, u1)

Quasi-Newton update of the Moore-Penrose inverse. See (7.2.3) in Allgower, Georg.

Parameters

Name Type Description
A Array
u0 Array
u1 Array

Returns

Array

Details

Source
math/implicitplot.js, line 971

Inherited

none

Example

var f = (x, y) => x**3 - 2 * x * y + y**3;
    var c = board.create('curve', [[], []], {
            strokeWidth: 3,
            strokeColor: JXG.palette.red
        });

    c.updateDataArray = function () {
        var bbox = this.board.getBoundingBox(),
            ip, cfg,
            ret = [],
            mgn = 1;

        bbox[0] -= mgn;
        bbox[1] += mgn;
        bbox[2] += mgn;
        bbox[3] -= mgn;

        cfg = {
            resolution_out: 5,
            resolution_in: 5,
            unitX: this.board.unitX,
            unitY: this.board.unitX
        };

        this.dataX = [];
        this.dataY = [];
        ip = new JXG.Math.ImplicitPlot(bbox, cfg, f, null, null);
        ret = ip.plot();
        this.dataX = ret[0];
        this.dataY = ret[1];
    };
    board.update();

Parameters

Name Type Attributes Description
bbox Array

Bounding box of the area in which solutions of the equation are determined.

config Object

Configuration object.

f function

function from \({\mathbb R}^2 \to {\mathbb R}\)

dfx function <optional>

Optional partial derivative of \(f\) with regard to \(x\)

dfy function <optional>

Optional partial derivative of \(f\) with regard to \(y\)

Details

Default Value
{
     resolution_out: 5,    // Horizontal resolution: distance between vertical lines to search for components
     resolution_in: 5,     // Vertical resolution to search for components
     max_steps: 1024,      // Max number of points in one call of tracing
     alpha_0: 0.05,        // Angle between two successive tangents: smoothness of curve

     tol_u0: Mat.eps,      // Tolerance to find starting points for tracing.
     tol_newton: 1.0e-7,   // Tolerance for Newton steps.
     tol_cusp: 0.05,       // Tolerance for cusp / bifurcation detection
     tol_progress: 0.0001, // If two points are closer than this value, we bail out
     qdt_box: 0.2,         // half of box size to search in qdt
     kappa_0: 0.2,         // Inverse of planned number of Newton steps
     delta_0: 0.05,        // Distance of predictor point to curve

     h_initial: 0.1,       // Initial stepwidth
     h_critical: 0.001,    // If h is below this threshold we bail out
     h_max: 1,             // Maximal value of h (user units)
     loop_dist: 0.09,      // Allowed distance (multiplied by actual stepwidth) to detect loop
     loop_dir: 0.99,       // Should be > 0.95
     loop_detection: true, // Use Gosper's loop detector
     unitX: 10,            // unitX of board
     unitY: 10             // unitX of board
  }
Source
math/implicitplot.js, line 37