
(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 18 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 (if (or (<= im 0.07) (not (<= im 1.35e+154))) (* (* 0.5 (sin re)) (fma im im 2.0)) (* (* 0.5 re) (+ (exp (- im)) (exp im)))))
double code(double re, double im) {
double tmp;
if ((im <= 0.07) || !(im <= 1.35e+154)) {
tmp = (0.5 * sin(re)) * fma(im, im, 2.0);
} else {
tmp = (0.5 * re) * (exp(-im) + exp(im));
}
return tmp;
}
function code(re, im) tmp = 0.0 if ((im <= 0.07) || !(im <= 1.35e+154)) tmp = Float64(Float64(0.5 * sin(re)) * fma(im, im, 2.0)); else tmp = Float64(Float64(0.5 * re) * Float64(exp(Float64(-im)) + exp(im))); end return tmp end
code[re_, im_] := If[Or[LessEqual[im, 0.07], 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[(0.5 * re), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.07 \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(0.5 \cdot re\right) \cdot \left(e^{-im} + e^{im}\right)\\
\end{array}
\end{array}
if im < 0.070000000000000007 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 87.1%
Simplified87.1%
if 0.070000000000000007 < 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 81.3%
Simplified81.3%
Final simplification86.4%
(FPCore (re im) :precision binary64 (if (or (<= im 580.0) (not (<= im 9.5e+146))) (* (* 0.5 (sin re)) (fma im im 2.0)) (pow (* (sin re) -2.0) -2.0)))
double code(double re, double im) {
double tmp;
if ((im <= 580.0) || !(im <= 9.5e+146)) {
tmp = (0.5 * sin(re)) * fma(im, im, 2.0);
} else {
tmp = pow((sin(re) * -2.0), -2.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if ((im <= 580.0) || !(im <= 9.5e+146)) tmp = Float64(Float64(0.5 * sin(re)) * fma(im, im, 2.0)); else tmp = Float64(sin(re) * -2.0) ^ -2.0; end return tmp end
code[re_, im_] := If[Or[LessEqual[im, 580.0], N[Not[LessEqual[im, 9.5e+146]], $MachinePrecision]], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], N[Power[N[(N[Sin[re], $MachinePrecision] * -2.0), $MachinePrecision], -2.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 580 \lor \neg \left(im \leq 9.5 \cdot 10^{+146}\right):\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(\sin re \cdot -2\right)}^{-2}\\
\end{array}
\end{array}
if im < 580 or 9.49999999999999926e146 < 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 84.8%
Simplified84.8%
if 580 < im < 9.49999999999999926e146Initial 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-rr17.5%
Final simplification78.2%
(FPCore (re im)
:precision binary64
(if (<= im 480.0)
(sin re)
(if (<= im 1.55e+125)
(pow (* (sin re) -2.0) -2.0)
(* re (+ 1.0 (* 0.5 (pow im 2.0)))))))
double code(double re, double im) {
double tmp;
if (im <= 480.0) {
tmp = sin(re);
} else if (im <= 1.55e+125) {
tmp = pow((sin(re) * -2.0), -2.0);
} else {
tmp = re * (1.0 + (0.5 * 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 <= 480.0d0) then
tmp = sin(re)
else if (im <= 1.55d+125) then
tmp = (sin(re) * (-2.0d0)) ** (-2.0d0)
else
tmp = re * (1.0d0 + (0.5d0 * (im ** 2.0d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 480.0) {
tmp = Math.sin(re);
} else if (im <= 1.55e+125) {
tmp = Math.pow((Math.sin(re) * -2.0), -2.0);
} else {
tmp = re * (1.0 + (0.5 * Math.pow(im, 2.0)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 480.0: tmp = math.sin(re) elif im <= 1.55e+125: tmp = math.pow((math.sin(re) * -2.0), -2.0) else: tmp = re * (1.0 + (0.5 * math.pow(im, 2.0))) return tmp
function code(re, im) tmp = 0.0 if (im <= 480.0) tmp = sin(re); elseif (im <= 1.55e+125) tmp = Float64(sin(re) * -2.0) ^ -2.0; else tmp = Float64(re * Float64(1.0 + Float64(0.5 * (im ^ 2.0)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 480.0) tmp = sin(re); elseif (im <= 1.55e+125) tmp = (sin(re) * -2.0) ^ -2.0; else tmp = re * (1.0 + (0.5 * (im ^ 2.0))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 480.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.55e+125], N[Power[N[(N[Sin[re], $MachinePrecision] * -2.0), $MachinePrecision], -2.0], $MachinePrecision], N[(re * N[(1.0 + N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 480:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.55 \cdot 10^{+125}:\\
\;\;\;\;{\left(\sin re \cdot -2\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(1 + 0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 480Initial 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 480 < im < 1.55e125Initial 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-rr19.9%
if 1.55e125 < 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 79.2%
Simplified79.2%
Taylor expanded in re around 0 59.7%
Final simplification61.4%
(FPCore (re im)
:precision binary64
(if (<= im 580.0)
(sin re)
(if (<= im 2.6e+124)
(+ 0.08333333333333333 (/ 0.25 (pow re 2.0)))
(* re (+ 1.0 (* 0.5 (pow im 2.0)))))))
double code(double re, double im) {
double tmp;
if (im <= 580.0) {
tmp = sin(re);
} else if (im <= 2.6e+124) {
tmp = 0.08333333333333333 + (0.25 / pow(re, 2.0));
} else {
tmp = re * (1.0 + (0.5 * 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 <= 580.0d0) then
tmp = sin(re)
else if (im <= 2.6d+124) then
tmp = 0.08333333333333333d0 + (0.25d0 / (re ** 2.0d0))
else
tmp = re * (1.0d0 + (0.5d0 * (im ** 2.0d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 580.0) {
tmp = Math.sin(re);
} else if (im <= 2.6e+124) {
tmp = 0.08333333333333333 + (0.25 / Math.pow(re, 2.0));
} else {
tmp = re * (1.0 + (0.5 * Math.pow(im, 2.0)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 580.0: tmp = math.sin(re) elif im <= 2.6e+124: tmp = 0.08333333333333333 + (0.25 / math.pow(re, 2.0)) else: tmp = re * (1.0 + (0.5 * math.pow(im, 2.0))) return tmp
function code(re, im) tmp = 0.0 if (im <= 580.0) tmp = sin(re); elseif (im <= 2.6e+124) tmp = Float64(0.08333333333333333 + Float64(0.25 / (re ^ 2.0))); else tmp = Float64(re * Float64(1.0 + Float64(0.5 * (im ^ 2.0)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 580.0) tmp = sin(re); elseif (im <= 2.6e+124) tmp = 0.08333333333333333 + (0.25 / (re ^ 2.0)); else tmp = re * (1.0 + (0.5 * (im ^ 2.0))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 580.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 2.6e+124], N[(0.08333333333333333 + N[(0.25 / N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re * N[(1.0 + N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 580:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 2.6 \cdot 10^{+124}:\\
\;\;\;\;0.08333333333333333 + \frac{0.25}{{re}^{2}}\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(1 + 0.5 \cdot {im}^{2}\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 66.6%
if 580 < im < 2.6e124Initial 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-rr19.9%
Taylor expanded in re around 0 19.9%
associate-*r/19.9%
metadata-eval19.9%
Simplified19.9%
if 2.6e124 < 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 79.2%
Simplified79.2%
Taylor expanded in re around 0 59.7%
Final simplification61.4%
(FPCore (re im) :precision binary64 (if (<= im 750.0) (sin re) (if (<= im 7.5e+125) (/ 0.25 (pow re 2.0)) (* re (* 0.5 (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 750.0) {
tmp = sin(re);
} else if (im <= 7.5e+125) {
tmp = 0.25 / pow(re, 2.0);
} else {
tmp = re * (0.5 * 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 <= 750.0d0) then
tmp = sin(re)
else if (im <= 7.5d+125) then
tmp = 0.25d0 / (re ** 2.0d0)
else
tmp = re * (0.5d0 * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 750.0) {
tmp = Math.sin(re);
} else if (im <= 7.5e+125) {
tmp = 0.25 / Math.pow(re, 2.0);
} else {
tmp = re * (0.5 * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 750.0: tmp = math.sin(re) elif im <= 7.5e+125: tmp = 0.25 / math.pow(re, 2.0) else: tmp = re * (0.5 * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 750.0) tmp = sin(re); elseif (im <= 7.5e+125) tmp = Float64(0.25 / (re ^ 2.0)); else tmp = Float64(re * Float64(0.5 * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 750.0) tmp = sin(re); elseif (im <= 7.5e+125) tmp = 0.25 / (re ^ 2.0); else tmp = re * (0.5 * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 750.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 7.5e+125], N[(0.25 / N[Power[re, 2.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 750:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 7.5 \cdot 10^{+125}:\\
\;\;\;\;\frac{0.25}{{re}^{2}}\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 750Initial 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 750 < im < 7.5000000000000006e125Initial 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-rr19.9%
Taylor expanded in re around 0 19.7%
if 7.5000000000000006e125 < 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 79.2%
Simplified79.2%
Taylor expanded in re around 0 59.7%
Taylor expanded in im around inf 59.7%
associate-*r*59.7%
*-commutative59.7%
Simplified59.7%
Final simplification61.4%
(FPCore (re im)
:precision binary64
(if (<= im 600.0)
(sin re)
(if (<= im 8.5e+126)
(+ 0.08333333333333333 (/ 0.25 (pow re 2.0)))
(* re (* 0.5 (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 600.0) {
tmp = sin(re);
} else if (im <= 8.5e+126) {
tmp = 0.08333333333333333 + (0.25 / pow(re, 2.0));
} else {
tmp = re * (0.5 * 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 <= 600.0d0) then
tmp = sin(re)
else if (im <= 8.5d+126) then
tmp = 0.08333333333333333d0 + (0.25d0 / (re ** 2.0d0))
else
tmp = re * (0.5d0 * (im ** 2.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 if (im <= 8.5e+126) {
tmp = 0.08333333333333333 + (0.25 / Math.pow(re, 2.0));
} else {
tmp = re * (0.5 * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 600.0: tmp = math.sin(re) elif im <= 8.5e+126: tmp = 0.08333333333333333 + (0.25 / math.pow(re, 2.0)) else: tmp = re * (0.5 * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 600.0) tmp = sin(re); elseif (im <= 8.5e+126) tmp = Float64(0.08333333333333333 + Float64(0.25 / (re ^ 2.0))); else tmp = Float64(re * Float64(0.5 * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 600.0) tmp = sin(re); elseif (im <= 8.5e+126) tmp = 0.08333333333333333 + (0.25 / (re ^ 2.0)); else tmp = re * (0.5 * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 600.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 8.5e+126], N[(0.08333333333333333 + N[(0.25 / N[Power[re, 2.0], $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 600:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 8.5 \cdot 10^{+126}:\\
\;\;\;\;0.08333333333333333 + \frac{0.25}{{re}^{2}}\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\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 66.6%
if 600 < im < 8.49999999999999944e126Initial 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-rr19.9%
Taylor expanded in re around 0 19.9%
associate-*r/19.9%
metadata-eval19.9%
Simplified19.9%
if 8.49999999999999944e126 < 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 79.2%
Simplified79.2%
Taylor expanded in re around 0 59.7%
Taylor expanded in im around inf 59.7%
associate-*r*59.7%
*-commutative59.7%
Simplified59.7%
Final simplification61.4%
(FPCore (re im) :precision binary64 (if (<= im 580.0) (sin re) (/ 0.25 (pow re 2.0))))
double code(double re, double im) {
double tmp;
if (im <= 580.0) {
tmp = sin(re);
} else {
tmp = 0.25 / 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 <= 580.0d0) then
tmp = sin(re)
else
tmp = 0.25d0 / (re ** 2.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 580.0) {
tmp = Math.sin(re);
} else {
tmp = 0.25 / Math.pow(re, 2.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 580.0: tmp = math.sin(re) else: tmp = 0.25 / math.pow(re, 2.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 580.0) tmp = sin(re); else tmp = Float64(0.25 / (re ^ 2.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 580.0) tmp = sin(re); else tmp = 0.25 / (re ^ 2.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 580.0], N[Sin[re], $MachinePrecision], N[(0.25 / N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 580:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{{re}^{2}}\\
\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 66.6%
if 580 < 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-rr13.9%
Taylor expanded in re around 0 13.8%
Final simplification53.0%
(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%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 50.1%
Final simplification50.1%
(FPCore (re im) :precision binary64 -2.0)
double code(double re, double im) {
return -2.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -2.0d0
end function
public static double code(double re, double im) {
return -2.0;
}
def code(re, im): return -2.0
function code(re, im) return -2.0 end
function tmp = code(re, im) tmp = -2.0; end
code[re_, im_] := -2.0
\begin{array}{l}
\\
-2
\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 re around 0 68.4%
Simplified68.4%
Applied egg-rr4.1%
Final simplification4.1%
(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%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 68.4%
Simplified68.4%
Applied egg-rr4.6%
Final simplification4.6%
(FPCore (re im) :precision binary64 0.0625)
double code(double re, double im) {
return 0.0625;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.0625d0
end function
public static double code(double re, double im) {
return 0.0625;
}
def code(re, im): return 0.0625
function code(re, im) return 0.0625 end
function tmp = code(re, im) tmp = 0.0625; end
code[re_, im_] := 0.0625
\begin{array}{l}
\\
0.0625
\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 re around 0 68.4%
Simplified68.4%
Applied egg-rr3.8%
Final simplification3.8%
(FPCore (re im) :precision binary64 0.125)
double code(double re, double im) {
return 0.125;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.125d0
end function
public static double code(double re, double im) {
return 0.125;
}
def code(re, im): return 0.125
function code(re, im) return 0.125 end
function tmp = code(re, im) tmp = 0.125; end
code[re_, im_] := 0.125
\begin{array}{l}
\\
0.125
\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 re around 0 68.4%
Simplified68.4%
Applied egg-rr3.9%
Final simplification3.9%
(FPCore (re im) :precision binary64 0.25)
double code(double re, double im) {
return 0.25;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.25d0
end function
public static double code(double re, double im) {
return 0.25;
}
def code(re, im): return 0.25
function code(re, im) return 0.25 end
function tmp = code(re, im) tmp = 0.25; end
code[re_, im_] := 0.25
\begin{array}{l}
\\
0.25
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 68.4%
Simplified68.4%
Applied egg-rr4.0%
Final simplification4.0%
(FPCore (re im) :precision binary64 0.5)
double code(double re, double im) {
return 0.5;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.5d0
end function
public static double code(double re, double im) {
return 0.5;
}
def code(re, im): return 0.5
function code(re, im) return 0.5 end
function tmp = code(re, im) tmp = 0.5; end
code[re_, im_] := 0.5
\begin{array}{l}
\\
0.5
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 68.4%
Simplified68.4%
Applied egg-rr4.1%
Final simplification4.1%
(FPCore (re im) :precision binary64 0.75)
double code(double re, double im) {
return 0.75;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.75d0
end function
public static double code(double re, double im) {
return 0.75;
}
def code(re, im): return 0.75
function code(re, im) return 0.75 end
function tmp = code(re, im) tmp = 0.75; end
code[re_, im_] := 0.75
\begin{array}{l}
\\
0.75
\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 re around 0 68.4%
Simplified68.4%
Applied egg-rr4.1%
Final simplification4.1%
(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%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 68.4%
Simplified68.4%
Applied egg-rr4.2%
Final simplification4.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%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 68.4%
Simplified68.4%
Taylor expanded in im around 0 31.0%
Final simplification31.0%
herbie shell --seed 2024027
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))