So, I'm trying to learn Rust. And in thinking about the ontological status of 
mathematical representations of waves (https://arxiv.org/abs/2101.10873), I 
figured I'd validate Euler's identity:

fn main() {
  let e = num::complex::Complex::new(std::f32::consts::E,0.);
  let e2ip = e.powc(num::complex::Complex::new(0.,std::f32::consts::PI));
  let i = num::complex::Complex::new(0.,1.);
  println!("ln(e^iπ) = {}",e2ip.ln());
  println!("ln(-1) = {}", i.powi(2).ln());
}
$ cargo run
ln(e^iπ) = 0+3.1415925i
ln(-1) = 0+3.141592653589793i

I don't have any idea if that's a reasonable way to do that, since I'm ignorant 
of Rust. But it's interesting to contrast it with R and Sage:

$ Rscript -e "log(exp(1)^((0+1i)*pi));log((0+1i)^2)"
[1] 0+3.141593i
[1] 0+3.141593i

sage: numerical_approx(ln(e^(i*pi)));numerical_approx(ln(i^2))
3.14159265358979*I
3.14159265358979*I

The precision difference between the 2 results in Rust is interesting. It's the 
same if I use powf() instead of powi(). Any clues? Or should I simply RTFM?

-- 
↙↙↙ uǝlƃ

- .... . -..-. . -. -.. -..-. .. ... -..-. .... . .-. .
FRIAM Applied Complexity Group listserv
Zoom Fridays 9:30a-12p Mtn GMT-6  bit.ly/virtualfriam
un/subscribe http://redfish.com/mailman/listinfo/friam_redfish.com
FRIAM-COMIC http://friam-comic.blogspot.com/
archives: http://friam.471366.n2.nabble.com/

Reply via email to