
(FPCore (re im) :precision binary64 (/ (atan2 im re) (log 10.0)))
double code(double re, double im) {
return atan2(im, re) / log(10.0);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = atan2(im, re) / log(10.0d0)
end function
public static double code(double re, double im) {
return Math.atan2(im, re) / Math.log(10.0);
}
def code(re, im): return math.atan2(im, re) / math.log(10.0)
function code(re, im) return Float64(atan(im, re) / log(10.0)) end
function tmp = code(re, im) tmp = atan2(im, re) / log(10.0); end
code[re_, im_] := N[(N[ArcTan[im / re], $MachinePrecision] / N[Log[10.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\tan^{-1}_* \frac{im}{re}}{\log 10}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (/ (atan2 im re) (log 10.0)))
double code(double re, double im) {
return atan2(im, re) / log(10.0);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = atan2(im, re) / log(10.0d0)
end function
public static double code(double re, double im) {
return Math.atan2(im, re) / Math.log(10.0);
}
def code(re, im): return math.atan2(im, re) / math.log(10.0)
function code(re, im) return Float64(atan(im, re) / log(10.0)) end
function tmp = code(re, im) tmp = atan2(im, re) / log(10.0); end
code[re_, im_] := N[(N[ArcTan[im / re], $MachinePrecision] / N[Log[10.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\tan^{-1}_* \frac{im}{re}}{\log 10}
\end{array}
(FPCore (re im) :precision binary64 (/ (atan2 im re) (- (log 0.1))))
double code(double re, double im) {
return atan2(im, re) / -log(0.1);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = atan2(im, re) / -log(0.1d0)
end function
public static double code(double re, double im) {
return Math.atan2(im, re) / -Math.log(0.1);
}
def code(re, im): return math.atan2(im, re) / -math.log(0.1)
function code(re, im) return Float64(atan(im, re) / Float64(-log(0.1))) end
function tmp = code(re, im) tmp = atan2(im, re) / -log(0.1); end
code[re_, im_] := N[(N[ArcTan[im / re], $MachinePrecision] / (-N[Log[0.1], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
\\
\frac{\tan^{-1}_* \frac{im}{re}}{-\log 0.1}
\end{array}
Initial program 98.6%
clear-num98.4%
frac-2neg98.4%
div-inv98.4%
associate-/r*97.6%
inv-pow97.6%
sqr-pow0.0%
pow-prod-down7.4%
sqr-neg7.4%
pow-prod-down7.4%
div-inv7.4%
times-frac7.4%
Applied egg-rr0.0%
*-commutative0.0%
associate-/r/0.0%
associate-*r*0.0%
associate-*l/0.0%
*-commutative0.0%
associate-*l*0.0%
pow-sqr99.8%
metadata-eval99.8%
unpow-199.8%
associate-*r/99.8%
associate-/l*99.8%
/-rgt-identity99.8%
associate-/l/99.8%
mul-1-neg99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (re im) :precision binary64 (/ (atan2 im re) (log 10.0)))
double code(double re, double im) {
return atan2(im, re) / log(10.0);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = atan2(im, re) / log(10.0d0)
end function
public static double code(double re, double im) {
return Math.atan2(im, re) / Math.log(10.0);
}
def code(re, im): return math.atan2(im, re) / math.log(10.0)
function code(re, im) return Float64(atan(im, re) / log(10.0)) end
function tmp = code(re, im) tmp = atan2(im, re) / log(10.0); end
code[re_, im_] := N[(N[ArcTan[im / re], $MachinePrecision] / N[Log[10.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\tan^{-1}_* \frac{im}{re}}{\log 10}
\end{array}
Initial program 98.6%
Final simplification98.6%
(FPCore (re im) :precision binary64 (/ (atan2 im re) 2.0))
double code(double re, double im) {
return atan2(im, re) / 2.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = atan2(im, re) / 2.0d0
end function
public static double code(double re, double im) {
return Math.atan2(im, re) / 2.0;
}
def code(re, im): return math.atan2(im, re) / 2.0
function code(re, im) return Float64(atan(im, re) / 2.0) end
function tmp = code(re, im) tmp = atan2(im, re) / 2.0; end
code[re_, im_] := N[(N[ArcTan[im / re], $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\tan^{-1}_* \frac{im}{re}}{2}
\end{array}
Initial program 98.6%
clear-num98.4%
frac-2neg98.4%
div-inv98.4%
associate-/r*97.6%
inv-pow97.6%
sqr-pow0.0%
pow-prod-down7.4%
sqr-neg7.4%
pow-prod-down7.4%
div-inv7.4%
times-frac7.4%
Applied egg-rr0.0%
*-commutative0.0%
associate-/r/0.0%
associate-*r*0.0%
associate-*l/0.0%
*-commutative0.0%
associate-*l*0.0%
pow-sqr99.8%
metadata-eval99.8%
unpow-199.8%
associate-*r/99.8%
associate-/l*99.8%
/-rgt-identity99.8%
associate-/l/99.8%
mul-1-neg99.8%
Simplified99.8%
Applied egg-rr26.6%
Final simplification26.6%
herbie shell --seed 2023297
(FPCore (re im)
:name "math.log10 on complex, imaginary part"
:precision binary64
(/ (atan2 im re) (log 10.0)))