Crate zbessel_rs

Source
Expand description

§zbessel-rs

A library that provides complex Bessel functions and Airy functions for Rust.

§Simple Usage

use num_complex::Complex64;
use zbessel_rs::{J, Y, I, K, Ai, Bi, J_scaled, Y_scaled, I_scaled, K_scaled, Ai_scaled, Bi_scaled};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let z = Complex64::new(1.0, 0.5);
     
    // Bessel functions (order, variable order)
    let j0 = J(0.0, z)?;  // J_0(z)
    let j1 = J(1.0, z)?;  // J_1(z)
    let y0 = Y(0.0, z)?;  // Y_0(z)
    let i0 = I(0.0, z)?;  // I_0(z)
    let k0 = K(0.0, z)?;  // K_0(z)
     
    // Airy functions
    let ai_val = Ai(z)?;  // Ai(z)
    let bi_val = Bi(z)?;  // Bi(z)
     
    // Scaled versions (useful for large arguments)
    let j0_scaled = J_scaled(0.0, z)?;  // J_0(z) with scaling
    let i0_scaled = I_scaled(0.0, z)?;  // I_0(z) with scaling
    let ai_scaled = Ai_scaled(z)?;      // Ai(z) with scaling
     
    println!("J_0({}) = {}", z, j0);
    println!("Y_0({}) = {}", z, y0);
    println!("I_0({}) = {}", z, i0);
    println!("K_0({}) = {}", z, k0);
    println!("Ai({}) = {}", z, ai_val);
    println!("Bi({}) = {}", z, bi_val);
     
    println!("J_0({}) (scaled) = {}", z, j0_scaled);
    println!("I_0({}) (scaled) = {}", z, i0_scaled);
    println!("Ai({}) (scaled) = {}", z, ai_scaled);
     
    Ok(())
}

§Advanced Usage

For multiple value calculations or scaling:

use num_complex::Complex64;
use zbessel_rs::{bessel_j, bessel_i, airy_ai};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let z = Complex64::new(2.0, 1.0);
     
    // Calculate multiple orders at once: J_0(z), J_1(z), J_2(z)
    let result = bessel_j(z, 0.0, 1, 3)?;
    for (n, value) in result.values.iter().enumerate() {
        println!("J_{}({}) = {}", n, z, value);
    }
     
    // Scaled result (kode=2)
    let scaled = bessel_i(z, 0.0, 2, 1)?;
    println!("I_0({}) (scaled) = {}", z, scaled.values[0]);
     
    // Airy function derivative (id=1)
    let ai_prime = airy_ai(z, 1, 1)?;
    println!("Ai'({}) = {}", z, ai_prime);
     
    Ok(())
}

Structs§

BesselResult
Structure representing the result of complex Bessel function calculations

Enums§

BesselError
Error types

Functions§

Ai
Calculate Airy function Ai(z) (no scaling)
Ai_scaled
Calculate Airy function Ai(z) with scaling
Bi
Calculate Airy function Bi(z) (no scaling)
Bi_scaled
Calculate Airy function Bi(z) with scaling
I
Calculate modified Bessel function I_ν(z) (single value, no scaling)
I_scaled
Calculate modified Bessel function I_ν(z) with scaling (single value)
J
Calculate Bessel function J_ν(z) (single value, no scaling)
J_scaled
Calculate Bessel function J_ν(z) with scaling (single value)
K
Calculate modified Bessel function K_ν(z) (single value, no scaling)
K_scaled
Calculate modified Bessel function K_ν(z) with scaling (single value)
Y
Calculate Bessel function Y_ν(z) (single value, no scaling)
Y_scaled
Calculate Bessel function Y_ν(z) with scaling (single value)
airy_ai
Calculate complex Airy function Ai(z)
airy_bi
Calculate complex Airy function Bi(z)
bessel_i
Calculate complex modified Bessel function I_ν(z)
bessel_j
Calculate complex Bessel function J_ν(z)
bessel_k
Calculate complex modified Bessel function K_ν(z)
bessel_y
Calculate complex Bessel function Y_ν(z)
zairy
zbesh
zbesi
zbesj
zbesk
zbesy
zbiry