Skip to main content

biry

Function biry 

Source
pub fn biry<T: BesselFloat>(z: Complex<T>) -> Result<Complex<T>, Error>
Expand description

Airy function of the second kind, Bi(z).

Computes the Airy function Bi(z) for complex z. Bi(z) is the solution to w′′ − z·w = 0 that grows super-exponentially for large positive real z.

§Example

use complex_bessel::biry;
use num_complex::Complex;

let z = Complex::new(0.0_f64, 0.0);
let bi = biry(z).unwrap();
assert!((bi.re - 0.6149).abs() < 1e-3); // Bi(0) ≈ 0.6149

§Errors

Examples found in repository?
examples/basic.rs (line 63)
4fn main() {
5    let z = Complex::new(1.0_f64, 2.0);
6
7    // -- Single-value Bessel functions --
8    println!("=== Single-value functions (f64) ===");
9    let j = besselj(0.5, z).unwrap();
10    println!("J_0.5({z}) = {j}");
11
12    let y = bessely(1.0, z).unwrap();
13    println!("Y_1({z}) = {y}");
14
15    let i = besseli(0.0, z).unwrap();
16    println!("I_0({z}) = {i}");
17
18    let k = besselk(1.0, z).unwrap();
19    println!("K_1({z}) = {k}");
20
21    let h1 = hankel1(0.0, z).unwrap();
22    println!("H^(1)_0({z}) = {h1}");
23
24    let h2 = hankel2(0.0, z).unwrap();
25    println!("H^(2)_0({z}) = {h2}");
26
27    // -- Negative order --
28    println!("\n=== Negative order ===");
29    let j_neg = besselj(-0.5, z).unwrap();
30    println!("J_-0.5({z}) = {j_neg}");
31
32    let k_neg = besselk(-3.0, z).unwrap();
33    let k_pos = besselk(3.0, z).unwrap();
34    println!("K_-3({z}) = {k_neg}");
35    println!("K_3({z})  = {k_pos}  (should be equal)");
36
37    // -- Scaled computation --
38    println!("\n=== Scaled functions ===");
39    let k_sc = besselk_scaled(1.0, z).unwrap();
40    println!("exp(z)*K_1({z}) = {k_sc}");
41
42    let j_sc = besselj_scaled(0.5, z).unwrap();
43    println!("exp(-|Im(z)|)*J_0.5({z}) = {j_sc}");
44
45    // -- Sequence computation --
46    println!("\n=== Sequence: K_0, K_1, K_2 ===");
47    let seq = besselk_seq(0.0, z, 3, Scaling::Unscaled).unwrap();
48    for (j, val) in seq.values.iter().enumerate() {
49        println!("  K_{j}({z}) = {val}");
50    }
51
52    println!("  underflow_count: {}", seq.underflow_count);
53    println!("  status: {:?}", seq.status);
54
55    // -- Airy functions --
56    println!("\n=== Airy functions ===");
57    let ai = airy(z).unwrap();
58    println!("Ai({z}) = {ai}");
59
60    let ai_prime = airyprime(z).unwrap();
61    println!("Ai'({z}) = {ai_prime}");
62
63    let bi = biry(z).unwrap();
64    println!("Bi({z}) = {bi}");
65
66    // -- f32 support --
67    println!("\n=== f32 support ===");
68    let z32 = Complex::new(1.0_f32, 2.0);
69    let j32 = besselj(0.5, z32).unwrap();
70    println!("J_0.5({z32}) = {j32} (f32)");
71}