
(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 (* (* 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 (* im (* 0.5 (* (cos re) im))))
(t_1 (* 0.5 (+ (exp (- im)) (exp im)))))
(if (<= im -3.1e+154)
t_0
(if (<= im -11.5)
t_1
(if (<= im 0.0305)
(+ (cos re) (* im (* (cos re) (* 0.5 im))))
(if (<= im 2.15e+154) t_1 t_0))))))
double code(double re, double im) {
double t_0 = im * (0.5 * (cos(re) * im));
double t_1 = 0.5 * (exp(-im) + exp(im));
double tmp;
if (im <= -3.1e+154) {
tmp = t_0;
} else if (im <= -11.5) {
tmp = t_1;
} else if (im <= 0.0305) {
tmp = cos(re) + (im * (cos(re) * (0.5 * im)));
} else if (im <= 2.15e+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 * (cos(re) * im))
t_1 = 0.5d0 * (exp(-im) + exp(im))
if (im <= (-3.1d+154)) then
tmp = t_0
else if (im <= (-11.5d0)) then
tmp = t_1
else if (im <= 0.0305d0) then
tmp = cos(re) + (im * (cos(re) * (0.5d0 * im)))
else if (im <= 2.15d+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 * (Math.cos(re) * im));
double t_1 = 0.5 * (Math.exp(-im) + Math.exp(im));
double tmp;
if (im <= -3.1e+154) {
tmp = t_0;
} else if (im <= -11.5) {
tmp = t_1;
} else if (im <= 0.0305) {
tmp = Math.cos(re) + (im * (Math.cos(re) * (0.5 * im)));
} else if (im <= 2.15e+154) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = im * (0.5 * (math.cos(re) * im)) t_1 = 0.5 * (math.exp(-im) + math.exp(im)) tmp = 0 if im <= -3.1e+154: tmp = t_0 elif im <= -11.5: tmp = t_1 elif im <= 0.0305: tmp = math.cos(re) + (im * (math.cos(re) * (0.5 * im))) elif im <= 2.15e+154: 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(0.5 * Float64(exp(Float64(-im)) + exp(im))) tmp = 0.0 if (im <= -3.1e+154) tmp = t_0; elseif (im <= -11.5) tmp = t_1; elseif (im <= 0.0305) tmp = Float64(cos(re) + Float64(im * Float64(cos(re) * Float64(0.5 * im)))); elseif (im <= 2.15e+154) 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 = 0.5 * (exp(-im) + exp(im)); tmp = 0.0; if (im <= -3.1e+154) tmp = t_0; elseif (im <= -11.5) tmp = t_1; elseif (im <= 0.0305) tmp = cos(re) + (im * (cos(re) * (0.5 * im))); elseif (im <= 2.15e+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 * N[(N[Cos[re], $MachinePrecision] * 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, -3.1e+154], t$95$0, If[LessEqual[im, -11.5], t$95$1, If[LessEqual[im, 0.0305], N[(N[Cos[re], $MachinePrecision] + N[(im * N[(N[Cos[re], $MachinePrecision] * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.15e+154], 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 := 0.5 \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{if}\;im \leq -3.1 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -11.5:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 0.0305:\\
\;\;\;\;\cos re + im \cdot \left(\cos re \cdot \left(0.5 \cdot im\right)\right)\\
\mathbf{elif}\;im \leq 2.15 \cdot 10^{+154}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -3.1000000000000001e154 or 2.1499999999999999e154 < 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%
if -3.1000000000000001e154 < im < -11.5 or 0.030499999999999999 < im < 2.1499999999999999e154Initial program 100.0%
Taylor expanded in re around 0 82.4%
if -11.5 < im < 0.030499999999999999Initial program 100.0%
Taylor expanded in im around 0 99.4%
Simplified99.4%
Taylor expanded in re around inf 99.4%
*-commutative99.4%
unpow299.4%
associate-*l*99.4%
Simplified99.4%
fma-udef99.4%
associate-*r*99.4%
associate-*r*99.4%
*-commutative99.4%
associate-*l*99.4%
associate-*l*99.4%
Applied egg-rr99.4%
Final simplification95.1%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (* 0.5 (* (cos re) im))))
(t_1 (* 0.5 (+ (exp (- im)) (exp im)))))
(if (<= im -2.06e+154)
t_0
(if (<= im -11.5)
t_1
(if (<= im 0.0071)
(* (cos re) (+ 1.0 (* 0.5 (* im im))))
(if (<= im 1.95e+154) t_1 t_0))))))
double code(double re, double im) {
double t_0 = im * (0.5 * (cos(re) * im));
double t_1 = 0.5 * (exp(-im) + exp(im));
double tmp;
if (im <= -2.06e+154) {
tmp = t_0;
} else if (im <= -11.5) {
tmp = t_1;
} else if (im <= 0.0071) {
tmp = cos(re) * (1.0 + (0.5 * (im * im)));
} else if (im <= 1.95e+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 * (cos(re) * im))
t_1 = 0.5d0 * (exp(-im) + exp(im))
if (im <= (-2.06d+154)) then
tmp = t_0
else if (im <= (-11.5d0)) then
tmp = t_1
else if (im <= 0.0071d0) then
tmp = cos(re) * (1.0d0 + (0.5d0 * (im * im)))
else if (im <= 1.95d+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 * (Math.cos(re) * im));
double t_1 = 0.5 * (Math.exp(-im) + Math.exp(im));
double tmp;
if (im <= -2.06e+154) {
tmp = t_0;
} else if (im <= -11.5) {
tmp = t_1;
} else if (im <= 0.0071) {
tmp = Math.cos(re) * (1.0 + (0.5 * (im * im)));
} else if (im <= 1.95e+154) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = im * (0.5 * (math.cos(re) * im)) t_1 = 0.5 * (math.exp(-im) + math.exp(im)) tmp = 0 if im <= -2.06e+154: tmp = t_0 elif im <= -11.5: tmp = t_1 elif im <= 0.0071: tmp = math.cos(re) * (1.0 + (0.5 * (im * im))) elif im <= 1.95e+154: 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(0.5 * Float64(exp(Float64(-im)) + exp(im))) tmp = 0.0 if (im <= -2.06e+154) tmp = t_0; elseif (im <= -11.5) tmp = t_1; elseif (im <= 0.0071) tmp = Float64(cos(re) * Float64(1.0 + Float64(0.5 * Float64(im * im)))); elseif (im <= 1.95e+154) 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 = 0.5 * (exp(-im) + exp(im)); tmp = 0.0; if (im <= -2.06e+154) tmp = t_0; elseif (im <= -11.5) tmp = t_1; elseif (im <= 0.0071) tmp = cos(re) * (1.0 + (0.5 * (im * im))); elseif (im <= 1.95e+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 * N[(N[Cos[re], $MachinePrecision] * 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, -2.06e+154], t$95$0, If[LessEqual[im, -11.5], t$95$1, If[LessEqual[im, 0.0071], N[(N[Cos[re], $MachinePrecision] * N[(1.0 + N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.95e+154], 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 := 0.5 \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{if}\;im \leq -2.06 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -11.5:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 0.0071:\\
\;\;\;\;\cos re \cdot \left(1 + 0.5 \cdot \left(im \cdot im\right)\right)\\
\mathbf{elif}\;im \leq 1.95 \cdot 10^{+154}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -2.05999999999999988e154 or 1.9500000000000001e154 < 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%
if -2.05999999999999988e154 < im < -11.5 or 0.0071000000000000004 < im < 1.9500000000000001e154Initial program 100.0%
Taylor expanded in re around 0 82.4%
if -11.5 < im < 0.0071000000000000004Initial program 100.0%
Taylor expanded in im around 0 99.4%
Simplified99.4%
Taylor expanded in re around inf 99.4%
*-commutative99.4%
associate-*l*99.4%
unpow299.4%
distribute-lft1-in99.3%
+-commutative99.3%
unpow299.3%
*-commutative99.3%
unpow299.3%
Simplified99.3%
Final simplification95.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (* 0.5 (* (cos re) im)))) (t_1 (+ 0.25 (* 0.25 (* re re)))))
(if (<= im -2.9e+150)
t_0
(if (<= im -600.0)
t_1
(if (<= im 2.3)
(cos re)
(if (<= im 5.4e+135)
(* (* im im) (+ 0.5 (* (* re re) -0.25)))
(if (<= im 2.6e+138) t_1 t_0)))))))
double code(double re, double im) {
double t_0 = im * (0.5 * (cos(re) * im));
double t_1 = 0.25 + (0.25 * (re * re));
double tmp;
if (im <= -2.9e+150) {
tmp = t_0;
} else if (im <= -600.0) {
tmp = t_1;
} else if (im <= 2.3) {
tmp = cos(re);
} else if (im <= 5.4e+135) {
tmp = (im * im) * (0.5 + ((re * re) * -0.25));
} else if (im <= 2.6e+138) {
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 = 0.25d0 + (0.25d0 * (re * re))
if (im <= (-2.9d+150)) then
tmp = t_0
else if (im <= (-600.0d0)) then
tmp = t_1
else if (im <= 2.3d0) then
tmp = cos(re)
else if (im <= 5.4d+135) then
tmp = (im * im) * (0.5d0 + ((re * re) * (-0.25d0)))
else if (im <= 2.6d+138) 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 = 0.25 + (0.25 * (re * re));
double tmp;
if (im <= -2.9e+150) {
tmp = t_0;
} else if (im <= -600.0) {
tmp = t_1;
} else if (im <= 2.3) {
tmp = Math.cos(re);
} else if (im <= 5.4e+135) {
tmp = (im * im) * (0.5 + ((re * re) * -0.25));
} else if (im <= 2.6e+138) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = im * (0.5 * (math.cos(re) * im)) t_1 = 0.25 + (0.25 * (re * re)) tmp = 0 if im <= -2.9e+150: tmp = t_0 elif im <= -600.0: tmp = t_1 elif im <= 2.3: tmp = math.cos(re) elif im <= 5.4e+135: tmp = (im * im) * (0.5 + ((re * re) * -0.25)) elif im <= 2.6e+138: 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(0.25 + Float64(0.25 * Float64(re * re))) tmp = 0.0 if (im <= -2.9e+150) tmp = t_0; elseif (im <= -600.0) tmp = t_1; elseif (im <= 2.3) tmp = cos(re); elseif (im <= 5.4e+135) tmp = Float64(Float64(im * im) * Float64(0.5 + Float64(Float64(re * re) * -0.25))); elseif (im <= 2.6e+138) 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 = 0.25 + (0.25 * (re * re)); tmp = 0.0; if (im <= -2.9e+150) tmp = t_0; elseif (im <= -600.0) tmp = t_1; elseif (im <= 2.3) tmp = cos(re); elseif (im <= 5.4e+135) tmp = (im * im) * (0.5 + ((re * re) * -0.25)); elseif (im <= 2.6e+138) 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[(0.25 + N[(0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.9e+150], t$95$0, If[LessEqual[im, -600.0], t$95$1, If[LessEqual[im, 2.3], N[Cos[re], $MachinePrecision], If[LessEqual[im, 5.4e+135], N[(N[(im * im), $MachinePrecision] * N[(0.5 + N[(N[(re * re), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.6e+138], 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 := 0.25 + 0.25 \cdot \left(re \cdot re\right)\\
\mathbf{if}\;im \leq -2.9 \cdot 10^{+150}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -600:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 2.3:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 5.4 \cdot 10^{+135}:\\
\;\;\;\;\left(im \cdot im\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)\\
\mathbf{elif}\;im \leq 2.6 \cdot 10^{+138}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -2.90000000000000011e150 or 2.6000000000000001e138 < im Initial program 100.0%
Taylor expanded in im around 0 92.5%
Simplified92.5%
Taylor expanded in im around inf 92.5%
unpow292.5%
associate-*r*92.5%
associate-*r*92.5%
*-commutative92.5%
*-commutative92.5%
Simplified92.5%
if -2.90000000000000011e150 < im < -600 or 5.3999999999999997e135 < im < 2.6000000000000001e138Initial program 100.0%
Applied egg-rr2.7%
Taylor expanded in re around 0 18.7%
*-commutative18.7%
unpow218.7%
Simplified18.7%
if -600 < im < 2.2999999999999998Initial program 100.0%
Taylor expanded in im around 0 98.1%
if 2.2999999999999998 < im < 5.3999999999999997e135Initial program 100.0%
Taylor expanded in im around 0 5.9%
Simplified5.9%
Taylor expanded in im around inf 5.8%
*-commutative5.8%
associate-*r*5.8%
unpow25.8%
Simplified5.8%
Taylor expanded in re around 0 27.6%
associate-*r*27.6%
distribute-rgt-out27.6%
unpow227.6%
+-commutative27.6%
*-commutative27.6%
unpow227.6%
Simplified27.6%
Final simplification78.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (* 0.5 (* (cos re) im)))))
(if (<= im -4e+150)
t_0
(if (<= im -255.0)
(+ 0.25 (* 0.25 (* re re)))
(if (<= im 320000.0) (+ (cos re) (* im (* 0.5 im))) t_0)))))
double code(double re, double im) {
double t_0 = im * (0.5 * (cos(re) * im));
double tmp;
if (im <= -4e+150) {
tmp = t_0;
} else if (im <= -255.0) {
tmp = 0.25 + (0.25 * (re * re));
} else if (im <= 320000.0) {
tmp = cos(re) + (im * (0.5 * 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 * (0.5d0 * (cos(re) * im))
if (im <= (-4d+150)) then
tmp = t_0
else if (im <= (-255.0d0)) then
tmp = 0.25d0 + (0.25d0 * (re * re))
else if (im <= 320000.0d0) then
tmp = cos(re) + (im * (0.5d0 * im))
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 tmp;
if (im <= -4e+150) {
tmp = t_0;
} else if (im <= -255.0) {
tmp = 0.25 + (0.25 * (re * re));
} else if (im <= 320000.0) {
tmp = Math.cos(re) + (im * (0.5 * im));
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = im * (0.5 * (math.cos(re) * im)) tmp = 0 if im <= -4e+150: tmp = t_0 elif im <= -255.0: tmp = 0.25 + (0.25 * (re * re)) elif im <= 320000.0: tmp = math.cos(re) + (im * (0.5 * im)) else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(im * Float64(0.5 * Float64(cos(re) * im))) tmp = 0.0 if (im <= -4e+150) tmp = t_0; elseif (im <= -255.0) tmp = Float64(0.25 + Float64(0.25 * Float64(re * re))); elseif (im <= 320000.0) tmp = Float64(cos(re) + Float64(im * Float64(0.5 * im))); else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = im * (0.5 * (cos(re) * im)); tmp = 0.0; if (im <= -4e+150) tmp = t_0; elseif (im <= -255.0) tmp = 0.25 + (0.25 * (re * re)); elseif (im <= 320000.0) tmp = cos(re) + (im * (0.5 * im)); 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]}, If[LessEqual[im, -4e+150], t$95$0, If[LessEqual[im, -255.0], N[(0.25 + N[(0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 320000.0], N[(N[Cos[re], $MachinePrecision] + N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := im \cdot \left(0.5 \cdot \left(\cos re \cdot im\right)\right)\\
\mathbf{if}\;im \leq -4 \cdot 10^{+150}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -255:\\
\;\;\;\;0.25 + 0.25 \cdot \left(re \cdot re\right)\\
\mathbf{elif}\;im \leq 320000:\\
\;\;\;\;\cos re + im \cdot \left(0.5 \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -3.99999999999999992e150 or 3.2e5 < im Initial program 100.0%
Taylor expanded in im around 0 73.9%
Simplified73.9%
Taylor expanded in im around inf 73.9%
unpow273.9%
associate-*r*73.9%
associate-*r*73.9%
*-commutative73.9%
*-commutative73.9%
Simplified73.9%
if -3.99999999999999992e150 < im < -255Initial program 100.0%
Applied egg-rr2.7%
Taylor expanded in re around 0 16.8%
*-commutative16.8%
unpow216.8%
Simplified16.8%
if -255 < im < 3.2e5Initial program 100.0%
Taylor expanded in im around 0 97.0%
Simplified97.0%
Taylor expanded in re around 0 96.8%
unpow296.8%
Simplified96.8%
fma-udef96.8%
*-commutative96.8%
associate-*l*96.8%
Applied egg-rr96.8%
Final simplification77.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (* 0.5 (* (cos re) im)))))
(if (<= im -6.6e+150)
t_0
(if (<= im -600.0)
(* (pow re 4.0) (* im (* im 0.020833333333333332)))
(if (<= im 21000000.0) (+ (cos re) (* im (* 0.5 im))) t_0)))))
double code(double re, double im) {
double t_0 = im * (0.5 * (cos(re) * im));
double tmp;
if (im <= -6.6e+150) {
tmp = t_0;
} else if (im <= -600.0) {
tmp = pow(re, 4.0) * (im * (im * 0.020833333333333332));
} else if (im <= 21000000.0) {
tmp = cos(re) + (im * (0.5 * 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 * (0.5d0 * (cos(re) * im))
if (im <= (-6.6d+150)) then
tmp = t_0
else if (im <= (-600.0d0)) then
tmp = (re ** 4.0d0) * (im * (im * 0.020833333333333332d0))
else if (im <= 21000000.0d0) then
tmp = cos(re) + (im * (0.5d0 * im))
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 tmp;
if (im <= -6.6e+150) {
tmp = t_0;
} else if (im <= -600.0) {
tmp = Math.pow(re, 4.0) * (im * (im * 0.020833333333333332));
} else if (im <= 21000000.0) {
tmp = Math.cos(re) + (im * (0.5 * im));
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = im * (0.5 * (math.cos(re) * im)) tmp = 0 if im <= -6.6e+150: tmp = t_0 elif im <= -600.0: tmp = math.pow(re, 4.0) * (im * (im * 0.020833333333333332)) elif im <= 21000000.0: tmp = math.cos(re) + (im * (0.5 * im)) else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(im * Float64(0.5 * Float64(cos(re) * im))) tmp = 0.0 if (im <= -6.6e+150) tmp = t_0; elseif (im <= -600.0) tmp = Float64((re ^ 4.0) * Float64(im * Float64(im * 0.020833333333333332))); elseif (im <= 21000000.0) tmp = Float64(cos(re) + Float64(im * Float64(0.5 * im))); else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = im * (0.5 * (cos(re) * im)); tmp = 0.0; if (im <= -6.6e+150) tmp = t_0; elseif (im <= -600.0) tmp = (re ^ 4.0) * (im * (im * 0.020833333333333332)); elseif (im <= 21000000.0) tmp = cos(re) + (im * (0.5 * im)); 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]}, If[LessEqual[im, -6.6e+150], t$95$0, If[LessEqual[im, -600.0], N[(N[Power[re, 4.0], $MachinePrecision] * N[(im * N[(im * 0.020833333333333332), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 21000000.0], N[(N[Cos[re], $MachinePrecision] + N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := im \cdot \left(0.5 \cdot \left(\cos re \cdot im\right)\right)\\
\mathbf{if}\;im \leq -6.6 \cdot 10^{+150}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -600:\\
\;\;\;\;{re}^{4} \cdot \left(im \cdot \left(im \cdot 0.020833333333333332\right)\right)\\
\mathbf{elif}\;im \leq 21000000:\\
\;\;\;\;\cos re + im \cdot \left(0.5 \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -6.59999999999999962e150 or 2.1e7 < im Initial program 100.0%
Taylor expanded in im around 0 73.9%
Simplified73.9%
Taylor expanded in im around inf 73.9%
unpow273.9%
associate-*r*73.9%
associate-*r*73.9%
*-commutative73.9%
*-commutative73.9%
Simplified73.9%
if -6.59999999999999962e150 < im < -600Initial program 100.0%
Taylor expanded in im around 0 5.0%
Simplified5.0%
Taylor expanded in im around inf 5.0%
*-commutative5.0%
associate-*r*5.0%
unpow25.0%
Simplified5.0%
Taylor expanded in re around 0 7.6%
associate-+r+7.6%
+-commutative7.6%
associate-*r*7.6%
*-commutative7.6%
associate-*r*7.6%
distribute-rgt-out7.6%
distribute-lft-out14.8%
unpow214.8%
*-commutative14.8%
unpow214.8%
*-commutative14.8%
Simplified14.8%
Taylor expanded in re around inf 27.2%
*-commutative27.2%
associate-*r*27.2%
unpow227.2%
associate-*l*27.2%
Simplified27.2%
if -600 < im < 2.1e7Initial program 100.0%
Taylor expanded in im around 0 97.0%
Simplified97.0%
Taylor expanded in re around 0 96.8%
unpow296.8%
Simplified96.8%
fma-udef96.8%
*-commutative96.8%
associate-*l*96.8%
Applied egg-rr96.8%
Final simplification78.7%
(FPCore (re im) :precision binary64 (* (cos re) (+ 1.0 (* 0.5 (* im im)))))
double code(double re, double im) {
return cos(re) * (1.0 + (0.5 * (im * im)));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = cos(re) * (1.0d0 + (0.5d0 * (im * im)))
end function
public static double code(double re, double im) {
return Math.cos(re) * (1.0 + (0.5 * (im * im)));
}
def code(re, im): return math.cos(re) * (1.0 + (0.5 * (im * im)))
function code(re, im) return Float64(cos(re) * Float64(1.0 + Float64(0.5 * Float64(im * im)))) end
function tmp = code(re, im) tmp = cos(re) * (1.0 + (0.5 * (im * im))); end
code[re_, im_] := N[(N[Cos[re], $MachinePrecision] * N[(1.0 + N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos re \cdot \left(1 + 0.5 \cdot \left(im \cdot im\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 75.1%
Simplified75.1%
Taylor expanded in re around inf 75.1%
*-commutative75.1%
associate-*l*75.1%
unpow275.1%
distribute-lft1-in75.1%
+-commutative75.1%
unpow275.1%
*-commutative75.1%
unpow275.1%
Simplified75.1%
Final simplification75.1%
(FPCore (re im) :precision binary64 (if (or (<= im -1.8e+23) (not (<= im 2.5))) (* (* im im) (+ 0.5 (* (* re re) -0.25))) (cos re)))
double code(double re, double im) {
double tmp;
if ((im <= -1.8e+23) || !(im <= 2.5)) {
tmp = (im * im) * (0.5 + ((re * re) * -0.25));
} else {
tmp = cos(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-1.8d+23)) .or. (.not. (im <= 2.5d0))) then
tmp = (im * im) * (0.5d0 + ((re * re) * (-0.25d0)))
else
tmp = cos(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -1.8e+23) || !(im <= 2.5)) {
tmp = (im * im) * (0.5 + ((re * re) * -0.25));
} else {
tmp = Math.cos(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -1.8e+23) or not (im <= 2.5): tmp = (im * im) * (0.5 + ((re * re) * -0.25)) else: tmp = math.cos(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -1.8e+23) || !(im <= 2.5)) tmp = Float64(Float64(im * im) * Float64(0.5 + Float64(Float64(re * re) * -0.25))); else tmp = cos(re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -1.8e+23) || ~((im <= 2.5))) tmp = (im * im) * (0.5 + ((re * re) * -0.25)); else tmp = cos(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -1.8e+23], N[Not[LessEqual[im, 2.5]], $MachinePrecision]], N[(N[(im * im), $MachinePrecision] * N[(0.5 + N[(N[(re * re), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Cos[re], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.8 \cdot 10^{+23} \lor \neg \left(im \leq 2.5\right):\\
\;\;\;\;\left(im \cdot im\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)\\
\mathbf{else}:\\
\;\;\;\;\cos re\\
\end{array}
\end{array}
if im < -1.7999999999999999e23 or 2.5 < im Initial program 100.0%
Taylor expanded in im around 0 51.4%
Simplified51.4%
Taylor expanded in im around inf 51.4%
*-commutative51.4%
associate-*r*51.4%
unpow251.4%
Simplified51.4%
Taylor expanded in re around 0 10.0%
associate-*r*10.0%
distribute-rgt-out49.3%
unpow249.3%
+-commutative49.3%
*-commutative49.3%
unpow249.3%
Simplified49.3%
if -1.7999999999999999e23 < im < 2.5Initial program 100.0%
Taylor expanded in im around 0 93.5%
Final simplification74.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* im im) (+ 0.5 (* (* re re) -0.25)))))
(if (<= im -6.8e+23)
t_0
(if (<= im 320000.0)
(+ 1.0 (* 0.5 (* im im)))
(if (<= im 1e+161) t_0 (* im (/ im 2.0)))))))
double code(double re, double im) {
double t_0 = (im * im) * (0.5 + ((re * re) * -0.25));
double tmp;
if (im <= -6.8e+23) {
tmp = t_0;
} else if (im <= 320000.0) {
tmp = 1.0 + (0.5 * (im * im));
} else if (im <= 1e+161) {
tmp = t_0;
} else {
tmp = im * (im / 2.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 * im) * (0.5d0 + ((re * re) * (-0.25d0)))
if (im <= (-6.8d+23)) then
tmp = t_0
else if (im <= 320000.0d0) then
tmp = 1.0d0 + (0.5d0 * (im * im))
else if (im <= 1d+161) then
tmp = t_0
else
tmp = im * (im / 2.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = (im * im) * (0.5 + ((re * re) * -0.25));
double tmp;
if (im <= -6.8e+23) {
tmp = t_0;
} else if (im <= 320000.0) {
tmp = 1.0 + (0.5 * (im * im));
} else if (im <= 1e+161) {
tmp = t_0;
} else {
tmp = im * (im / 2.0);
}
return tmp;
}
def code(re, im): t_0 = (im * im) * (0.5 + ((re * re) * -0.25)) tmp = 0 if im <= -6.8e+23: tmp = t_0 elif im <= 320000.0: tmp = 1.0 + (0.5 * (im * im)) elif im <= 1e+161: tmp = t_0 else: tmp = im * (im / 2.0) return tmp
function code(re, im) t_0 = Float64(Float64(im * im) * Float64(0.5 + Float64(Float64(re * re) * -0.25))) tmp = 0.0 if (im <= -6.8e+23) tmp = t_0; elseif (im <= 320000.0) tmp = Float64(1.0 + Float64(0.5 * Float64(im * im))); elseif (im <= 1e+161) tmp = t_0; else tmp = Float64(im * Float64(im / 2.0)); end return tmp end
function tmp_2 = code(re, im) t_0 = (im * im) * (0.5 + ((re * re) * -0.25)); tmp = 0.0; if (im <= -6.8e+23) tmp = t_0; elseif (im <= 320000.0) tmp = 1.0 + (0.5 * (im * im)); elseif (im <= 1e+161) tmp = t_0; else tmp = im * (im / 2.0); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(im * im), $MachinePrecision] * N[(0.5 + N[(N[(re * re), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -6.8e+23], t$95$0, If[LessEqual[im, 320000.0], N[(1.0 + N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1e+161], t$95$0, N[(im * N[(im / 2.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(im \cdot im\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)\\
\mathbf{if}\;im \leq -6.8 \cdot 10^{+23}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 320000:\\
\;\;\;\;1 + 0.5 \cdot \left(im \cdot im\right)\\
\mathbf{elif}\;im \leq 10^{+161}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;im \cdot \frac{im}{2}\\
\end{array}
\end{array}
if im < -6.79999999999999983e23 or 3.2e5 < im < 1e161Initial program 100.0%
Taylor expanded in im around 0 40.8%
Simplified40.8%
Taylor expanded in im around inf 40.8%
*-commutative40.8%
associate-*r*40.8%
unpow240.8%
Simplified40.8%
Taylor expanded in re around 0 12.4%
associate-*r*12.4%
distribute-rgt-out45.0%
unpow245.0%
+-commutative45.0%
*-commutative45.0%
unpow245.0%
Simplified45.0%
if -6.79999999999999983e23 < im < 3.2e5Initial program 100.0%
Taylor expanded in im around 0 92.5%
Simplified92.5%
Taylor expanded in re around 0 54.5%
*-commutative54.5%
unpow254.5%
Simplified54.5%
if 1e161 < im Initial 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%
Taylor expanded in re around 0 85.7%
unpow285.7%
rem-log-exp85.7%
log-pow85.7%
log-pow85.7%
unpow1/285.7%
sqr-pow85.7%
rem-sqrt-square85.7%
sqr-pow85.7%
fabs-sqr85.7%
sqr-pow85.7%
log-pow85.7%
rem-log-exp85.7%
Simplified85.7%
Final simplification53.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (/ im 2.0))) (t_1 (+ 0.25 (* 0.25 (* re re)))))
(if (<= im -6.6e+150)
t_0
(if (<= im -410.0)
t_1
(if (<= im 1.3e+15) 0.25 (if (<= im 1.8e+154) t_1 t_0))))))
double code(double re, double im) {
double t_0 = im * (im / 2.0);
double t_1 = 0.25 + (0.25 * (re * re));
double tmp;
if (im <= -6.6e+150) {
tmp = t_0;
} else if (im <= -410.0) {
tmp = t_1;
} else if (im <= 1.3e+15) {
tmp = 0.25;
} else if (im <= 1.8e+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 * (im / 2.0d0)
t_1 = 0.25d0 + (0.25d0 * (re * re))
if (im <= (-6.6d+150)) then
tmp = t_0
else if (im <= (-410.0d0)) then
tmp = t_1
else if (im <= 1.3d+15) then
tmp = 0.25d0
else if (im <= 1.8d+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 * (im / 2.0);
double t_1 = 0.25 + (0.25 * (re * re));
double tmp;
if (im <= -6.6e+150) {
tmp = t_0;
} else if (im <= -410.0) {
tmp = t_1;
} else if (im <= 1.3e+15) {
tmp = 0.25;
} else if (im <= 1.8e+154) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = im * (im / 2.0) t_1 = 0.25 + (0.25 * (re * re)) tmp = 0 if im <= -6.6e+150: tmp = t_0 elif im <= -410.0: tmp = t_1 elif im <= 1.3e+15: tmp = 0.25 elif im <= 1.8e+154: tmp = t_1 else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(im * Float64(im / 2.0)) t_1 = Float64(0.25 + Float64(0.25 * Float64(re * re))) tmp = 0.0 if (im <= -6.6e+150) tmp = t_0; elseif (im <= -410.0) tmp = t_1; elseif (im <= 1.3e+15) tmp = 0.25; elseif (im <= 1.8e+154) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = im * (im / 2.0); t_1 = 0.25 + (0.25 * (re * re)); tmp = 0.0; if (im <= -6.6e+150) tmp = t_0; elseif (im <= -410.0) tmp = t_1; elseif (im <= 1.3e+15) tmp = 0.25; elseif (im <= 1.8e+154) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(im / 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.25 + N[(0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -6.6e+150], t$95$0, If[LessEqual[im, -410.0], t$95$1, If[LessEqual[im, 1.3e+15], 0.25, If[LessEqual[im, 1.8e+154], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := im \cdot \frac{im}{2}\\
t_1 := 0.25 + 0.25 \cdot \left(re \cdot re\right)\\
\mathbf{if}\;im \leq -6.6 \cdot 10^{+150}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -410:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 1.3 \cdot 10^{+15}:\\
\;\;\;\;0.25\\
\mathbf{elif}\;im \leq 1.8 \cdot 10^{+154}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -6.59999999999999962e150 or 1.8e154 < im Initial program 100.0%
Taylor expanded in im around 0 98.4%
Simplified98.4%
Taylor expanded in im around inf 98.4%
*-commutative98.4%
associate-*r*98.4%
unpow298.4%
Simplified98.4%
Taylor expanded in re around 0 63.8%
unpow263.8%
rem-log-exp65.5%
log-pow65.5%
log-pow65.5%
unpow1/265.5%
sqr-pow65.5%
rem-sqrt-square65.5%
sqr-pow65.5%
fabs-sqr65.5%
sqr-pow65.5%
log-pow65.5%
rem-log-exp63.8%
Simplified63.8%
if -6.59999999999999962e150 < im < -410 or 1.3e15 < im < 1.8e154Initial program 100.0%
Applied egg-rr2.7%
Taylor expanded in re around 0 17.3%
*-commutative17.3%
unpow217.3%
Simplified17.3%
if -410 < im < 1.3e15Initial program 100.0%
Applied egg-rr13.5%
Taylor expanded in re around 0 13.8%
Final simplification25.4%
(FPCore (re im) :precision binary64 (if (or (<= re -4.5e+167) (not (<= re 1.56))) (* im (* (* re re) (* im -0.25))) (+ 1.0 (* 0.5 (* im im)))))
double code(double re, double im) {
double tmp;
if ((re <= -4.5e+167) || !(re <= 1.56)) {
tmp = im * ((re * re) * (im * -0.25));
} else {
tmp = 1.0 + (0.5 * (im * im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((re <= (-4.5d+167)) .or. (.not. (re <= 1.56d0))) then
tmp = im * ((re * re) * (im * (-0.25d0)))
else
tmp = 1.0d0 + (0.5d0 * (im * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -4.5e+167) || !(re <= 1.56)) {
tmp = im * ((re * re) * (im * -0.25));
} else {
tmp = 1.0 + (0.5 * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -4.5e+167) or not (re <= 1.56): tmp = im * ((re * re) * (im * -0.25)) else: tmp = 1.0 + (0.5 * (im * im)) return tmp
function code(re, im) tmp = 0.0 if ((re <= -4.5e+167) || !(re <= 1.56)) tmp = Float64(im * Float64(Float64(re * re) * Float64(im * -0.25))); else tmp = Float64(1.0 + Float64(0.5 * Float64(im * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -4.5e+167) || ~((re <= 1.56))) tmp = im * ((re * re) * (im * -0.25)); else tmp = 1.0 + (0.5 * (im * im)); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -4.5e+167], N[Not[LessEqual[re, 1.56]], $MachinePrecision]], N[(im * N[(N[(re * re), $MachinePrecision] * N[(im * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -4.5 \cdot 10^{+167} \lor \neg \left(re \leq 1.56\right):\\
\;\;\;\;im \cdot \left(\left(re \cdot re\right) \cdot \left(im \cdot -0.25\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 + 0.5 \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if re < -4.4999999999999999e167 or 1.5600000000000001 < re Initial program 100.0%
Taylor expanded in im around 0 76.5%
Simplified76.5%
Taylor expanded in im around inf 29.7%
*-commutative29.7%
associate-*r*29.7%
unpow229.7%
Simplified29.7%
Taylor expanded in re around 0 11.4%
associate-*r*11.4%
distribute-rgt-out29.5%
unpow229.5%
+-commutative29.5%
*-commutative29.5%
unpow229.5%
Simplified29.5%
Taylor expanded in re around inf 29.5%
*-commutative29.5%
*-commutative29.5%
associate-*r*29.5%
unpow229.5%
associate-*r*29.5%
unpow229.5%
associate-*l*29.7%
associate-*r*29.7%
unpow229.7%
associate-*l*29.7%
*-commutative29.7%
associate-*l*29.7%
unpow229.7%
Simplified29.7%
if -4.4999999999999999e167 < re < 1.5600000000000001Initial program 100.0%
Taylor expanded in im around 0 74.4%
Simplified74.4%
Taylor expanded in re around 0 62.5%
*-commutative62.5%
unpow262.5%
Simplified62.5%
Final simplification51.2%
(FPCore (re im) :precision binary64 (if (or (<= im -11.5) (not (<= im 0.7))) (* im (/ im 2.0)) 0.25))
double code(double re, double im) {
double tmp;
if ((im <= -11.5) || !(im <= 0.7)) {
tmp = im * (im / 2.0);
} 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 <= (-11.5d0)) .or. (.not. (im <= 0.7d0))) then
tmp = im * (im / 2.0d0)
else
tmp = 0.25d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -11.5) || !(im <= 0.7)) {
tmp = im * (im / 2.0);
} else {
tmp = 0.25;
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -11.5) or not (im <= 0.7): tmp = im * (im / 2.0) else: tmp = 0.25 return tmp
function code(re, im) tmp = 0.0 if ((im <= -11.5) || !(im <= 0.7)) tmp = Float64(im * Float64(im / 2.0)); else tmp = 0.25; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -11.5) || ~((im <= 0.7))) tmp = im * (im / 2.0); else tmp = 0.25; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -11.5], N[Not[LessEqual[im, 0.7]], $MachinePrecision]], N[(im * N[(im / 2.0), $MachinePrecision]), $MachinePrecision], 0.25]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -11.5 \lor \neg \left(im \leq 0.7\right):\\
\;\;\;\;im \cdot \frac{im}{2}\\
\mathbf{else}:\\
\;\;\;\;0.25\\
\end{array}
\end{array}
if im < -11.5 or 0.69999999999999996 < im Initial program 100.0%
Taylor expanded in im around 0 48.2%
Simplified48.2%
Taylor expanded in im around inf 48.2%
*-commutative48.2%
associate-*r*48.2%
unpow248.2%
Simplified48.2%
Taylor expanded in re around 0 32.0%
unpow232.0%
rem-log-exp73.6%
log-pow73.5%
log-pow73.5%
unpow1/273.5%
sqr-pow73.5%
rem-sqrt-square73.5%
sqr-pow73.5%
fabs-sqr73.5%
sqr-pow73.5%
log-pow73.6%
rem-log-exp32.0%
Simplified32.0%
if -11.5 < im < 0.69999999999999996Initial program 100.0%
Applied egg-rr13.7%
Taylor expanded in re around 0 14.0%
Final simplification22.4%
(FPCore (re im) :precision binary64 (+ 1.0 (* 0.5 (* im im))))
double code(double re, double im) {
return 1.0 + (0.5 * (im * im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 1.0d0 + (0.5d0 * (im * im))
end function
public static double code(double re, double im) {
return 1.0 + (0.5 * (im * im));
}
def code(re, im): return 1.0 + (0.5 * (im * im))
function code(re, im) return Float64(1.0 + Float64(0.5 * Float64(im * im))) end
function tmp = code(re, im) tmp = 1.0 + (0.5 * (im * im)); end
code[re_, im_] := N[(1.0 + N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + 0.5 \cdot \left(im \cdot im\right)
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 75.1%
Simplified75.1%
Taylor expanded in re around 0 45.9%
*-commutative45.9%
unpow245.9%
Simplified45.9%
Final simplification45.9%
(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-rr8.5%
Taylor expanded in re around 0 8.7%
Final simplification8.7%
herbie shell --seed 2023193
(FPCore (re im)
:name "math.cos on complex, real part"
:precision binary64
(* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))