@zushah/chalkboard 1.6.0 → 2.0.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 +56 -8
- package/LICENSE.md +1 -1
- package/README.md +97 -61
- package/dist/Chalkboard.d.ts +656 -0
- package/dist/Chalkboard.d.ts.map +1 -0
- package/dist/Chalkboard.js +4997 -0
- package/dist/Chalkboard.js.map +1 -0
- package/examples/README.md +2 -2
- package/examples/fluid.js +13 -13
- package/examples/hyperbolics.js +13 -13
- package/examples/mandelbrot.js +8 -8
- package/examples/matr-donut.js +16 -16
- package/examples/newton.js +9 -13
- package/examples/quat-donut.js +12 -12
- package/package.json +35 -6
- package/assets/Chalkboard-logo.png +0 -0
- package/docs/README.md +0 -2
- package/src/Chalkboard.js +0 -3866
- package/src/ChalkboardProcessing.js +0 -3815
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,55 @@
|
|
|
1
1
|
# Chalkboard changelog
|
|
2
2
|
All notable changes of every update of the Chalkboard library are recorded in this file.
|
|
3
3
|
|
|
4
|
-
## [
|
|
4
|
+
## [v2.0.0 al-Khwarizmi](https://www.github.com/Zushah/Chalkboard/releases/tag/v2.0.0) - 01/08/2024
|
|
5
|
+
The tenth release of the Chalkboard library.
|
|
6
|
+
Commits: [`v1.7.0...v2.0.0`](https://www.github.com/Zushah/Chalkboard/compare/v1.7.0...v2.0.0)
|
|
7
|
+
- Rewrote everything in TypeScript, applied ESLint and Prettier, and remade the website with TypeDoc
|
|
8
|
+
- Added `APPLY` which applies a callback function in an element-wise manner on a complex number, matrix, quaternion, tensor, or vector
|
|
9
|
+
- Added the `vect` category which merges the `vec2`, `vec3`, and `vec4` categories into one
|
|
10
|
+
- Added `VERSION` and `VERSIONALIAS` which return the installed version and its alias, respectively
|
|
11
|
+
- Removed the `vec2`, `vec3`, and `vec4` categories
|
|
12
|
+
- Removed `quat.fromVector` because it's been replaced by `vect.toQuaternion`
|
|
13
|
+
- Removed `plot.vec3` because it was weird
|
|
14
|
+
- Changed everything due to the TypeScript rewrite and the vector categories merge
|
|
15
|
+
- Changed all of the `.new` commands to be renamed as `.init`
|
|
16
|
+
- 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`
|
|
17
|
+
- Changed `LOGO` to draw the logo as a circle instead of a square
|
|
18
|
+
- Changed `matr.mulvec` to be renamed as `matr.mulVector`
|
|
19
|
+
- Fixed `matr.mulVector`` which didn't work when the rows of the matrix equaled the dimension of the vector
|
|
20
|
+
- 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)
|
|
21
|
+
|
|
22
|
+
## [v1.7.0 Descartes](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.7.0) - 01/01/2024
|
|
23
|
+
The ninth release of the Chalkboard library.
|
|
24
|
+
Commits: [`v1.6.0...v1.7.0`](https://www.github.com/Zushah/Chalkboard/compare/v1.6.0...v1.7.0)
|
|
25
|
+
- Added tensors (multidimensional multidimensional matrices, or n-dimensional arrays) with 29 commands in the new `tens` category
|
|
26
|
+
- Added 12 more matrix commands: copying, resizing, five new primitive matrices (exchange, shift, binomial, Hilbert, Lehmer), concatenating, multiplying with vectors, Kronecker sum, Kronecker product, and converting to a tensor
|
|
27
|
+
- Added `.copy` commands for complex numbers, quaternions, and vectors
|
|
28
|
+
- Added `stat.toTensor` to convert an array to a tensor
|
|
29
|
+
- Added quaternion division with `quat.div`
|
|
30
|
+
- Added `PARSEPREFIX` as a Chalkboard global which makes it easier to add custom functions to Chalkboard functions than the `init` parameter in `real.parse` and `comp.parse`
|
|
31
|
+
- Added `CONTEXT` as a Chalkboard global to replace the removed `plot.CONTEXT`
|
|
32
|
+
- Removed `plot.CONTEXT`
|
|
33
|
+
- Changed all of the `plot` commands, `LOGO`, and `geom.line3D` to use the new `CONTEXT` constant instead of `plot.CONTEXT`
|
|
34
|
+
- Changed all of the `plot` commands to use `config.x` and `config.y` to determine their position on the canvas instead of `config.origin`
|
|
35
|
+
- Changed all of the `plot` commands' initialization of the `config` parameter to be two less lines long
|
|
36
|
+
- Changed `matr.plot` to have a `config.domain` option
|
|
37
|
+
- Changed `real.parse` and `comp.parse` to no longer have an `init` parameter
|
|
38
|
+
- Changed many of the `comp` and `quat` commands to accept regular numbers (not just complex numbers and quaternions) as inputs
|
|
39
|
+
- Changed `comp.new` and `quat.new` to be able to accept only one argument as the real part and fill the imaginary part(s) with zeroes
|
|
40
|
+
- Changed `stat.eq`, `stat.ineq`, `stat.lt`, and `stat.gt` to use `Array.isArray` instead of `.constructor === Array`
|
|
41
|
+
- Changed `stat.toVector` to have an `index` parameter to change the index of the array to start at when defining a vector
|
|
42
|
+
- Changed all of the integration commands (`calc.fxdx`, `calc.fxydxdy`, `calc.fds`, `calc.frds`, `calc.fnds`, and `calc.fzdz`) to use `inf` and `sup` for the bounds in their parameters instead of `a`, `b`, `c`, and `d`
|
|
43
|
+
- Changed `matr.new` to accept one array of arrays (already-constructed matrix) as an input instead of only multiple arrays (to use as rows to construct a matrix)
|
|
44
|
+
- Changed the order of `matr.random`'s parameters
|
|
45
|
+
- Changed `matr.fill`, `matr.empty`, and `matr.random` to make square matrices with the size inputted into the `rows` parameter if nothing is inputted into the `cols` parameter
|
|
46
|
+
- Changed `matr.LUdecomp` and `matr.QRdecomp` to use `matr.fill` instead of `matr.zero` composed with `matr.empty`
|
|
47
|
+
- Fixed `plot.matr` which hadn't been working for who knows how long because of a critical misspelling (`vec2.plot` instead of `plot.vec2`)
|
|
48
|
+
- Fixed (rewrote) `numb.binomial` which kept giving "callstack size exceeded" errors for some reason
|
|
49
|
+
- Fixed (rewrote) `matr.QRdecomp` thanks to [@JentGent](https://www.github.com/JentGent)'s [implementation](https://www.github.com/JentGent/linalg/blob/main/linalg.js#L519)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## [v1.6.0 Fermat](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.6.0) - 12/25/2023
|
|
5
53
|
The eighth release of the Chalkboard library.
|
|
6
54
|
Commits: [`v1.5.0...v1.6.0`](https://www.github.com/Zushah/Chalkboard/compare/v1.5.0...v1.6.0)
|
|
7
55
|
- Added a new type of function: the inverse function (`type` of `"inve"`)
|
|
@@ -27,7 +75,7 @@ Commits: [`v1.5.0...v1.6.0`](https://www.github.com/Zushah/Chalkboard/compare/v1
|
|
|
27
75
|
- Fixed the default domain for `plot.function` which was incorrectly using the domain for domain colorings instead of normal graphs
|
|
28
76
|
|
|
29
77
|
|
|
30
|
-
## [v1.5.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.5.0) - 12/18/2023
|
|
78
|
+
## [v1.5.0 Cauchy](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.5.0) - 12/18/2023
|
|
31
79
|
The seventh release of the Chalkboard library.
|
|
32
80
|
Commits: [`v1.4.0...v1.5.0`](https://www.github.com/Zushah/Chalkboard/compare/v1.4.0...v1.5.0)
|
|
33
81
|
- Added Chalkboard as an npm package, so now it can be used on the server-side just like the client side
|
|
@@ -49,7 +97,7 @@ Commits: [`v1.4.0...v1.5.0`](https://www.github.com/Zushah/Chalkboard/compare/v1
|
|
|
49
97
|
- Fixed the error messages in `calc.dfdrt` which were misspelled
|
|
50
98
|
- Fixed `plot.field` to include the upper bounds in its domain
|
|
51
99
|
|
|
52
|
-
## [v1.4.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.4.0) - 12/11/2023
|
|
100
|
+
## [v1.4.0 Herschel](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.4.0) - 12/11/2023
|
|
53
101
|
The sixth release of the Chalkboard library.
|
|
54
102
|
Commits: [`v1.3.1...v1.4.0`](https://www.github.com/Zushah/Chalkboard/compare/v1.3.1...v1.4.0)
|
|
55
103
|
- Added many new commands for arrays: creating an array of random numbers, calculating different types of the norm (and the squared norm) of an array, calculating the normalized array, calculating the array that has the numbers that are equal to, greater than (or equal to), less than (or equal to), or some compound inequality of another number or array, calculating the skewness and kurtosis of an array, calculating the different quartiles of an array, and converting an array to a vector, matrix, object, string, or printing it in the console
|
|
@@ -69,14 +117,14 @@ Commits: [`v1.3.1...v1.4.0`](https://www.github.com/Zushah/Chalkboard/compare/v1
|
|
|
69
117
|
- Changed `calc.frdt` to also work for three-dimensional (instead of only two-dimensional) vector fields and parametric curves
|
|
70
118
|
- Fixed `calc.dfrdt` which didn't work due to a slight misspelling in an `if()` statement
|
|
71
119
|
|
|
72
|
-
## [v1.3.1](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.3.1) - 12/04/2023
|
|
120
|
+
## [v1.3.1 Heaviside Patch](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.3.1) - 12/04/2023
|
|
73
121
|
The fifth release of the Chalkboard library.
|
|
74
122
|
Commits: [`v1.3.0...v1.3.1`](https://www.github.com/Zushah/Chalkboard/compare/v1.3.0...v1.3.1)
|
|
75
123
|
- Fixed `matr.translator` which was misspelled
|
|
76
124
|
- Fixed `matr.rotator` which didn't work for two-dimensional rotations and was also misspelled
|
|
77
125
|
- Fixed `calc.grad` which didn't work for vector fields because of another misspelling
|
|
78
126
|
|
|
79
|
-
## [v1.3.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.3.0) - 12/04/2023
|
|
127
|
+
## [v1.3.0 Heaviside](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.3.0) - 12/04/2023
|
|
80
128
|
The fourth release of the Chalkboard library.
|
|
81
129
|
Commits: [`v1.2.0...v1.3.0`](https://www.github.com/Zushah/Chalkboard/compare/v1.2.0...v1.3.0)
|
|
82
130
|
- Added multivariable calculus, with commands for directional differentiation, multivariable chain rule, gradient (partial differentiation), double gradient (second-order partial differentiation), divergence, curl, double integration, line/surface integration, arc length, surface area, and curvature
|
|
@@ -99,7 +147,7 @@ Commits: [`v1.2.0...v1.3.0`](https://www.github.com/Zushah/Chalkboard/compare/v1
|
|
|
99
147
|
- Changed the name of `calc.average` to `calc.mean`
|
|
100
148
|
- Fixed `matr.invert` returning `NaN` values when `0` is on the diagonal of a matrix, thanks to [@bhavjitChauhan](https://www.github.com/bhavjitChauhan).
|
|
101
149
|
|
|
102
|
-
## [v1.2.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.2.0) - 11/27/2023
|
|
150
|
+
## [v1.2.0 Cayley](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.2.0) - 11/27/2023
|
|
103
151
|
The third release of the Chalkboard library.
|
|
104
152
|
Commits: [`v1.1.0...v1.2.0`](https://www.github.com/Zushah/Chalkboard/compare/v1.1.0...v1.2.0)
|
|
105
153
|
- Added new matrix commands for the trace of a matrix, the row space of a matrix, the column space, and null space, the exponentation, the row Echelon form (Gaussian elimination), solving systems of linear equations, and conversion of a matrix to an object
|
|
@@ -113,7 +161,7 @@ Commits: [`v1.1.0...v1.2.0`](https://www.github.com/Zushah/Chalkboard/compare/v1
|
|
|
113
161
|
- Changed `numb.Gaussian` to use `while(typeof x === "undefined")` instead of `while(true)`
|
|
114
162
|
- Fixed the `vec2.magset` and `vec3.magset` commands which would return vectors in the wrong dimensions
|
|
115
163
|
|
|
116
|
-
## [v1.1.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.1.0) - 11/13/2023
|
|
164
|
+
## [v1.1.0 Riemann](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.1.0) - 11/13/2023
|
|
117
165
|
The second release of the Chalkboard library.
|
|
118
166
|
Commits: [`v1.0.0...v1.1.0`](https://www.github.com/Zushah/Chalkboard/compare/v1.0.0...v1.1.0)
|
|
119
167
|
- Added `numb.prime` to calculate the nth prime number, `numb.nextPrime` to calculate the next prime number, and `numb.primeGap` to calculate the prime gap with an interval
|
|
@@ -132,6 +180,6 @@ Commits: [`v1.0.0...v1.1.0`](https://www.github.com/Zushah/Chalkboard/compare/v1
|
|
|
132
180
|
- Changed the name of the `position` parameter in `stat.Gaussian` to `mean`
|
|
133
181
|
- Changed the name of `numb.prime` (the command that checks if a number is prime) to `numb.isPrime`, so parts of `numb.primeArr` and `prime.compositeArr` had to be changed, too
|
|
134
182
|
|
|
135
|
-
## [v1.0.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.0.0) - 11/06/2023
|
|
183
|
+
## [v1.0.0 Euclid](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.0.0) - 11/06/2023
|
|
136
184
|
The first release of the Chalkboard library.
|
|
137
185
|
Commits: [`v1.0.0...main`](https://www.github.com/Zushah/Chalkboard/compare/v1.0.0...main)
|
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
<p align="center"><a href="https://www.github.com/Zushah/Chalkboard"><img src="
|
|
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/
|
|
4
|
-
<a href="https://www.codefactor.io/repository/github/zushah/chalkboard"><img src="https://
|
|
5
|
-
<a href="https://
|
|
6
|
-
<a href="https://www.
|
|
7
|
-
<a href="https://www.
|
|
3
|
+
<a href="https://www.github.com/Zushah/Chalkboard/releases/tag/v2.0.0"><img src="https://img.shields.io/badge/release-v2.0.0_al--Khwarizmi-blueviolet?logo=github&logoColor=white" alt="Latest release"></a>
|
|
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.0.0"><img src="https://img.shields.io/bundlephobia/min/%40zushah/chalkboard?color=darkgreen&logo=files&logoColor=white" alt="Minified size"></a>
|
|
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
|
+
<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>
|
|
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>
|
|
8
10
|
<br>
|
|
9
|
-
<a href="https://zushah.github.io/Chalkboard
|
|
11
|
+
<a href="https://zushah.github.io/Chalkboard">https://zushah.github.io/Chalkboard</a>
|
|
10
12
|
</p>
|
|
11
13
|
|
|
12
14
|
# Contents
|
|
@@ -21,44 +23,57 @@
|
|
|
21
23
|
</ol>
|
|
22
24
|
|
|
23
25
|
# About
|
|
24
|
-
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 [
|
|
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.0.0 al-Khwarizmi](https://www.github.com/Zushah/Chalkboard/releases/tag/v2.0.0), Chalkboard has 410 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).
|
|
25
27
|
|
|
26
28
|
# Installation
|
|
27
29
|
If your JavaScript project is being run on the client-side within a webpage, you can install Chalkboard with this HTML tag:
|
|
28
30
|
```html
|
|
29
|
-
<script src="https://cdn.jsdelivr.net/gh/Zushah/Chalkboard@
|
|
31
|
+
<script src="https://cdn.jsdelivr.net/gh/Zushah/Chalkboard@2.0.0/dist/Chalkboard.min.js"></script>
|
|
30
32
|
```
|
|
31
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:
|
|
32
34
|
```bash
|
|
33
|
-
npm install @zushah/chalkboard
|
|
35
|
+
npm install @zushah/chalkboard
|
|
34
36
|
```
|
|
35
|
-
Alternatively, you can simply download the [latest release](https://www.github.com/Zushah/Chalkboard/releases/tag/
|
|
37
|
+
Alternatively, you can simply download the [latest release](https://www.github.com/Zushah/Chalkboard/releases/tag/v2.0.0) and put the relevant files in your project's directory.
|
|
36
38
|
|
|
37
|
-
|
|
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).
|
|
38
40
|
|
|
39
41
|
# Documentation
|
|
40
|
-
|
|
41
|
-
- `
|
|
42
|
-
- `real` - Real number and real function operations
|
|
42
|
+
Chalkboard has twelve categories of commands:
|
|
43
|
+
- `calc` - Single/multi-variable real/complex-valued calculus operations
|
|
43
44
|
- `comp` - Complex number and complex function operations
|
|
45
|
+
- `geom` - Geometric operations
|
|
46
|
+
- `matr` - Multidimensional matrix operations
|
|
47
|
+
- `numb` - Number-theory-related operations
|
|
48
|
+
- `plot` - Plotting real and complex functions, complex numbers, vectors, matrices, and statistical graphs
|
|
44
49
|
- `quat` - Quaternion operations
|
|
45
|
-
- `
|
|
46
|
-
- `geom` - Geometric formulae operations
|
|
47
|
-
- `trig` - Trigonometric function operations
|
|
50
|
+
- `real` - Real number and real function operations
|
|
48
51
|
- `stat` - Statistical array operations
|
|
49
|
-
- `
|
|
50
|
-
- `
|
|
51
|
-
- `
|
|
52
|
-
- `matr` - Multidimensional matrix operations
|
|
53
|
-
- `calc` - Several-variable calculus operations
|
|
52
|
+
- `tens` - Tensor (multidimensional multidimensional matrix) operations
|
|
53
|
+
- `trig` - Trigonometric function operations
|
|
54
|
+
- `vect` - Two-, three-, and four-dimensional vector and vector field operations
|
|
54
55
|
|
|
55
|
-
There are also
|
|
56
|
-
- `
|
|
57
|
-
- `
|
|
58
|
-
- `PI()` - Computes the number pi
|
|
56
|
+
There are also eight "global" commands and constants, which are:
|
|
57
|
+
- `APPLY` - Applies a callback function in an element-wise manner on a Chalkboard object
|
|
58
|
+
- `CONTEXT` - The JavaScript canvas rendering context to use for plotting
|
|
59
59
|
- `E()` - Computes the number e
|
|
60
|
+
- `LOGO()` - Draws the Chalkboard logo
|
|
61
|
+
- `PARSEPREFIX` - Used for adding custom functions to the Chalkboard parser
|
|
62
|
+
- `PI()` - Computes the number π
|
|
63
|
+
- `README()` - Prints basic information about Chalkboard in the console
|
|
64
|
+
- `VERSION` - The installed version of Chalkboard
|
|
65
|
+
- `VERSIONALIAS` - The alias of the installed version of Chalkboard
|
|
60
66
|
|
|
61
|
-
|
|
67
|
+
Lastly, Chalkboard has seven data types (also known as Chalkboard objects):
|
|
68
|
+
- `ChalkboardComplex` - Complex numbers
|
|
69
|
+
- `ChalkboardFunction` - Mathematical functions
|
|
70
|
+
- `ChalkboardMatrix` - Matrices
|
|
71
|
+
- `ChalkboardQuaternion` - Quaternions
|
|
72
|
+
- `ChalkboardTensor` - Tensors
|
|
73
|
+
- `ChalkboardVector` - Vectors
|
|
74
|
+
- `ChalkboardVectorField` - Vector fields
|
|
75
|
+
|
|
76
|
+
The comprehensive Chalkboard documentation can be visited [here](https://zushah.github.io/Chalkboard).
|
|
62
77
|
|
|
63
78
|
# Getting Started
|
|
64
79
|
After installing Chalkboard into your program, you can immediately get started with using it. Every Chalkboard command begins with typing "Chalkboard" followed by a period, then the name of the category of the command (all categories are listed above in the [documentation](#documentation) section) with another period, and lastly the desired command itself.
|
|
@@ -67,69 +82,90 @@ Chalkboard.category.command(parameters);
|
|
|
67
82
|
```
|
|
68
83
|
Here is some code that shows off only a few features of Chalkboard:
|
|
69
84
|
```js
|
|
70
|
-
const cb = Chalkboard; //
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
import cb from "@zushah/chalkboard";
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
*/
|
|
78
|
-
|
|
79
|
-
let f = cb.real.function("Math.cos(2 * x)"); // f(x) = cos(2x)
|
|
85
|
+
const cb = Chalkboard; // Initialize in a browser
|
|
86
|
+
// or
|
|
87
|
+
const cb = require("@zushah/chalkboard"); // Initialize in Node with CommonJS
|
|
88
|
+
// or
|
|
89
|
+
import cb from "@zushah/chalkboard"; // Initiialize in Node with ES Modules
|
|
90
|
+
|
|
91
|
+
let f = cb.real.define("Math.cos(2 * x)"); // f(x) = cos(2x)
|
|
80
92
|
let dfdx = cb.calc.dfdx(f, 2); // Derivative of f at x = 0
|
|
81
93
|
let fxdx = cb.calc.fxdx(f, 0, 2); // Antiderivative of f from x = 0 to x = 2
|
|
82
94
|
let fourier = cb.calc.Fourier(f, 2); // Fourier transform of f at x = 2
|
|
83
95
|
|
|
84
96
|
let f = cb.vec3.field("x", "y", "z"); // f(x, y, z) = (x, y, z)
|
|
85
|
-
let r = cb.real.
|
|
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))
|
|
86
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
|
|
87
99
|
|
|
88
100
|
let primes = cb.numb.primeArr(0, 100); // Array of prime numbers between 0 and 100
|
|
89
101
|
let midPrime = cb.stat.median(primes); // Median number in the primes array
|
|
90
102
|
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
|
|
91
103
|
|
|
92
|
-
let z = cb.comp.
|
|
104
|
+
let z = cb.comp.init(1, 1); // z = 1 + i
|
|
93
105
|
let zsqsqrt = cb.comp.sqrt(cb.comp.sq(z)); // The square root of z squared equals z
|
|
94
|
-
let f = cb.comp.
|
|
95
|
-
cb.plot.
|
|
106
|
+
let f = cb.comp.define("a*a - b*b + 1", "2*a*b"); // f(z) = z^2 + 1
|
|
107
|
+
cb.plot.definition(f); // Plots the domain coloring of f
|
|
96
108
|
|
|
97
|
-
let r = cb.real.
|
|
109
|
+
let r = cb.real.define(["Math.cos(t)", "Math.sin(t)"], "curv"); // r(t) = (cos(t), sin(t))
|
|
98
110
|
cb.plot.xyplane({size: 2}); // Draws the Cartesian coordinate plane scaled by 2
|
|
99
|
-
cb.plot.
|
|
100
|
-
|
|
101
|
-
let a = cb.
|
|
102
|
-
let b = cb.
|
|
103
|
-
let c = cb.
|
|
104
|
-
let axbxc = cb.
|
|
105
|
-
cb.
|
|
106
|
-
|
|
107
|
-
let m = cb.matr.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
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
|
+
|
|
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
|
|
117
|
+
cb.vect.print(axbxc); // Prints axbxc in the console
|
|
118
|
+
|
|
119
|
+
let m = cb.matr.init( // m is a 5x5 matrix
|
|
120
|
+
[0, 1, 1, 1, 1],
|
|
121
|
+
[1, 0, 1, 1, 1],
|
|
122
|
+
[1, 1, 0, 1, 1],
|
|
123
|
+
[1, 1, 1, 0, 1],
|
|
124
|
+
[1, 1, 1, 1, 0]
|
|
125
|
+
);
|
|
112
126
|
let mi = cb.matr.invert(m); // mi is the inverse of m
|
|
113
127
|
let mmi = cb.matr.mul(m, mi); // mmi is the product of m and mi
|
|
114
128
|
cb.matr.print(mmi); // Prints mmi in the console
|
|
129
|
+
|
|
130
|
+
let t = cb.tens.init( // t is a 2x2x2 rank-3 tensor
|
|
131
|
+
[
|
|
132
|
+
[1, 2],
|
|
133
|
+
[3, 4]
|
|
134
|
+
],
|
|
135
|
+
[
|
|
136
|
+
[5, 6],
|
|
137
|
+
[7, 8]
|
|
138
|
+
]
|
|
139
|
+
);
|
|
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)
|
|
142
|
+
cb.tens.print(tt); // Prints tt in the console just to see what it looks like for fun
|
|
143
|
+
|
|
144
|
+
// Takes the factorial of each element of t
|
|
145
|
+
let factorialt = cb.APPLY(t, (x) => {
|
|
146
|
+
return cb.numb.factorial(x);
|
|
147
|
+
});
|
|
115
148
|
```
|
|
116
|
-
More examples that are more interesting can be seen [here](https://zushah.github.io/Chalkboard/examples.html) with their source code [here](https://www.github.com/Zushah/Chalkboard/tree/main/examples).
|
|
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).
|
|
117
150
|
|
|
118
151
|
# Contributing
|
|
119
152
|
<ol>
|
|
120
153
|
<li>Fork Chalkboard's GitHub repository. Make sure the fork is based on the main branch.</li>
|
|
121
|
-
<li>
|
|
154
|
+
<li>Clone the repository, download the dependencies with `npm install`, and then make your contributions to your fork.</li>
|
|
122
155
|
<li>When you're done, commit the changes to your fork with a detailed description.</li>
|
|
123
156
|
<li>Open a pull request. It will be reviewed soon and then merged to the main branch.</li>
|
|
124
157
|
</ol>
|
|
125
158
|
|
|
159
|
+
NOTE: If you want to change the documentation, you will also have to clone the [zushah.github.io repository](https://www.github.com/Zushah/zushah.github.io) because that's where the files are generated.
|
|
160
|
+
|
|
126
161
|
The changelog can be read [here](https://www.github.com/Zushah/Chalkboard/blob/main/CHANGELOG.md).
|
|
127
162
|
|
|
128
163
|
The Chalkboard library is available under the [MIT License](https://www.github.com/Zushah/Chalkboard/blob/main/LICENSE.md).
|
|
129
164
|
|
|
130
|
-
#
|
|
131
|
-
Thanks to [
|
|
132
|
-
Thanks to [
|
|
165
|
+
# 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).
|
|
133
169
|
|
|
134
170
|
# Contact
|
|
135
171
|
[GitHub](https://www.github.com/Zushah)\
|