wedge v1.0-3

0

Monthly downloads

0th

Percentile

The Exterior Calculus

Provides functionality for working with differentials, k-forms, wedge products, Stokes's theorem, and related concepts from the exterior calculus. The canonical reference would be: M. Spivak (1965, ISBN:0-8053-9021-9). "Calculus on Manifolds", Benjamin Cummings.

Readme

The wedge package: exterior calculus in R

Build
Status CRAN\_Status\_Badge Rdoc

Overview

The wedge package provides functionality for working with the exterior calculus. It includes cross products and wedge products and a variety of use-cases. The canonical reference would be Spivak (see references). A detailed vignette is provided in the package.

The package deals with k-tensors and k-forms. A k-tensor is a multilinear map S\\colon
V^k\\longrightarrow\\mathbb{R}, where V=\\mathbb{R}^n is considered as a vector space. Given two k-tensors S,T the package can calculate their outer product S\\otimes
T using natural R idiom (see below and the vignette for details).

A k-form is an alternating k-tensor, that is a k-tensor \\omega with the property that linear dependence of x\_1,\\ldots,x\_n implies that \\omega\\left(x\_1,\\ldots,x\_n\\right)=0. Given k-forms \\omega,\\eta, the package provides R idiom for calculating their wedge product \\omega\\wedge\\eta.

Installation

You can install the released version of wedge from CRAN with:

# install.packages("wedge")  # uncomment this to install the package
library("wedge")

The wedge package in use

The package has two main classes of objects, kform and ktensor. We may define a k-tensor as follows

KT <- as.ktensor(cbind(1:4,3:5),1:4)
#> Warning in cbind(1:4, 3:5): number of rows of result is not a multiple of
#> vector length (arg 2)
KT
#>          val
#>  1 3  =    1
#>  2 4  =    2
#>  3 5  =    3
#>  4 3  =    4

We can coerce KT to a function and then evaluate it:

KT <- as.ktensor(cbind(1:4,2:5),1:4)
f <- as.function(KT)
E <- matrix(rnorm(10),5,2)
f(E)
#> [1] -0.1383716

Cross products are implemented:

KT %X% KT
#>              val
#>  3 4 3 4  =    9
#>  2 3 1 2  =    2
#>  2 3 2 3  =    4
#>  3 4 1 2  =    3
#>  4 5 1 2  =    4
#>  1 2 1 2  =    1
#>  1 2 2 3  =    2
#>  2 3 3 4  =    6
#>  3 4 2 3  =    6
#>  4 5 4 5  =   16
#>  4 5 2 3  =    8
#>  1 2 3 4  =    3
#>  4 5 3 4  =   12
#>  1 2 4 5  =    4
#>  2 3 4 5  =    8
#>  3 4 4 5  =   12

Alternating forms

An alternating form (or k-form) is an antisymmetric k-tensor; the package can convert a general k-tensor to alternating form using the Alt() function:

Alt(KT)
#>           val
#>  1 2  =   0.5
#>  2 1  =  -0.5
#>  4 3  =  -1.5
#>  2 3  =   1.0
#>  3 2  =  -1.0
#>  5 4  =  -2.0
#>  3 4  =   1.5
#>  4 5  =   2.0

However, the package provides a bespoke and efficient representation for k-forms as objects with class kform. Such objects may be created using the as.kform() function:


M <- matrix(c(4,2,3,1,2,4),2,3,byrow=TRUE)
M
#>      [,1] [,2] [,3]
#> [1,]    4    2    3
#> [2,]    1    2    4
KF <- as.kform(M,c(1,5))
KF
#>            val
#>  2 3 4  =    1
#>  1 2 4  =    5

We may coerce KF to functional form:

f <- as.function(KF)
E <- matrix(rnorm(12),4,3)
f(E)
#> [1] -1.895993

The wedge product

The wedge product of two k-forms is implemented as %^% or wedge():

KF2 <- kform_general(6:9,2,1:6)
KF2
#>          val
#>  6 7  =    1
#>  6 8  =    2
#>  7 9  =    5
#>  7 8  =    3
#>  6 9  =    4
#>  8 9  =    6
KF %^% KF2
#>                val
#>  2 3 4 6 7  =    1
#>  1 2 4 6 8  =   10
#>  1 2 4 6 9  =   20
#>  2 3 4 7 9  =    5
#>  1 2 4 7 9  =   25
#>  2 3 4 6 8  =    2
#>  1 2 4 6 7  =    5
#>  2 3 4 8 9  =    6
#>  2 3 4 6 9  =    4
#>  2 3 4 7 8  =    3
#>  1 2 4 7 8  =   15
#>  1 2 4 8 9  =   30

The package can accommodate a number of results from the exterior calculus such as elementary forms:

dx <- as.kform(1)
dy <- as.kform(2)
dz <- as.kform(3)
dx %^% dy %^% dz  # element of volume 
#>            val
#>  1 2 3  =    1

A number of useful functions from the exterior calculus are provided, such as the gradient of a scalar function:

grad(1:6)
#>        val
#>  1  =    1
#>  2  =    2
#>  3  =    3
#>  4  =    4
#>  5  =    5
#>  6  =    6

The package takes the leg-work out of the exterior calculus:

grad(1:4) %^% grad(1:6)
#>          val
#>  2 5  =   10
#>  3 5  =   15
#>  3 6  =   18
#>  1 5  =    5
#>  2 6  =   12
#>  4 5  =   20
#>  1 6  =    6
#>  4 6  =   24

References

The most concise reference is

  • Spivak 1971. Calculus on manifolds, Addison-Wesley.

But an accessible book would be

  • Hubbard and Hubbard 2015. Vector calculus, linear algebra, and differential forms: a unified approach. Matrix Editions

Further information

For more detail, see the package vignette

vignette("wedge")

Functions in wedge

Name Description
inner Inner product operator
contract Contractions of \(k\)-forms
hodge Hodge star operator
as.1form Coerce vectors to 1-forms
Alt Alternating multilinear forms
issmall Is a form zero to within numerical precision?
keep Keep or drop variables
consolidate Various low-level helper functions
cross Cross products of \(k\)-tensors
Ops.kform Arithmetic Ops Group Methods for kform and ktensor objects
kform k-forms
wedge-package wedge
volume The volume element
symbolic Symbolic form
transform Linear transforms of \(k\)-forms
ktensor k-tensors
zero Zero tensors and zero forms
wedge Wedge products
rform Random kforms and ktensors
scalar Lose attributes
No Results!

Vignettes of wedge

Name
wedge.Rmd
No Results!

Last month downloads

Details

Type Package
VignetteBuilder knitr
License GPL-2
URL https://github.com/RobinHankin/wedge.git
BugReports https://github.com/RobinHankin/wedge/issues
NeedsCompilation no
Packaged 2019-09-04 02:20:51 UTC; rhankin
Repository CRAN
Date/Publication 2019-09-04 05:10:03 UTC

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/wedge)](http://www.rdocumentation.org/packages/wedge)