
(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 (/ 1.0 (* (/ -1.0 (atan2 im re)) (log 0.1))))
double code(double re, double im) {
return 1.0 / ((-1.0 / atan2(im, re)) * log(0.1));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 1.0d0 / (((-1.0d0) / atan2(im, re)) * log(0.1d0))
end function
public static double code(double re, double im) {
return 1.0 / ((-1.0 / Math.atan2(im, re)) * Math.log(0.1));
}
def code(re, im): return 1.0 / ((-1.0 / math.atan2(im, re)) * math.log(0.1))
function code(re, im) return Float64(1.0 / Float64(Float64(-1.0 / atan(im, re)) * log(0.1))) end
function tmp = code(re, im) tmp = 1.0 / ((-1.0 / atan2(im, re)) * log(0.1)); end
code[re_, im_] := N[(1.0 / N[(N[(-1.0 / N[ArcTan[im / re], $MachinePrecision]), $MachinePrecision] * N[Log[0.1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{-1}{\tan^{-1}_* \frac{im}{re}} \cdot \log 0.1}
\end{array}
Initial program 98.6%
clear-num98.6%
inv-pow98.6%
Applied egg-rr98.6%
Applied egg-rr98.9%
pow-pow98.2%
pow1/352.9%
pow-pow98.6%
metadata-eval98.6%
metadata-eval98.6%
inv-pow98.6%
clear-num98.6%
div-inv98.6%
remove-double-div98.6%
frac-2neg98.6%
metadata-eval98.6%
frac-2neg98.6%
metadata-eval98.6%
log1p-undefine98.6%
neg-log99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval98.6%
log1p-undefine98.6%
frac-times98.6%
metadata-eval98.6%
distribute-neg-frac98.6%
metadata-eval98.6%
log1p-undefine98.6%
Applied egg-rr99.8%
Final simplification99.8%
(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%
div-inv98.6%
frac-2neg98.6%
metadata-eval98.6%
log1p-expm1-u98.6%
expm1-undefine98.6%
exp-neg98.6%
rem-exp-log98.6%
metadata-eval98.6%
metadata-eval98.6%
Applied egg-rr98.6%
metadata-eval98.6%
distribute-neg-frac98.6%
distribute-neg-frac298.6%
associate-/l*98.6%
*-rgt-identity98.6%
log1p-undefine98.6%
metadata-eval99.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%
herbie shell --seed 2024077
(FPCore (re im)
:name "math.log10 on complex, imaginary part"
:precision binary64
(/ (atan2 im re) (log 10.0)))