crowlogic / arb4j

arb4j is a Java API for the arbitrary precision ball arithmetic library found at http://arblib.org
Other
1 stars 0 forks source link

expression compiler: automatic differentiation #253

Open crowlogic opened 8 months ago

crowlogic commented 8 months ago

Implementing Automatic Differentiator

This issue tracks the implementation of an automatic differentiator for the expression compiler. The compiler parses expressions into binary trees, and this differentiator will apply differentiation rules recursively based on the tree structure.

Algorithm Outline

  1. Base Case:

    • For leaf nodes:
      • If a constant, derivative = 0.
      • If a variable, derivative = 1 for the differentiation variable, otherwise 0.
  2. Differentiation Rules:

    • Addition/Subtraction Nodes: Derivative of a sum/difference is the sum/difference of the derivatives.
    • Multiplication Nodes (Product Rule): For a product $f g$, derivative = $f' g + f * g'$.
    • Division Nodes (Quotient Rule): For a division $f / g$, derivative = $(f' g - f g') / g^2$.
    • Exponential and Logarithmic Functions: Apply respective differentiation rules.
    • Trigonometric Functions: Apply differentiation rules for sine, cosine, etc.
    • Power Nodes: Apply power rule or generalized power rule.
  3. Recursive Application:

    • Apply these rules to each child node to compute $f'$ and $g'$
  4. Construct New Tree:

    • Construct a new tree representing the derivative.
  5. Simplification (Optional):

    • Simplify the resulting tree to combine like terms, simplify constants, etc.

Stuff To Be Done And Whatnot

crowlogic commented 8 months ago

When designing this it would be good to take into account and tie it into this paradigm as well since this relies on repeated differentiation which will need to be done automatically

Rodrigues' Formula and Orthogonal Polynomials

Rodrigues' formula is a mathematical expression that provides an efficient way to generate certain orthogonal polynomials. Orthogonal polynomials play a pivotal role in various branches of mathematics, including approximation theory, differential equations, and even quantum mechanics.

What is Rodrigues' Formula?

For a given differential operator $D$ and weight function $w(x)$, the Rodrigues' formula for an orthogonal polynomial $P_n(x)$ is given by:

$$P_n(x) = \frac{1}{w(x) n!} D^n [w(x) f(x)]$$

Here, $n$ denotes the order of the polynomial, and $f(x)$ is a function specific to the type of orthogonal polynomial under consideration.

Examples:

  1. Legendre Polynomials: The Rodrigues' formula for the Legendre polynomials $P_n(x)$ is:

$$P_n(x) = \frac{1}{2^n n!} \frac{d^n}{dx^n} (x^2 - 1)^n$$

  1. Hermite Polynomials: The Hermite polynomials $H_n(x)$ are described by:

$$H_n(x) = (-1)^n e^{x^2} \frac{d^n}{dx^n} e^{-x^2}$$

In both examples, differentiation acts as an iterated linear function to generate the nth polynomial in the sequence.

Connection to Linear Iterated Functions Systems (L.I.F.S.)

The study of orthogonal polynomials can be extended to consider measures generated by Linear Iterated Functions Systems, or L.I.F.S. This is a more advanced topic, delving into the interplay between orthogonal polynomials and iterative linear processes, especially in the context of Fourier analysis.

In more advanced research, like the paper by Giorgio Mantica and Davide Guzzetti, the authors explore the asymptotic behavior of the Fourier transforms of orthogonal polynomials, relating them to measures generated by L.I.F.S.

Conclusion

The Rodrigues' formula serves as a foundation for understanding and generating orthogonal polynomials. As mathematics advances, the interplay between these polynomials, linear iterated systems, and Fourier analysis continues to offer rich areas for exploration and discovery.

crowlogic commented 7 months ago

Fluent Programming Style in Java

In Java, the fluent programming style, often seen in method chaining, is where you can call multiple methods on objects in a single statement. Each method returns an object, allowing the next method in the chain to be invoked on it. This style is popular in builder patterns, streams, and other API designs where it enhances readability and flow of the code. For example:

myObject.methodOne().methodTwo().methodThree();

In this style, each method invocation returns an object, which may not necessarily be of the same type as the input object. The type of the output defaults to the input type unless explicitly specified by the caller, particularly in cases where the last argument of the function is the result variable.

Composition of Functions in Mathematics

In mathematics, function composition is the application of one function to the result of another to produce a third function. For example, if $f$ and $g$ are two functions, their composition $(f \circ g)(x)$ is defined as $f(g(x))$. This is a fundamental concept in mathematics, particularly in fields like calculus and algebra.

Similarity

The similarity lies in the way operations or functions are applied in a sequence, each taking the output of the previous one as its input:

Difference

While structurally similar, the contexts and applications of these concepts are different:

In summary, while the two concepts are not identical, the structural similarity is clear, and understanding one can help in grasping the other, with the specific distinction in how the types of inputs and outputs are handled.

crowlogic commented 5 months ago

Alglib