Crates.io | rustnomial |
lib.rs | rustnomial |
version | 0.3.2 |
source | src |
created_at | 2020-08-10 01:29:09.070679 |
updated_at | 2021-06-27 03:25:04.453178 |
description | A crate for working with polynomials. |
homepage | |
repository | https://github.com/philippeitis/rustnomial |
max_upload_size | |
id | 274853 |
size | 202,437 |
This crate provides utilities for operating on polynomials, including:
use std::str::FromStr;
use rustnomial::{GenericPolynomial, Polynomial};
fn main() {
let poly = Polynomial::<i32>::from_str("1+x^2-3+11x").unwrap();
// x^2 + 11x - 2
println!("{}", poly);
}
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.));
}
use rustnomial::derivative;
fn main() {
let poly = derivative!(5., 2., 0.);
// 10x + 2
println!("{}", poly);
}
use rustnomial::{GenericPolynomial, Polynomial};
fn main() {
let poly = Polynomial::<f64>::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());
}