@thi.ng/math
Advanced tools
Comparing version 5.3.16 to 5.3.17
# Change Log | ||
- **Last updated**: 2022-12-16T12:52:25Z | ||
- **Last updated**: 2022-12-20T16:33:11Z | ||
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub) | ||
@@ -5,0 +5,0 @@ |
@@ -95,7 +95,7 @@ import type { FnN, FnN2, FnN3, FnN4, FnU3 } from "@thi.ng/api"; | ||
/** | ||
* Smooth maximum. Note: Result values will be slightly larger than max | ||
* value near max(a,b) + eps due to exponential decay. Higher `k` values | ||
* reduce the error, but also reduce the smoothing. Recommended k=16. | ||
* Smooth maximum. Note: Result values will be slightly larger than max value | ||
* near max(a,b) + eps due to exponential decay. Higher `k` values reduce the | ||
* error, but also reduce the smoothing. Recommended k=16. | ||
* | ||
* {@link https://en.wikipedia.org/wiki/Smooth_maximum} | ||
* https://en.wikipedia.org/wiki/Smooth_maximum | ||
* | ||
@@ -102,0 +102,0 @@ * @param a - |
@@ -138,7 +138,7 @@ /** | ||
/** | ||
* Smooth maximum. Note: Result values will be slightly larger than max | ||
* value near max(a,b) + eps due to exponential decay. Higher `k` values | ||
* reduce the error, but also reduce the smoothing. Recommended k=16. | ||
* Smooth maximum. Note: Result values will be slightly larger than max value | ||
* near max(a,b) + eps due to exponential decay. Higher `k` values reduce the | ||
* error, but also reduce the smoothing. Recommended k=16. | ||
* | ||
* {@link https://en.wikipedia.org/wiki/Smooth_maximum} | ||
* https://en.wikipedia.org/wiki/Smooth_maximum | ||
* | ||
@@ -145,0 +145,0 @@ * @param a - |
40
mix.d.ts
@@ -50,6 +50,6 @@ import type { FnN, FnN2, FnN3, FnN4, FnN5, FnN6 } from "@thi.ng/api"; | ||
/** | ||
* Returns hermite interpolation of `a, b, c, d` at normalized position | ||
* `t`, where `a` and `d` are used as predecessor/successor of `b` / `c` | ||
* and only inform the tangent of the interpolation curve. The | ||
* interpolated result is that of `b` and `c`. | ||
* Returns hermite interpolation of `a, b, c, d` at normalized position `t`, | ||
* where `a` and `d` are used as predecessor/successor of `b` / `c` and only | ||
* inform the tangent of the interpolation curve. The interpolated result is | ||
* that of `b` and `c`. | ||
* | ||
@@ -60,6 +60,6 @@ * Assumes all inputs are uniformly spaced. If that's not the case, use | ||
* | ||
* See: {@link https://www.desmos.com/calculator/j4gf8g9vkr} | ||
* See: https://www.desmos.com/calculator/j4gf8g9vkr | ||
* | ||
* Source: | ||
* {@link https://www.musicdsp.org/en/latest/Other/93-hermite-interpollation.html} | ||
* https://www.musicdsp.org/en/latest/Other/93-hermite-interpollation.html | ||
* | ||
@@ -81,3 +81,3 @@ * - {@link mixCubicHermite} | ||
* | ||
* {@link https://en.wikipedia.org/wiki/Cubic_Hermite_spline} | ||
* https://en.wikipedia.org/wiki/Cubic_Hermite_spline | ||
* | ||
@@ -136,10 +136,10 @@ * - {@link mixHermite} | ||
/** | ||
* Helper function for {@link mixCubicHermite}. Computes cardinal tangents | ||
* based on point neighbors of a point B (not given), i.e. `a` | ||
* (predecessor) and `c` (successor) and their times (defaults to | ||
* uniformly spaced). The optional `tension` parameter can be used to | ||
* scale the tangent where 0.0 produces a Cardinal spline tangent and | ||
* 1.0 a Catmull-Rom (opposite to the Wikipedia ref). | ||
* Helper function for {@link mixCubicHermite}. Computes cardinal tangents based | ||
* on point neighbors of a point B (not given), i.e. `a` (predecessor) and `c` | ||
* (successor) and their times (defaults to uniformly spaced). The optional | ||
* `tension` parameter can be used to scale the tangent where 0.0 produces a | ||
* Cardinal spline tangent and 1.0 a Catmull-Rom (opposite to the Wikipedia | ||
* ref). | ||
* | ||
* {@link https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline} | ||
* https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline | ||
* | ||
@@ -155,11 +155,11 @@ * @param prev - | ||
* Helper function for {@link mixCubicHermite}. Computes tangent for `curr`, | ||
* based on 3-point finite difference, where `prev` & `next` are | ||
* `curr`'s neighbors and the `tX` the three points' respective time | ||
* values. The latter are equally spaced by default (each 1.0 apart). | ||
* based on 3-point finite difference, where `prev` & `next` are `curr`'s | ||
* neighbors and the `tX` the three points' respective time values. The latter | ||
* are equally spaced by default (each 1.0 apart). | ||
* | ||
* Using this function with equal spacing of 1.0 and together with | ||
* {@link mixCubicHermite} will produce same results as the somewhat | ||
* optimized variant {@link mixHermite}. | ||
* {@link mixCubicHermite} will produce same results as the somewhat optimized | ||
* variant {@link mixHermite}. | ||
* | ||
* {@link https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Finite_difference} | ||
* https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Finite_difference | ||
* | ||
@@ -166,0 +166,0 @@ * @param prev - |
40
mix.js
@@ -62,6 +62,6 @@ import { EPS, HALF_PI, PI } from "./api.js"; | ||
/** | ||
* Returns hermite interpolation of `a, b, c, d` at normalized position | ||
* `t`, where `a` and `d` are used as predecessor/successor of `b` / `c` | ||
* and only inform the tangent of the interpolation curve. The | ||
* interpolated result is that of `b` and `c`. | ||
* Returns hermite interpolation of `a, b, c, d` at normalized position `t`, | ||
* where `a` and `d` are used as predecessor/successor of `b` / `c` and only | ||
* inform the tangent of the interpolation curve. The interpolated result is | ||
* that of `b` and `c`. | ||
* | ||
@@ -72,6 +72,6 @@ * Assumes all inputs are uniformly spaced. If that's not the case, use | ||
* | ||
* See: {@link https://www.desmos.com/calculator/j4gf8g9vkr} | ||
* See: https://www.desmos.com/calculator/j4gf8g9vkr | ||
* | ||
* Source: | ||
* {@link https://www.musicdsp.org/en/latest/Other/93-hermite-interpollation.html} | ||
* https://www.musicdsp.org/en/latest/Other/93-hermite-interpollation.html | ||
* | ||
@@ -97,3 +97,3 @@ * - {@link mixCubicHermite} | ||
* | ||
* {@link https://en.wikipedia.org/wiki/Cubic_Hermite_spline} | ||
* https://en.wikipedia.org/wiki/Cubic_Hermite_spline | ||
* | ||
@@ -169,10 +169,10 @@ * - {@link mixHermite} | ||
/** | ||
* Helper function for {@link mixCubicHermite}. Computes cardinal tangents | ||
* based on point neighbors of a point B (not given), i.e. `a` | ||
* (predecessor) and `c` (successor) and their times (defaults to | ||
* uniformly spaced). The optional `tension` parameter can be used to | ||
* scale the tangent where 0.0 produces a Cardinal spline tangent and | ||
* 1.0 a Catmull-Rom (opposite to the Wikipedia ref). | ||
* Helper function for {@link mixCubicHermite}. Computes cardinal tangents based | ||
* on point neighbors of a point B (not given), i.e. `a` (predecessor) and `c` | ||
* (successor) and their times (defaults to uniformly spaced). The optional | ||
* `tension` parameter can be used to scale the tangent where 0.0 produces a | ||
* Cardinal spline tangent and 1.0 a Catmull-Rom (opposite to the Wikipedia | ||
* ref). | ||
* | ||
* {@link https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline} | ||
* https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline | ||
* | ||
@@ -188,11 +188,11 @@ * @param prev - | ||
* Helper function for {@link mixCubicHermite}. Computes tangent for `curr`, | ||
* based on 3-point finite difference, where `prev` & `next` are | ||
* `curr`'s neighbors and the `tX` the three points' respective time | ||
* values. The latter are equally spaced by default (each 1.0 apart). | ||
* based on 3-point finite difference, where `prev` & `next` are `curr`'s | ||
* neighbors and the `tX` the three points' respective time values. The latter | ||
* are equally spaced by default (each 1.0 apart). | ||
* | ||
* Using this function with equal spacing of 1.0 and together with | ||
* {@link mixCubicHermite} will produce same results as the somewhat | ||
* optimized variant {@link mixHermite}. | ||
* {@link mixCubicHermite} will produce same results as the somewhat optimized | ||
* variant {@link mixHermite}. | ||
* | ||
* {@link https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Finite_difference} | ||
* https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Finite_difference | ||
* | ||
@@ -199,0 +199,0 @@ * @param prev - |
{ | ||
"name": "@thi.ng/math", | ||
"version": "5.3.16", | ||
"version": "5.3.17", | ||
"description": "Assorted common math functions & utilities", | ||
@@ -40,3 +40,3 @@ "type": "module", | ||
"dependencies": { | ||
"@thi.ng/api": "^8.6.0" | ||
"@thi.ng/api": "^8.6.1" | ||
}, | ||
@@ -139,3 +139,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "f445a9cc8022bcdebbf6ff91fd66ced016d72f01\n" | ||
"gitHead": "7b2af448da8a63fb21704a79cc4cdf1f3d7d7a64\n" | ||
} |
import type { FnN2 } from "@thi.ng/api"; | ||
/** | ||
* Produces a new function which computes derivative of the given | ||
* single-arg function. The extra optional arg `eps` is used to | ||
* define the step width for computing derived values: | ||
* Produces a new function which computes derivative of the given single-arg | ||
* function. The extra optional arg `eps` is used to define the step width for | ||
* computing derived values: | ||
* | ||
* `f'(x) = (f(x + eps) - f(x)) / eps` | ||
* | ||
* The original function is assumed to be fully differentiable | ||
* in the interval the returned function is going to be used. | ||
* No validity checks of any form are done. | ||
* The original function is assumed to be fully differentiable in the interval | ||
* the returned function is going to be used. No validity checks of any form are | ||
* done. | ||
* | ||
* {@link https://en.wikipedia.org/wiki/Derivative#Continuity_and_differentiability} | ||
* https://en.wikipedia.org/wiki/Derivative#Continuity_and_differentiability | ||
* | ||
@@ -29,9 +29,8 @@ * @param fn - | ||
/** | ||
* Computes solutions for quadratic equation: `ax^2 + bx + c = 0`. | ||
* Returns array of real solutions. | ||
* Note: `a` MUST NOT be zero. If the quadratic term is missing, | ||
* use {@link solveLinear} instead. | ||
* Computes solutions for quadratic equation: `ax^2 + bx + c = 0`. Returns array | ||
* of real solutions. Note: `a` MUST NOT be zero. If the quadratic term is | ||
* missing, use {@link solveLinear} instead. | ||
* | ||
* - {@link https://en.wikipedia.org/wiki/Quadratic_function} | ||
* - {@link https://en.wikipedia.org/wiki/Quadratic_equation} | ||
* - https://en.wikipedia.org/wiki/Quadratic_function | ||
* - https://en.wikipedia.org/wiki/Quadratic_equation | ||
* | ||
@@ -46,7 +45,7 @@ * @param a - quadratic coefficient | ||
* Computes solutions for quadratic equation: `ax^3 + bx^2 + c*x + d = 0`. | ||
* Returns array of solutions, both real & imaginary. | ||
* Note: `a` MUST NOT be zero. If the cubic term is missing (i.e. zero), | ||
* use {@link solveQuadratic} or {@link solveLinear} instead. | ||
* Returns array of solutions, both real & imaginary. Note: `a` MUST NOT be | ||
* zero. If the cubic term is missing (i.e. zero), use {@link solveQuadratic} or | ||
* {@link solveLinear} instead. | ||
* | ||
* {@link https://en.wikipedia.org/wiki/Cubic_function} | ||
* https://en.wikipedia.org/wiki/Cubic_function | ||
* | ||
@@ -53,0 +52,0 @@ * @param a - cubic coefficient |
33
solve.js
import { EPS } from "./api.js"; | ||
import { safeDiv } from "./safe-div.js"; | ||
/** | ||
* Produces a new function which computes derivative of the given | ||
* single-arg function. The extra optional arg `eps` is used to | ||
* define the step width for computing derived values: | ||
* Produces a new function which computes derivative of the given single-arg | ||
* function. The extra optional arg `eps` is used to define the step width for | ||
* computing derived values: | ||
* | ||
* `f'(x) = (f(x + eps) - f(x)) / eps` | ||
* | ||
* The original function is assumed to be fully differentiable | ||
* in the interval the returned function is going to be used. | ||
* No validity checks of any form are done. | ||
* The original function is assumed to be fully differentiable in the interval | ||
* the returned function is going to be used. No validity checks of any form are | ||
* done. | ||
* | ||
* {@link https://en.wikipedia.org/wiki/Derivative#Continuity_and_differentiability} | ||
* https://en.wikipedia.org/wiki/Derivative#Continuity_and_differentiability | ||
* | ||
@@ -30,9 +30,8 @@ * @param fn - | ||
/** | ||
* Computes solutions for quadratic equation: `ax^2 + bx + c = 0`. | ||
* Returns array of real solutions. | ||
* Note: `a` MUST NOT be zero. If the quadratic term is missing, | ||
* use {@link solveLinear} instead. | ||
* Computes solutions for quadratic equation: `ax^2 + bx + c = 0`. Returns array | ||
* of real solutions. Note: `a` MUST NOT be zero. If the quadratic term is | ||
* missing, use {@link solveLinear} instead. | ||
* | ||
* - {@link https://en.wikipedia.org/wiki/Quadratic_function} | ||
* - {@link https://en.wikipedia.org/wiki/Quadratic_equation} | ||
* - https://en.wikipedia.org/wiki/Quadratic_function | ||
* - https://en.wikipedia.org/wiki/Quadratic_equation | ||
* | ||
@@ -55,7 +54,7 @@ * @param a - quadratic coefficient | ||
* Computes solutions for quadratic equation: `ax^3 + bx^2 + c*x + d = 0`. | ||
* Returns array of solutions, both real & imaginary. | ||
* Note: `a` MUST NOT be zero. If the cubic term is missing (i.e. zero), | ||
* use {@link solveQuadratic} or {@link solveLinear} instead. | ||
* Returns array of solutions, both real & imaginary. Note: `a` MUST NOT be | ||
* zero. If the cubic term is missing (i.e. zero), use {@link solveQuadratic} or | ||
* {@link solveLinear} instead. | ||
* | ||
* {@link https://en.wikipedia.org/wiki/Cubic_function} | ||
* https://en.wikipedia.org/wiki/Cubic_function | ||
* | ||
@@ -62,0 +61,0 @@ * @param a - cubic coefficient |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
106394
2616
Updated@thi.ng/api@^8.6.1