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
41 changes: 41 additions & 0 deletions BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,47 @@ even numbers and the negative whole numbers, and at a whole `s >= 2` with a whol
| `"hurwitzzeta(s, a)".ToEntity()` | throws `UnrecognizedFunctionParseException` | `zeta(s, a)` |
| `"zeta (s)".ToEntity()` | `zeta * s` | unchanged |

### The beta function

**Not silent: what was a parse error now parses.** `beta(a, b)` threw `UnhandledParseException`. It is now
`Entity.Betaf`, built by `MathS.Beta`: `Gamma(a) Gamma(b)/Gamma(a + b)` ([DLMF 5.12.1](https://dlmf.nist.gov/5.12.E1)),
exact at a whole argument, `(n - 1)!/(b (b + 1) ... (b + n - 1))`, and at two half-whole ones, a rational times `pi`,
and evaluated to the working precision elsewhere, real or complex. It has no value where `a` or `b` is `0, -1, -2, ...`,
unless `a + b` is one too, where the other argument is whole and the value is that of the rational function, as
mpmath's `beta` takes it. With one argument, `beta(x)` is still the product `beta * x`, and `beta` alone and
`beta (x)` with a space are as they were ([#2182](https://github.com/asc-community/AngouriMath/issues/2182)).

| Input | Was (2.7.0) | Now |
|---|---|---|
| `"beta(2, 3)".ToEntity().Simplify()` | throws `UnhandledParseException` | `1/12` |
| `"beta(1/2, 1/2)".ToEntity().Simplify()` | throws `UnhandledParseException` | `pi` |
| `"beta(2.5, 1.3)".ToEntity().Evaled` | throws `UnhandledParseException` | `0.2541541901764604945390…` |
| `"beta(1, b)".ToEntity().Simplify()` | throws `UnhandledParseException` | `1 / b` |
| `"beta(2, -3)".ToEntity().Simplify()` | throws `UnhandledParseException` | `1/6` |
| `"beta(0, 1/2)".ToEntity().Simplify()` | throws `UnhandledParseException` | `NaN`, a pole |
| `"beta(x)".ToEntity()` | `beta * x` | unchanged |

### The p-norm of a vector

**Not silent: what was a parse error now parses, or is refused saying why.** `norm(v, p)` threw
`UnhandledParseException`. It is now `Entity.Normf`, built by `MathS.Norm`: `(|v_1|^p + ... + |v_n|^p)^(1/p)` for a
real `p >= 1`, the largest modulus at `p = +oo`, taken when simplified of a vector written out, a column or a row,
whose entries may be complex. `norm(v, 2)` is `abs(v)`, the same expression. A `p` that is a number below `1`, where
there is no norm, and a matrix written out that is not a vector throw `InvalidArgumentParseException`; a symbolic `p`
stays as written, with the condition `p >= 1`. With one argument, `norm(v)` is still the product `norm * v`
([#2182](https://github.com/asc-community/AngouriMath/issues/2182)).

| Input | Was (2.7.0) | Now |
|---|---|---|
| `"norm([3, 4], 1)".ToEntity().Simplify()` | throws `UnhandledParseException` | `7` |
| `"norm([3, 4], 3)".ToEntity().Simplify()` | throws `UnhandledParseException` | `91 ^ (1/3)` |
| `"norm([3, 4], +oo)".ToEntity().Simplify()` | throws `UnhandledParseException` | `4` |
| `"norm([3, 4], 2)".ToEntity().Simplify()` | throws `UnhandledParseException` | `5`, as `abs([3, 4])` |
| `"norm([x, y], p)".ToEntity().Simplify()` | throws `UnhandledParseException` | `norm([x, y], p)` |
| `"norm(v, 1/2)".ToEntity()` | throws `UnhandledParseException` | throws `InvalidArgumentParseException`: `p >= 1` |
| `"norm([[1, 2], [3, 4]], 2)".ToEntity()` | throws `UnhandledParseException` | throws `InvalidArgumentParseException`: not a vector |
| `"norm([3, 4])".ToEntity().Simplify()` | `[3 * norm, 4 * norm]` | 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)`,
Expand Down
9 changes: 9 additions & 0 deletions Sources/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@ file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed
[AngouriMath/Core/Entity/Continuous/Entity.Continuous.{Floors,Rounding}.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/Entity.Continuous.{Beta,Norm}.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/Beta.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

[Utils/Utils/CiTiming.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

Expand Down Expand Up @@ -327,6 +333,9 @@ file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed
[Tests/UnitTests/Convenience/BinomialTest.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/{Beta,Norm}Test.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/MaxMinOffTheRealLineTest.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

Expand Down
21 changes: 21 additions & 0 deletions Sources/AngouriMath/Convenience/MathS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1783,6 +1783,27 @@ public static Entity VectorLength(Matrix v)
/// <remarks>https://github.com/asc-community/AngouriMath/issues/2182</remarks>
public static Entity Zeta(Entity s, Entity a) => new Zetaf(s, a);

/// <summary>The beta function, <c>B(a, b) = Gamma(a) Gamma(b)/Gamma(a + b)</c> (DLMF 5.12.1)</summary>
/// <param name="a">The first argument, any complex number but <c>0, -1, -2, ...</c></param>
/// <param name="b">The second argument, any complex number but <c>0, -1, -2, ...</c></param>
/// <returns>The <see cref="Entity.Betaf"/> node</returns>
/// <remarks>
/// Where one argument is <c>0, -1, -2, ...</c> and so is <c>a + b</c>, the other is a whole number <c>n</c>
/// and the value is that of <c>(n - 1)!/(b (b + 1) ... (b + n - 1))</c>, so <c>B(1, b) = 1/b</c> wherever
/// either side has a value. https://github.com/asc-community/AngouriMath/issues/2182
/// </remarks>
public static Entity Beta(Entity a, Entity b) => new Betaf(a, b);

/// <summary>
/// The p-norm of a vector, <c>(|v_1|^p + ... + |v_n|^p)^(1/p)</c> for <c>p &gt;= 1</c>, the largest modulus
/// at <c>p = +oo</c>; the 2-norm is <see cref="Abs(Entity)"/> of the vector
/// </summary>
/// <param name="v">The vector, a column or a row</param>
/// <param name="p">The order, a real number at least <c>1</c>, or <c>+oo</c></param>
/// <returns>The <see cref="Entity.Normf"/> node</returns>
/// <remarks>https://github.com/asc-community/AngouriMath/issues/2182</remarks>
public static Entity Norm(Entity v, Entity p) => new Normf(v, p);

/// <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
7 changes: 7 additions & 0 deletions Sources/AngouriMath/Core/Antlr/AngouriMath.g
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,10 @@ atom returns[Entity value]
| '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 beta function B(a, b), named by its symbol as gamma is. A call with one argument is not
this rule's: Parser.cs hands it back as the name and a bracket, so beta(x) is still beta * x.
https://github.com/asc-community/AngouriMath/issues/2182 */
| 'beta(' args = function_arguments ')' { Assert("beta", 2, $args.list.Count); $value = MathS.Beta($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 @@ -707,6 +711,9 @@ atom returns[Entity value]
| '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); }
/* The p-norm of a vector. With one argument it is still the product Parser.cs leaves it as,
norm * v. https://github.com/asc-community/AngouriMath/issues/2182 */
| 'norm(' args = function_arguments ')' { $value = ParsingHelpers.Norm($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 Down
6 changes: 5 additions & 1 deletion Sources/AngouriMath/Core/Antlr/AngouriMath.interp

Large diffs are not rendered by default.

116 changes: 60 additions & 56 deletions Sources/AngouriMath/Core/Antlr/AngouriMath.tokens
Original file line number Diff line number Diff line change
Expand Up @@ -239,16 +239,18 @@ T__237=238
T__238=239
T__239=240
T__240=241
NEWLINE=242
NUMBER=243
SPECIALSET=244
BOOLEAN=245
NAN=246
UNICODE_SYNONYM=247
SUPERSCRIPT=248
VARIABLE=249
COMMENT=250
WS=251
T__241=242
T__242=243
NEWLINE=244
NUMBER=245
SPECIALSET=246
BOOLEAN=247
NAN=248
UNICODE_SYNONYM=249
SUPERSCRIPT=250
VARIABLE=251
COMMENT=252
WS=253
'['=1
']'=2
'!'=3
Expand Down Expand Up @@ -445,49 +447,51 @@ WS=251
'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
'partialderivative('=241
'NaN'=246
'beta('=197
'Si('=198
'Ci('=199
'Shi('=200
'Chi('=201
'det('=202
'transpose('=203
'trace('=204
'dot('=205
'cross('=206
'laplacian('=207
'forwarddifference('=208
'jacobian('=209
'hessian('=210
'gradient('=211
'divergence('=212
'curl('=213
'norm('=214
'resultant('=215
'conjugate('=216
'conj('=217
'arg('=218
'Re('=219
'Im('=220
're('=221
'real('=222
'im('=223
'imag('=224
'trunc('=225
'heaviside('=226
'unitstep('=227
'isprime('=228
'pochhammer('=229
'doublefactorial('=230
'factorial2('=231
'fractionalpart('=232
'quotient('=233
'factorize('=234
'nextprime('=235
'divisors('=236
'φ('=237
'ϕ('=238
'domain('=239
'piecewise('=240
'apply('=241
'lambda('=242
'partialderivative('=243
'NaN'=248
Loading
Loading