
(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));
}
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));
}
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 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]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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));
}
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));
}
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 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]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
\end{array}
(FPCore (re im) :precision binary64 (* (cos re) (fma 0.5 (exp im) (/ 0.5 (exp im)))))
double code(double re, double im) {
return cos(re) * fma(0.5, exp(im), (0.5 / exp(im)));
}
function code(re, im) return Float64(cos(re) * fma(0.5, exp(im), Float64(0.5 / exp(im)))) end
code[re_, im_] := N[(N[Cos[re], $MachinePrecision] * N[(0.5 * N[Exp[im], $MachinePrecision] + N[(0.5 / N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)
\end{array}
Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-lft-in100.0%
distribute-lft-in100.0%
distribute-rgt-in100.0%
*-commutative100.0%
fma-def100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (re im) :precision binary64 (* (* (cos re) 0.5) (+ (exp im) (exp (- im)))))
double code(double re, double im) {
return (cos(re) * 0.5) * (exp(im) + exp(-im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (cos(re) * 0.5d0) * (exp(im) + exp(-im))
end function
public static double code(double re, double im) {
return (Math.cos(re) * 0.5) * (Math.exp(im) + Math.exp(-im));
}
def code(re, im): return (math.cos(re) * 0.5) * (math.exp(im) + math.exp(-im))
function code(re, im) return Float64(Float64(cos(re) * 0.5) * Float64(exp(im) + exp(Float64(-im)))) end
function tmp = code(re, im) tmp = (cos(re) * 0.5) * (exp(im) + exp(-im)); end
code[re_, im_] := N[(N[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\cos re \cdot 0.5\right) \cdot \left(e^{im} + e^{-im}\right)
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (* (cos re) (* 0.5 im))))
(t_1 (* 0.5 (+ (exp im) (exp (- im))))))
(if (<= im -1.4e+159)
t_0
(if (<= im -0.057)
t_1
(if (<= im 0.0145)
(* (* (cos re) 0.5) (+ 2.0 (* im im)))
(if (<= im 8e+151) t_1 t_0))))))
double code(double re, double im) {
double t_0 = im * (cos(re) * (0.5 * im));
double t_1 = 0.5 * (exp(im) + exp(-im));
double tmp;
if (im <= -1.4e+159) {
tmp = t_0;
} else if (im <= -0.057) {
tmp = t_1;
} else if (im <= 0.0145) {
tmp = (cos(re) * 0.5) * (2.0 + (im * im));
} else if (im <= 8e+151) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = im * (cos(re) * (0.5d0 * im))
t_1 = 0.5d0 * (exp(im) + exp(-im))
if (im <= (-1.4d+159)) then
tmp = t_0
else if (im <= (-0.057d0)) then
tmp = t_1
else if (im <= 0.0145d0) then
tmp = (cos(re) * 0.5d0) * (2.0d0 + (im * im))
else if (im <= 8d+151) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = im * (Math.cos(re) * (0.5 * im));
double t_1 = 0.5 * (Math.exp(im) + Math.exp(-im));
double tmp;
if (im <= -1.4e+159) {
tmp = t_0;
} else if (im <= -0.057) {
tmp = t_1;
} else if (im <= 0.0145) {
tmp = (Math.cos(re) * 0.5) * (2.0 + (im * im));
} else if (im <= 8e+151) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = im * (math.cos(re) * (0.5 * im)) t_1 = 0.5 * (math.exp(im) + math.exp(-im)) tmp = 0 if im <= -1.4e+159: tmp = t_0 elif im <= -0.057: tmp = t_1 elif im <= 0.0145: tmp = (math.cos(re) * 0.5) * (2.0 + (im * im)) elif im <= 8e+151: tmp = t_1 else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(im * Float64(cos(re) * Float64(0.5 * im))) t_1 = Float64(0.5 * Float64(exp(im) + exp(Float64(-im)))) tmp = 0.0 if (im <= -1.4e+159) tmp = t_0; elseif (im <= -0.057) tmp = t_1; elseif (im <= 0.0145) tmp = Float64(Float64(cos(re) * 0.5) * Float64(2.0 + Float64(im * im))); elseif (im <= 8e+151) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = im * (cos(re) * (0.5 * im)); t_1 = 0.5 * (exp(im) + exp(-im)); tmp = 0.0; if (im <= -1.4e+159) tmp = t_0; elseif (im <= -0.057) tmp = t_1; elseif (im <= 0.0145) tmp = (cos(re) * 0.5) * (2.0 + (im * im)); elseif (im <= 8e+151) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(N[Cos[re], $MachinePrecision] * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.4e+159], t$95$0, If[LessEqual[im, -0.057], t$95$1, If[LessEqual[im, 0.0145], N[(N[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 8e+151], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := im \cdot \left(\cos re \cdot \left(0.5 \cdot im\right)\right)\\
t_1 := 0.5 \cdot \left(e^{im} + e^{-im}\right)\\
\mathbf{if}\;im \leq -1.4 \cdot 10^{+159}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -0.057:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 0.0145:\\
\;\;\;\;\left(\cos re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\
\mathbf{elif}\;im \leq 8 \cdot 10^{+151}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -1.4000000000000001e159 or 8.00000000000000014e151 < im Initial program 100.0%
Taylor expanded in im around 0 98.6%
unpow298.6%
Simplified98.6%
Taylor expanded in im around inf 98.6%
*-commutative98.6%
associate-*r*98.6%
*-commutative98.6%
unpow298.6%
associate-*l*98.6%
associate-*l*98.6%
Simplified98.6%
if -1.4000000000000001e159 < im < -0.0570000000000000021 or 0.0145000000000000007 < im < 8.00000000000000014e151Initial program 100.0%
Taylor expanded in re around 0 82.6%
if -0.0570000000000000021 < im < 0.0145000000000000007Initial program 100.0%
Taylor expanded in im around 0 99.6%
unpow299.6%
Simplified99.6%
Final simplification94.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (+ (exp im) (exp (- im)))))
(t_1 (* (pow im 4.0) (* (cos re) 0.041666666666666664))))
(if (<= im -5.1e+82)
t_1
(if (<= im -0.088)
t_0
(if (<= im 0.0145)
(* (* (cos re) 0.5) (+ 2.0 (* im im)))
(if (<= im 1.15e+73) t_0 t_1))))))
double code(double re, double im) {
double t_0 = 0.5 * (exp(im) + exp(-im));
double t_1 = pow(im, 4.0) * (cos(re) * 0.041666666666666664);
double tmp;
if (im <= -5.1e+82) {
tmp = t_1;
} else if (im <= -0.088) {
tmp = t_0;
} else if (im <= 0.0145) {
tmp = (cos(re) * 0.5) * (2.0 + (im * im));
} else if (im <= 1.15e+73) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 * (exp(im) + exp(-im))
t_1 = (im ** 4.0d0) * (cos(re) * 0.041666666666666664d0)
if (im <= (-5.1d+82)) then
tmp = t_1
else if (im <= (-0.088d0)) then
tmp = t_0
else if (im <= 0.0145d0) then
tmp = (cos(re) * 0.5d0) * (2.0d0 + (im * im))
else if (im <= 1.15d+73) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * (Math.exp(im) + Math.exp(-im));
double t_1 = Math.pow(im, 4.0) * (Math.cos(re) * 0.041666666666666664);
double tmp;
if (im <= -5.1e+82) {
tmp = t_1;
} else if (im <= -0.088) {
tmp = t_0;
} else if (im <= 0.0145) {
tmp = (Math.cos(re) * 0.5) * (2.0 + (im * im));
} else if (im <= 1.15e+73) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * (math.exp(im) + math.exp(-im)) t_1 = math.pow(im, 4.0) * (math.cos(re) * 0.041666666666666664) tmp = 0 if im <= -5.1e+82: tmp = t_1 elif im <= -0.088: tmp = t_0 elif im <= 0.0145: tmp = (math.cos(re) * 0.5) * (2.0 + (im * im)) elif im <= 1.15e+73: tmp = t_0 else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(exp(im) + exp(Float64(-im)))) t_1 = Float64((im ^ 4.0) * Float64(cos(re) * 0.041666666666666664)) tmp = 0.0 if (im <= -5.1e+82) tmp = t_1; elseif (im <= -0.088) tmp = t_0; elseif (im <= 0.0145) tmp = Float64(Float64(cos(re) * 0.5) * Float64(2.0 + Float64(im * im))); elseif (im <= 1.15e+73) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (exp(im) + exp(-im)); t_1 = (im ^ 4.0) * (cos(re) * 0.041666666666666664); tmp = 0.0; if (im <= -5.1e+82) tmp = t_1; elseif (im <= -0.088) tmp = t_0; elseif (im <= 0.0145) tmp = (cos(re) * 0.5) * (2.0 + (im * im)); elseif (im <= 1.15e+73) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[im, 4.0], $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -5.1e+82], t$95$1, If[LessEqual[im, -0.088], t$95$0, If[LessEqual[im, 0.0145], N[(N[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.15e+73], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{im} + e^{-im}\right)\\
t_1 := {im}^{4} \cdot \left(\cos re \cdot 0.041666666666666664\right)\\
\mathbf{if}\;im \leq -5.1 \cdot 10^{+82}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -0.088:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 0.0145:\\
\;\;\;\;\left(\cos re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\
\mathbf{elif}\;im \leq 1.15 \cdot 10^{+73}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -5.1000000000000003e82 or 1.15e73 < im Initial program 100.0%
Taylor expanded in im around 0 99.1%
unpow299.1%
*-commutative99.1%
Simplified99.1%
Taylor expanded in im around inf 99.1%
*-commutative99.1%
*-commutative99.1%
associate-*l*99.1%
Simplified99.1%
if -5.1000000000000003e82 < im < -0.087999999999999995 or 0.0145000000000000007 < im < 1.15e73Initial program 100.0%
Taylor expanded in re around 0 78.7%
if -0.087999999999999995 < im < 0.0145000000000000007Initial program 100.0%
Taylor expanded in im around 0 99.6%
unpow299.6%
Simplified99.6%
Final simplification96.8%
(FPCore (re im)
:precision binary64
(if (<= im -5.1e+82)
(* (pow im 4.0) (* (cos re) 0.041666666666666664))
(if (<= im -9e-10)
(* 0.5 (+ (exp im) (exp (- im))))
(* (cos re) (+ 0.5 (* 0.5 (exp im)))))))
double code(double re, double im) {
double tmp;
if (im <= -5.1e+82) {
tmp = pow(im, 4.0) * (cos(re) * 0.041666666666666664);
} else if (im <= -9e-10) {
tmp = 0.5 * (exp(im) + exp(-im));
} else {
tmp = cos(re) * (0.5 + (0.5 * exp(im)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= (-5.1d+82)) then
tmp = (im ** 4.0d0) * (cos(re) * 0.041666666666666664d0)
else if (im <= (-9d-10)) then
tmp = 0.5d0 * (exp(im) + exp(-im))
else
tmp = cos(re) * (0.5d0 + (0.5d0 * exp(im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= -5.1e+82) {
tmp = Math.pow(im, 4.0) * (Math.cos(re) * 0.041666666666666664);
} else if (im <= -9e-10) {
tmp = 0.5 * (Math.exp(im) + Math.exp(-im));
} else {
tmp = Math.cos(re) * (0.5 + (0.5 * Math.exp(im)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= -5.1e+82: tmp = math.pow(im, 4.0) * (math.cos(re) * 0.041666666666666664) elif im <= -9e-10: tmp = 0.5 * (math.exp(im) + math.exp(-im)) else: tmp = math.cos(re) * (0.5 + (0.5 * math.exp(im))) return tmp
function code(re, im) tmp = 0.0 if (im <= -5.1e+82) tmp = Float64((im ^ 4.0) * Float64(cos(re) * 0.041666666666666664)); elseif (im <= -9e-10) tmp = Float64(0.5 * Float64(exp(im) + exp(Float64(-im)))); else tmp = Float64(cos(re) * Float64(0.5 + Float64(0.5 * exp(im)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= -5.1e+82) tmp = (im ^ 4.0) * (cos(re) * 0.041666666666666664); elseif (im <= -9e-10) tmp = 0.5 * (exp(im) + exp(-im)); else tmp = cos(re) * (0.5 + (0.5 * exp(im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, -5.1e+82], N[(N[Power[im, 4.0], $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, -9e-10], N[(0.5 * N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(0.5 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -5.1 \cdot 10^{+82}:\\
\;\;\;\;{im}^{4} \cdot \left(\cos re \cdot 0.041666666666666664\right)\\
\mathbf{elif}\;im \leq -9 \cdot 10^{-10}:\\
\;\;\;\;0.5 \cdot \left(e^{im} + e^{-im}\right)\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)\\
\end{array}
\end{array}
if im < -5.1000000000000003e82Initial program 100.0%
Taylor expanded in im around 0 100.0%
unpow2100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
*-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
if -5.1000000000000003e82 < im < -8.9999999999999999e-10Initial program 99.9%
Taylor expanded in re around 0 67.5%
if -8.9999999999999999e-10 < im Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-lft-in100.0%
distribute-lft-in100.0%
distribute-rgt-in100.0%
*-commutative100.0%
fma-def100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 99.5%
fma-udef99.5%
Applied egg-rr99.5%
Final simplification97.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (* (cos re) (* 0.5 im)))))
(if (<= im -1.4)
t_0
(if (<= im 1.75)
(cos re)
(if (<= im 8e+151) (+ 0.5 (* 0.5 (exp im))) t_0)))))
double code(double re, double im) {
double t_0 = im * (cos(re) * (0.5 * im));
double tmp;
if (im <= -1.4) {
tmp = t_0;
} else if (im <= 1.75) {
tmp = cos(re);
} else if (im <= 8e+151) {
tmp = 0.5 + (0.5 * exp(im));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = im * (cos(re) * (0.5d0 * im))
if (im <= (-1.4d0)) then
tmp = t_0
else if (im <= 1.75d0) then
tmp = cos(re)
else if (im <= 8d+151) then
tmp = 0.5d0 + (0.5d0 * exp(im))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = im * (Math.cos(re) * (0.5 * im));
double tmp;
if (im <= -1.4) {
tmp = t_0;
} else if (im <= 1.75) {
tmp = Math.cos(re);
} else if (im <= 8e+151) {
tmp = 0.5 + (0.5 * Math.exp(im));
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = im * (math.cos(re) * (0.5 * im)) tmp = 0 if im <= -1.4: tmp = t_0 elif im <= 1.75: tmp = math.cos(re) elif im <= 8e+151: tmp = 0.5 + (0.5 * math.exp(im)) else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(im * Float64(cos(re) * Float64(0.5 * im))) tmp = 0.0 if (im <= -1.4) tmp = t_0; elseif (im <= 1.75) tmp = cos(re); elseif (im <= 8e+151) tmp = Float64(0.5 + Float64(0.5 * exp(im))); else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = im * (cos(re) * (0.5 * im)); tmp = 0.0; if (im <= -1.4) tmp = t_0; elseif (im <= 1.75) tmp = cos(re); elseif (im <= 8e+151) tmp = 0.5 + (0.5 * exp(im)); else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(N[Cos[re], $MachinePrecision] * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.4], t$95$0, If[LessEqual[im, 1.75], N[Cos[re], $MachinePrecision], If[LessEqual[im, 8e+151], N[(0.5 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := im \cdot \left(\cos re \cdot \left(0.5 \cdot im\right)\right)\\
\mathbf{if}\;im \leq -1.4:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 1.75:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 8 \cdot 10^{+151}:\\
\;\;\;\;0.5 + 0.5 \cdot e^{im}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -1.3999999999999999 or 8.00000000000000014e151 < im Initial program 100.0%
Taylor expanded in im around 0 66.0%
unpow266.0%
Simplified66.0%
Taylor expanded in im around inf 66.0%
*-commutative66.0%
associate-*r*66.0%
*-commutative66.0%
unpow266.0%
associate-*l*66.0%
associate-*l*66.0%
Simplified66.0%
if -1.3999999999999999 < im < 1.75Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-lft-in100.0%
distribute-lft-in100.0%
distribute-rgt-in100.0%
*-commutative100.0%
fma-def100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 99.5%
if 1.75 < im < 8.00000000000000014e151Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-lft-in100.0%
distribute-lft-in100.0%
distribute-rgt-in100.0%
*-commutative100.0%
fma-def100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 84.4%
Final simplification84.9%
(FPCore (re im)
:precision binary64
(if (<= im 3.5)
(* (* (cos re) 0.5) (+ 2.0 (* im im)))
(if (<= im 8e+151)
(+ 0.5 (* 0.5 (exp im)))
(* im (* (cos re) (* 0.5 im))))))
double code(double re, double im) {
double tmp;
if (im <= 3.5) {
tmp = (cos(re) * 0.5) * (2.0 + (im * im));
} else if (im <= 8e+151) {
tmp = 0.5 + (0.5 * exp(im));
} else {
tmp = im * (cos(re) * (0.5 * im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 3.5d0) then
tmp = (cos(re) * 0.5d0) * (2.0d0 + (im * im))
else if (im <= 8d+151) then
tmp = 0.5d0 + (0.5d0 * exp(im))
else
tmp = im * (cos(re) * (0.5d0 * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 3.5) {
tmp = (Math.cos(re) * 0.5) * (2.0 + (im * im));
} else if (im <= 8e+151) {
tmp = 0.5 + (0.5 * Math.exp(im));
} else {
tmp = im * (Math.cos(re) * (0.5 * im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 3.5: tmp = (math.cos(re) * 0.5) * (2.0 + (im * im)) elif im <= 8e+151: tmp = 0.5 + (0.5 * math.exp(im)) else: tmp = im * (math.cos(re) * (0.5 * im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 3.5) tmp = Float64(Float64(cos(re) * 0.5) * Float64(2.0 + Float64(im * im))); elseif (im <= 8e+151) tmp = Float64(0.5 + Float64(0.5 * exp(im))); else tmp = Float64(im * Float64(cos(re) * Float64(0.5 * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 3.5) tmp = (cos(re) * 0.5) * (2.0 + (im * im)); elseif (im <= 8e+151) tmp = 0.5 + (0.5 * exp(im)); else tmp = im * (cos(re) * (0.5 * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 3.5], N[(N[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 8e+151], N[(0.5 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * N[(N[Cos[re], $MachinePrecision] * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 3.5:\\
\;\;\;\;\left(\cos re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\
\mathbf{elif}\;im \leq 8 \cdot 10^{+151}:\\
\;\;\;\;0.5 + 0.5 \cdot e^{im}\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(\cos re \cdot \left(0.5 \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 3.5Initial program 100.0%
Taylor expanded in im around 0 83.7%
unpow283.7%
Simplified83.7%
if 3.5 < im < 8.00000000000000014e151Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-lft-in100.0%
distribute-lft-in100.0%
distribute-rgt-in100.0%
*-commutative100.0%
fma-def100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 84.4%
if 8.00000000000000014e151 < im Initial program 100.0%
Taylor expanded in im around 0 96.3%
unpow296.3%
Simplified96.3%
Taylor expanded in im around inf 96.3%
*-commutative96.3%
associate-*r*96.3%
*-commutative96.3%
unpow296.3%
associate-*l*96.3%
associate-*l*96.3%
Simplified96.3%
Final simplification85.0%
(FPCore (re im) :precision binary64 (if (<= im -1.2e+47) (* im (* 0.5 im)) (if (<= im 2.0) (cos re) (+ 0.5 (* 0.5 (exp im))))))
double code(double re, double im) {
double tmp;
if (im <= -1.2e+47) {
tmp = im * (0.5 * im);
} else if (im <= 2.0) {
tmp = cos(re);
} else {
tmp = 0.5 + (0.5 * exp(im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= (-1.2d+47)) then
tmp = im * (0.5d0 * im)
else if (im <= 2.0d0) then
tmp = cos(re)
else
tmp = 0.5d0 + (0.5d0 * exp(im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= -1.2e+47) {
tmp = im * (0.5 * im);
} else if (im <= 2.0) {
tmp = Math.cos(re);
} else {
tmp = 0.5 + (0.5 * Math.exp(im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= -1.2e+47: tmp = im * (0.5 * im) elif im <= 2.0: tmp = math.cos(re) else: tmp = 0.5 + (0.5 * math.exp(im)) return tmp
function code(re, im) tmp = 0.0 if (im <= -1.2e+47) tmp = Float64(im * Float64(0.5 * im)); elseif (im <= 2.0) tmp = cos(re); else tmp = Float64(0.5 + Float64(0.5 * exp(im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= -1.2e+47) tmp = im * (0.5 * im); elseif (im <= 2.0) tmp = cos(re); else tmp = 0.5 + (0.5 * exp(im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, -1.2e+47], N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.0], N[Cos[re], $MachinePrecision], N[(0.5 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.2 \cdot 10^{+47}:\\
\;\;\;\;im \cdot \left(0.5 \cdot im\right)\\
\mathbf{elif}\;im \leq 2:\\
\;\;\;\;\cos re\\
\mathbf{else}:\\
\;\;\;\;0.5 + 0.5 \cdot e^{im}\\
\end{array}
\end{array}
if im < -1.20000000000000009e47Initial program 100.0%
Taylor expanded in im around 0 69.3%
unpow269.3%
Simplified69.3%
Taylor expanded in re around 0 2.7%
*-commutative2.7%
*-commutative2.7%
associate-*l*2.7%
distribute-lft-out49.2%
+-commutative49.2%
unpow249.2%
fma-def49.2%
*-commutative49.2%
unpow249.2%
Simplified49.2%
Taylor expanded in im around inf 49.2%
*-commutative49.2%
unpow249.2%
unpow249.2%
Simplified49.2%
Taylor expanded in re around 0 55.4%
unpow255.4%
associate-*r*55.4%
Simplified55.4%
if -1.20000000000000009e47 < im < 2Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-lft-in100.0%
distribute-lft-in100.0%
distribute-rgt-in100.0%
*-commutative100.0%
fma-def100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 89.4%
if 2 < im Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-lft-in100.0%
distribute-lft-in100.0%
distribute-rgt-in100.0%
*-commutative100.0%
fma-def100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 78.6%
Final simplification79.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (* im im)))
(t_1 (* im (* 0.5 im)))
(t_2 (* im (* im (* re (* re -0.25))))))
(if (<= im -4e+47)
t_1
(if (<= im 5.8e+86)
(cos re)
(if (<= im 2.3e+139)
(/ (- (* t_0 t_0) (* t_2 t_2)) (- t_0 t_2))
t_1)))))
double code(double re, double im) {
double t_0 = 0.5 * (im * im);
double t_1 = im * (0.5 * im);
double t_2 = im * (im * (re * (re * -0.25)));
double tmp;
if (im <= -4e+47) {
tmp = t_1;
} else if (im <= 5.8e+86) {
tmp = cos(re);
} else if (im <= 2.3e+139) {
tmp = ((t_0 * t_0) - (t_2 * t_2)) / (t_0 - t_2);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = 0.5d0 * (im * im)
t_1 = im * (0.5d0 * im)
t_2 = im * (im * (re * (re * (-0.25d0))))
if (im <= (-4d+47)) then
tmp = t_1
else if (im <= 5.8d+86) then
tmp = cos(re)
else if (im <= 2.3d+139) then
tmp = ((t_0 * t_0) - (t_2 * t_2)) / (t_0 - t_2)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * (im * im);
double t_1 = im * (0.5 * im);
double t_2 = im * (im * (re * (re * -0.25)));
double tmp;
if (im <= -4e+47) {
tmp = t_1;
} else if (im <= 5.8e+86) {
tmp = Math.cos(re);
} else if (im <= 2.3e+139) {
tmp = ((t_0 * t_0) - (t_2 * t_2)) / (t_0 - t_2);
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * (im * im) t_1 = im * (0.5 * im) t_2 = im * (im * (re * (re * -0.25))) tmp = 0 if im <= -4e+47: tmp = t_1 elif im <= 5.8e+86: tmp = math.cos(re) elif im <= 2.3e+139: tmp = ((t_0 * t_0) - (t_2 * t_2)) / (t_0 - t_2) else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(im * im)) t_1 = Float64(im * Float64(0.5 * im)) t_2 = Float64(im * Float64(im * Float64(re * Float64(re * -0.25)))) tmp = 0.0 if (im <= -4e+47) tmp = t_1; elseif (im <= 5.8e+86) tmp = cos(re); elseif (im <= 2.3e+139) tmp = Float64(Float64(Float64(t_0 * t_0) - Float64(t_2 * t_2)) / Float64(t_0 - t_2)); else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (im * im); t_1 = im * (0.5 * im); t_2 = im * (im * (re * (re * -0.25))); tmp = 0.0; if (im <= -4e+47) tmp = t_1; elseif (im <= 5.8e+86) tmp = cos(re); elseif (im <= 2.3e+139) tmp = ((t_0 * t_0) - (t_2 * t_2)) / (t_0 - t_2); else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(im * N[(im * N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -4e+47], t$95$1, If[LessEqual[im, 5.8e+86], N[Cos[re], $MachinePrecision], If[LessEqual[im, 2.3e+139], N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - t$95$2), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(im \cdot im\right)\\
t_1 := im \cdot \left(0.5 \cdot im\right)\\
t_2 := im \cdot \left(im \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)\\
\mathbf{if}\;im \leq -4 \cdot 10^{+47}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 5.8 \cdot 10^{+86}:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 2.3 \cdot 10^{+139}:\\
\;\;\;\;\frac{t_0 \cdot t_0 - t_2 \cdot t_2}{t_0 - t_2}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -4.0000000000000002e47 or 2.3e139 < im Initial program 100.0%
Taylor expanded in im around 0 76.4%
unpow276.4%
Simplified76.4%
Taylor expanded in re around 0 3.1%
*-commutative3.1%
*-commutative3.1%
associate-*l*3.1%
distribute-lft-out53.7%
+-commutative53.7%
unpow253.7%
fma-def53.7%
*-commutative53.7%
unpow253.7%
Simplified53.7%
Taylor expanded in im around inf 53.7%
*-commutative53.7%
unpow253.7%
unpow253.7%
Simplified53.7%
Taylor expanded in re around 0 59.3%
unpow259.3%
associate-*r*59.3%
Simplified59.3%
if -4.0000000000000002e47 < im < 5.79999999999999981e86Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
distribute-lft-in100.0%
distribute-lft-in100.0%
distribute-rgt-in100.0%
*-commutative100.0%
fma-def100.0%
exp-neg100.0%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 81.2%
if 5.79999999999999981e86 < im < 2.3e139Initial program 100.0%
Taylor expanded in im around 0 6.6%
unpow26.6%
Simplified6.6%
Taylor expanded in re around 0 11.1%
*-commutative11.1%
*-commutative11.1%
associate-*l*11.1%
distribute-lft-out11.1%
+-commutative11.1%
unpow211.1%
fma-def11.1%
*-commutative11.1%
unpow211.1%
Simplified11.1%
Taylor expanded in im around inf 11.1%
*-commutative11.1%
unpow211.1%
unpow211.1%
Simplified11.1%
distribute-lft-in11.1%
flip-+56.3%
*-commutative56.3%
*-commutative56.3%
associate-*l*56.3%
*-commutative56.3%
associate-*l*56.3%
associate-*l*56.3%
*-commutative56.3%
associate-*l*56.3%
*-commutative56.3%
associate-*l*56.3%
Applied egg-rr56.3%
Final simplification72.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (* im (* re (* re -0.25))))) (t_1 (* 0.5 (* im im))))
(if (<= im 5.8e+86)
(+ t_1 1.0)
(if (<= im 2.3e+139)
(/ (- (* t_1 t_1) (* t_0 t_0)) (- t_1 t_0))
(* im (* 0.5 im))))))
double code(double re, double im) {
double t_0 = im * (im * (re * (re * -0.25)));
double t_1 = 0.5 * (im * im);
double tmp;
if (im <= 5.8e+86) {
tmp = t_1 + 1.0;
} else if (im <= 2.3e+139) {
tmp = ((t_1 * t_1) - (t_0 * t_0)) / (t_1 - t_0);
} else {
tmp = im * (0.5 * im);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = im * (im * (re * (re * (-0.25d0))))
t_1 = 0.5d0 * (im * im)
if (im <= 5.8d+86) then
tmp = t_1 + 1.0d0
else if (im <= 2.3d+139) then
tmp = ((t_1 * t_1) - (t_0 * t_0)) / (t_1 - t_0)
else
tmp = im * (0.5d0 * im)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = im * (im * (re * (re * -0.25)));
double t_1 = 0.5 * (im * im);
double tmp;
if (im <= 5.8e+86) {
tmp = t_1 + 1.0;
} else if (im <= 2.3e+139) {
tmp = ((t_1 * t_1) - (t_0 * t_0)) / (t_1 - t_0);
} else {
tmp = im * (0.5 * im);
}
return tmp;
}
def code(re, im): t_0 = im * (im * (re * (re * -0.25))) t_1 = 0.5 * (im * im) tmp = 0 if im <= 5.8e+86: tmp = t_1 + 1.0 elif im <= 2.3e+139: tmp = ((t_1 * t_1) - (t_0 * t_0)) / (t_1 - t_0) else: tmp = im * (0.5 * im) return tmp
function code(re, im) t_0 = Float64(im * Float64(im * Float64(re * Float64(re * -0.25)))) t_1 = Float64(0.5 * Float64(im * im)) tmp = 0.0 if (im <= 5.8e+86) tmp = Float64(t_1 + 1.0); elseif (im <= 2.3e+139) tmp = Float64(Float64(Float64(t_1 * t_1) - Float64(t_0 * t_0)) / Float64(t_1 - t_0)); else tmp = Float64(im * Float64(0.5 * im)); end return tmp end
function tmp_2 = code(re, im) t_0 = im * (im * (re * (re * -0.25))); t_1 = 0.5 * (im * im); tmp = 0.0; if (im <= 5.8e+86) tmp = t_1 + 1.0; elseif (im <= 2.3e+139) tmp = ((t_1 * t_1) - (t_0 * t_0)) / (t_1 - t_0); else tmp = im * (0.5 * im); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(im * N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 5.8e+86], N[(t$95$1 + 1.0), $MachinePrecision], If[LessEqual[im, 2.3e+139], N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - t$95$0), $MachinePrecision]), $MachinePrecision], N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := im \cdot \left(im \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)\\
t_1 := 0.5 \cdot \left(im \cdot im\right)\\
\mathbf{if}\;im \leq 5.8 \cdot 10^{+86}:\\
\;\;\;\;t_1 + 1\\
\mathbf{elif}\;im \leq 2.3 \cdot 10^{+139}:\\
\;\;\;\;\frac{t_1 \cdot t_1 - t_0 \cdot t_0}{t_1 - t_0}\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 \cdot im\right)\\
\end{array}
\end{array}
if im < 5.79999999999999981e86Initial program 100.0%
Taylor expanded in im around 0 78.2%
unpow278.2%
Simplified78.2%
Taylor expanded in re around 0 45.6%
distribute-lft-in45.6%
metadata-eval45.6%
unpow245.6%
Simplified45.6%
if 5.79999999999999981e86 < im < 2.3e139Initial program 100.0%
Taylor expanded in im around 0 6.6%
unpow26.6%
Simplified6.6%
Taylor expanded in re around 0 11.1%
*-commutative11.1%
*-commutative11.1%
associate-*l*11.1%
distribute-lft-out11.1%
+-commutative11.1%
unpow211.1%
fma-def11.1%
*-commutative11.1%
unpow211.1%
Simplified11.1%
Taylor expanded in im around inf 11.1%
*-commutative11.1%
unpow211.1%
unpow211.1%
Simplified11.1%
distribute-lft-in11.1%
flip-+56.3%
*-commutative56.3%
*-commutative56.3%
associate-*l*56.3%
*-commutative56.3%
associate-*l*56.3%
associate-*l*56.3%
*-commutative56.3%
associate-*l*56.3%
*-commutative56.3%
associate-*l*56.3%
Applied egg-rr56.3%
if 2.3e139 < im Initial program 100.0%
Taylor expanded in im around 0 92.8%
unpow292.8%
Simplified92.8%
Taylor expanded in re around 0 4.0%
*-commutative4.0%
*-commutative4.0%
associate-*l*4.0%
distribute-lft-out64.0%
+-commutative64.0%
unpow264.0%
fma-def64.0%
*-commutative64.0%
unpow264.0%
Simplified64.0%
Taylor expanded in im around inf 64.0%
*-commutative64.0%
unpow264.0%
unpow264.0%
Simplified64.0%
Taylor expanded in re around 0 68.3%
unpow268.3%
associate-*r*68.3%
Simplified68.3%
Final simplification48.5%
(FPCore (re im) :precision binary64 (if (or (<= im -0.042) (not (<= im 1.45))) (* im (* 0.5 im)) 1.0))
double code(double re, double im) {
double tmp;
if ((im <= -0.042) || !(im <= 1.45)) {
tmp = im * (0.5 * im);
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-0.042d0)) .or. (.not. (im <= 1.45d0))) then
tmp = im * (0.5d0 * im)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -0.042) || !(im <= 1.45)) {
tmp = im * (0.5 * im);
} else {
tmp = 1.0;
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -0.042) or not (im <= 1.45): tmp = im * (0.5 * im) else: tmp = 1.0 return tmp
function code(re, im) tmp = 0.0 if ((im <= -0.042) || !(im <= 1.45)) tmp = Float64(im * Float64(0.5 * im)); else tmp = 1.0; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -0.042) || ~((im <= 1.45))) tmp = im * (0.5 * im); else tmp = 1.0; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -0.042], N[Not[LessEqual[im, 1.45]], $MachinePrecision]], N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -0.042 \lor \neg \left(im \leq 1.45\right):\\
\;\;\;\;im \cdot \left(0.5 \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if im < -0.0420000000000000026 or 1.44999999999999996 < im Initial program 100.0%
Taylor expanded in im around 0 51.0%
unpow251.0%
Simplified51.0%
Taylor expanded in re around 0 6.3%
*-commutative6.3%
*-commutative6.3%
associate-*l*6.3%
distribute-lft-out38.6%
+-commutative38.6%
unpow238.6%
fma-def38.6%
*-commutative38.6%
unpow238.6%
Simplified38.6%
Taylor expanded in im around inf 38.6%
*-commutative38.6%
unpow238.6%
unpow238.6%
Simplified38.6%
Taylor expanded in re around 0 39.4%
unpow239.4%
associate-*r*39.4%
Simplified39.4%
if -0.0420000000000000026 < im < 1.44999999999999996Initial program 100.0%
Taylor expanded in im around 0 100.0%
unpow2100.0%
*-commutative100.0%
Simplified100.0%
Applied egg-rr51.5%
*-inverses51.5%
Simplified51.5%
Final simplification45.3%
(FPCore (re im) :precision binary64 (+ (* 0.5 (* im im)) 1.0))
double code(double re, double im) {
return (0.5 * (im * im)) + 1.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * (im * im)) + 1.0d0
end function
public static double code(double re, double im) {
return (0.5 * (im * im)) + 1.0;
}
def code(re, im): return (0.5 * (im * im)) + 1.0
function code(re, im) return Float64(Float64(0.5 * Float64(im * im)) + 1.0) end
function tmp = code(re, im) tmp = (0.5 * (im * im)) + 1.0; end
code[re_, im_] := N[(N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(im \cdot im\right) + 1
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 75.1%
unpow275.1%
Simplified75.1%
Taylor expanded in re around 0 45.3%
distribute-lft-in45.3%
metadata-eval45.3%
unpow245.3%
Simplified45.3%
Final simplification45.3%
(FPCore (re im) :precision binary64 -1.0)
double code(double re, double im) {
return -1.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -1.0d0
end function
public static double code(double re, double im) {
return -1.0;
}
def code(re, im): return -1.0
function code(re, im) return -1.0 end
function tmp = code(re, im) tmp = -1.0; end
code[re_, im_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 75.1%
unpow275.1%
Simplified75.1%
Applied egg-rr3.6%
+-commutative3.6%
Simplified3.6%
Taylor expanded in re around 0 4.2%
Final simplification4.2%
(FPCore (re im) :precision binary64 1.0)
double code(double re, double im) {
return 1.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 1.0d0
end function
public static double code(double re, double im) {
return 1.0;
}
def code(re, im): return 1.0
function code(re, im) return 1.0 end
function tmp = code(re, im) tmp = 1.0; end
code[re_, im_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 88.1%
unpow288.1%
*-commutative88.1%
Simplified88.1%
Applied egg-rr26.7%
*-inverses26.7%
Simplified26.7%
Final simplification26.7%
herbie shell --seed 2023178
(FPCore (re im)
:name "math.cos on complex, real part"
:precision binary64
(* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))