
(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 15 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 (* (* 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}
Initial program 100.0%
Final simplification100.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (cos re) (* 0.5 (* im im))))
(t_1 (* (+ (exp (- im)) (exp im)) (+ 0.5 (* -0.25 (* re re))))))
(if (<= im -7.2e+150)
t_0
(if (<= im -2.6)
t_1
(if (<= im 1.95)
(+ (cos re) t_0)
(if (<= im 2.1e+150) t_1 (* im (* 0.5 (* (cos re) im)))))))))
double code(double re, double im) {
double t_0 = cos(re) * (0.5 * (im * im));
double t_1 = (exp(-im) + exp(im)) * (0.5 + (-0.25 * (re * re)));
double tmp;
if (im <= -7.2e+150) {
tmp = t_0;
} else if (im <= -2.6) {
tmp = t_1;
} else if (im <= 1.95) {
tmp = cos(re) + t_0;
} else if (im <= 2.1e+150) {
tmp = t_1;
} else {
tmp = im * (0.5 * (cos(re) * 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 = cos(re) * (0.5d0 * (im * im))
t_1 = (exp(-im) + exp(im)) * (0.5d0 + ((-0.25d0) * (re * re)))
if (im <= (-7.2d+150)) then
tmp = t_0
else if (im <= (-2.6d0)) then
tmp = t_1
else if (im <= 1.95d0) then
tmp = cos(re) + t_0
else if (im <= 2.1d+150) then
tmp = t_1
else
tmp = im * (0.5d0 * (cos(re) * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.cos(re) * (0.5 * (im * im));
double t_1 = (Math.exp(-im) + Math.exp(im)) * (0.5 + (-0.25 * (re * re)));
double tmp;
if (im <= -7.2e+150) {
tmp = t_0;
} else if (im <= -2.6) {
tmp = t_1;
} else if (im <= 1.95) {
tmp = Math.cos(re) + t_0;
} else if (im <= 2.1e+150) {
tmp = t_1;
} else {
tmp = im * (0.5 * (Math.cos(re) * im));
}
return tmp;
}
def code(re, im): t_0 = math.cos(re) * (0.5 * (im * im)) t_1 = (math.exp(-im) + math.exp(im)) * (0.5 + (-0.25 * (re * re))) tmp = 0 if im <= -7.2e+150: tmp = t_0 elif im <= -2.6: tmp = t_1 elif im <= 1.95: tmp = math.cos(re) + t_0 elif im <= 2.1e+150: tmp = t_1 else: tmp = im * (0.5 * (math.cos(re) * im)) return tmp
function code(re, im) t_0 = Float64(cos(re) * Float64(0.5 * Float64(im * im))) t_1 = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 + Float64(-0.25 * Float64(re * re)))) tmp = 0.0 if (im <= -7.2e+150) tmp = t_0; elseif (im <= -2.6) tmp = t_1; elseif (im <= 1.95) tmp = Float64(cos(re) + t_0); elseif (im <= 2.1e+150) tmp = t_1; else tmp = Float64(im * Float64(0.5 * Float64(cos(re) * im))); end return tmp end
function tmp_2 = code(re, im) t_0 = cos(re) * (0.5 * (im * im)); t_1 = (exp(-im) + exp(im)) * (0.5 + (-0.25 * (re * re))); tmp = 0.0; if (im <= -7.2e+150) tmp = t_0; elseif (im <= -2.6) tmp = t_1; elseif (im <= 1.95) tmp = cos(re) + t_0; elseif (im <= 2.1e+150) tmp = t_1; else tmp = im * (0.5 * (cos(re) * im)); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Cos[re], $MachinePrecision] * N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -7.2e+150], t$95$0, If[LessEqual[im, -2.6], t$95$1, If[LessEqual[im, 1.95], N[(N[Cos[re], $MachinePrecision] + t$95$0), $MachinePrecision], If[LessEqual[im, 2.1e+150], t$95$1, N[(im * N[(0.5 * N[(N[Cos[re], $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos re \cdot \left(0.5 \cdot \left(im \cdot im\right)\right)\\
t_1 := \left(e^{-im} + e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\
\mathbf{if}\;im \leq -7.2 \cdot 10^{+150}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -2.6:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 1.95:\\
\;\;\;\;\cos re + t_0\\
\mathbf{elif}\;im \leq 2.1 \cdot 10^{+150}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 \cdot \left(\cos re \cdot im\right)\right)\\
\end{array}
\end{array}
if im < -7.19999999999999972e150Initial program 100.0%
Taylor expanded in im around 0 96.7%
Simplified96.7%
Taylor expanded in im around inf 96.7%
*-commutative96.7%
associate-*r*96.7%
unpow296.7%
Simplified96.7%
if -7.19999999999999972e150 < im < -2.60000000000000009 or 1.94999999999999996 < im < 2.09999999999999998e150Initial program 100.0%
Taylor expanded in re around 0 0.0%
Simplified77.8%
if -2.60000000000000009 < im < 1.94999999999999996Initial program 100.0%
Taylor expanded in im around 0 98.8%
Simplified98.8%
fma-udef98.8%
*-commutative98.8%
associate-*r*98.8%
Applied egg-rr98.8%
if 2.09999999999999998e150 < im Initial program 100.0%
Taylor expanded in im around 0 96.9%
Simplified96.9%
Taylor expanded in im around inf 96.9%
unpow296.9%
associate-*r*96.9%
associate-*r*96.9%
*-commutative96.9%
*-commutative96.9%
Simplified96.9%
Final simplification92.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (cos re) (* 0.5 (* im im))))
(t_1 (* 0.5 (+ (exp (- im)) (exp im)))))
(if (<= im -1.35e+154)
t_0
(if (<= im -2.6)
t_1
(if (<= im 2000000000.0)
(+ (cos re) t_0)
(if (<= im 3.1e+154) t_1 (* im (* 0.5 (* (cos re) im)))))))))
double code(double re, double im) {
double t_0 = cos(re) * (0.5 * (im * im));
double t_1 = 0.5 * (exp(-im) + exp(im));
double tmp;
if (im <= -1.35e+154) {
tmp = t_0;
} else if (im <= -2.6) {
tmp = t_1;
} else if (im <= 2000000000.0) {
tmp = cos(re) + t_0;
} else if (im <= 3.1e+154) {
tmp = t_1;
} else {
tmp = im * (0.5 * (cos(re) * 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 = cos(re) * (0.5d0 * (im * im))
t_1 = 0.5d0 * (exp(-im) + exp(im))
if (im <= (-1.35d+154)) then
tmp = t_0
else if (im <= (-2.6d0)) then
tmp = t_1
else if (im <= 2000000000.0d0) then
tmp = cos(re) + t_0
else if (im <= 3.1d+154) then
tmp = t_1
else
tmp = im * (0.5d0 * (cos(re) * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.cos(re) * (0.5 * (im * im));
double t_1 = 0.5 * (Math.exp(-im) + Math.exp(im));
double tmp;
if (im <= -1.35e+154) {
tmp = t_0;
} else if (im <= -2.6) {
tmp = t_1;
} else if (im <= 2000000000.0) {
tmp = Math.cos(re) + t_0;
} else if (im <= 3.1e+154) {
tmp = t_1;
} else {
tmp = im * (0.5 * (Math.cos(re) * im));
}
return tmp;
}
def code(re, im): t_0 = math.cos(re) * (0.5 * (im * im)) t_1 = 0.5 * (math.exp(-im) + math.exp(im)) tmp = 0 if im <= -1.35e+154: tmp = t_0 elif im <= -2.6: tmp = t_1 elif im <= 2000000000.0: tmp = math.cos(re) + t_0 elif im <= 3.1e+154: tmp = t_1 else: tmp = im * (0.5 * (math.cos(re) * im)) return tmp
function code(re, im) t_0 = Float64(cos(re) * Float64(0.5 * Float64(im * im))) t_1 = Float64(0.5 * Float64(exp(Float64(-im)) + exp(im))) tmp = 0.0 if (im <= -1.35e+154) tmp = t_0; elseif (im <= -2.6) tmp = t_1; elseif (im <= 2000000000.0) tmp = Float64(cos(re) + t_0); elseif (im <= 3.1e+154) tmp = t_1; else tmp = Float64(im * Float64(0.5 * Float64(cos(re) * im))); end return tmp end
function tmp_2 = code(re, im) t_0 = cos(re) * (0.5 * (im * im)); t_1 = 0.5 * (exp(-im) + exp(im)); tmp = 0.0; if (im <= -1.35e+154) tmp = t_0; elseif (im <= -2.6) tmp = t_1; elseif (im <= 2000000000.0) tmp = cos(re) + t_0; elseif (im <= 3.1e+154) tmp = t_1; else tmp = im * (0.5 * (cos(re) * im)); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Cos[re], $MachinePrecision] * N[(0.5 * N[(im * 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.35e+154], t$95$0, If[LessEqual[im, -2.6], t$95$1, If[LessEqual[im, 2000000000.0], N[(N[Cos[re], $MachinePrecision] + t$95$0), $MachinePrecision], If[LessEqual[im, 3.1e+154], t$95$1, N[(im * N[(0.5 * N[(N[Cos[re], $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos re \cdot \left(0.5 \cdot \left(im \cdot im\right)\right)\\
t_1 := 0.5 \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{if}\;im \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -2.6:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 2000000000:\\
\;\;\;\;\cos re + t_0\\
\mathbf{elif}\;im \leq 3.1 \cdot 10^{+154}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 \cdot \left(\cos re \cdot im\right)\right)\\
\end{array}
\end{array}
if im < -1.35000000000000003e154Initial program 100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
*-commutative100.0%
associate-*r*100.0%
unpow2100.0%
Simplified100.0%
if -1.35000000000000003e154 < im < -2.60000000000000009 or 2e9 < im < 3.1000000000000001e154Initial program 100.0%
Taylor expanded in re around 0 72.6%
if -2.60000000000000009 < im < 2e9Initial program 100.0%
Taylor expanded in im around 0 98.0%
Simplified98.0%
fma-udef98.0%
*-commutative98.0%
associate-*r*98.0%
Applied egg-rr98.0%
if 3.1000000000000001e154 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
unpow2100.0%
associate-*r*100.0%
associate-*r*100.0%
*-commutative100.0%
*-commutative100.0%
Simplified100.0%
Final simplification91.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (* im im))) (t_1 (* 0.5 (+ (exp (- im)) (exp im)))))
(if (<= im -1.35e+154)
(* (cos re) t_0)
(if (<= im -2.6)
t_1
(if (<= im 2000000000.0)
(* (cos re) (+ t_0 1.0))
(if (<= im 2.2e+154) t_1 (* im (* 0.5 (* (cos re) im)))))))))
double code(double re, double im) {
double t_0 = 0.5 * (im * im);
double t_1 = 0.5 * (exp(-im) + exp(im));
double tmp;
if (im <= -1.35e+154) {
tmp = cos(re) * t_0;
} else if (im <= -2.6) {
tmp = t_1;
} else if (im <= 2000000000.0) {
tmp = cos(re) * (t_0 + 1.0);
} else if (im <= 2.2e+154) {
tmp = t_1;
} else {
tmp = im * (0.5 * (cos(re) * 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 = 0.5d0 * (im * im)
t_1 = 0.5d0 * (exp(-im) + exp(im))
if (im <= (-1.35d+154)) then
tmp = cos(re) * t_0
else if (im <= (-2.6d0)) then
tmp = t_1
else if (im <= 2000000000.0d0) then
tmp = cos(re) * (t_0 + 1.0d0)
else if (im <= 2.2d+154) then
tmp = t_1
else
tmp = im * (0.5d0 * (cos(re) * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * (im * im);
double t_1 = 0.5 * (Math.exp(-im) + Math.exp(im));
double tmp;
if (im <= -1.35e+154) {
tmp = Math.cos(re) * t_0;
} else if (im <= -2.6) {
tmp = t_1;
} else if (im <= 2000000000.0) {
tmp = Math.cos(re) * (t_0 + 1.0);
} else if (im <= 2.2e+154) {
tmp = t_1;
} else {
tmp = im * (0.5 * (Math.cos(re) * im));
}
return tmp;
}
def code(re, im): t_0 = 0.5 * (im * im) t_1 = 0.5 * (math.exp(-im) + math.exp(im)) tmp = 0 if im <= -1.35e+154: tmp = math.cos(re) * t_0 elif im <= -2.6: tmp = t_1 elif im <= 2000000000.0: tmp = math.cos(re) * (t_0 + 1.0) elif im <= 2.2e+154: tmp = t_1 else: tmp = im * (0.5 * (math.cos(re) * im)) return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(im * im)) t_1 = Float64(0.5 * Float64(exp(Float64(-im)) + exp(im))) tmp = 0.0 if (im <= -1.35e+154) tmp = Float64(cos(re) * t_0); elseif (im <= -2.6) tmp = t_1; elseif (im <= 2000000000.0) tmp = Float64(cos(re) * Float64(t_0 + 1.0)); elseif (im <= 2.2e+154) tmp = t_1; else tmp = Float64(im * Float64(0.5 * Float64(cos(re) * im))); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (im * im); t_1 = 0.5 * (exp(-im) + exp(im)); tmp = 0.0; if (im <= -1.35e+154) tmp = cos(re) * t_0; elseif (im <= -2.6) tmp = t_1; elseif (im <= 2000000000.0) tmp = cos(re) * (t_0 + 1.0); elseif (im <= 2.2e+154) tmp = t_1; else tmp = im * (0.5 * (cos(re) * im)); 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[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.35e+154], N[(N[Cos[re], $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[im, -2.6], t$95$1, If[LessEqual[im, 2000000000.0], N[(N[Cos[re], $MachinePrecision] * N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.2e+154], t$95$1, N[(im * N[(0.5 * N[(N[Cos[re], $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(im \cdot im\right)\\
t_1 := 0.5 \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{if}\;im \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;\cos re \cdot t_0\\
\mathbf{elif}\;im \leq -2.6:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 2000000000:\\
\;\;\;\;\cos re \cdot \left(t_0 + 1\right)\\
\mathbf{elif}\;im \leq 2.2 \cdot 10^{+154}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 \cdot \left(\cos re \cdot im\right)\right)\\
\end{array}
\end{array}
if im < -1.35000000000000003e154Initial program 100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
*-commutative100.0%
associate-*r*100.0%
unpow2100.0%
Simplified100.0%
if -1.35000000000000003e154 < im < -2.60000000000000009 or 2e9 < im < 2.2000000000000001e154Initial program 100.0%
Taylor expanded in re around 0 72.6%
if -2.60000000000000009 < im < 2e9Initial program 100.0%
Taylor expanded in im around 0 98.0%
Simplified98.0%
Taylor expanded in re around inf 98.0%
*-commutative98.0%
associate-*l*98.0%
unpow298.0%
distribute-lft1-in98.0%
+-commutative98.0%
unpow298.0%
*-commutative98.0%
unpow298.0%
Simplified98.0%
if 2.2000000000000001e154 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
unpow2100.0%
associate-*r*100.0%
associate-*r*100.0%
*-commutative100.0%
*-commutative100.0%
Simplified100.0%
Final simplification91.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (* 0.5 (* (cos re) im))))
(t_1 (* (* re re) (* (* im im) -0.25))))
(if (<= im -1.9e+154)
t_0
(if (<= im -1900000000000.0)
t_1
(if (<= im 1.1e+49) (cos re) (if (<= im 1.9e+150) t_1 t_0))))))
double code(double re, double im) {
double t_0 = im * (0.5 * (cos(re) * im));
double t_1 = (re * re) * ((im * im) * -0.25);
double tmp;
if (im <= -1.9e+154) {
tmp = t_0;
} else if (im <= -1900000000000.0) {
tmp = t_1;
} else if (im <= 1.1e+49) {
tmp = cos(re);
} else if (im <= 1.9e+150) {
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 * (0.5d0 * (cos(re) * im))
t_1 = (re * re) * ((im * im) * (-0.25d0))
if (im <= (-1.9d+154)) then
tmp = t_0
else if (im <= (-1900000000000.0d0)) then
tmp = t_1
else if (im <= 1.1d+49) then
tmp = cos(re)
else if (im <= 1.9d+150) 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 * (0.5 * (Math.cos(re) * im));
double t_1 = (re * re) * ((im * im) * -0.25);
double tmp;
if (im <= -1.9e+154) {
tmp = t_0;
} else if (im <= -1900000000000.0) {
tmp = t_1;
} else if (im <= 1.1e+49) {
tmp = Math.cos(re);
} else if (im <= 1.9e+150) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = im * (0.5 * (math.cos(re) * im)) t_1 = (re * re) * ((im * im) * -0.25) tmp = 0 if im <= -1.9e+154: tmp = t_0 elif im <= -1900000000000.0: tmp = t_1 elif im <= 1.1e+49: tmp = math.cos(re) elif im <= 1.9e+150: tmp = t_1 else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(im * Float64(0.5 * Float64(cos(re) * im))) t_1 = Float64(Float64(re * re) * Float64(Float64(im * im) * -0.25)) tmp = 0.0 if (im <= -1.9e+154) tmp = t_0; elseif (im <= -1900000000000.0) tmp = t_1; elseif (im <= 1.1e+49) tmp = cos(re); elseif (im <= 1.9e+150) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = im * (0.5 * (cos(re) * im)); t_1 = (re * re) * ((im * im) * -0.25); tmp = 0.0; if (im <= -1.9e+154) tmp = t_0; elseif (im <= -1900000000000.0) tmp = t_1; elseif (im <= 1.1e+49) tmp = cos(re); elseif (im <= 1.9e+150) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(0.5 * N[(N[Cos[re], $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(re * re), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.9e+154], t$95$0, If[LessEqual[im, -1900000000000.0], t$95$1, If[LessEqual[im, 1.1e+49], N[Cos[re], $MachinePrecision], If[LessEqual[im, 1.9e+150], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := im \cdot \left(0.5 \cdot \left(\cos re \cdot im\right)\right)\\
t_1 := \left(re \cdot re\right) \cdot \left(\left(im \cdot im\right) \cdot -0.25\right)\\
\mathbf{if}\;im \leq -1.9 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -1900000000000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 1.1 \cdot 10^{+49}:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 1.9 \cdot 10^{+150}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -1.8999999999999999e154 or 1.89999999999999995e150 < im Initial program 100.0%
Taylor expanded in im around 0 98.4%
Simplified98.4%
Taylor expanded in im around inf 98.4%
unpow298.4%
associate-*r*98.4%
associate-*r*98.4%
*-commutative98.4%
*-commutative98.4%
Simplified98.4%
if -1.8999999999999999e154 < im < -1.9e12 or 1.1e49 < im < 1.89999999999999995e150Initial program 100.0%
Taylor expanded in im around 0 7.3%
Simplified7.3%
Taylor expanded in im around inf 7.3%
unpow27.3%
associate-*r*6.0%
associate-*r*6.0%
*-commutative6.0%
*-commutative6.0%
Simplified6.0%
Taylor expanded in re around 0 27.4%
associate-*r*27.4%
fma-def27.4%
unpow227.4%
associate-*r*27.4%
Simplified27.4%
Taylor expanded in re around inf 25.3%
*-commutative25.3%
associate-*l*25.3%
unpow225.3%
unpow225.3%
Simplified25.3%
if -1.9e12 < im < 1.1e49Initial program 100.0%
Taylor expanded in im around 0 89.8%
Final simplification76.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* re re) (* (* im im) -0.25))))
(if (<= im -6e+139)
(* (cos re) (* 0.5 (* im im)))
(if (<= im -1900000000000.0)
t_0
(if (<= im 1e+51)
(cos re)
(if (<= im 2.1e+150) t_0 (* im (* 0.5 (* (cos re) im)))))))))
double code(double re, double im) {
double t_0 = (re * re) * ((im * im) * -0.25);
double tmp;
if (im <= -6e+139) {
tmp = cos(re) * (0.5 * (im * im));
} else if (im <= -1900000000000.0) {
tmp = t_0;
} else if (im <= 1e+51) {
tmp = cos(re);
} else if (im <= 2.1e+150) {
tmp = t_0;
} else {
tmp = im * (0.5 * (cos(re) * 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) :: tmp
t_0 = (re * re) * ((im * im) * (-0.25d0))
if (im <= (-6d+139)) then
tmp = cos(re) * (0.5d0 * (im * im))
else if (im <= (-1900000000000.0d0)) then
tmp = t_0
else if (im <= 1d+51) then
tmp = cos(re)
else if (im <= 2.1d+150) then
tmp = t_0
else
tmp = im * (0.5d0 * (cos(re) * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = (re * re) * ((im * im) * -0.25);
double tmp;
if (im <= -6e+139) {
tmp = Math.cos(re) * (0.5 * (im * im));
} else if (im <= -1900000000000.0) {
tmp = t_0;
} else if (im <= 1e+51) {
tmp = Math.cos(re);
} else if (im <= 2.1e+150) {
tmp = t_0;
} else {
tmp = im * (0.5 * (Math.cos(re) * im));
}
return tmp;
}
def code(re, im): t_0 = (re * re) * ((im * im) * -0.25) tmp = 0 if im <= -6e+139: tmp = math.cos(re) * (0.5 * (im * im)) elif im <= -1900000000000.0: tmp = t_0 elif im <= 1e+51: tmp = math.cos(re) elif im <= 2.1e+150: tmp = t_0 else: tmp = im * (0.5 * (math.cos(re) * im)) return tmp
function code(re, im) t_0 = Float64(Float64(re * re) * Float64(Float64(im * im) * -0.25)) tmp = 0.0 if (im <= -6e+139) tmp = Float64(cos(re) * Float64(0.5 * Float64(im * im))); elseif (im <= -1900000000000.0) tmp = t_0; elseif (im <= 1e+51) tmp = cos(re); elseif (im <= 2.1e+150) tmp = t_0; else tmp = Float64(im * Float64(0.5 * Float64(cos(re) * im))); end return tmp end
function tmp_2 = code(re, im) t_0 = (re * re) * ((im * im) * -0.25); tmp = 0.0; if (im <= -6e+139) tmp = cos(re) * (0.5 * (im * im)); elseif (im <= -1900000000000.0) tmp = t_0; elseif (im <= 1e+51) tmp = cos(re); elseif (im <= 2.1e+150) tmp = t_0; else tmp = im * (0.5 * (cos(re) * im)); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(re * re), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -6e+139], N[(N[Cos[re], $MachinePrecision] * N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, -1900000000000.0], t$95$0, If[LessEqual[im, 1e+51], N[Cos[re], $MachinePrecision], If[LessEqual[im, 2.1e+150], t$95$0, N[(im * N[(0.5 * N[(N[Cos[re], $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(re \cdot re\right) \cdot \left(\left(im \cdot im\right) \cdot -0.25\right)\\
\mathbf{if}\;im \leq -6 \cdot 10^{+139}:\\
\;\;\;\;\cos re \cdot \left(0.5 \cdot \left(im \cdot im\right)\right)\\
\mathbf{elif}\;im \leq -1900000000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 10^{+51}:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 2.1 \cdot 10^{+150}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 \cdot \left(\cos re \cdot im\right)\right)\\
\end{array}
\end{array}
if im < -5.9999999999999999e139Initial program 100.0%
Taylor expanded in im around 0 88.0%
Simplified88.0%
Taylor expanded in im around inf 88.0%
*-commutative88.0%
associate-*r*88.0%
unpow288.0%
Simplified88.0%
if -5.9999999999999999e139 < im < -1.9e12 or 1e51 < im < 2.09999999999999998e150Initial program 100.0%
Taylor expanded in im around 0 5.5%
Simplified5.5%
Taylor expanded in im around inf 5.5%
unpow25.5%
associate-*r*5.5%
associate-*r*5.5%
*-commutative5.5%
*-commutative5.5%
Simplified5.5%
Taylor expanded in re around 0 27.5%
associate-*r*27.5%
fma-def27.5%
unpow227.5%
associate-*r*27.5%
Simplified27.5%
Taylor expanded in re around inf 25.8%
*-commutative25.8%
associate-*l*25.8%
unpow225.8%
unpow225.8%
Simplified25.8%
if -1.9e12 < im < 1e51Initial program 100.0%
Taylor expanded in im around 0 89.8%
if 2.09999999999999998e150 < im Initial program 100.0%
Taylor expanded in im around 0 96.9%
Simplified96.9%
Taylor expanded in im around inf 96.9%
unpow296.9%
associate-*r*96.9%
associate-*r*96.9%
*-commutative96.9%
*-commutative96.9%
Simplified96.9%
Final simplification76.2%
(FPCore (re im) :precision binary64 (* (cos re) (+ (* 0.5 (* im im)) 1.0)))
double code(double re, double im) {
return cos(re) * ((0.5 * (im * im)) + 1.0);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = cos(re) * ((0.5d0 * (im * im)) + 1.0d0)
end function
public static double code(double re, double im) {
return Math.cos(re) * ((0.5 * (im * im)) + 1.0);
}
def code(re, im): return math.cos(re) * ((0.5 * (im * im)) + 1.0)
function code(re, im) return Float64(cos(re) * Float64(Float64(0.5 * Float64(im * im)) + 1.0)) end
function tmp = code(re, im) tmp = cos(re) * ((0.5 * (im * im)) + 1.0); end
code[re_, im_] := N[(N[Cos[re], $MachinePrecision] * N[(N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos re \cdot \left(0.5 \cdot \left(im \cdot im\right) + 1\right)
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 72.1%
Simplified72.1%
Taylor expanded in re around inf 72.1%
*-commutative72.1%
associate-*l*72.1%
unpow272.1%
distribute-lft1-in72.1%
+-commutative72.1%
unpow272.1%
*-commutative72.1%
unpow272.1%
Simplified72.1%
Final simplification72.1%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (* 0.5 im))) (t_1 (* (* re re) (* (* im im) -0.25))))
(if (<= im -1.85e+154)
t_0
(if (<= im -2050000000000.0)
t_1
(if (<= im 1.1e+49) (cos re) (if (<= im 1.65e+150) t_1 t_0))))))
double code(double re, double im) {
double t_0 = im * (0.5 * im);
double t_1 = (re * re) * ((im * im) * -0.25);
double tmp;
if (im <= -1.85e+154) {
tmp = t_0;
} else if (im <= -2050000000000.0) {
tmp = t_1;
} else if (im <= 1.1e+49) {
tmp = cos(re);
} else if (im <= 1.65e+150) {
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 * (0.5d0 * im)
t_1 = (re * re) * ((im * im) * (-0.25d0))
if (im <= (-1.85d+154)) then
tmp = t_0
else if (im <= (-2050000000000.0d0)) then
tmp = t_1
else if (im <= 1.1d+49) then
tmp = cos(re)
else if (im <= 1.65d+150) 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 * (0.5 * im);
double t_1 = (re * re) * ((im * im) * -0.25);
double tmp;
if (im <= -1.85e+154) {
tmp = t_0;
} else if (im <= -2050000000000.0) {
tmp = t_1;
} else if (im <= 1.1e+49) {
tmp = Math.cos(re);
} else if (im <= 1.65e+150) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = im * (0.5 * im) t_1 = (re * re) * ((im * im) * -0.25) tmp = 0 if im <= -1.85e+154: tmp = t_0 elif im <= -2050000000000.0: tmp = t_1 elif im <= 1.1e+49: tmp = math.cos(re) elif im <= 1.65e+150: tmp = t_1 else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(im * Float64(0.5 * im)) t_1 = Float64(Float64(re * re) * Float64(Float64(im * im) * -0.25)) tmp = 0.0 if (im <= -1.85e+154) tmp = t_0; elseif (im <= -2050000000000.0) tmp = t_1; elseif (im <= 1.1e+49) tmp = cos(re); elseif (im <= 1.65e+150) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = im * (0.5 * im); t_1 = (re * re) * ((im * im) * -0.25); tmp = 0.0; if (im <= -1.85e+154) tmp = t_0; elseif (im <= -2050000000000.0) tmp = t_1; elseif (im <= 1.1e+49) tmp = cos(re); elseif (im <= 1.65e+150) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(re * re), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.85e+154], t$95$0, If[LessEqual[im, -2050000000000.0], t$95$1, If[LessEqual[im, 1.1e+49], N[Cos[re], $MachinePrecision], If[LessEqual[im, 1.65e+150], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := im \cdot \left(0.5 \cdot im\right)\\
t_1 := \left(re \cdot re\right) \cdot \left(\left(im \cdot im\right) \cdot -0.25\right)\\
\mathbf{if}\;im \leq -1.85 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -2050000000000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 1.1 \cdot 10^{+49}:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 1.65 \cdot 10^{+150}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -1.84999999999999997e154 or 1.6499999999999999e150 < im Initial program 100.0%
Taylor expanded in im around 0 98.4%
Simplified98.4%
Taylor expanded in im around inf 98.4%
unpow298.4%
associate-*r*98.4%
associate-*r*98.4%
*-commutative98.4%
*-commutative98.4%
Simplified98.4%
Taylor expanded in re around 0 76.1%
if -1.84999999999999997e154 < im < -2.05e12 or 1.1e49 < im < 1.6499999999999999e150Initial program 100.0%
Taylor expanded in im around 0 7.3%
Simplified7.3%
Taylor expanded in im around inf 7.3%
unpow27.3%
associate-*r*6.0%
associate-*r*6.0%
*-commutative6.0%
*-commutative6.0%
Simplified6.0%
Taylor expanded in re around 0 27.4%
associate-*r*27.4%
fma-def27.4%
unpow227.4%
associate-*r*27.4%
Simplified27.4%
Taylor expanded in re around inf 25.3%
*-commutative25.3%
associate-*l*25.3%
unpow225.3%
unpow225.3%
Simplified25.3%
if -2.05e12 < im < 1.1e49Initial program 100.0%
Taylor expanded in im around 0 89.8%
Final simplification71.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (* 0.5 im))) (t_1 (* im (* 0.5 (* re re)))))
(if (<= im -1.7e+154)
t_0
(if (<= im -2.5)
t_1
(if (<= im 1.5e+29) 0.25 (if (<= im 1.7e+154) t_1 t_0))))))
double code(double re, double im) {
double t_0 = im * (0.5 * im);
double t_1 = im * (0.5 * (re * re));
double tmp;
if (im <= -1.7e+154) {
tmp = t_0;
} else if (im <= -2.5) {
tmp = t_1;
} else if (im <= 1.5e+29) {
tmp = 0.25;
} else if (im <= 1.7e+154) {
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 * (0.5d0 * im)
t_1 = im * (0.5d0 * (re * re))
if (im <= (-1.7d+154)) then
tmp = t_0
else if (im <= (-2.5d0)) then
tmp = t_1
else if (im <= 1.5d+29) then
tmp = 0.25d0
else if (im <= 1.7d+154) 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 * (0.5 * im);
double t_1 = im * (0.5 * (re * re));
double tmp;
if (im <= -1.7e+154) {
tmp = t_0;
} else if (im <= -2.5) {
tmp = t_1;
} else if (im <= 1.5e+29) {
tmp = 0.25;
} else if (im <= 1.7e+154) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = im * (0.5 * im) t_1 = im * (0.5 * (re * re)) tmp = 0 if im <= -1.7e+154: tmp = t_0 elif im <= -2.5: tmp = t_1 elif im <= 1.5e+29: tmp = 0.25 elif im <= 1.7e+154: tmp = t_1 else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(im * Float64(0.5 * im)) t_1 = Float64(im * Float64(0.5 * Float64(re * re))) tmp = 0.0 if (im <= -1.7e+154) tmp = t_0; elseif (im <= -2.5) tmp = t_1; elseif (im <= 1.5e+29) tmp = 0.25; elseif (im <= 1.7e+154) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = im * (0.5 * im); t_1 = im * (0.5 * (re * re)); tmp = 0.0; if (im <= -1.7e+154) tmp = t_0; elseif (im <= -2.5) tmp = t_1; elseif (im <= 1.5e+29) tmp = 0.25; elseif (im <= 1.7e+154) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(im * N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.7e+154], t$95$0, If[LessEqual[im, -2.5], t$95$1, If[LessEqual[im, 1.5e+29], 0.25, If[LessEqual[im, 1.7e+154], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := im \cdot \left(0.5 \cdot im\right)\\
t_1 := im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right)\\
\mathbf{if}\;im \leq -1.7 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -2.5:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 1.5 \cdot 10^{+29}:\\
\;\;\;\;0.25\\
\mathbf{elif}\;im \leq 1.7 \cdot 10^{+154}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -1.69999999999999987e154 or 1.69999999999999987e154 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
unpow2100.0%
associate-*r*100.0%
associate-*r*100.0%
*-commutative100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in re around 0 77.4%
if -1.69999999999999987e154 < im < -2.5 or 1.5e29 < im < 1.69999999999999987e154Initial program 100.0%
Taylor expanded in im around 0 7.2%
Simplified7.2%
Taylor expanded in im around inf 7.2%
unpow27.2%
associate-*r*6.0%
associate-*r*6.0%
*-commutative6.0%
*-commutative6.0%
Simplified6.0%
Taylor expanded in re around 0 24.5%
associate-*r*24.5%
fma-def24.5%
unpow224.5%
associate-*r*24.5%
Simplified24.5%
Applied egg-rr18.7%
if -2.5 < im < 1.5e29Initial program 100.0%
Applied egg-rr12.9%
Taylor expanded in re around 0 13.0%
Final simplification27.9%
(FPCore (re im) :precision binary64 (if (<= re 1.6e+59) (+ (* 0.5 (* im im)) 1.0) (if (<= re 2.8e+195) (* im (* -0.25 (* re (* re im)))) (- (* re re) re))))
double code(double re, double im) {
double tmp;
if (re <= 1.6e+59) {
tmp = (0.5 * (im * im)) + 1.0;
} else if (re <= 2.8e+195) {
tmp = im * (-0.25 * (re * (re * im)));
} else {
tmp = (re * re) - re;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 1.6d+59) then
tmp = (0.5d0 * (im * im)) + 1.0d0
else if (re <= 2.8d+195) then
tmp = im * ((-0.25d0) * (re * (re * im)))
else
tmp = (re * re) - re
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 1.6e+59) {
tmp = (0.5 * (im * im)) + 1.0;
} else if (re <= 2.8e+195) {
tmp = im * (-0.25 * (re * (re * im)));
} else {
tmp = (re * re) - re;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1.6e+59: tmp = (0.5 * (im * im)) + 1.0 elif re <= 2.8e+195: tmp = im * (-0.25 * (re * (re * im))) else: tmp = (re * re) - re return tmp
function code(re, im) tmp = 0.0 if (re <= 1.6e+59) tmp = Float64(Float64(0.5 * Float64(im * im)) + 1.0); elseif (re <= 2.8e+195) tmp = Float64(im * Float64(-0.25 * Float64(re * Float64(re * im)))); else tmp = Float64(Float64(re * re) - re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 1.6e+59) tmp = (0.5 * (im * im)) + 1.0; elseif (re <= 2.8e+195) tmp = im * (-0.25 * (re * (re * im))); else tmp = (re * re) - re; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1.6e+59], N[(N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[re, 2.8e+195], N[(im * N[(-0.25 * N[(re * N[(re * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(re * re), $MachinePrecision] - re), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.6 \cdot 10^{+59}:\\
\;\;\;\;0.5 \cdot \left(im \cdot im\right) + 1\\
\mathbf{elif}\;re \leq 2.8 \cdot 10^{+195}:\\
\;\;\;\;im \cdot \left(-0.25 \cdot \left(re \cdot \left(re \cdot im\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;re \cdot re - re\\
\end{array}
\end{array}
if re < 1.59999999999999991e59Initial program 100.0%
Taylor expanded in im around 0 73.2%
Simplified73.2%
Taylor expanded in re around 0 52.0%
*-commutative52.0%
unpow252.0%
Simplified52.0%
if 1.59999999999999991e59 < re < 2.7999999999999998e195Initial program 100.0%
Taylor expanded in im around 0 63.7%
Simplified63.7%
Taylor expanded in im around inf 26.1%
unpow226.1%
associate-*r*26.1%
associate-*r*26.1%
*-commutative26.1%
*-commutative26.1%
Simplified26.1%
Taylor expanded in re around 0 38.7%
associate-*r*38.7%
fma-def38.7%
unpow238.7%
associate-*r*38.7%
Simplified38.7%
Taylor expanded in re around inf 38.6%
*-commutative38.6%
unpow238.6%
associate-*r*38.7%
*-commutative38.7%
associate-*l*38.7%
unpow238.7%
associate-*l*38.7%
*-commutative38.7%
Simplified38.7%
if 2.7999999999999998e195 < re Initial program 100.0%
Taylor expanded in im around 0 76.0%
Simplified76.0%
Taylor expanded in im around inf 28.0%
unpow228.0%
associate-*r*28.0%
associate-*r*28.0%
*-commutative28.0%
*-commutative28.0%
Simplified28.0%
Taylor expanded in re around 0 0.9%
associate-*r*0.9%
fma-def0.9%
unpow20.9%
associate-*r*0.9%
Simplified0.9%
Applied egg-rr50.9%
fma-neg50.9%
Simplified50.9%
Final simplification50.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (* 0.5 im))))
(if (<= im -2.7e+151)
t_0
(if (<= im -2.3e+28)
(- (* re re) re)
(if (<= im 2000000000.0) 0.25 t_0)))))
double code(double re, double im) {
double t_0 = im * (0.5 * im);
double tmp;
if (im <= -2.7e+151) {
tmp = t_0;
} else if (im <= -2.3e+28) {
tmp = (re * re) - re;
} else if (im <= 2000000000.0) {
tmp = 0.25;
} 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 * (0.5d0 * im)
if (im <= (-2.7d+151)) then
tmp = t_0
else if (im <= (-2.3d+28)) then
tmp = (re * re) - re
else if (im <= 2000000000.0d0) then
tmp = 0.25d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = im * (0.5 * im);
double tmp;
if (im <= -2.7e+151) {
tmp = t_0;
} else if (im <= -2.3e+28) {
tmp = (re * re) - re;
} else if (im <= 2000000000.0) {
tmp = 0.25;
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = im * (0.5 * im) tmp = 0 if im <= -2.7e+151: tmp = t_0 elif im <= -2.3e+28: tmp = (re * re) - re elif im <= 2000000000.0: tmp = 0.25 else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(im * Float64(0.5 * im)) tmp = 0.0 if (im <= -2.7e+151) tmp = t_0; elseif (im <= -2.3e+28) tmp = Float64(Float64(re * re) - re); elseif (im <= 2000000000.0) tmp = 0.25; else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = im * (0.5 * im); tmp = 0.0; if (im <= -2.7e+151) tmp = t_0; elseif (im <= -2.3e+28) tmp = (re * re) - re; elseif (im <= 2000000000.0) tmp = 0.25; else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.7e+151], t$95$0, If[LessEqual[im, -2.3e+28], N[(N[(re * re), $MachinePrecision] - re), $MachinePrecision], If[LessEqual[im, 2000000000.0], 0.25, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := im \cdot \left(0.5 \cdot im\right)\\
\mathbf{if}\;im \leq -2.7 \cdot 10^{+151}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -2.3 \cdot 10^{+28}:\\
\;\;\;\;re \cdot re - re\\
\mathbf{elif}\;im \leq 2000000000:\\
\;\;\;\;0.25\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -2.7000000000000001e151 or 2e9 < im Initial program 100.0%
Taylor expanded in im around 0 62.2%
Simplified62.2%
Taylor expanded in im around inf 62.2%
unpow262.2%
associate-*r*61.3%
associate-*r*61.3%
*-commutative61.3%
*-commutative61.3%
Simplified61.3%
Taylor expanded in re around 0 47.2%
if -2.7000000000000001e151 < im < -2.29999999999999984e28Initial program 100.0%
Taylor expanded in im around 0 5.9%
Simplified5.9%
Taylor expanded in im around inf 5.9%
unpow25.9%
associate-*r*5.9%
associate-*r*5.9%
*-commutative5.9%
*-commutative5.9%
Simplified5.9%
Taylor expanded in re around 0 22.6%
associate-*r*22.6%
fma-def22.6%
unpow222.6%
associate-*r*22.6%
Simplified22.6%
Applied egg-rr17.4%
fma-neg17.4%
Simplified17.4%
if -2.29999999999999984e28 < im < 2e9Initial program 100.0%
Applied egg-rr12.7%
Taylor expanded in re around 0 12.8%
Final simplification25.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (* 0.5 im))))
(if (<= im -1.45e+154)
t_0
(if (<= im -2.1e+14)
(* im (* re (- 0.5)))
(if (<= im 2000000000.0) 0.25 t_0)))))
double code(double re, double im) {
double t_0 = im * (0.5 * im);
double tmp;
if (im <= -1.45e+154) {
tmp = t_0;
} else if (im <= -2.1e+14) {
tmp = im * (re * -0.5);
} else if (im <= 2000000000.0) {
tmp = 0.25;
} 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 * (0.5d0 * im)
if (im <= (-1.45d+154)) then
tmp = t_0
else if (im <= (-2.1d+14)) then
tmp = im * (re * -0.5d0)
else if (im <= 2000000000.0d0) then
tmp = 0.25d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = im * (0.5 * im);
double tmp;
if (im <= -1.45e+154) {
tmp = t_0;
} else if (im <= -2.1e+14) {
tmp = im * (re * -0.5);
} else if (im <= 2000000000.0) {
tmp = 0.25;
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = im * (0.5 * im) tmp = 0 if im <= -1.45e+154: tmp = t_0 elif im <= -2.1e+14: tmp = im * (re * -0.5) elif im <= 2000000000.0: tmp = 0.25 else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(im * Float64(0.5 * im)) tmp = 0.0 if (im <= -1.45e+154) tmp = t_0; elseif (im <= -2.1e+14) tmp = Float64(im * Float64(re * Float64(-0.5))); elseif (im <= 2000000000.0) tmp = 0.25; else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = im * (0.5 * im); tmp = 0.0; if (im <= -1.45e+154) tmp = t_0; elseif (im <= -2.1e+14) tmp = im * (re * -0.5); elseif (im <= 2000000000.0) tmp = 0.25; else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.45e+154], t$95$0, If[LessEqual[im, -2.1e+14], N[(im * N[(re * (-0.5)), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2000000000.0], 0.25, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := im \cdot \left(0.5 \cdot im\right)\\
\mathbf{if}\;im \leq -1.45 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -2.1 \cdot 10^{+14}:\\
\;\;\;\;im \cdot \left(re \cdot \left(-0.5\right)\right)\\
\mathbf{elif}\;im \leq 2000000000:\\
\;\;\;\;0.25\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -1.4499999999999999e154 or 2e9 < im Initial program 100.0%
Taylor expanded in im around 0 61.8%
Simplified61.8%
Taylor expanded in im around inf 61.8%
unpow261.8%
associate-*r*61.8%
associate-*r*61.8%
*-commutative61.8%
*-commutative61.8%
Simplified61.8%
Taylor expanded in re around 0 47.8%
if -1.4499999999999999e154 < im < -2.1e14Initial program 100.0%
Taylor expanded in im around 0 8.2%
Simplified8.2%
Taylor expanded in im around inf 8.2%
unpow28.2%
associate-*r*5.9%
associate-*r*5.9%
*-commutative5.9%
*-commutative5.9%
Simplified5.9%
Taylor expanded in re around 0 25.4%
associate-*r*25.4%
fma-def25.4%
unpow225.4%
associate-*r*25.4%
Simplified25.4%
Applied egg-rr16.2%
neg-mul-116.2%
Simplified16.2%
if -2.1e14 < im < 2e9Initial program 100.0%
Applied egg-rr13.0%
Taylor expanded in re around 0 13.1%
Final simplification25.6%
(FPCore (re im) :precision binary64 (if (or (<= im -2.6) (not (<= im 2000000000.0))) (* im (* 0.5 im)) 0.25))
double code(double re, double im) {
double tmp;
if ((im <= -2.6) || !(im <= 2000000000.0)) {
tmp = im * (0.5 * im);
} else {
tmp = 0.25;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-2.6d0)) .or. (.not. (im <= 2000000000.0d0))) then
tmp = im * (0.5d0 * im)
else
tmp = 0.25d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -2.6) || !(im <= 2000000000.0)) {
tmp = im * (0.5 * im);
} else {
tmp = 0.25;
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -2.6) or not (im <= 2000000000.0): tmp = im * (0.5 * im) else: tmp = 0.25 return tmp
function code(re, im) tmp = 0.0 if ((im <= -2.6) || !(im <= 2000000000.0)) tmp = Float64(im * Float64(0.5 * im)); else tmp = 0.25; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -2.6) || ~((im <= 2000000000.0))) tmp = im * (0.5 * im); else tmp = 0.25; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -2.6], N[Not[LessEqual[im, 2000000000.0]], $MachinePrecision]], N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision], 0.25]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -2.6 \lor \neg \left(im \leq 2000000000\right):\\
\;\;\;\;im \cdot \left(0.5 \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;0.25\\
\end{array}
\end{array}
if im < -2.60000000000000009 or 2e9 < im Initial program 100.0%
Taylor expanded in im around 0 45.7%
Simplified45.7%
Taylor expanded in im around inf 45.7%
unpow245.7%
associate-*r*45.0%
associate-*r*45.0%
*-commutative45.0%
*-commutative45.0%
Simplified45.0%
Taylor expanded in re around 0 34.6%
if -2.60000000000000009 < im < 2e9Initial program 100.0%
Applied egg-rr13.2%
Taylor expanded in re around 0 13.3%
Final simplification23.9%
(FPCore (re im) :precision binary64 (if (<= re 1.6e+59) (+ (* 0.5 (* im im)) 1.0) (* im (* 0.5 (* re re)))))
double code(double re, double im) {
double tmp;
if (re <= 1.6e+59) {
tmp = (0.5 * (im * im)) + 1.0;
} else {
tmp = im * (0.5 * (re * re));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 1.6d+59) then
tmp = (0.5d0 * (im * im)) + 1.0d0
else
tmp = im * (0.5d0 * (re * re))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 1.6e+59) {
tmp = (0.5 * (im * im)) + 1.0;
} else {
tmp = im * (0.5 * (re * re));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1.6e+59: tmp = (0.5 * (im * im)) + 1.0 else: tmp = im * (0.5 * (re * re)) return tmp
function code(re, im) tmp = 0.0 if (re <= 1.6e+59) tmp = Float64(Float64(0.5 * Float64(im * im)) + 1.0); else tmp = Float64(im * Float64(0.5 * Float64(re * re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 1.6e+59) tmp = (0.5 * (im * im)) + 1.0; else tmp = im * (0.5 * (re * re)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1.6e+59], N[(N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(im * N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.6 \cdot 10^{+59}:\\
\;\;\;\;0.5 \cdot \left(im \cdot im\right) + 1\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right)\\
\end{array}
\end{array}
if re < 1.59999999999999991e59Initial program 100.0%
Taylor expanded in im around 0 73.2%
Simplified73.2%
Taylor expanded in re around 0 52.0%
*-commutative52.0%
unpow252.0%
Simplified52.0%
if 1.59999999999999991e59 < re Initial program 100.0%
Taylor expanded in im around 0 66.9%
Simplified66.9%
Taylor expanded in im around inf 26.6%
unpow226.6%
associate-*r*26.6%
associate-*r*26.6%
*-commutative26.6%
*-commutative26.6%
Simplified26.6%
Taylor expanded in re around 0 28.6%
associate-*r*28.6%
fma-def28.6%
unpow228.6%
associate-*r*28.6%
Simplified28.6%
Applied egg-rr26.3%
Final simplification47.5%
(FPCore (re im) :precision binary64 0.25)
double code(double re, double im) {
return 0.25;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.25d0
end function
public static double code(double re, double im) {
return 0.25;
}
def code(re, im): return 0.25
function code(re, im) return 0.25 end
function tmp = code(re, im) tmp = 0.25; end
code[re_, im_] := 0.25
\begin{array}{l}
\\
0.25
\end{array}
Initial program 100.0%
Applied egg-rr7.9%
Taylor expanded in re around 0 7.9%
Final simplification7.9%
herbie shell --seed 2023174
(FPCore (re im)
:name "math.cos on complex, real part"
:precision binary64
(* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))