Skip to content

Integrals #17

@k4b7

Description

@k4b7

There are two main types of integrals: definite and indefinite integrals. Definite integrals specify a domain over which integration is performed. That domain can be in the form of limits or it could be a set, e.g. let D = [0, 1] and then integrate over D.

Integration can also occur over surfaces or higher dimension domains. Sometimes these are specified as a single integral over a multi-dimension domain and other times a double or triple integral is used. It would be nice to be to be able to differentiate between a double integral and an integral inside brackets/parens inside of another integral.

Suggested AST structure for various examples:

// indefinite integral w.r.t x
int(x^2, x) --> { type: 'Apply', op: 'int', args: [x^2, [x]] }

// definite integral w.r.t x over domain D
int(x^2, x, D) --> { type: 'Apply', op: 'int', args: [x^2, [x], [D]] }

// definite integral w.r.t between a and b
int(x^2, x, a, b) --> { type: 'Apply', op: 'int', args: [x^2, [x], [[a, b]]] },

// indefinite double integral w.r.t x and then y
{ type: 'Apply', op: 'int', args: [x^2 + y^2, [x, y]] }

// definite integral w.r.t x and y over different domains D_x and D_y
{ type: 'Apply', op: 'int', args: [x^2 + y^2, [x, y], [D_x, D_y]] }

// definite integral w.r.t x and y over the intervals (a, b) and (c, d)
{ type: 'Apply', op: 'int', args: [x^2 + y^2, [x, y], [[a, b], [c, d]]] }

We may at some point in the future decide to make limits such as [a, b] more than a simple array, but this should be good for now. It does make tree traversal more complicated because the handler for Apply nodes now needs to know how to traverse all these different variants of op: 'int'.

It should be noted that D may be defined elsewhere so in terms of actually evaluating an integral over a domain set, what D actually points will have to be tracked outside of the AST.

Also, D could point to a contour allowing for representation of contour integrals of a complex valued function.

A valid integral would requires the following things:

  • if bounds (domain of integration) is specified, the derivative is definite and the number of bounds (domains) specified should match the number of variables of integration
  • when integrating over of a complex function the domain of integration must be a contour (the reverse must also be true)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions