| Alternative 1 | |
|---|---|
| Error | 7.2 |
| Cost | 20040 |
(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))))
(FPCore (re im base)
:precision binary64
(if (<= im 6.5e-159)
(/ (log (- re)) (log base))
(if (<= im 4.6e+70)
(*
(/ -1.0 (log base))
(/ (log (+ (* re re) (* im im))) (* (/ -2.0 (log base)) (log base))))
(log (pow im (/ 1.0 (log base)))))))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));
}
double code(double re, double im, double base) {
double tmp;
if (im <= 6.5e-159) {
tmp = log(-re) / log(base);
} else if (im <= 4.6e+70) {
tmp = (-1.0 / log(base)) * (log(((re * re) + (im * im))) / ((-2.0 / log(base)) * log(base)));
} else {
tmp = log(pow(im, (1.0 / 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
code = ((log(sqrt(((re * re) + (im * im)))) * log(base)) + (atan2(im, re) * 0.0d0)) / ((log(base) * log(base)) + (0.0d0 * 0.0d0))
end function
real(8) function code(re, im, base)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8), intent (in) :: base
real(8) :: tmp
if (im <= 6.5d-159) then
tmp = log(-re) / log(base)
else if (im <= 4.6d+70) then
tmp = ((-1.0d0) / log(base)) * (log(((re * re) + (im * im))) / (((-2.0d0) / log(base)) * log(base)))
else
tmp = log((im ** (1.0d0 / log(base))))
end if
code = tmp
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));
}
public static double code(double re, double im, double base) {
double tmp;
if (im <= 6.5e-159) {
tmp = Math.log(-re) / Math.log(base);
} else if (im <= 4.6e+70) {
tmp = (-1.0 / Math.log(base)) * (Math.log(((re * re) + (im * im))) / ((-2.0 / Math.log(base)) * Math.log(base)));
} else {
tmp = Math.log(Math.pow(im, (1.0 / Math.log(base))));
}
return tmp;
}
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))
def code(re, im, base): tmp = 0 if im <= 6.5e-159: tmp = math.log(-re) / math.log(base) elif im <= 4.6e+70: tmp = (-1.0 / math.log(base)) * (math.log(((re * re) + (im * im))) / ((-2.0 / math.log(base)) * math.log(base))) else: tmp = math.log(math.pow(im, (1.0 / math.log(base)))) return tmp
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 code(re, im, base) tmp = 0.0 if (im <= 6.5e-159) tmp = Float64(log(Float64(-re)) / log(base)); elseif (im <= 4.6e+70) tmp = Float64(Float64(-1.0 / log(base)) * Float64(log(Float64(Float64(re * re) + Float64(im * im))) / Float64(Float64(-2.0 / log(base)) * log(base)))); else tmp = log((im ^ Float64(1.0 / log(base)))); end return tmp 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
function tmp_2 = code(re, im, base) tmp = 0.0; if (im <= 6.5e-159) tmp = log(-re) / log(base); elseif (im <= 4.6e+70) tmp = (-1.0 / log(base)) * (log(((re * re) + (im * im))) / ((-2.0 / log(base)) * log(base))); else tmp = log((im ^ (1.0 / log(base)))); end tmp_2 = tmp; 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]
code[re_, im_, base_] := If[LessEqual[im, 6.5e-159], N[(N[Log[(-re)], $MachinePrecision] / N[Log[base], $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.6e+70], N[(N[(-1.0 / N[Log[base], $MachinePrecision]), $MachinePrecision] * N[(N[Log[N[(N[(re * re), $MachinePrecision] + N[(im * im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[(-2.0 / N[Log[base], $MachinePrecision]), $MachinePrecision] * N[Log[base], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Log[N[Power[im, N[(1.0 / N[Log[base], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]
\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}
\begin{array}{l}
\mathbf{if}\;im \leq 6.5 \cdot 10^{-159}:\\
\;\;\;\;\frac{\log \left(-re\right)}{\log base}\\
\mathbf{elif}\;im \leq 4.6 \cdot 10^{+70}:\\
\;\;\;\;\frac{-1}{\log base} \cdot \frac{\log \left(re \cdot re + im \cdot im\right)}{\frac{-2}{\log base} \cdot \log base}\\
\mathbf{else}:\\
\;\;\;\;\log \left({im}^{\left(\frac{1}{\log base}\right)}\right)\\
\end{array}
Results
if im < 6.5000000000000001e-159Initial program 32.3
Simplified32.3
[Start]32.3 | \[ \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}
\] |
|---|---|
rational_best-simplify-65 [=>]32.3 | \[ \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base + 0 \cdot 0} + \frac{\tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}}
\] |
rational_best-simplify-17 [=>]32.3 | \[ \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base + 0 \cdot 0} + \frac{\color{blue}{\tan^{-1}_* \frac{im}{re} - \tan^{-1}_* \frac{im}{re}}}{\log base \cdot \log base + 0 \cdot 0}
\] |
rational_best-simplify-5 [=>]32.3 | \[ \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base + 0 \cdot 0} + \frac{\color{blue}{0}}{\log base \cdot \log base + 0 \cdot 0}
\] |
rational_best-simplify-64 [=>]32.3 | \[ \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + 0}{\log base \cdot \log base + 0 \cdot 0}}
\] |
trig-simplify-13 [=>]32.3 | \[ \frac{\color{blue}{0 + \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}}{\log base \cdot \log base + 0 \cdot 0}
\] |
rational_best-simplify-6 [=>]32.3 | \[ \frac{\color{blue}{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}}{\log base \cdot \log base + 0 \cdot 0}
\] |
metadata-eval [=>]32.3 | \[ \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base + \color{blue}{0}}
\] |
rational_best-simplify-3 [=>]32.3 | \[ \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\color{blue}{0 + \log base \cdot \log base}}
\] |
rational_best-simplify-6 [=>]32.3 | \[ \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\color{blue}{\log base \cdot \log base}}
\] |
rational_best-simplify-90 [=>]32.3 | \[ \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base} + \frac{0}{\log base}}
\] |
rational_best-simplify-64 [=>]32.3 | \[ \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) + 0}{\log base}}
\] |
rational_best-simplify-3 [=>]32.3 | \[ \frac{\color{blue}{0 + \log \left(\sqrt{re \cdot re + im \cdot im}\right)}}{\log base}
\] |
Taylor expanded in re around -inf 4.6
Simplified4.6
[Start]4.6 | \[ \frac{\log \left(-1 \cdot re\right)}{\log base}
\] |
|---|---|
rational_best-simplify-1 [=>]4.6 | \[ \frac{\log \color{blue}{\left(re \cdot -1\right)}}{\log base}
\] |
rational_best-simplify-11 [<=]4.6 | \[ \frac{\log \color{blue}{\left(-re\right)}}{\log base}
\] |
if 6.5000000000000001e-159 < im < 4.59999999999999987e70Initial program 11.9
Simplified11.9
[Start]11.9 | \[ \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}
\] |
|---|---|
rational_best-simplify-65 [=>]11.9 | \[ \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base + 0 \cdot 0} + \frac{\tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}}
\] |
rational_best-simplify-17 [=>]11.9 | \[ \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base + 0 \cdot 0} + \frac{\color{blue}{\tan^{-1}_* \frac{im}{re} - \tan^{-1}_* \frac{im}{re}}}{\log base \cdot \log base + 0 \cdot 0}
\] |
rational_best-simplify-5 [=>]11.9 | \[ \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base + 0 \cdot 0} + \frac{\color{blue}{0}}{\log base \cdot \log base + 0 \cdot 0}
\] |
rational_best-simplify-64 [=>]11.9 | \[ \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + 0}{\log base \cdot \log base + 0 \cdot 0}}
\] |
metadata-eval [=>]11.9 | \[ \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + 0}{\log base \cdot \log base + \color{blue}{0}}
\] |
rational_best-simplify-3 [=>]11.9 | \[ \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + 0}{\color{blue}{0 + \log base \cdot \log base}}
\] |
rational_best-simplify-6 [=>]11.9 | \[ \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + 0}{\color{blue}{\log base \cdot \log base}}
\] |
Applied egg-rr11.8
Applied egg-rr11.8
Simplified11.8
[Start]11.8 | \[ \frac{\frac{1}{\log base} \cdot \frac{\log \left(re \cdot re + im \cdot im\right)}{\frac{-2}{\log base}}}{-\log base}
\] |
|---|---|
rational_best-simplify-60 [=>]11.8 | \[ \color{blue}{\left(-\frac{1}{\log base}\right) \cdot \frac{\frac{\log \left(re \cdot re + im \cdot im\right)}{\frac{-2}{\log base}}}{\log base}}
\] |
rational_best-simplify-13 [=>]11.8 | \[ \color{blue}{\frac{\frac{1}{\log base}}{-1}} \cdot \frac{\frac{\log \left(re \cdot re + im \cdot im\right)}{\frac{-2}{\log base}}}{\log base}
\] |
metadata-eval [<=]11.8 | \[ \frac{\frac{\color{blue}{\frac{4}{4}}}{\log base}}{-1} \cdot \frac{\frac{\log \left(re \cdot re + im \cdot im\right)}{\frac{-2}{\log base}}}{\log base}
\] |
rational_best-simplify-54 [<=]11.8 | \[ \frac{\color{blue}{\frac{4}{4 \cdot \log base}}}{-1} \cdot \frac{\frac{\log \left(re \cdot re + im \cdot im\right)}{\frac{-2}{\log base}}}{\log base}
\] |
rational_best-simplify-1 [<=]11.8 | \[ \frac{\frac{4}{\color{blue}{\log base \cdot 4}}}{-1} \cdot \frac{\frac{\log \left(re \cdot re + im \cdot im\right)}{\frac{-2}{\log base}}}{\log base}
\] |
rational_best-simplify-54 [=>]11.8 | \[ \frac{\color{blue}{\frac{\frac{4}{\log base}}{4}}}{-1} \cdot \frac{\frac{\log \left(re \cdot re + im \cdot im\right)}{\frac{-2}{\log base}}}{\log base}
\] |
rational_best-simplify-49 [<=]11.8 | \[ \color{blue}{\frac{\frac{\frac{4}{\log base}}{-1}}{4}} \cdot \frac{\frac{\log \left(re \cdot re + im \cdot im\right)}{\frac{-2}{\log base}}}{\log base}
\] |
rational_best-simplify-49 [=>]11.8 | \[ \frac{\color{blue}{\frac{\frac{4}{-1}}{\log base}}}{4} \cdot \frac{\frac{\log \left(re \cdot re + im \cdot im\right)}{\frac{-2}{\log base}}}{\log base}
\] |
metadata-eval [=>]11.8 | \[ \frac{\frac{\color{blue}{-4}}{\log base}}{4} \cdot \frac{\frac{\log \left(re \cdot re + im \cdot im\right)}{\frac{-2}{\log base}}}{\log base}
\] |
rational_best-simplify-54 [<=]11.8 | \[ \color{blue}{\frac{-4}{\log base \cdot 4}} \cdot \frac{\frac{\log \left(re \cdot re + im \cdot im\right)}{\frac{-2}{\log base}}}{\log base}
\] |
rational_best-simplify-1 [=>]11.8 | \[ \frac{-4}{\color{blue}{4 \cdot \log base}} \cdot \frac{\frac{\log \left(re \cdot re + im \cdot im\right)}{\frac{-2}{\log base}}}{\log base}
\] |
rational_best-simplify-54 [=>]11.8 | \[ \color{blue}{\frac{\frac{-4}{4}}{\log base}} \cdot \frac{\frac{\log \left(re \cdot re + im \cdot im\right)}{\frac{-2}{\log base}}}{\log base}
\] |
metadata-eval [=>]11.8 | \[ \frac{\color{blue}{-1}}{\log base} \cdot \frac{\frac{\log \left(re \cdot re + im \cdot im\right)}{\frac{-2}{\log base}}}{\log base}
\] |
rational_best-simplify-53 [=>]11.8 | \[ \frac{-1}{\log base} \cdot \color{blue}{\frac{\log \left(re \cdot re + im \cdot im\right)}{\frac{-2}{\log base} \cdot \log base}}
\] |
if 4.59999999999999987e70 < im Initial program 46.4
Simplified46.4
[Start]46.4 | \[ \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}
\] |
|---|---|
rational_best-simplify-65 [=>]46.4 | \[ \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base + 0 \cdot 0} + \frac{\tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}}
\] |
rational_best-simplify-17 [=>]46.4 | \[ \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base + 0 \cdot 0} + \frac{\color{blue}{\tan^{-1}_* \frac{im}{re} - \tan^{-1}_* \frac{im}{re}}}{\log base \cdot \log base + 0 \cdot 0}
\] |
rational_best-simplify-5 [=>]46.4 | \[ \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base + 0 \cdot 0} + \frac{\color{blue}{0}}{\log base \cdot \log base + 0 \cdot 0}
\] |
rational_best-simplify-64 [=>]46.4 | \[ \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + 0}{\log base \cdot \log base + 0 \cdot 0}}
\] |
trig-simplify-13 [=>]46.4 | \[ \frac{\color{blue}{0 + \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}}{\log base \cdot \log base + 0 \cdot 0}
\] |
rational_best-simplify-6 [=>]46.4 | \[ \frac{\color{blue}{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}}{\log base \cdot \log base + 0 \cdot 0}
\] |
metadata-eval [=>]46.4 | \[ \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base + \color{blue}{0}}
\] |
rational_best-simplify-3 [=>]46.4 | \[ \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\color{blue}{0 + \log base \cdot \log base}}
\] |
rational_best-simplify-6 [=>]46.4 | \[ \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\color{blue}{\log base \cdot \log base}}
\] |
rational_best-simplify-90 [=>]46.4 | \[ \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base} + \frac{0}{\log base}}
\] |
rational_best-simplify-64 [=>]46.4 | \[ \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) + 0}{\log base}}
\] |
rational_best-simplify-3 [=>]46.4 | \[ \frac{\color{blue}{0 + \log \left(\sqrt{re \cdot re + im \cdot im}\right)}}{\log base}
\] |
Taylor expanded in re around 0 6.6
Applied egg-rr6.7
Applied egg-rr6.7
Final simplification7.3
| Alternative 1 | |
|---|---|
| Error | 7.2 |
| Cost | 20040 |
| Alternative 2 | |
|---|---|
| Error | 7.3 |
| Cost | 19720 |
| Alternative 3 | |
|---|---|
| Error | 7.2 |
| Cost | 13768 |
| Alternative 4 | |
|---|---|
| Error | 10.3 |
| Cost | 13188 |
| Alternative 5 | |
|---|---|
| Error | 31.5 |
| Cost | 12992 |
herbie shell --seed 2023100
(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))))