diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 322fb3e5..574e9d75 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2024-02-10T06:18:54","documenter_version":"1.1.2"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2024-02-11T06:19:14","documenter_version":"1.1.2"}} \ No newline at end of file diff --git a/dev/api.html b/dev/api.html index ae17df9f..16ec6793 100644 --- a/dev/api.html +++ b/dev/api.html @@ -10,4 +10,4 @@ julia> map(∇(*), (1,2,3), (4,5,6)) ((4.0, 1.0), (5.0, 2.0), (6.0, 3.0))

The derivative ∂f/∂f

Note that since in Julia, there is no distinction between functions and values, there is in principle a partial derivative with respect to the function itself. However, said partial derivative is dropped by this interface. It is however available using the lower level ∂⃖ if desired. This interaction can also be used to obtain gradients with respect to only some of the arguments by using a closure:

∇((x,z)->f(x,y,z))(x, z) # returns (∂f/∂x, ∂f/∂z)

Though of course the same can be obtained by simply indexing the resulting tuple (in well-inferred code there should not be a performance difference between these two options).

source
Diffractor.:'Method
f'

This is a convenience syntax for taking the derivative of a function f: ℝ -> ℝ. In particular, for such a function f'(x) will be the first derivative of f at x (and similar for f''(x) and second derivatives and so on.)

Note that the syntax conflicts with the Base definition for the adjoint of a matrix and thus is not enabled by default. To use it, add the following to the top of your module:

using Diffractor: var"'"

It is also available using the @∂ macro:

@∂ f'(x)
source
Diffractor.bundleFunction
bundle(primal, tangent)

Wraps a primal up with a tangent into the appropriate kind of AbstractBundle{1}. This is more or less the Diffractor equivelent of ForwardDiff.jl's Dual type.

source
Diffractor.destructureMethod

for a TaylorTangent{N, <:Tuple} this breaks it up unto 1 TaylorTangent{N} for each element of the primal tuple

source
Diffractor.dxMethod
dx(x)

dx represents the trival differential one-form of a one dimensional Riemannian manifold M. In particular, it is a section of the cotangent bundle of M, meaning it may be evaluted at a point x of M to obtain an element of the cotangent space T*ₓ M to M at x. We impose no restrictions on the representations of either the manifold itself or the cotangent space.

By default, the only implementation provided identifies T*ₓ ℝ ≃ ℝ, keeping watever type is used to represent ℝ. i.e.

dx(x::Real) = one(x)

However, users may provide additional overloads for custom representations of one dimensional Riemannian manifolds.

source
Diffractor.find_end_of_phi_blockMethod
find_end_of_phi_block(ir::IRCode, start_search_idx::Int)

Finds the last index within the same basic block, on or after the start_search_idx which is not within a phi block. A phi-block is a run on PhiNodes or nothings that must be the first statements within the basic block.

If start_search_idx is not within a phi block to begin with, then just returns start_search_idx

source
Diffractor.forward_diff_no_inf!Method
forward_diff_no_inf!(ir::IRCode, to_diff::Vector{Pair{SSAValue,Int}}; visit_custom!, transform!)

Internal method which generates the code for forward mode diffentiation

  • ir the IR being differnetation

  • to_diff: collection of all SSA values for which the derivative is to be taken, paired with the order (first deriviative, second derivative etc)

  • visit_custom!(ir::IRCode, ssa, order::Int, recurse::Bool) -> Bool:

	decides if the custom `transform!` should be applied to a `stmt` or not
 	Default: `false` for all statements
  • transform!(ir::IRCode, ssa::SSAValue, order::Int) mutates ir to do a custom tranformation.
source
Diffractor.jet_taylor_evMethod
jet_taylor_ev(::Val{}, jet, taylor)

Generates a closed form arithmetic expression for the N-th component of the action of a 1d jet (of order at least N) on a maximally symmetric (i.e. taylor) tangent bundle element. In particular, if we represent both the jet and the taylor tangent bundle element by their associated canonical taylor series:

j = j₀ + j₁ (x - a) + j₂ 1/2 (x - a)^2 + ... + jₙ 1/n! (x - a)^n
-t = t₀ + t₁ (x - t₀) + t₂ 1/2 (x - t₀)^2 + ... + tₙ 1/n! (x - t₀)^n

then the action of evaluating j on t, is some other taylor series

t′ = a + t′₁ (x - a) + t′₂ 1/2 (x - a)^2 + ... + t′ₙ 1/n! (x - a)^n

The t′ᵢ can be found by explicitly plugging in t for every x and expanding out, dropping terms of orders that are higher. This computes closed form expressions for the t′ᵢ that are hopefully easier on the compiler.

source
Diffractor.@∂Macro
@∂

Convenice macro for writing partial derivatives. E.g. The expression:

@∂ f(∂x, ∂y)

