
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * sin(re)) * (exp((0.0d0 - im)) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp((0.0 - im)) + Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp((0.0 - im)) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(0.0 - im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * sin(re)) * (exp((0.0d0 - im)) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp((0.0 - im)) + Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp((0.0 - im)) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(0.0 - im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)
\end{array}
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (+ (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp(-im) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * sin(re)) * (exp(-im) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp(-im) + Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp(-im) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp(-im) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right)
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (re im) :precision binary64 (if (or (<= im 0.115) (not (<= im 1.15e+146))) (* (* 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.115) || !(im <= 1.15e+146)) {
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.115) || !(im <= 1.15e+146)) 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.115], N[Not[LessEqual[im, 1.15e+146]], $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.115 \lor \neg \left(im \leq 1.15 \cdot 10^{+146}\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.115000000000000005 or 1.15e146 < 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 88.4%
Simplified88.4%
if 0.115000000000000005 < im < 1.15e146Initial 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 65.6%
Simplified65.6%
Final simplification85.6%
(FPCore (re im) :precision binary64 (if (or (<= im 700.0) (not (<= im 1.35e+154))) (* (* 0.5 (sin re)) (fma im im 2.0)) (log (/ -2.0 (exp re)))))
double code(double re, double im) {
double tmp;
if ((im <= 700.0) || !(im <= 1.35e+154)) {
tmp = (0.5 * sin(re)) * fma(im, im, 2.0);
} else {
tmp = log((-2.0 / exp(re)));
}
return tmp;
}
function code(re, im) tmp = 0.0 if ((im <= 700.0) || !(im <= 1.35e+154)) tmp = Float64(Float64(0.5 * sin(re)) * fma(im, im, 2.0)); else tmp = log(Float64(-2.0 / exp(re))); end return tmp end
code[re_, im_] := If[Or[LessEqual[im, 700.0], 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[Log[N[(-2.0 / N[Exp[re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 700 \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}:\\
\;\;\;\;\log \left(\frac{-2}{e^{re}}\right)\\
\end{array}
\end{array}
if im < 700 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 88.8%
Simplified88.8%
if 700 < 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%
Applied egg-rr13.6%
Taylor expanded in re around 0 13.5%
Applied egg-rr15.2%
Final simplification79.3%
(FPCore (re im) :precision binary64 (if (<= im 720.0) (sin re) (if (<= im 2e+119) (log (/ -2.0 (exp re))) (* re (* 0.5 (fma im im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 720.0) {
tmp = sin(re);
} else if (im <= 2e+119) {
tmp = log((-2.0 / exp(re)));
} else {
tmp = re * (0.5 * fma(im, im, 2.0));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 720.0) tmp = sin(re); elseif (im <= 2e+119) tmp = log(Float64(-2.0 / exp(re))); else tmp = Float64(re * Float64(0.5 * fma(im, im, 2.0))); end return tmp end
code[re_, im_] := If[LessEqual[im, 720.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 2e+119], N[Log[N[(-2.0 / N[Exp[re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(re * N[(0.5 * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 720:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 2 \cdot 10^{+119}:\\
\;\;\;\;\log \left(\frac{-2}{e^{re}}\right)\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot \mathsf{fma}\left(im, im, 2\right)\right)\\
\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 70.2%
if 720 < im < 1.99999999999999989e119Initial 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.9%
Taylor expanded in re around 0 12.8%
Applied egg-rr19.2%
if 1.99999999999999989e119 < 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 86.0%
Simplified86.0%
Taylor expanded in re around 0 64.3%
*-commutative64.3%
associate-*r*64.3%
+-commutative64.3%
unpow264.3%
fma-udef64.3%
Simplified64.3%
Final simplification64.0%
(FPCore (re im) :precision binary64 (if (<= im 12400000.0) (sin re) (if (<= im 2e+119) (pow re -2.0) (* re (* 0.5 (fma im im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 12400000.0) {
tmp = sin(re);
} else if (im <= 2e+119) {
tmp = pow(re, -2.0);
} else {
tmp = re * (0.5 * fma(im, im, 2.0));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 12400000.0) tmp = sin(re); elseif (im <= 2e+119) tmp = re ^ -2.0; else tmp = Float64(re * Float64(0.5 * fma(im, im, 2.0))); end return tmp end
code[re_, im_] := If[LessEqual[im, 12400000.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 2e+119], N[Power[re, -2.0], $MachinePrecision], N[(re * N[(0.5 * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 12400000:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 2 \cdot 10^{+119}:\\
\;\;\;\;{re}^{-2}\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot \mathsf{fma}\left(im, im, 2\right)\right)\\
\end{array}
\end{array}
if im < 1.24e7Initial 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 69.9%
if 1.24e7 < im < 1.99999999999999989e119Initial 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.4%
Taylor expanded in re around 0 13.3%
Applied egg-rr13.3%
if 1.99999999999999989e119 < 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 86.0%
Simplified86.0%
Taylor expanded in re around 0 64.3%
*-commutative64.3%
associate-*r*64.3%
+-commutative64.3%
unpow264.3%
fma-udef64.3%
Simplified64.3%
Final simplification63.3%
(FPCore (re im) :precision binary64 (if (<= im 12400000.0) (sin re) (+ (pow re -2.0) 0.08333333333333333)))
double code(double re, double im) {
double tmp;
if (im <= 12400000.0) {
tmp = sin(re);
} else {
tmp = pow(re, -2.0) + 0.08333333333333333;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 12400000.0d0) then
tmp = sin(re)
else
tmp = (re ** (-2.0d0)) + 0.08333333333333333d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 12400000.0) {
tmp = Math.sin(re);
} else {
tmp = Math.pow(re, -2.0) + 0.08333333333333333;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 12400000.0: tmp = math.sin(re) else: tmp = math.pow(re, -2.0) + 0.08333333333333333 return tmp
function code(re, im) tmp = 0.0 if (im <= 12400000.0) tmp = sin(re); else tmp = Float64((re ^ -2.0) + 0.08333333333333333); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 12400000.0) tmp = sin(re); else tmp = (re ^ -2.0) + 0.08333333333333333; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 12400000.0], N[Sin[re], $MachinePrecision], N[(N[Power[re, -2.0], $MachinePrecision] + 0.08333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 12400000:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;{re}^{-2} + 0.08333333333333333\\
\end{array}
\end{array}
if im < 1.24e7Initial 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 69.9%
if 1.24e7 < 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.4%
Taylor expanded in re around 0 15.4%
associate-*r/15.4%
metadata-eval15.4%
Simplified15.4%
Applied egg-rr15.4%
Final simplification54.6%
(FPCore (re im) :precision binary64 (if (<= im 12400000.0) (sin re) (pow re -2.0)))
double code(double re, double im) {
double tmp;
if (im <= 12400000.0) {
tmp = sin(re);
} else {
tmp = 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 <= 12400000.0d0) then
tmp = sin(re)
else
tmp = re ** (-2.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 12400000.0) {
tmp = Math.sin(re);
} else {
tmp = Math.pow(re, -2.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 12400000.0: tmp = math.sin(re) else: tmp = math.pow(re, -2.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 12400000.0) tmp = sin(re); else tmp = re ^ -2.0; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 12400000.0) tmp = sin(re); else tmp = re ^ -2.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 12400000.0], N[Sin[re], $MachinePrecision], N[Power[re, -2.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 12400000:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;{re}^{-2}\\
\end{array}
\end{array}
if im < 1.24e7Initial 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 69.9%
if 1.24e7 < 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.4%
Taylor expanded in re around 0 15.3%
Applied egg-rr15.3%
Final simplification54.5%
(FPCore (re im)
:precision binary64
(if (<= im 2.6e+25)
(sin re)
(if (or (<= im 2.35e+159) (not (<= im 1.05e+196)))
(/
(/ (- 3.3489797668038406e-7 (* re re)) (+ re 0.0005787037037037037))
(+ 0.006944444444444444 (* re 0.9791666666666666)))
(+ 0.08333333333333333 (* re re)))))
double code(double re, double im) {
double tmp;
if (im <= 2.6e+25) {
tmp = sin(re);
} else if ((im <= 2.35e+159) || !(im <= 1.05e+196)) {
tmp = ((3.3489797668038406e-7 - (re * re)) / (re + 0.0005787037037037037)) / (0.006944444444444444 + (re * 0.9791666666666666));
} else {
tmp = 0.08333333333333333 + (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 <= 2.6d+25) then
tmp = sin(re)
else if ((im <= 2.35d+159) .or. (.not. (im <= 1.05d+196))) then
tmp = ((3.3489797668038406d-7 - (re * re)) / (re + 0.0005787037037037037d0)) / (0.006944444444444444d0 + (re * 0.9791666666666666d0))
else
tmp = 0.08333333333333333d0 + (re * re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2.6e+25) {
tmp = Math.sin(re);
} else if ((im <= 2.35e+159) || !(im <= 1.05e+196)) {
tmp = ((3.3489797668038406e-7 - (re * re)) / (re + 0.0005787037037037037)) / (0.006944444444444444 + (re * 0.9791666666666666));
} else {
tmp = 0.08333333333333333 + (re * re);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.6e+25: tmp = math.sin(re) elif (im <= 2.35e+159) or not (im <= 1.05e+196): tmp = ((3.3489797668038406e-7 - (re * re)) / (re + 0.0005787037037037037)) / (0.006944444444444444 + (re * 0.9791666666666666)) else: tmp = 0.08333333333333333 + (re * re) return tmp
function code(re, im) tmp = 0.0 if (im <= 2.6e+25) tmp = sin(re); elseif ((im <= 2.35e+159) || !(im <= 1.05e+196)) tmp = Float64(Float64(Float64(3.3489797668038406e-7 - Float64(re * re)) / Float64(re + 0.0005787037037037037)) / Float64(0.006944444444444444 + Float64(re * 0.9791666666666666))); else tmp = Float64(0.08333333333333333 + Float64(re * re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.6e+25) tmp = sin(re); elseif ((im <= 2.35e+159) || ~((im <= 1.05e+196))) tmp = ((3.3489797668038406e-7 - (re * re)) / (re + 0.0005787037037037037)) / (0.006944444444444444 + (re * 0.9791666666666666)); else tmp = 0.08333333333333333 + (re * re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.6e+25], N[Sin[re], $MachinePrecision], If[Or[LessEqual[im, 2.35e+159], N[Not[LessEqual[im, 1.05e+196]], $MachinePrecision]], N[(N[(N[(3.3489797668038406e-7 - N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(re + 0.0005787037037037037), $MachinePrecision]), $MachinePrecision] / N[(0.006944444444444444 + N[(re * 0.9791666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.08333333333333333 + N[(re * re), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.6 \cdot 10^{+25}:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 2.35 \cdot 10^{+159} \lor \neg \left(im \leq 1.05 \cdot 10^{+196}\right):\\
\;\;\;\;\frac{\frac{3.3489797668038406 \cdot 10^{-7} - re \cdot re}{re + 0.0005787037037037037}}{0.006944444444444444 + re \cdot 0.9791666666666666}\\
\mathbf{else}:\\
\;\;\;\;0.08333333333333333 + re \cdot re\\
\end{array}
\end{array}
if im < 2.5999999999999998e25Initial 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.8%
if 2.5999999999999998e25 < im < 2.3500000000000002e159 or 1.05000000000000007e196 < 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.0%
Taylor expanded in re around 0 15.0%
associate-*r/15.0%
metadata-eval15.0%
Simplified15.0%
Applied egg-rr2.0%
*-commutative2.0%
distribute-rgt1-in2.0%
metadata-eval2.0%
Simplified2.0%
sub-neg2.0%
flip-+20.0%
metadata-eval20.0%
Applied egg-rr20.0%
if 2.3500000000000002e159 < im < 1.05000000000000007e196Initial 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-rr21.9%
Taylor expanded in re around 0 21.8%
associate-*r/21.8%
metadata-eval21.8%
Simplified21.8%
Applied egg-rr31.0%
Final simplification56.1%
(FPCore (re im)
:precision binary64
(if (<= re 0.17)
re
(/
(/
(* (+ re 0.0005787037037037037) (+ re 0.006944444444444444))
(+ re -0.020833333333333332))
(+ 0.006944444444444444 (* re 1.0208333333333333)))))
double code(double re, double im) {
double tmp;
if (re <= 0.17) {
tmp = re;
} else {
tmp = (((re + 0.0005787037037037037) * (re + 0.006944444444444444)) / (re + -0.020833333333333332)) / (0.006944444444444444 + (re * 1.0208333333333333));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 0.17d0) then
tmp = re
else
tmp = (((re + 0.0005787037037037037d0) * (re + 0.006944444444444444d0)) / (re + (-0.020833333333333332d0))) / (0.006944444444444444d0 + (re * 1.0208333333333333d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 0.17) {
tmp = re;
} else {
tmp = (((re + 0.0005787037037037037) * (re + 0.006944444444444444)) / (re + -0.020833333333333332)) / (0.006944444444444444 + (re * 1.0208333333333333));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 0.17: tmp = re else: tmp = (((re + 0.0005787037037037037) * (re + 0.006944444444444444)) / (re + -0.020833333333333332)) / (0.006944444444444444 + (re * 1.0208333333333333)) return tmp
function code(re, im) tmp = 0.0 if (re <= 0.17) tmp = re; else tmp = Float64(Float64(Float64(Float64(re + 0.0005787037037037037) * Float64(re + 0.006944444444444444)) / Float64(re + -0.020833333333333332)) / Float64(0.006944444444444444 + Float64(re * 1.0208333333333333))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 0.17) tmp = re; else tmp = (((re + 0.0005787037037037037) * (re + 0.006944444444444444)) / (re + -0.020833333333333332)) / (0.006944444444444444 + (re * 1.0208333333333333)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 0.17], re, N[(N[(N[(N[(re + 0.0005787037037037037), $MachinePrecision] * N[(re + 0.006944444444444444), $MachinePrecision]), $MachinePrecision] / N[(re + -0.020833333333333332), $MachinePrecision]), $MachinePrecision] / N[(0.006944444444444444 + N[(re * 1.0208333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 0.17:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(re + 0.0005787037037037037\right) \cdot \left(re + 0.006944444444444444\right)}{re + -0.020833333333333332}}{0.006944444444444444 + re \cdot 1.0208333333333333}\\
\end{array}
\end{array}
if re < 0.170000000000000012Initial 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 76.9%
Simplified76.9%
Taylor expanded in re around 0 56.9%
*-commutative56.9%
associate-*r*56.9%
+-commutative56.9%
unpow256.9%
fma-udef56.9%
Simplified56.9%
Taylor expanded in im around 0 34.7%
if 0.170000000000000012 < 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%
Applied egg-rr5.9%
Taylor expanded in re around 0 5.7%
associate-*r/5.7%
metadata-eval5.7%
Simplified5.7%
Applied egg-rr3.2%
*-commutative3.2%
associate-/l/16.6%
*-commutative16.6%
+-commutative16.6%
associate--l+16.6%
*-commutative16.6%
cancel-sign-sub-inv16.6%
distribute-rgt1-in16.6%
metadata-eval16.6%
metadata-eval16.6%
Simplified16.6%
Final simplification30.3%
(FPCore (re im)
:precision binary64
(if (<= re 3.1)
re
(/
(/ (- 3.3489797668038406e-7 (* re re)) (+ re 0.0005787037037037037))
(+ 0.006944444444444444 (* re 0.9791666666666666)))))
double code(double re, double im) {
double tmp;
if (re <= 3.1) {
tmp = re;
} else {
tmp = ((3.3489797668038406e-7 - (re * re)) / (re + 0.0005787037037037037)) / (0.006944444444444444 + (re * 0.9791666666666666));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 3.1d0) then
tmp = re
else
tmp = ((3.3489797668038406d-7 - (re * re)) / (re + 0.0005787037037037037d0)) / (0.006944444444444444d0 + (re * 0.9791666666666666d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 3.1) {
tmp = re;
} else {
tmp = ((3.3489797668038406e-7 - (re * re)) / (re + 0.0005787037037037037)) / (0.006944444444444444 + (re * 0.9791666666666666));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 3.1: tmp = re else: tmp = ((3.3489797668038406e-7 - (re * re)) / (re + 0.0005787037037037037)) / (0.006944444444444444 + (re * 0.9791666666666666)) return tmp
function code(re, im) tmp = 0.0 if (re <= 3.1) tmp = re; else tmp = Float64(Float64(Float64(3.3489797668038406e-7 - Float64(re * re)) / Float64(re + 0.0005787037037037037)) / Float64(0.006944444444444444 + Float64(re * 0.9791666666666666))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 3.1) tmp = re; else tmp = ((3.3489797668038406e-7 - (re * re)) / (re + 0.0005787037037037037)) / (0.006944444444444444 + (re * 0.9791666666666666)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 3.1], re, N[(N[(N[(3.3489797668038406e-7 - N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(re + 0.0005787037037037037), $MachinePrecision]), $MachinePrecision] / N[(0.006944444444444444 + N[(re * 0.9791666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 3.1:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{3.3489797668038406 \cdot 10^{-7} - re \cdot re}{re + 0.0005787037037037037}}{0.006944444444444444 + re \cdot 0.9791666666666666}\\
\end{array}
\end{array}
if re < 3.10000000000000009Initial 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 76.9%
Simplified76.9%
Taylor expanded in re around 0 56.9%
*-commutative56.9%
associate-*r*56.9%
+-commutative56.9%
unpow256.9%
fma-udef56.9%
Simplified56.9%
Taylor expanded in im around 0 34.7%
if 3.10000000000000009 < 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%
Applied egg-rr5.9%
Taylor expanded in re around 0 5.7%
associate-*r/5.7%
metadata-eval5.7%
Simplified5.7%
Applied egg-rr5.8%
*-commutative5.8%
distribute-rgt1-in5.8%
metadata-eval5.8%
Simplified5.8%
sub-neg5.8%
flip-+21.1%
metadata-eval21.1%
Applied egg-rr21.1%
Final simplification31.4%
(FPCore (re im) :precision binary64 (if (<= im 58000.0) re (+ 0.08333333333333333 (* re re))))
double code(double re, double im) {
double tmp;
if (im <= 58000.0) {
tmp = re;
} else {
tmp = 0.08333333333333333 + (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 <= 58000.0d0) then
tmp = re
else
tmp = 0.08333333333333333d0 + (re * re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 58000.0) {
tmp = re;
} else {
tmp = 0.08333333333333333 + (re * re);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 58000.0: tmp = re else: tmp = 0.08333333333333333 + (re * re) return tmp
function code(re, im) tmp = 0.0 if (im <= 58000.0) tmp = re; else tmp = Float64(0.08333333333333333 + Float64(re * re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 58000.0) tmp = re; else tmp = 0.08333333333333333 + (re * re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 58000.0], re, N[(0.08333333333333333 + N[(re * re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 58000:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;0.08333333333333333 + re \cdot re\\
\end{array}
\end{array}
if im < 58000Initial 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 86.3%
Simplified86.3%
Taylor expanded in re around 0 48.6%
*-commutative48.6%
associate-*r*48.6%
+-commutative48.6%
unpow248.6%
fma-udef48.6%
Simplified48.6%
Taylor expanded in im around 0 36.8%
if 58000 < 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.2%
Taylor expanded in re around 0 15.2%
associate-*r/15.2%
metadata-eval15.2%
Simplified15.2%
Applied egg-rr15.1%
Final simplification30.6%
(FPCore (re im) :precision binary64 (if (<= im 58000.0) re (* re re)))
double code(double re, double im) {
double tmp;
if (im <= 58000.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 <= 58000.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 <= 58000.0) {
tmp = re;
} else {
tmp = re * re;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 58000.0: tmp = re else: tmp = re * re return tmp
function code(re, im) tmp = 0.0 if (im <= 58000.0) tmp = re; else tmp = Float64(re * re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 58000.0) tmp = re; else tmp = re * re; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 58000.0], re, N[(re * re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 58000:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;re \cdot re\\
\end{array}
\end{array}
if im < 58000Initial 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 86.3%
Simplified86.3%
Taylor expanded in re around 0 48.6%
*-commutative48.6%
associate-*r*48.6%
+-commutative48.6%
unpow248.6%
fma-udef48.6%
Simplified48.6%
Taylor expanded in im around 0 36.8%
if 58000 < 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.2%
Taylor expanded in re around 0 15.1%
Applied egg-rr15.0%
Final simplification30.5%
(FPCore (re im) :precision binary64 (if (<= re 3.9e-5) re 0.9596001665972511))
double code(double re, double im) {
double tmp;
if (re <= 3.9e-5) {
tmp = re;
} else {
tmp = 0.9596001665972511;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 3.9d-5) then
tmp = re
else
tmp = 0.9596001665972511d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 3.9e-5) {
tmp = re;
} else {
tmp = 0.9596001665972511;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 3.9e-5: tmp = re else: tmp = 0.9596001665972511 return tmp
function code(re, im) tmp = 0.0 if (re <= 3.9e-5) tmp = re; else tmp = 0.9596001665972511; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 3.9e-5) tmp = re; else tmp = 0.9596001665972511; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 3.9e-5], re, 0.9596001665972511]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 3.9 \cdot 10^{-5}:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;0.9596001665972511\\
\end{array}
\end{array}
if re < 3.8999999999999999e-5Initial 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 77.3%
Simplified77.3%
Taylor expanded in re around 0 57.2%
*-commutative57.2%
associate-*r*57.2%
+-commutative57.2%
unpow257.2%
fma-udef57.2%
Simplified57.2%
Taylor expanded in im around 0 34.8%
if 3.8999999999999999e-5 < 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%
Applied egg-rr5.8%
Taylor expanded in re around 0 5.7%
associate-*r/5.7%
metadata-eval5.7%
Simplified5.7%
Applied egg-rr3.3%
times-frac7.1%
+-commutative7.1%
associate-+r-7.1%
+-commutative7.1%
associate-+r-7.1%
Simplified7.1%
Taylor expanded in re around inf 7.1%
Final simplification28.0%
(FPCore (re im) :precision binary64 -1.0212765957446808)
double code(double re, double im) {
return -1.0212765957446808;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -1.0212765957446808d0
end function
public static double code(double re, double im) {
return -1.0212765957446808;
}
def code(re, im): return -1.0212765957446808
function code(re, im) return -1.0212765957446808 end
function tmp = code(re, im) tmp = -1.0212765957446808; end
code[re_, im_] := -1.0212765957446808
\begin{array}{l}
\\
-1.0212765957446808
\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-rr9.6%
Taylor expanded in re around 0 9.5%
associate-*r/9.5%
metadata-eval9.5%
Simplified9.5%
Applied egg-rr4.6%
*-commutative4.6%
distribute-rgt1-in4.6%
metadata-eval4.6%
Simplified4.6%
Taylor expanded in re around inf 4.6%
Final simplification4.6%
(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-rr9.6%
Taylor expanded in re around 0 9.5%
associate-*r/9.5%
metadata-eval9.5%
Simplified9.5%
Taylor expanded in re around inf 4.1%
Final simplification4.1%
(FPCore (re im) :precision binary64 0.9596001665972511)
double code(double re, double im) {
return 0.9596001665972511;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.9596001665972511d0
end function
public static double code(double re, double im) {
return 0.9596001665972511;
}
def code(re, im): return 0.9596001665972511
function code(re, im) return 0.9596001665972511 end
function tmp = code(re, im) tmp = 0.9596001665972511; end
code[re_, im_] := 0.9596001665972511
\begin{array}{l}
\\
0.9596001665972511
\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-rr9.6%
Taylor expanded in re around 0 9.5%
associate-*r/9.5%
metadata-eval9.5%
Simplified9.5%
Applied egg-rr2.9%
times-frac4.8%
+-commutative4.8%
associate-+r-4.8%
+-commutative4.8%
associate-+r-4.8%
Simplified4.8%
Taylor expanded in re around inf 4.8%
Final simplification4.8%
herbie shell --seed 2024031
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))