
(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 4 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 (/ (pow (log 0.1) -1.0) (/ -1.0 (atan2 im re))))
double code(double re, double im) {
return pow(log(0.1), -1.0) / (-1.0 / atan2(im, re));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (log(0.1d0) ** (-1.0d0)) / ((-1.0d0) / atan2(im, re))
end function
public static double code(double re, double im) {
return Math.pow(Math.log(0.1), -1.0) / (-1.0 / Math.atan2(im, re));
}
def code(re, im): return math.pow(math.log(0.1), -1.0) / (-1.0 / math.atan2(im, re))
function code(re, im) return Float64((log(0.1) ^ -1.0) / Float64(-1.0 / atan(im, re))) end
function tmp = code(re, im) tmp = (log(0.1) ^ -1.0) / (-1.0 / atan2(im, re)); end
code[re_, im_] := N[(N[Power[N[Log[0.1], $MachinePrecision], -1.0], $MachinePrecision] / N[(-1.0 / N[ArcTan[im / re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\log 0.1}^{-1}}{\frac{-1}{\tan^{-1}_* \frac{im}{re}}}
\end{array}
Initial program 98.7%
lift-/.f64N/A
frac-2negN/A
clear-numN/A
div-invN/A
associate-/r*N/A
lower-/.f64N/A
inv-powN/A
lower-pow.f64N/A
lift-log.f64N/A
neg-logN/A
lower-log.f64N/A
metadata-evalN/A
frac-2negN/A
metadata-evalN/A
remove-double-negN/A
lower-/.f6499.7
Applied rewrites99.7%
(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.7%
remove-double-negN/A
lower-neg.f64N/A
lift-log.f64N/A
neg-logN/A
lower-log.f64N/A
metadata-eval99.7
Applied rewrites99.7%
(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.7%
(FPCore (re im) :precision binary64 (atan2 im re))
double code(double re, double im) {
return atan2(im, re);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = atan2(im, re)
end function
public static double code(double re, double im) {
return Math.atan2(im, re);
}
def code(re, im): return math.atan2(im, re)
function code(re, im) return atan(im, re) end
function tmp = code(re, im) tmp = atan2(im, re); end
code[re_, im_] := N[ArcTan[im / re], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{im}{re}
\end{array}
Initial program 98.7%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
inv-powN/A
sqr-powN/A
associate-*l*N/A
lower-*.f64N/A
lower-pow.f64N/A
metadata-evalN/A
lower-*.f64N/A
lower-pow.f64N/A
metadata-eval98.8
Applied rewrites98.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-upN/A
metadata-evalN/A
inv-powN/A
*-commutativeN/A
div-invN/A
lift-/.f6498.7
rem-square-sqrtN/A
sqrt-unprodN/A
lift-/.f64N/A
div-invN/A
lift-/.f64N/A
div-invN/A
swap-sqrN/A
unpow2N/A
lift-pow.f64N/A
Applied rewrites98.8%
Applied rewrites24.1%
herbie shell --seed 2024268
(FPCore (re im)
:name "math.log10 on complex, imaginary part"
:precision binary64
(/ (atan2 im re) (log 10.0)))