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
22 changes: 19 additions & 3 deletions BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,9 @@ were read as products or refused.** A name the parser does not know, followed by
`Entity.Conjugatef`, carried through sums, differences, products, quotients and whole powers and not through a root or
a logarithm; `arg(z)` is `Entity.Argf`, in `(-pi, pi]`, with no value at `0`
([#2136](https://github.com/asc-community/AngouriMath/issues/2136),
[#2145](https://github.com/asc-community/AngouriMath/issues/2145)). `re` and `im` are still read as products.
[#2145](https://github.com/asc-community/AngouriMath/issues/2145)). The conjugate is drawn as `\overline{z}`, and as
the whole exponent of a power in brackets, `x^{\left(\overline{n}\right)}`, since `x^{\overline{n}}` is the rising
factorial ([#2182](https://github.com/asc-community/AngouriMath/issues/2182)).

| Input | Was (2.6.0) | Now |
|---|---|---|
Expand Down Expand Up @@ -452,8 +454,8 @@ 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`, `catalannumber`, `multinomial`, `fallingfactorial`, `factorialpower`,
`risingfactorial` and `forwarddifference`. Names that will not be functions,
is: `zeta`, `riemannzeta`, `hurwitzzeta`, `lambertw`, `productlog`, `harmonicnumber`, `catalannumber`, `multinomial` 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`.
Each name without a bracket is still a variable, and short names such as `beta` and `norm` are still read as products
Expand Down Expand Up @@ -501,6 +503,20 @@ 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 falling and the rising factorial

**Not silent: `fallingfactorial(x, n)`, also `factorialpower(x, n)`, and `risingfactorial(x, n)` are functions, where
they were a parse error.** For a whole `n >= 0` they are `x (x - 1) ... (x - n + 1)` and `x (x + 1) ... (x + n - 1)`. For a
negative whole `n` they are reciprocals of products, and for any other `n` they are the gamma ratios `Γ(x + 1)/Γ(x - n + 1)`
and `Γ(x + n)/Γ(x)`. LaTeX draws them with Knuth's bars, `x^{\underline{n}}` and `x^{\overline{n}}`
([#2182](https://github.com/asc-community/AngouriMath/issues/2182)).

| Input | Was (2.6.0) | Now |
|---|---|---|
| `"fallingfactorial(5, 2)".ToEntity().Simplify()` | throws `UnhandledParseException` | `20` |
| `"risingfactorial(3, 2)".ToEntity().Simplify()` | throws `UnhandledParseException` | `12` |
| `"fallingfactorial(5, 1/2)".ToEntity().EvalNumerical()` | throws `UnhandledParseException` | `2.29257989505120015013822761269...` |

### A subscript may have a subscript

**Not silent: what was a parse error is a name.** A name took at most one `_`, so `x_1_2` and `X_a_beta` were lexer
Expand Down
3 changes: 3 additions & 0 deletions Sources/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -811,3 +811,6 @@ file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed

[Tests/UnitTests/Convenience/VectorCalculusTest.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/FactorialPowerTest.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 falling factorial <c>x (x - 1) ... (x - n + 1)</c>, <c>x^{\underline{n}}</c></summary>
/// <remarks>https://github.com/asc-community/AngouriMath/issues/2182</remarks>
public static Entity FallingFactorial(Entity x, Entity n) => new FallingFactorialf(x, n);

/// <summary>The rising factorial <c>x (x + 1) ... (x + n - 1)</c>, <c>x^{\overline{n}}</c></summary>
/// <remarks>https://github.com/asc-community/AngouriMath/issues/2182</remarks>
public static Entity RisingFactorial(Entity x, Entity n) => new RisingFactorialf(x, n);

/// <summary>The Iverson bracket <c>iverson(P)</c>: <c>1</c> where the statement holds, <c>0</c> where it does not</summary>
/// <param name="statement">The statement</param>
/// <returns>The <see cref="Entity.Iversonf"/> node</returns>
Expand Down
6 changes: 3 additions & 3 deletions Sources/AngouriMath/Core/Antlr/AngouriMath.g
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,9 @@ atom returns[Entity value]
| 'gcd(' args = function_arguments ')' { AssertAtLeast("gcd", 1, $args.list.Count); $value = $args.list.Aggregate((a, b) => MathS.Gcd(a, b)); }
| 'lcm(' args = function_arguments ')' { AssertAtLeast("lcm", 1, $args.list.Count); $value = $args.list.Aggregate((a, b) => MathS.Lcm(a, b)); }
| 'binomial(' args = function_arguments ')' { Assert("binomial", 2, $args.list.Count); $value = MathS.Binomial($args.list[0], $args.list[1]); }
| '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]); }
/* The Iverson bracket, 1 where a statement holds and 0 where it does not: a count written as
a sum. https://github.com/asc-community/AngouriMath/issues/1478 */
| 'iverson(' args = function_arguments ')' { Assert("iverson", 1, $args.list.Count); $value = MathS.Iverson($args.list[0]); }
Expand Down Expand Up @@ -693,9 +696,6 @@ atom returns[Entity value]
| 'harmonicnumber(' args = function_arguments ')' { $value = NotImplementedFunction("harmonicnumber", "harmonic numbers yet"); }
| 'catalannumber(' args = function_arguments ')' { $value = NotImplementedFunction("catalannumber", "Catalan numbers yet"); }
| 'multinomial(' args = function_arguments ')' { $value = NotImplementedFunction("multinomial", "multinomial coefficients yet"); }
| 'fallingfactorial(' args = function_arguments ')' { $value = NotImplementedFunction("fallingfactorial", "falling factorial yet"); }
| 'factorialpower(' args = function_arguments ')' { $value = NotImplementedFunction("factorialpower", "falling factorial yet"); }
| 'risingfactorial(' args = function_arguments ')' { $value = NotImplementedFunction("risingfactorial", "rising factorial 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
6 changes: 3 additions & 3 deletions Sources/AngouriMath/Core/Antlr/AngouriMath.interp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ null
'gcd('
'lcm('
'binomial('
'fallingfactorial('
'factorialpower('
'risingfactorial('
'iverson('
'aleph('
'erf('
Expand Down Expand Up @@ -213,9 +216,6 @@ null
'harmonicnumber('
'catalannumber('
'multinomial('
'fallingfactorial('
'factorialpower('
'risingfactorial('
'forwarddifference('
'heaviside('
'unitstep('
Expand Down
84 changes: 42 additions & 42 deletions Sources/AngouriMath/Core/Antlr/AngouriMath.tokens
Original file line number Diff line number Diff line change
Expand Up @@ -409,48 +409,48 @@ WS=237
'gcd('=172
'lcm('=173
'binomial('=174
'iverson('=175
'aleph('=176
'erf('=177
'erfc('=178
'erfi('=179
'Ei('=180
'li('=181
'polygamma('=182
'digamma('=183
'Si('=184
'Ci('=185
'Shi('=186
'Chi('=187
'det('=188
'transpose('=189
'dot('=190
'cross('=191
'laplacian('=192
'jacobian('=193
'hessian('=194
'resultant('=195
'conjugate('=196
'conj('=197
'arg('=198
'Re('=199
'Im('=200
're('=201
'real('=202
'im('=203
'imag('=204
'trunc('=205
'zeta('=206
'riemannzeta('=207
'hurwitzzeta('=208
'lambertw('=209
'productlog('=210
'harmonicnumber('=211
'catalannumber('=212
'multinomial('=213
'fallingfactorial('=214
'factorialpower('=215
'risingfactorial('=216
'fallingfactorial('=175
'factorialpower('=176
'risingfactorial('=177
'iverson('=178
'aleph('=179
'erf('=180
'erfc('=181
'erfi('=182
'Ei('=183
'li('=184
'polygamma('=185
'digamma('=186
'Si('=187
'Ci('=188
'Shi('=189
'Chi('=190
'det('=191
'transpose('=192
'dot('=193
'cross('=194
'laplacian('=195
'jacobian('=196
'hessian('=197
'resultant('=198
'conjugate('=199
'conj('=200
'arg('=201
'Re('=202
'Im('=203
're('=204
'real('=205
'im('=206
'imag('=207
'trunc('=208
'zeta('=209
'riemannzeta('=210
'hurwitzzeta('=211
'lambertw('=212
'productlog('=213
'harmonicnumber('=214
'catalannumber('=215
'multinomial('=216
'forwarddifference('=217
'heaviside('=218
'unitstep('=219
Expand Down
Loading
Loading