Average Error: 32.2 → 0.4
Time: 4.8s
Precision: 64
\[\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
\[\mathsf{expm1}\left(\mathsf{log1p}\left(1 \cdot \frac{\tan^{-1}_* \frac{im}{re}}{\log base}\right)\right)\]
\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}
\mathsf{expm1}\left(\mathsf{log1p}\left(1 \cdot \frac{\tan^{-1}_* \frac{im}{re}}{\log base}\right)\right)
double code(double re, double im, double base) {
	return (((atan2(im, re) * log(base)) - (log(sqrt(((re * re) + (im * im)))) * 0.0)) / ((log(base) * log(base)) + (0.0 * 0.0)));
}
double code(double re, double im, double base) {
	return expm1(log1p((1.0 * (atan2(im, re) / log(base)))));
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 32.2

    \[\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
  2. Taylor expanded around 0 0.3

    \[\leadsto \color{blue}{\frac{\tan^{-1}_* \frac{im}{re}}{\log base}}\]
  3. Using strategy rm
  4. Applied expm1-log1p-u0.4

    \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\tan^{-1}_* \frac{im}{re}}{\log base}\right)\right)}\]
  5. Using strategy rm
  6. Applied div-inv0.5

    \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\color{blue}{\tan^{-1}_* \frac{im}{re} \cdot \frac{1}{\log base}}\right)\right)\]
  7. Using strategy rm
  8. Applied *-un-lft-identity0.5

    \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\color{blue}{\left(1 \cdot \tan^{-1}_* \frac{im}{re}\right)} \cdot \frac{1}{\log base}\right)\right)\]
  9. Applied associate-*l*0.5

    \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\color{blue}{1 \cdot \left(\tan^{-1}_* \frac{im}{re} \cdot \frac{1}{\log base}\right)}\right)\right)\]
  10. Simplified0.4

    \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(1 \cdot \color{blue}{\frac{\tan^{-1}_* \frac{im}{re}}{\log base}}\right)\right)\]
  11. Final simplification0.4

    \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(1 \cdot \frac{\tan^{-1}_* \frac{im}{re}}{\log base}\right)\right)\]

Reproduce

herbie shell --seed 2020057 +o rules:numerics
(FPCore (re im base)
  :name "math.log/2 on complex, imaginary part"
  :precision binary64
  (/ (- (* (atan2 im re) (log base)) (* (log (sqrt (+ (* re re) (* im im)))) 0.0)) (+ (* (log base) (log base)) (* 0.0 0.0))))