镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
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
3 changes: 3 additions & 0 deletions Sources/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed
[Tests/UnitTests/Convenience/MatrixFunctionsInAnExpressionTest.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/LambertWOverTheRealsTest.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/Common/ExponentialOfALogarithmTest.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
Original file line number Diff line number Diff line change
Expand Up @@ -753,8 +753,14 @@ private static Entity Numerically(Complex n, int m)
public partial record LambertWf
{
// Every whole branch, and every z but 0 off the principal branch, where W_k(z) goes to -oo as ln z does.
// Over the reals, where a branch is real: W_0 for z >= -1/e and W_(-1) for -1/e <= z < 0, both -1 at
// -1/e; no other branch is real anywhere. The condition was the complex one under either reading, so it
// held for W_0(-1), which is -0.318 + 1.337i. https://github.com/asc-community/AngouriMath/issues/2256
private protected override Entity IntrinsicCondition =>
Branch.In(MathS.Sets.Z) & (Branch.Equalizes(Integer.Zero) | !Argument.Equalizes(Integer.Zero));
Codomain < Domain.Complex
? Branch.Equalizes(Integer.Zero) & Argument >= -1 / MathS.e
| Branch.Equalizes(Integer.Create(-1)) & Argument >= -1 / MathS.e & Argument < 0
: Branch.In(MathS.Sets.Z) & (Branch.Equalizes(Integer.Zero) | !Argument.Equalizes(Integer.Zero));

/// <inheritdoc/>
protected override Entity InnerSimplify(bool isExact) =>
Expand Down
54 changes: 54 additions & 0 deletions Sources/Tests/UnitTests/Convenience/LambertWOverTheRealsTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// Copyright (c) 2019-2026 Angouri.
// AngouriMath is licensed under MIT.
// Details: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.
// Website: https://am.angouri.org.
//

using AngouriMath;
using AngouriMath.Core;
using AngouriMath.Extensions;
using Xunit;

namespace AngouriMath.Tests.Convenience
{
/// <summary>
/// Over the reals the Lambert W function is defined where its branch is real: <c>W_0</c> for <c>z &gt;= -1/e</c> and
/// <c>W_(-1)</c> for <c>-1/e &lt;= z &lt; 0</c>. The condition was the complex one under either reading, so it held for
/// <c>W_0(-1)</c>, which is <c>-0.318 + 1.337i</c>.
/// <a href="https://github.com/asc-community/AngouriMath/issues/2256">#2256</a>
/// </summary>
[Trait("Area", "Convenience")]
public sealed class LambertWOverTheRealsTest
{
[Theory]
[InlineData("lambertw(0, x)", "-3", false)]
[InlineData("lambertw(0, x)", "-1", false)]
[InlineData("lambertw(0, x)", "-1/e", true)]
[InlineData("lambertw(0, x)", "-1/5", true)]
[InlineData("lambertw(0, x)", "0", true)]
[InlineData("lambertw(0, x)", "2", true)]
[InlineData("lambertw(-1, x)", "-1/e", true)]
[InlineData("lambertw(-1, x)", "-1/5", true)]
[InlineData("lambertw(-1, x)", "-1/2", false)]
[InlineData("lambertw(-1, x)", "0", false)]
[InlineData("lambertw(-1, x)", "1", false)]
[InlineData("lambertw(1, x)", "1", false)]
public void OverTheRealsItIsWhereItsBranchIsReal(string expression, string at, bool defined)
{
var condition = expression.ToEntity().DomainConditionIn(Domain.Real).Substitute("x", at.ToEntity()).Evaled;
Assert.Equal(defined ? Entity.Boolean.True : Entity.Boolean.False, condition);
}

/// <summary>Over the complex numbers every branch is defined but off the principal one at 0.</summary>
[Theory]
[InlineData("lambertw(0, x)", "-3", true)]
[InlineData("lambertw(-1, x)", "1", true)]
[InlineData("lambertw(-1, x)", "0", false)]
public void OverTheComplexNumbersItIsAsItWas(string expression, string at, bool defined)
{
var condition = expression.ToEntity().DomainCondition.Substitute("x", at.ToEntity()).Evaled;
Assert.Equal(defined ? Entity.Boolean.True : Entity.Boolean.False, condition);
}
}
}
Loading