Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/philippeitis/rustnomial
Rust library for high-performance polynomial operations
https://github.com/philippeitis/rustnomial
Last synced: 9 days ago
JSON representation
Rust library for high-performance polynomial operations
- Host: GitHub
- URL: https://github.com/philippeitis/rustnomial
- Owner: philippeitis
- License: mit
- Created: 2020-05-19T22:36:17.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-12-26T20:00:55.000Z (almost 2 years ago)
- Last Synced: 2024-10-13T21:09:31.783Z (23 days ago)
- Language: Rust
- Homepage:
- Size: 219 KB
- Stars: 7
- Watchers: 2
- Forks: 3
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# rustnomial
This crate provides utilities for operating on polynomials, including:
- Parsing polynomials from strings, and creating strings from polynomials
- Math operations with polynomials
- Integration and derivation of polynomials
- Finding polynomial roots# Examples
- Parsing polynomials from / to strings:
```rust
use std::str::FromStr;use rustnomial::{GenericPolynomial, Polynomial};
fn main() {
let poly = Polynomial::::from_str("1+x^2-3+11x").unwrap();
// x^2 + 11x - 2
println!("{}", poly);
}
```- Integration
```rust
use rustnomial::integral;fn main() {
let poly = integral!(5., 2., 0.);
// 1.6666666666666667x^3 + x^2 + C
println!("{}", poly);
// 2.666666666666667
println!("{}", poly.eval(0., 1.));
}
```- Derivation
```rust
use rustnomial::derivative;fn main() {
let poly = derivative!(5., 2., 0.);
// 10x + 2
println!("{}", poly);
}
```- Rootfinding
```rust
use rustnomial::{GenericPolynomial, Polynomial};fn main() {
let poly = Polynomial::::new(vec![1., 2.]).pow(9) * Polynomial::new(vec![1., 3.]);
// ManyRealRoots([-3.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0])
println!("{:?}", poly.roots());
}
```