
(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%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* 0.5 (sin re)) (fma im im 2.0))))
(if (<= im 5800.0)
t_0
(if (<= im 5e+115)
(log1p (expm1 re))
(if (<= im 1.9e+135)
(pow re -2.0)
(if (<= im 8e+148) (* (fma im im 2.0) (* 0.5 re)) t_0))))))
double code(double re, double im) {
double t_0 = (0.5 * sin(re)) * fma(im, im, 2.0);
double tmp;
if (im <= 5800.0) {
tmp = t_0;
} else if (im <= 5e+115) {
tmp = log1p(expm1(re));
} else if (im <= 1.9e+135) {
tmp = pow(re, -2.0);
} else if (im <= 8e+148) {
tmp = fma(im, im, 2.0) * (0.5 * re);
} else {
tmp = t_0;
}
return tmp;
}
function code(re, im) t_0 = Float64(Float64(0.5 * sin(re)) * fma(im, im, 2.0)) tmp = 0.0 if (im <= 5800.0) tmp = t_0; elseif (im <= 5e+115) tmp = log1p(expm1(re)); elseif (im <= 1.9e+135) tmp = re ^ -2.0; elseif (im <= 8e+148) tmp = Float64(fma(im, im, 2.0) * Float64(0.5 * re)); else tmp = t_0; end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 5800.0], t$95$0, If[LessEqual[im, 5e+115], N[Log[1 + N[(Exp[re] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 1.9e+135], N[Power[re, -2.0], $MachinePrecision], If[LessEqual[im, 8e+148], N[(N[(im * im + 2.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{if}\;im \leq 5800:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 5 \cdot 10^{+115}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\
\mathbf{elif}\;im \leq 1.9 \cdot 10^{+135}:\\
\;\;\;\;{re}^{-2}\\
\mathbf{elif}\;im \leq 8 \cdot 10^{+148}:\\
\;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < 5800 or 8.0000000000000004e148 < 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 80.4%
Simplified80.4%
if 5800 < im < 5.00000000000000008e115Initial 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%
Applied egg-rr10.0%
Taylor expanded in re around 0 9.8%
Applied egg-rr42.5%
if 5.00000000000000008e115 < im < 1.9000000000000001e135Initial 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%
Applied egg-rr18.5%
Taylor expanded in re around 0 18.1%
Applied egg-rr18.1%
if 1.9000000000000001e135 < im < 8.0000000000000004e148Initial 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 8.2%
Simplified8.2%
Taylor expanded in re around 0 0.0%
*-commutative0.0%
*-commutative0.0%
associate-*l*0.0%
+-commutative0.0%
unpow20.0%
fma-udef0.0%
Simplified0.0%
Final simplification75.1%
(FPCore (re im) :precision binary64 (if (or (<= im 0.0135) (not (<= im 1.35e+154))) (* (* 0.5 (sin re)) (fma im im 2.0)) (* (+ (exp (- im)) (exp im)) (* 0.5 re))))
double code(double re, double im) {
double tmp;
if ((im <= 0.0135) || !(im <= 1.35e+154)) {
tmp = (0.5 * sin(re)) * fma(im, im, 2.0);
} else {
tmp = (exp(-im) + exp(im)) * (0.5 * re);
}
return tmp;
}
function code(re, im) tmp = 0.0 if ((im <= 0.0135) || !(im <= 1.35e+154)) tmp = Float64(Float64(0.5 * sin(re)) * fma(im, im, 2.0)); else tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 * re)); end return tmp end
code[re_, im_] := If[Or[LessEqual[im, 0.0135], N[Not[LessEqual[im, 1.35e+154]], $MachinePrecision]], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.0135 \lor \neg \left(im \leq 1.35 \cdot 10^{+154}\right):\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{else}:\\
\;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
\end{array}
\end{array}
if im < 0.0134999999999999998 or 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 82.7%
Simplified82.7%
if 0.0134999999999999998 < 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 73.7%
Simplified73.7%
Final simplification81.4%
(FPCore (re im) :precision binary64 (if (<= im 580.0) (sin re) (if (<= im 1.18e+107) (log1p (expm1 re)) (* (fma im im 2.0) (* 0.5 re)))))
double code(double re, double im) {
double tmp;
if (im <= 580.0) {
tmp = sin(re);
} else if (im <= 1.18e+107) {
tmp = log1p(expm1(re));
} else {
tmp = fma(im, im, 2.0) * (0.5 * re);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 580.0) tmp = sin(re); elseif (im <= 1.18e+107) tmp = log1p(expm1(re)); else tmp = Float64(fma(im, im, 2.0) * Float64(0.5 * re)); end return tmp end
code[re_, im_] := If[LessEqual[im, 580.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.18e+107], N[Log[1 + N[(Exp[re] - 1), $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 580:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.18 \cdot 10^{+107}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re\right)\\
\end{array}
\end{array}
if im < 580Initial 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 64.1%
if 580 < im < 1.18000000000000005e107Initial 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%
Applied egg-rr10.0%
Taylor expanded in re around 0 9.7%
Applied egg-rr38.4%
if 1.18000000000000005e107 < 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 74.7%
Simplified74.7%
Taylor expanded in re around 0 64.1%
*-commutative64.1%
*-commutative64.1%
associate-*l*64.1%
+-commutative64.1%
unpow264.1%
fma-udef64.1%
Simplified64.1%
Final simplification61.7%
(FPCore (re im)
:precision binary64
(if (<= im 760.0)
(sin re)
(if (or (<= im 6.8e+89)
(and (not (<= im 7.5e+115))
(or (<= im 2.3e+163) (not (<= im 3.8e+206)))))
(pow re -2.0)
(* (+ re -0.020833333333333332) (+ re -0.020833333333333332)))))
double code(double re, double im) {
double tmp;
if (im <= 760.0) {
tmp = sin(re);
} else if ((im <= 6.8e+89) || (!(im <= 7.5e+115) && ((im <= 2.3e+163) || !(im <= 3.8e+206)))) {
tmp = pow(re, -2.0);
} else {
tmp = (re + -0.020833333333333332) * (re + -0.020833333333333332);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 760.0d0) then
tmp = sin(re)
else if ((im <= 6.8d+89) .or. (.not. (im <= 7.5d+115)) .and. (im <= 2.3d+163) .or. (.not. (im <= 3.8d+206))) then
tmp = re ** (-2.0d0)
else
tmp = (re + (-0.020833333333333332d0)) * (re + (-0.020833333333333332d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 760.0) {
tmp = Math.sin(re);
} else if ((im <= 6.8e+89) || (!(im <= 7.5e+115) && ((im <= 2.3e+163) || !(im <= 3.8e+206)))) {
tmp = Math.pow(re, -2.0);
} else {
tmp = (re + -0.020833333333333332) * (re + -0.020833333333333332);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 760.0: tmp = math.sin(re) elif (im <= 6.8e+89) or (not (im <= 7.5e+115) and ((im <= 2.3e+163) or not (im <= 3.8e+206))): tmp = math.pow(re, -2.0) else: tmp = (re + -0.020833333333333332) * (re + -0.020833333333333332) return tmp
function code(re, im) tmp = 0.0 if (im <= 760.0) tmp = sin(re); elseif ((im <= 6.8e+89) || (!(im <= 7.5e+115) && ((im <= 2.3e+163) || !(im <= 3.8e+206)))) tmp = re ^ -2.0; else tmp = Float64(Float64(re + -0.020833333333333332) * Float64(re + -0.020833333333333332)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 760.0) tmp = sin(re); elseif ((im <= 6.8e+89) || (~((im <= 7.5e+115)) && ((im <= 2.3e+163) || ~((im <= 3.8e+206))))) tmp = re ^ -2.0; else tmp = (re + -0.020833333333333332) * (re + -0.020833333333333332); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 760.0], N[Sin[re], $MachinePrecision], If[Or[LessEqual[im, 6.8e+89], And[N[Not[LessEqual[im, 7.5e+115]], $MachinePrecision], Or[LessEqual[im, 2.3e+163], N[Not[LessEqual[im, 3.8e+206]], $MachinePrecision]]]], N[Power[re, -2.0], $MachinePrecision], N[(N[(re + -0.020833333333333332), $MachinePrecision] * N[(re + -0.020833333333333332), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 760:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 6.8 \cdot 10^{+89} \lor \neg \left(im \leq 7.5 \cdot 10^{+115}\right) \land \left(im \leq 2.3 \cdot 10^{+163} \lor \neg \left(im \leq 3.8 \cdot 10^{+206}\right)\right):\\
\;\;\;\;{re}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\left(re + -0.020833333333333332\right) \cdot \left(re + -0.020833333333333332\right)\\
\end{array}
\end{array}
if im < 760Initial 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 64.1%
if 760 < im < 6.8000000000000004e89 or 7.4999999999999997e115 < im < 2.30000000000000002e163 or 3.7999999999999999e206 < 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%
Applied egg-rr15.7%
Taylor expanded in re around 0 15.6%
Applied egg-rr15.6%
if 6.8000000000000004e89 < im < 7.4999999999999997e115 or 2.30000000000000002e163 < im < 3.7999999999999999e206Initial 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%
Applied egg-rr2.0%
Taylor expanded in re around 0 2.0%
associate-*r/2.0%
metadata-eval2.0%
Simplified2.0%
Applied egg-rr28.0%
+-commutative28.0%
+-commutative28.0%
Simplified28.0%
Final simplification52.5%
(FPCore (re im)
:precision binary64
(if (<= im 600.0)
(sin re)
(if (<= im 6.5e+82)
(+ 0.08333333333333333 (/ 0.25 (pow re 2.0)))
(* (fma im im 2.0) (* 0.5 re)))))
double code(double re, double im) {
double tmp;
if (im <= 600.0) {
tmp = sin(re);
} else if (im <= 6.5e+82) {
tmp = 0.08333333333333333 + (0.25 / 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 <= 600.0) tmp = sin(re); elseif (im <= 6.5e+82) tmp = Float64(0.08333333333333333 + Float64(0.25 / (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, 600.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 6.5e+82], N[(0.08333333333333333 + N[(0.25 / N[Power[re, 2.0], $MachinePrecision]), $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 600:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 6.5 \cdot 10^{+82}:\\
\;\;\;\;0.08333333333333333 + \frac{0.25}{{re}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re\right)\\
\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%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 64.1%
if 600 < im < 6.5000000000000003e82Initial 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%
Applied egg-rr11.4%
Taylor expanded in re around 0 11.4%
associate-*r/11.4%
metadata-eval11.4%
Simplified11.4%
if 6.5000000000000003e82 < 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 68.5%
Simplified68.5%
Taylor expanded in re around 0 60.8%
*-commutative60.8%
*-commutative60.8%
associate-*l*60.8%
+-commutative60.8%
unpow260.8%
fma-udef60.8%
Simplified60.8%
Final simplification59.4%
(FPCore (re im) :precision binary64 (if (<= im 980.0) (sin re) (if (<= im 1.35e+81) (pow re -2.0) (* (* 0.5 re) (pow im 2.0)))))
double code(double re, double im) {
double tmp;
if (im <= 980.0) {
tmp = sin(re);
} else if (im <= 1.35e+81) {
tmp = pow(re, -2.0);
} else {
tmp = (0.5 * re) * pow(im, 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 <= 980.0d0) then
tmp = sin(re)
else if (im <= 1.35d+81) then
tmp = re ** (-2.0d0)
else
tmp = (0.5d0 * re) * (im ** 2.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 980.0) {
tmp = Math.sin(re);
} else if (im <= 1.35e+81) {
tmp = Math.pow(re, -2.0);
} else {
tmp = (0.5 * re) * Math.pow(im, 2.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 980.0: tmp = math.sin(re) elif im <= 1.35e+81: tmp = math.pow(re, -2.0) else: tmp = (0.5 * re) * math.pow(im, 2.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 980.0) tmp = sin(re); elseif (im <= 1.35e+81) tmp = re ^ -2.0; else tmp = Float64(Float64(0.5 * re) * (im ^ 2.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 980.0) tmp = sin(re); elseif (im <= 1.35e+81) tmp = re ^ -2.0; else tmp = (0.5 * re) * (im ^ 2.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 980.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.35e+81], N[Power[re, -2.0], $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 980:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+81}:\\
\;\;\;\;{re}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot {im}^{2}\\
\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 64.1%
if 980 < im < 1.35e81Initial 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%
Applied egg-rr11.4%
Taylor expanded in re around 0 11.2%
Applied egg-rr11.2%
if 1.35e81 < 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 68.5%
Simplified68.5%
Taylor expanded in re around 0 60.8%
*-commutative60.8%
*-commutative60.8%
associate-*l*60.8%
+-commutative60.8%
unpow260.8%
fma-udef60.8%
Simplified60.8%
Taylor expanded in im around 0 60.8%
Taylor expanded in im around inf 60.8%
*-commutative60.8%
associate-*r*60.8%
Simplified60.8%
Final simplification59.4%
(FPCore (re im)
:precision binary64
(if (<= im 550.0)
(sin re)
(if (<= im 8.2e+82)
(+ 0.08333333333333333 (/ 0.25 (pow re 2.0)))
(* (* 0.5 re) (pow im 2.0)))))
double code(double re, double im) {
double tmp;
if (im <= 550.0) {
tmp = sin(re);
} else if (im <= 8.2e+82) {
tmp = 0.08333333333333333 + (0.25 / pow(re, 2.0));
} else {
tmp = (0.5 * re) * pow(im, 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 <= 550.0d0) then
tmp = sin(re)
else if (im <= 8.2d+82) then
tmp = 0.08333333333333333d0 + (0.25d0 / (re ** 2.0d0))
else
tmp = (0.5d0 * re) * (im ** 2.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 550.0) {
tmp = Math.sin(re);
} else if (im <= 8.2e+82) {
tmp = 0.08333333333333333 + (0.25 / Math.pow(re, 2.0));
} else {
tmp = (0.5 * re) * Math.pow(im, 2.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 550.0: tmp = math.sin(re) elif im <= 8.2e+82: tmp = 0.08333333333333333 + (0.25 / math.pow(re, 2.0)) else: tmp = (0.5 * re) * math.pow(im, 2.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 550.0) tmp = sin(re); elseif (im <= 8.2e+82) tmp = Float64(0.08333333333333333 + Float64(0.25 / (re ^ 2.0))); else tmp = Float64(Float64(0.5 * re) * (im ^ 2.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 550.0) tmp = sin(re); elseif (im <= 8.2e+82) tmp = 0.08333333333333333 + (0.25 / (re ^ 2.0)); else tmp = (0.5 * re) * (im ^ 2.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 550.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 8.2e+82], N[(0.08333333333333333 + N[(0.25 / N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 550:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 8.2 \cdot 10^{+82}:\\
\;\;\;\;0.08333333333333333 + \frac{0.25}{{re}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot {im}^{2}\\
\end{array}
\end{array}
if im < 550Initial 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 64.1%
if 550 < im < 8.1999999999999999e82Initial 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%
Applied egg-rr11.4%
Taylor expanded in re around 0 11.4%
associate-*r/11.4%
metadata-eval11.4%
Simplified11.4%
if 8.1999999999999999e82 < 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 68.5%
Simplified68.5%
Taylor expanded in re around 0 60.8%
*-commutative60.8%
*-commutative60.8%
associate-*l*60.8%
+-commutative60.8%
unpow260.8%
fma-udef60.8%
Simplified60.8%
Taylor expanded in im around 0 60.8%
Taylor expanded in im around inf 60.8%
*-commutative60.8%
associate-*r*60.8%
Simplified60.8%
Final simplification59.4%
(FPCore (re im) :precision binary64 (if (<= im 240.0) (sin re) (* (+ re -0.020833333333333332) (+ re -0.020833333333333332))))
double code(double re, double im) {
double tmp;
if (im <= 240.0) {
tmp = sin(re);
} else {
tmp = (re + -0.020833333333333332) * (re + -0.020833333333333332);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 240.0d0) then
tmp = sin(re)
else
tmp = (re + (-0.020833333333333332d0)) * (re + (-0.020833333333333332d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 240.0) {
tmp = Math.sin(re);
} else {
tmp = (re + -0.020833333333333332) * (re + -0.020833333333333332);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 240.0: tmp = math.sin(re) else: tmp = (re + -0.020833333333333332) * (re + -0.020833333333333332) return tmp
function code(re, im) tmp = 0.0 if (im <= 240.0) tmp = sin(re); else tmp = Float64(Float64(re + -0.020833333333333332) * Float64(re + -0.020833333333333332)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 240.0) tmp = sin(re); else tmp = (re + -0.020833333333333332) * (re + -0.020833333333333332); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 240.0], N[Sin[re], $MachinePrecision], N[(N[(re + -0.020833333333333332), $MachinePrecision] * N[(re + -0.020833333333333332), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 240:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;\left(re + -0.020833333333333332\right) \cdot \left(re + -0.020833333333333332\right)\\
\end{array}
\end{array}
if im < 240Initial 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 64.1%
if 240 < 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%
Applied egg-rr12.5%
Taylor expanded in re around 0 12.5%
associate-*r/12.5%
metadata-eval12.5%
Simplified12.5%
Applied egg-rr14.1%
+-commutative14.1%
+-commutative14.1%
Simplified14.1%
Final simplification51.4%
(FPCore (re im) :precision binary64 (if (<= im 260.0) re (* (+ re -0.020833333333333332) (+ re -0.020833333333333332))))
double code(double re, double im) {
double tmp;
if (im <= 260.0) {
tmp = re;
} else {
tmp = (re + -0.020833333333333332) * (re + -0.020833333333333332);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 260.0d0) then
tmp = re
else
tmp = (re + (-0.020833333333333332d0)) * (re + (-0.020833333333333332d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 260.0) {
tmp = re;
} else {
tmp = (re + -0.020833333333333332) * (re + -0.020833333333333332);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 260.0: tmp = re else: tmp = (re + -0.020833333333333332) * (re + -0.020833333333333332) return tmp
function code(re, im) tmp = 0.0 if (im <= 260.0) tmp = re; else tmp = Float64(Float64(re + -0.020833333333333332) * Float64(re + -0.020833333333333332)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 260.0) tmp = re; else tmp = (re + -0.020833333333333332) * (re + -0.020833333333333332); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 260.0], re, N[(N[(re + -0.020833333333333332), $MachinePrecision] * N[(re + -0.020833333333333332), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 260:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;\left(re + -0.020833333333333332\right) \cdot \left(re + -0.020833333333333332\right)\\
\end{array}
\end{array}
if im < 260Initial 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 78.9%
Simplified78.9%
Taylor expanded in re around 0 50.0%
*-commutative50.0%
*-commutative50.0%
associate-*l*50.0%
+-commutative50.0%
unpow250.0%
fma-udef50.0%
Simplified50.0%
Taylor expanded in im around 0 35.0%
if 260 < 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%
Applied egg-rr12.5%
Taylor expanded in re around 0 12.5%
associate-*r/12.5%
metadata-eval12.5%
Simplified12.5%
Applied egg-rr14.1%
+-commutative14.1%
+-commutative14.1%
Simplified14.1%
Final simplification29.7%
(FPCore (re im) :precision binary64 (if (<= im 6200.0) re (* re re)))
double code(double re, double im) {
double tmp;
if (im <= 6200.0) {
tmp = re;
} else {
tmp = 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 <= 6200.0d0) then
tmp = re
else
tmp = re * re
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 6200.0) {
tmp = re;
} else {
tmp = re * re;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 6200.0: tmp = re else: tmp = re * re return tmp
function code(re, im) tmp = 0.0 if (im <= 6200.0) tmp = re; else tmp = Float64(re * re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 6200.0) tmp = re; else tmp = re * re; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 6200.0], re, N[(re * re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 6200:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;re \cdot re\\
\end{array}
\end{array}
if im < 6200Initial 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 78.5%
Simplified78.5%
Taylor expanded in re around 0 49.8%
*-commutative49.8%
*-commutative49.8%
associate-*l*49.8%
+-commutative49.8%
unpow249.8%
fma-udef49.8%
Simplified49.8%
Taylor expanded in im around 0 34.8%
if 6200 < 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%
Applied egg-rr12.7%
Taylor expanded in re around 0 12.5%
Applied egg-rr14.1%
Final simplification29.7%
(FPCore (re im) :precision binary64 0.08333333333333333)
double code(double re, double im) {
return 0.08333333333333333;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.08333333333333333d0
end function
public static double code(double re, double im) {
return 0.08333333333333333;
}
def code(re, im): return 0.08333333333333333
function code(re, im) return 0.08333333333333333 end
function tmp = code(re, im) tmp = 0.08333333333333333; end
code[re_, im_] := 0.08333333333333333
\begin{array}{l}
\\
0.08333333333333333
\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%
Applied egg-rr8.2%
Taylor expanded in re around 0 8.1%
associate-*r/8.1%
metadata-eval8.1%
Simplified8.1%
Taylor expanded in re around inf 3.5%
Final simplification3.5%
(FPCore (re im) :precision binary64 0.9795918367346939)
double code(double re, double im) {
return 0.9795918367346939;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.9795918367346939d0
end function
public static double code(double re, double im) {
return 0.9795918367346939;
}
def code(re, im): return 0.9795918367346939
function code(re, im) return 0.9795918367346939 end
function tmp = code(re, im) tmp = 0.9795918367346939; end
code[re_, im_] := 0.9795918367346939
\begin{array}{l}
\\
0.9795918367346939
\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%
Applied egg-rr8.2%
Taylor expanded in re around 0 8.1%
associate-*r/8.1%
metadata-eval8.1%
Simplified8.1%
Applied egg-rr3.8%
+-commutative3.8%
associate-+l-3.8%
*-lft-identity3.8%
distribute-rgt-out--3.8%
metadata-eval3.8%
Simplified3.8%
Taylor expanded in re around inf 3.8%
Final simplification3.8%
(FPCore (re im) :precision binary64 re)
double code(double re, double im) {
return re;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re
end function
public static double code(double re, double im) {
return re;
}
def code(re, im): return re
function code(re, im) return re end
function tmp = code(re, im) tmp = re; end
code[re_, im_] := re
\begin{array}{l}
\\
re
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 71.2%
Simplified71.2%
Taylor expanded in re around 0 48.6%
*-commutative48.6%
*-commutative48.6%
associate-*l*48.6%
+-commutative48.6%
unpow248.6%
fma-udef48.6%
Simplified48.6%
Taylor expanded in im around 0 26.8%
Final simplification26.8%
herbie shell --seed 2023322
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))