
(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 12 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 (* (+ (exp (- im)) (exp im)) (* 0.5 (sin re))))
double code(double re, double im) {
return (exp(-im) + exp(im)) * (0.5 * sin(re));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (exp(-im) + exp(im)) * (0.5d0 * sin(re))
end function
public static double code(double re, double im) {
return (Math.exp(-im) + Math.exp(im)) * (0.5 * Math.sin(re));
}
def code(re, im): return (math.exp(-im) + math.exp(im)) * (0.5 * math.sin(re))
function code(re, im) return Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 * sin(re))) end
function tmp = code(re, im) tmp = (exp(-im) + exp(im)) * (0.5 * sin(re)); end
code[re_, im_] := N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot \sin re\right)
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (re im)
:precision binary64
(if (<= im 0.0095)
(* (sin re) (* 0.5 (fma im im 2.0)))
(if (<= im 1.35e+154)
(* (+ (exp (- im)) (exp im)) (* 0.5 re))
(* (pow im 2.0) (* 0.5 (sin re))))))
double code(double re, double im) {
double tmp;
if (im <= 0.0095) {
tmp = sin(re) * (0.5 * fma(im, im, 2.0));
} else if (im <= 1.35e+154) {
tmp = (exp(-im) + exp(im)) * (0.5 * re);
} else {
tmp = pow(im, 2.0) * (0.5 * sin(re));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 0.0095) tmp = Float64(sin(re) * Float64(0.5 * fma(im, im, 2.0))); elseif (im <= 1.35e+154) tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 * re)); else tmp = Float64((im ^ 2.0) * Float64(0.5 * sin(re))); end return tmp end
code[re_, im_] := If[LessEqual[im, 0.0095], N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.35e+154], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(N[Power[im, 2.0], $MachinePrecision] * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.0095:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot \mathsf{fma}\left(im, im, 2\right)\right)\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;{im}^{2} \cdot \left(0.5 \cdot \sin re\right)\\
\end{array}
\end{array}
if im < 0.00949999999999999976Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 83.1%
Taylor expanded in re around inf 83.1%
associate-*r*83.1%
*-commutative83.1%
+-commutative83.1%
unpow283.1%
fma-udef83.1%
associate-*r*83.1%
Simplified83.1%
if 0.00949999999999999976 < im < 1.35000000000000003e154Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 76.4%
if 1.35000000000000003e154 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around inf 100.0%
*-commutative100.0%
associate-*r*100.0%
Simplified100.0%
Final simplification84.7%
(FPCore (re im)
:precision binary64
(if (<= im 850.0)
(sin re)
(if (<= im 1.35e+154)
(cbrt (pow re -6.0))
(* (pow im 2.0) (* 0.5 (sin re))))))
double code(double re, double im) {
double tmp;
if (im <= 850.0) {
tmp = sin(re);
} else if (im <= 1.35e+154) {
tmp = cbrt(pow(re, -6.0));
} else {
tmp = pow(im, 2.0) * (0.5 * sin(re));
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (im <= 850.0) {
tmp = Math.sin(re);
} else if (im <= 1.35e+154) {
tmp = Math.cbrt(Math.pow(re, -6.0));
} else {
tmp = Math.pow(im, 2.0) * (0.5 * Math.sin(re));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 850.0) tmp = sin(re); elseif (im <= 1.35e+154) tmp = cbrt((re ^ -6.0)); else tmp = Float64((im ^ 2.0) * Float64(0.5 * sin(re))); end return tmp end
code[re_, im_] := If[LessEqual[im, 850.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.35e+154], N[Power[N[Power[re, -6.0], $MachinePrecision], 1/3], $MachinePrecision], N[(N[Power[im, 2.0], $MachinePrecision] * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 850:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\sqrt[3]{{re}^{-6}}\\
\mathbf{else}:\\
\;\;\;\;{im}^{2} \cdot \left(0.5 \cdot \sin re\right)\\
\end{array}
\end{array}
if im < 850Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 66.6%
if 850 < im < 1.35000000000000003e154Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 2.7%
Applied egg-rr13.9%
Taylor expanded in re around 0 13.8%
metadata-eval13.8%
pow-flip13.8%
add-cbrt-cube25.2%
pow325.2%
pow-flip25.2%
metadata-eval25.2%
pow-pow25.2%
metadata-eval25.2%
Applied egg-rr25.2%
if 1.35000000000000003e154 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around inf 100.0%
*-commutative100.0%
associate-*r*100.0%
Simplified100.0%
Final simplification66.2%
(FPCore (re im)
:precision binary64
(if (<= im 980.0)
(* (sin re) (* 0.5 (fma im im 2.0)))
(if (<= im 1.35e+154)
(cbrt (pow re -6.0))
(* (pow im 2.0) (* 0.5 (sin re))))))
double code(double re, double im) {
double tmp;
if (im <= 980.0) {
tmp = sin(re) * (0.5 * fma(im, im, 2.0));
} else if (im <= 1.35e+154) {
tmp = cbrt(pow(re, -6.0));
} else {
tmp = pow(im, 2.0) * (0.5 * sin(re));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 980.0) tmp = Float64(sin(re) * Float64(0.5 * fma(im, im, 2.0))); elseif (im <= 1.35e+154) tmp = cbrt((re ^ -6.0)); else tmp = Float64((im ^ 2.0) * Float64(0.5 * sin(re))); end return tmp end
code[re_, im_] := If[LessEqual[im, 980.0], N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.35e+154], N[Power[N[Power[re, -6.0], $MachinePrecision], 1/3], $MachinePrecision], N[(N[Power[im, 2.0], $MachinePrecision] * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 980:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot \mathsf{fma}\left(im, im, 2\right)\right)\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\sqrt[3]{{re}^{-6}}\\
\mathbf{else}:\\
\;\;\;\;{im}^{2} \cdot \left(0.5 \cdot \sin re\right)\\
\end{array}
\end{array}
if im < 980Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 83.0%
Taylor expanded in re around inf 83.0%
associate-*r*83.0%
*-commutative83.0%
+-commutative83.0%
unpow283.0%
fma-udef83.0%
associate-*r*83.0%
Simplified83.0%
if 980 < im < 1.35000000000000003e154Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 2.7%
Applied egg-rr13.9%
Taylor expanded in re around 0 13.8%
metadata-eval13.8%
pow-flip13.8%
add-cbrt-cube25.2%
pow325.2%
pow-flip25.2%
metadata-eval25.2%
pow-pow25.2%
metadata-eval25.2%
Applied egg-rr25.2%
if 1.35000000000000003e154 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around inf 100.0%
*-commutative100.0%
associate-*r*100.0%
Simplified100.0%
Final simplification78.1%
(FPCore (re im) :precision binary64 (if (<= im 780.0) (sin re) (if (<= im 2.5e+162) (cbrt (pow re -6.0)) (* (fma im im 2.0) (* 0.5 re)))))
double code(double re, double im) {
double tmp;
if (im <= 780.0) {
tmp = sin(re);
} else if (im <= 2.5e+162) {
tmp = cbrt(pow(re, -6.0));
} else {
tmp = fma(im, im, 2.0) * (0.5 * re);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 780.0) tmp = sin(re); elseif (im <= 2.5e+162) tmp = cbrt((re ^ -6.0)); else tmp = Float64(fma(im, im, 2.0) * Float64(0.5 * re)); end return tmp end
code[re_, im_] := If[LessEqual[im, 780.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 2.5e+162], N[Power[N[Power[re, -6.0], $MachinePrecision], 1/3], $MachinePrecision], N[(N[(im * im + 2.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 780:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 2.5 \cdot 10^{+162}:\\
\;\;\;\;\sqrt[3]{{re}^{-6}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re\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%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 66.6%
if 780 < im < 2.4999999999999998e162Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 2.7%
Applied egg-rr13.5%
Taylor expanded in re around 0 13.5%
metadata-eval13.5%
pow-flip13.5%
add-cbrt-cube24.5%
pow324.5%
pow-flip24.5%
metadata-eval24.5%
pow-pow24.5%
metadata-eval24.5%
Applied egg-rr24.5%
if 2.4999999999999998e162 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 75.7%
*-commutative75.7%
*-commutative75.7%
associate-*l*75.7%
+-commutative75.7%
unpow275.7%
fma-udef75.7%
Simplified75.7%
Final simplification62.3%
(FPCore (re im)
:precision binary64
(if (<= im 650.0)
(sin re)
(if (<= im 2.5e+162)
(+ 0.3333333333333333 (pow re -2.0))
(* (fma im im 2.0) (* 0.5 re)))))
double code(double re, double im) {
double tmp;
if (im <= 650.0) {
tmp = sin(re);
} else if (im <= 2.5e+162) {
tmp = 0.3333333333333333 + pow(re, -2.0);
} else {
tmp = fma(im, im, 2.0) * (0.5 * re);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 650.0) tmp = sin(re); elseif (im <= 2.5e+162) tmp = Float64(0.3333333333333333 + (re ^ -2.0)); else tmp = Float64(fma(im, im, 2.0) * Float64(0.5 * re)); end return tmp end
code[re_, im_] := If[LessEqual[im, 650.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 2.5e+162], N[(0.3333333333333333 + N[Power[re, -2.0], $MachinePrecision]), $MachinePrecision], N[(N[(im * im + 2.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 650:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 2.5 \cdot 10^{+162}:\\
\;\;\;\;0.3333333333333333 + {re}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re\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%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 66.6%
if 650 < im < 2.4999999999999998e162Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 2.7%
Applied egg-rr13.5%
Taylor expanded in re around 0 13.5%
+-commutative13.5%
Simplified13.5%
Taylor expanded in re around 0 13.5%
unpow213.5%
associate-/l/13.5%
*-rgt-identity13.5%
associate-*r/13.5%
unpow-113.5%
unpow-113.5%
pow-sqr13.5%
metadata-eval13.5%
Simplified13.5%
if 2.4999999999999998e162 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 75.7%
*-commutative75.7%
*-commutative75.7%
associate-*l*75.7%
+-commutative75.7%
unpow275.7%
fma-udef75.7%
Simplified75.7%
Final simplification60.9%
(FPCore (re im) :precision binary64 (if (<= im 720.0) (sin re) (+ 0.3333333333333333 (pow re -2.0))))
double code(double re, double im) {
double tmp;
if (im <= 720.0) {
tmp = sin(re);
} else {
tmp = 0.3333333333333333 + pow(re, -2.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
tmp = 0.3333333333333333d0 + (re ** (-2.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 {
tmp = 0.3333333333333333 + Math.pow(re, -2.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 720.0: tmp = math.sin(re) else: tmp = 0.3333333333333333 + math.pow(re, -2.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 720.0) tmp = sin(re); else tmp = Float64(0.3333333333333333 + (re ^ -2.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 720.0) tmp = sin(re); else tmp = 0.3333333333333333 + (re ^ -2.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 720.0], N[Sin[re], $MachinePrecision], N[(0.3333333333333333 + N[Power[re, -2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 720:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 + {re}^{-2}\\
\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%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 66.6%
if 720 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 2.7%
Applied egg-rr14.3%
Taylor expanded in re around 0 14.3%
+-commutative14.3%
Simplified14.3%
Taylor expanded in re around 0 14.3%
unpow214.3%
associate-/l/14.3%
*-rgt-identity14.3%
associate-*r/14.3%
unpow-114.3%
unpow-114.3%
pow-sqr14.3%
metadata-eval14.3%
Simplified14.3%
Final simplification52.1%
(FPCore (re im) :precision binary64 (if (<= im 720.0) (sin re) (/ (/ 1.0 re) re)))
double code(double re, double im) {
double tmp;
if (im <= 720.0) {
tmp = sin(re);
} else {
tmp = (1.0 / re) / re;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 720.0d0) then
tmp = sin(re)
else
tmp = (1.0d0 / re) / re
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 {
tmp = (1.0 / re) / re;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 720.0: tmp = math.sin(re) else: tmp = (1.0 / re) / re return tmp
function code(re, im) tmp = 0.0 if (im <= 720.0) tmp = sin(re); else tmp = Float64(Float64(1.0 / re) / re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 720.0) tmp = sin(re); else tmp = (1.0 / re) / re; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 720.0], N[Sin[re], $MachinePrecision], N[(N[(1.0 / re), $MachinePrecision] / re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 720:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{re}}{re}\\
\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%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 66.6%
if 720 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 2.7%
Applied egg-rr14.3%
Taylor expanded in re around 0 14.3%
metadata-eval14.3%
pow-flip14.3%
unpow214.3%
associate-/r*14.3%
Applied egg-rr14.3%
Final simplification52.1%
(FPCore (re im) :precision binary64 (if (<= im 1080.0) re (/ (/ 1.0 re) re)))
double code(double re, double im) {
double tmp;
if (im <= 1080.0) {
tmp = re;
} else {
tmp = (1.0 / re) / re;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1080.0d0) then
tmp = re
else
tmp = (1.0d0 / re) / re
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1080.0) {
tmp = re;
} else {
tmp = (1.0 / re) / re;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1080.0: tmp = re else: tmp = (1.0 / re) / re return tmp
function code(re, im) tmp = 0.0 if (im <= 1080.0) tmp = re; else tmp = Float64(Float64(1.0 / re) / re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1080.0) tmp = re; else tmp = (1.0 / re) / re; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1080.0], re, N[(N[(1.0 / re), $MachinePrecision] / re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1080:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{re}}{re}\\
\end{array}
\end{array}
if im < 1080Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 66.6%
Taylor expanded in re around 0 29.7%
if 1080 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 2.7%
Applied egg-rr14.3%
Taylor expanded in re around 0 14.3%
metadata-eval14.3%
pow-flip14.3%
unpow214.3%
associate-/r*14.3%
Applied egg-rr14.3%
Final simplification25.5%
(FPCore (re im) :precision binary64 (if (<= re 3.55e-10) re 0.3333333333333333))
double code(double re, double im) {
double tmp;
if (re <= 3.55e-10) {
tmp = re;
} else {
tmp = 0.3333333333333333;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 3.55d-10) then
tmp = re
else
tmp = 0.3333333333333333d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 3.55e-10) {
tmp = re;
} else {
tmp = 0.3333333333333333;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 3.55e-10: tmp = re else: tmp = 0.3333333333333333 return tmp
function code(re, im) tmp = 0.0 if (re <= 3.55e-10) tmp = re; else tmp = 0.3333333333333333; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 3.55e-10) tmp = re; else tmp = 0.3333333333333333; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 3.55e-10], re, 0.3333333333333333]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 3.55 \cdot 10^{-10}:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333\\
\end{array}
\end{array}
if re < 3.5500000000000001e-10Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 49.5%
Taylor expanded in re around 0 29.9%
if 3.5500000000000001e-10 < re Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 47.5%
Applied egg-rr7.0%
Taylor expanded in re around 0 6.4%
+-commutative6.4%
Simplified6.4%
Taylor expanded in re around inf 6.4%
Final simplification23.3%
(FPCore (re im) :precision binary64 -0.16666666666666666)
double code(double re, double im) {
return -0.16666666666666666;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -0.16666666666666666d0
end function
public static double code(double re, double im) {
return -0.16666666666666666;
}
def code(re, im): return -0.16666666666666666
function code(re, im) return -0.16666666666666666 end
function tmp = code(re, im) tmp = -0.16666666666666666; end
code[re_, im_] := -0.16666666666666666
\begin{array}{l}
\\
-0.16666666666666666
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 48.9%
Taylor expanded in re around 0 30.3%
Simplified30.3%
Applied egg-rr3.1%
Taylor expanded in re around 0 4.3%
Final simplification4.3%
(FPCore (re im) :precision binary64 0.3333333333333333)
double code(double re, double im) {
return 0.3333333333333333;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.3333333333333333d0
end function
public static double code(double re, double im) {
return 0.3333333333333333;
}
def code(re, im): return 0.3333333333333333
function code(re, im) return 0.3333333333333333 end
function tmp = code(re, im) tmp = 0.3333333333333333; end
code[re_, im_] := 0.3333333333333333
\begin{array}{l}
\\
0.3333333333333333
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 48.9%
Applied egg-rr11.3%
Taylor expanded in re around 0 11.0%
+-commutative11.0%
Simplified11.0%
Taylor expanded in re around inf 4.8%
Final simplification4.8%
herbie shell --seed 2024010
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))