Will compute the partial derivative ∂^2 f/∂x∂y at (x, y)`. And similarly

@∂ f(∂²x, ∂y)

will compute the derivative ∂^3 f/∂x^2 ∂y at (x,y).

source
+t = t₀ + t₁ (x - t₀) + t₂ 1/2 (x - t₀)^2 + ... + tₙ 1/n! (x - t₀)^n

then the action of evaluating j on t, is some other taylor series

t′ = a + t′₁ (x - a) + t′₂ 1/2 (x - a)^2 + ... + t′ₙ 1/n! (x - a)^n

The t′ᵢ can be found by explicitly plugging in t for every x and expanding out, dropping terms of orders that are higher. This computes closed form expressions for the t′ᵢ that are hopefully easier on the compiler.

source
Diffractor.@∂Macro
@∂

Convenice macro for writing partial derivatives. E.g. The expression:

@∂ f(∂x, ∂y)

Will compute the partial derivative ∂^2 f/∂x∂y at (x, y)`. And similarly

@∂ f(∂²x, ∂y)

will compute the derivative ∂^3 f/∂x^2 ∂y at (x,y).

source
diff --git a/dev/index.html b/dev/index.html index 9e519200..1a1331dd 100644 --- a/dev/index.html +++ b/dev/index.html @@ -17,4 +17,4 @@ 3×3 Matrix{Float64}: 1.0 0.0 0.0 0.0 1.0 0.0 - 0.0 0.0 1.0 + 0.0 0.0 1.0 diff --git a/dev/reading_list.html b/dev/reading_list.html index 2fb947a5..2e41689e 100644 --- a/dev/reading_list.html +++ b/dev/reading_list.html @@ -1,2 +1,2 @@ -Reading List · Diffractor

This is a list of references I found useful while thinking about Diffractor. If you are new to Julia, AD or Diffractor and are primarily intersted in Diffractor, how it works, how to use it, or even the general Diffractor theory, this is probably not the list for you. As always in the literature, some of these references use terms differently from how they are used in Diffractor (as well as being inconsistent with each other). Additionally, many of these references are quite dense and though I've found small nuggets of insight in each, excavating those took many hours. Also, these are not introductory texts. If you've not taken an introductory differential geometry course, I would recommend looking for that first. Don't feel bad if some of these references read like like nonsense. It often reads that way to me too.

Reading on Optics

  • "Categories of Optics" - Mitchell Riley - https://arxiv.org/abs/1809.00738

The original paper on optics. Good background for understanding the optics terminology.

Readings on First Order Differential Geometry

  • "Introduction to Smooth Manifolds" John M. Lee

Chapter 11 "The Cotangent Bundle" is useful for a reference on the theory of cotangent bundles, which corresponds to the structure of reverse mode AD through the optical equivalence. Also a useful general reference for Differential Geomtry.

  • "Natural Operations in Differential Geometry" - Ivan Kolář

I recommend Chapter IV. "Jets and Natural bundles"

Readings on Higher Order Differential Geometry

  • "Second Order Tangent Vectors in Riemannian Geometry", Fisher and Laquer, J. Korean Math Soc 36 (1999)

This one is quite good. I recommend reading the first half at least and tracing through the definitions. This corresponds fairly closely to notion of iterated tangent spaces as implemented in Diffractor.

  • "The Geometry of Jet Bundles" D. J. Saunders

I recommend reading Chapter 5 "Second order Jet bundles", though of course some earlier chapters may be useful to understand this chapter. I'm not 100% happy with the notation, but it gives good intuition.

+Reading List · Diffractor

This is a list of references I found useful while thinking about Diffractor. If you are new to Julia, AD or Diffractor and are primarily intersted in Diffractor, how it works, how to use it, or even the general Diffractor theory, this is probably not the list for you. As always in the literature, some of these references use terms differently from how they are used in Diffractor (as well as being inconsistent with each other). Additionally, many of these references are quite dense and though I've found small nuggets of insight in each, excavating those took many hours. Also, these are not introductory texts. If you've not taken an introductory differential geometry course, I would recommend looking for that first. Don't feel bad if some of these references read like like nonsense. It often reads that way to me too.

Reading on Optics

  • "Categories of Optics" - Mitchell Riley - https://arxiv.org/abs/1809.00738

The original paper on optics. Good background for understanding the optics terminology.

Readings on First Order Differential Geometry

  • "Introduction to Smooth Manifolds" John M. Lee

Chapter 11 "The Cotangent Bundle" is useful for a reference on the theory of cotangent bundles, which corresponds to the structure of reverse mode AD through the optical equivalence. Also a useful general reference for Differential Geomtry.

  • "Natural Operations in Differential Geometry" - Ivan Kolář

I recommend Chapter IV. "Jets and Natural bundles"

Readings on Higher Order Differential Geometry

  • "Second Order Tangent Vectors in Riemannian Geometry", Fisher and Laquer, J. Korean Math Soc 36 (1999)

This one is quite good. I recommend reading the first half at least and tracing through the definitions. This corresponds fairly closely to notion of iterated tangent spaces as implemented in Diffractor.

  • "The Geometry of Jet Bundles" D. J. Saunders

I recommend reading Chapter 5 "Second order Jet bundles", though of course some earlier chapters may be useful to understand this chapter. I'm not 100% happy with the notation, but it gives good intuition.

diff --git a/dev/terminology.pdf b/dev/terminology.pdf index d1778459..fcba79eb 100644 Binary files a/dev/terminology.pdf and b/dev/terminology.pdf differ