
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * sin(re)) * (exp((0.0d0 - im)) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp((0.0 - im)) + Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp((0.0 - im)) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(0.0 - im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * sin(re)) * (exp((0.0d0 - im)) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp((0.0 - im)) + Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp((0.0 - im)) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(0.0 - im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)
\end{array}
(FPCore (re im) :precision binary64 (* (sin re) (* 0.5 (+ (exp (- im)) (exp im)))))
double code(double re, double im) {
return sin(re) * (0.5 * (exp(-im) + exp(im)));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = sin(re) * (0.5d0 * (exp(-im) + exp(im)))
end function
public static double code(double re, double im) {
return Math.sin(re) * (0.5 * (Math.exp(-im) + Math.exp(im)));
}
def code(re, im): return math.sin(re) * (0.5 * (math.exp(-im) + math.exp(im)))
function code(re, im) return Float64(sin(re) * Float64(0.5 * Float64(exp(Float64(-im)) + exp(im)))) end
function tmp = code(re, im) tmp = sin(re) * (0.5 * (exp(-im) + exp(im))); end
code[re_, im_] := N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin re \cdot \left(0.5 \cdot \left(e^{-im} + e^{im}\right)\right)
\end{array}
Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (re im)
:precision binary64
(let* ((t_0
(*
(sin re)
(+ 1.0 (* (* im im) (+ 0.5 (* (* im im) 0.041666666666666664)))))))
(if (<= im -2.55e+77)
t_0
(if (<= im -0.011)
(* 0.5 (fma re (exp im) (/ re (exp im))))
(if (<= im 0.039)
(* (sin re) (+ 1.0 (* im (* 0.5 im))))
(if (<= im 2.6e+77) (* (+ (exp (- im)) (exp im)) (* re 0.5)) t_0))))))
double code(double re, double im) {
double t_0 = sin(re) * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664))));
double tmp;
if (im <= -2.55e+77) {
tmp = t_0;
} else if (im <= -0.011) {
tmp = 0.5 * fma(re, exp(im), (re / exp(im)));
} else if (im <= 0.039) {
tmp = sin(re) * (1.0 + (im * (0.5 * im)));
} else if (im <= 2.6e+77) {
tmp = (exp(-im) + exp(im)) * (re * 0.5);
} else {
tmp = t_0;
}
return tmp;
}
function code(re, im) t_0 = Float64(sin(re) * Float64(1.0 + Float64(Float64(im * im) * Float64(0.5 + Float64(Float64(im * im) * 0.041666666666666664))))) tmp = 0.0 if (im <= -2.55e+77) tmp = t_0; elseif (im <= -0.011) tmp = Float64(0.5 * fma(re, exp(im), Float64(re / exp(im)))); elseif (im <= 0.039) tmp = Float64(sin(re) * Float64(1.0 + Float64(im * Float64(0.5 * im)))); elseif (im <= 2.6e+77) tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(re * 0.5)); else tmp = t_0; end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[Sin[re], $MachinePrecision] * N[(1.0 + N[(N[(im * im), $MachinePrecision] * N[(0.5 + N[(N[(im * im), $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.55e+77], t$95$0, If[LessEqual[im, -0.011], N[(0.5 * N[(re * N[Exp[im], $MachinePrecision] + N[(re / N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 0.039], N[(N[Sin[re], $MachinePrecision] * N[(1.0 + N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.6e+77], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin re \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\
\mathbf{if}\;im \leq -2.55 \cdot 10^{+77}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -0.011:\\
\;\;\;\;0.5 \cdot \mathsf{fma}\left(re, e^{im}, \frac{re}{e^{im}}\right)\\
\mathbf{elif}\;im \leq 0.039:\\
\;\;\;\;\sin re \cdot \left(1 + im \cdot \left(0.5 \cdot im\right)\right)\\
\mathbf{elif}\;im \leq 2.6 \cdot 10^{+77}:\\
\;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(re \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -2.54999999999999985e77 or 2.6000000000000002e77 < im Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
*-rgt-identity100.0%
*-commutative100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
distribute-lft-out100.0%
metadata-eval100.0%
pow-sqr100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
unpow2100.0%
unpow2100.0%
Simplified100.0%
if -2.54999999999999985e77 < im < -0.010999999999999999Initial program 99.9%
*-commutative99.9%
associate-*l*99.9%
sub0-neg99.9%
Simplified99.9%
Taylor expanded in re around 0 71.4%
distribute-lft-in71.4%
fma-def71.4%
exp-neg71.4%
associate-*r/71.4%
*-rgt-identity71.4%
Simplified71.4%
if -0.010999999999999999 < im < 0.0389999999999999999Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt1-in100.0%
*-commutative100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
if 0.0389999999999999999 < im < 2.6000000000000002e77Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 92.9%
associate-*r*92.9%
Simplified92.9%
Final simplification96.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (+ (exp (- im)) (exp im)) (* re 0.5)))
(t_1
(*
(sin re)
(+ 1.0 (* (* im im) (+ 0.5 (* (* im im) 0.041666666666666664)))))))
(if (<= im -2.55e+77)
t_1
(if (<= im -0.0125)
t_0
(if (<= im 0.022)
(* (sin re) (+ 1.0 (* im (* 0.5 im))))
(if (<= im 2.6e+77) t_0 t_1))))))
double code(double re, double im) {
double t_0 = (exp(-im) + exp(im)) * (re * 0.5);
double t_1 = sin(re) * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664))));
double tmp;
if (im <= -2.55e+77) {
tmp = t_1;
} else if (im <= -0.0125) {
tmp = t_0;
} else if (im <= 0.022) {
tmp = sin(re) * (1.0 + (im * (0.5 * im)));
} else if (im <= 2.6e+77) {
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 = (exp(-im) + exp(im)) * (re * 0.5d0)
t_1 = sin(re) * (1.0d0 + ((im * im) * (0.5d0 + ((im * im) * 0.041666666666666664d0))))
if (im <= (-2.55d+77)) then
tmp = t_1
else if (im <= (-0.0125d0)) then
tmp = t_0
else if (im <= 0.022d0) then
tmp = sin(re) * (1.0d0 + (im * (0.5d0 * im)))
else if (im <= 2.6d+77) 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 = (Math.exp(-im) + Math.exp(im)) * (re * 0.5);
double t_1 = Math.sin(re) * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664))));
double tmp;
if (im <= -2.55e+77) {
tmp = t_1;
} else if (im <= -0.0125) {
tmp = t_0;
} else if (im <= 0.022) {
tmp = Math.sin(re) * (1.0 + (im * (0.5 * im)));
} else if (im <= 2.6e+77) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = (math.exp(-im) + math.exp(im)) * (re * 0.5) t_1 = math.sin(re) * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664)))) tmp = 0 if im <= -2.55e+77: tmp = t_1 elif im <= -0.0125: tmp = t_0 elif im <= 0.022: tmp = math.sin(re) * (1.0 + (im * (0.5 * im))) elif im <= 2.6e+77: tmp = t_0 else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(re * 0.5)) t_1 = Float64(sin(re) * Float64(1.0 + Float64(Float64(im * im) * Float64(0.5 + Float64(Float64(im * im) * 0.041666666666666664))))) tmp = 0.0 if (im <= -2.55e+77) tmp = t_1; elseif (im <= -0.0125) tmp = t_0; elseif (im <= 0.022) tmp = Float64(sin(re) * Float64(1.0 + Float64(im * Float64(0.5 * im)))); elseif (im <= 2.6e+77) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = (exp(-im) + exp(im)) * (re * 0.5); t_1 = sin(re) * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664)))); tmp = 0.0; if (im <= -2.55e+77) tmp = t_1; elseif (im <= -0.0125) tmp = t_0; elseif (im <= 0.022) tmp = sin(re) * (1.0 + (im * (0.5 * im))); elseif (im <= 2.6e+77) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[re], $MachinePrecision] * N[(1.0 + N[(N[(im * im), $MachinePrecision] * N[(0.5 + N[(N[(im * im), $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.55e+77], t$95$1, If[LessEqual[im, -0.0125], t$95$0, If[LessEqual[im, 0.022], N[(N[Sin[re], $MachinePrecision] * N[(1.0 + N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.6e+77], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{-im} + e^{im}\right) \cdot \left(re \cdot 0.5\right)\\
t_1 := \sin re \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\
\mathbf{if}\;im \leq -2.55 \cdot 10^{+77}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -0.0125:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 0.022:\\
\;\;\;\;\sin re \cdot \left(1 + im \cdot \left(0.5 \cdot im\right)\right)\\
\mathbf{elif}\;im \leq 2.6 \cdot 10^{+77}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -2.54999999999999985e77 or 2.6000000000000002e77 < im Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
*-rgt-identity100.0%
*-commutative100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
distribute-lft-out100.0%
metadata-eval100.0%
pow-sqr100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
unpow2100.0%
unpow2100.0%
Simplified100.0%
if -2.54999999999999985e77 < im < -0.012500000000000001 or 0.021999999999999999 < im < 2.6000000000000002e77Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 78.5%
associate-*r*78.5%
Simplified78.5%
if -0.012500000000000001 < im < 0.021999999999999999Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt1-in100.0%
*-commutative100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
Final simplification96.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (* (sin re) (* im im))))
(t_1
(*
re
(+ 1.0 (* (* im im) (+ 0.5 (* (* im im) 0.041666666666666664)))))))
(if (<= im -2.35e+156)
t_0
(if (<= im -0.00075)
t_1
(if (<= im 370.0) (sin re) (if (<= im 3.6e+137) t_1 t_0))))))
double code(double re, double im) {
double t_0 = 0.5 * (sin(re) * (im * im));
double t_1 = re * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664))));
double tmp;
if (im <= -2.35e+156) {
tmp = t_0;
} else if (im <= -0.00075) {
tmp = t_1;
} else if (im <= 370.0) {
tmp = sin(re);
} else if (im <= 3.6e+137) {
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 = 0.5d0 * (sin(re) * (im * im))
t_1 = re * (1.0d0 + ((im * im) * (0.5d0 + ((im * im) * 0.041666666666666664d0))))
if (im <= (-2.35d+156)) then
tmp = t_0
else if (im <= (-0.00075d0)) then
tmp = t_1
else if (im <= 370.0d0) then
tmp = sin(re)
else if (im <= 3.6d+137) 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 = 0.5 * (Math.sin(re) * (im * im));
double t_1 = re * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664))));
double tmp;
if (im <= -2.35e+156) {
tmp = t_0;
} else if (im <= -0.00075) {
tmp = t_1;
} else if (im <= 370.0) {
tmp = Math.sin(re);
} else if (im <= 3.6e+137) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * (math.sin(re) * (im * im)) t_1 = re * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664)))) tmp = 0 if im <= -2.35e+156: tmp = t_0 elif im <= -0.00075: tmp = t_1 elif im <= 370.0: tmp = math.sin(re) elif im <= 3.6e+137: tmp = t_1 else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(sin(re) * Float64(im * im))) t_1 = Float64(re * Float64(1.0 + Float64(Float64(im * im) * Float64(0.5 + Float64(Float64(im * im) * 0.041666666666666664))))) tmp = 0.0 if (im <= -2.35e+156) tmp = t_0; elseif (im <= -0.00075) tmp = t_1; elseif (im <= 370.0) tmp = sin(re); elseif (im <= 3.6e+137) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (sin(re) * (im * im)); t_1 = re * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664)))); tmp = 0.0; if (im <= -2.35e+156) tmp = t_0; elseif (im <= -0.00075) tmp = t_1; elseif (im <= 370.0) tmp = sin(re); elseif (im <= 3.6e+137) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(re * N[(1.0 + N[(N[(im * im), $MachinePrecision] * N[(0.5 + N[(N[(im * im), $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.35e+156], t$95$0, If[LessEqual[im, -0.00075], t$95$1, If[LessEqual[im, 370.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 3.6e+137], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(\sin re \cdot \left(im \cdot im\right)\right)\\
t_1 := re \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\
\mathbf{if}\;im \leq -2.35 \cdot 10^{+156}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -0.00075:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 370:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 3.6 \cdot 10^{+137}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -2.35e156 or 3.6e137 < im Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 98.5%
*-commutative98.5%
associate-*r*98.5%
distribute-rgt1-in98.5%
*-commutative98.5%
unpow298.5%
associate-*l*98.5%
Simplified98.5%
Taylor expanded in im around inf 98.5%
*-commutative98.5%
unpow298.5%
Simplified98.5%
if -2.35e156 < im < -7.5000000000000002e-4 or 370 < im < 3.6e137Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 40.5%
*-rgt-identity40.5%
*-commutative40.5%
associate-*r*40.5%
*-commutative40.5%
associate-*r*40.5%
distribute-rgt-out40.5%
distribute-lft-out40.5%
metadata-eval40.5%
pow-sqr40.5%
associate-*r*40.5%
distribute-rgt-out40.5%
unpow240.5%
unpow240.5%
Simplified40.5%
Taylor expanded in re around 0 39.2%
*-commutative39.2%
unpow239.2%
unpow239.2%
Simplified39.2%
if -7.5000000000000002e-4 < im < 370Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 99.8%
Final simplification83.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (* (sin re) (* im im))))
(t_1
(*
re
(+ 1.0 (* (* im im) (+ 0.5 (* (* im im) 0.041666666666666664)))))))
(if (<= im -2.35e+156)
t_0
(if (<= im -0.014)
t_1
(if (<= im 950.0)
(* (sin re) (+ 1.0 (* im (* 0.5 im))))
(if (<= im 3.6e+137) t_1 t_0))))))
double code(double re, double im) {
double t_0 = 0.5 * (sin(re) * (im * im));
double t_1 = re * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664))));
double tmp;
if (im <= -2.35e+156) {
tmp = t_0;
} else if (im <= -0.014) {
tmp = t_1;
} else if (im <= 950.0) {
tmp = sin(re) * (1.0 + (im * (0.5 * im)));
} else if (im <= 3.6e+137) {
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 = 0.5d0 * (sin(re) * (im * im))
t_1 = re * (1.0d0 + ((im * im) * (0.5d0 + ((im * im) * 0.041666666666666664d0))))
if (im <= (-2.35d+156)) then
tmp = t_0
else if (im <= (-0.014d0)) then
tmp = t_1
else if (im <= 950.0d0) then
tmp = sin(re) * (1.0d0 + (im * (0.5d0 * im)))
else if (im <= 3.6d+137) 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 = 0.5 * (Math.sin(re) * (im * im));
double t_1 = re * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664))));
double tmp;
if (im <= -2.35e+156) {
tmp = t_0;
} else if (im <= -0.014) {
tmp = t_1;
} else if (im <= 950.0) {
tmp = Math.sin(re) * (1.0 + (im * (0.5 * im)));
} else if (im <= 3.6e+137) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * (math.sin(re) * (im * im)) t_1 = re * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664)))) tmp = 0 if im <= -2.35e+156: tmp = t_0 elif im <= -0.014: tmp = t_1 elif im <= 950.0: tmp = math.sin(re) * (1.0 + (im * (0.5 * im))) elif im <= 3.6e+137: tmp = t_1 else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(sin(re) * Float64(im * im))) t_1 = Float64(re * Float64(1.0 + Float64(Float64(im * im) * Float64(0.5 + Float64(Float64(im * im) * 0.041666666666666664))))) tmp = 0.0 if (im <= -2.35e+156) tmp = t_0; elseif (im <= -0.014) tmp = t_1; elseif (im <= 950.0) tmp = Float64(sin(re) * Float64(1.0 + Float64(im * Float64(0.5 * im)))); elseif (im <= 3.6e+137) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (sin(re) * (im * im)); t_1 = re * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664)))); tmp = 0.0; if (im <= -2.35e+156) tmp = t_0; elseif (im <= -0.014) tmp = t_1; elseif (im <= 950.0) tmp = sin(re) * (1.0 + (im * (0.5 * im))); elseif (im <= 3.6e+137) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(re * N[(1.0 + N[(N[(im * im), $MachinePrecision] * N[(0.5 + N[(N[(im * im), $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.35e+156], t$95$0, If[LessEqual[im, -0.014], t$95$1, If[LessEqual[im, 950.0], N[(N[Sin[re], $MachinePrecision] * N[(1.0 + N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3.6e+137], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(\sin re \cdot \left(im \cdot im\right)\right)\\
t_1 := re \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\
\mathbf{if}\;im \leq -2.35 \cdot 10^{+156}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -0.014:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 950:\\
\;\;\;\;\sin re \cdot \left(1 + im \cdot \left(0.5 \cdot im\right)\right)\\
\mathbf{elif}\;im \leq 3.6 \cdot 10^{+137}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -2.35e156 or 3.6e137 < im Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 98.5%
*-commutative98.5%
associate-*r*98.5%
distribute-rgt1-in98.5%
*-commutative98.5%
unpow298.5%
associate-*l*98.5%
Simplified98.5%
Taylor expanded in im around inf 98.5%
*-commutative98.5%
unpow298.5%
Simplified98.5%
if -2.35e156 < im < -0.0140000000000000003 or 950 < im < 3.6e137Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 40.5%
*-rgt-identity40.5%
*-commutative40.5%
associate-*r*40.5%
*-commutative40.5%
associate-*r*40.5%
distribute-rgt-out40.5%
distribute-lft-out40.5%
metadata-eval40.5%
pow-sqr40.5%
associate-*r*40.5%
distribute-rgt-out40.5%
unpow240.5%
unpow240.5%
Simplified40.5%
Taylor expanded in re around 0 39.2%
*-commutative39.2%
unpow239.2%
unpow239.2%
Simplified39.2%
if -0.0140000000000000003 < im < 950Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt1-in100.0%
*-commutative100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
Final simplification84.0%
(FPCore (re im) :precision binary64 (* (sin re) (+ 1.0 (* (* im im) (+ 0.5 (* (* im im) 0.041666666666666664))))))
double code(double re, double im) {
return sin(re) * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664))));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = sin(re) * (1.0d0 + ((im * im) * (0.5d0 + ((im * im) * 0.041666666666666664d0))))
end function
public static double code(double re, double im) {
return Math.sin(re) * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664))));
}
def code(re, im): return math.sin(re) * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664))))
function code(re, im) return Float64(sin(re) * Float64(1.0 + Float64(Float64(im * im) * Float64(0.5 + Float64(Float64(im * im) * 0.041666666666666664))))) end
function tmp = code(re, im) tmp = sin(re) * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664)))); end
code[re_, im_] := N[(N[Sin[re], $MachinePrecision] * N[(1.0 + N[(N[(im * im), $MachinePrecision] * N[(0.5 + N[(N[(im * im), $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin re \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)
\end{array}
Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 84.6%
*-rgt-identity84.6%
*-commutative84.6%
associate-*r*84.6%
*-commutative84.6%
associate-*r*84.6%
distribute-rgt-out84.6%
distribute-lft-out84.6%
metadata-eval84.6%
pow-sqr84.6%
associate-*r*84.6%
distribute-rgt-out84.6%
unpow284.6%
unpow284.6%
Simplified84.6%
Final simplification84.6%
(FPCore (re im)
:precision binary64
(if (<= im -2.3e+243)
(* 0.5 (* im (* (sin re) im)))
(if (or (<= im -0.00014) (not (<= im 400.0)))
(* re (+ 1.0 (* (* im im) (+ 0.5 (* (* im im) 0.041666666666666664)))))
(sin re))))
double code(double re, double im) {
double tmp;
if (im <= -2.3e+243) {
tmp = 0.5 * (im * (sin(re) * im));
} else if ((im <= -0.00014) || !(im <= 400.0)) {
tmp = re * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664))));
} else {
tmp = sin(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= (-2.3d+243)) then
tmp = 0.5d0 * (im * (sin(re) * im))
else if ((im <= (-0.00014d0)) .or. (.not. (im <= 400.0d0))) then
tmp = re * (1.0d0 + ((im * im) * (0.5d0 + ((im * im) * 0.041666666666666664d0))))
else
tmp = sin(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= -2.3e+243) {
tmp = 0.5 * (im * (Math.sin(re) * im));
} else if ((im <= -0.00014) || !(im <= 400.0)) {
tmp = re * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664))));
} else {
tmp = Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= -2.3e+243: tmp = 0.5 * (im * (math.sin(re) * im)) elif (im <= -0.00014) or not (im <= 400.0): tmp = re * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664)))) else: tmp = math.sin(re) return tmp
function code(re, im) tmp = 0.0 if (im <= -2.3e+243) tmp = Float64(0.5 * Float64(im * Float64(sin(re) * im))); elseif ((im <= -0.00014) || !(im <= 400.0)) tmp = Float64(re * Float64(1.0 + Float64(Float64(im * im) * Float64(0.5 + Float64(Float64(im * im) * 0.041666666666666664))))); else tmp = sin(re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= -2.3e+243) tmp = 0.5 * (im * (sin(re) * im)); elseif ((im <= -0.00014) || ~((im <= 400.0))) tmp = re * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664)))); else tmp = sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, -2.3e+243], N[(0.5 * N[(im * N[(N[Sin[re], $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im, -0.00014], N[Not[LessEqual[im, 400.0]], $MachinePrecision]], N[(re * N[(1.0 + N[(N[(im * im), $MachinePrecision] * N[(0.5 + N[(N[(im * im), $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -2.3 \cdot 10^{+243}:\\
\;\;\;\;0.5 \cdot \left(im \cdot \left(\sin re \cdot im\right)\right)\\
\mathbf{elif}\;im \leq -0.00014 \lor \neg \left(im \leq 400\right):\\
\;\;\;\;re \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re\\
\end{array}
\end{array}
if im < -2.29999999999999987e243Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt1-in100.0%
*-commutative100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
*-commutative100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
if -2.29999999999999987e243 < im < -1.3999999999999999e-4 or 400 < im Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 65.5%
*-rgt-identity65.5%
*-commutative65.5%
associate-*r*65.5%
*-commutative65.5%
associate-*r*65.5%
distribute-rgt-out65.5%
distribute-lft-out65.5%
metadata-eval65.5%
pow-sqr65.5%
associate-*r*65.5%
distribute-rgt-out65.5%
unpow265.5%
unpow265.5%
Simplified65.5%
Taylor expanded in re around 0 54.2%
*-commutative54.2%
unpow254.2%
unpow254.2%
Simplified54.2%
if -1.3999999999999999e-4 < im < 400Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 99.8%
Final simplification79.5%
(FPCore (re im) :precision binary64 (if (or (<= im -0.00037) (not (<= im 250.0))) (* re (+ 1.0 (* (* im im) (+ 0.5 (* (* im im) 0.041666666666666664))))) (sin re)))
double code(double re, double im) {
double tmp;
if ((im <= -0.00037) || !(im <= 250.0)) {
tmp = re * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664))));
} else {
tmp = sin(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-0.00037d0)) .or. (.not. (im <= 250.0d0))) then
tmp = re * (1.0d0 + ((im * im) * (0.5d0 + ((im * im) * 0.041666666666666664d0))))
else
tmp = sin(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -0.00037) || !(im <= 250.0)) {
tmp = re * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664))));
} else {
tmp = Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -0.00037) or not (im <= 250.0): tmp = re * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664)))) else: tmp = math.sin(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -0.00037) || !(im <= 250.0)) tmp = Float64(re * Float64(1.0 + Float64(Float64(im * im) * Float64(0.5 + Float64(Float64(im * im) * 0.041666666666666664))))); else tmp = sin(re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -0.00037) || ~((im <= 250.0))) tmp = re * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664)))); else tmp = sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -0.00037], N[Not[LessEqual[im, 250.0]], $MachinePrecision]], N[(re * N[(1.0 + N[(N[(im * im), $MachinePrecision] * N[(0.5 + N[(N[(im * im), $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[re], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -0.00037 \lor \neg \left(im \leq 250\right):\\
\;\;\;\;re \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re\\
\end{array}
\end{array}
if im < -3.6999999999999999e-4 or 250 < im Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 69.5%
*-rgt-identity69.5%
*-commutative69.5%
associate-*r*69.5%
*-commutative69.5%
associate-*r*69.5%
distribute-rgt-out69.5%
distribute-lft-out69.5%
metadata-eval69.5%
pow-sqr69.5%
associate-*r*69.5%
distribute-rgt-out69.5%
unpow269.5%
unpow269.5%
Simplified69.5%
Taylor expanded in re around 0 55.7%
*-commutative55.7%
unpow255.7%
unpow255.7%
Simplified55.7%
if -3.6999999999999999e-4 < im < 250Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 99.8%
Final simplification77.6%
(FPCore (re im) :precision binary64 (* re (+ 1.0 (* (* im im) (+ 0.5 (* (* im im) 0.041666666666666664))))))
double code(double re, double im) {
return re * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664))));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re * (1.0d0 + ((im * im) * (0.5d0 + ((im * im) * 0.041666666666666664d0))))
end function
public static double code(double re, double im) {
return re * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664))));
}
def code(re, im): return re * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664))))
function code(re, im) return Float64(re * Float64(1.0 + Float64(Float64(im * im) * Float64(0.5 + Float64(Float64(im * im) * 0.041666666666666664))))) end
function tmp = code(re, im) tmp = re * (1.0 + ((im * im) * (0.5 + ((im * im) * 0.041666666666666664)))); end
code[re_, im_] := N[(re * N[(1.0 + N[(N[(im * im), $MachinePrecision] * N[(0.5 + N[(N[(im * im), $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
re \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)
\end{array}
Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 84.6%
*-rgt-identity84.6%
*-commutative84.6%
associate-*r*84.6%
*-commutative84.6%
associate-*r*84.6%
distribute-rgt-out84.6%
distribute-lft-out84.6%
metadata-eval84.6%
pow-sqr84.6%
associate-*r*84.6%
distribute-rgt-out84.6%
unpow284.6%
unpow284.6%
Simplified84.6%
Taylor expanded in re around 0 53.4%
*-commutative53.4%
unpow253.4%
unpow253.4%
Simplified53.4%
Final simplification53.4%
(FPCore (re im) :precision binary64 (if (or (<= im -1.42) (not (<= im 1.28e-33))) (* 0.5 (* im (* re im))) re))
double code(double re, double im) {
double tmp;
if ((im <= -1.42) || !(im <= 1.28e-33)) {
tmp = 0.5 * (im * (re * im));
} else {
tmp = 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.42d0)) .or. (.not. (im <= 1.28d-33))) then
tmp = 0.5d0 * (im * (re * im))
else
tmp = re
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -1.42) || !(im <= 1.28e-33)) {
tmp = 0.5 * (im * (re * im));
} else {
tmp = re;
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -1.42) or not (im <= 1.28e-33): tmp = 0.5 * (im * (re * im)) else: tmp = re return tmp
function code(re, im) tmp = 0.0 if ((im <= -1.42) || !(im <= 1.28e-33)) tmp = Float64(0.5 * Float64(im * Float64(re * im))); else tmp = re; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -1.42) || ~((im <= 1.28e-33))) tmp = 0.5 * (im * (re * im)); else tmp = re; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -1.42], N[Not[LessEqual[im, 1.28e-33]], $MachinePrecision]], N[(0.5 * N[(im * N[(re * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], re]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.42 \lor \neg \left(im \leq 1.28 \cdot 10^{-33}\right):\\
\;\;\;\;0.5 \cdot \left(im \cdot \left(re \cdot im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;re\\
\end{array}
\end{array}
if im < -1.4199999999999999 or 1.28000000000000001e-33 < im Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 52.7%
*-commutative52.7%
associate-*r*52.7%
distribute-rgt1-in52.7%
*-commutative52.7%
unpow252.7%
associate-*l*52.7%
Simplified52.7%
Taylor expanded in im around inf 49.9%
*-commutative49.9%
unpow249.9%
associate-*l*36.4%
Simplified36.4%
Taylor expanded in re around 0 29.4%
if -1.4199999999999999 < im < 1.28000000000000001e-33Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 53.1%
associate-*r*53.1%
Simplified53.1%
Taylor expanded in im around 0 52.6%
Final simplification40.6%
(FPCore (re im) :precision binary64 (if (or (<= im -1.42) (not (<= im 1.28e-33))) (* 0.5 (* re (* im im))) re))
double code(double re, double im) {
double tmp;
if ((im <= -1.42) || !(im <= 1.28e-33)) {
tmp = 0.5 * (re * (im * im));
} else {
tmp = 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.42d0)) .or. (.not. (im <= 1.28d-33))) then
tmp = 0.5d0 * (re * (im * im))
else
tmp = re
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -1.42) || !(im <= 1.28e-33)) {
tmp = 0.5 * (re * (im * im));
} else {
tmp = re;
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -1.42) or not (im <= 1.28e-33): tmp = 0.5 * (re * (im * im)) else: tmp = re return tmp
function code(re, im) tmp = 0.0 if ((im <= -1.42) || !(im <= 1.28e-33)) tmp = Float64(0.5 * Float64(re * Float64(im * im))); else tmp = re; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -1.42) || ~((im <= 1.28e-33))) tmp = 0.5 * (re * (im * im)); else tmp = re; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -1.42], N[Not[LessEqual[im, 1.28e-33]], $MachinePrecision]], N[(0.5 * N[(re * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], re]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.42 \lor \neg \left(im \leq 1.28 \cdot 10^{-33}\right):\\
\;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;re\\
\end{array}
\end{array}
if im < -1.4199999999999999 or 1.28000000000000001e-33 < im Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 52.7%
*-commutative52.7%
associate-*r*52.7%
distribute-rgt1-in52.7%
*-commutative52.7%
unpow252.7%
associate-*l*52.7%
Simplified52.7%
Taylor expanded in im around inf 49.9%
*-commutative49.9%
unpow249.9%
associate-*l*36.4%
Simplified36.4%
Taylor expanded in re around 0 42.9%
*-commutative42.9%
unpow242.9%
Simplified42.9%
if -1.4199999999999999 < im < 1.28000000000000001e-33Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 53.1%
associate-*r*53.1%
Simplified53.1%
Taylor expanded in im around 0 52.6%
Final simplification47.6%
(FPCore (re im) :precision binary64 (if (or (<= im -1800000000000.0) (not (<= im 1.28e-33))) (/ 0.25 (* re re)) re))
double code(double re, double im) {
double tmp;
if ((im <= -1800000000000.0) || !(im <= 1.28e-33)) {
tmp = 0.25 / (re * re);
} else {
tmp = re;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-1800000000000.0d0)) .or. (.not. (im <= 1.28d-33))) then
tmp = 0.25d0 / (re * re)
else
tmp = re
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -1800000000000.0) || !(im <= 1.28e-33)) {
tmp = 0.25 / (re * re);
} else {
tmp = re;
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -1800000000000.0) or not (im <= 1.28e-33): tmp = 0.25 / (re * re) else: tmp = re return tmp
function code(re, im) tmp = 0.0 if ((im <= -1800000000000.0) || !(im <= 1.28e-33)) tmp = Float64(0.25 / Float64(re * re)); else tmp = re; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -1800000000000.0) || ~((im <= 1.28e-33))) tmp = 0.25 / (re * re); else tmp = re; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -1800000000000.0], N[Not[LessEqual[im, 1.28e-33]], $MachinePrecision]], N[(0.25 / N[(re * re), $MachinePrecision]), $MachinePrecision], re]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -1800000000000 \lor \neg \left(im \leq 1.28 \cdot 10^{-33}\right):\\
\;\;\;\;\frac{0.25}{re \cdot re}\\
\mathbf{else}:\\
\;\;\;\;re\\
\end{array}
\end{array}
if im < -1.8e12 or 1.28000000000000001e-33 < im Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Applied egg-rr13.1%
Taylor expanded in re around 0 12.7%
unpow212.7%
Simplified12.7%
if -1.8e12 < im < 1.28000000000000001e-33Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 54.8%
associate-*r*54.8%
Simplified54.8%
Taylor expanded in im around 0 49.9%
Final simplification31.8%
(FPCore (re im) :precision binary64 (if (<= im -1800000000000.0) (/ 0.25 (* re re)) (if (<= im 1.28e-33) re (/ (/ 0.25 re) re))))
double code(double re, double im) {
double tmp;
if (im <= -1800000000000.0) {
tmp = 0.25 / (re * re);
} else if (im <= 1.28e-33) {
tmp = re;
} else {
tmp = (0.25 / re) / re;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= (-1800000000000.0d0)) then
tmp = 0.25d0 / (re * re)
else if (im <= 1.28d-33) then
tmp = re
else
tmp = (0.25d0 / re) / re
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= -1800000000000.0) {
tmp = 0.25 / (re * re);
} else if (im <= 1.28e-33) {
tmp = re;
} else {
tmp = (0.25 / re) / re;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= -1800000000000.0: tmp = 0.25 / (re * re) elif im <= 1.28e-33: tmp = re else: tmp = (0.25 / re) / re return tmp
function code(re, im) tmp = 0.0 if (im <= -1800000000000.0) tmp = Float64(0.25 / Float64(re * re)); elseif (im <= 1.28e-33) tmp = re; else tmp = Float64(Float64(0.25 / re) / re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= -1800000000000.0) tmp = 0.25 / (re * re); elseif (im <= 1.28e-33) tmp = re; else tmp = (0.25 / re) / re; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, -1800000000000.0], N[(0.25 / N[(re * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.28e-33], re, N[(N[(0.25 / re), $MachinePrecision] / re), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -1800000000000:\\
\;\;\;\;\frac{0.25}{re \cdot re}\\
\mathbf{elif}\;im \leq 1.28 \cdot 10^{-33}:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.25}{re}}{re}\\
\end{array}
\end{array}
if im < -1.8e12Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Applied egg-rr9.0%
Taylor expanded in re around 0 9.0%
unpow29.0%
Simplified9.0%
if -1.8e12 < im < 1.28000000000000001e-33Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 54.8%
associate-*r*54.8%
Simplified54.8%
Taylor expanded in im around 0 49.9%
if 1.28000000000000001e-33 < im Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Applied egg-rr18.0%
Taylor expanded in re around 0 17.2%
unpow217.2%
Simplified17.2%
Taylor expanded in re around 0 17.2%
unpow217.2%
associate-/r*17.2%
Simplified17.2%
Final simplification31.8%
(FPCore (re im) :precision binary64 (* re (+ 1.0 (* 0.5 (* im im)))))
double code(double re, double im) {
return re * (1.0 + (0.5 * (im * im)));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re * (1.0d0 + (0.5d0 * (im * im)))
end function
public static double code(double re, double im) {
return re * (1.0 + (0.5 * (im * im)));
}
def code(re, im): return re * (1.0 + (0.5 * (im * im)))
function code(re, im) return Float64(re * Float64(1.0 + Float64(0.5 * Float64(im * im)))) end
function tmp = code(re, im) tmp = re * (1.0 + (0.5 * (im * im))); end
code[re_, im_] := N[(re * N[(1.0 + N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
re \cdot \left(1 + 0.5 \cdot \left(im \cdot im\right)\right)
\end{array}
Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 75.5%
*-commutative75.5%
associate-*r*75.5%
distribute-rgt1-in75.5%
*-commutative75.5%
unpow275.5%
associate-*l*75.5%
Simplified75.5%
Taylor expanded in re around 0 47.7%
*-commutative47.7%
unpow247.7%
Simplified47.7%
Final simplification47.7%
(FPCore (re im) :precision binary64 -512.0)
double code(double re, double im) {
return -512.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -512.0d0
end function
public static double code(double re, double im) {
return -512.0;
}
def code(re, im): return -512.0
function code(re, im) return -512.0 end
function tmp = code(re, im) tmp = -512.0; end
code[re_, im_] := -512.0
\begin{array}{l}
\\
-512
\end{array}
Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 84.6%
*-rgt-identity84.6%
*-commutative84.6%
associate-*r*84.6%
*-commutative84.6%
associate-*r*84.6%
distribute-rgt-out84.6%
distribute-lft-out84.6%
metadata-eval84.6%
pow-sqr84.6%
associate-*r*84.6%
distribute-rgt-out84.6%
unpow284.6%
unpow284.6%
Simplified84.6%
Applied egg-rr4.0%
Final simplification4.0%
(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%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 84.6%
*-rgt-identity84.6%
*-commutative84.6%
associate-*r*84.6%
*-commutative84.6%
associate-*r*84.6%
distribute-rgt-out84.6%
distribute-lft-out84.6%
metadata-eval84.6%
pow-sqr84.6%
associate-*r*84.6%
distribute-rgt-out84.6%
unpow284.6%
unpow284.6%
Simplified84.6%
Applied egg-rr5.1%
Final simplification5.1%
(FPCore (re im) :precision binary64 re)
double code(double re, double im) {
return re;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re
end function
public static double code(double re, double im) {
return re;
}
def code(re, im): return re
function code(re, im) return re end
function tmp = code(re, im) tmp = re; end
code[re_, im_] := re
\begin{array}{l}
\\
re
\end{array}
Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 62.1%
associate-*r*62.1%
Simplified62.1%
Taylor expanded in im around 0 26.8%
Final simplification26.8%
herbie shell --seed 2023171
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))