|
| 1 | +// |
| 2 | +// Copyright (c) 2019-2026 Angouri. |
| 3 | +// AngouriMath is licensed under MIT. |
| 4 | +// Details: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md. |
| 5 | +// Website: https://am.angouri.org. |
| 6 | +// |
| 7 | + |
| 8 | +using System; |
| 9 | +using System.Threading.Tasks; |
| 10 | +using AngouriMath.Core; |
| 11 | +using AngouriMath.Extensions; |
| 12 | +using Xunit; |
| 13 | + |
| 14 | +namespace AngouriMath.Tests.Calculus |
| 15 | +{ |
| 16 | + /// <summary> |
| 17 | + /// The sign a power keeps near a point is read from its base before its slope: a positive base to a real power is |
| 18 | + /// positive. sgn((x * x)^arctan(1/2)) at 0 from the left asked for the slope of the power first, which l'Hopital's |
| 19 | + /// rule took 6.6 s over, for 1. Found by limitcheck; no issue was filed. |
| 20 | + /// </summary> |
| 21 | + [Trait("Area", "Calculus")] |
| 22 | + public sealed class APowerHasTheSignOfItsBaseTest |
| 23 | + { |
| 24 | + [Theory] |
| 25 | + [InlineData("sgn((x * x) ^ arctan(1/2))", ApproachFrom.Left, "1")] |
| 26 | + [InlineData("sgn((x * x) ^ arctan(1/2))", ApproachFrom.BothSides, "1")] |
| 27 | + [InlineData("floor((x * x) ^ pi)", ApproachFrom.Left, "0")] |
| 28 | + public void TheLimitAtZeroIsAnswered(string input, ApproachFrom side, string expected) |
| 29 | + { |
| 30 | + var limit = Task.Run(() => input.ToEntity().Limit("x", 0, side)); |
| 31 | + Assert.True(limit.Wait(TimeSpan.FromSeconds(30)), $"{input} at 0 from {side} did not finish in 30 seconds"); |
| 32 | + Assert.Equal(expected.ToEntity().Evaled, limit.Result.Evaled); |
| 33 | + } |
| 34 | + |
| 35 | + // A negative base to a power that is not whole is complex on that side, and has no sign. |
| 36 | + [Fact] |
| 37 | + public void AComplexPowerHasNoSign() |
| 38 | + => Assert.IsType<Entity.Limitf>("sgn((x * x * x) ^ pi)".ToEntity().Limit("x", 0, ApproachFrom.Left)); |
| 39 | + } |
| 40 | +} |
0 commit comments