@zushah/chalkboard 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,48 @@
1
1
  # Chalkboard changelog
2
2
  All notable changes of every update of the Chalkboard library are recorded in this file.
3
3
 
4
+ ## [v2.2.0 Galois](https://www.github.com/Zushah/Chalkboard/releases/tag/v2.2.0) - 04/07/2024
5
+ The twelfth release of the Chalkboard library.
6
+ Commits: [`v2.1.0...v2.2.0`](https://www.github.com/Zushah/Chalkboard/compare/v2.1.0...v2.2.0)
7
+ - Added abstract algebra functionalities with the new `abal` category containing 76 commands, so only a few notable ones are mentioned below
8
+ - Added `abal.set` which defines a mathematical set, as well as `abal.Z` which defines the set of integers or the set of integers modulo n, `abal.Q` which defines the set of rational numbers, `abal.R` which defines the set of real numbers, and `abal.C` which defines the set of complex numbers or the set of nth roots of unity
9
+ - Added `abal.union`, `abal.intersection`, `abal.complement`, `abal.difference`, `abal.symmetricDifference`, `abal.Cartesian`, `abal.powerSet`, `abal.isSubset`, and `abal.isSuperset` which respectively calculate the union of two sets, the intersection of two sets, the complement of a set, the difference of two sets, the symmetric difference of two sets, the Cartesian product of two sets, the power set of a set, whether or not a set is a subset of another set, and whether or not a set is a superset of another set
10
+ - Added `abal.group`, `abal.ring`, and `abal.field` which define the algebraic structures known as groups, rings, and fields
11
+ - Added `abal.direct` which calculates the direct sum or direct product of two algebraic structures
12
+ - Added `abal.cosets` and `abal.quotient` which respectively calculate the cosets or quotient structure of two inputted algebraic structures
13
+ - Added `abal.homomorphism`, `abal.endomorphism`, `abal.isomorphism`, `abal.automorphism`, `abal.idmorphism`, and `abal.invmorphism` which define various types of morphisms between one or two algebraic structures
14
+ - Added `abal.compose` which calculates the composition morphism of two given morphisms
15
+ - Added `abal.image`, `abal.preimage`, and `abal.kernel` which respectively calculate the image, preimage, or kernel of a given morphism
16
+ - Added `abal.cardinality` which calculates the cardinality of a set or the set of a structure
17
+ - Added `abal.isEqual` which checks if two sets, structures, or morphisms are equal
18
+ - Added `abal.copy` which creates a copy of a set, structure, or morphism
19
+ - Added `abal.toArray`, `abal.toMatrix`, `abal.toObject`, `abal.toString`, `abal.toTensor`, and `abal.toVector` which convert sets or structures to arrays, matricies, objects, strings, tensors, or vectors, and `abal.print` prints a set or structure in the console
20
+ - Added `stat.Bayes` which calculates the posterior probability given prior probabilities
21
+ - Added `stat.expected` which calculates the expected value of an array given the probabilities of its elements
22
+ - Added `stat.normal` and `stat.inormal` which respectively calculate the values of the standard normal distribution and cumulative distribution function of the standard normal distribution
23
+ - Added `stat.resampling` which resamples an array either by the bootstrap or jackknife methods
24
+ - Added `stat.interpolate` which linearly or quadratically interpolates missing elements in an array
25
+ - Added `stat.absolute` which takes the absolute value of the elements of an array, `stat.negate` which negates the elements of an array, `stat.add` which adds the elements of two arrays, `stat.sub` which subtracts the elements of two arrays, `stat.dot` which calculates the dot product of two arrays, `stat.scl` which scales the elements of an array by a given number, `stat.sum` which calculates the sum of the elements of an array, `stat.mul` which calculates the product of the elements of an array, and `stat.reverse` which reverses the elements of an array
26
+ - Added `stat.cumsum`, `stat.cummul`, `stat.cummax`, and `stat.cummin` which respectively calculate the cumululative sum, product, maximum, and minimum of an array
27
+ - Added `stat.meanMoving` and `stat.meanWeighted` which respectively calculate the moving and weighted averages of an array
28
+ - Added `stat.covariance` which calculates the covariance of two arrays and `stat.correlationCoefficient` which calculates the correlation coefficient of two arrays
29
+ - Added `stat.interquartileRange` which calculates the interquartile range of an array
30
+ - Added `stat.zscored` which standardizes the elements of an array by their mean and standard deviation
31
+ - Added `stat.pad` which pads an array by a given element to a given length
32
+ - Added `stat.unique` which deduplicates an array of numbers, arrays, objects, etc.
33
+ - Added `matr.toSet`, `stat.toSet` and `tens.toSet` to convert matrices, arrays, and tensors to sets
34
+ - Added `numb.toFraction` to convert decimals to fractions and `numb.isRational` to check if a number is rational
35
+ - Changed `APPLY` to work for sets and algebraic structures introduced in the `abal` category
36
+ - Changed `stat.change` and `stat.chiSquared` to be written more succinctly
37
+ - Changed `stat.confidenceInterval` to use an adjustable confidence level
38
+ - Changed `stat.toMatrix` to be able to use only one parameter for the size of the matrix instead of requiring two
39
+ - Changed `matr.rotator` to be faster
40
+ - Changed `comp.toString` to output 1, i, -1, or -i when 1+0i, 0+1i, -1+0i, or 0-1i are inputted
41
+ - Fixed `comp.div` which was broken for who knows how long because it was using the wrong formula for some reason
42
+ - Fixed `matr.resize` which was always returning zero matrices
43
+ - Fixed `matr.zero` which was unnecessarily using erasing operations
44
+ - Fixed `tens.init` which had an expression assigned to itself
45
+
4
46
  ## [v2.1.0 Seki](https://www.github.com/Zushah/Chalkboard/releases/tag/v2.1.0) - 01/22/2024
5
47
  The eleventh release of the Chalkboard library.
6
48
  Commits: [`v2.0.0...v2.1.0`](https://www.github.com/Zushah/Chalkboard/compare/v2.0.0...v2.1.0)
@@ -42,7 +84,7 @@ Commits: [`v1.7.0...v2.0.0`](https://www.github.com/Zushah/Chalkboard/compare/v1
42
84
  - Changed `real.function` to be renamed as `real.define`, `comp.function` to be renamed as `comp.define`, and `plot.function` to be renamed as `plot.definition`
43
85
  - Changed `LOGO` to draw the logo as a circle instead of a square
44
86
  - Changed `matr.mulvec` to be renamed as `matr.mulVector`
45
- - Fixed `matr.mulVector`` which didn't work when the rows of the matrix equaled the dimension of the vector
87
+ - Fixed `matr.mulVector` which didn't work when the rows of the matrix equaled the dimension of the vector
46
88
  - Discontinued the Processsing.js edition of the library, meaning it will no longer be updated and it will only be available on the Khan Academy release (it will no longer be available on GitHub)
47
89
 
48
90
  ## [v1.7.0 Descartes](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.7.0) - 01/01/2024
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023-2024 Zushah
3
+ Copyright (c) 2023-2025 Zushah
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  <p align="center"><a href="https://www.github.com/Zushah/Chalkboard"><img src="https://raw.githubusercontent.com/Zushah/Chalkboard/main/assets/Chalkboard-logo.png" width="50%"></a></p>
2
2
  <p align="center">
3
- <a href="https://www.github.com/Zushah/Chalkboard/releases/tag/v2.1.0"><img src="https://img.shields.io/badge/release-v2.1.0_Seki-blueviolet?logo=github&logoColor=white" alt="Latest release"></a>
3
+ <a href="https://www.github.com/Zushah/Chalkboard/releases/tag/v2.2.0"><img src="https://img.shields.io/badge/release-v2.2.0_Galois-blueviolet?logo=github&logoColor=white" alt="Latest release"></a>
4
4
  <a href="https://www.codefactor.io/repository/github/zushah/chalkboard"><img src="https://img.shields.io/codefactor/grade/github/Zushah/Chalkboard?color=blue&logo=codefactor&logoColor=white" alt="CodeFactor grade"></a>
5
- <a href="https://bundlephobia.com/package/@zushah/chalkboard@2.1.0"><img src="https://img.shields.io/bundlephobia/min/%40zushah/chalkboard?color=darkgreen&logo=files&logoColor=white" alt="Minified size"></a>
5
+ <a href="https://bundlephobia.com/package/@zushah/chalkboard@2.2.0"><img src="https://img.shields.io/bundlephobia/min/%40zushah/chalkboard?color=darkgreen&logo=files&logoColor=white" alt="Minified size"></a>
6
6
  <a href="https://www.npmjs.com/package/@zushah/chalkboard"><img src="https://img.shields.io/npm/dm/%40zushah/chalkboard?logo=npm&logoColor=white" alt="npm downloads"></a>
7
7
  <a href="https://www.github.com/Zushah/Chalkboard/blob/main/LICENSE.md"><img src="https://img.shields.io/github/license/Zushah/Chalkboard?color=yellow&logo=opensourceinitiative&logoColor=white" alt="MIT License"></a>
8
- <a href="https://en.wikipedia.org/wiki/TypeScript"><img src="https://img.shields.io/github/languages/top/Zushah/Chalkboard?color=orange&logo=typescript&logoColor=white" alt="Written in TypeScript"></a>
8
+ <a href="https://www.github.com/microsoft/TypeScript"><img src="https://img.shields.io/github/languages/top/Zushah/Chalkboard?color=blue&logo=typescript&logoColor=white" alt="Written in TypeScript"></a>
9
9
  <a href="https://www.jsdelivr.com/package/gh/Zushah/Chalkboard"><img src="https://img.shields.io/jsdelivr/gh/hm/Zushah/Chalkboard?color=crimson&logo=jsdelivr&logoColor=white" alt="jsDelivr requests"></a>
10
10
  <br>
11
11
  <a href="https://zushah.github.io/Chalkboard">https://zushah.github.io/Chalkboard</a>
@@ -23,23 +23,24 @@
23
23
  </ol>
24
24
 
25
25
  # About
26
- The Chalkboard library is a JavaScript namespace that provides a plethora of both practical and abstract mathematical functionalities for its user. It was developed by [Zushah](https://www.github.com/Zushah) during 2022 and 2023 and then [released](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.0.0) on November 6, 2023. As per the latest release of [v2.1.0 Seki](https://www.github.com/Zushah/Chalkboard/releases/tag/v2.1.0), Chalkboard has 455 different commands. The library is available for regular JavaScript on both the client-side and the server-side as well as [Proccesing.js](https://www.processing.org/) (fully compatible with [Khan Academy](https://www.khanacademy.org/cs/chalkboard/6708642430369792)). Chalkboard's website can be visited [here](https://zushah.github.io/Chalkboard).
26
+ The Chalkboard library is a JavaScript namespace that provides a plethora of both practical and abstract mathematical functionalities for its user. It was developed by [Zushah](https://www.github.com/Zushah) during 2022 and 2023 and then [released](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.0.0) on November 6, 2023. As per the latest release of [v2.2.0 Galois](https://www.github.com/Zushah/Chalkboard/releases/tag/v2.2.0), Chalkboard has 564 unique commands. The library is available for regular JavaScript on both the client-side and the server-side as well as [Proccesing.js](https://www.processing.org/) (fully compatible with [Khan Academy](https://www.khanacademy.org/cs/chalkboard/6708642430369792)). Chalkboard's website can be visited [here](https://zushah.github.io/Chalkboard).
27
27
 
28
28
  # Installation
29
29
  If your JavaScript project is being run on the client-side within a webpage, you can install Chalkboard with this HTML tag:
30
30
  ```html
31
- <script src="https://cdn.jsdelivr.net/gh/Zushah/Chalkboard@2.1.0/dist/Chalkboard.min.js"></script>
31
+ <script src="https://cdn.jsdelivr.net/gh/Zushah/Chalkboard@2.2.0/dist/Chalkboard.min.js"></script>
32
32
  ```
33
33
  If your JavaScript project is being run on the server-side within the [Node.js](https://nodejs.org/en) environment, you can install Chalkboard with this console command:
34
34
  ```bash
35
35
  npm install @zushah/chalkboard
36
36
  ```
37
- Alternatively, you can simply download the [latest release](https://www.github.com/Zushah/Chalkboard/releases/tag/v2.1.0) and put the relevant files in your project's directory.
37
+ Alternatively, you can simply download the [latest release](https://www.github.com/Zushah/Chalkboard/releases/tag/v2.2.0) and put the relevant files in your project's directory.
38
38
 
39
39
  Chalkboard can also be downloaded on [Khan Academy](https://www.khanacademy.org) from the code in the corresponding [release](https://www.khanacademy.org/cs/chalkboard/6708642430369792).
40
40
 
41
41
  # Documentation
42
- Chalkboard has twelve categories of commands:
42
+ Chalkboard has thirteen categories of commands:
43
+ - `abal` - Abstract algebra definitions, sets, operations, structures, and morphisms
43
44
  - `calc` - Single/multi-variable real/complex-valued calculus operations
44
45
  - `comp` - Complex number and complex function operations
45
46
  - `geom` - Geometric operations
@@ -64,11 +65,15 @@ There are also eight "global" commands and constants, which are:
64
65
  - `VERSION` - The installed version of Chalkboard
65
66
  - `VERSIONALIAS` - The alias of the installed version of Chalkboard
66
67
 
67
- Lastly, Chalkboard has seven data types (also known as Chalkboard objects):
68
+ Lastly, Chalkboard has eleven data types (also known as Chalkboard objects):
68
69
  - `ChalkboardComplex` - Complex numbers
69
70
  - `ChalkboardFunction` - Mathematical functions
70
71
  - `ChalkboardMatrix` - Matrices
72
+ - `ChalkboardMorphism` - Morphisms
71
73
  - `ChalkboardQuaternion` - Quaternions
74
+ - `ChalkboardSet` - Sets
75
+ - `ChalkboardStructure` - Algebraic structures
76
+ - `ChalkboardStructureExtension` - Algebraic structure extensions
72
77
  - `ChalkboardTensor` - Tensors
73
78
  - `ChalkboardVector` - Vectors
74
79
  - `ChalkboardVectorField` - Vector fields
@@ -83,51 +88,49 @@ Chalkboard.category.command(parameters);
83
88
  Here is some code that shows off only a few features of Chalkboard:
84
89
  ```js
85
90
  const cb = Chalkboard; // Initialize in a browser
86
- // or
87
91
  const cb = require("@zushah/chalkboard"); // Initialize in Node with CommonJS
88
- // or
89
92
  import cb from "@zushah/chalkboard"; // Initiialize in Node with ES Modules
90
93
 
91
- let f = cb.real.define("Math.cos(2 * x)"); // f(x) = cos(2x)
92
- let dfdx = cb.calc.dfdx(f, 2); // Derivative of f at x = 0
93
- let fxdx = cb.calc.fxdx(f, 0, 2); // Antiderivative of f from x = 0 to x = 2
94
- let fourier = cb.calc.Fourier(f, 2); // Fourier transform of f at x = 2
94
+ const f = cb.real.define("Math.cos(2 * x)"); // f(x) = cos(2x)
95
+ const dfdx = cb.calc.dfdx(f, 2); // Derivative of f at x = 0
96
+ const fxdx = cb.calc.fxdx(f, 0, 2); // Antiderivative of f from x = 0 to x = 2
97
+ const fourier = cb.calc.Fourier(f, 2); // Fourier transform of f at x = 2
95
98
 
96
- let f = cb.vect.field("x", "y", "z"); // f(x, y, z) = (x, y, z)
97
- let r = cb.real.define(["Math.cos(s) * Math.cos(t)", "Math.sin(s) * Math.cos(t)", "Math.sin(t)"], "surf"); // r(s, t) = (cos(s)cos(t), sin(s)cos(t), sin(t))
98
- let fnds = cb.calc.fnds(f, r, cb.PI(-1/2), cb.PI(1/2), 0, cb.PI(2)); // Flux of the radial vector field through the unit sphere
99
+ const f = cb.vect.field("x", "y", "z"); // f(x, y, z) = (x, y, z)
100
+ const r = cb.real.define(["Math.cos(s) * Math.cos(t)", "Math.sin(s) * Math.cos(t)", "Math.sin(t)"], "surf"); // r(s, t) = (cos(s)cos(t), sin(s)cos(t), sin(t))
101
+ const fnds = cb.calc.fnds(f, r, cb.PI(-1/2), cb.PI(1/2), 0, cb.PI(2)); // Flux of the radial vector field through the unit sphere
99
102
 
100
- let primes = cb.numb.primeArr(0, 100); // Array of prime numbers between 0 and 100
101
- let midPrime = cb.stat.median(primes); // Median number in the primes array
103
+ const primes = cb.numb.primeArr(0, 100); // Array of prime numbers between 0 and 100
104
+ const midPrime = cb.stat.median(primes); // Median number in the primes array
102
105
  cb.plot.barplot(primes, cb.stat.array(0, 100, 11), {size: 5, strokeStyle: "black", fillStyle: "blue"}); // Barplot of the primes array with a bin size of 10, a scale of 2, a stroke color of black, and a fill color of blue
103
106
 
104
- let z = cb.comp.init(1, 1); // z = 1 + i
105
- let zsqsqrt = cb.comp.sqrt(cb.comp.sq(z)); // The square root of z squared equals z
106
- let f = cb.comp.define("a*a - b*b + 1", "2*a*b"); // f(z) = z^2 + 1
107
+ const z = cb.comp.init(1, 1); // z = 1 + i
108
+ const zsqsqrt = cb.comp.sqrt(cb.comp.sq(z)); // The square root of z squared equals z
109
+ const f = cb.comp.define("a*a - b*b + 1", "2*a*b"); // f(z) = z^2 + 1
107
110
  cb.plot.definition(f); // Plots the domain coloring of f
108
111
 
109
- let r = cb.real.define(["Math.cos(t)", "Math.sin(t)"], "curv"); // r(t) = (cos(t), sin(t))
112
+ const r = cb.real.define(["Math.cos(t)", "Math.sin(t)"], "curv"); // r(t) = (cos(t), sin(t))
110
113
  cb.plot.xyplane({size: 2}); // Draws the Cartesian coordinate plane scaled by 2
111
114
  cb.plot.definition(r, {size: 2, strokeStyle: "rgb(255, 100, 100)", domain: [0, cb.PI(2)]}); // Plots r(t) scaled by 2 colored light red from t = 0 to t = π/2
112
115
 
113
- let a = cb.vect.init(1, 2, 3); // Vector a = (1, 2, 3)
114
- let b = cb.vect.init(4, 5, 6); // Vector b = (4, 5, 6)
115
- let c = cb.vect.init(7, 8, 9); // Vector c = (7, 8, 9)
116
- let axbxc = cb.vect.vectorTriple(a, b, c); // Triple cross product between a, b, and c
116
+ const a = cb.vect.init(1, 2, 3); // Vector a = (1, 2, 3)
117
+ const b = cb.vect.init(4, 5, 6); // Vector b = (4, 5, 6)
118
+ const c = cb.vect.init(7, 8, 9); // Vector c = (7, 8, 9)
119
+ const axbxc = cb.vect.vectorTriple(a, b, c); // Triple cross product between a, b, and c
117
120
  cb.vect.print(axbxc); // Prints axbxc in the console
118
121
 
119
- let m = cb.matr.init( // m is a 5x5 matrix
122
+ const m = cb.matr.init( // m is a 5x5 matrix
120
123
  [0, 1, 1, 1, 1],
121
124
  [1, 0, 1, 1, 1],
122
125
  [1, 1, 0, 1, 1],
123
126
  [1, 1, 1, 0, 1],
124
127
  [1, 1, 1, 1, 0]
125
128
  );
126
- let mi = cb.matr.invert(m); // mi is the inverse of m
127
- let mmi = cb.matr.mul(m, mi); // mmi is the product of m and mi
129
+ const mi = cb.matr.invert(m); // mi is the inverse of m
130
+ const mmi = cb.matr.mul(m, mi); // mmi is the product of m and mi
128
131
  cb.matr.print(mmi); // Prints mmi in the console
129
132
 
130
- let t = cb.tens.init( // t is a 2x2x2 rank-3 tensor
133
+ const t = cb.tens.init( // t is a 2x2x2 rank-3 tensor
131
134
  [
132
135
  [1, 2],
133
136
  [3, 4]
@@ -137,21 +140,23 @@ let t = cb.tens.init( // t is a 2x2x2 rank-3 tensor
137
140
  [7, 8]
138
141
  ]
139
142
  );
140
- let tt = cb.tens.mul(t, t); // tt is a 2x2x2x2x2x2 rank-6 tensor
141
- let ttm = cb.tens.resize(tt, 8, 8); // ttm is an 8x8 matrix (or rank-2 tensor)
143
+ const tt = cb.tens.mul(t, t); // tt is a 2x2x2x2x2x2 rank-6 tensor
144
+ const ttm = cb.tens.resize(tt, 8, 8); // ttm is an 8x8 matrix (or rank-2 tensor)
142
145
  cb.tens.print(tt); // Prints tt in the console just to see what it looks like for fun
146
+ const factorialt = cb.APPLY(t, (x) => cb.numb.factorial(x)); // Calculates the factorial of each element of t
143
147
 
144
- // Calculates the factorial of each element of t
145
- let factorialt = cb.APPLY(t, (x) => {
146
- return cb.numb.factorial(x);
147
- });
148
+ const Z4 = cb.abal.Z(4); // The set of integers modulo 4 is the set {0, 1, 2, 3}
149
+ const C4 = cb.abal.C(4); // The set of fourth roots of unity is the set {1, i, -1, -i}
150
+ const G = cb.abal.group(Z4, (a, b) => (a + b) % 4); // The group G is the set Z4 with mod 4 addition
151
+ const H = cb.abal.group(C4, (z, w) => cb.comp.mul(z, w)); // The group H is the set C4 with complex multiplication
152
+ const F = cb.abal.isomorphism(G, H, (n) => cb.comp.round(cb.comp.pow(cb.comp.init(0, 1), n))); // The isomorphism F: G → H is defined by F(n) = i^n for all n in Z4
148
153
  ```
149
- More examples that are more interesting can be seen [here](https://zushah.github.io/Chalkboard/examples/index.html) with their source code [here](https://www.github.com/Zushah/Chalkboard/tree/main/examples).
154
+ Several examples that are rather interesting can be seen [here](https://zushah.github.io/Chalkboard/examples/index.html), and their source code is [here](https://www.github.com/Zushah/Chalkboard/tree/main/examples).
150
155
 
151
156
  # Contributing
152
157
  <ol>
153
158
  <li>Fork Chalkboard's GitHub repository. Make sure the fork is based on the main branch.</li>
154
- <li>Clone the repository, download the dependencies with `npm install`, and then make your contributions to your fork.</li>
159
+ <li>Clone the repository, download the dev dependencies with `npm install`, and then make your contributions to your fork.</li>
155
160
  <li>When you're done, commit the changes to your fork with a detailed description.</li>
156
161
  <li>Open a pull request. It will be reviewed soon and then merged to the main branch.</li>
157
162
  </ol>
@@ -163,9 +168,9 @@ The changelog can be read [here](https://www.github.com/Zushah/Chalkboard/blob/m
163
168
  The Chalkboard library is available under the [MIT License](https://www.github.com/Zushah/Chalkboard/blob/main/LICENSE.md).
164
169
 
165
170
  # Acknowledgments
166
- Thanks to [@bhavjitChauhan](https://www.github.com/bhavjitChauhan) for his [contribution](https://www.github.com/Zushah/Chalkboard/pull/1) to [v1.3.0 Heaviside](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.3.0).\
167
- Thanks to [@gyang0](https://www.github.com/gyang0) for his [contribution](https://www.github.com/Zushah/zushah.github.io/pull/1) to the [documentation](https://www.github.com/Zushah/zushah.github.io/tree/main/Chalkboard).\
168
- Thanks to [@JentGent](https://www.github.com/JentGent) for his [implementation](https://www.github.com/JentGent/linalg/blob/main/linalg.js#L519) for calculating QR decomposition which was [adapted](https://www.github.com/Zushah/Chalkboard/commit/1dce0dbac82b38f9a550dd496bc878c402a92442) into [v1.7.0 Descartes](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.7.0).
171
+ Thanks to [@bhavjitChauhan](https://www.github.com/bhavjitChauhan) for his contribution ([here](https://www.github.com/Zushah/Chalkboard/pull/1)) to [v1.3.0 Heaviside](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.3.0).\
172
+ Thanks to [@gyang0](https://www.github.com/gyang0) for his contributions ([here](https://www.github.com/Zushah/zushah.github.io/pull/1) and [here](https://github.com/Zushah/Chalkboard/pull/5)) to the [documentation](https://www.github.com/Zushah/zushah.github.io/tree/main/Chalkboard).\
173
+ Thanks to [@JentGent](https://www.github.com/JentGent) for his implementation ([here](https://www.github.com/JentGent/linalg/blob/main/linalg.js#L519)) for calculating QR decomposition which was [adapted](https://www.github.com/Zushah/Chalkboard/commit/1dce0dbac82b38f9a550dd496bc878c402a92442) into [v1.7.0 Descartes](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.7.0).
169
174
 
170
175
  # Contact
171
176
  [GitHub](https://www.github.com/Zushah)\
@@ -7,12 +7,43 @@ type ChalkboardFunction = {
7
7
  type: "expl" | "inve" | "pola" | "curv" | "surf" | "mult" | "comp";
8
8
  };
9
9
  type ChalkboardMatrix = number[][];
10
+ type ChalkboardMorphism<T, U> = {
11
+ struc1: ChalkboardStructure<T>;
12
+ struc2: ChalkboardStructure<U>;
13
+ mapping: (a: T) => U;
14
+ };
10
15
  type ChalkboardQuaternion = {
11
16
  a: number;
12
17
  b: number;
13
18
  c: number;
14
19
  d: number;
15
20
  };
21
+ type ChalkboardSet<T> = {
22
+ contains: (element: T) => boolean;
23
+ elements?: T[];
24
+ id?: string;
25
+ };
26
+ type ChalkboardStructure<T> = {
27
+ set: ChalkboardSet<T>;
28
+ operation?: (a: T, b: T) => T;
29
+ identity?: T;
30
+ inverter?: (a: T) => T;
31
+ add?: (a: T, b: T) => T;
32
+ mul?: (a: T, b: T) => T;
33
+ addIdentity?: T;
34
+ mulIdentity?: T;
35
+ addInverter?: (a: T) => T;
36
+ mulInverter?: (a: T) => T;
37
+ };
38
+ type ChalkboardStructureExtension<T, U extends T> = {
39
+ base: ChalkboardStructure<T>;
40
+ extension: ChalkboardStructure<U>;
41
+ degree: number;
42
+ basis: ChalkboardVector[];
43
+ isFinite: boolean;
44
+ isSimple: boolean;
45
+ isAlgebraic: boolean;
46
+ };
16
47
  type ChalkboardTensor = number | ChalkboardTensor[];
17
48
  type ChalkboardVector = {
18
49
  x: number;
@@ -27,15 +58,97 @@ type ChalkboardVectorField = {
27
58
  s?: string;
28
59
  };
29
60
  declare namespace Chalkboard {
30
- const APPLY: (object: ChalkboardComplex | ChalkboardMatrix | ChalkboardQuaternion | ChalkboardTensor | ChalkboardVector, callback: Function) => ChalkboardComplex | ChalkboardMatrix | ChalkboardQuaternion | ChalkboardTensor | ChalkboardVector;
61
+ const APPLY: <T>(object: ChalkboardComplex | ChalkboardMatrix | ChalkboardQuaternion | ChalkboardTensor | ChalkboardVector | ChalkboardSet<T> | ChalkboardStructure<T>, callback: (x: any) => any) => ChalkboardComplex | ChalkboardMatrix | ChalkboardQuaternion | ChalkboardTensor | ChalkboardVector | ChalkboardSet<T> | ChalkboardStructure<T>;
31
62
  let CONTEXT: string;
32
63
  const E: (exponent?: number) => number;
33
64
  const LOGO: (x?: number, y?: number, size?: number, context?: CanvasRenderingContext2D) => void;
34
65
  let PARSEPREFIX: string;
35
66
  const PI: (coefficient?: number) => number;
36
67
  const README: () => void;
37
- const VERSION: "2.1.0";
38
- const VERSIONALIAS: "Seki";
68
+ const VERSION: "2.2.0";
69
+ const VERSIONALIAS: "Galois";
70
+ }
71
+ declare namespace Chalkboard {
72
+ namespace abal {
73
+ const A: (n: number) => ChalkboardSet<number[]>;
74
+ const automorphism: <T>(struc: ChalkboardStructure<T>, mapping: (element: T) => T) => ChalkboardMorphism<T, T>;
75
+ const C: (n?: number) => ChalkboardSet<ChalkboardComplex>;
76
+ const cardinality: <T>(struc: ChalkboardSet<T> | ChalkboardStructure<T>) => number;
77
+ const Cartesian: <T, U>(set1: ChalkboardSet<T>, set2: ChalkboardSet<U>) => ChalkboardSet<[T, U]>;
78
+ const Cayley: (struc: ChalkboardStructure<number>, type?: "add" | "mul") => ChalkboardMatrix;
79
+ const center: <T>(group: ChalkboardStructure<T>) => ChalkboardSet<T>;
80
+ const complement: <T>(set: ChalkboardSet<T>, superset: ChalkboardSet<T>) => ChalkboardSet<T>;
81
+ const compose: <T, U, V>(morph1: ChalkboardMorphism<T, U>, morph2: ChalkboardMorphism<U, V>) => ChalkboardMorphism<T, V>;
82
+ const copy: <T, U extends T>(struc: ChalkboardSet<T> | ChalkboardStructure<T> | ChalkboardStructureExtension<T, U> | ChalkboardMorphism<T, U>) => ChalkboardSet<T> | ChalkboardStructure<T> | ChalkboardStructureExtension<T, U> | ChalkboardMorphism<T, U>;
83
+ const coset: <T>(struc: ChalkboardStructure<T>, substruc: ChalkboardStructure<T>) => ChalkboardSet<ChalkboardSet<T>>;
84
+ const cyclicSubgroup: <T>(group: ChalkboardStructure<T>, element: T) => ChalkboardSet<T>;
85
+ const D: (n: number) => ChalkboardSet<string>;
86
+ const difference: <T>(set1: ChalkboardSet<T>, set2: ChalkboardSet<T>) => ChalkboardSet<T>;
87
+ const direct: <T, U>(struc1: ChalkboardStructure<T>, struc2: ChalkboardStructure<U>, type?: "product" | "sum") => ChalkboardStructure<[T, U]>;
88
+ const endomorphism: <T>(struc: ChalkboardStructure<T>, mapping: (element: T) => T) => ChalkboardMorphism<T, T>;
89
+ const field: <T>(set: ChalkboardSet<T>, add: (a: T, b: T) => T, mul: (a: T, b: T) => T, addIdentity?: T, mulIdentity?: T, addInverter?: (a: T) => T, mulInverter?: (a: T) => T) => ChalkboardStructure<T>;
90
+ const fieldExtension: <T, U extends T>(base: ChalkboardStructure<T>, extension: ChalkboardStructure<U>, degree: number, basis: ChalkboardVector[], isFinite: boolean, isSimple: boolean, isAlgebraic: boolean) => ChalkboardStructureExtension<T, U>;
91
+ const GL: (n: number) => ChalkboardSet<ChalkboardMatrix>;
92
+ const group: <T>(set: ChalkboardSet<T>, operation: (a: T, b: T) => T, identity?: T, inverter?: (a: T) => T) => ChalkboardStructure<T>;
93
+ const homomorphism: <T, U>(struc1: ChalkboardStructure<T>, struc2: ChalkboardStructure<U>, mapping: (element: T) => U) => ChalkboardMorphism<T, U>;
94
+ const idmorphism: <T>(struc: ChalkboardStructure<T>) => ChalkboardMorphism<T, T>;
95
+ const image: <T, U>(morph: ChalkboardMorphism<T, U>, subset?: ChalkboardSet<T>) => ChalkboardSet<U>;
96
+ const intersection: <T>(set1: ChalkboardSet<T>, set2: ChalkboardSet<T>) => ChalkboardSet<T>;
97
+ const invmorphism: <T, U>(morph: ChalkboardMorphism<T, U>) => ChalkboardMorphism<U, T>;
98
+ const isAutomorphism: <T>(morph: ChalkboardMorphism<T, T>) => boolean;
99
+ const isBijective: <T, U>(morph: ChalkboardMorphism<T, U>) => boolean;
100
+ const isClosed: <T>(set: ChalkboardSet<T> | string, operation: ((a: T, b: T) => T) | "addition" | "multiplication") => boolean;
101
+ const isCommutative: <T>(struc: ChalkboardStructure<T>) => boolean;
102
+ const isCyclicSubgroup: <T>(group: ChalkboardStructure<T>, subgroup: ChalkboardSet<T>) => boolean;
103
+ const isEmpty: <T>(struc: ChalkboardSet<T> | ChalkboardStructure<T>) => boolean;
104
+ const isEndomorphism: <T>(morph: ChalkboardMorphism<T, T>) => boolean;
105
+ const isEqual: <T, U>(struc1: ChalkboardSet<T> | ChalkboardStructure<T> | ChalkboardMorphism<T, U>, struc2: ChalkboardSet<T> | ChalkboardStructure<T> | ChalkboardMorphism<T, U>) => boolean;
106
+ const isExact: <T, U, V>(morph1: ChalkboardMorphism<T, U>, morph2: ChalkboardMorphism<U, V>) => boolean;
107
+ const isField: <T>(field: ChalkboardStructure<T>) => boolean;
108
+ const isGroup: <T>(group: ChalkboardStructure<T>) => boolean;
109
+ const isHomomorphism: <T, U>(morph: ChalkboardMorphism<T, U>) => boolean;
110
+ const isIdeal: <T>(ring: ChalkboardStructure<T>, subset: ChalkboardSet<T>) => boolean;
111
+ const isIdentity: <T>(struc: ChalkboardStructure<T>, element: T, type?: "add" | "mul") => boolean;
112
+ const isInjective: <T, U>(morph: ChalkboardMorphism<T, U>) => boolean;
113
+ const isInverse: <T>(struc: ChalkboardStructure<T>, element1: T, element2: T, type?: "add" | "mul") => boolean;
114
+ const isIsomorphism: <T, U>(morph: ChalkboardMorphism<T, U>) => boolean;
115
+ const isNormalSubgroup: <T>(group: ChalkboardStructure<T>, subgroup: ChalkboardSet<T>) => boolean;
116
+ const isomorphism: <T, U>(struc1: ChalkboardStructure<T>, struc2: ChalkboardStructure<U>, mapping: (element: T) => U) => ChalkboardMorphism<T, U>;
117
+ const isPrincipalIdeal: <T>(ring: ChalkboardStructure<T>, ideal: ChalkboardSet<T>) => boolean;
118
+ const isRing: <T>(ring: ChalkboardStructure<T>) => boolean;
119
+ const isSubfield: <T>(field: ChalkboardStructure<T>, subset: ChalkboardSet<T>) => boolean;
120
+ const isSubgroup: <T>(group: ChalkboardStructure<T>, subset: ChalkboardSet<T>) => boolean;
121
+ const isSubring: <T>(ring: ChalkboardStructure<T>, subset: ChalkboardSet<T>) => boolean;
122
+ const isSubset: <T>(set: ChalkboardSet<T>, superset: ChalkboardSet<T>) => boolean;
123
+ const isSuperset: <T>(set: ChalkboardSet<T>, subset: ChalkboardSet<T>) => boolean;
124
+ const isSurjective: <T, U>(morph: ChalkboardMorphism<T, U>) => boolean;
125
+ const kernel: <T, U>(morph: ChalkboardMorphism<T, U>, subset?: ChalkboardSet<T>) => ChalkboardSet<T>;
126
+ const Lagrange: <T>(group: ChalkboardStructure<T>, subgroup: ChalkboardSet<T>) => boolean;
127
+ const M: (rows: number, cols?: number) => ChalkboardSet<ChalkboardMatrix>;
128
+ const N: () => ChalkboardSet<number>;
129
+ const order: <T>(group: ChalkboardStructure<T>, element: T) => number;
130
+ const P: () => ChalkboardSet<number>;
131
+ const powerSet: <T>(set: ChalkboardSet<T>) => ChalkboardSet<ChalkboardSet<T>>;
132
+ const preimage: <T, U>(morph: ChalkboardMorphism<T, U>, subset?: ChalkboardSet<U>) => ChalkboardSet<T>;
133
+ const principalIdeal: <T>(ring: ChalkboardStructure<T>, element: T) => ChalkboardSet<T>;
134
+ const print: (struc: ChalkboardSet<number> | ChalkboardStructure<number>) => void;
135
+ const Q: () => ChalkboardSet<number>;
136
+ const quotient: <T>(struc: ChalkboardStructure<T>, substruc: ChalkboardStructure<T>) => ChalkboardStructure<ChalkboardSet<T>>;
137
+ const R: () => ChalkboardSet<number>;
138
+ const ring: <T>(set: ChalkboardSet<T>, add: (a: T, b: T) => T, mul: (a: T, b: T) => T, addIdentity?: T, mulIdentity?: T, addInverter?: (a: T) => T) => ChalkboardStructure<T>;
139
+ const ringExtension: <T, U extends T>(base: ChalkboardStructure<T>, extension: ChalkboardStructure<U>, degree: number, basis: ChalkboardVector[], isFinite: boolean, isSimple: boolean, isAlgebraic: boolean) => ChalkboardStructureExtension<T, U>;
140
+ const S: (n: number) => ChalkboardSet<number[]>;
141
+ const set: <T>(set: T[]) => ChalkboardSet<T>;
142
+ const symmetricDifference: <T>(set1: ChalkboardSet<T>, set2: ChalkboardSet<T>) => ChalkboardSet<T>;
143
+ const toArray: <T>(struc: ChalkboardSet<T> | ChalkboardStructure<T>) => T[];
144
+ const toMatrix: (struc: ChalkboardSet<number> | ChalkboardStructure<number>, rows: number, cols?: number) => ChalkboardMatrix;
145
+ const toObject: (struc: ChalkboardSet<number> | ChalkboardStructure<number>) => object;
146
+ const toString: (struc: ChalkboardSet<number> | ChalkboardStructure<number>) => string;
147
+ const toTensor: (struc: ChalkboardSet<number> | ChalkboardStructure<number>, ...size: number[]) => ChalkboardTensor;
148
+ const toVector: (struc: ChalkboardSet<number> | ChalkboardStructure<number>, dimension: 2 | 3 | 4, index?: number) => ChalkboardVector;
149
+ const union: <T>(set1: ChalkboardSet<T>, set2: ChalkboardSet<T>) => ChalkboardSet<T>;
150
+ const Z: (n?: number) => ChalkboardSet<number>;
151
+ }
39
152
  }
40
153
  declare namespace Chalkboard {
41
154
  namespace calc {
@@ -234,6 +347,7 @@ declare namespace Chalkboard {
234
347
  const symmetricBinomial: (size: number) => ChalkboardMatrix;
235
348
  const toArray: (matr: ChalkboardMatrix) => number[];
236
349
  const toObject: (matr: ChalkboardMatrix) => object;
350
+ const toSet: (matr: ChalkboardMatrix) => ChalkboardSet<number>;
237
351
  const toString: (matr: ChalkboardMatrix) => string;
238
352
  const toTensor: (matr: ChalkboardMatrix, ...size: number[]) => ChalkboardTensor;
239
353
  const toVector: (matr: ChalkboardMatrix, dimension: 2 | 3 | 4, index?: number, axis?: 0 | 1) => ChalkboardVector;
@@ -266,6 +380,7 @@ declare namespace Chalkboard {
266
380
  const Goldbach: (num: number) => [number, number] | undefined;
267
381
  const isApproxEqual: (a: number, b: number, precision?: number) => boolean;
268
382
  const isPrime: (num: number) => boolean;
383
+ const isRational: (num: number, tolerance?: number) => boolean;
269
384
  const Kronecker: (a: number, b: number) => 1 | 0;
270
385
  const lcm: (a: number, b: number) => number;
271
386
  const map: (num: number, range1: number[], range2: number[]) => number;
@@ -282,6 +397,7 @@ declare namespace Chalkboard {
282
397
  const roundTo: (num: number, positionalIndex: number) => number;
283
398
  const sgn: (num: number) => -1 | 0 | 1;
284
399
  const sum: (formula: string, inf: number, sup: number) => number;
400
+ const toFraction: (num: number, tolerance?: number) => [number, number];
285
401
  }
286
402
  }
287
403
  declare namespace Chalkboard {
@@ -525,46 +641,74 @@ declare namespace Chalkboard {
525
641
  }
526
642
  declare namespace Chalkboard {
527
643
  namespace stat {
644
+ const absolute: (arr: number[]) => number[];
645
+ const add: (arr1: number[], arr2: number[]) => number[];
528
646
  const array: (inf: number, sup: number, length?: number) => number[];
529
647
  const autocorrelation: (arr: number[]) => number[];
648
+ const Bayes: (pA: number, pGivenA: number, pGivenNotA: number) => number;
530
649
  const change: (arr1: number[], arr2: number[]) => number[];
531
650
  const chiSquared: (arr1: number[], arr2: number[]) => number[];
532
- const confidenceInterval: (arr: number[]) => [number, number];
651
+ const confidenceInterval: (arr: number[], confidence?: number) => [number, number];
533
652
  const constrain: (arr: number[], range?: [number, number]) => number[];
534
653
  const convolution: (arr1: number[], arr2: number[]) => number[];
535
654
  const correlation: (arr1: number[], arr2: number[]) => number[];
655
+ const correlationCoefficient: (arr1: number[], arr2: number[]) => number;
656
+ const covariance: (arr1: number[], arr2: number[]) => number;
657
+ const cummax: (arr: number[]) => number[];
658
+ const cummin: (arr: number[]) => number[];
659
+ const cummul: (arr: number[]) => number[];
660
+ const cumsum: (arr: number[]) => number[];
536
661
  const deviation: (arr: number[]) => number;
662
+ const dot: (arr1: number[], arr2: number[]) => number;
537
663
  const error: (arr: number[]) => number;
538
664
  const eq: (arr: number[], arrORnum: number | number[]) => number[];
665
+ const expected: (arr: number[], probabilities?: number[]) => number;
539
666
  const Gaussian: (height: number, mean: number, deviation: number) => ChalkboardFunction;
540
667
  const gt: (arr: number[], arrORnum: number | number[], includeEnd?: boolean) => number[];
541
668
  const ineq: (arr: number[], inf: number, sup: number, includeInf?: boolean, includeSup?: boolean) => number[];
669
+ const inormal: (p: number) => number;
670
+ const interpolate: (arr: (number | null | undefined)[], type?: "linear" | "quadratic") => number[];
671
+ const interquartileRange: (arr: number[]) => number;
542
672
  const kurtosis: (arr: number[]) => number;
543
673
  const lt: (arr: number[], arrORnum: number | number[], includeEnd?: boolean) => number[];
544
674
  const mad: (arr: number[]) => number;
545
675
  const max: (arr: number[]) => number;
546
676
  const mean: (arr: number[], type?: "arithmetic" | "geometric" | "harmonic") => number;
677
+ const meanMoving: (arr: number[], windowSize: number) => number[];
678
+ const meanWeighted: (arr: number[], weights: number[]) => number;
547
679
  const median: (arr: number[]) => number;
548
680
  const min: (arr: number[]) => number;
549
681
  const mode: (arr: number[]) => number;
682
+ const mul: (arr: number[]) => number;
683
+ const negate: (arr: number[]) => number[];
550
684
  const norm: (arr: number[], type?: "L0" | "L1" | "L2" | "LInfinity") => number;
685
+ const normal: (x: number) => number;
551
686
  const normalize: (arr: number[], type?: "L0" | "L1" | "L2" | "LInfinity") => number[];
552
687
  const normsq: (arr: number[], type?: "L0" | "L1" | "L2" | "LInfinity") => number;
688
+ const pad: (arr: number[], length: number, num?: number) => number[];
553
689
  const percentile: (arr: number[], num: number) => number;
554
690
  const print: (arr: number[]) => void;
555
691
  const quartile: (arr: number[], type: "Q1" | "Q2" | "Q3") => number;
556
692
  const random: (inf: number, sup: number, length: number) => number[];
557
693
  const range: (arr: number[]) => number;
558
694
  const regression: (data: number[][], type?: "linear" | "polynomial" | "power" | "exponential" | "logarithmic", degree?: number) => ChalkboardFunction;
695
+ const resampling: (arr: number[], samples?: number, type?: "bootstrap" | "jackknife") => number[][];
696
+ const reverse: (arr: number[]) => number[];
697
+ const scl: (arr: number[], num: number) => number[];
559
698
  const shuffle: (arr: number[]) => number[];
560
699
  const skewness: (arr: number[]) => number;
700
+ const sub: (arr1: number[], arr2: number[]) => number[];
561
701
  const subsets: (arr: number[]) => number[][];
562
- const toMatrix: (arr: number[], rows: number, cols: number) => ChalkboardMatrix;
702
+ const sum: (arr: number[]) => number;
703
+ const toMatrix: (arr: number[], rows: number, cols?: number) => ChalkboardMatrix;
563
704
  const toObject: (arr: number[]) => object;
705
+ const toSet: (arr: number[]) => ChalkboardSet<number>;
564
706
  const toString: (arr: number[]) => string;
565
707
  const toTensor: (arr: number[], ...size: number[]) => ChalkboardTensor;
566
708
  const toVector: (arr: number[], dimension: 2 | 3 | 4, index?: number) => ChalkboardVector;
709
+ const unique: <T>(arr: T[]) => T[];
567
710
  const variance: (arr: number[]) => number;
711
+ const zscored: (arr: number[]) => number[];
568
712
  }
569
713
  }
570
714
  declare namespace Chalkboard {
@@ -600,6 +744,7 @@ declare namespace Chalkboard {
600
744
  const toArray: (tens: ChalkboardTensor) => number[];
601
745
  const toMatrix: (tens: ChalkboardTensor) => ChalkboardMatrix;
602
746
  const toObject: (tens: ChalkboardTensor) => object | number;
747
+ const toSet: (tens: ChalkboardTensor) => ChalkboardSet<number>;
603
748
  const toString: (tens: ChalkboardTensor, indentation?: number) => string;
604
749
  const toVector: (tens: ChalkboardTensor, dimension: number, index?: number) => ChalkboardVector;
605
750
  const transpose: (tens: ChalkboardTensor) => ChalkboardTensor;