
(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 (* (* 0.5 (sin re)) (+ (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp(-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(-im) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp(-im) + Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp(-im) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp(-im) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right)
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (sin re))))
(if (<= im 1.05e+103)
(*
t_0
(+
(exp im)
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))))
(*
t_0
(+ 4.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))))))
double code(double re, double im) {
double t_0 = 0.5 * sin(re);
double tmp;
if (im <= 1.05e+103) {
tmp = t_0 * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} else {
tmp = t_0 * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
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 = 0.5d0 * sin(re)
if (im <= 1.05d+103) then
tmp = t_0 * (exp(im) + (1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))))
else
tmp = t_0 * (4.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * Math.sin(re);
double tmp;
if (im <= 1.05e+103) {
tmp = t_0 * (Math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} else {
tmp = t_0 * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.sin(re) tmp = 0 if im <= 1.05e+103: tmp = t_0 * (math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))) else: tmp = t_0 * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) return tmp
function code(re, im) t_0 = Float64(0.5 * sin(re)) tmp = 0.0 if (im <= 1.05e+103) tmp = Float64(t_0 * Float64(exp(im) + Float64(1.0 + Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0))))); else tmp = Float64(t_0 * Float64(4.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * sin(re); tmp = 0.0; if (im <= 1.05e+103) tmp = t_0 * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))); else tmp = t_0 * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 1.05e+103], N[(t$95$0 * N[(N[Exp[im], $MachinePrecision] + N[(1.0 + N[(im * N[(N[(im * N[(0.5 + N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(4.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
\mathbf{if}\;im \leq 1.05 \cdot 10^{+103}:\\
\;\;\;\;t\_0 \cdot \left(e^{im} + \left(1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(4 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if im < 1.0500000000000001e103Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 90.5%
if 1.0500000000000001e103 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
Final simplification92.0%
(FPCore (re im)
:precision binary64
(if (<= im 2.2)
(*
0.5
(*
(sin re)
(+
2.0
(+
(* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0))
(* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666)))))))))
(* (* 0.5 (sin re)) (+ (exp im) 3.0))))
double code(double re, double im) {
double tmp;
if (im <= 2.2) {
tmp = 0.5 * (sin(re) * (2.0 + ((im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)) + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))))));
} else {
tmp = (0.5 * sin(re)) * (exp(im) + 3.0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 2.2d0) then
tmp = 0.5d0 * (sin(re) * (2.0d0 + ((im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0))) + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))))))
else
tmp = (0.5d0 * sin(re)) * (exp(im) + 3.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2.2) {
tmp = 0.5 * (Math.sin(re) * (2.0 + ((im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)) + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))))));
} else {
tmp = (0.5 * Math.sin(re)) * (Math.exp(im) + 3.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.2: tmp = 0.5 * (math.sin(re) * (2.0 + ((im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)) + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))))) else: tmp = (0.5 * math.sin(re)) * (math.exp(im) + 3.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 2.2) tmp = Float64(0.5 * Float64(sin(re) * Float64(2.0 + Float64(Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0)) + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))))))); else tmp = Float64(Float64(0.5 * sin(re)) * Float64(exp(im) + 3.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.2) tmp = 0.5 * (sin(re) * (2.0 + ((im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)) + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))))); else tmp = (0.5 * sin(re)) * (exp(im) + 3.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.2], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[(2.0 + N[(N[(im * N[(N[(im * N[(0.5 + N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[im], $MachinePrecision] + 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.2:\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot \left(2 + \left(im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right) + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + 3\right)\\
\end{array}
\end{array}
if im < 2.2000000000000002Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 89.5%
Taylor expanded in im around 0 72.4%
Taylor expanded in re around inf 72.5%
if 2.2000000000000002 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Final simplification78.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666)))))))
(if (<= im 7.0)
(*
0.5
(*
(sin re)
(+
2.0
(+ (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)) t_0))))
(if (<= im 1.1e+102)
(* (+ (exp im) 3.0) (* 0.5 re))
(* (* 0.5 (sin re)) (+ 4.0 t_0))))))
double code(double re, double im) {
double t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))));
double tmp;
if (im <= 7.0) {
tmp = 0.5 * (sin(re) * (2.0 + ((im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)) + t_0)));
} else if (im <= 1.1e+102) {
tmp = (exp(im) + 3.0) * (0.5 * re);
} else {
tmp = (0.5 * sin(re)) * (4.0 + 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 * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))
if (im <= 7.0d0) then
tmp = 0.5d0 * (sin(re) * (2.0d0 + ((im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0))) + t_0)))
else if (im <= 1.1d+102) then
tmp = (exp(im) + 3.0d0) * (0.5d0 * re)
else
tmp = (0.5d0 * sin(re)) * (4.0d0 + t_0)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))));
double tmp;
if (im <= 7.0) {
tmp = 0.5 * (Math.sin(re) * (2.0 + ((im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)) + t_0)));
} else if (im <= 1.1e+102) {
tmp = (Math.exp(im) + 3.0) * (0.5 * re);
} else {
tmp = (0.5 * Math.sin(re)) * (4.0 + t_0);
}
return tmp;
}
def code(re, im): t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))) tmp = 0 if im <= 7.0: tmp = 0.5 * (math.sin(re) * (2.0 + ((im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)) + t_0))) elif im <= 1.1e+102: tmp = (math.exp(im) + 3.0) * (0.5 * re) else: tmp = (0.5 * math.sin(re)) * (4.0 + t_0) return tmp
function code(re, im) t_0 = Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))) tmp = 0.0 if (im <= 7.0) tmp = Float64(0.5 * Float64(sin(re) * Float64(2.0 + Float64(Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0)) + t_0)))); elseif (im <= 1.1e+102) tmp = Float64(Float64(exp(im) + 3.0) * Float64(0.5 * re)); else tmp = Float64(Float64(0.5 * sin(re)) * Float64(4.0 + t_0)); end return tmp end
function tmp_2 = code(re, im) t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))); tmp = 0.0; if (im <= 7.0) tmp = 0.5 * (sin(re) * (2.0 + ((im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)) + t_0))); elseif (im <= 1.1e+102) tmp = (exp(im) + 3.0) * (0.5 * re); else tmp = (0.5 * sin(re)) * (4.0 + t_0); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 7.0], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[(2.0 + N[(N[(im * N[(N[(im * N[(0.5 + N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.1e+102], N[(N[(N[Exp[im], $MachinePrecision] + 3.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(4.0 + t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\\
\mathbf{if}\;im \leq 7:\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot \left(2 + \left(im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right) + t\_0\right)\right)\right)\\
\mathbf{elif}\;im \leq 1.1 \cdot 10^{+102}:\\
\;\;\;\;\left(e^{im} + 3\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(4 + t\_0\right)\\
\end{array}
\end{array}
if im < 7Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 89.5%
Taylor expanded in im around 0 72.4%
Taylor expanded in re around inf 72.5%
if 7 < im < 1.10000000000000004e102Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 84.2%
*-commutative84.2%
*-commutative84.2%
associate-*l*84.2%
Simplified84.2%
if 1.10000000000000004e102 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 97.9%
Final simplification77.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (sin re))))
(if (<= im 4.5)
(*
t_0
(+
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))
(+ 1.0 (* im (+ 1.0 (* 0.5 im))))))
(if (<= im 1.1e+102)
(* (+ (exp im) 3.0) (* 0.5 re))
(*
t_0
(+ 4.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666)))))))))))
double code(double re, double im) {
double t_0 = 0.5 * sin(re);
double tmp;
if (im <= 4.5) {
tmp = t_0 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + (im * (1.0 + (0.5 * im)))));
} else if (im <= 1.1e+102) {
tmp = (exp(im) + 3.0) * (0.5 * re);
} else {
tmp = t_0 * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
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 = 0.5d0 * sin(re)
if (im <= 4.5d0) then
tmp = t_0 * ((1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))) + (1.0d0 + (im * (1.0d0 + (0.5d0 * im)))))
else if (im <= 1.1d+102) then
tmp = (exp(im) + 3.0d0) * (0.5d0 * re)
else
tmp = t_0 * (4.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * Math.sin(re);
double tmp;
if (im <= 4.5) {
tmp = t_0 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + (im * (1.0 + (0.5 * im)))));
} else if (im <= 1.1e+102) {
tmp = (Math.exp(im) + 3.0) * (0.5 * re);
} else {
tmp = t_0 * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.sin(re) tmp = 0 if im <= 4.5: tmp = t_0 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + (im * (1.0 + (0.5 * im))))) elif im <= 1.1e+102: tmp = (math.exp(im) + 3.0) * (0.5 * re) else: tmp = t_0 * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) return tmp
function code(re, im) t_0 = Float64(0.5 * sin(re)) tmp = 0.0 if (im <= 4.5) tmp = Float64(t_0 * Float64(Float64(1.0 + Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0))) + Float64(1.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))))); elseif (im <= 1.1e+102) tmp = Float64(Float64(exp(im) + 3.0) * Float64(0.5 * re)); else tmp = Float64(t_0 * Float64(4.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * sin(re); tmp = 0.0; if (im <= 4.5) tmp = t_0 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + (im * (1.0 + (0.5 * im))))); elseif (im <= 1.1e+102) tmp = (exp(im) + 3.0) * (0.5 * re); else tmp = t_0 * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 4.5], N[(t$95$0 * N[(N[(1.0 + N[(im * N[(N[(im * N[(0.5 + N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.1e+102], N[(N[(N[Exp[im], $MachinePrecision] + 3.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(4.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
\mathbf{if}\;im \leq 4.5:\\
\;\;\;\;t\_0 \cdot \left(\left(1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\right) + \left(1 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\right)\\
\mathbf{elif}\;im \leq 1.1 \cdot 10^{+102}:\\
\;\;\;\;\left(e^{im} + 3\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(4 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if im < 4.5Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 89.5%
Taylor expanded in im around 0 89.3%
if 4.5 < im < 1.10000000000000004e102Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 84.2%
*-commutative84.2%
*-commutative84.2%
associate-*l*84.2%
Simplified84.2%
if 1.10000000000000004e102 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 97.9%
Final simplification90.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (sin re))))
(if (<= im 2.8)
(*
t_0
(+
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))
(+ im 1.0)))
(if (<= im 1.1e+102)
(* (+ (exp im) 3.0) (* 0.5 re))
(*
t_0
(+ 4.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666)))))))))))
double code(double re, double im) {
double t_0 = 0.5 * sin(re);
double tmp;
if (im <= 2.8) {
tmp = t_0 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (im + 1.0));
} else if (im <= 1.1e+102) {
tmp = (exp(im) + 3.0) * (0.5 * re);
} else {
tmp = t_0 * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
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 = 0.5d0 * sin(re)
if (im <= 2.8d0) then
tmp = t_0 * ((1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))) + (im + 1.0d0))
else if (im <= 1.1d+102) then
tmp = (exp(im) + 3.0d0) * (0.5d0 * re)
else
tmp = t_0 * (4.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * Math.sin(re);
double tmp;
if (im <= 2.8) {
tmp = t_0 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (im + 1.0));
} else if (im <= 1.1e+102) {
tmp = (Math.exp(im) + 3.0) * (0.5 * re);
} else {
tmp = t_0 * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.sin(re) tmp = 0 if im <= 2.8: tmp = t_0 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (im + 1.0)) elif im <= 1.1e+102: tmp = (math.exp(im) + 3.0) * (0.5 * re) else: tmp = t_0 * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) return tmp
function code(re, im) t_0 = Float64(0.5 * sin(re)) tmp = 0.0 if (im <= 2.8) tmp = Float64(t_0 * Float64(Float64(1.0 + Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0))) + Float64(im + 1.0))); elseif (im <= 1.1e+102) tmp = Float64(Float64(exp(im) + 3.0) * Float64(0.5 * re)); else tmp = Float64(t_0 * Float64(4.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * sin(re); tmp = 0.0; if (im <= 2.8) tmp = t_0 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (im + 1.0)); elseif (im <= 1.1e+102) tmp = (exp(im) + 3.0) * (0.5 * re); else tmp = t_0 * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 2.8], N[(t$95$0 * N[(N[(1.0 + N[(im * N[(N[(im * N[(0.5 + N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(im + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.1e+102], N[(N[(N[Exp[im], $MachinePrecision] + 3.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(4.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
\mathbf{if}\;im \leq 2.8:\\
\;\;\;\;t\_0 \cdot \left(\left(1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\right) + \left(im + 1\right)\right)\\
\mathbf{elif}\;im \leq 1.1 \cdot 10^{+102}:\\
\;\;\;\;\left(e^{im} + 3\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(4 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if im < 2.7999999999999998Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 89.5%
Taylor expanded in im around 0 88.9%
if 2.7999999999999998 < im < 1.10000000000000004e102Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 84.2%
*-commutative84.2%
*-commutative84.2%
associate-*l*84.2%
Simplified84.2%
if 1.10000000000000004e102 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 97.9%
Final simplification90.0%
(FPCore (re im)
:precision binary64
(if (<= im 5.6)
(sin re)
(if (<= im 1.1e+102)
(* (+ (exp im) 3.0) (* 0.5 re))
(*
(* 0.5 (sin re))
(+ 4.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))))))
double code(double re, double im) {
double tmp;
if (im <= 5.6) {
tmp = sin(re);
} else if (im <= 1.1e+102) {
tmp = (exp(im) + 3.0) * (0.5 * re);
} else {
tmp = (0.5 * sin(re)) * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 5.6d0) then
tmp = sin(re)
else if (im <= 1.1d+102) then
tmp = (exp(im) + 3.0d0) * (0.5d0 * re)
else
tmp = (0.5d0 * sin(re)) * (4.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 5.6) {
tmp = Math.sin(re);
} else if (im <= 1.1e+102) {
tmp = (Math.exp(im) + 3.0) * (0.5 * re);
} else {
tmp = (0.5 * Math.sin(re)) * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 5.6: tmp = math.sin(re) elif im <= 1.1e+102: tmp = (math.exp(im) + 3.0) * (0.5 * re) else: tmp = (0.5 * math.sin(re)) * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) return tmp
function code(re, im) tmp = 0.0 if (im <= 5.6) tmp = sin(re); elseif (im <= 1.1e+102) tmp = Float64(Float64(exp(im) + 3.0) * Float64(0.5 * re)); else tmp = Float64(Float64(0.5 * sin(re)) * Float64(4.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 5.6) tmp = sin(re); elseif (im <= 1.1e+102) tmp = (exp(im) + 3.0) * (0.5 * re); else tmp = (0.5 * sin(re)) * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 5.6], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.1e+102], N[(N[(N[Exp[im], $MachinePrecision] + 3.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(4.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 5.6:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.1 \cdot 10^{+102}:\\
\;\;\;\;\left(e^{im} + 3\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(4 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if im < 5.5999999999999996Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 72.3%
Taylor expanded in re around inf 72.3%
if 5.5999999999999996 < im < 1.10000000000000004e102Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 84.2%
*-commutative84.2%
*-commutative84.2%
associate-*l*84.2%
Simplified84.2%
if 1.10000000000000004e102 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 97.9%
Final simplification77.3%
(FPCore (re im)
:precision binary64
(if (<= im 5.0)
(sin re)
(if (<= im 1.9e+154)
(* (+ (exp im) 3.0) (* 0.5 re))
(* (* 0.5 (sin re)) (+ 4.0 (* im (+ 1.0 (* 0.5 im))))))))
double code(double re, double im) {
double tmp;
if (im <= 5.0) {
tmp = sin(re);
} else if (im <= 1.9e+154) {
tmp = (exp(im) + 3.0) * (0.5 * re);
} else {
tmp = (0.5 * sin(re)) * (4.0 + (im * (1.0 + (0.5 * im))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 5.0d0) then
tmp = sin(re)
else if (im <= 1.9d+154) then
tmp = (exp(im) + 3.0d0) * (0.5d0 * re)
else
tmp = (0.5d0 * sin(re)) * (4.0d0 + (im * (1.0d0 + (0.5d0 * im))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 5.0) {
tmp = Math.sin(re);
} else if (im <= 1.9e+154) {
tmp = (Math.exp(im) + 3.0) * (0.5 * re);
} else {
tmp = (0.5 * Math.sin(re)) * (4.0 + (im * (1.0 + (0.5 * im))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 5.0: tmp = math.sin(re) elif im <= 1.9e+154: tmp = (math.exp(im) + 3.0) * (0.5 * re) else: tmp = (0.5 * math.sin(re)) * (4.0 + (im * (1.0 + (0.5 * im)))) return tmp
function code(re, im) tmp = 0.0 if (im <= 5.0) tmp = sin(re); elseif (im <= 1.9e+154) tmp = Float64(Float64(exp(im) + 3.0) * Float64(0.5 * re)); else tmp = Float64(Float64(0.5 * sin(re)) * Float64(4.0 + Float64(im * Float64(1.0 + Float64(0.5 * im))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 5.0) tmp = sin(re); elseif (im <= 1.9e+154) tmp = (exp(im) + 3.0) * (0.5 * re); else tmp = (0.5 * sin(re)) * (4.0 + (im * (1.0 + (0.5 * im)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 5.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.9e+154], N[(N[(N[Exp[im], $MachinePrecision] + 3.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(4.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 5:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.9 \cdot 10^{+154}:\\
\;\;\;\;\left(e^{im} + 3\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(4 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 5Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 72.3%
Taylor expanded in re around inf 72.3%
if 5 < im < 1.8999999999999999e154Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 71.0%
*-commutative71.0%
*-commutative71.0%
associate-*l*71.0%
Simplified71.0%
if 1.8999999999999999e154 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification75.3%
(FPCore (re im) :precision binary64 (if (<= im 4.2) (sin re) (* (+ (exp im) 3.0) (* 0.5 re))))
double code(double re, double im) {
double tmp;
if (im <= 4.2) {
tmp = sin(re);
} else {
tmp = (exp(im) + 3.0) * (0.5 * re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 4.2d0) then
tmp = sin(re)
else
tmp = (exp(im) + 3.0d0) * (0.5d0 * re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 4.2) {
tmp = Math.sin(re);
} else {
tmp = (Math.exp(im) + 3.0) * (0.5 * re);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 4.2: tmp = math.sin(re) else: tmp = (math.exp(im) + 3.0) * (0.5 * re) return tmp
function code(re, im) tmp = 0.0 if (im <= 4.2) tmp = sin(re); else tmp = Float64(Float64(exp(im) + 3.0) * Float64(0.5 * re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 4.2) tmp = sin(re); else tmp = (exp(im) + 3.0) * (0.5 * re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 4.2], N[Sin[re], $MachinePrecision], N[(N[(N[Exp[im], $MachinePrecision] + 3.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 4.2:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;\left(e^{im} + 3\right) \cdot \left(0.5 \cdot re\right)\\
\end{array}
\end{array}
if im < 4.20000000000000018Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 72.3%
Taylor expanded in re around inf 72.3%
if 4.20000000000000018 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 73.3%
*-commutative73.3%
*-commutative73.3%
associate-*l*73.3%
Simplified73.3%
Final simplification72.5%
(FPCore (re im)
:precision binary64
(if (<= im 1.65e+15)
(sin re)
(*
(+ 4.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))
(* 0.5 re))))
double code(double re, double im) {
double tmp;
if (im <= 1.65e+15) {
tmp = sin(re);
} else {
tmp = (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) * (0.5 * 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.65d+15) then
tmp = sin(re)
else
tmp = (4.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0)))))) * (0.5d0 * re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.65e+15) {
tmp = Math.sin(re);
} else {
tmp = (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) * (0.5 * re);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.65e+15: tmp = math.sin(re) else: tmp = (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) * (0.5 * re) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.65e+15) tmp = sin(re); else tmp = Float64(Float64(4.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666)))))) * Float64(0.5 * re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.65e+15) tmp = sin(re); else tmp = (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) * (0.5 * re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.65e+15], N[Sin[re], $MachinePrecision], N[(N[(4.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.65 \cdot 10^{+15}:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;\left(4 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right) \cdot \left(0.5 \cdot re\right)\\
\end{array}
\end{array}
if im < 1.65e15Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 71.6%
Taylor expanded in re around inf 71.6%
if 1.65e15 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 72.4%
*-commutative72.4%
*-commutative72.4%
associate-*l*72.4%
Simplified72.4%
Taylor expanded in im around 0 54.2%
Final simplification67.7%
(FPCore (re im)
:precision binary64
(if (<= im 4.2e+54)
(* re (+ 1.0 (* -0.16666666666666666 (* re re))))
(*
(+ 4.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))
(* 0.5 re))))
double code(double re, double im) {
double tmp;
if (im <= 4.2e+54) {
tmp = re * (1.0 + (-0.16666666666666666 * (re * re)));
} else {
tmp = (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) * (0.5 * re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 4.2d+54) then
tmp = re * (1.0d0 + ((-0.16666666666666666d0) * (re * re)))
else
tmp = (4.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0)))))) * (0.5d0 * re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 4.2e+54) {
tmp = re * (1.0 + (-0.16666666666666666 * (re * re)));
} else {
tmp = (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) * (0.5 * re);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 4.2e+54: tmp = re * (1.0 + (-0.16666666666666666 * (re * re))) else: tmp = (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) * (0.5 * re) return tmp
function code(re, im) tmp = 0.0 if (im <= 4.2e+54) tmp = Float64(re * Float64(1.0 + Float64(-0.16666666666666666 * Float64(re * re)))); else tmp = Float64(Float64(4.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666)))))) * Float64(0.5 * re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 4.2e+54) tmp = re * (1.0 + (-0.16666666666666666 * (re * re))); else tmp = (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) * (0.5 * re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 4.2e+54], N[(re * N[(1.0 + N[(-0.16666666666666666 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(4.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 4.2 \cdot 10^{+54}:\\
\;\;\;\;re \cdot \left(1 + -0.16666666666666666 \cdot \left(re \cdot re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(4 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right) \cdot \left(0.5 \cdot re\right)\\
\end{array}
\end{array}
if im < 4.19999999999999972e54Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 69.2%
Taylor expanded in re around inf 69.2%
Taylor expanded in re around 0 41.8%
*-commutative41.8%
Simplified41.8%
unpow241.8%
Applied egg-rr41.8%
if 4.19999999999999972e54 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 72.5%
*-commutative72.5%
*-commutative72.5%
associate-*l*72.5%
Simplified72.5%
Taylor expanded in im around 0 61.3%
Final simplification45.7%
(FPCore (re im) :precision binary64 (if (<= im 1.18e+56) (* re (+ 1.0 (* -0.16666666666666666 (* re re)))) (* (* 0.5 re) (+ 4.0 (* im (+ 1.0 (* 0.5 im)))))))
double code(double re, double im) {
double tmp;
if (im <= 1.18e+56) {
tmp = re * (1.0 + (-0.16666666666666666 * (re * re)));
} else {
tmp = (0.5 * re) * (4.0 + (im * (1.0 + (0.5 * im))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.18d+56) then
tmp = re * (1.0d0 + ((-0.16666666666666666d0) * (re * re)))
else
tmp = (0.5d0 * re) * (4.0d0 + (im * (1.0d0 + (0.5d0 * im))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.18e+56) {
tmp = re * (1.0 + (-0.16666666666666666 * (re * re)));
} else {
tmp = (0.5 * re) * (4.0 + (im * (1.0 + (0.5 * im))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.18e+56: tmp = re * (1.0 + (-0.16666666666666666 * (re * re))) else: tmp = (0.5 * re) * (4.0 + (im * (1.0 + (0.5 * im)))) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.18e+56) tmp = Float64(re * Float64(1.0 + Float64(-0.16666666666666666 * Float64(re * re)))); else tmp = Float64(Float64(0.5 * re) * Float64(4.0 + Float64(im * Float64(1.0 + Float64(0.5 * im))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.18e+56) tmp = re * (1.0 + (-0.16666666666666666 * (re * re))); else tmp = (0.5 * re) * (4.0 + (im * (1.0 + (0.5 * im)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.18e+56], N[(re * N[(1.0 + N[(-0.16666666666666666 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(4.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.18 \cdot 10^{+56}:\\
\;\;\;\;re \cdot \left(1 + -0.16666666666666666 \cdot \left(re \cdot re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(4 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 1.1799999999999999e56Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 69.2%
Taylor expanded in re around inf 69.2%
Taylor expanded in re around 0 41.8%
*-commutative41.8%
Simplified41.8%
unpow241.8%
Applied egg-rr41.8%
if 1.1799999999999999e56 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 72.5%
*-commutative72.5%
*-commutative72.5%
associate-*l*72.5%
Simplified72.5%
Taylor expanded in im around 0 53.7%
*-commutative58.9%
Simplified53.7%
Final simplification44.1%
(FPCore (re im) :precision binary64 (if (<= im 1.78e+56) (* re (+ 1.0 (* -0.16666666666666666 (* re re)))) (* im (* re (+ 0.5 (* im 0.25))))))
double code(double re, double im) {
double tmp;
if (im <= 1.78e+56) {
tmp = re * (1.0 + (-0.16666666666666666 * (re * re)));
} else {
tmp = im * (re * (0.5 + (im * 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 <= 1.78d+56) then
tmp = re * (1.0d0 + ((-0.16666666666666666d0) * (re * re)))
else
tmp = im * (re * (0.5d0 + (im * 0.25d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.78e+56) {
tmp = re * (1.0 + (-0.16666666666666666 * (re * re)));
} else {
tmp = im * (re * (0.5 + (im * 0.25)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.78e+56: tmp = re * (1.0 + (-0.16666666666666666 * (re * re))) else: tmp = im * (re * (0.5 + (im * 0.25))) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.78e+56) tmp = Float64(re * Float64(1.0 + Float64(-0.16666666666666666 * Float64(re * re)))); else tmp = Float64(im * Float64(re * Float64(0.5 + Float64(im * 0.25)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.78e+56) tmp = re * (1.0 + (-0.16666666666666666 * (re * re))); else tmp = im * (re * (0.5 + (im * 0.25))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.78e+56], N[(re * N[(1.0 + N[(-0.16666666666666666 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * N[(re * N[(0.5 + N[(im * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.78 \cdot 10^{+56}:\\
\;\;\;\;re \cdot \left(1 + -0.16666666666666666 \cdot \left(re \cdot re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(re \cdot \left(0.5 + im \cdot 0.25\right)\right)\\
\end{array}
\end{array}
if im < 1.78e56Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 69.2%
Taylor expanded in re around inf 69.2%
Taylor expanded in re around 0 41.8%
*-commutative41.8%
Simplified41.8%
unpow241.8%
Applied egg-rr41.8%
if 1.78e56 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 72.5%
*-commutative72.5%
*-commutative72.5%
associate-*l*72.5%
Simplified72.5%
Taylor expanded in im around 0 53.7%
*-commutative58.9%
Simplified53.7%
Taylor expanded in im around inf 53.7%
distribute-rgt-in32.1%
unpow232.1%
associate-*r*32.1%
associate-*r*32.1%
*-commutative32.1%
associate-*r/32.1%
associate-*l/53.7%
*-lft-identity53.7%
times-frac53.7%
/-rgt-identity53.7%
*-rgt-identity53.7%
associate-*r/53.7%
unpow253.7%
associate-*l*40.8%
rgt-mult-inverse40.8%
*-rgt-identity40.8%
distribute-rgt-in40.8%
associate-*r*40.8%
distribute-rgt-out40.8%
*-commutative40.8%
Simplified40.8%
Final simplification41.6%
(FPCore (re im) :precision binary64 (if (<= im 2.5e-6) re (* im (* re (+ 0.5 (* im 0.25))))))
double code(double re, double im) {
double tmp;
if (im <= 2.5e-6) {
tmp = re;
} else {
tmp = im * (re * (0.5 + (im * 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.5d-6) then
tmp = re
else
tmp = im * (re * (0.5d0 + (im * 0.25d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2.5e-6) {
tmp = re;
} else {
tmp = im * (re * (0.5 + (im * 0.25)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.5e-6: tmp = re else: tmp = im * (re * (0.5 + (im * 0.25))) return tmp
function code(re, im) tmp = 0.0 if (im <= 2.5e-6) tmp = re; else tmp = Float64(im * Float64(re * Float64(0.5 + Float64(im * 0.25)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.5e-6) tmp = re; else tmp = im * (re * (0.5 + (im * 0.25))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.5e-6], re, N[(im * N[(re * N[(0.5 + N[(im * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.5 \cdot 10^{-6}:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(re \cdot \left(0.5 + im \cdot 0.25\right)\right)\\
\end{array}
\end{array}
if im < 2.5000000000000002e-6Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 72.6%
Taylor expanded in re around 0 39.1%
if 2.5000000000000002e-6 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr96.1%
Taylor expanded in re around 0 70.0%
*-commutative70.0%
*-commutative70.0%
associate-*l*70.0%
Simplified70.0%
Taylor expanded in im around 0 43.9%
*-commutative49.0%
Simplified43.9%
Taylor expanded in im around inf 43.9%
distribute-rgt-in26.5%
unpow226.5%
associate-*r*26.5%
associate-*r*26.5%
*-commutative26.5%
associate-*r/26.5%
associate-*l/43.9%
*-lft-identity43.9%
times-frac43.9%
/-rgt-identity43.9%
*-rgt-identity43.9%
associate-*r/43.9%
unpow243.9%
associate-*l*33.5%
rgt-mult-inverse33.5%
*-rgt-identity33.5%
distribute-rgt-in33.5%
associate-*r*33.5%
distribute-rgt-out33.5%
*-commutative33.5%
Simplified33.5%
Final simplification37.7%
(FPCore (re im) :precision binary64 (if (<= im 1.05) re (* (* 0.5 re) (+ im 4.0))))
double code(double re, double im) {
double tmp;
if (im <= 1.05) {
tmp = re;
} else {
tmp = (0.5 * re) * (im + 4.0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.05d0) then
tmp = re
else
tmp = (0.5d0 * re) * (im + 4.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.05) {
tmp = re;
} else {
tmp = (0.5 * re) * (im + 4.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.05: tmp = re else: tmp = (0.5 * re) * (im + 4.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.05) tmp = re; else tmp = Float64(Float64(0.5 * re) * Float64(im + 4.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.05) tmp = re; else tmp = (0.5 * re) * (im + 4.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.05], re, N[(N[(0.5 * re), $MachinePrecision] * N[(im + 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.05:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(im + 4\right)\\
\end{array}
\end{array}
if im < 1.05000000000000004Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 72.3%
Taylor expanded in re around 0 38.5%
if 1.05000000000000004 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 73.3%
*-commutative73.3%
*-commutative73.3%
associate-*l*73.3%
Simplified73.3%
Taylor expanded in im around 0 14.0%
Final simplification32.8%
(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%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 56.0%
Taylor expanded in re around 0 30.1%
(FPCore (re im) :precision binary64 0.0)
double code(double re, double im) {
return 0.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.0d0
end function
public static double code(double re, double im) {
return 0.0;
}
def code(re, im): return 0.0
function code(re, im) return 0.0 end
function tmp = code(re, im) tmp = 0.0; end
code[re_, im_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 56.0%
Applied egg-rr3.1%
pow-base-13.1%
metadata-eval3.1%
Simplified3.1%
metadata-eval3.1%
Applied egg-rr3.1%
herbie shell --seed 2024129
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))