Math FPCore C Fortran Java Python Julia MATLAB Wolfram TeX \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
\]
↓
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
\]
(FPCore (re im)
:precision binary64
(* (* 0.5 (cos re)) (+ (exp (- im)) (exp im)))) ↓
(FPCore (re im)
:precision binary64
(* (* 0.5 (cos re)) (+ (exp (- im)) (exp im)))) double code(double re, double im) {
return (0.5 * cos(re)) * (exp(-im) + exp(im));
}
↓
double code(double re, double im) {
return (0.5 * cos(re)) * (exp(-im) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp(-im) + exp(im))
end function
↓
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp(-im) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im));
}
↓
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im));
}
def code(re, im):
return (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))
↓
def code(re, im):
return (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))
function code(re, im)
return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im)))
end
↓
function code(re, im)
return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im)))
end
function tmp = code(re, im)
tmp = (0.5 * cos(re)) * (exp(-im) + exp(im));
end
↓
function tmp = code(re, im)
tmp = (0.5 * cos(re)) * (exp(-im) + exp(im));
end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
↓
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
↓
\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
Alternatives Alternative 1 Accuracy 93.7% Cost 14096
\[\begin{array}{l}
t_0 := e^{-im} + e^{im}\\
t_1 := 0.5 \cdot \left(im \cdot im\right)\\
t_2 := \cos re \cdot t_1\\
\mathbf{if}\;im \leq -5.9 \cdot 10^{+152}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;im \leq -0.55:\\
\;\;\;\;0.5 \cdot t_0\\
\mathbf{elif}\;im \leq 2.3:\\
\;\;\;\;\cos re \cdot \left(t_1 + 1\right)\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;t_0 \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\]
Alternative 2 Accuracy 93.2% Cost 13712
\[\begin{array}{l}
t_0 := 0.5 \cdot \left(im \cdot im\right)\\
t_1 := \cos re \cdot t_0\\
t_2 := 0.5 \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{if}\;im \leq -5.9 \cdot 10^{+152}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -0.55:\\
\;\;\;\;t_2\\
\mathbf{elif}\;im \leq 2.3:\\
\;\;\;\;\cos re \cdot \left(t_0 + 1\right)\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
Alternative 3 Accuracy 85.5% Cost 7956
\[\begin{array}{l}
t_0 := 0.5 \cdot \left(im \cdot im\right)\\
t_1 := \cos re \cdot t_0\\
t_2 := \frac{{im}^{4} \cdot 0.25 + -1}{t_0 + -1}\\
\mathbf{if}\;im \leq -5.9 \cdot 10^{+152}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -1.2 \cdot 10^{+77}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;im \leq -7200:\\
\;\;\;\;\left(im \cdot im\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\
\mathbf{elif}\;im \leq 3.3 \cdot 10^{+75}:\\
\;\;\;\;\cos re \cdot \left(t_0 + 1\right)\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
Alternative 4 Accuracy 79.9% Cost 7760
\[\begin{array}{l}
t_0 := 0.5 \cdot \left(im \cdot im\right)\\
t_1 := \cos re \cdot t_0\\
\mathbf{if}\;im \leq -2.1 \cdot 10^{+154}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -780:\\
\;\;\;\;\left(im \cdot im\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\
\mathbf{elif}\;im \leq 4.5 \cdot 10^{+22}:\\
\;\;\;\;\cos re \cdot \left(t_0 + 1\right)\\
\mathbf{elif}\;im \leq 6.6 \cdot 10^{+152}:\\
\;\;\;\;\mathsf{fma}\left(0.5, im \cdot im, 1\right) \cdot \left(1 + \left(re \cdot re\right) \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
Alternative 5 Accuracy 79.7% Cost 7376
\[\begin{array}{l}
t_0 := \cos re \cdot \left(0.5 \cdot \left(im \cdot im\right)\right)\\
t_1 := \left(im \cdot im\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\
\mathbf{if}\;im \leq -2.1 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -780:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 4.1 \cdot 10^{+14}:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 6.6 \cdot 10^{+152}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
Alternative 6 Accuracy 79.7% Cost 7376
\[\begin{array}{l}
t_0 := 0.5 \cdot \left(im \cdot im\right)\\
t_1 := \cos re \cdot t_0\\
t_2 := \left(im \cdot im\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\
\mathbf{if}\;im \leq -2.1 \cdot 10^{+154}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -2300:\\
\;\;\;\;t_2\\
\mathbf{elif}\;im \leq 6 \cdot 10^{+22}:\\
\;\;\;\;\cos re + t_0\\
\mathbf{elif}\;im \leq 6.6 \cdot 10^{+152}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
Alternative 7 Accuracy 79.9% Cost 7376
\[\begin{array}{l}
t_0 := 0.5 \cdot \left(im \cdot im\right)\\
t_1 := \cos re \cdot t_0\\
t_2 := \left(im \cdot im\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\
\mathbf{if}\;im \leq -2.1 \cdot 10^{+154}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -780:\\
\;\;\;\;t_2\\
\mathbf{elif}\;im \leq 4.5 \cdot 10^{+22}:\\
\;\;\;\;\cos re \cdot \left(t_0 + 1\right)\\
\mathbf{elif}\;im \leq 6.6 \cdot 10^{+152}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
Alternative 8 Accuracy 73.6% Cost 6728
\[\begin{array}{l}
t_0 := \left(im \cdot im\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\
\mathbf{if}\;im \leq -780:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 4.1 \cdot 10^{+14}:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 2.7 \cdot 10^{+193}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(im \cdot im\right) + 1\\
\end{array}
\]
Alternative 9 Accuracy 48.4% Cost 1100
\[\begin{array}{l}
t_0 := \left(im \cdot im\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\
\mathbf{if}\;re \leq -7.8 \cdot 10^{+89}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;re \leq 4.6 \cdot 10^{+136}:\\
\;\;\;\;0.5 \cdot \left(im \cdot im\right) + 1\\
\mathbf{elif}\;re \leq 2.36 \cdot 10^{+213}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;0.25 + \left(re \cdot re\right) \cdot 0.25\\
\end{array}
\]
Alternative 10 Accuracy 47.4% Cost 716
\[\begin{array}{l}
t_0 := im \cdot \left(0.5 \cdot im\right)\\
\mathbf{if}\;im \leq -1.85 \cdot 10^{+158}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -220:\\
\;\;\;\;0.25 + \left(re \cdot re\right) \cdot 0.25\\
\mathbf{elif}\;im \leq 1.4:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
Alternative 11 Accuracy 47.5% Cost 712
\[\begin{array}{l}
\mathbf{if}\;im \leq -1.85 \cdot 10^{+158}:\\
\;\;\;\;im \cdot \left(0.5 \cdot im\right)\\
\mathbf{elif}\;im \leq -250:\\
\;\;\;\;0.25 + \left(re \cdot re\right) \cdot 0.25\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(im \cdot im\right) + 1\\
\end{array}
\]
Alternative 12 Accuracy 46.1% Cost 585
\[\begin{array}{l}
\mathbf{if}\;im \leq -1.75 \cdot 10^{+19} \lor \neg \left(im \leq 1.3\right):\\
\;\;\;\;im \cdot \left(0.5 \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\]
Alternative 13 Accuracy 8.0% Cost 64
\[0.25
\]
Alternative 14 Accuracy 27.6% Cost 64
\[1
\]