
(FPCore (re im base) :precision binary64 (/ (+ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (atan2 im re) 0.0)) (+ (* (log base) (log base)) (* 0.0 0.0))))
double code(double re, double im, double base) {
return ((log(sqrt(((re * re) + (im * im)))) * log(base)) + (atan2(im, re) * 0.0)) / ((log(base) * log(base)) + (0.0 * 0.0));
}
real(8) function code(re, im, base)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8), intent (in) :: base
code = ((log(sqrt(((re * re) + (im * im)))) * log(base)) + (atan2(im, re) * 0.0d0)) / ((log(base) * log(base)) + (0.0d0 * 0.0d0))
end function
public static double code(double re, double im, double base) {
return ((Math.log(Math.sqrt(((re * re) + (im * im)))) * Math.log(base)) + (Math.atan2(im, re) * 0.0)) / ((Math.log(base) * Math.log(base)) + (0.0 * 0.0));
}
def code(re, im, base): return ((math.log(math.sqrt(((re * re) + (im * im)))) * math.log(base)) + (math.atan2(im, re) * 0.0)) / ((math.log(base) * math.log(base)) + (0.0 * 0.0))
function code(re, im, base) return Float64(Float64(Float64(log(sqrt(Float64(Float64(re * re) + Float64(im * im)))) * log(base)) + Float64(atan(im, re) * 0.0)) / Float64(Float64(log(base) * log(base)) + Float64(0.0 * 0.0))) end
function tmp = code(re, im, base) tmp = ((log(sqrt(((re * re) + (im * im)))) * log(base)) + (atan2(im, re) * 0.0)) / ((log(base) * log(base)) + (0.0 * 0.0)); end
code[re_, im_, base_] := N[(N[(N[(N[Log[N[Sqrt[N[(N[(re * re), $MachinePrecision] + N[(im * im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Log[base], $MachinePrecision]), $MachinePrecision] + N[(N[ArcTan[im / re], $MachinePrecision] * 0.0), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Log[base], $MachinePrecision] * N[Log[base], $MachinePrecision]), $MachinePrecision] + N[(0.0 * 0.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im base) :precision binary64 (/ (+ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (atan2 im re) 0.0)) (+ (* (log base) (log base)) (* 0.0 0.0))))
double code(double re, double im, double base) {
return ((log(sqrt(((re * re) + (im * im)))) * log(base)) + (atan2(im, re) * 0.0)) / ((log(base) * log(base)) + (0.0 * 0.0));
}
real(8) function code(re, im, base)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8), intent (in) :: base
code = ((log(sqrt(((re * re) + (im * im)))) * log(base)) + (atan2(im, re) * 0.0d0)) / ((log(base) * log(base)) + (0.0d0 * 0.0d0))
end function
public static double code(double re, double im, double base) {
return ((Math.log(Math.sqrt(((re * re) + (im * im)))) * Math.log(base)) + (Math.atan2(im, re) * 0.0)) / ((Math.log(base) * Math.log(base)) + (0.0 * 0.0));
}
def code(re, im, base): return ((math.log(math.sqrt(((re * re) + (im * im)))) * math.log(base)) + (math.atan2(im, re) * 0.0)) / ((math.log(base) * math.log(base)) + (0.0 * 0.0))
function code(re, im, base) return Float64(Float64(Float64(log(sqrt(Float64(Float64(re * re) + Float64(im * im)))) * log(base)) + Float64(atan(im, re) * 0.0)) / Float64(Float64(log(base) * log(base)) + Float64(0.0 * 0.0))) end
function tmp = code(re, im, base) tmp = ((log(sqrt(((re * re) + (im * im)))) * log(base)) + (atan2(im, re) * 0.0)) / ((log(base) * log(base)) + (0.0 * 0.0)); end
code[re_, im_, base_] := N[(N[(N[(N[Log[N[Sqrt[N[(N[(re * re), $MachinePrecision] + N[(im * im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Log[base], $MachinePrecision]), $MachinePrecision] + N[(N[ArcTan[im / re], $MachinePrecision] * 0.0), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Log[base], $MachinePrecision] * N[Log[base], $MachinePrecision]), $MachinePrecision] + N[(0.0 * 0.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}
\end{array}
(FPCore (re im base) :precision binary64 (/ (log (hypot re im)) (log base)))
double code(double re, double im, double base) {
return log(hypot(re, im)) / log(base);
}
public static double code(double re, double im, double base) {
return Math.log(Math.hypot(re, im)) / Math.log(base);
}
def code(re, im, base): return math.log(math.hypot(re, im)) / math.log(base)
function code(re, im, base) return Float64(log(hypot(re, im)) / log(base)) end
function tmp = code(re, im, base) tmp = log(hypot(re, im)) / log(base); end
code[re_, im_, base_] := N[(N[Log[N[Sqrt[re ^ 2 + im ^ 2], $MachinePrecision]], $MachinePrecision] / N[Log[base], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log base}
\end{array}
Initial program 51.6%
mul0-rgt51.6%
+-rgt-identity51.6%
metadata-eval51.6%
+-rgt-identity51.6%
times-frac51.7%
*-inverses51.7%
*-rgt-identity51.7%
hypot-def99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (re im base)
:precision binary64
(let* ((t_0 (/ (- (log (/ -1.0 re))) (log base))))
(if (<= im 1.02e-203)
t_0
(if (<= im 7.2e-165)
(/ 1.0 (/ (log base) (log im)))
(if (<= im 2.55e-101)
t_0
(if (<= im 1.05e-61)
(* (log im) (/ 1.0 (log base)))
(if (<= im 2.7e-50) t_0 (/ (log im) (log base)))))))))
double code(double re, double im, double base) {
double t_0 = -log((-1.0 / re)) / log(base);
double tmp;
if (im <= 1.02e-203) {
tmp = t_0;
} else if (im <= 7.2e-165) {
tmp = 1.0 / (log(base) / log(im));
} else if (im <= 2.55e-101) {
tmp = t_0;
} else if (im <= 1.05e-61) {
tmp = log(im) * (1.0 / log(base));
} else if (im <= 2.7e-50) {
tmp = t_0;
} else {
tmp = log(im) / log(base);
}
return tmp;
}
real(8) function code(re, im, base)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8), intent (in) :: base
real(8) :: t_0
real(8) :: tmp
t_0 = -log(((-1.0d0) / re)) / log(base)
if (im <= 1.02d-203) then
tmp = t_0
else if (im <= 7.2d-165) then
tmp = 1.0d0 / (log(base) / log(im))
else if (im <= 2.55d-101) then
tmp = t_0
else if (im <= 1.05d-61) then
tmp = log(im) * (1.0d0 / log(base))
else if (im <= 2.7d-50) then
tmp = t_0
else
tmp = log(im) / log(base)
end if
code = tmp
end function
public static double code(double re, double im, double base) {
double t_0 = -Math.log((-1.0 / re)) / Math.log(base);
double tmp;
if (im <= 1.02e-203) {
tmp = t_0;
} else if (im <= 7.2e-165) {
tmp = 1.0 / (Math.log(base) / Math.log(im));
} else if (im <= 2.55e-101) {
tmp = t_0;
} else if (im <= 1.05e-61) {
tmp = Math.log(im) * (1.0 / Math.log(base));
} else if (im <= 2.7e-50) {
tmp = t_0;
} else {
tmp = Math.log(im) / Math.log(base);
}
return tmp;
}
def code(re, im, base): t_0 = -math.log((-1.0 / re)) / math.log(base) tmp = 0 if im <= 1.02e-203: tmp = t_0 elif im <= 7.2e-165: tmp = 1.0 / (math.log(base) / math.log(im)) elif im <= 2.55e-101: tmp = t_0 elif im <= 1.05e-61: tmp = math.log(im) * (1.0 / math.log(base)) elif im <= 2.7e-50: tmp = t_0 else: tmp = math.log(im) / math.log(base) return tmp
function code(re, im, base) t_0 = Float64(Float64(-log(Float64(-1.0 / re))) / log(base)) tmp = 0.0 if (im <= 1.02e-203) tmp = t_0; elseif (im <= 7.2e-165) tmp = Float64(1.0 / Float64(log(base) / log(im))); elseif (im <= 2.55e-101) tmp = t_0; elseif (im <= 1.05e-61) tmp = Float64(log(im) * Float64(1.0 / log(base))); elseif (im <= 2.7e-50) tmp = t_0; else tmp = Float64(log(im) / log(base)); end return tmp end
function tmp_2 = code(re, im, base) t_0 = -log((-1.0 / re)) / log(base); tmp = 0.0; if (im <= 1.02e-203) tmp = t_0; elseif (im <= 7.2e-165) tmp = 1.0 / (log(base) / log(im)); elseif (im <= 2.55e-101) tmp = t_0; elseif (im <= 1.05e-61) tmp = log(im) * (1.0 / log(base)); elseif (im <= 2.7e-50) tmp = t_0; else tmp = log(im) / log(base); end tmp_2 = tmp; end
code[re_, im_, base_] := Block[{t$95$0 = N[((-N[Log[N[(-1.0 / re), $MachinePrecision]], $MachinePrecision]) / N[Log[base], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 1.02e-203], t$95$0, If[LessEqual[im, 7.2e-165], N[(1.0 / N[(N[Log[base], $MachinePrecision] / N[Log[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.55e-101], t$95$0, If[LessEqual[im, 1.05e-61], N[(N[Log[im], $MachinePrecision] * N[(1.0 / N[Log[base], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.7e-50], t$95$0, N[(N[Log[im], $MachinePrecision] / N[Log[base], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-\log \left(\frac{-1}{re}\right)}{\log base}\\
\mathbf{if}\;im \leq 1.02 \cdot 10^{-203}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 7.2 \cdot 10^{-165}:\\
\;\;\;\;\frac{1}{\frac{\log base}{\log im}}\\
\mathbf{elif}\;im \leq 2.55 \cdot 10^{-101}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 1.05 \cdot 10^{-61}:\\
\;\;\;\;\log im \cdot \frac{1}{\log base}\\
\mathbf{elif}\;im \leq 2.7 \cdot 10^{-50}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\log im}{\log base}\\
\end{array}
\end{array}
if im < 1.02000000000000005e-203 or 7.19999999999999969e-165 < im < 2.5500000000000001e-101 or 1.05e-61 < im < 2.7e-50Initial program 51.2%
mul0-rgt51.2%
+-rgt-identity51.2%
metadata-eval51.2%
+-rgt-identity51.2%
times-frac51.3%
*-inverses51.3%
*-rgt-identity51.3%
hypot-def99.5%
Simplified99.5%
Taylor expanded in re around -inf 39.4%
associate-*r/39.4%
mul-1-neg39.4%
Simplified39.4%
if 1.02000000000000005e-203 < im < 7.19999999999999969e-165Initial program 56.6%
mul0-rgt56.6%
+-rgt-identity56.6%
metadata-eval56.6%
+-rgt-identity56.6%
times-frac56.6%
*-inverses56.6%
*-rgt-identity56.6%
hypot-def99.5%
Simplified99.5%
Taylor expanded in re around 0 25.4%
clear-num25.4%
inv-pow25.4%
Applied egg-rr25.4%
unpow-125.4%
Simplified25.4%
if 2.5500000000000001e-101 < im < 1.05e-61Initial program 83.3%
mul0-rgt83.3%
+-rgt-identity83.3%
metadata-eval83.3%
+-rgt-identity83.3%
times-frac83.5%
*-inverses83.5%
*-rgt-identity83.5%
hypot-def99.6%
Simplified99.6%
Taylor expanded in re around 0 48.6%
clear-num48.7%
associate-/r/48.8%
Applied egg-rr48.8%
if 2.7e-50 < im Initial program 46.7%
mul0-rgt46.7%
+-rgt-identity46.7%
metadata-eval46.7%
+-rgt-identity46.7%
times-frac46.6%
*-inverses46.6%
*-rgt-identity46.6%
hypot-def99.3%
Simplified99.3%
Taylor expanded in re around 0 79.0%
Final simplification50.6%
(FPCore (re im base)
:precision binary64
(let* ((t_0 (log (/ -1.0 re))) (t_1 (/ (- t_0) (log base))))
(if (<= im 1.02e-203)
t_1
(if (<= im 1.7e-168)
(/ 1.0 (/ (log base) (log im)))
(if (<= im 2.15e-102)
(* t_0 (/ -1.0 (log base)))
(if (<= im 2.35e-61)
(* (log im) (/ 1.0 (log base)))
(if (<= im 3.2e-50) t_1 (/ (log im) (log base)))))))))
double code(double re, double im, double base) {
double t_0 = log((-1.0 / re));
double t_1 = -t_0 / log(base);
double tmp;
if (im <= 1.02e-203) {
tmp = t_1;
} else if (im <= 1.7e-168) {
tmp = 1.0 / (log(base) / log(im));
} else if (im <= 2.15e-102) {
tmp = t_0 * (-1.0 / log(base));
} else if (im <= 2.35e-61) {
tmp = log(im) * (1.0 / log(base));
} else if (im <= 3.2e-50) {
tmp = t_1;
} else {
tmp = log(im) / log(base);
}
return tmp;
}
real(8) function code(re, im, base)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8), intent (in) :: base
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = log(((-1.0d0) / re))
t_1 = -t_0 / log(base)
if (im <= 1.02d-203) then
tmp = t_1
else if (im <= 1.7d-168) then
tmp = 1.0d0 / (log(base) / log(im))
else if (im <= 2.15d-102) then
tmp = t_0 * ((-1.0d0) / log(base))
else if (im <= 2.35d-61) then
tmp = log(im) * (1.0d0 / log(base))
else if (im <= 3.2d-50) then
tmp = t_1
else
tmp = log(im) / log(base)
end if
code = tmp
end function
public static double code(double re, double im, double base) {
double t_0 = Math.log((-1.0 / re));
double t_1 = -t_0 / Math.log(base);
double tmp;
if (im <= 1.02e-203) {
tmp = t_1;
} else if (im <= 1.7e-168) {
tmp = 1.0 / (Math.log(base) / Math.log(im));
} else if (im <= 2.15e-102) {
tmp = t_0 * (-1.0 / Math.log(base));
} else if (im <= 2.35e-61) {
tmp = Math.log(im) * (1.0 / Math.log(base));
} else if (im <= 3.2e-50) {
tmp = t_1;
} else {
tmp = Math.log(im) / Math.log(base);
}
return tmp;
}
def code(re, im, base): t_0 = math.log((-1.0 / re)) t_1 = -t_0 / math.log(base) tmp = 0 if im <= 1.02e-203: tmp = t_1 elif im <= 1.7e-168: tmp = 1.0 / (math.log(base) / math.log(im)) elif im <= 2.15e-102: tmp = t_0 * (-1.0 / math.log(base)) elif im <= 2.35e-61: tmp = math.log(im) * (1.0 / math.log(base)) elif im <= 3.2e-50: tmp = t_1 else: tmp = math.log(im) / math.log(base) return tmp
function code(re, im, base) t_0 = log(Float64(-1.0 / re)) t_1 = Float64(Float64(-t_0) / log(base)) tmp = 0.0 if (im <= 1.02e-203) tmp = t_1; elseif (im <= 1.7e-168) tmp = Float64(1.0 / Float64(log(base) / log(im))); elseif (im <= 2.15e-102) tmp = Float64(t_0 * Float64(-1.0 / log(base))); elseif (im <= 2.35e-61) tmp = Float64(log(im) * Float64(1.0 / log(base))); elseif (im <= 3.2e-50) tmp = t_1; else tmp = Float64(log(im) / log(base)); end return tmp end
function tmp_2 = code(re, im, base) t_0 = log((-1.0 / re)); t_1 = -t_0 / log(base); tmp = 0.0; if (im <= 1.02e-203) tmp = t_1; elseif (im <= 1.7e-168) tmp = 1.0 / (log(base) / log(im)); elseif (im <= 2.15e-102) tmp = t_0 * (-1.0 / log(base)); elseif (im <= 2.35e-61) tmp = log(im) * (1.0 / log(base)); elseif (im <= 3.2e-50) tmp = t_1; else tmp = log(im) / log(base); end tmp_2 = tmp; end
code[re_, im_, base_] := Block[{t$95$0 = N[Log[N[(-1.0 / re), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[((-t$95$0) / N[Log[base], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 1.02e-203], t$95$1, If[LessEqual[im, 1.7e-168], N[(1.0 / N[(N[Log[base], $MachinePrecision] / N[Log[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.15e-102], N[(t$95$0 * N[(-1.0 / N[Log[base], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.35e-61], N[(N[Log[im], $MachinePrecision] * N[(1.0 / N[Log[base], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3.2e-50], t$95$1, N[(N[Log[im], $MachinePrecision] / N[Log[base], $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\frac{-1}{re}\right)\\
t_1 := \frac{-t_0}{\log base}\\
\mathbf{if}\;im \leq 1.02 \cdot 10^{-203}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 1.7 \cdot 10^{-168}:\\
\;\;\;\;\frac{1}{\frac{\log base}{\log im}}\\
\mathbf{elif}\;im \leq 2.15 \cdot 10^{-102}:\\
\;\;\;\;t_0 \cdot \frac{-1}{\log base}\\
\mathbf{elif}\;im \leq 2.35 \cdot 10^{-61}:\\
\;\;\;\;\log im \cdot \frac{1}{\log base}\\
\mathbf{elif}\;im \leq 3.2 \cdot 10^{-50}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\log im}{\log base}\\
\end{array}
\end{array}
if im < 1.02000000000000005e-203 or 2.3499999999999998e-61 < im < 3.2e-50Initial program 51.5%
mul0-rgt51.5%
+-rgt-identity51.5%
metadata-eval51.5%
+-rgt-identity51.5%
times-frac51.6%
*-inverses51.6%
*-rgt-identity51.6%
hypot-def99.5%
Simplified99.5%
Taylor expanded in re around -inf 39.5%
associate-*r/39.5%
mul-1-neg39.5%
Simplified39.5%
if 1.02000000000000005e-203 < im < 1.70000000000000011e-168Initial program 56.6%
mul0-rgt56.6%
+-rgt-identity56.6%
metadata-eval56.6%
+-rgt-identity56.6%
times-frac56.6%
*-inverses56.6%
*-rgt-identity56.6%
hypot-def99.5%
Simplified99.5%
Taylor expanded in re around 0 25.4%
clear-num25.4%
inv-pow25.4%
Applied egg-rr25.4%
unpow-125.4%
Simplified25.4%
if 1.70000000000000011e-168 < im < 2.1499999999999999e-102Initial program 46.0%
mul0-rgt46.0%
+-rgt-identity46.0%
metadata-eval46.0%
+-rgt-identity46.0%
times-frac46.0%
*-inverses46.0%
*-rgt-identity46.0%
hypot-def99.7%
Simplified99.7%
clear-num99.3%
associate-/r/99.7%
Applied egg-rr99.7%
add-exp-log54.6%
log-rec54.6%
Applied egg-rr54.6%
Taylor expanded in re around -inf 15.8%
mul-1-neg15.8%
*-commutative15.8%
distribute-rgt-neg-in15.8%
exp-neg15.8%
rem-exp-log38.0%
Simplified38.0%
if 2.1499999999999999e-102 < im < 2.3499999999999998e-61Initial program 83.3%
mul0-rgt83.3%
+-rgt-identity83.3%
metadata-eval83.3%
+-rgt-identity83.3%
times-frac83.5%
*-inverses83.5%
*-rgt-identity83.5%
hypot-def99.6%
Simplified99.6%
Taylor expanded in re around 0 48.6%
clear-num48.7%
associate-/r/48.8%
Applied egg-rr48.8%
if 3.2e-50 < im Initial program 46.7%
mul0-rgt46.7%
+-rgt-identity46.7%
metadata-eval46.7%
+-rgt-identity46.7%
times-frac46.6%
*-inverses46.6%
*-rgt-identity46.6%
hypot-def99.3%
Simplified99.3%
Taylor expanded in re around 0 79.0%
Final simplification50.6%
(FPCore (re im base) :precision binary64 (* (log base) (log im)))
double code(double re, double im, double base) {
return log(base) * log(im);
}
real(8) function code(re, im, base)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8), intent (in) :: base
code = log(base) * log(im)
end function
public static double code(double re, double im, double base) {
return Math.log(base) * Math.log(im);
}
def code(re, im, base): return math.log(base) * math.log(im)
function code(re, im, base) return Float64(log(base) * log(im)) end
function tmp = code(re, im, base) tmp = log(base) * log(im); end
code[re_, im_, base_] := N[(N[Log[base], $MachinePrecision] * N[Log[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\log base \cdot \log im
\end{array}
Initial program 51.6%
mul0-rgt51.6%
+-rgt-identity51.6%
metadata-eval51.6%
+-rgt-identity51.6%
times-frac51.7%
*-inverses51.7%
*-rgt-identity51.7%
hypot-def99.4%
Simplified99.4%
Taylor expanded in re around 0 27.9%
log1p-expm1-u27.6%
Applied egg-rr27.6%
log1p-expm1-u27.9%
div-inv27.9%
add-exp-log14.4%
neg-log14.4%
add-sqr-sqrt0.0%
sqrt-unprod2.6%
sqr-neg2.6%
sqrt-unprod2.6%
add-sqr-sqrt2.6%
add-exp-log5.0%
Applied egg-rr5.0%
Final simplification5.0%
(FPCore (re im base) :precision binary64 (/ (log im) (log base)))
double code(double re, double im, double base) {
return log(im) / log(base);
}
real(8) function code(re, im, base)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8), intent (in) :: base
code = log(im) / log(base)
end function
public static double code(double re, double im, double base) {
return Math.log(im) / Math.log(base);
}
def code(re, im, base): return math.log(im) / math.log(base)
function code(re, im, base) return Float64(log(im) / log(base)) end
function tmp = code(re, im, base) tmp = log(im) / log(base); end
code[re_, im_, base_] := N[(N[Log[im], $MachinePrecision] / N[Log[base], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\log im}{\log base}
\end{array}
Initial program 51.6%
mul0-rgt51.6%
+-rgt-identity51.6%
metadata-eval51.6%
+-rgt-identity51.6%
times-frac51.7%
*-inverses51.7%
*-rgt-identity51.7%
hypot-def99.4%
Simplified99.4%
Taylor expanded in re around 0 27.9%
Final simplification27.9%
(FPCore (re im base) :precision binary64 (log im))
double code(double re, double im, double base) {
return log(im);
}
real(8) function code(re, im, base)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8), intent (in) :: base
code = log(im)
end function
public static double code(double re, double im, double base) {
return Math.log(im);
}
def code(re, im, base): return math.log(im)
function code(re, im, base) return log(im) end
function tmp = code(re, im, base) tmp = log(im); end
code[re_, im_, base_] := N[Log[im], $MachinePrecision]
\begin{array}{l}
\\
\log im
\end{array}
Initial program 51.6%
mul0-rgt51.6%
+-rgt-identity51.6%
metadata-eval51.6%
+-rgt-identity51.6%
times-frac51.7%
*-inverses51.7%
*-rgt-identity51.7%
hypot-def99.4%
Simplified99.4%
Taylor expanded in re around 0 27.9%
clear-num27.9%
associate-/r/27.9%
Applied egg-rr27.9%
inv-pow27.9%
metadata-eval27.9%
pow-div27.9%
pow127.9%
*-commutative27.9%
associate-*r/28.0%
frac-2neg28.0%
*-commutative28.0%
add-sqr-sqrt28.0%
sqrt-unprod28.0%
unpow228.0%
associate-*r*27.9%
Applied egg-rr4.3%
distribute-lft-neg-in4.3%
*-commutative4.3%
associate-/l*4.3%
*-inverses4.3%
/-rgt-identity4.3%
Simplified4.3%
Final simplification4.3%
herbie shell --seed 2023174
(FPCore (re im base)
:name "math.log/2 on complex, real part"
:precision binary64
(/ (+ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (atan2 im re) 0.0)) (+ (* (log base) (log base)) (* 0.0 0.0))))