
(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 22 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
(if (<= im 0.24)
(* (* 0.5 (sin re)) (fma im im 2.0))
(if (<= im 1e+103)
(* (+ (exp (- im)) (exp im)) (* 0.5 re))
(*
0.5
(*
(sin re)
(-
(+ 2.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))
im))))))
double code(double re, double im) {
double tmp;
if (im <= 0.24) {
tmp = (0.5 * sin(re)) * fma(im, im, 2.0);
} else if (im <= 1e+103) {
tmp = (exp(-im) + exp(im)) * (0.5 * re);
} else {
tmp = 0.5 * (sin(re) * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 0.24) tmp = Float64(Float64(0.5 * sin(re)) * fma(im, im, 2.0)); elseif (im <= 1e+103) tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 * re)); else tmp = Float64(0.5 * Float64(sin(re) * Float64(Float64(2.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666)))))) - im))); end return tmp end
code[re_, im_] := If[LessEqual[im, 0.24], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1e+103], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[(N[(2.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.24:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{elif}\;im \leq 10^{+103}:\\
\;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot \left(\left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right) - im\right)\right)\\
\end{array}
\end{array}
if im < 0.23999999999999999Initial 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 80.7%
+-commutative80.7%
unpow280.7%
fma-define80.7%
Simplified80.7%
if 0.23999999999999999 < im < 1e103Initial program 100.0%
distribute-rgt-in99.9%
cancel-sign-sub99.9%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in re around 0 66.7%
if 1e103 < 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%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
Final simplification82.9%
(FPCore (re im)
:precision binary64
(if (<= im 0.88)
(* (* 0.5 (sin re)) (fma im im 2.0))
(if (<= im 1e+103)
(*
(* 0.5 re)
(+
(exp im)
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))))
(*
0.5
(*
(sin re)
(-
(+ 2.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))
im))))))
double code(double re, double im) {
double tmp;
if (im <= 0.88) {
tmp = (0.5 * sin(re)) * fma(im, im, 2.0);
} else if (im <= 1e+103) {
tmp = (0.5 * re) * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} else {
tmp = 0.5 * (sin(re) * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 0.88) tmp = Float64(Float64(0.5 * sin(re)) * fma(im, im, 2.0)); elseif (im <= 1e+103) tmp = Float64(Float64(0.5 * re) * Float64(exp(im) + Float64(1.0 + Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0))))); else tmp = Float64(0.5 * Float64(sin(re) * Float64(Float64(2.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666)))))) - im))); end return tmp end
code[re_, im_] := If[LessEqual[im, 0.88], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1e+103], N[(N[(0.5 * re), $MachinePrecision] * 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[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[(N[(2.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.88:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{elif}\;im \leq 10^{+103}:\\
\;\;\;\;\left(0.5 \cdot re\right) \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}:\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot \left(\left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right) - im\right)\right)\\
\end{array}
\end{array}
if im < 0.880000000000000004Initial 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 80.7%
+-commutative80.7%
unpow280.7%
fma-define80.7%
Simplified80.7%
if 0.880000000000000004 < im < 1e103Initial program 100.0%
distribute-rgt-in99.9%
cancel-sign-sub99.9%
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 66.7%
Simplified66.7%
Taylor expanded in im around 0 63.7%
if 1e103 < 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%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
Final simplification82.6%
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (+ (exp im) (- 1.0 im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp(im) + (1.0 - im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * sin(re)) * (exp(im) + (1.0d0 - im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp(im) + (1.0 - im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp(im) + (1.0 - im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(im) + Float64(1.0 - im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp(im) + (1.0 - im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[im], $MachinePrecision] + N[(1.0 - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + \left(1 - im\right)\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%
Taylor expanded in im around 0 70.2%
neg-mul-170.2%
unsub-neg70.2%
Simplified70.2%
Final simplification70.2%
(FPCore (re im)
:precision binary64
(if (<= im 0.0002)
(* (* 0.5 (sin re)) (+ (- 1.0 im) (+ 1.0 (* im (+ 1.0 (* 0.5 im))))))
(if (<= im 1e+103)
(*
(* 0.5 re)
(+
(exp im)
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))))
(*
0.5
(*
(sin re)
(-
(+ 2.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))
im))))))
double code(double re, double im) {
double tmp;
if (im <= 0.0002) {
tmp = (0.5 * sin(re)) * ((1.0 - im) + (1.0 + (im * (1.0 + (0.5 * im)))));
} else if (im <= 1e+103) {
tmp = (0.5 * re) * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} else {
tmp = 0.5 * (sin(re) * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 0.0002d0) then
tmp = (0.5d0 * sin(re)) * ((1.0d0 - im) + (1.0d0 + (im * (1.0d0 + (0.5d0 * im)))))
else if (im <= 1d+103) then
tmp = (0.5d0 * re) * (exp(im) + (1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))))
else
tmp = 0.5d0 * (sin(re) * ((2.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0)))))) - im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 0.0002) {
tmp = (0.5 * Math.sin(re)) * ((1.0 - im) + (1.0 + (im * (1.0 + (0.5 * im)))));
} else if (im <= 1e+103) {
tmp = (0.5 * re) * (Math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} else {
tmp = 0.5 * (Math.sin(re) * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.0002: tmp = (0.5 * math.sin(re)) * ((1.0 - im) + (1.0 + (im * (1.0 + (0.5 * im))))) elif im <= 1e+103: tmp = (0.5 * re) * (math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))) else: tmp = 0.5 * (math.sin(re) * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 0.0002) tmp = Float64(Float64(0.5 * sin(re)) * Float64(Float64(1.0 - im) + Float64(1.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))))); elseif (im <= 1e+103) tmp = Float64(Float64(0.5 * re) * Float64(exp(im) + Float64(1.0 + Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0))))); else tmp = Float64(0.5 * Float64(sin(re) * Float64(Float64(2.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666)))))) - im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.0002) tmp = (0.5 * sin(re)) * ((1.0 - im) + (1.0 + (im * (1.0 + (0.5 * im))))); elseif (im <= 1e+103) tmp = (0.5 * re) * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))); else tmp = 0.5 * (sin(re) * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.0002], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 - im), $MachinePrecision] + N[(1.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1e+103], N[(N[(0.5 * re), $MachinePrecision] * 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[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[(N[(2.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.0002:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(\left(1 - im\right) + \left(1 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\right)\\
\mathbf{elif}\;im \leq 10^{+103}:\\
\;\;\;\;\left(0.5 \cdot re\right) \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}:\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot \left(\left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right) - im\right)\right)\\
\end{array}
\end{array}
if im < 2.0000000000000001e-4Initial 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 59.8%
neg-mul-159.8%
unsub-neg59.8%
Simplified59.8%
Taylor expanded in im around 0 81.0%
if 2.0000000000000001e-4 < im < 1e103Initial program 99.8%
distribute-rgt-in99.8%
cancel-sign-sub99.8%
distribute-rgt-out--99.8%
sub-neg99.8%
remove-double-neg99.8%
neg-sub099.8%
Simplified99.8%
Applied egg-rr99.8%
Taylor expanded in re around 0 65.6%
Simplified65.6%
Taylor expanded in im around 0 61.1%
if 1e103 < 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%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
Final simplification82.2%
(FPCore (re im)
:precision binary64
(if (<= im 5.2)
(* (* 0.5 (sin re)) (+ (- 1.0 im) (+ 1.0 (* im (+ 1.0 (* 0.5 im))))))
(if (<= im 1e+103)
(* (* 0.5 re) (- (expm1 im) im))
(*
0.5
(*
(sin re)
(-
(+ 2.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))
im))))))
double code(double re, double im) {
double tmp;
if (im <= 5.2) {
tmp = (0.5 * sin(re)) * ((1.0 - im) + (1.0 + (im * (1.0 + (0.5 * im)))));
} else if (im <= 1e+103) {
tmp = (0.5 * re) * (expm1(im) - im);
} else {
tmp = 0.5 * (sin(re) * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im));
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (im <= 5.2) {
tmp = (0.5 * Math.sin(re)) * ((1.0 - im) + (1.0 + (im * (1.0 + (0.5 * im)))));
} else if (im <= 1e+103) {
tmp = (0.5 * re) * (Math.expm1(im) - im);
} else {
tmp = 0.5 * (Math.sin(re) * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 5.2: tmp = (0.5 * math.sin(re)) * ((1.0 - im) + (1.0 + (im * (1.0 + (0.5 * im))))) elif im <= 1e+103: tmp = (0.5 * re) * (math.expm1(im) - im) else: tmp = 0.5 * (math.sin(re) * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 5.2) tmp = Float64(Float64(0.5 * sin(re)) * Float64(Float64(1.0 - im) + Float64(1.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))))); elseif (im <= 1e+103) tmp = Float64(Float64(0.5 * re) * Float64(expm1(im) - im)); else tmp = Float64(0.5 * Float64(sin(re) * Float64(Float64(2.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666)))))) - im))); end return tmp end
code[re_, im_] := If[LessEqual[im, 5.2], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 - im), $MachinePrecision] + N[(1.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1e+103], N[(N[(0.5 * re), $MachinePrecision] * N[(N[(Exp[im] - 1), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[(N[(2.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 5.2:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(\left(1 - im\right) + \left(1 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\right)\\
\mathbf{elif}\;im \leq 10^{+103}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(\mathsf{expm1}\left(im\right) - im\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot \left(\left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right) - im\right)\right)\\
\end{array}
\end{array}
if im < 5.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 59.2%
neg-mul-159.2%
unsub-neg59.2%
Simplified59.2%
Taylor expanded in im around 0 79.7%
if 5.20000000000000018 < im < 1e103Initial 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 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 65.2%
Simplified65.2%
Taylor expanded in re around 0 65.2%
associate-*r*65.2%
*-commutative65.2%
associate--r+65.2%
expm1-define65.2%
Simplified65.2%
if 1e103 < 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%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
Final simplification82.0%
(FPCore (re im) :precision binary64 (if (or (<= im 6.5) (not (<= im 1.85e+154))) (* 0.5 (* (sin re) (- (+ 2.0 (* im (+ 1.0 (* 0.5 im)))) im))) (* (* 0.5 re) (- (expm1 im) im))))
double code(double re, double im) {
double tmp;
if ((im <= 6.5) || !(im <= 1.85e+154)) {
tmp = 0.5 * (sin(re) * ((2.0 + (im * (1.0 + (0.5 * im)))) - im));
} else {
tmp = (0.5 * re) * (expm1(im) - im);
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if ((im <= 6.5) || !(im <= 1.85e+154)) {
tmp = 0.5 * (Math.sin(re) * ((2.0 + (im * (1.0 + (0.5 * im)))) - im));
} else {
tmp = (0.5 * re) * (Math.expm1(im) - im);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= 6.5) or not (im <= 1.85e+154): tmp = 0.5 * (math.sin(re) * ((2.0 + (im * (1.0 + (0.5 * im)))) - im)) else: tmp = (0.5 * re) * (math.expm1(im) - im) return tmp
function code(re, im) tmp = 0.0 if ((im <= 6.5) || !(im <= 1.85e+154)) tmp = Float64(0.5 * Float64(sin(re) * Float64(Float64(2.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))) - im))); else tmp = Float64(Float64(0.5 * re) * Float64(expm1(im) - im)); end return tmp end
code[re_, im_] := If[Or[LessEqual[im, 6.5], N[Not[LessEqual[im, 1.85e+154]], $MachinePrecision]], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[(N[(2.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(N[(Exp[im] - 1), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 6.5 \lor \neg \left(im \leq 1.85 \cdot 10^{+154}\right):\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot \left(\left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right) - im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(\mathsf{expm1}\left(im\right) - im\right)\\
\end{array}
\end{array}
if im < 6.5 or 1.84999999999999997e154 < 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%
Taylor expanded in im around 0 65.0%
neg-mul-165.0%
unsub-neg65.0%
Simplified65.0%
Taylor expanded in im around 0 82.6%
Taylor expanded in re around inf 82.6%
if 6.5 < im < 1.84999999999999997e154Initial 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 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 68.4%
Simplified68.4%
Taylor expanded in re around 0 68.4%
associate-*r*68.4%
*-commutative68.4%
associate--r+68.4%
expm1-define68.4%
Simplified68.4%
Final simplification80.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (+ 1.0 (* 0.5 im)))))
(if (<= im 7.0)
(* (* 0.5 (sin re)) (+ (- 1.0 im) (+ 1.0 t_0)))
(if (<= im 1.85e+154)
(* (* 0.5 re) (- (expm1 im) im))
(* 0.5 (* (sin re) (- (+ 2.0 t_0) im)))))))
double code(double re, double im) {
double t_0 = im * (1.0 + (0.5 * im));
double tmp;
if (im <= 7.0) {
tmp = (0.5 * sin(re)) * ((1.0 - im) + (1.0 + t_0));
} else if (im <= 1.85e+154) {
tmp = (0.5 * re) * (expm1(im) - im);
} else {
tmp = 0.5 * (sin(re) * ((2.0 + t_0) - im));
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = im * (1.0 + (0.5 * im));
double tmp;
if (im <= 7.0) {
tmp = (0.5 * Math.sin(re)) * ((1.0 - im) + (1.0 + t_0));
} else if (im <= 1.85e+154) {
tmp = (0.5 * re) * (Math.expm1(im) - im);
} else {
tmp = 0.5 * (Math.sin(re) * ((2.0 + t_0) - im));
}
return tmp;
}
def code(re, im): t_0 = im * (1.0 + (0.5 * im)) tmp = 0 if im <= 7.0: tmp = (0.5 * math.sin(re)) * ((1.0 - im) + (1.0 + t_0)) elif im <= 1.85e+154: tmp = (0.5 * re) * (math.expm1(im) - im) else: tmp = 0.5 * (math.sin(re) * ((2.0 + t_0) - im)) return tmp
function code(re, im) t_0 = Float64(im * Float64(1.0 + Float64(0.5 * im))) tmp = 0.0 if (im <= 7.0) tmp = Float64(Float64(0.5 * sin(re)) * Float64(Float64(1.0 - im) + Float64(1.0 + t_0))); elseif (im <= 1.85e+154) tmp = Float64(Float64(0.5 * re) * Float64(expm1(im) - im)); else tmp = Float64(0.5 * Float64(sin(re) * Float64(Float64(2.0 + t_0) - im))); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 7.0], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 - im), $MachinePrecision] + N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.85e+154], N[(N[(0.5 * re), $MachinePrecision] * N[(N[(Exp[im] - 1), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[(N[(2.0 + t$95$0), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := im \cdot \left(1 + 0.5 \cdot im\right)\\
\mathbf{if}\;im \leq 7:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(\left(1 - im\right) + \left(1 + t\_0\right)\right)\\
\mathbf{elif}\;im \leq 1.85 \cdot 10^{+154}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(\mathsf{expm1}\left(im\right) - im\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot \left(\left(2 + t\_0\right) - im\right)\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 59.2%
neg-mul-159.2%
unsub-neg59.2%
Simplified59.2%
Taylor expanded in im around 0 79.7%
if 7 < im < 1.84999999999999997e154Initial 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 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 68.4%
Simplified68.4%
Taylor expanded in re around 0 68.4%
associate-*r*68.4%
*-commutative68.4%
associate--r+68.4%
expm1-define68.4%
Simplified68.4%
if 1.84999999999999997e154 < 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%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around inf 100.0%
Final simplification80.5%
(FPCore (re im)
:precision binary64
(if (<= im 220000000.0)
(sin re)
(if (<= im 3.8e+90)
(- (- im (exp im)) -1.0)
(*
0.5
(*
re
(-
(+ 2.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))
im))))))
double code(double re, double im) {
double tmp;
if (im <= 220000000.0) {
tmp = sin(re);
} else if (im <= 3.8e+90) {
tmp = (im - exp(im)) - -1.0;
} else {
tmp = 0.5 * (re * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 220000000.0d0) then
tmp = sin(re)
else if (im <= 3.8d+90) then
tmp = (im - exp(im)) - (-1.0d0)
else
tmp = 0.5d0 * (re * ((2.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0)))))) - im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 220000000.0) {
tmp = Math.sin(re);
} else if (im <= 3.8e+90) {
tmp = (im - Math.exp(im)) - -1.0;
} else {
tmp = 0.5 * (re * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 220000000.0: tmp = math.sin(re) elif im <= 3.8e+90: tmp = (im - math.exp(im)) - -1.0 else: tmp = 0.5 * (re * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 220000000.0) tmp = sin(re); elseif (im <= 3.8e+90) tmp = Float64(Float64(im - exp(im)) - -1.0); else tmp = Float64(0.5 * Float64(re * Float64(Float64(2.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666)))))) - im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 220000000.0) tmp = sin(re); elseif (im <= 3.8e+90) tmp = (im - exp(im)) - -1.0; else tmp = 0.5 * (re * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 220000000.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 3.8e+90], N[(N[(im - N[Exp[im], $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision], N[(0.5 * N[(re * N[(N[(2.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 220000000:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 3.8 \cdot 10^{+90}:\\
\;\;\;\;\left(im - e^{im}\right) - -1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(re \cdot \left(\left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right) - im\right)\right)\\
\end{array}
\end{array}
if im < 2.2e8Initial 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 57.5%
if 2.2e8 < im < 3.8000000000000001e90Initial 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 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
Simplified50.0%
if 3.8000000000000001e90 < 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%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 92.5%
*-commutative92.5%
Simplified92.5%
Taylor expanded in re around 0 64.1%
Final simplification58.4%
(FPCore (re im) :precision binary64 (if (<= im 4.9) (sin re) (* (* 0.5 re) (- (expm1 im) im))))
double code(double re, double im) {
double tmp;
if (im <= 4.9) {
tmp = sin(re);
} else {
tmp = (0.5 * re) * (expm1(im) - im);
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (im <= 4.9) {
tmp = Math.sin(re);
} else {
tmp = (0.5 * re) * (Math.expm1(im) - im);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 4.9: tmp = math.sin(re) else: tmp = (0.5 * re) * (math.expm1(im) - im) return tmp
function code(re, im) tmp = 0.0 if (im <= 4.9) tmp = sin(re); else tmp = Float64(Float64(0.5 * re) * Float64(expm1(im) - im)); end return tmp end
code[re_, im_] := If[LessEqual[im, 4.9], N[Sin[re], $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(N[(Exp[im] - 1), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 4.9:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(\mathsf{expm1}\left(im\right) - im\right)\\
\end{array}
\end{array}
if im < 4.9000000000000004Initial 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 58.4%
if 4.9000000000000004 < 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%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 66.7%
Simplified66.7%
Taylor expanded in re around 0 66.7%
associate-*r*66.7%
*-commutative66.7%
associate--r+66.7%
expm1-define66.7%
Simplified66.7%
Final simplification60.6%
(FPCore (re im)
:precision binary64
(if (<= im 3.3e+34)
(sin re)
(*
0.5
(*
re
(-
(+ 2.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))
im)))))
double code(double re, double im) {
double tmp;
if (im <= 3.3e+34) {
tmp = sin(re);
} else {
tmp = 0.5 * (re * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 3.3d+34) then
tmp = sin(re)
else
tmp = 0.5d0 * (re * ((2.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0)))))) - im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 3.3e+34) {
tmp = Math.sin(re);
} else {
tmp = 0.5 * (re * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 3.3e+34: tmp = math.sin(re) else: tmp = 0.5 * (re * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 3.3e+34) tmp = sin(re); else tmp = Float64(0.5 * Float64(re * Float64(Float64(2.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666)))))) - im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 3.3e+34) tmp = sin(re); else tmp = 0.5 * (re * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 3.3e+34], N[Sin[re], $MachinePrecision], N[(0.5 * N[(re * N[(N[(2.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 3.3 \cdot 10^{+34}:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(re \cdot \left(\left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right) - im\right)\right)\\
\end{array}
\end{array}
if im < 3.29999999999999988e34Initial 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 55.6%
if 3.29999999999999988e34 < 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%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 79.1%
*-commutative79.1%
Simplified79.1%
Taylor expanded in re around 0 54.6%
Final simplification55.4%
(FPCore (re im)
:precision binary64
(if (<= im 2.3)
(* 0.5 (* re (- (+ 2.0 (* im (+ 1.0 (* 0.5 im)))) im)))
(*
0.5
(* re (- (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))) im)))))
double code(double re, double im) {
double tmp;
if (im <= 2.3) {
tmp = 0.5 * (re * ((2.0 + (im * (1.0 + (0.5 * im)))) - im));
} else {
tmp = 0.5 * (re * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) - im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 2.3d0) then
tmp = 0.5d0 * (re * ((2.0d0 + (im * (1.0d0 + (0.5d0 * im)))) - im))
else
tmp = 0.5d0 * (re * ((im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))) - im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2.3) {
tmp = 0.5 * (re * ((2.0 + (im * (1.0 + (0.5 * im)))) - im));
} else {
tmp = 0.5 * (re * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) - im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.3: tmp = 0.5 * (re * ((2.0 + (im * (1.0 + (0.5 * im)))) - im)) else: tmp = 0.5 * (re * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) - im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 2.3) tmp = Float64(0.5 * Float64(re * Float64(Float64(2.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))) - im))); else tmp = Float64(0.5 * Float64(re * Float64(Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))) - im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.3) tmp = 0.5 * (re * ((2.0 + (im * (1.0 + (0.5 * im)))) - im)); else tmp = 0.5 * (re * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) - im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.3], N[(0.5 * N[(re * N[(N[(2.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(re * N[(N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.3:\\
\;\;\;\;0.5 \cdot \left(re \cdot \left(\left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right) - im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right) - im\right)\right)\\
\end{array}
\end{array}
if im < 2.2999999999999998Initial 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 59.2%
neg-mul-159.2%
unsub-neg59.2%
Simplified59.2%
Taylor expanded in im around 0 79.7%
Taylor expanded in re around 0 51.4%
if 2.2999999999999998 < 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%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 66.7%
Simplified66.7%
Taylor expanded in im around 0 47.1%
*-commutative68.1%
Simplified47.1%
Taylor expanded in re around 0 47.1%
Final simplification50.3%
(FPCore (re im) :precision binary64 (* (* 0.5 re) (+ (- 1.0 im) (+ 1.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666)))))))))
double code(double re, double im) {
return (0.5 * re) * ((1.0 - im) + (1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * re) * ((1.0d0 - im) + (1.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0)))))))
end function
public static double code(double re, double im) {
return (0.5 * re) * ((1.0 - im) + (1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))));
}
def code(re, im): return (0.5 * re) * ((1.0 - im) + (1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))))
function code(re, im) return Float64(Float64(0.5 * re) * Float64(Float64(1.0 - im) + Float64(1.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666)))))))) end
function tmp = code(re, im) tmp = (0.5 * re) * ((1.0 - im) + (1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))))); end
code[re_, im_] := N[(N[(0.5 * re), $MachinePrecision] * N[(N[(1.0 - im), $MachinePrecision] + N[(1.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot re\right) \cdot \left(\left(1 - im\right) + \left(1 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\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%
Taylor expanded in im around 0 70.2%
neg-mul-170.2%
unsub-neg70.2%
Simplified70.2%
Taylor expanded in im around 0 60.3%
*-commutative60.3%
Simplified60.3%
Taylor expanded in re around 0 42.5%
(FPCore (re im) :precision binary64 (* 0.5 (* re (- (+ 2.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666)))))) im))))
double code(double re, double im) {
return 0.5 * (re * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.5d0 * (re * ((2.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0)))))) - im))
end function
public static double code(double re, double im) {
return 0.5 * (re * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im));
}
def code(re, im): return 0.5 * (re * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im))
function code(re, im) return Float64(0.5 * Float64(re * Float64(Float64(2.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666)))))) - im))) end
function tmp = code(re, im) tmp = 0.5 * (re * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im)); end
code[re_, im_] := N[(0.5 * N[(re * N[(N[(2.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(re \cdot \left(\left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right) - im\right)\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%
Taylor expanded in im around 0 70.2%
neg-mul-170.2%
unsub-neg70.2%
Simplified70.2%
Taylor expanded in im around 0 60.3%
*-commutative60.3%
Simplified60.3%
Taylor expanded in re around 0 42.5%
Final simplification42.5%
(FPCore (re im) :precision binary64 (* 0.5 (* re (- (+ 2.0 (* im (+ 1.0 (* 0.5 im)))) im))))
double code(double re, double im) {
return 0.5 * (re * ((2.0 + (im * (1.0 + (0.5 * im)))) - im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.5d0 * (re * ((2.0d0 + (im * (1.0d0 + (0.5d0 * im)))) - im))
end function
public static double code(double re, double im) {
return 0.5 * (re * ((2.0 + (im * (1.0 + (0.5 * im)))) - im));
}
def code(re, im): return 0.5 * (re * ((2.0 + (im * (1.0 + (0.5 * im)))) - im))
function code(re, im) return Float64(0.5 * Float64(re * Float64(Float64(2.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))) - im))) end
function tmp = code(re, im) tmp = 0.5 * (re * ((2.0 + (im * (1.0 + (0.5 * im)))) - im)); end
code[re_, im_] := N[(0.5 * N[(re * N[(N[(2.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(re \cdot \left(\left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right) - im\right)\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%
Taylor expanded in im around 0 70.2%
neg-mul-170.2%
unsub-neg70.2%
Simplified70.2%
Taylor expanded in im around 0 71.1%
Taylor expanded in re around 0 48.8%
(FPCore (re im) :precision binary64 (if (<= re 2.75e+45) (* 2.0 (* 0.5 re)) (* (* re im) -0.5)))
double code(double re, double im) {
double tmp;
if (re <= 2.75e+45) {
tmp = 2.0 * (0.5 * re);
} else {
tmp = (re * im) * -0.5;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 2.75d+45) then
tmp = 2.0d0 * (0.5d0 * re)
else
tmp = (re * im) * (-0.5d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 2.75e+45) {
tmp = 2.0 * (0.5 * re);
} else {
tmp = (re * im) * -0.5;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 2.75e+45: tmp = 2.0 * (0.5 * re) else: tmp = (re * im) * -0.5 return tmp
function code(re, im) tmp = 0.0 if (re <= 2.75e+45) tmp = Float64(2.0 * Float64(0.5 * re)); else tmp = Float64(Float64(re * im) * -0.5); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 2.75e+45) tmp = 2.0 * (0.5 * re); else tmp = (re * im) * -0.5; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 2.75e+45], N[(2.0 * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(N[(re * im), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 2.75 \cdot 10^{+45}:\\
\;\;\;\;2 \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot im\right) \cdot -0.5\\
\end{array}
\end{array}
if re < 2.75e45Initial 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-rr99.9%
Taylor expanded in re around 0 73.8%
Simplified73.8%
Taylor expanded in im around 0 30.4%
if 2.75e45 < re 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 75.3%
neg-mul-175.3%
unsub-neg75.3%
Simplified75.3%
Taylor expanded in re around 0 27.2%
Simplified27.5%
Taylor expanded in im around inf 18.9%
*-commutative18.9%
*-commutative18.9%
Simplified18.9%
Final simplification28.0%
(FPCore (re im) :precision binary64 (* 2.0 (* 0.5 re)))
double code(double re, double im) {
return 2.0 * (0.5 * re);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 2.0d0 * (0.5d0 * re)
end function
public static double code(double re, double im) {
return 2.0 * (0.5 * re);
}
def code(re, im): return 2.0 * (0.5 * re)
function code(re, im) return Float64(2.0 * Float64(0.5 * re)) end
function tmp = code(re, im) tmp = 2.0 * (0.5 * re); end
code[re_, im_] := N[(2.0 * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(0.5 \cdot re\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%
Applied egg-rr99.9%
Taylor expanded in re around 0 64.7%
Simplified64.7%
Taylor expanded in im around 0 24.6%
Final simplification24.6%
(FPCore (re im) :precision binary64 (* re 2.0))
double code(double re, double im) {
return re * 2.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re * 2.0d0
end function
public static double code(double re, double im) {
return re * 2.0;
}
def code(re, im): return re * 2.0
function code(re, im) return Float64(re * 2.0) end
function tmp = code(re, im) tmp = re * 2.0; end
code[re_, im_] := N[(re * 2.0), $MachinePrecision]
\begin{array}{l}
\\
re \cdot 2
\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%
Applied egg-rr9.7%
count-29.7%
Simplified9.7%
Taylor expanded in re around 0 6.7%
Final simplification6.7%
(FPCore (re im) :precision binary64 0.5)
double code(double re, double im) {
return 0.5;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.5d0
end function
public static double code(double re, double im) {
return 0.5;
}
def code(re, im): return 0.5
function code(re, im) return 0.5 end
function tmp = code(re, im) tmp = 0.5; end
code[re_, im_] := 0.5
\begin{array}{l}
\\
0.5
\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%
Applied egg-rr9.7%
count-29.7%
Simplified9.7%
Taylor expanded in re around 0 6.7%
Applied egg-rr4.1%
(FPCore (re im) :precision binary64 0.25)
double code(double re, double im) {
return 0.25;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.25d0
end function
public static double code(double re, double im) {
return 0.25;
}
def code(re, im): return 0.25
function code(re, im) return 0.25 end
function tmp = code(re, im) tmp = 0.25; end
code[re_, im_] := 0.25
\begin{array}{l}
\\
0.25
\end{array}
Initial program 100.0%
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-rr9.7%
count-29.7%
Simplified9.7%
Taylor expanded in re around 0 6.7%
Applied egg-rr4.0%
(FPCore (re im) :precision binary64 -0.5)
double code(double re, double im) {
return -0.5;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -0.5d0
end function
public static double code(double re, double im) {
return -0.5;
}
def code(re, im): return -0.5
function code(re, im) return -0.5 end
function tmp = code(re, im) tmp = -0.5; end
code[re_, im_] := -0.5
\begin{array}{l}
\\
-0.5
\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%
Applied egg-rr9.7%
count-29.7%
Simplified9.7%
Taylor expanded in re around 0 6.7%
Applied egg-rr4.1%
(FPCore (re im) :precision binary64 -6.0)
double code(double re, double im) {
return -6.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -6.0d0
end function
public static double code(double re, double im) {
return -6.0;
}
def code(re, im): return -6.0
function code(re, im) return -6.0 end
function tmp = code(re, im) tmp = -6.0; end
code[re_, im_] := -6.0
\begin{array}{l}
\\
-6
\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%
Applied egg-rr9.7%
count-29.7%
Simplified9.7%
Taylor expanded in re around 0 6.7%
Applied egg-rr3.7%
herbie shell --seed 2024131
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))