onion

R functionality to deal with quaternions and octonions

https://github.com/robinhankin/onion

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.1%) to scientific vocabulary
Last synced: 8 months ago · JSON representation ·

Repository

R functionality to deal with quaternions and octonions

Basic Info
  • Host: GitHub
  • Owner: RobinHankin
  • Language: R
  • Default Branch: master
  • Size: 1.78 MB
Statistics
  • Stars: 6
  • Watchers: 1
  • Forks: 1
  • Open Issues: 4
  • Releases: 0
Created almost 8 years ago · Last pushed about 1 year ago
Metadata Files
Readme Contributing Code of conduct Citation

README.Rmd

---
title: "Quaternions and octonions in R"
output:
  github_document:
    pandoc_args: --webtex
---



```{r setup, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
```





[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/onion)](https://cran.r-project.org/package=onion)


# Overview

The `onion` package provides functionality for working with
quaternions and octonions in R.  A detailed vignette is provided in
the package.

Informally, the *quaternions*, usually denoted $\mathbb{H}$, are a
generalization of the complex numbers represented as a
four-dimensional vector space over the reals.  An arbitrary quaternion
$q$ represented as

$$
q=a + b\mathbf{i} + c\mathbf{j}+ d\mathbf{k}
$$

where $a,b,c,d\in\mathbb{R}$ and $\mathbf{i},\mathbf{j},\mathbf{k}$
are the quaternion units linked by the equations

$$
\mathbf{i}^2=
\mathbf{j}^2=
\mathbf{k}^2=
\mathbf{i}\mathbf{j}\mathbf{k}=-1.$$

which, together with distributivity, define quaternion multiplication.
We can see that the quaternions are not commutative, for while
$\mathbf{i}\mathbf{j}=\mathbf{k}$, it is easy to show that
$\mathbf{j}\mathbf{i}=-\mathbf{k}$.  Quaternion multiplication is,
however, associative (the proof is messy and long).

Defining

$$
\left( a+b\mathbf{i} + c\mathbf{j}+ d\mathbf{k}\right)^{-1}=
\frac{1}{a^2 + b^2 + c^2 + d^2}
\left(a-b\mathbf{i} - c\mathbf{j}- d\mathbf{k}\right)
$$

shows that the quaternions are a division algebra: division works as
expected (although one has to be careful about ordering terms).


The *octonions* $\mathbb{O}$ are essentially a pair of quaternions,
with a general octonion written

$$a+b\mathbf{i}+c\mathbf{j}+d\mathbf{k}+e\mathbf{l}+f\mathbf{il}+g\mathbf{jl}+h\mathbf{kl}$$

(other notations are sometimes used); Baez gives a multiplication
table for the unit octonions and together with distributivity we have
a well-defined division algebra.  However, octonion multiplication is
not associative and we have $x(yz)\neq (xy)z$ in general.

# Installation

You can install the released version of onion from
[CRAN](https://CRAN.R-project.org) with:

```{r, message=FALSE}
# install.packages("onion")  # uncomment this to install the package
library("onion")
```

# The `onion` package in use

The basic quaternions are denoted `H1`, `Hi`, `Hj` and
`Hk` and these should behave as expected in R idiom:

```{r}
a <- 1:9 + Hi -2*Hj
a
a*Hk
Hk*a
```

Function `rquat()` generates random quaternions:

```{r, echo=FALSE}
set.seed(0)
```

```{r}
a <- rquat(9)
names(a) <- letters[1:9]
a
a[6] <- 33
a
cumsum(a)
```

## Octonions

Octonions follow the same general pattern and we may show
nonassociativity numerically:

```{r}
x <- roct(5)
y <- roct(5)
z <- roct(5)
x*(y*z) - (x*y)*z
```

# References

- RKS Hankin (2006).  "Normed division algebras with R: introducing the onion package". _R News_, 6(2):49-52
- JC Baez (2001). "The octonions".  _Bulletin of the American Mathematical Society_, 39(5), 145--205


# Further information

For more detail, see the package vignette

`vignette("onion")`

Owner

  • Name: Robin Hankin
  • Login: RobinHankin
  • Kind: user
  • Location: Auckland
  • Company: AUT

pushing the boundaries of R in non-statistical contexts

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Hankin"
  given-names: "Robin K. S."
  orcid: "https://orcid.org/0000-0001-5982-0415"
title: "Normed division algebras with R: Introducing the onion package"
version: 2.0-1
url: "https://github.com/RobinHankin/onion"
preferred-citation:
  type: article
  authors:
  - family-names: "Hankin"
    given-names: "Robin K. S."
    orcid: "https://orcid.org/0000-0001-5982-0415"
  journal: "R News"
  title: "Normed division algebras with R: Introducing the onion package"
  volume: 6
  issue: 2
  start: 49
  end: 52
  year: 2006

GitHub Events

Total
  • Push event: 3
Last Year
  • Push event: 3

Committers

Last synced: over 2 years ago

All Time
  • Total Commits: 353
  • Total Committers: 3
  • Avg Commits per committer: 117.667
  • Development Distribution Score (DDS): 0.017
Past Year
  • Commits: 18
  • Committers: 1
  • Avg Commits per committer: 18.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
RobinHankin h****n@g****m 347
Robin Hankin R****n 4
Robin Hankin r****n@w****z 2
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 8 months ago

All Time
  • Total issues: 24
  • Total pull requests: 1
  • Average time to close issues: 5 months
  • Average time to close pull requests: 8 months
  • Total issue authors: 4
  • Total pull request authors: 1
  • Average comments per issue: 1.67
  • Average comments per pull request: 1.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • RobinHankin (18)
  • stla (4)
  • ggrothendieck (1)
  • MamtaMohan (1)
Pull Request Authors
  • stla (1)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

DESCRIPTION cran
  • R >= 3.5.0 depends
  • methods * depends
  • Matrix * imports
  • emulator * imports
  • knitr * suggests
  • rmarkdown * suggests
  • testthat * suggests