
(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 (let* ((t_0 (pow (log 10.0) 0.25))) (/ (/ (/ (atan2 im re) (sqrt (log 10.0))) t_0) t_0)))
double code(double re, double im) {
double t_0 = pow(log(10.0), 0.25);
return ((atan2(im, re) / sqrt(log(10.0))) / t_0) / t_0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
t_0 = log(10.0d0) ** 0.25d0
code = ((atan2(im, re) / sqrt(log(10.0d0))) / t_0) / t_0
end function
public static double code(double re, double im) {
double t_0 = Math.pow(Math.log(10.0), 0.25);
return ((Math.atan2(im, re) / Math.sqrt(Math.log(10.0))) / t_0) / t_0;
}
def code(re, im): t_0 = math.pow(math.log(10.0), 0.25) return ((math.atan2(im, re) / math.sqrt(math.log(10.0))) / t_0) / t_0
function code(re, im) t_0 = log(10.0) ^ 0.25 return Float64(Float64(Float64(atan(im, re) / sqrt(log(10.0))) / t_0) / t_0) end
function tmp = code(re, im) t_0 = log(10.0) ^ 0.25; tmp = ((atan2(im, re) / sqrt(log(10.0))) / t_0) / t_0; end
code[re_, im_] := Block[{t$95$0 = N[Power[N[Log[10.0], $MachinePrecision], 0.25], $MachinePrecision]}, N[(N[(N[(N[ArcTan[im / re], $MachinePrecision] / N[Sqrt[N[Log[10.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\log 10}^{0.25}\\
\frac{\frac{\frac{\tan^{-1}_* \frac{im}{re}}{\sqrt{\log 10}}}{t_0}}{t_0}
\end{array}
\end{array}
Initial program 98.7%
expm1-log1p-u86.8%
expm1-udef67.2%
log1p-udef67.2%
add-exp-log79.1%
Applied egg-rr79.1%
associate--l+79.1%
Simplified79.1%
associate-+r-79.1%
add-exp-log67.2%
log1p-udef67.2%
expm1-udef86.8%
expm1-log1p-u98.7%
add-sqr-sqrt98.7%
associate-/r*98.7%
add-sqr-sqrt97.8%
associate-/r*97.8%
pow1/297.8%
sqrt-pow198.7%
metadata-eval98.7%
pow1/298.7%
sqrt-pow199.8%
metadata-eval99.8%
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(-Float64(atan(im, re) / 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%
frac-2neg98.7%
div-inv98.6%
neg-log99.7%
metadata-eval99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Final simplification99.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%
Final simplification98.7%
herbie shell --seed 2023178
(FPCore (re im)
:name "math.log10 on complex, imaginary part"
:precision binary64
(/ (atan2 im re) (log 10.0)))