
(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 16 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 1.02e-8)
(sin re)
(if (<= im 1.15e+77)
(*
(* 0.5 re)
(+
(exp im)
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))))
(* 0.041666666666666664 (* (sin re) (pow im 4.0))))))
double code(double re, double im) {
double tmp;
if (im <= 1.02e-8) {
tmp = sin(re);
} else if (im <= 1.15e+77) {
tmp = (0.5 * re) * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} else {
tmp = 0.041666666666666664 * (sin(re) * pow(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.02d-8) then
tmp = sin(re)
else if (im <= 1.15d+77) then
tmp = (0.5d0 * re) * (exp(im) + (1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))))
else
tmp = 0.041666666666666664d0 * (sin(re) * (im ** 4.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.02e-8) {
tmp = Math.sin(re);
} else if (im <= 1.15e+77) {
tmp = (0.5 * re) * (Math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} else {
tmp = 0.041666666666666664 * (Math.sin(re) * Math.pow(im, 4.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.02e-8: tmp = math.sin(re) elif im <= 1.15e+77: tmp = (0.5 * re) * (math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))) else: tmp = 0.041666666666666664 * (math.sin(re) * math.pow(im, 4.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.02e-8) tmp = sin(re); elseif (im <= 1.15e+77) 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.041666666666666664 * Float64(sin(re) * (im ^ 4.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.02e-8) tmp = sin(re); elseif (im <= 1.15e+77) tmp = (0.5 * re) * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))); else tmp = 0.041666666666666664 * (sin(re) * (im ^ 4.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.02e-8], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.15e+77], 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.041666666666666664 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.02 \cdot 10^{-8}:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\
\;\;\;\;\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.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\right)\\
\end{array}
\end{array}
if im < 1.02000000000000003e-8Initial 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.0%
if 1.02000000000000003e-8 < im < 1.14999999999999997e77Initial 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 94.1%
Taylor expanded in im around 0 93.1%
if 1.14999999999999997e77 < 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 90.9%
+-commutative90.9%
fma-define90.9%
associate-*r*90.9%
distribute-rgt-out90.9%
*-commutative90.9%
Simplified90.9%
Taylor expanded in im around inf 100.0%
Final simplification78.9%
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (+ (exp im) 1.0)))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp(im) + 1.0);
}
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)
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp(im) + 1.0);
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp(im) + 1.0)
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(im) + 1.0)) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp(im) + 1.0); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[im], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + 1\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 78.6%
Final simplification78.6%
(FPCore (re im)
:precision binary64
(if (<= im 1.02e-8)
(sin re)
(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))))))))))
double code(double re, double im) {
double tmp;
if (im <= 1.02e-8) {
tmp = sin(re);
} 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))))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.02d-8) then
tmp = sin(re)
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))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.02e-8) {
tmp = Math.sin(re);
} 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))))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.02e-8: tmp = math.sin(re) 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)))))) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.02e-8) tmp = sin(re); 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(Float64(0.5 * sin(re)) * Float64(2.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 <= 1.02e-8) tmp = sin(re); 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)))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.02e-8], N[Sin[re], $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[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(2.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 1.02 \cdot 10^{-8}:\\
\;\;\;\;\sin re\\
\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}:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if im < 1.02000000000000003e-8Initial 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.0%
if 1.02000000000000003e-8 < 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 86.4%
Taylor expanded in im around 0 85.6%
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%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification78.1%
(FPCore (re im)
:precision binary64
(if (<= im 4.5)
(sin re)
(if (<= im 1e+103)
(* (+ (exp im) 1.0) (* 0.5 re))
(*
(* 0.5 (sin re))
(+ 2.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))))))
double code(double re, double im) {
double tmp;
if (im <= 4.5) {
tmp = sin(re);
} else if (im <= 1e+103) {
tmp = (exp(im) + 1.0) * (0.5 * re);
} else {
tmp = (0.5 * sin(re)) * (2.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 <= 4.5d0) then
tmp = sin(re)
else if (im <= 1d+103) then
tmp = (exp(im) + 1.0d0) * (0.5d0 * re)
else
tmp = (0.5d0 * sin(re)) * (2.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 <= 4.5) {
tmp = Math.sin(re);
} else if (im <= 1e+103) {
tmp = (Math.exp(im) + 1.0) * (0.5 * re);
} else {
tmp = (0.5 * Math.sin(re)) * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 4.5: tmp = math.sin(re) elif im <= 1e+103: tmp = (math.exp(im) + 1.0) * (0.5 * re) else: tmp = (0.5 * math.sin(re)) * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) return tmp
function code(re, im) tmp = 0.0 if (im <= 4.5) tmp = sin(re); elseif (im <= 1e+103) tmp = Float64(Float64(exp(im) + 1.0) * Float64(0.5 * re)); else tmp = Float64(Float64(0.5 * sin(re)) * Float64(2.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 <= 4.5) tmp = sin(re); elseif (im <= 1e+103) tmp = (exp(im) + 1.0) * (0.5 * re); else tmp = (0.5 * sin(re)) * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 4.5], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1e+103], N[(N[(N[Exp[im], $MachinePrecision] + 1.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(2.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 4.5:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 10^{+103}:\\
\;\;\;\;\left(e^{im} + 1\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(2 + 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 71.9%
if 4.5 < 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%
Taylor expanded in re around 0 85.7%
associate-*r*85.7%
Simplified85.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%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification77.9%
(FPCore (re im)
:precision binary64
(if (<= im 4.4)
(sin re)
(if (<= im 1.9e+154)
(* (+ (exp im) 1.0) (* 0.5 re))
(* (* 0.5 (sin re)) (+ 2.0 (* im (+ 1.0 (* 0.5 im))))))))
double code(double re, double im) {
double tmp;
if (im <= 4.4) {
tmp = sin(re);
} else if (im <= 1.9e+154) {
tmp = (exp(im) + 1.0) * (0.5 * re);
} else {
tmp = (0.5 * sin(re)) * (2.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 <= 4.4d0) then
tmp = sin(re)
else if (im <= 1.9d+154) then
tmp = (exp(im) + 1.0d0) * (0.5d0 * re)
else
tmp = (0.5d0 * sin(re)) * (2.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 <= 4.4) {
tmp = Math.sin(re);
} else if (im <= 1.9e+154) {
tmp = (Math.exp(im) + 1.0) * (0.5 * re);
} else {
tmp = (0.5 * Math.sin(re)) * (2.0 + (im * (1.0 + (0.5 * im))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 4.4: tmp = math.sin(re) elif im <= 1.9e+154: tmp = (math.exp(im) + 1.0) * (0.5 * re) else: tmp = (0.5 * math.sin(re)) * (2.0 + (im * (1.0 + (0.5 * im)))) return tmp
function code(re, im) tmp = 0.0 if (im <= 4.4) tmp = sin(re); elseif (im <= 1.9e+154) tmp = Float64(Float64(exp(im) + 1.0) * Float64(0.5 * re)); else tmp = Float64(Float64(0.5 * sin(re)) * Float64(2.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 <= 4.4) tmp = sin(re); elseif (im <= 1.9e+154) tmp = (exp(im) + 1.0) * (0.5 * re); else tmp = (0.5 * sin(re)) * (2.0 + (im * (1.0 + (0.5 * im)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 4.4], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.9e+154], N[(N[(N[Exp[im], $MachinePrecision] + 1.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(2.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 4.4:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.9 \cdot 10^{+154}:\\
\;\;\;\;\left(e^{im} + 1\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 4.4000000000000004Initial 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.9%
if 4.4000000000000004 < 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%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 80.0%
associate-*r*80.0%
Simplified80.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%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification76.8%
(FPCore (re im) :precision binary64 (if (<= im 5.2) (sin re) (* (+ (exp im) 1.0) (* 0.5 re))))
double code(double re, double im) {
double tmp;
if (im <= 5.2) {
tmp = sin(re);
} else {
tmp = (exp(im) + 1.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 <= 5.2d0) then
tmp = sin(re)
else
tmp = (exp(im) + 1.0d0) * (0.5d0 * re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 5.2) {
tmp = Math.sin(re);
} else {
tmp = (Math.exp(im) + 1.0) * (0.5 * re);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 5.2: tmp = math.sin(re) else: tmp = (math.exp(im) + 1.0) * (0.5 * re) return tmp
function code(re, im) tmp = 0.0 if (im <= 5.2) tmp = sin(re); else tmp = Float64(Float64(exp(im) + 1.0) * Float64(0.5 * re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 5.2) tmp = sin(re); else tmp = (exp(im) + 1.0) * (0.5 * re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 5.2], N[Sin[re], $MachinePrecision], N[(N[(N[Exp[im], $MachinePrecision] + 1.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 5.2:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;\left(e^{im} + 1\right) \cdot \left(0.5 \cdot re\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 71.9%
if 5.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%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 84.8%
associate-*r*84.8%
Simplified84.8%
Final simplification75.2%
(FPCore (re im) :precision binary64 (if (<= im 106000.0) (sin re) (* re (* 0.041666666666666664 (pow im 4.0)))))
double code(double re, double im) {
double tmp;
if (im <= 106000.0) {
tmp = sin(re);
} else {
tmp = re * (0.041666666666666664 * pow(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 <= 106000.0d0) then
tmp = sin(re)
else
tmp = re * (0.041666666666666664d0 * (im ** 4.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 106000.0) {
tmp = Math.sin(re);
} else {
tmp = re * (0.041666666666666664 * Math.pow(im, 4.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 106000.0: tmp = math.sin(re) else: tmp = re * (0.041666666666666664 * math.pow(im, 4.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 106000.0) tmp = sin(re); else tmp = Float64(re * Float64(0.041666666666666664 * (im ^ 4.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 106000.0) tmp = sin(re); else tmp = re * (0.041666666666666664 * (im ^ 4.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 106000.0], N[Sin[re], $MachinePrecision], N[(re * N[(0.041666666666666664 * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 106000:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.041666666666666664 \cdot {im}^{4}\right)\\
\end{array}
\end{array}
if im < 106000Initial 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.9%
if 106000 < 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 70.0%
+-commutative70.0%
fma-define70.0%
associate-*r*70.0%
distribute-rgt-out70.0%
*-commutative70.0%
Simplified70.0%
Taylor expanded in im around inf 76.9%
Taylor expanded in re around 0 70.4%
associate-*r*70.4%
*-commutative70.4%
Simplified70.4%
(FPCore (re im) :precision binary64 (if (<= im 3350000.0) (sin re) (* 0.041666666666666664 (* re (pow im 4.0)))))
double code(double re, double im) {
double tmp;
if (im <= 3350000.0) {
tmp = sin(re);
} else {
tmp = 0.041666666666666664 * (re * pow(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 <= 3350000.0d0) then
tmp = sin(re)
else
tmp = 0.041666666666666664d0 * (re * (im ** 4.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 3350000.0) {
tmp = Math.sin(re);
} else {
tmp = 0.041666666666666664 * (re * Math.pow(im, 4.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 3350000.0: tmp = math.sin(re) else: tmp = 0.041666666666666664 * (re * math.pow(im, 4.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 3350000.0) tmp = sin(re); else tmp = Float64(0.041666666666666664 * Float64(re * (im ^ 4.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 3350000.0) tmp = sin(re); else tmp = 0.041666666666666664 * (re * (im ^ 4.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 3350000.0], N[Sin[re], $MachinePrecision], N[(0.041666666666666664 * N[(re * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 3350000:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\
\end{array}
\end{array}
if im < 3.35e6Initial 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.9%
if 3.35e6 < 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 70.0%
+-commutative70.0%
fma-define70.0%
associate-*r*70.0%
distribute-rgt-out70.0%
*-commutative70.0%
Simplified70.0%
Taylor expanded in im around inf 76.9%
Taylor expanded in re around 0 70.4%
Final simplification71.5%
(FPCore (re im)
:precision binary64
(if (<= im 56000.0)
(sin re)
(*
(+ 2.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))
(+ re 9.0))))
double code(double re, double im) {
double tmp;
if (im <= 56000.0) {
tmp = sin(re);
} else {
tmp = (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) * (re + 9.0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 56000.0d0) then
tmp = sin(re)
else
tmp = (2.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0)))))) * (re + 9.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 56000.0) {
tmp = Math.sin(re);
} else {
tmp = (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) * (re + 9.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 56000.0: tmp = math.sin(re) else: tmp = (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) * (re + 9.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 56000.0) tmp = sin(re); else tmp = Float64(Float64(2.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666)))))) * Float64(re + 9.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 56000.0) tmp = sin(re); else tmp = (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) * (re + 9.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 56000.0], 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] * N[(re + 9.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 56000:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;\left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right) \cdot \left(re + 9\right)\\
\end{array}
\end{array}
if im < 56000Initial 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.9%
if 56000 < 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%
Taylor expanded in im around 0 69.5%
*-commutative69.5%
Simplified69.5%
Taylor expanded in re around 0 64.5%
Applied egg-rr34.1%
log1p-undefine34.1%
rem-exp-log46.2%
+-commutative46.2%
associate--l+46.2%
metadata-eval46.2%
Simplified46.2%
Final simplification65.2%
(FPCore (re im) :precision binary64 (* (* 0.5 re) (+ 2.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))))
double code(double re, double im) {
return (0.5 * re) * (2.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) * (2.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))))
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))))));
}
def code(re, im): return (0.5 * re) * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))))
function code(re, im) return Float64(Float64(0.5 * re) * Float64(2.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) * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))); end
code[re_, im_] := N[(N[(0.5 * re), $MachinePrecision] * N[(2.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}
\\
\left(0.5 \cdot re\right) \cdot \left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\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 78.6%
Taylor expanded in im around 0 70.2%
*-commutative70.2%
Simplified70.2%
Taylor expanded in re around 0 42.5%
(FPCore (re im) :precision binary64 (* (* 0.5 re) (+ 2.0 (* im (+ 1.0 (* im (* im 0.16666666666666666)))))))
double code(double re, double im) {
return (0.5 * re) * (2.0 + (im * (1.0 + (im * (im * 0.16666666666666666)))));
}
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 * (im * 0.16666666666666666d0)))))
end function
public static double code(double re, double im) {
return (0.5 * re) * (2.0 + (im * (1.0 + (im * (im * 0.16666666666666666)))));
}
def code(re, im): return (0.5 * re) * (2.0 + (im * (1.0 + (im * (im * 0.16666666666666666)))))
function code(re, im) return Float64(Float64(0.5 * re) * Float64(2.0 + Float64(im * Float64(1.0 + Float64(im * Float64(im * 0.16666666666666666)))))) end
function tmp = code(re, im) tmp = (0.5 * re) * (2.0 + (im * (1.0 + (im * (im * 0.16666666666666666))))); end
code[re_, im_] := N[(N[(0.5 * re), $MachinePrecision] * N[(2.0 + N[(im * N[(1.0 + N[(im * N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot re\right) \cdot \left(2 + im \cdot \left(1 + im \cdot \left(im \cdot 0.16666666666666666\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 78.6%
Taylor expanded in im around 0 70.2%
*-commutative70.2%
Simplified70.2%
Taylor expanded in re around 0 42.5%
Taylor expanded in im around inf 42.5%
*-commutative42.5%
Simplified42.5%
(FPCore (re im) :precision binary64 (* (* 0.5 re) (+ 2.0 (* im (+ 1.0 (* 0.5 im))))))
double code(double re, double im) {
return (0.5 * re) * (2.0 + (im * (1.0 + (0.5 * 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))))
end function
public static double code(double re, double im) {
return (0.5 * re) * (2.0 + (im * (1.0 + (0.5 * im))));
}
def code(re, im): return (0.5 * re) * (2.0 + (im * (1.0 + (0.5 * im))))
function code(re, im) return Float64(Float64(0.5 * re) * Float64(2.0 + Float64(im * Float64(1.0 + Float64(0.5 * im))))) end
function tmp = code(re, im) tmp = (0.5 * re) * (2.0 + (im * (1.0 + (0.5 * im)))); end
code[re_, im_] := N[(N[(0.5 * re), $MachinePrecision] * N[(2.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot re\right) \cdot \left(2 + im \cdot \left(1 + 0.5 \cdot 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 78.6%
Taylor expanded in im around 0 70.2%
*-commutative70.2%
Simplified70.2%
Taylor expanded in re around 0 42.5%
Taylor expanded in im around 0 44.5%
Final simplification44.5%
(FPCore (re im) :precision binary64 (* (* 0.5 re) (+ im 2.0)))
double code(double re, double im) {
return (0.5 * re) * (im + 2.0);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * re) * (im + 2.0d0)
end function
public static double code(double re, double im) {
return (0.5 * re) * (im + 2.0);
}
def code(re, im): return (0.5 * re) * (im + 2.0)
function code(re, im) return Float64(Float64(0.5 * re) * Float64(im + 2.0)) end
function tmp = code(re, im) tmp = (0.5 * re) * (im + 2.0); end
code[re_, im_] := N[(N[(0.5 * re), $MachinePrecision] * N[(im + 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot re\right) \cdot \left(im + 2\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 78.6%
Taylor expanded in im around 0 53.4%
Taylor expanded in re around 0 29.2%
Final simplification29.2%
(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 re around 0 59.6%
Taylor expanded in im around 0 23.5%
(FPCore (re im) :precision binary64 9.0)
double code(double re, double im) {
return 9.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 9.0d0
end function
public static double code(double re, double im) {
return 9.0;
}
def code(re, im): return 9.0
function code(re, im) return 9.0 end
function tmp = code(re, im) tmp = 9.0; end
code[re_, im_] := 9.0
\begin{array}{l}
\\
9
\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 78.2%
+-commutative78.2%
unpow278.2%
fma-define78.2%
Simplified78.2%
Applied egg-rr4.4%
log1p-undefine4.4%
rem-exp-log4.4%
+-commutative4.4%
associate--l+4.4%
metadata-eval4.4%
Simplified4.4%
Taylor expanded in re around 0 4.4%
herbie shell --seed 2024137
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))