@zushah/chalkboard 1.5.0 → 1.7.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,9 +1,65 @@
1
1
  # Chalkboard changelog
2
2
  All notable changes of every update of the Chalkboard library are recorded in this file.
3
3
 
4
- ## [v1.5.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.5.0) - 12/18/2023
4
+ ## [v1.7.0 Descartes](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.7.0) - 01/01/2024
5
+ The ninth release of the Chalkboard library.
6
+ Commits: [`v1.6.0...v1.7.0`](https://www.github.com/Zushah/Chalkboard/compare/v1.6.0...v1.7.0)
7
+ - Added tensors (multidimensional multidimensional matrices, or n-dimensional arrays) with 29 commands in the new `tens` category
8
+ - 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
9
+ - Added `.copy` commands for complex numbers, quaternions, and vectors
10
+ - Added `stat.toTensor` to convert an array to a tensor
11
+ - Added quaternion division with `quat.div`
12
+ - 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`
13
+ - Added `CONTEXT` as a Chalkboard global to replace the removed `plot.CONTEXT`
14
+ - Removed `plot.CONTEXT`
15
+ - Changed all of the `plot` commands, `LOGO`, and `geom.line3D` to use the new `CONTEXT` constant instead of `plot.CONTEXT`
16
+ - Changed all of the `plot` commands to use `config.x` and `config.y` to determine their position on the canvas instead of `config.origin`
17
+ - Changed all of the `plot` commands' initialization of the `config` parameter to be two less lines long
18
+ - Changed `matr.plot` to have a `config.domain` option
19
+ - Changed `real.parse` and `comp.parse` to no longer have an `init` parameter
20
+ - Changed many of the `comp` and `quat` commands to accept regular numbers (not just complex numbers and quaternions) as inputs
21
+ - 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
22
+ - Changed `stat.eq`, `stat.ineq`, `stat.lt`, and `stat.gt` to use `Array.isArray` instead of `.constructor === Array`
23
+ - Changed `stat.toVector` to have an `index` parameter to change the index of the array to start at when defining a vector
24
+ - 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`
25
+ - 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)
26
+ - Changed the order of `matr.random`'s parameters
27
+ - 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
28
+ - Changed `matr.LUdecomp` and `matr.QRdecomp` to use `matr.fill` instead of `matr.zero` composed with `matr.empty`
29
+ - Fixed `plot.matr` which hadn't been working for who knows how long because of a critical misspelling (`vec2.plot` instead of `plot.vec2`)
30
+ - Fixed (rewrote) `numb.binomial` which kept giving "callstack size exceeded" errors for some reason
31
+ - 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)
32
+
33
+
34
+ ## [v1.6.0 Fermat](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.6.0) - 12/25/2023
35
+ The eighth release of the Chalkboard library.
36
+ Commits: [`v1.5.0...v1.6.0`](https://www.github.com/Zushah/Chalkboard/compare/v1.5.0...v1.6.0)
37
+ - Added a new type of function: the inverse function (`type` of `"inve"`)
38
+ - Added `stat.regression` to calculate different types of statistical regression models (linear, polynomial, exponential, etc.)
39
+ - Added `plot.CONTEXT` which determines the `CanvasRenderingContext2D` to use for plots
40
+ - Added LU decomposition and QR decomposition for matrices with `matr.LUdecomp` and `matr.QRdecomp`
41
+ - Added `matr.push` and `matr.pull` to add or remove rows or columns from matrices
42
+ - Added `matr.fill` to create a new matrix with a single value for all of the elements
43
+ - Added more commands for generating random numbers: `numb.exponential`, `numb.Bernoullian`, and `numb.Poissonian`
44
+ - Added `numb.Goldbach` to return an even number as a sum of two prime numbers
45
+ - Added `numb.Euler` to calculate Euler's totient function on a number
46
+ - Added `stat.shuffle` to randomly shuffle an array and `stat.subsets` to return all of the possible subsets of an array
47
+ - Changed all of the `plot` commands to use an optional `config` object parameter to configure their customizations (size, color, domain, etc.) instead of separate parameters for each of them
48
+ - Changed `real.function`, `real.val`, `calc.dfdx`, `calc.d2fdx2`, and `calc.fxdx` to accomodate the new `"inve"` function type
49
+ - Changed all of the `plot` commands, the `LOGO` command, and the `geom.line3D` command to use the new `plot.CONTEXT` value instead of `ctx` and `canvas`
50
+ - Changed `matr.empty` and `matr.random` to use `rows` and `cols` as parameters for the size of the matrix instead of `dimension`, and renamed the `dimension` parameter for `matr.identity` to `size`
51
+ - Changed `real.nrt` to be renamed as `real.root` (so `stat.mean` had to be changed since it was used there), and changed the `n` parameter in `comp.root` to be renamed as `index`
52
+ - Changed `numb.random` to use its default values only if the parameters are undefined instead of if the parameters are falsy
53
+ - Changed `matr.new` to use its `matrix` parameter instead of leaving it as declared but unused
54
+ - Changed `comp.d2fdz2` which was incorrectly named as `comp.df2dz2`
55
+ - Fixed (rewrote) `numb.Gaussian` which basically didn't work at all
56
+ - Fixed `real.pow` which returned `NaN` for 0 raised to the power of 0
57
+ - Fixed the default domain for `plot.function` which was incorrectly using the domain for domain colorings instead of normal graphs
58
+
59
+
60
+ ## [v1.5.0 Cauchy](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.5.0) - 12/18/2023
5
61
  The seventh release of the Chalkboard library.
6
- Commits: [`v1.4.0...v1.5.0`](https://github.com/Zushah/Chalkboard/compare/v1.4.0...v1.5.0)
62
+ Commits: [`v1.4.0...v1.5.0`](https://www.github.com/Zushah/Chalkboard/compare/v1.4.0...v1.5.0)
7
63
  - Added Chalkboard as an npm package, so now it can be used on the server-side just like the client side
8
64
  - Added `comp.function`, `comp.parse`, and `comp.val` to define, parse, and evaluate complex functions
9
65
  - Added `calc.dfdz`, `calc.d2fdz2`, and `calc.fzdz` to calculate the first derivatives, second derivatives, and antiderivatives of complex functions
@@ -23,9 +79,9 @@ Commits: [`v1.4.0...v1.5.0`](https://github.com/Zushah/Chalkboard/compare/v1.4.0
23
79
  - Fixed the error messages in `calc.dfdrt` which were misspelled
24
80
  - Fixed `plot.field` to include the upper bounds in its domain
25
81
 
26
- ## [v1.4.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.4.0) - 12/11/2023
82
+ ## [v1.4.0 Herschel](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.4.0) - 12/11/2023
27
83
  The sixth release of the Chalkboard library.
28
- Commits: [`v1.3.1...v1.4.0`](https://github.com/Zushah/Chalkboard/compare/v1.3.1...v1.4.0)
84
+ Commits: [`v1.3.1...v1.4.0`](https://www.github.com/Zushah/Chalkboard/compare/v1.3.1...v1.4.0)
29
85
  - 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
30
86
  - Added `plot.barplot`, `plot.lineplot`, and `plot.scatterplot` to plot arrays of data
31
87
  - Added `.constrain` commands for numbers, arrays, complex numbers, quaternions, vectors, and matrices to constrain their values within a range
@@ -43,16 +99,16 @@ Commits: [`v1.3.1...v1.4.0`](https://github.com/Zushah/Chalkboard/compare/v1.3.1
43
99
  - Changed `calc.frdt` to also work for three-dimensional (instead of only two-dimensional) vector fields and parametric curves
44
100
  - Fixed `calc.dfrdt` which didn't work due to a slight misspelling in an `if()` statement
45
101
 
46
- ## [v1.3.1](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.3.1) - 12/04/2023
102
+ ## [v1.3.1 Heaviside Patch](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.3.1) - 12/04/2023
47
103
  The fifth release of the Chalkboard library.
48
- Commits: [`v1.3.0...v1.3.1`](https://github.com/Zushah/Chalkboard/compare/v1.3.0...v1.3.1)
104
+ Commits: [`v1.3.0...v1.3.1`](https://www.github.com/Zushah/Chalkboard/compare/v1.3.0...v1.3.1)
49
105
  - Fixed `matr.translator` which was misspelled
50
106
  - Fixed `matr.rotator` which didn't work for two-dimensional rotations and was also misspelled
51
107
  - Fixed `calc.grad` which didn't work for vector fields because of another misspelling
52
108
 
53
- ## [v1.3.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.3.0) - 12/04/2023
109
+ ## [v1.3.0 Heaviside](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.3.0) - 12/04/2023
54
110
  The fourth release of the Chalkboard library.
55
- Commits: [`v1.2.0...v1.3.0`](https://github.com/Zushah/Chalkboard/compare/v1.2.0...v1.3.0)
111
+ Commits: [`v1.2.0...v1.3.0`](https://www.github.com/Zushah/Chalkboard/compare/v1.2.0...v1.3.0)
56
112
  - 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
57
113
  - Added second-order differentiation with `calc.d2fdx2`, unit tangent vectors for parametric curves with `calc.tangent`, unit normal vectors with `calc.normal`, and unit binormal vectors with `calc.binormal`
58
114
  - Functions that previously had the `type` property of `"para"` should now be changed to `"curv"`
@@ -71,11 +127,11 @@ Commits: [`v1.2.0...v1.3.0`](https://github.com/Zushah/Chalkboard/compare/v1.2.0
71
127
  - Changed all `plot` commands so they can now optionally have their opacity changed with the `rgba` parameter (which previously used to only be `rgb`)
72
128
  - Changed `numb.Gaussian` to use `for(;;)` instead of `while(typeof x === "undefined")`
73
129
  - Changed the name of `calc.average` to `calc.mean`
74
- - Fixed `matr.invert` returning `NaN` values when `0` is on the diagonal of a matrix, thanks to [@bhavjitChauhan](https://github.com/bhavjitChauhan).
130
+ - Fixed `matr.invert` returning `NaN` values when `0` is on the diagonal of a matrix, thanks to [@bhavjitChauhan](https://www.github.com/bhavjitChauhan).
75
131
 
76
- ## [v1.2.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.2.0) - 11/27/2023
132
+ ## [v1.2.0 Cayley](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.2.0) - 11/27/2023
77
133
  The third release of the Chalkboard library.
78
- Commits: [`v1.1.0...v1.2.0`](https://github.com/Zushah/Chalkboard/compare/v1.1.0...v1.2.0)
134
+ Commits: [`v1.1.0...v1.2.0`](https://www.github.com/Zushah/Chalkboard/compare/v1.1.0...v1.2.0)
79
135
  - 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
80
136
  - Added `plot.comp`, `plot.vec2`, `plot.vec3`, and `plot.matr` to replace `comp.display`, `vec2.display`, `vec3.display`, and `matr.display`
81
137
  - Added `numb.binomial` to calculate binomial coefficients
@@ -87,9 +143,9 @@ Commits: [`v1.1.0...v1.2.0`](https://github.com/Zushah/Chalkboard/compare/v1.1.0
87
143
  - Changed `numb.Gaussian` to use `while(typeof x === "undefined")` instead of `while(true)`
88
144
  - Fixed the `vec2.magset` and `vec3.magset` commands which would return vectors in the wrong dimensions
89
145
 
90
- ## [v1.1.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.1.0) - 11/13/2023
146
+ ## [v1.1.0 Riemann](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.1.0) - 11/13/2023
91
147
  The second release of the Chalkboard library.
92
- Commits: [`v1.0.0...v1.1.0`](https://github.com/Zushah/Chalkboard/compare/v1.0.0...v1.1.0)
148
+ Commits: [`v1.0.0...v1.1.0`](https://www.github.com/Zushah/Chalkboard/compare/v1.0.0...v1.1.0)
93
149
  - 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
94
150
  - Added `numb.factors` to calculate the prime factorization of a number and `numb.divisors` to calculate the divisors of a number
95
151
  - Added `numb.Gaussian` to calculate a random number based on a Gaussian distribution
@@ -106,6 +162,6 @@ Commits: [`v1.0.0...v1.1.0`](https://github.com/Zushah/Chalkboard/compare/v1.0.0
106
162
  - Changed the name of the `position` parameter in `stat.Gaussian` to `mean`
107
163
  - 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
108
164
 
109
- ## [v1.0.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.0.0) - 11/06/2023
165
+ ## [v1.0.0 Euclid](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.0.0) - 11/06/2023
110
166
  The first release of the Chalkboard library.
111
- Commits: [`v1.0.0...main`](https://github.com/Zushah/Chalkboard/compare/v1.0.0...main)
167
+ Commits: [`v1.0.0...main`](https://www.github.com/Zushah/Chalkboard/compare/v1.0.0...main)
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Zushah
3
+ Copyright (c) 2023-2024 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,10 +1,12 @@
1
1
  <p align="center"><a href="https://www.github.com/Zushah/Chalkboard"><img src="./assets/Chalkboard-logo.png" width="50%"></a></p>
2
2
  <p align="center">
3
- <a href="https://www.github.com/Zushah/Chalkboard/releases/tag/v1.5.0"><img src="https://img.shields.io/github/v/release/Zushah/Chalkboard" alt="Latest release"></a>
4
- <a href="https://www.codefactor.io/repository/github/zushah/chalkboard"><img src="https://www.codefactor.io/repository/github/zushah/chalkboard/badge" alt="CodeFactor grade"></a>
5
- <a href="https://www.npmjs.com/package/@zushah/chalkboard"><img src="https://img.shields.io/badge/node-v20.10.0-limegreen" alt="Node.js support"></a>
6
- <a href="https://github.com/Zushah/Chalkboard/blob/main/LICENSE.md"><img src="https://img.shields.io/badge/license-MIT-yellow" alt="MIT License"></a>
7
- <a href="https://www.jsdelivr.com/package/gh/Zushah/Chalkboard"><img src="https://data.jsdelivr.com/v1/package/gh/Zushah/Chalkboard/badge" alt="JSDelivr requests"></a>
3
+ <a href="https://www.github.com/Zushah/Chalkboard/releases/tag/v1.7.0"><img src="https://img.shields.io/badge/release-v1.7.0_Descartes-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@1.7.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/JavaScript"><img src="https://img.shields.io/github/languages/top/Zushah/Chalkboard?color=orange&logo=javascript&logoColor=white" alt="Written in JavaScript"></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
11
  <a href="https://zushah.github.io/Chalkboard/home.html">https://zushah.github.io/Chalkboard/home.html</a>
10
12
  </p>
@@ -21,28 +23,28 @@
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://github.com/Zushah/Chalkboard/releases/tag/v1.0.0) on November 6, 2023. As per the latest release of [v1.5.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.5.0), Chalkboard has 431 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/home.html).
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 [v1.7.0 Descartes](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.7.0), Chalkboard has 492 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/home.html).
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 type="text/javascript" src="https://cdn.jsdelivr.net/gh/Zushah/Chalkboard@1.5.0/src/Chalkboard.min.js"></script>
31
+ <script src="https://cdn.jsdelivr.net/gh/Zushah/Chalkboard@1.7.0/src/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@1.5.0
35
+ npm install @zushah/chalkboard@1.7.0
34
36
  ```
35
- Alternatively, you can simply download the [latest release](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.5.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/v1.7.0) and put the relevant files in your project's directory.
36
38
 
37
39
  More methods and details about installing Chalkboard can be read [here](https://zushah.github.io/Chalkboard/installation.html).
38
40
 
39
41
  # Documentation
40
- These are all thirteen Chalkboard categories with a brief description of what they're mostly about, and listed in the order they appear in the source code:
42
+ These are all fourteen Chalkboard categories with a brief description of what they're mostly about, and listed in the order they appear in the source code:
41
43
  - `numb` - Number-theory-related operations
42
44
  - `real` - Real number and real function operations
43
45
  - `comp` - Complex number and complex function operations
44
46
  - `quat` - Quaternion operations
45
- - `plot` - Plotting functions, complex numbers, vectors, matrices, and statistical graphs
47
+ - `plot` - Plotting real and complex functions, complex numbers, vectors, matrices, and statistical graphs
46
48
  - `geom` - Geometric formulae operations
47
49
  - `trig` - Trigonometric function operations
48
50
  - `stat` - Statistical array operations
@@ -50,13 +52,16 @@ These are all thirteen Chalkboard categories with a brief description of what th
50
52
  - `vec3` - Three-dimensional vector operations
51
53
  - `vec4` - Four-dimensional vector operations
52
54
  - `matr` - Multidimensional matrix operations
53
- - `calc` - Several-variable calculus operations
55
+ - `tens` - Tensor (multidimensional multidimensional matrix) operations
56
+ - `calc` - Single/multi-variable real/complex-valued calculus operations
54
57
 
55
- There are also four "global" commands in Chalkboard, which are:
58
+ There are also six "global" commands and constants in Chalkboard, which are:
56
59
  - `README()` - Prints basic information about Chalkboard in the console
57
60
  - `LOGO()` - Draws the Chalkboard logo
58
- - `PI()` - Computes the number pi
61
+ - `PI()` - Computes the number π
59
62
  - `E()` - Computes the number e
63
+ - `CONTEXT` - The JavaScript canvas rendering context to use for plotting
64
+ - `PARSEPREFIX` - Used for adding custom functions to the Chalkboard parser
60
65
 
61
66
  The comprehensive Chalkboard documentation can be visited [here](https://zushah.github.io/Chalkboard/documentation.html).
62
67
 
@@ -67,12 +72,11 @@ Chalkboard.category.command(parameters);
67
72
  ```
68
73
  Here is some code that shows off only a few features of Chalkboard:
69
74
  ```js
70
- const cb = Chalkboard; // Chalkboard is a nice name but it's also long
71
- /*
72
- Note that this code is written on the client-side
73
- You can write all the same code on the server-side, too, but you would have to replace the line above with:
74
- const cb = require("@zushah/chalkboard@1.5.0");
75
- */
75
+ const cb = Chalkboard; // Initialize in a browser
76
+ // or
77
+ const cb = require("@zushah/chalkboard"); // Initialize in Node with CommonJS
78
+ // or
79
+ import cb from "@zushah/chalkboard"; // Initiialize in Node with ES Modules
76
80
 
77
81
  let f = cb.real.function("Math.cos(2 * x)"); // f(x) = cos(2x)
78
82
  let dfdx = cb.calc.dfdx(f, 2); // Derivative of f at x = 0
@@ -85,16 +89,16 @@ let fnds = cb.calc.fnds(f, r, cb.PI(-1/2), cb.PI(1/2), 0, cb.PI(2)); // Flux of
85
89
 
86
90
  let primes = cb.numb.primeArr(0, 100); // Array of prime numbers between 0 and 100
87
91
  let midPrime = cb.stat.median(primes); // Median number in the primes array
88
- cb.plot.barplot(primes, cb.stat.array(0, 100, 11), 5, [[0, 0, 0], [0, 0, 255]]); // 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
92
+ 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
89
93
 
90
94
  let z = cb.comp.new(1, 1); // z = 1 + i
91
95
  let zsqsqrt = cb.comp.sqrt(cb.comp.sq(z)); // The square root of z squared equals z
92
- let f = cb.comp.function("a*a - b*b + 1", "2*a*b"); // f(z) = z^2 + 1 for z = a + bi (a complex-valued function)
96
+ let f = cb.comp.function("a*a - b*b + 1", "2*a*b"); // f(z) = z^2 + 1
93
97
  cb.plot.function(f); // Plots the domain coloring of f
94
98
 
95
99
  let r = cb.real.function(["Math.cos(t)", "Math.sin(t)"], "curv"); // r(t) = (cos(t), sin(t))
96
- cb.plot.xyplane(2); // Draws the Cartesian coordinate plane
97
- cb.plot.function(r, 2, [255, 0, 0] [0, cb.PI(1/2)]); // Plots r(t) colored red from t = 0 to t = π/2
100
+ cb.plot.xyplane({size: 2}); // Draws the Cartesian coordinate plane scaled by 2
101
+ cb.plot.function(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
98
102
 
99
103
  let a = cb.vec3.new(1, 2, 3); // Vector a = (1, 2, 3)
100
104
  let b = cb.vec3.new(4, 5, 6); // Vector b = (4, 5, 6)
@@ -110,8 +114,14 @@ let m = cb.matr.new([0, 1, 1, 1, 1], // m is a 5x5 matrix
110
114
  let mi = cb.matr.invert(m); // mi is the inverse of m
111
115
  let mmi = cb.matr.mul(m, mi); // mmi is the product of m and mi
112
116
  cb.matr.print(mmi); // Prints mmi in the console
117
+
118
+ let t = cb.tens.new([[1, 2], [3, 4]], // t is a 2x2x2 (rank-3) tensor
119
+ [[5, 6], [7, 8]]);
120
+ let tt = cb.tens.mul(t, t); // tt is a 2x2x2x2x2x2 (rank-6) tensor
121
+ let ttm = cb.tens.resize(tt, 8, 8); // ttm is an 8x8 matrix (or rank-2 tensor)
122
+ cb.tens.print(tt); // Prints tt in the console just to see what it looks like for fun
113
123
  ```
114
- More examples that are more interesting can be seen [here](https://zushah.github.io/Chalkboard/examples.html) with their source code [here](https://github.com/Zushah/Chalkboard/tree/main/examples).
124
+ 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).
115
125
 
116
126
  # Contributing
117
127
  <ol>
@@ -121,13 +131,14 @@ More examples that are more interesting can be seen [here](https://zushah.github
121
131
  <li>Open a pull request. It will be reviewed soon and then merged to the main branch.</li>
122
132
  </ol>
123
133
 
124
- The changelog can be read [here](https://github.com/Zushah/Chalkboard/blob/main/CHANGELOG.md).
134
+ The changelog can be read [here](https://www.github.com/Zushah/Chalkboard/blob/main/CHANGELOG.md).
125
135
 
126
- The Chalkboard library is available under the [MIT License](https://github.com/Zushah/Chalkboard/blob/main/LICENSE.md).
136
+ The Chalkboard library is available under the [MIT License](https://www.github.com/Zushah/Chalkboard/blob/main/LICENSE.md).
127
137
 
128
- # Acknowledgements
129
- Thanks to [Bhavjit Chauhan](https://github.com/bhavjitChauhan) for his [contribution](https://www.github.com/Zushah/Chalkboard/pull/1) to [v1.3.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.3.0).\
130
- Thanks to [G. Yang](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).
138
+ # Acknowledgments
139
+ Thanks to [Bhavjit Chauhan](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).\
140
+ Thanks to [G. Yang](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).\
141
+ 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).
131
142
 
132
143
  # Contact
133
144
  [GitHub](https://www.github.com/Zushah)\
package/docs/README.md CHANGED
@@ -1,2 +1,2 @@
1
1
  # Chalkboard documentation
2
- The documentation for [Chalkboard v1.5.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.5.0) can be visited [here](https://zushah.github.io/Chalkboard/documentation.html/). Its source code is located [here](https://github.com/Zushah/zushah.github.io/blob/main/Chalkboard/documentation.html).
2
+ The documentation for [Chalkboard v1.7.0 Descartes](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.7.0) can be visited [here](https://zushah.github.io/Chalkboard/documentation.html/). Its source code is located [here](https://www.github.com/Zushah/zushah.github.io/blob/main/Chalkboard/documentation.html).
@@ -1,5 +1,5 @@
1
1
  # Chalkboard examples
2
- Six basic programs made by Zushah that utilize [Chalkboard v1.5.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.5.0) are located in this directory.
2
+ Six basic programs made by Zushah that utilize [Chalkboard v1.7.0 Descartes](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.7.0) are located in this directory.
3
3
 
4
4
  They can be viewed in action here:
5
5
  - [fluid.js](https://zushah.github.io/Chalkboard/examples/fluid.html)
package/examples/fluid.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  The Chalkboard Library ===> https://www.github.com/Zushah/Chalkboard
3
- Version 1.5.0 Example Program: Fluid Flow
3
+ Version 1.7.0 Descartes Example Program: Fluid Flow
4
4
  Authored by Zushah ===> https://www.github.com/Zushah
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  The Chalkboard Library ===> https://www.github.com/Zushah/Chalkboard
3
- Version 1.5.0 Example Program: Hyperbolic Functions
3
+ Version 1.7.0 Descartes Example Program: Hyperbolic Functions
4
4
  Authored by Zushah ===> https://www.github.com/Zushah
5
5
  */
6
6
 
@@ -15,12 +15,12 @@ var theta = 0;
15
15
  function main() {
16
16
  ctx.fillStyle = "rgb(255, 255, 255)";
17
17
  ctx.fillRect(0, 0, canvas.width, canvas.height);
18
- cb.plot.xyplane(1, [0, 0, 0], [canvas.width / 2, canvas.height / 2], 2);
18
+ cb.plot.xyplane({lineWidth: 2});
19
19
 
20
20
  // Plot the unit hyperbola with a parametric function (see: https://en.wikipedia.org/wiki/Hyperbola)
21
21
  var f = cb.real.function(["(t * t + 1) / (2 * t)", "(t * t - 1) / (2 * t)"], "curv");
22
- cb.plot.function(f, 1, [100, 100, 255], [0, 10], [canvas.width / 2, canvas.height / 2], 4);
23
- cb.plot.function(f, 1, [100, 100, 255], [-10, 0], [canvas.width / 2, canvas.height / 2], 4);
22
+ cb.plot.function(f, {strokeStyle: "rgb(100, 100, 255)", domain: [0, 10], lineWidth: 4});
23
+ cb.plot.function(f, {strokeStyle: "rgb(100, 100, 255)", domain: [-10, 0], lineWidth: 4});
24
24
 
25
25
  // The two main hyperbolic trigonometric functions, hyperbolic sine (sinh) and hyperbolic cosine (cosh)
26
26
  var x = cb.trig.cosh(theta);
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  The Chalkboard Library ===> https://www.github.com/Zushah/Chalkboard
3
- Version 1.5.0 Example Program: Mandelbrot Set
3
+ Version 1.7.0 Descartes Example Program: Mandelbrot Set
4
4
  Authored by Zushah ===> https://www.github.com/Zushah
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  The Chalkboard Library ===> https://www.github.com/Zushah/Chalkboard
3
- Version 1.5.0 Example Program: Matrix Donut
3
+ Version 1.7.0 Descartes Example Program: Matrix Donut
4
4
  Authored by Zushah ===> https://www.github.com/Zushah
5
5
  */
6
6
 
@@ -11,7 +11,7 @@ canvas.height = window.innerHeight;
11
11
 
12
12
  var cb = Chalkboard; // Initialize Chalkboard as cb
13
13
 
14
- // Generate the donut's points with a parametric function (see: https://en.wikipedia.org/wiki/Torus)
14
+ // Generate the donut's points with parametric equations (see: https://en.wikipedia.org/wiki/Torus)
15
15
  var points = [];
16
16
  for(var u = 0; u < cb.PI(2); u += cb.PI(1/16)) {
17
17
  for(var v = 0; v < cb.PI(2); v += cb.PI(1/6)) {
@@ -41,9 +41,7 @@ function main() {
41
41
  // Make the donut rotate with a rotation matrix
42
42
  var r = cb.matr.rotator(cb.trig.toRad(1), cb.trig.toRad(1), cb.trig.toRad(1));
43
43
  for(var i = 0; i < points.length; i++) {
44
- var buffer = cb.vec3.toMatrix(points[i]); // Create a buffer matrix which has the donut's points
45
- var rbuffer = cb.matr.mul(r, buffer); // Multiply the rotation matrix with the buffer matrix
46
- points[i] = cb.matr.toVector(rbuffer, "vec3"); // Reassign the values of the donut's points to the new rotated points
44
+ points[i] = cb.matr.mulvec(r, points[i]); // Multiply the rotation matrix with the points' vectors
47
45
  }
48
46
 
49
47
  window.requestAnimationFrame(main);
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  The Chalkboard Library ===> https://www.github.com/Zushah/Chalkboard
3
- Version 1.5.0 Example Program: Newton's Method
3
+ Version 1.7.0 Descartes Example Program: Newton's Method
4
4
  Authored by Zushah ===> https://www.github.com/Zushah
5
5
  */
6
6
 
@@ -26,10 +26,10 @@ var y = cb.real.function(cb.calc.dfdx(f, root) + " * (x - " + root + ") + " + cb
26
26
  function main() {
27
27
  ctx.fillStyle = "rgb(255, 255, 255)";
28
28
  ctx.fillRect(0, 0, canvas.width, canvas.height);
29
- cb.plot.xyplane(1, [0, 0, 0], [canvas.width / 2, canvas.height / 2], 2);
29
+ cb.plot.xyplane({lineWidth: 2});
30
30
 
31
31
  // Draw the polynomial
32
- cb.plot.function(f, 1, [100, 100, 255], [-10, 10], [canvas.width / 2, canvas.height / 2], 4);
32
+ cb.plot.function(f, {strokeStyle: "rgb(100, 100, 255)", lineWidth: 4});
33
33
  ctx.fillStyle = "rgb(0, 0, 0)";
34
34
  ctx.font = "50px Times New Roman";
35
35
  ctx.fillText("f(x) = " + c1.toFixed(2) + "x⁴ + " + c2.toFixed(2) + "x³ + " + c3.toFixed(2) + "x² + " + c4.toFixed(2) + "x + " + c5.toFixed(2), 20, 70);
@@ -38,7 +38,7 @@ function main() {
38
38
  if(cb.real.val(f, root).toFixed(1) == 0) {
39
39
  ctx.fillText("y = " + cb.calc.dfdx(f, root).toFixed(2) + "x - " + (cb.calc.dfdx(f, root) * root).toFixed(2), 20, 120);
40
40
  ctx.fillText("A possible root is at x = " + root.toFixed(2), 20, 170);
41
- cb.plot.function(y, 1, [255, 100, 100], [-10, 10], [canvas.width / 2, canvas.height / 2], 4);
41
+ cb.plot.function(y, {strokeStyle: "rgb(255, 100, 100)", lineWidth: 4});
42
42
  ctx.save();
43
43
  ctx.translate(canvas.width / 2, canvas.height / 2);
44
44
  ctx.beginPath();
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  The Chalkboard Library ===> https://www.github.com/Zushah/Chalkboard
3
- Version 1.5.0 Example Program: Quaternion Donut
3
+ Version 1.7.0 Descartes Example Program: Quaternion Donut
4
4
  Authored by Zushah ===> https://www.github.com/Zushah
5
5
  */
6
6
 
@@ -11,7 +11,7 @@ canvas.height = window.innerHeight;
11
11
 
12
12
  var cb = Chalkboard; // Initialize Chalkboard as cb
13
13
 
14
- // Generate the donut's points with a parametric function (see: https://en.wikipedia.org/wiki/Torus)
14
+ // Generate the donut's points with parametric equations (see: https://en.wikipedia.org/wiki/Torus)
15
15
  var points = [];
16
16
  for(var u = 0; u < cb.PI(2); u += cb.PI(1/16)) {
17
17
  for(var v = 0; v < cb.PI(2); v += cb.PI(1/6)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zushah/chalkboard",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "The Chalkboard library provides a plethora of mathematical functionalities for its user.",
5
5
  "main": "src/Chalkboard.js",
6
6
  "scripts": {
@@ -20,5 +20,8 @@
20
20
  "bugs": {
21
21
  "url": "https://github.com/Zushah/Chalkboard/issues"
22
22
  },
23
- "homepage": "https://zushah.github.io/Chalkboard/home.html"
23
+ "homepage": "https://zushah.github.io/Chalkboard/home.html",
24
+ "publishConfig": {
25
+ "access": "public"
26
+ }
24
27
  }