Skip to content

Commit

Permalink
Expand should be less limited (#372)
Browse files Browse the repository at this point in the history
1. Term count is now 2000 (instead of 50)
2. No power limitation in the expansion algorithm (it was 30 before)
3. Readme update
  • Loading branch information
WhiteBlackGoose committed Apr 10, 2021
1 parent a8609ae commit 53b1a56
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 22 deletions.
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,7 @@
<p align="center">
<i>New open-source cross-platform symbolic algebra library for </i><b>C# · F# · Jupyter · C++ (WIP)</b>
<br>
<a href="https://www.nuget.org/packages/AngouriMath" title="Go to NuGet"><b>Download</b></a>
<b>(</b>
<a href="https://www.nuget.org/packages/AngouriMath" title="Go to NuGet"><b>C#</b></a>
,
<a href="https://www.nuget.org/packages/AngouriMath.FSharp" title="Go to NuGet to get an F# version"><b>F#</b></a>
,
<a href="https://www.nuget.org/packages/AngouriMath.Interactive" title="Go to NuGet to get a Jupyter version"><b>Jupyter</b></a>
,
C++ (WIP)
<b>)</b>
<a href="https://am.angouri.org/quickstart/"><b>Get started</b></a>
<b>·</b>
<a href="#exam"><b>Examples</b></a>
<b>·</b>
Expand All @@ -34,7 +25,7 @@
<a href="https://discord.gg/YWJEX7a"><img alt="Discord" src="https://img.shields.io/discord/642350046213439489?color=darkgreen&label=Join+our+chat!&logo=discord&style=flat-square&labelColor=474"></a>
</p>

<details><summary><strong>Status</strong></summary>
<details><summary><strong>Status board</strong></summary>


![Solution Build](https://github.com/asc-community/AngouriMath/actions/workflows/EverythingBuild.yml/badge.svg)
Expand Down Expand Up @@ -434,6 +425,12 @@ catch (OperationCanceledException)

</details>

If you want, you can add a badge to your repo:
```
[![Powered by AngouriMath](https://img.shields.io/badge/Powered%20by-AngouriMath-purple?style=flat-square&labelColor=646)](https://am.angouri.org)
```
[![Powered by AngouriMath](https://img.shields.io/badge/Powered%20by-AngouriMath-purple?style=flat-square&labelColor=646)](https://am.angouri.org)

## <a name="contrib"></a>Contribution

We appreciate and welcome any contributors to AngouriMath. Current tasks can be tracked
Expand Down
2 changes: 1 addition & 1 deletion Sources/AngouriMath/Convenience/MathS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ public sealed record NewtonSetting
/// </item>
/// </list>
/// </summary>
public static Setting<long> MaxExpansionTermCount => maxExpansionTermCount ??= 50;
public static Setting<long> MaxExpansionTermCount => maxExpansionTermCount ??= 2_000;
[ThreadStatic] private static Setting<long>? maxExpansionTermCount;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ internal static Set Solve(Entity equation, Variable x)
{
using var _ = MathS.Settings.PrecisionErrorZeroRange.Set(1e-12m);
using var __ = MathS.Settings.FloatToRationalIterCount.Set(0);
using var ___ = MathS.Settings.MaxExpansionTermCount.Set(50);
var solutions = AnalyticalEquationSolver.Solve(equation, x);

static Entity simplifier(Entity entity) => entity.InnerSimplified;
Expand Down
3 changes: 1 addition & 2 deletions Sources/AngouriMath/Functions/TreeAnalyzer/Expansion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ static IEnumerable<List<EInteger>> Combinations(EInteger min, EInteger max, EInt
new List<Entity> { new Powf(baseDividend, power) / new Powf(baseDivisor, power) },
_ => new List<Entity> { expr }
};
if (power > 20 && linBaseChildren.Count > 1 ||
EstimateTermCount(linBaseChildren.Count, power) >
if (EstimateTermCount(linBaseChildren.Count, power) >
EInteger.FromInt64(MathS.Settings.MaxExpansionTermCount))
return null;
foreach (var powerListForTerm in CombinateSums(linBaseChildren.Count, power))
Expand Down
10 changes: 4 additions & 6 deletions Sources/Samples/Samples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@


// Console.WriteLine("[ [ 1, 2 ] ; [ 3, 4 ] ]".ToEntity());
// var piecewise = (Piecewise)"piecewise(x provided a, y + x provided b, 3)";
// var var = Var("d");
// Console.WriteLine(piecewise.Integrate(var));

Console.WriteLine("a and b".Limit("x", "+oo"));

Matrix m = "[[3 - lambda, -1, 0, -2, 0], [-3, -4 - lambda, -2, 1, 3], [0, -7, 1 - lambda, -5, 2], [3, 4, 1, 1 - lambda, -2], [-6, -19, -5, -3, 10 - lambda]]";
Console.WriteLine(m.Determinant.Simplify());
// using var _ = MathS.Settings.MaxExpansionTermCount.Set(50);
// Console.WriteLine("(a + b)100".Expand());
4 changes: 2 additions & 2 deletions Sources/Tests/DotnetBenchmark/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public class Program
{
public static void Main(string[] _)
{
// BenchmarkRunner.Run<CommonFunctionsInterVersion>();
BenchmarkRunner.Run<BenchLinqCompilation>();
BenchmarkRunner.Run<CommonFunctionsInterVersion>();
// BenchmarkRunner.Run<BenchLinqCompilation>();
Console.ReadLine(); Console.ReadLine(); Console.ReadLine();
}
}
Expand Down

0 comments on commit 53b1a56

Please sign in to comment.