## AngouriMath

## Settings

Here we will cover the way you can manipulate global settings of the library.

## Introduction

There are a lot of points at which we cannot trust our choice, and you might want to change the behaviour. That is why we introduced global settings. There is no need to create additional files, and those settings are static properties. The settings are, although static, thread-safe. Every setting is set for one thread only (via## Using Settings

Let us consider a particular example. When AM cannot solve an equation analytically, it would apply numerical methods to solve it, for example, that of Newton. Example:```
Entity expr = "x + sin(x) = 0";
Console.WriteLine(expr.Solve("x"));
```

Will print:
`{ 10.712... + 3.103...i, ... }`

(Major share of the result was omitted under "...")
This equation does not have a elementary roots (except for 0). We want to restrict it to solving
only analytically, and if it cannot solve it so, it should not apply Newton's method. Let us
set this setting:
```
using var _ = MathS.Settings.AllowNewton.Set(false);
Entity expr = "x + sin(x) = 0";
Console.WriteLine(expr.Solve("x"));
```

Output:
`{ }`

As it can be seen, it does not apply the Newton's method when solving, even if no analytical
solution was found.
Summing up, the syntax has two options.
The first one is more convenient:
```
using var _ = MathS.Settings.SomeSetting.Set(SomeValue);
// code
```

The second one might be useful for parts, when the setting should be reverted before the method ends:
```
using (var _ = MathS.Settings.SomeSetting.Set(SomeValue))
{
// code
}
```

## Explanation

ThisAngouri © 2019-2023 · Project's repo · Site's repo · Octicons · Transparency · 1534 pages online