## DifferentialForms.jl

Differential forms in Julia
Author eschnett
Popularity
5 Stars
Updated Last
7 Months Ago
Started In
August 2020

# Differential Forms

Implement differential forms in Julia.

## Overview

Differential forms are an often very convenient alternative to using tensor algebra for multi-dimensional geometric calculations. The fundamental quantity is an R-form (a form with rank R). In D dimensions, 0 ≤ R ≤ D. R-forms are isomorphic to totally antisymmetric rank-R tensors.

In addition to the usual vector operations (add, subtract, scale, dot product), forms also offer an exterior product (or wedge product, written x ∧ y) that is equivalent to an antisymmetrized tensor product, as well as a hodge dual (written ⋆x, a prefix star operator). Calculating these two operations efficiently for arbitrary dimensions and ranks is not trivial, and is the main contribution of this package.

## Examples

We use D=3 dimensions.

Create some forms:

julia> using DifferentialForms

julia> # Create a 0-form (a scalar):
e = one(Form{3})
Float64⟦1.0⟧{3,0}

julia> e[] == 1
true

julia> collect(e) == 
true

julia> # Create a 1-form (a vector) from a tuple:
v = Form{3,1}((1, 2, 3))
Int64⟦1,2,3⟧{3,1}

julia> v == 1
true

julia> v == 2
true

julia> v == 3
true

julia> collect(v) == [1, 2, 3]
true

julia> # Create a 2-form (an axial vector) from a tuple:
a = Form{3,2}((1, 2, 3))
Int64⟦1,2,3⟧{3,2}

julia> a[1, 2] == 1
true

julia> a[1, 3] == 2
true

julia> a[2, 3] == 3
true

julia> collect(a) == [1, 2, 3]
true

julia> # Create a 3-form (a pseudoscalar):
p = Form{3,3}((1,))
Int64⟦1⟧{3,3}

julia> p[1, 2, 3] == 1
true

julia> p[end] == 1
true

julia> collect(p) == 
true

a2 = 2*a
Int64⟦2,4,6⟧{3,2}

julia> a3 = a + a2
Int64⟦3,6,9⟧{3,2}

julia> a3 == 3*a
true

julia> # Exterior product (type \wedge<tab>)
# q = wedge(v, a)
q = v ∧ a
Float64⟦2.0⟧{3,3}

julia> q == Form{3,3}((2,))
true

julia> # Dot product (type \cdot<tab>)
# b = dot(v, v)
b = v ⋅ v
Float64⟦14.0⟧{3,0}

julia> b == 14 * one(Form{3})
true

julia> c = a ⋅ a
Float64⟦14.0⟧{3,0}

julia> c == 14 * one(Form{3})
true

julia> # Cross product (type \times<tab>)
# w = cross(a, a)
w = v × v
Float64⟦0.0,-0.0,0.0⟧{3,1}

julia> w == zero(Form{3,1})
true

## Related work

This package draws inspiration from Grassmann.jl, which includes similar functionality.

DiscreteDifferentialGeometry.jl also provides similar functionality, but only for two-dimensional meshes.
{"ft_lang_label":"__label__en","ft_lang_prob":0.71739787,"math_prob":0.98916346,"size":2336,"snap":"2021-31-2021-39","text_gpt3_token_len":898,"char_repetition_ratio":0.16337907,"word_repetition_ratio":0.043701798,"special_character_ratio":0.36386988,"punctuation_ratio":0.15728155,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9973881,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-09-26T19:53:48Z\",\"WARC-Record-ID\":\"<urn:uuid:b7db329a-5798-45fd-96c8-f2c43a34e95a>\",\"Content-Length\":\"82590\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:00c345e8-036f-4863-ab2b-d3d7e12c32ca>\",\"WARC-Concurrent-To\":\"<urn:uuid:8f891b01-1a98-4657-9c50-41c1a490df27>\",\"WARC-IP-Address\":\"13.249.38.93\",\"WARC-Target-URI\":\"https://juliapackages.com/p/differentialforms\",\"WARC-Payload-Digest\":\"sha1:FCSQCQQOT7UFHCMUUZCW37CAB2NZ3E4T\",\"WARC-Block-Digest\":\"sha1:4VKWQ7YGQZD6MBCFZIB5NT6YPJ6P47M3\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-39/CC-MAIN-2021-39_segments_1631780057913.34_warc_CC-MAIN-20210926175051-20210926205051-00159.warc.gz\"}"}