Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 50 additions & 6 deletions BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,8 @@ products.** `factorize(360)` was `factorize * 360` and simplified to `360 * fact
of them, so each is refused with what to write today: in C#, `MathS.NumberTheory.Factorize(n)` for the prime factors of
an integer and `Factorize()` to factor an expression; `prime(primepi(n) + 1)` for the least prime above `n`;
`divisorsigma(0, n)` and `divisorsigma(1, n)` for the count and the sum of the divisors
([#2449](https://github.com/asc-community/AngouriMath/issues/2449)); `jacobian([f], [x, y])` for a gradient and
`trace(jacobian(F, [x, y]))` for a divergence ([#2182](https://github.com/asc-community/AngouriMath/issues/2182)).
Euler's totient is `phi(n)`, and `φ(n)` and `ϕ(n)` are refused. Each name without a bracket is still a variable.
([#2449](https://github.com/asc-community/AngouriMath/issues/2449)). `gradient` and `divergence` were refused too,
until they were implemented; see below. Euler's totient is `phi(n)`, and `φ(n)` and `ϕ(n)` are refused. Each name without a bracket is still a variable.

| Input | Was (2.7.0) | Now |
|---|---|---|
Expand All @@ -131,9 +130,6 @@ Euler's totient is `phi(n)`, and `φ(n)` and `ϕ(n)` are refused. Each name with
| `"divisors(12)".ToEntity()` | `divisors * 12` | throws `UnrecognizedFunctionParseException`: write `divisorsigma(0, n)` or `divisorsigma(1, n)` |
| `"φ(10)".ToEntity()` | `φ * 10` | throws `UnrecognizedFunctionParseException`: write `phi(n)` |
| `"ϕ(10)".ToEntity()` | `ϕ * 10` | throws `UnrecognizedFunctionParseException`: write `phi(n)` |
| `"gradient(x^2)".ToEntity()` | `gradient * x ^ 2` | throws `UnrecognizedFunctionParseException` |
| `"divergence(x)".ToEntity()` | `divergence * x` | throws `UnrecognizedFunctionParseException` |
| `"gradient(x^2*y, [x, y])".ToEntity()` | throws `UnhandledParseException` | throws `UnrecognizedFunctionParseException` |

### A definite integral with a parameter takes the limit at an infinite bound

Expand Down Expand Up @@ -316,6 +312,54 @@ changes. See [`Docs/Usage/Shaders.md`](Sources/AngouriMath/Docs/Usage/Shaders.md

---

### The Riemann and the Hurwitz zeta functions

**Not silent: what was refused now parses.** `zeta(s)` and `zeta(s, a)`, also `riemannzeta(s)` and `hurwitzzeta(s, a)`,
threw `UnrecognizedFunctionParseException`, the names being reserved. They are now `Entity.Zetaf`, built by `MathS.Zeta`:
the Riemann zeta function, and the Hurwitz one of [DLMF 25.11](https://dlmf.nist.gov/25.11), `sum_(n >= 0) 1/(n + a)^s`
continued to every `s` but its pole at `1`, with no value where `a` is `0, -1, -2, ...`. It is exact at `0`, at the
even numbers and the negative whole numbers, and at a whole `s >= 2` with a whole or half-whole `a` it is written in
`zeta(s)`; elsewhere it is evaluated to the working precision, real or complex. `zeta` alone is still a variable, and
`zeta (s)` with a space still the product `zeta * s`, as `gamma (s)` is. `Zeta(s)` is still `Zeta * s`
([#2182](https://github.com/asc-community/AngouriMath/issues/2182)).

| Input | Was (2.7.0) | Now |
|---|---|---|
| `"zeta(2)".ToEntity().Simplify()` | throws `UnrecognizedFunctionParseException` | `pi ^ 2 / 6` |
| `"zeta(-1)".ToEntity().Simplify()` | throws `UnrecognizedFunctionParseException` | `-1/12` |
| `"zeta(3)".ToEntity().Evaled` | throws `UnrecognizedFunctionParseException` | `1.2020569031595942853997…` |
| `"zeta(3, 1/2)".ToEntity().Simplify()` | throws `UnrecognizedFunctionParseException` | `7 * zeta(3)` |
| `"zeta(1)".ToEntity().Simplify()` | throws `UnrecognizedFunctionParseException` | `NaN`, the pole |
| `"riemannzeta(s)".ToEntity()` | throws `UnrecognizedFunctionParseException` | `zeta(s)` |
| `"hurwitzzeta(s, a)".ToEntity()` | throws `UnrecognizedFunctionParseException` | `zeta(s, a)` |
| `"zeta (s)".ToEntity()` | `zeta * s` | unchanged |

### The gradient, the divergence and the curl

**Not silent: what was refused or a product now parses or is refused differently.** `gradient(f, x)`,
`divergence(F, x)` and `curl(F, x)` are computed into derivatives when parsed, as `jacobian` is: the gradient is the
column of the first derivatives of a scalar `f`, the divergence the sum of each component's derivative in its variable,
and the curl the column `[dF_3/dy - dF_2/dz, dF_1/dz - dF_3/dx, dF_2/dx - dF_1/dy]`, in three variables only. The
variables are a vector, `[x, y, z]`, or one name, and the field of a divergence or a curl a vector written out with a
component for each. With one argument each throws `FunctionArgumentCountException` saying to give the variables:
`gradient(x^2)` and `divergence(x)` were refused by name in 2.8 already, while in 2.7.0 they and `curl(x)` were products.
With two, `gradient` and `divergence` were refused by name and `curl` was a parse error. There is no `grad` or `div`:
both, and `curl` alone, are still variables ([#2182](https://github.com/asc-community/AngouriMath/issues/2182)).

| Input | Was (2.7.0) | Now |
|---|---|---|
| `"gradient(x^2 y + z, [x, y, z])".ToEntity().Simplify()` | throws `UnhandledParseException` | `[2 * x * y, x ^ 2, 1]` |
| `"divergence([x y, y z, z x], [x, y, z])".ToEntity().Simplify()` | throws `UnhandledParseException` | `x + y + z` |
| `"curl([-y, x, 0], [x, y, z])".ToEntity().Simplify()` | throws `UnhandledParseException` | `[0, 0, 2]` |
| `"curl([x, y], [x, y])".ToEntity()` | throws `UnhandledParseException` | throws `InvalidArgumentParseException`: three variables only |
| `"gradient(x^2)".ToEntity()` | `gradient * x ^ 2` | throws `FunctionArgumentCountException`: give the variables |
| `"divergence(x)".ToEntity()` | `divergence * x` | throws `FunctionArgumentCountException`: give the variables |
| `"curl(x)".ToEntity()` | `curl * x` | throws `FunctionArgumentCountException`: give the variables |
| `"grad(f, x)".ToEntity()` | throws `UnhandledParseException` | unchanged |

---


### A system row that is not a solution declines the system

**Silent: a wrong row is now no answer.** With `P + Q sqrt(2) = (1 + sqrt(2))^70`, the coefficient `P - Q y` is
Expand Down
9 changes: 9 additions & 0 deletions Sources/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1132,3 +1132,12 @@ file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed

[Tests/UnitTests/Convenience/PrimeFactorizationNodeTest.cs]
file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed under MIT.\nDetails: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.\nWebsite: https://am.angouri.org.\n

[AngouriMath/Core/Entity/Continuous/Entity.Continuous.Zeta.Classes.cs]
file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed under MIT.\nDetails: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.\nWebsite: https://am.angouri.org.\n

[AngouriMath/Core/Entity/Continuous/Number/Zeta.cs]
file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed under MIT.\nDetails: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.\nWebsite: https://am.angouri.org.\n

[Tests/UnitTests/Convenience/ZetaTest.cs]
file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed under MIT.\nDetails: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.\nWebsite: https://am.angouri.org.\n
16 changes: 16 additions & 0 deletions Sources/AngouriMath/Convenience/MathS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1729,6 +1729,22 @@ public static Entity VectorLength(Matrix v)
/// <remarks>https://github.com/asc-community/AngouriMath/issues/2182</remarks>
public static Entity LambertW(Entity k, Entity z) => new LambertWf(k, z);

/// <summary>The Riemann zeta function, <c>zeta(s) = sum_(n >= 1) 1/n^s</c> continued to every <c>s</c> but its pole at <c>1</c></summary>
/// <param name="s">The argument, any complex number but <c>1</c></param>
/// <returns>The <see cref="Entity.Zetaf"/> node, with the parameter <c>1</c></returns>
/// <remarks>https://github.com/asc-community/AngouriMath/issues/2182</remarks>
public static Entity Zeta(Entity s) => new Zetaf(s, Integer.One);

/// <summary>
/// The Hurwitz zeta function, <c>zeta(s, a) = sum_(n >= 0) 1/(n + a)^s</c> continued to every <c>s</c> but its pole at
/// <c>1</c> (DLMF 25.11.1); <c>zeta(s, 1)</c> is the Riemann zeta function
/// </summary>
/// <param name="s">The argument, any complex number but <c>1</c></param>
/// <param name="a">The parameter, any complex number but <c>0, -1, -2, ...</c></param>
/// <returns>The <see cref="Entity.Zetaf"/> node</returns>
/// <remarks>https://github.com/asc-community/AngouriMath/issues/2182</remarks>
public static Entity Zeta(Entity s, Entity a) => new Zetaf(s, a);

/// <summary>The upper incomplete gamma function, <c>Gamma(a, z) = int_z^oo t^(a - 1) e^(-t) dt</c></summary>
/// <param name="parameter">The parameter <c>a</c>, any complex number</param>
/// <param name="lowerLimit">The lower limit <c>z</c>, any complex number; <c>0</c> only where <c>Re a > 0</c></param>
Expand Down
21 changes: 9 additions & 12 deletions Sources/AngouriMath/Core/Antlr/AngouriMath.g
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,11 @@ atom returns[Entity value]
| 'productlog(' args = function_arguments ')' { if (Assert("productlog", (2, 1), $args.list.Count)) $value = MathS.LambertW($args.list[0], $args.list[1]); else $value = MathS.LambertW($args.list[0]); }
| 'polygamma(' args = function_arguments ')' { Assert("polygamma", 2, $args.list.Count); $value = MathS.Polygamma($args.list[0], $args.list[1]); }
| 'digamma(' args = function_arguments ')' { Assert("digamma", 1, $args.list.Count); $value = MathS.Digamma($args.list[0]); }
/* The Riemann zeta function zeta(s), and the Hurwitz one zeta(s, a), also by their long names.
https://github.com/asc-community/AngouriMath/issues/2182 */
| 'zeta(' args = function_arguments ')' { if (Assert("zeta", (1, 2), $args.list.Count)) $value = MathS.Zeta($args.list[0]); else $value = MathS.Zeta($args.list[0], $args.list[1]); }
| 'riemannzeta(' args = function_arguments ')' { Assert("riemannzeta", 1, $args.list.Count); $value = MathS.Zeta($args.list[0]); }
| 'hurwitzzeta(' args = function_arguments ')' { Assert("hurwitzzeta", 2, $args.list.Count); $value = MathS.Zeta($args.list[0], $args.list[1]); }
/* The trigonometric and hyperbolic integrals. https://github.com/asc-community/AngouriMath/issues/1501 */
| 'Si(' args = function_arguments ')' { Assert("Si", 1, $args.list.Count); $value = MathS.Si($args.list[0]); }
| 'Ci(' args = function_arguments ')' { Assert("Ci", 1, $args.list.Count); $value = MathS.Ci($args.list[0]); }
Expand All @@ -699,6 +704,9 @@ atom returns[Entity value]
| 'forwarddifference(' args = function_arguments ')' { Assert("forwarddifference", 2, $args.list.Count); $value = ParsingHelpers.ForwardDifference($args.list[0], $args.list[1]); }
| 'jacobian(' args = function_arguments ')' { Assert("jacobian", 2, $args.list.Count); $value = ParsingHelpers.Jacobian($args.list[0], $args.list[1]); }
| 'hessian(' args = function_arguments ')' { Assert("hessian", 2, $args.list.Count); $value = ParsingHelpers.Hessian($args.list[0], $args.list[1]); }
| 'gradient(' args = function_arguments ')' { $value = ParsingHelpers.Gradient($args.list); }
| 'divergence(' args = function_arguments ')' { $value = ParsingHelpers.Divergence($args.list); }
| 'curl(' args = function_arguments ')' { $value = ParsingHelpers.Curl($args.list); }
| 'resultant(' args = function_arguments ')' { Assert("resultant", 3, $args.list.Count); $value = ParsingHelpers.Resultant($args.list[0], $args.list[1], $args.list[2]); }
/* The complex conjugate, by its name and by the shorter one other systems use.
https://github.com/asc-community/AngouriMath/issues/2145 */
Expand All @@ -723,14 +731,6 @@ atom returns[Entity value]
between a missing function and a wrong answer. */

| 'trunc(' args = function_arguments ')' { $value = NotImplementedFunction("trunc", "rounding functions"); }
/* Names of functions to come, reserved so that each is refused rather than read as a
product until it is implemented: zeta(s) was zeta * s. Only names no one writes as a
variable before a bracket; beta, norm, grad, div, curl and the other short ones are left
as products until each lands. The names and their conventions are in
https://github.com/asc-community/AngouriMath/issues/2182 */
| 'zeta(' args = function_arguments ')' { $value = NotImplementedFunction("zeta", "Riemann or Hurwitz zeta function yet"); }
| 'riemannzeta(' args = function_arguments ')' { $value = NotImplementedFunction("riemannzeta", "Riemann zeta function yet"); }
| 'hurwitzzeta(' args = function_arguments ')' { $value = NotImplementedFunction("hurwitzzeta", "Hurwitz zeta function yet"); }
/* Names that will not be functions, refused with the spelling to use: what they mean is
ambiguous between sources, or is already written exactly another way. */
| 'heaviside(' args = function_arguments ')' { $value = NotAFunctionHere("heaviside", "its value at 0 is 0, 1/2 or 1 by source; write iverson(x > 0), iverson(x >= 0) or (1 + sgn(x))/2"); }
Expand All @@ -743,13 +743,10 @@ atom returns[Entity value]
| 'quotient(' args = function_arguments ')' { $value = NotAFunctionHere("quotient", "write floor(a / b)"); }
/* Names another system calls a function and this library has no node for, each refused
with what can be written today: factorize(360) was factorize * 360, and φ(10) was φ * 10.
factorize, nextprime and divisors: https://github.com/asc-community/AngouriMath/issues/2449.
gradient and divergence: https://github.com/asc-community/AngouriMath/issues/2182 */
factorize, nextprime and divisors: https://github.com/asc-community/AngouriMath/issues/2449. */
| 'factorize(' args = function_arguments ')' { $value = NotAFunctionHere("factorize", "the prime factorisation of an integer is factorization(n), and in C# Factorize() factors an expression"); }
| 'nextprime(' args = function_arguments ')' { $value = NotImplementedFunction("nextprime", "nextprime yet; prime(primepi(n) + 1) is the least prime greater than n"); }
| 'divisors(' args = function_arguments ')' { $value = NotImplementedFunction("divisors", "set of divisors yet; divisorsigma(0, n) counts them and divisorsigma(1, n) is their sum"); }
| 'gradient(' args = function_arguments ')' { $value = NotImplementedFunction("gradient", "gradient yet; jacobian([f], [x, y]) is the row of partial derivatives of f"); }
| 'divergence(' args = function_arguments ')' { $value = NotImplementedFunction("divergence", "divergence yet; trace(jacobian(F, [x, y])) is the divergence of F"); }
| 'φ(' args = function_arguments ')' { $value = NotAFunctionHere("φ", "Euler's totient is written phi(n)"); }
| 'ϕ(' args = function_arguments ')' { $value = NotAFunctionHere("ϕ", "Euler's totient is written phi(n)"); }
| 'domain(' args = function_arguments ')'
Expand Down
14 changes: 8 additions & 6 deletions Sources/AngouriMath/Core/Antlr/AngouriMath.interp

Large diffs are not rendered by default.

116 changes: 59 additions & 57 deletions Sources/AngouriMath/Core/Antlr/AngouriMath.tokens
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,17 @@ T__235=236
T__236=237
T__237=238
T__238=239
NEWLINE=240
NUMBER=241
SPECIALSET=242
BOOLEAN=243
NAN=244
UNICODE_SYNONYM=245
SUPERSCRIPT=246
VARIABLE=247
COMMENT=248
WS=249
T__239=240
NEWLINE=241
NUMBER=242
SPECIALSET=243
BOOLEAN=244
NAN=245
UNICODE_SYNONYM=246
SUPERSCRIPT=247
VARIABLE=248
COMMENT=249
WS=250
'['=1
']'=2
'!'=3
Expand Down Expand Up @@ -440,50 +441,51 @@ WS=249
'productlog('=191
'polygamma('=192
'digamma('=193
'Si('=194
'Ci('=195
'Shi('=196
'Chi('=197
'det('=198
'transpose('=199
'trace('=200
'dot('=201
'cross('=202
'laplacian('=203
'forwarddifference('=204
'jacobian('=205
'hessian('=206
'resultant('=207
'conjugate('=208
'conj('=209
'arg('=210
'Re('=211
'Im('=212
're('=213
'real('=214
'im('=215
'imag('=216
'trunc('=217
'zeta('=218
'riemannzeta('=219
'hurwitzzeta('=220
'heaviside('=221
'unitstep('=222
'isprime('=223
'pochhammer('=224
'doublefactorial('=225
'factorial2('=226
'fractionalpart('=227
'quotient('=228
'factorize('=229
'nextprime('=230
'divisors('=231
'gradient('=232
'divergence('=233
'φ('=234
'ϕ('=235
'domain('=236
'piecewise('=237
'apply('=238
'lambda('=239
'NaN'=244
'zeta('=194
'riemannzeta('=195
'hurwitzzeta('=196
'Si('=197
'Ci('=198
'Shi('=199
'Chi('=200
'det('=201
'transpose('=202
'trace('=203
'dot('=204
'cross('=205
'laplacian('=206
'forwarddifference('=207
'jacobian('=208
'hessian('=209
'gradient('=210
'divergence('=211
'curl('=212
'resultant('=213
'conjugate('=214
'conj('=215
'arg('=216
'Re('=217
'Im('=218
're('=219
'real('=220
'im('=221
'imag('=222
'trunc('=223
'heaviside('=224
'unitstep('=225
'isprime('=226
'pochhammer('=227
'doublefactorial('=228
'factorial2('=229
'fractionalpart('=230
'quotient('=231
'factorize('=232
'nextprime('=233
'divisors('=234
'φ('=235
'ϕ('=236
'domain('=237
'piecewise('=238
'apply('=239
'lambda('=240
'NaN'=245
Loading
Loading