| Crates.io | math-wave |
| lib.rs | math-wave |
| version | 0.3.0 |
| created_at | 2025-12-21 13:00:03.304218+00 |
| updated_at | 2026-01-02 08:43:59.680421+00 |
| description | Analytical solutions for wave and Helmholtz equations |
| homepage | |
| repository | https://github.com/pierreaubert/math-audio |
| max_upload_size | |
| id | 1997930 |
| size | 85,523 |
Analytical solutions for wave and Helmholtz equations.
Add to your Cargo.toml:
[dependencies]
math-wave = { path = "../math-wave" }
use math_wave::analytical::plane_wave_1d;
use std::f64::consts::PI;
let wave = plane_wave_1d(1.0, 0.0, 2.0 * PI, 100);
assert_eq!(wave.pressure.len(), 100);
use math_wave::analytical::sphere_scattering_3d;
use std::f64::consts::PI;
let scatter = sphere_scattering_3d(1.0, 1.0, 20, vec![2.0], vec![0.0, PI / 2.0]);
assert!(scatter.pressure[0].norm() > 0.0);
The Helmholtz Green's function for 3D:
G(x, y) = exp(ik|x-y|) / (4π|x-y|)
For 2D (cylindrical):
G(x, y) = (i/4) H₀⁽¹⁾(k|x-y|)
analytical - Exact solutions for validation (1D, 2D, 3D)greens - Green's function implementationsspecial - Spherical Bessel, Hankel, and Legendre functionsRepresents a point in 1D, 2D, or 3D space with coordinate conversions:
use math_wave::Point;
let p = Point::new_3d(1.0, 2.0, 3.0);
let r = p.radius();
let theta = p.theta_3d();
Contains solution data with error computation:
use math_wave::AnalyticalSolution;
let l2_err = solution.l2_error(&reference);
let linf_err = solution.linf_error(&reference);
let rel_err = solution.relative_l2_error(&reference);