[Open source, .NET, C#, Математика, F#] AngouriMath 1.3 update
Автор
Сообщение
news_bot ®
Стаж: 6 лет 9 месяцев
Сообщений: 27286
What is it about?AngouriMath is a free open-source symbolic algebra library, written in and for .NET, that I've been working since the end of 2019. The previous major release happened on the second of March, I made an article about it too.Now, let me tell what we, together with contributors, did within these four months!
AngouriMath is made for C#, F#, Interactive, and to an extent, C++, so let me draw a distinction, what package affects what environment:C#F#InteractiveC++AngouriMath✓ ✓✓AngouriMath.FSharp✓✓AngouriMath.Interactive✓AngouriMath.CPP✓MatricesThis is the main change in terms of breaking API and behaviour. Now, instead of tensor, there's matrix, which is Entity.Matrix. There is also vector, but it doesn't have its own type. Instead, it's a single-column matrix. So for matrices there's only one type.The syntax for parsing is
Entity a = "[1, 2, 3]";
it becomes a vector of three elements.
Entity a = "[1, 2, 3]T"
becomes a transposed vector, that is, instead of column vector, it's a row vector. Here's how we create a 2x2 matrix:
Entity a = "[[1, 2], [3, 4]]"
[1, 2] is a row.The properties and functions of matrix:
Entity.Matrix m = ...
m.Adjugate // null if it doesn't exist
m.AsScalar() // casts a 1x1 to scalar
m.Inverse // null if it doesn't exist
m.Pow(int) // finds a matrix power or throws
m.ReducedRowEchelonForm
See more at the docs.There are also improvements in AngouriMath.FSharp's matrices. All matrix-related functions moved to AngouriMath.FSharp.Matrices. Now there is a number of operators for matrices specifically all of which end with dot. For example,
a +. b
a -. b
a *. b
a /. b
a **. b // matrix power
a ***. b // tensor product
a ****. b // tensor power
Parser and LaTeXThe parser now supports Cyrillic and Greek letters, as well as it skips \n and \r letters, which might be helpful for building matrices.There's also now a setting MathS.Settings.ExplicitParsingOnly, which, when set to true, does not insert omitted operators, so while
Entity a = "2x + 3(x + 1)";
is fine when the setting is disabled, it won't be considered valid with the setting enabled.There is also MathS.Parse which returns an Either of Entity and reason why parsing failed. Either is an anonymous type union from Honk#, which I'll mention later. Example of code using it:
using AngouriMath;
using System;
var res = MathS.Parse("2x + 3")
.Switch(
valid => valid,
failure => failure.Reason.Switch<Entity>(
unknown => $"Unknown reason: {unknown.Reason}",
missingOperator => $"Operator missed: {missingOperator.Details}",
internalError => $"Internal error: {internalError.Details}"
)
);
Console.WriteLine(res);
Latexise now doesn't produce unneeded \times, and instead, \dot-s are only produced when needed (e. g. between variables). A few bugs in it fixed.New FunctionsMathS.Series.Maclaurin, MathS.Series.Taylor , MathS.Series.TaylorTerms are functions to generate Taylor expansion expressions. A lot of experimental API added for number theory. The final function is the symbolic form of sine and cosine based on existing analytical angles, for example, here's the precise value of sin(17/42 pi):
1/2 * ((sqrt(1 - sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2)) ^ 2) ^ 2 - sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2)) ^ 2) * sqrt(1 - sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2)) ^ 2) - 2 * sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2)) * sqrt(1 - sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2)) ^ 2) * sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2))) - -(2 * sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2)) * sqrt(1 - sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2)) ^ 2) * sqrt(1 - sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2)) ^ 2) + (sqrt(1 - sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2)) ^ 2) ^ 2 - sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2)) ^ 2) * sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2))) * sqrt(3) / 2
All added functions: SymbolicFormOfSine, SymbolicFormOfCosine, ExpandSineOfSum, ExpandConsineOfSum, ExpandSineArgumentMultiplied, ExpandCosineArgumentMultiplied, GetSineOfHalvedAngle, GetCosineOfHalvedAngle, DecomposeRational, GetSineOfHalvedAngle A few synonyms added for hyperbolic functions. All functions from AngouriMath.FSharp now get InnerSimplified applied (for instance, sqrt 4 will return 2 while MathS.Sqrt(4) will still return a power node).AngouriMath.Interactive now has a AggressiveOperators module, which overrides the default operators, such as +, -, *, /, **, <, >, >=, <=, =. It is not recommended to use it as a library, but might be useful for some small calculations, like I did it in the terminal.AngouriMath.CPP: wrapper for C++Now there's a native version of the library that can be consumed from unmanaged code. It is possible thanks to NativeAOT, new feature which allows to compile managed .NET assemblies into native code.It is currently in the experimental phase. You can try it by installing it following a short instruction. Very few functions are still exposed, so it can be barely used for now, but hope it will be developed further in the future.My Reddit postabout it.Using AngouriMath in your projectsNow, aside from netstandard2.0, it multitargets .NET Framework 4.7.2+ and netstandard2.1. The former allows to use the library in legacy projects more conveniently.Honk# now helps to maintain the project easier, but since it's shipped with AngouriMath now, it might be a good idea to try its syntax in some cases.ConclusionThere are a lot of minor features and fixes that are not very interesting to read about. Most of them and other updates are listed in the what's new page on the website.Thank you for your attention! Feel free to ask questions.References
- Github of the project
- Website
- Release notes
- Nuget (C#, F#, Interactive)
- Try in binder
- NativeAOT for native compilation
- dotnet/interactive for Jupyter and notebooks
- Honk# for convenient coding
- My twitter
ThanksAside from myself, I want to thank these people for helping with the project:Contributors: Happypig375, ryynmapes, MomoDeve, TheSeems, KuhakuPixel, jaimeadf, yoshiask.Consultants: Happypig375, mednik.Sponsors: zyzhu.
===========
Источник:
habr.com
===========
Похожие новости:
- [Настройка Linux, *nix, Разработка под Linux, Учебный процесс в IT, DevOps] Зачем уметь работать в командной строке?
- [Сетевые технологии, Математика, Машинное обучение, Искусственный интеллект, Химия] Теория Графов. Часть 2 Смежность, инцидентность, петли
- [Open source, Python] Dramatiq как современная альтернатива Celery: больше нет проблем с версиями и поддержкой Windows
- [Open source, API, Dart, Flutter] Как перестать писать код для взаимодействия с бэкендом
- [Математика, Научно-популярное, Физика, Звук] О звуках, спектрах и обманутых ожиданиях
- [Программирование, Геоинформационные сервисы, Математика, Научно-популярное, Физика] Кто и как поломал Землю, или откуда возникли планетарные горные хребты и разломы
- [Open source, Программирование, Учебный процесс в IT] Как я учил студентов Северной Кореи разрабатывать ПО с открытым исходным кодом (перевод)
- [Программирование, .NET] Creating a NuGet package for a library with platform-specific API
- [.NET, Проектирование и рефакторинг] Королевские рефакторинги с Roslyn
- [Open source, C++, Qt, Софт] Haiku, Inc. проспонсировала приобретение RISC-V материнских плат для портирования системы Haiku
Теги для поиска: #_open_source, #_.net, #_c#, #_matematika (Математика), #_f#, #_angourimath, #_csharp, #_fsharp, #_math, #_update, #_open_source, #_.net, #_c#, #_matematika (
Математика
), #_f#
Вы не можете начинать темы
Вы не можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете голосовать в опросах
Вы не можете прикреплять файлы к сообщениям
Вы не можете скачивать файлы
Текущее время: 22-Ноя 15:57
Часовой пояс: UTC + 5
Автор | Сообщение |
---|---|
news_bot ®
Стаж: 6 лет 9 месяцев |
|
What is it about?AngouriMath is a free open-source symbolic algebra library, written in and for .NET, that I've been working since the end of 2019. The previous major release happened on the second of March, I made an article about it too.Now, let me tell what we, together with contributors, did within these four months! AngouriMath is made for C#, F#, Interactive, and to an extent, C++, so let me draw a distinction, what package affects what environment:C#F#InteractiveC++AngouriMath✓ ✓✓AngouriMath.FSharp✓✓AngouriMath.Interactive✓AngouriMath.CPP✓MatricesThis is the main change in terms of breaking API and behaviour. Now, instead of tensor, there's matrix, which is Entity.Matrix. There is also vector, but it doesn't have its own type. Instead, it's a single-column matrix. So for matrices there's only one type.The syntax for parsing is Entity a = "[1, 2, 3]";
Entity a = "[1, 2, 3]T"
Entity a = "[[1, 2], [3, 4]]"
Entity.Matrix m = ...
m.Adjugate // null if it doesn't exist m.AsScalar() // casts a 1x1 to scalar m.Inverse // null if it doesn't exist m.Pow(int) // finds a matrix power or throws m.ReducedRowEchelonForm a +. b
a -. b a *. b a /. b a **. b // matrix power a ***. b // tensor product a ****. b // tensor power Entity a = "2x + 3(x + 1)";
using AngouriMath;
using System; var res = MathS.Parse("2x + 3") .Switch( valid => valid, failure => failure.Reason.Switch<Entity>( unknown => $"Unknown reason: {unknown.Reason}", missingOperator => $"Operator missed: {missingOperator.Details}", internalError => $"Internal error: {internalError.Details}" ) ); Console.WriteLine(res); 1/2 * ((sqrt(1 - sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2)) ^ 2) ^ 2 - sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2)) ^ 2) * sqrt(1 - sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2)) ^ 2) - 2 * sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2)) * sqrt(1 - sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2)) ^ 2) * sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2))) - -(2 * sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2)) * sqrt(1 - sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2)) ^ 2) * sqrt(1 - sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2)) ^ 2) + (sqrt(1 - sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2)) ^ 2) ^ 2 - sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2)) ^ 2) * sqrt(1/2 - 1/2 * sqrt(1 - sqrt(1 - (1/6 * (-1 + ((7 + 21 * sqrt(-3)) / 2) ^ (1/3) + ((7 - 21 * sqrt(-3)) / 2) ^ (1/3))) ^ 2) ^ 2))) * sqrt(3) / 2
=========== Источник: habr.com =========== Похожие новости:
Математика ), #_f# |
|
Вы не можете начинать темы
Вы не можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете голосовать в опросах
Вы не можете прикреплять файлы к сообщениям
Вы не можете скачивать файлы
Вы не можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете голосовать в опросах
Вы не можете прикреплять файлы к сообщениям
Вы не можете скачивать файлы
Текущее время: 22-Ноя 15:57
Часовой пояс: UTC + 5