
(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 14 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%
Final simplification100.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (sin re))))
(if (<= im 0.0055)
(* t_0 (fma im im 2.0))
(if (<= im 1.34e+154)
(* (+ (exp (- im)) (exp im)) (* 0.5 re))
(* t_0 (pow im 2.0))))))
double code(double re, double im) {
double t_0 = 0.5 * sin(re);
double tmp;
if (im <= 0.0055) {
tmp = t_0 * fma(im, im, 2.0);
} else if (im <= 1.34e+154) {
tmp = (exp(-im) + exp(im)) * (0.5 * re);
} else {
tmp = t_0 * pow(im, 2.0);
}
return tmp;
}
function code(re, im) t_0 = Float64(0.5 * sin(re)) tmp = 0.0 if (im <= 0.0055) tmp = Float64(t_0 * fma(im, im, 2.0)); elseif (im <= 1.34e+154) tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 * re)); else tmp = Float64(t_0 * (im ^ 2.0)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 0.0055], N[(t$95$0 * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.34e+154], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
\mathbf{if}\;im \leq 0.0055:\\
\;\;\;\;t\_0 \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{elif}\;im \leq 1.34 \cdot 10^{+154}:\\
\;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot {im}^{2}\\
\end{array}
\end{array}
if im < 0.0054999999999999997Initial 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 83.8%
+-commutative48.4%
unpow248.4%
fma-define48.4%
Simplified83.8%
if 0.0054999999999999997 < im < 1.34000000000000001e154Initial 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 80.6%
if 1.34000000000000001e154 < 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 inf 100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*r*100.0%
Simplified100.0%
Final simplification85.3%
(FPCore (re im)
:precision binary64
(if (<= im 680.0)
(sin re)
(if (<= im 1.34e+154)
(cbrt (pow re -12.0))
(* (* 0.5 (sin re)) (pow im 2.0)))))
double code(double re, double im) {
double tmp;
if (im <= 680.0) {
tmp = sin(re);
} else if (im <= 1.34e+154) {
tmp = cbrt(pow(re, -12.0));
} else {
tmp = (0.5 * sin(re)) * pow(im, 2.0);
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (im <= 680.0) {
tmp = Math.sin(re);
} else if (im <= 1.34e+154) {
tmp = Math.cbrt(Math.pow(re, -12.0));
} else {
tmp = (0.5 * Math.sin(re)) * Math.pow(im, 2.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 680.0) tmp = sin(re); elseif (im <= 1.34e+154) tmp = cbrt((re ^ -12.0)); else tmp = Float64(Float64(0.5 * sin(re)) * (im ^ 2.0)); end return tmp end
code[re_, im_] := If[LessEqual[im, 680.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.34e+154], N[Power[N[Power[re, -12.0], $MachinePrecision], 1/3], $MachinePrecision], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 680:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.34 \cdot 10^{+154}:\\
\;\;\;\;\sqrt[3]{{re}^{-12}}\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot {im}^{2}\\
\end{array}
\end{array}
if im < 680Initial 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 64.2%
if 680 < im < 1.34000000000000001e154Initial 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 78.8%
Applied egg-rr21.8%
add-cbrt-cube27.5%
pow1/327.5%
pow327.5%
exp-to-pow28.1%
pow-pow28.1%
metadata-eval28.1%
Applied egg-rr28.1%
unpow1/328.1%
Simplified28.1%
if 1.34000000000000001e154 < 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 inf 100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*r*100.0%
Simplified100.0%
Final simplification64.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (sin re))))
(if (<= im 820.0)
(* t_0 (fma im im 2.0))
(if (<= im 1.34e+154) (cbrt (pow re -12.0)) (* t_0 (pow im 2.0))))))
double code(double re, double im) {
double t_0 = 0.5 * sin(re);
double tmp;
if (im <= 820.0) {
tmp = t_0 * fma(im, im, 2.0);
} else if (im <= 1.34e+154) {
tmp = cbrt(pow(re, -12.0));
} else {
tmp = t_0 * pow(im, 2.0);
}
return tmp;
}
function code(re, im) t_0 = Float64(0.5 * sin(re)) tmp = 0.0 if (im <= 820.0) tmp = Float64(t_0 * fma(im, im, 2.0)); elseif (im <= 1.34e+154) tmp = cbrt((re ^ -12.0)); else tmp = Float64(t_0 * (im ^ 2.0)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 820.0], N[(t$95$0 * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.34e+154], N[Power[N[Power[re, -12.0], $MachinePrecision], 1/3], $MachinePrecision], N[(t$95$0 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
\mathbf{if}\;im \leq 820:\\
\;\;\;\;t\_0 \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{elif}\;im \leq 1.34 \cdot 10^{+154}:\\
\;\;\;\;\sqrt[3]{{re}^{-12}}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot {im}^{2}\\
\end{array}
\end{array}
if im < 820Initial 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 82.9%
+-commutative48.1%
unpow248.1%
fma-define48.1%
Simplified82.9%
if 820 < im < 1.34000000000000001e154Initial 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 78.8%
Applied egg-rr21.8%
add-cbrt-cube27.5%
pow1/327.5%
pow327.5%
exp-to-pow28.1%
pow-pow28.1%
metadata-eval28.1%
Applied egg-rr28.1%
unpow1/328.1%
Simplified28.1%
if 1.34000000000000001e154 < 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 inf 100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*r*100.0%
Simplified100.0%
Final simplification78.0%
(FPCore (re im)
:precision binary64
(if (<= im 650.0)
(sin re)
(if (<= im 1.8e+141)
(cbrt (pow re -12.0))
(if (<= im 1.8e+243)
(* (fma im im 2.0) (* 0.5 re))
(if (<= im 6.8e+259)
(* re (+ 1.0 (* (pow re 2.0) -0.16666666666666666)))
(* re (* 0.5 (pow im 2.0))))))))
double code(double re, double im) {
double tmp;
if (im <= 650.0) {
tmp = sin(re);
} else if (im <= 1.8e+141) {
tmp = cbrt(pow(re, -12.0));
} else if (im <= 1.8e+243) {
tmp = fma(im, im, 2.0) * (0.5 * re);
} else if (im <= 6.8e+259) {
tmp = re * (1.0 + (pow(re, 2.0) * -0.16666666666666666));
} else {
tmp = re * (0.5 * pow(im, 2.0));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 650.0) tmp = sin(re); elseif (im <= 1.8e+141) tmp = cbrt((re ^ -12.0)); elseif (im <= 1.8e+243) tmp = Float64(fma(im, im, 2.0) * Float64(0.5 * re)); elseif (im <= 6.8e+259) tmp = Float64(re * Float64(1.0 + Float64((re ^ 2.0) * -0.16666666666666666))); else tmp = Float64(re * Float64(0.5 * (im ^ 2.0))); end return tmp end
code[re_, im_] := If[LessEqual[im, 650.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.8e+141], N[Power[N[Power[re, -12.0], $MachinePrecision], 1/3], $MachinePrecision], If[LessEqual[im, 1.8e+243], N[(N[(im * im + 2.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 6.8e+259], N[(re * N[(1.0 + N[(N[Power[re, 2.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 650:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.8 \cdot 10^{+141}:\\
\;\;\;\;\sqrt[3]{{re}^{-12}}\\
\mathbf{elif}\;im \leq 1.8 \cdot 10^{+243}:\\
\;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{elif}\;im \leq 6.8 \cdot 10^{+259}:\\
\;\;\;\;re \cdot \left(1 + {re}^{2} \cdot -0.16666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 650Initial 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 64.2%
if 650 < im < 1.8000000000000001e141Initial 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 77.4%
Applied egg-rr19.9%
add-cbrt-cube26.0%
pow1/326.0%
pow326.0%
exp-to-pow26.6%
pow-pow26.6%
metadata-eval26.6%
Applied egg-rr26.6%
unpow1/326.6%
Simplified26.6%
if 1.8000000000000001e141 < im < 1.7999999999999998e243Initial 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 72.7%
Taylor expanded in im around 0 68.3%
+-commutative68.3%
unpow268.3%
fma-define68.3%
Simplified68.3%
if 1.7999999999999998e243 < im < 6.79999999999999979e259Initial 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 3.1%
Taylor expanded in re around 0 67.8%
*-commutative67.8%
Simplified67.8%
if 6.79999999999999979e259 < 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 re around 0 66.7%
Taylor expanded in im around 0 66.7%
+-commutative66.7%
unpow266.7%
fma-define66.7%
Simplified66.7%
Taylor expanded in im around inf 66.7%
associate-*r*66.7%
*-commutative66.7%
Simplified66.7%
Final simplification60.1%
(FPCore (re im)
:precision binary64
(if (<= im 660.0)
(sin re)
(if (<= im 1.7e+132)
(pow re -4.0)
(if (<= im 1.8e+243)
(* (fma im im 2.0) (* 0.5 re))
(if (<= im 6.8e+259)
(* re (+ 1.0 (* (pow re 2.0) -0.16666666666666666)))
(* re (* 0.5 (pow im 2.0))))))))
double code(double re, double im) {
double tmp;
if (im <= 660.0) {
tmp = sin(re);
} else if (im <= 1.7e+132) {
tmp = pow(re, -4.0);
} else if (im <= 1.8e+243) {
tmp = fma(im, im, 2.0) * (0.5 * re);
} else if (im <= 6.8e+259) {
tmp = re * (1.0 + (pow(re, 2.0) * -0.16666666666666666));
} else {
tmp = re * (0.5 * pow(im, 2.0));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 660.0) tmp = sin(re); elseif (im <= 1.7e+132) tmp = re ^ -4.0; elseif (im <= 1.8e+243) tmp = Float64(fma(im, im, 2.0) * Float64(0.5 * re)); elseif (im <= 6.8e+259) tmp = Float64(re * Float64(1.0 + Float64((re ^ 2.0) * -0.16666666666666666))); else tmp = Float64(re * Float64(0.5 * (im ^ 2.0))); end return tmp end
code[re_, im_] := If[LessEqual[im, 660.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.7e+132], N[Power[re, -4.0], $MachinePrecision], If[LessEqual[im, 1.8e+243], N[(N[(im * im + 2.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 6.8e+259], N[(re * N[(1.0 + N[(N[Power[re, 2.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 660:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.7 \cdot 10^{+132}:\\
\;\;\;\;{re}^{-4}\\
\mathbf{elif}\;im \leq 1.8 \cdot 10^{+243}:\\
\;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{elif}\;im \leq 6.8 \cdot 10^{+259}:\\
\;\;\;\;re \cdot \left(1 + {re}^{2} \cdot -0.16666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 660Initial 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 64.2%
if 660 < im < 1.70000000000000013e132Initial 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 73.1%
Applied egg-rr20.6%
if 1.70000000000000013e132 < im < 1.7999999999999998e243Initial 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 77.8%
Taylor expanded in im around 0 63.7%
+-commutative63.7%
unpow263.7%
fma-define63.7%
Simplified63.7%
if 1.7999999999999998e243 < im < 6.79999999999999979e259Initial 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 3.1%
Taylor expanded in re around 0 67.8%
*-commutative67.8%
Simplified67.8%
if 6.79999999999999979e259 < 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 re around 0 66.7%
Taylor expanded in im around 0 66.7%
+-commutative66.7%
unpow266.7%
fma-define66.7%
Simplified66.7%
Taylor expanded in im around inf 66.7%
associate-*r*66.7%
*-commutative66.7%
Simplified66.7%
Final simplification59.8%
(FPCore (re im)
:precision binary64
(if (<= im 720.0)
(sin re)
(if (<= im 4.4e+130)
(pow re -4.0)
(if (or (<= im 1.8e+243) (not (<= im 6.8e+259)))
(* re (* 0.5 (pow im 2.0)))
(* -0.16666666666666666 (pow re 3.0))))))
double code(double re, double im) {
double tmp;
if (im <= 720.0) {
tmp = sin(re);
} else if (im <= 4.4e+130) {
tmp = pow(re, -4.0);
} else if ((im <= 1.8e+243) || !(im <= 6.8e+259)) {
tmp = re * (0.5 * pow(im, 2.0));
} else {
tmp = -0.16666666666666666 * pow(re, 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 <= 720.0d0) then
tmp = sin(re)
else if (im <= 4.4d+130) then
tmp = re ** (-4.0d0)
else if ((im <= 1.8d+243) .or. (.not. (im <= 6.8d+259))) then
tmp = re * (0.5d0 * (im ** 2.0d0))
else
tmp = (-0.16666666666666666d0) * (re ** 3.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 720.0) {
tmp = Math.sin(re);
} else if (im <= 4.4e+130) {
tmp = Math.pow(re, -4.0);
} else if ((im <= 1.8e+243) || !(im <= 6.8e+259)) {
tmp = re * (0.5 * Math.pow(im, 2.0));
} else {
tmp = -0.16666666666666666 * Math.pow(re, 3.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 720.0: tmp = math.sin(re) elif im <= 4.4e+130: tmp = math.pow(re, -4.0) elif (im <= 1.8e+243) or not (im <= 6.8e+259): tmp = re * (0.5 * math.pow(im, 2.0)) else: tmp = -0.16666666666666666 * math.pow(re, 3.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 720.0) tmp = sin(re); elseif (im <= 4.4e+130) tmp = re ^ -4.0; elseif ((im <= 1.8e+243) || !(im <= 6.8e+259)) tmp = Float64(re * Float64(0.5 * (im ^ 2.0))); else tmp = Float64(-0.16666666666666666 * (re ^ 3.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 720.0) tmp = sin(re); elseif (im <= 4.4e+130) tmp = re ^ -4.0; elseif ((im <= 1.8e+243) || ~((im <= 6.8e+259))) tmp = re * (0.5 * (im ^ 2.0)); else tmp = -0.16666666666666666 * (re ^ 3.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 720.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 4.4e+130], N[Power[re, -4.0], $MachinePrecision], If[Or[LessEqual[im, 1.8e+243], N[Not[LessEqual[im, 6.8e+259]], $MachinePrecision]], N[(re * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 720:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 4.4 \cdot 10^{+130}:\\
\;\;\;\;{re}^{-4}\\
\mathbf{elif}\;im \leq 1.8 \cdot 10^{+243} \lor \neg \left(im \leq 6.8 \cdot 10^{+259}\right):\\
\;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;-0.16666666666666666 \cdot {re}^{3}\\
\end{array}
\end{array}
if im < 720Initial 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 64.2%
if 720 < im < 4.39999999999999987e130Initial 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 73.1%
Applied egg-rr20.6%
if 4.39999999999999987e130 < im < 1.7999999999999998e243 or 6.79999999999999979e259 < 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 re around 0 75.0%
Taylor expanded in im around 0 64.4%
+-commutative64.4%
unpow264.4%
fma-define64.4%
Simplified64.4%
Taylor expanded in im around inf 64.4%
associate-*r*64.4%
*-commutative64.4%
Simplified64.4%
if 1.7999999999999998e243 < im < 6.79999999999999979e259Initial 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 3.1%
Taylor expanded in re around 0 67.8%
*-commutative67.8%
Simplified67.8%
Taylor expanded in re around inf 67.8%
Final simplification59.8%
(FPCore (re im)
:precision binary64
(if (<= im 780.0)
(sin re)
(if (<= im 9.8e+129)
(pow re -4.0)
(if (<= im 1.8e+243)
(* (fma im im 2.0) (* 0.5 re))
(if (<= im 6.8e+259)
(* -0.16666666666666666 (pow re 3.0))
(* re (* 0.5 (pow im 2.0))))))))
double code(double re, double im) {
double tmp;
if (im <= 780.0) {
tmp = sin(re);
} else if (im <= 9.8e+129) {
tmp = pow(re, -4.0);
} else if (im <= 1.8e+243) {
tmp = fma(im, im, 2.0) * (0.5 * re);
} else if (im <= 6.8e+259) {
tmp = -0.16666666666666666 * pow(re, 3.0);
} else {
tmp = re * (0.5 * pow(im, 2.0));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 780.0) tmp = sin(re); elseif (im <= 9.8e+129) tmp = re ^ -4.0; elseif (im <= 1.8e+243) tmp = Float64(fma(im, im, 2.0) * Float64(0.5 * re)); elseif (im <= 6.8e+259) tmp = Float64(-0.16666666666666666 * (re ^ 3.0)); else tmp = Float64(re * Float64(0.5 * (im ^ 2.0))); end return tmp end
code[re_, im_] := If[LessEqual[im, 780.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 9.8e+129], N[Power[re, -4.0], $MachinePrecision], If[LessEqual[im, 1.8e+243], N[(N[(im * im + 2.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 6.8e+259], N[(-0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision], N[(re * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 780:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 9.8 \cdot 10^{+129}:\\
\;\;\;\;{re}^{-4}\\
\mathbf{elif}\;im \leq 1.8 \cdot 10^{+243}:\\
\;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{elif}\;im \leq 6.8 \cdot 10^{+259}:\\
\;\;\;\;-0.16666666666666666 \cdot {re}^{3}\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 780Initial 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 64.2%
if 780 < im < 9.8e129Initial 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 73.1%
Applied egg-rr20.6%
if 9.8e129 < im < 1.7999999999999998e243Initial 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 77.8%
Taylor expanded in im around 0 63.7%
+-commutative63.7%
unpow263.7%
fma-define63.7%
Simplified63.7%
if 1.7999999999999998e243 < im < 6.79999999999999979e259Initial 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 3.1%
Taylor expanded in re around 0 67.8%
*-commutative67.8%
Simplified67.8%
Taylor expanded in re around inf 67.8%
if 6.79999999999999979e259 < 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 re around 0 66.7%
Taylor expanded in im around 0 66.7%
+-commutative66.7%
unpow266.7%
fma-define66.7%
Simplified66.7%
Taylor expanded in im around inf 66.7%
associate-*r*66.7%
*-commutative66.7%
Simplified66.7%
Final simplification59.8%
(FPCore (re im)
:precision binary64
(if (<= im 560.0)
(sin re)
(if (or (<= im 1.8e+243) (not (<= im 6.8e+259)))
(pow re -4.0)
(* -0.16666666666666666 (pow re 3.0)))))
double code(double re, double im) {
double tmp;
if (im <= 560.0) {
tmp = sin(re);
} else if ((im <= 1.8e+243) || !(im <= 6.8e+259)) {
tmp = pow(re, -4.0);
} else {
tmp = -0.16666666666666666 * pow(re, 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 <= 560.0d0) then
tmp = sin(re)
else if ((im <= 1.8d+243) .or. (.not. (im <= 6.8d+259))) then
tmp = re ** (-4.0d0)
else
tmp = (-0.16666666666666666d0) * (re ** 3.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 560.0) {
tmp = Math.sin(re);
} else if ((im <= 1.8e+243) || !(im <= 6.8e+259)) {
tmp = Math.pow(re, -4.0);
} else {
tmp = -0.16666666666666666 * Math.pow(re, 3.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 560.0: tmp = math.sin(re) elif (im <= 1.8e+243) or not (im <= 6.8e+259): tmp = math.pow(re, -4.0) else: tmp = -0.16666666666666666 * math.pow(re, 3.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 560.0) tmp = sin(re); elseif ((im <= 1.8e+243) || !(im <= 6.8e+259)) tmp = re ^ -4.0; else tmp = Float64(-0.16666666666666666 * (re ^ 3.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 560.0) tmp = sin(re); elseif ((im <= 1.8e+243) || ~((im <= 6.8e+259))) tmp = re ^ -4.0; else tmp = -0.16666666666666666 * (re ^ 3.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 560.0], N[Sin[re], $MachinePrecision], If[Or[LessEqual[im, 1.8e+243], N[Not[LessEqual[im, 6.8e+259]], $MachinePrecision]], N[Power[re, -4.0], $MachinePrecision], N[(-0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 560:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.8 \cdot 10^{+243} \lor \neg \left(im \leq 6.8 \cdot 10^{+259}\right):\\
\;\;\;\;{re}^{-4}\\
\mathbf{else}:\\
\;\;\;\;-0.16666666666666666 \cdot {re}^{3}\\
\end{array}
\end{array}
if im < 560Initial 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 64.2%
if 560 < im < 1.7999999999999998e243 or 6.79999999999999979e259 < 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 re around 0 74.2%
Applied egg-rr20.4%
if 1.7999999999999998e243 < im < 6.79999999999999979e259Initial 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 3.1%
Taylor expanded in re around 0 67.8%
*-commutative67.8%
Simplified67.8%
Taylor expanded in re around inf 67.8%
Final simplification53.6%
(FPCore (re im) :precision binary64 (if (<= im 600.0) (sin re) (pow re -4.0)))
double code(double re, double im) {
double tmp;
if (im <= 600.0) {
tmp = sin(re);
} else {
tmp = pow(re, -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 <= 600.0d0) then
tmp = sin(re)
else
tmp = re ** (-4.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 600.0) {
tmp = Math.sin(re);
} else {
tmp = Math.pow(re, -4.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 600.0: tmp = math.sin(re) else: tmp = math.pow(re, -4.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 600.0) tmp = sin(re); else tmp = re ^ -4.0; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 600.0) tmp = sin(re); else tmp = re ^ -4.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 600.0], N[Sin[re], $MachinePrecision], N[Power[re, -4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 600:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;{re}^{-4}\\
\end{array}
\end{array}
if im < 600Initial 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 64.2%
if 600 < 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 re around 0 70.8%
Applied egg-rr19.5%
Final simplification52.8%
(FPCore (re im) :precision binary64 (sin re))
double code(double re, double im) {
return sin(re);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = sin(re)
end function
public static double code(double re, double im) {
return Math.sin(re);
}
def code(re, im): return math.sin(re)
function code(re, im) return sin(re) end
function tmp = code(re, im) tmp = sin(re); end
code[re_, im_] := N[Sin[re], $MachinePrecision]
\begin{array}{l}
\\
\sin 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 48.5%
Final simplification48.5%
(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%
Applied egg-rr3.0%
pow-base-13.0%
metadata-eval3.0%
Simplified3.0%
Final simplification3.0%
(FPCore (re im) :precision binary64 1.0)
double code(double re, double im) {
return 1.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 1.0d0
end function
public static double code(double re, double im) {
return 1.0;
}
def code(re, im): return 1.0
function code(re, im) return 1.0 end
function tmp = code(re, im) tmp = 1.0; end
code[re_, im_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
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-rr4.5%
+-inverses4.5%
+-rgt-identity4.5%
*-inverses4.5%
Simplified4.5%
Final simplification4.5%
(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 62.2%
Taylor expanded in im around 0 26.1%
Final simplification26.1%
herbie shell --seed 2024055
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))