Skip to content
Merged
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
17 changes: 15 additions & 2 deletions BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ the right shape, written out or once its operations are carried out, throws `Inv
**Not silent: these names followed by a bracket now throw `UnrecognizedFunctionParseException` where they were read as
products.** An unknown name followed by a bracket is a product, so `zeta(2)` was `zeta * 2` and simplified to
`2 * zeta`. The long names of the functions the library is to have are refused until each is implemented, as `trunc`
is: `zeta`, `riemannzeta`, `hurwitzzeta`, `lambertw`, `productlog`, `harmonicnumber` and
is: `zeta`, `riemannzeta`, `hurwitzzeta`, `lambertw`, `productlog` and
`forwarddifference`. Names that will not be functions,
because what they mean differs between sources or is already written exactly, are refused with the spelling to use:
`heaviside`, `unitstep`, `isprime`, `pochhammer`, `doublefactorial`, `factorial2`, `fractionalpart` and `quotient`.
Expand All @@ -496,7 +496,7 @@ Each name without a bracket is still a variable, and short names such as `beta`
| `"zeta(2)".ToEntity().Simplify()` | `2 * zeta` | throws `UnrecognizedFunctionParseException` |
| `"isprime(7)".ToEntity()` | `isprime * 7` | throws `UnrecognizedFunctionParseException`: write `n in PP` |
| `"heaviside(x)".ToEntity()` | `heaviside * x` | throws `UnrecognizedFunctionParseException`: write `iverson(x > 0)`, `iverson(x >= 0)` or `(1 + sgn(x))/2` |
| `"harmonicnumber(n, m)".ToEntity()` | throws `UnhandledParseException` | throws `UnrecognizedFunctionParseException` |
| `"hurwitzzeta(s, a)".ToEntity()` | throws `UnhandledParseException` | throws `UnrecognizedFunctionParseException` |

### The Möbius, divisor and prime-counting functions

Expand Down Expand Up @@ -532,6 +532,19 @@ is ([#2182](https://github.com/asc-community/AngouriMath/issues/2182)).
| `"hessian(x^3 y^2, [x, y])".ToEntity().Simplify()` | throws `UnhandledParseException` | `[[6 * x * y ^ 2, 6 * x ^ 2 * y], [6 * x ^ 2 * y, 2 * x ^ 3]]` |
| `"jacobian(x y, {x, y})".ToEntity()` | throws `UnhandledParseException` | throws `InvalidArgumentParseException`: a set has no order for the columns |

### The harmonic numbers

**Not silent: `harmonicnumber(n)` and `harmonicnumber(n, m)` are the harmonic numbers, where the one was a product and the
other a parse error.** They are `1 + 1/2^m + ... + 1/n^m` for a whole `n >= 0`, exact for a rational `m`, and
`ζ(m) - ζ(m, n + 1)` elsewhere, as Mathematica's `HarmonicNumber` is: `ψ(n + 1) - ψ(1)` for `m = 1`, evaluated numerically
through `digamma` and `polygamma` for a whole `m >= 1`. A negative integer `n` has no value but for a whole `m <= 0`
([#2182](https://github.com/asc-community/AngouriMath/issues/2182)).

| Input | Was (2.6.0) | Now |
|---|---|---|
| `"harmonicnumber(4)".ToEntity().Simplify()` | `4 * harmonicnumber` | `25/12` |
| `"harmonicnumber(n, 2)".ToEntity()` | throws `UnhandledParseException` | `harmonicnumber(n, 2)` |

### The Catalan numbers

**Not silent: `catalannumber(n)` is the Catalan number, where it was a product.** It is `binomial(2n, n) / (n + 1)` for
Expand Down
3 changes: 3 additions & 0 deletions Sources/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -829,3 +829,6 @@ file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed

[Tests/UnitTests/Convenience/CatalanNumberTest.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/HarmonicNumberTest.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
8 changes: 8 additions & 0 deletions Sources/AngouriMath/Convenience/MathS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,14 @@ public static Entity VectorLength(Matrix v)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Entity Binomial(Entity n, Entity k) => new Binomialf(n, k);

/// <summary>The harmonic number <c>H_n = 1 + 1/2 + ... + 1/n</c></summary>
/// <remarks>https://github.com/asc-community/AngouriMath/issues/2182</remarks>
public static Entity HarmonicNumber(Entity n) => new HarmonicNumberf(n, Integer.One);

/// <summary>The generalized harmonic number <c>H_n^(m) = 1 + 1/2^m + ... + 1/n^m</c></summary>
/// <remarks>https://github.com/asc-community/AngouriMath/issues/2182</remarks>
public static Entity HarmonicNumber(Entity n, Entity m) => new HarmonicNumberf(n, m);

/// <summary>The Catalan number <c>C_n = binomial(2n, n) / (n + 1)</c></summary>
/// <remarks>https://github.com/asc-community/AngouriMath/issues/2182</remarks>
public static Entity CatalanNumber(Entity n) => new CatalanNumberf(n);
Expand Down
2 changes: 1 addition & 1 deletion Sources/AngouriMath/Core/Antlr/AngouriMath.g
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ atom returns[Entity value]
| 'binomial(' args = function_arguments ')' { Assert("binomial", 2, $args.list.Count); $value = MathS.Binomial($args.list[0], $args.list[1]); }
| 'multinomial(' args = function_arguments ')' { $value = ParsingHelpers.Multinomial($args.list); }
| 'catalannumber(' args = function_arguments ')' { Assert("catalannumber", 1, $args.list.Count); $value = MathS.CatalanNumber($args.list[0]); }
| 'harmonicnumber(' args = function_arguments ')' { if (Assert("harmonicnumber", (2, 1), $args.list.Count)) $value = MathS.HarmonicNumber($args.list[0], $args.list[1]); else $value = MathS.HarmonicNumber($args.list[0]); }
| 'fallingfactorial(' args = function_arguments ')' { Assert("fallingfactorial", 2, $args.list.Count); $value = MathS.FallingFactorial($args.list[0], $args.list[1]); }
| 'factorialpower(' args = function_arguments ')' { Assert("factorialpower", 2, $args.list.Count); $value = MathS.FallingFactorial($args.list[0], $args.list[1]); }
| 'risingfactorial(' args = function_arguments ')' { Assert("risingfactorial", 2, $args.list.Count); $value = MathS.RisingFactorial($args.list[0], $args.list[1]); }
Expand Down Expand Up @@ -695,7 +696,6 @@ atom returns[Entity value]
| 'hurwitzzeta(' args = function_arguments ')' { $value = NotImplementedFunction("hurwitzzeta", "Hurwitz zeta function yet"); }
| 'lambertw(' args = function_arguments ')' { $value = NotImplementedFunction("lambertw", "Lambert W function yet"); }
| 'productlog(' args = function_arguments ')' { $value = NotImplementedFunction("productlog", "Lambert W function yet"); }
| 'harmonicnumber(' args = function_arguments ')' { $value = NotImplementedFunction("harmonicnumber", "harmonic numbers yet"); }
| 'forwarddifference(' args = function_arguments ')' { $value = NotImplementedFunction("forwarddifference", "forward difference 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. */
Expand Down
2 changes: 1 addition & 1 deletion Sources/AngouriMath/Core/Antlr/AngouriMath.interp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ null
'binomial('
'multinomial('
'catalannumber('
'harmonicnumber('
'fallingfactorial('
'factorialpower('
'risingfactorial('
Expand Down Expand Up @@ -215,7 +216,6 @@ null
'hurwitzzeta('
'lambertw('
'productlog('
'harmonicnumber('
'forwarddifference('
'heaviside('
'unitstep('
Expand Down
80 changes: 40 additions & 40 deletions Sources/AngouriMath/Core/Antlr/AngouriMath.tokens
Original file line number Diff line number Diff line change
Expand Up @@ -411,46 +411,46 @@ WS=237
'binomial('=174
'multinomial('=175
'catalannumber('=176
'fallingfactorial('=177
'factorialpower('=178
'risingfactorial('=179
'iverson('=180
'aleph('=181
'erf('=182
'erfc('=183
'erfi('=184
'Ei('=185
'li('=186
'polygamma('=187
'digamma('=188
'Si('=189
'Ci('=190
'Shi('=191
'Chi('=192
'det('=193
'transpose('=194
'dot('=195
'cross('=196
'laplacian('=197
'jacobian('=198
'hessian('=199
'resultant('=200
'conjugate('=201
'conj('=202
'arg('=203
'Re('=204
'Im('=205
're('=206
'real('=207
'im('=208
'imag('=209
'trunc('=210
'zeta('=211
'riemannzeta('=212
'hurwitzzeta('=213
'lambertw('=214
'productlog('=215
'harmonicnumber('=216
'harmonicnumber('=177
'fallingfactorial('=178
'factorialpower('=179
'risingfactorial('=180
'iverson('=181
'aleph('=182
'erf('=183
'erfc('=184
'erfi('=185
'Ei('=186
'li('=187
'polygamma('=188
'digamma('=189
'Si('=190
'Ci('=191
'Shi('=192
'Chi('=193
'det('=194
'transpose('=195
'dot('=196
'cross('=197
'laplacian('=198
'jacobian('=199
'hessian('=200
'resultant('=201
'conjugate('=202
'conj('=203
'arg('=204
'Re('=205
'Im('=206
're('=207
'real('=208
'im('=209
'imag('=210
'trunc('=211
'zeta('=212
'riemannzeta('=213
'hurwitzzeta('=214
'lambertw('=215
'productlog('=216
'forwarddifference('=217
'heaviside('=218
'unitstep('=219
Expand Down
Loading
Loading