7 releases (3 stable)
1.0.2 | Feb 24, 2021 |
---|---|
0.0.4 | Feb 24, 2021 |
0.0.3 | Feb 23, 2021 |
0.0.2 | Feb 23, 2021 |
0.0.1 | Feb 22, 2021 |
#660 in Math
28 downloads per month
Used in cosmology
34KB
952 lines
Sequential integration
Description
Lightweight library for sequential integration.
Now support
Single, double and triple integrals with Simpson quadrature.
Examples version 1.*.*
sequential_integration::calculate_single_integral_simpson(
|x: f64| (1. - x.powf(2.)).sqrt(), // equation
-1., // first_integral_begin
1., // first_integral_end
0.01, // first_integral_step
)?
sequential_integration::calculate_double_integral_simpson(
|_x, _y| 1., // equation
-1., // first_integral_begin
1., // first_integral_end
0.01, // first_integral_step
|_x| -0., // second_integral_begin
|x: f64| (1. - x.powf(2.)).sqrt(), // second_integral_end
0.01, // second_integral_step
)?
sequential_integration::calculate_triple_integral_simpson(
|x: f64, y: f64, z: f64| x.powf(2.) + y.powf(2.) + z.powf(2.), // equation
-1., // first_integral_begin
1., // first_integral_end
0.01, // first_integral_step
|x| x, // second_integral_begin
|x| x / 2., // second_integral_end
0.01, // second_integral_step
|x: f64, y: f64| x.powf(2.) + y, // third_integral_begin
|_x, _y| 0., // third_integral_end
0.01, // third_integral_step
)?
equation - f(x) for single integral, f(x,y) for double integral and f(x,y,z) for triple integral
first_integral_begin/end - constant
second_integral_begin/end - f(x)
third_integral_begin/end - f(x,y)
Release updates:
0.0.1 - Double and triple integrals with Simpson quadrature
0.0.2 - Not use additional memory, correct way for last step
0.0.3 - Support single integral
0.0.4 - Support integration from larger bound to smaller bound
1.0.0 - Use closures instead string equations (See mexprp if you want to use string equations with closures)
Examples for old versions:
Examples version 0.*.*
sequential_integration::calculate_single_integral_simpson(
"max(sqrt(1 - x^2))", // equation
-1., // first_integral_begin
1., // first_integral_end
0.01, // first_integral_step
)?
sequential_integration::calculate_double_integral_simpson(
"1", // equation
-1., // first_integral_begin
1., // first_integral_end
0.01, // first_integral_step
"0", // second_integral_begin
"max(sqrt(1 - x^2))", // second_integral_end
0.01, // second_integral_step
)?
sequential_integration::calculate_triple_integral_simpson(
"x ^ 2 + y ^ 2 + z ^ 2", // equation
-1., // first_integral_begin
1., // first_integral_end
0.01, // first_integral_step
"x", // second_integral_begin
"x / 2", // second_integral_end
0.01, // second_integral_step
"x^2 + y", // third_integral_begin
"0", // third_integral_end
0.01, // third_integral_step
)?
Dependencies
~3.5–5MB
~109K SLoC