Skip to content

Commit fd8fc71

Browse files
Si, Ci, Shi and Chi are functions (#1529)
The sine and cosine integrals Si(z) = sum (-1)^k z^(2k+1)/((2k+1) (2k+1)!) and Ci(z) = gamma + ln z + sum_(k>=1) (-1)^k z^(2k)/(2k (2k)!), and the hyperbolic Shi and Chi, the same sums without the alternating sign, are nodes, the next of #1501's special functions: parsed, printed in text, LaTeX and SymPy, differentiated from their definitions, exact at the infinities and at 0, and evaluated to the working precision anywhere in the complex plane. Si and Shi are entire. Ci and Chi take the cut of ln z, the negative real axis, which keeps the value from above: Ci(-x) = Ci(x) + i pi, as SymPy's, mpmath's and Mathematica's is. Each is summed as its series, carrying the digits the terms cancel away from the axis it grows along, up to |z| = (P + 5) ln 10, and past that through the exponential integral's asymptotic series, by Shi(z) = (Ei(z) - Ei(-z))/2 - i pi/2 sgn(Im z) and its companions. None of the names was refused, so each was read as a product with an undeclared variable: Si(1) simplified to the variable Si. Part of #1501. Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 54e436f commit fd8fc71

29 files changed

Lines changed: 2039 additions & 906 deletions

‎BREAKING-CHANGES.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,6 +1633,27 @@ for `m = -1`, and by parts toward it below. The Gaussian's odd negative moments
16331633
| `"1/ln(x)".Integrate("x")` | `integral(1 / ln(x), x)` | `li(x) + C` |
16341634
| `"x^m/(a + b*ln(c*x^n))".Integrate("x")` | `integral(x ^ m / (a + b * ln(c * x ^ n)), x)` | the antiderivative, with `Ei` |
16351635

1636+
### `Si`, `Ci`, `Shi` and `Chi` are functions
1637+
1638+
**Addition, and four silent misreadings fixed.** The sine and cosine integrals
1639+
`Si(z) = sum (-1)^k z^(2k + 1)/((2k + 1) (2k + 1)!)` and
1640+
`Ci(z) = gamma + ln z + sum_(k >= 1) (-1)^k z^(2k)/(2k (2k)!)`, and the hyperbolic `Shi` and `Chi`,
1641+
the same sums without the alternating sign, are nodes (`MathS.Si`, `MathS.Ci`, `MathS.Shi`,
1642+
`MathS.Chi`), the next of #1501's special functions. On the real line `Si(x)` is `int_0^x sin t/t dt`
1643+
and `Shi(x)` is `int_0^x sinh t/t dt`, both real; `Ci` and `Chi` take the cut of `ln z`, so that
1644+
`Ci(-x) = Ci(x) + i pi` for `x > 0`, as SymPy's, mpmath's and Mathematica's do. Each is
1645+
differentiated, printed in LaTeX as `\operatorname{Si}` and so on, and evaluated to the working
1646+
precision anywhere in the complex plane (`Entity.Number.Si`, `Ci`, `Shi`, `Chi`). None of the names
1647+
was refused, so each was read as a product with an undeclared variable
1648+
([#1501](https://github.com/asc-community/AngouriMath/issues/1501)).
1649+
1650+
| Input | Was (2.5.0) | Now |
1651+
|---|---|---|
1652+
| `"Si(x)"` | `Si * x` | `Si(x)` |
1653+
| `"Ci(2)".Simplify()` | `2 * Ci` | `Ci(2)`, and `0.4229808287748649…` evaluated |
1654+
| `"Chi(1)".Simplify()` | `Chi` | `Chi(1)`, and `0.8378669409802082…` evaluated |
1655+
| `"Si(x)".Differentiate("x")` | `Si` | `sin(x) / x` |
1656+
16361657
### A definite integral is the limit at a bound where its antiderivative is undefined
16371658

16381659
`integral(x * e^(-x), x, 0, +oo)` was `NaN`, this library's way of saying a value does not

‎Sources/.editorconfig‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,3 +657,12 @@ file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed
657657

658658
[Tests/UnitTests/Calculus/ExponentialIntegralIntegrationTest.cs]
659659
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
660+
661+
[AngouriMath/Core/Entity/Continuous/Number/TrigonometricIntegrals.cs]
662+
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
663+
664+
[AngouriMath/Core/Entity/Continuous/Entity.Continuous.TrigonometricIntegrals.Classes.cs]
665+
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
666+
667+
[Tests/UnitTests/Convenience/TrigonometricIntegralTest.cs]
668+
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

‎Sources/AngouriMath/Convenience/MathS.cs‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,49 @@ public static Entity VectorLength(Matrix v)
14161416
[MethodImpl(MethodImplOptions.AggressiveInlining)]
14171417
public static Entity Li(Entity a) => new Lif(a);
14181418

1419+
/// <summary>The sine integral, <c>Si(z) = int_0^z sin(t)/t dt</c></summary>
1420+
/// <param name="a">The argument, any complex number</param>
1421+
/// <returns>The <see cref="Entity.Sif"/> node</returns>
1422+
/// <remarks>
1423+
/// Entire and odd, so what <c>int sin(x)/x dx</c> is in closed form; <c>Si(+oo) = pi/2</c>.
1424+
/// https://github.com/asc-community/AngouriMath/issues/1501
1425+
/// </remarks>
1426+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
1427+
public static Entity Si(Entity a) => new Sif(a);
1428+
1429+
/// <summary>The cosine integral, <c>Ci(z) = gamma + ln z + int_0^z (cos t - 1)/t dt</c></summary>
1430+
/// <param name="a">The argument, any complex number but 0</param>
1431+
/// <returns>The <see cref="Entity.Cif"/> node</returns>
1432+
/// <remarks>
1433+
/// On <c>x > 0</c> it is <c>-int_x^oo cos(t)/t dt</c>, real, so what <c>int cos(x)/x dx</c> is in
1434+
/// closed form. Its cut is the negative real axis, as for <c>ln</c>, on which it is the value
1435+
/// from above: <c>Ci(-x) = Ci(x) + i pi</c>, as SymPy's, mpmath's and Mathematica's is.
1436+
/// https://github.com/asc-community/AngouriMath/issues/1501
1437+
/// </remarks>
1438+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
1439+
public static Entity Ci(Entity a) => new Cif(a);
1440+
1441+
/// <summary>The hyperbolic sine integral, <c>Shi(z) = int_0^z sinh(t)/t dt</c></summary>
1442+
/// <param name="a">The argument, any complex number</param>
1443+
/// <returns>The <see cref="Entity.Shif"/> node</returns>
1444+
/// <remarks>
1445+
/// Entire and odd, so what <c>int sinh(x)/x dx</c> is in closed form.
1446+
/// https://github.com/asc-community/AngouriMath/issues/1501
1447+
/// </remarks>
1448+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
1449+
public static Entity Shi(Entity a) => new Shif(a);
1450+
1451+
/// <summary>The hyperbolic cosine integral, <c>Chi(z) = gamma + ln z + int_0^z (cosh t - 1)/t dt</c></summary>
1452+
/// <param name="a">The argument, any complex number but 0</param>
1453+
/// <returns>The <see cref="Entity.Chif"/> node</returns>
1454+
/// <remarks>
1455+
/// Real on <c>x > 0</c>, so what <c>int cosh(x)/x dx</c> is in closed form; its cut is the
1456+
/// negative real axis, <c>Chi(-x) = Chi(x) + i pi</c>.
1457+
/// https://github.com/asc-community/AngouriMath/issues/1501
1458+
/// </remarks>
1459+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
1460+
public static Entity Chi(Entity a) => new Chif(a);
1461+
14191462
/// <summary>Boolean negation
14201463
/// <a href="https://en.wikipedia.org/wiki/Negation">Wikipedia</a></summary>
14211464
/// <param name="a">Argument node of which Negation function will be taken</param>

‎Sources/AngouriMath/Core/Antlr/AngouriMath.g‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,11 @@ atom returns[Entity value]
603603
/* The exponential and logarithmic integrals. https://github.com/asc-community/AngouriMath/issues/1501 */
604604
| 'Ei(' args = function_arguments ')' { Assert("Ei", 1, $args.list.Count); $value = MathS.Ei($args.list[0]); }
605605
| 'li(' args = function_arguments ')' { Assert("li", 1, $args.list.Count); $value = MathS.Li($args.list[0]); }
606+
/* The trigonometric and hyperbolic integrals. https://github.com/asc-community/AngouriMath/issues/1501 */
607+
| 'Si(' args = function_arguments ')' { Assert("Si", 1, $args.list.Count); $value = MathS.Si($args.list[0]); }
608+
| 'Ci(' args = function_arguments ')' { Assert("Ci", 1, $args.list.Count); $value = MathS.Ci($args.list[0]); }
609+
| 'Shi(' args = function_arguments ')' { Assert("Shi", 1, $args.list.Count); $value = MathS.Shi($args.list[0]); }
610+
| 'Chi(' args = function_arguments ')' { Assert("Chi", 1, $args.list.Count); $value = MathS.Chi($args.list[0]); }
606611
607612
/* Names the library does not have. Each is a function every other CAS spells this way, so
608613
a caller reaches for it, and without these rules each is silently read as a product --

‎Sources/AngouriMath/Core/Antlr/AngouriMath.interp‎

Lines changed: 9 additions & 1 deletion
Large diffs are not rendered by default.

‎Sources/AngouriMath/Core/Antlr/AngouriMath.tokens‎

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,18 @@ T__173=174
175175
T__174=175
176176
T__175=176
177177
T__176=177
178-
NEWLINE=178
179-
NUMBER=179
180-
SPECIALSET=180
181-
BOOLEAN=181
182-
NAN=182
183-
VARIABLE=183
184-
COMMENT=184
185-
WS=185
178+
T__177=178
179+
T__178=179
180+
T__179=180
181+
T__180=181
182+
NEWLINE=182
183+
NUMBER=183
184+
SPECIALSET=184
185+
BOOLEAN=185
186+
NAN=186
187+
VARIABLE=187
188+
COMMENT=188
189+
WS=189
186190
'!'=1
187191
'^'=2
188192
'-'=3
@@ -354,10 +358,14 @@ WS=185
354358
'erfi('=169
355359
'Ei('=170
356360
'li('=171
357-
'trunc('=172
358-
'conjugate('=173
359-
'domain('=174
360-
'piecewise('=175
361-
'apply('=176
362-
'lambda('=177
363-
'NaN'=182
361+
'Si('=172
362+
'Ci('=173
363+
'Shi('=174
364+
'Chi('=175
365+
'trunc('=176
366+
'conjugate('=177
367+
'domain('=178
368+
'piecewise('=179
369+
'apply('=180
370+
'lambda('=181
371+
'NaN'=186

0 commit comments

Comments
 (0)