https://github.com/yuriy-chumak/libol-algebra
The package for scientific computing with Otus Lisp
https://github.com/yuriy-chumak/libol-algebra
algebra ol otus-lisp
Last synced: 3 months ago
JSON representation
The package for scientific computing with Otus Lisp
- Host: GitHub
- URL: https://github.com/yuriy-chumak/libol-algebra
- Owner: yuriy-chumak
- License: gpl-3.0
- Created: 2021-06-24T11:30:52.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-06-11T21:00:01.000Z (12 months ago)
- Last Synced: 2024-12-27T23:13:29.387Z (5 months ago)
- Topics: algebra, ol, otus-lisp
- Language: Scheme
- Homepage:
- Size: 271 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
(otus algebra)
==============A package for a smart math computing in the [Ol (Otus Lisp)](https://github.com/yuriy-chumak/ol).
[/badge.svg)](https://github.com/yuriy-chumak/libol-algebra/actions/workflows/check-linux.yml)
[/badge.svg)](https://github.com/yuriy-chumak/libol-algebra/actions/workflows/check-macos.yml)
[/badge.svg)](https://github.com/yuriy-chumak/libol-algebra/actions/workflows/check-win64.yml)## For what?
The main purpose of this library is to provide a comfortable way to perform complex math evaluations in a programming environment. Yet another math library? Yes and Not.
The Otus Lisp (`ol`) and `(otus algebra)` library may provide you very human friendly runtime environment with:
* *exact* calculations without losing the readability of the program text
* the same calculation results regardless of the platform used ([*](#note-1))
* *inexact* calculations on demand
* easy switching between *fast inexact* and *ordinary exact* calculation modes## Installing
You have a choice to:
- `make; make install` inside the project folder,
- `kiss install libol-algebra` using [ol-packages](https://github.com/yuriy-chumak/ol-packages) repository,
- If you don't need the *fast inexact* math support (the optimized C code for floating point machine types) or you don't have the C compiler available (huh?), just `copy the "otus" folder` to the your project path.## Usage
A lot of examples available on the [Reference](reference/README.md) page
and in the ["tests"](tests) folder.```scheme
$ ol
Welcome to Otus Lisp 2.5
type ',help' to help, ',quit' to end session.
> (import (otus algebra))
;; Library (otus algebra) added
;; Imported (otus algebra)> (dot-product [1 2 3] [8 -3 5])
17
```Use infix notation inside Lisp (`\\` is a short for macro `infix-notation`) freely:
```scheme
> (\\ [1 3 -5] ⨯ [4 -2 -1] )
[-13 -19 -14]> (\\ (2 + 3) * 4 - 1 )
19
```Some unicode math symbols (don't forget spaces between regular and unicode math letters) are available:
```scheme
> (import (otus algebra unicode))> (define-values (a b c) (values 5 3 -26))
;; All defined> (define D (\\
b ² − 4 * a * c
))
> D
529> (define X₁ (\\
(- b + √(D)) / (2 * a)
))
> (print "X₁ = " X₁)
X₁ = 2> (define X₂ (\\
(- b - √(D)) / (2 * a)
))
> (print "X₂ = " X₂)
X₂ = -13/5> (print (\\
a * (X₂)² + b * X₂ + c
))
0
```
> Don't forget for whitespaces around numbers and math operators.Very Important Notes
====================* All *algebra* arrays in Ol are **indexed starting from 1**.
From 1, as mathematicians do! Not from 0, like programmers.
**Negative index** means "counting from the end of".* By default all *algebra* math **are exact** (it can be changed using environment variables). That means no loss of precision during calculations.
- Some functions (like *sin*) can't be exact,
- Some functions (like *floor*) can be exact only,
- Most functions (like *sqrt*) can be exact and inexact depends on argument(s) exactness.These and other package features described in detail on the main [Reference](reference/README.md) page.
Good luck and happy calculations!
```scheme
> (\\ ((((((((2)²)²)²)²)²)²)²)² )
115792089237316195423570985008687907853269984665640564039457584007913129639936
```## Notes
#### note 1
In case of *inexact* (imprecise) calculations, the results of your work may (and will) vary across the same platforms as well, because of fundamental nature of imprecise calculations.