
(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 17 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 (<= im 1.1e-11)
(sin re)
(if (<= im 1.32e+154)
(* (* 0.5 re) (+ (exp (- im)) (exp im)))
(* (sin re) (* 0.5 (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 1.1e-11) {
tmp = sin(re);
} else if (im <= 1.32e+154) {
tmp = (0.5 * re) * (exp(-im) + exp(im));
} else {
tmp = sin(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 <= 1.1d-11) then
tmp = sin(re)
else if (im <= 1.32d+154) then
tmp = (0.5d0 * re) * (exp(-im) + exp(im))
else
tmp = sin(re) * (0.5d0 * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.1e-11) {
tmp = Math.sin(re);
} else if (im <= 1.32e+154) {
tmp = (0.5 * re) * (Math.exp(-im) + Math.exp(im));
} else {
tmp = Math.sin(re) * (0.5 * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.1e-11: tmp = math.sin(re) elif im <= 1.32e+154: tmp = (0.5 * re) * (math.exp(-im) + math.exp(im)) else: tmp = math.sin(re) * (0.5 * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.1e-11) tmp = sin(re); elseif (im <= 1.32e+154) tmp = Float64(Float64(0.5 * re) * Float64(exp(Float64(-im)) + exp(im))); else tmp = Float64(sin(re) * Float64(0.5 * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.1e-11) tmp = sin(re); elseif (im <= 1.32e+154) tmp = (0.5 * re) * (exp(-im) + exp(im)); else tmp = sin(re) * (0.5 * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.1e-11], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.32e+154], N[(N[(0.5 * re), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.1 \cdot 10^{-11}:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.32 \cdot 10^{+154}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 1.1000000000000001e-11Initial 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 67.6%
if 1.1000000000000001e-11 < im < 1.31999999999999998e154Initial program 99.9%
distribute-rgt-in99.9%
cancel-sign-sub99.9%
distribute-rgt-out--99.9%
sub-neg99.9%
neg-sub099.9%
remove-double-neg99.9%
Simplified99.9%
Taylor expanded in re around 0 86.8%
Simplified86.8%
if 1.31999999999999998e154 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification73.7%
(FPCore (re im)
:precision binary64
(if (<= im 680.0)
(sin re)
(if (<= im 1.32e+154)
(cbrt (pow (/ 0.5 re) 6.0))
(* (sin re) (* 0.5 (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 680.0) {
tmp = sin(re);
} else if (im <= 1.32e+154) {
tmp = cbrt(pow((0.5 / re), 6.0));
} else {
tmp = sin(re) * (0.5 * pow(im, 2.0));
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (im <= 680.0) {
tmp = Math.sin(re);
} else if (im <= 1.32e+154) {
tmp = Math.cbrt(Math.pow((0.5 / re), 6.0));
} else {
tmp = Math.sin(re) * (0.5 * Math.pow(im, 2.0));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 680.0) tmp = sin(re); elseif (im <= 1.32e+154) tmp = cbrt((Float64(0.5 / re) ^ 6.0)); else tmp = Float64(sin(re) * Float64(0.5 * (im ^ 2.0))); end return tmp end
code[re_, im_] := If[LessEqual[im, 680.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.32e+154], N[Power[N[Power[N[(0.5 / re), $MachinePrecision], 6.0], $MachinePrecision], 1/3], $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 680:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.32 \cdot 10^{+154}:\\
\;\;\;\;\sqrt[3]{{\left(\frac{0.5}{re}\right)}^{6}}\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 680Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 66.9%
if 680 < im < 1.31999999999999998e154Initial 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-rr27.3%
Taylor expanded in re around 0 27.1%
add-sqr-sqrt27.1%
sqrt-div27.1%
metadata-eval27.1%
unpow227.1%
sqrt-prod26.8%
add-sqr-sqrt42.4%
sqrt-div42.4%
metadata-eval42.4%
unpow242.4%
sqrt-prod26.8%
add-sqr-sqrt27.1%
Applied egg-rr27.1%
add-cbrt-cube34.0%
pow1/334.0%
pow334.0%
pow234.0%
pow-pow34.0%
metadata-eval34.0%
Applied egg-rr34.0%
unpow1/334.0%
Simplified34.0%
if 1.31999999999999998e154 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification67.3%
(FPCore (re im)
:precision binary64
(if (<= im 750.0)
(sin re)
(if (<= im 2.5e+142)
(cbrt (pow (/ 0.5 re) 6.0))
(* re (+ (* 0.5 (pow im 2.0)) 1.0)))))
double code(double re, double im) {
double tmp;
if (im <= 750.0) {
tmp = sin(re);
} else if (im <= 2.5e+142) {
tmp = cbrt(pow((0.5 / re), 6.0));
} else {
tmp = re * ((0.5 * pow(im, 2.0)) + 1.0);
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (im <= 750.0) {
tmp = Math.sin(re);
} else if (im <= 2.5e+142) {
tmp = Math.cbrt(Math.pow((0.5 / re), 6.0));
} else {
tmp = re * ((0.5 * Math.pow(im, 2.0)) + 1.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 750.0) tmp = sin(re); elseif (im <= 2.5e+142) tmp = cbrt((Float64(0.5 / re) ^ 6.0)); else tmp = Float64(re * Float64(Float64(0.5 * (im ^ 2.0)) + 1.0)); end return tmp end
code[re_, im_] := If[LessEqual[im, 750.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 2.5e+142], N[Power[N[Power[N[(0.5 / re), $MachinePrecision], 6.0], $MachinePrecision], 1/3], $MachinePrecision], N[(re * N[(N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 750:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 2.5 \cdot 10^{+142}:\\
\;\;\;\;\sqrt[3]{{\left(\frac{0.5}{re}\right)}^{6}}\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot {im}^{2} + 1\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.9%
if 750 < im < 2.5000000000000001e142Initial 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-rr27.3%
Taylor expanded in re around 0 27.1%
add-sqr-sqrt27.1%
sqrt-div27.1%
metadata-eval27.1%
unpow227.1%
sqrt-prod26.8%
add-sqr-sqrt40.8%
sqrt-div40.8%
metadata-eval40.8%
unpow240.8%
sqrt-prod26.8%
add-sqr-sqrt27.1%
Applied egg-rr27.1%
add-cbrt-cube31.1%
pow1/331.1%
pow331.1%
pow231.1%
pow-pow31.1%
metadata-eval31.1%
Applied egg-rr31.1%
unpow1/331.1%
Simplified31.1%
if 2.5000000000000001e142 < 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.9%
Simplified88.9%
Taylor expanded in re around 0 71.3%
Final simplification64.3%
(FPCore (re im)
:precision binary64
(if (<= im 490.0)
(sin re)
(if (<= im 1.35e+121)
(+ 0.08333333333333333 (/ (/ 0.25 re) re))
(* re (+ (* 0.5 (pow im 2.0)) 1.0)))))
double code(double re, double im) {
double tmp;
if (im <= 490.0) {
tmp = sin(re);
} else if (im <= 1.35e+121) {
tmp = 0.08333333333333333 + ((0.25 / re) / re);
} else {
tmp = re * ((0.5 * pow(im, 2.0)) + 1.0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 490.0d0) then
tmp = sin(re)
else if (im <= 1.35d+121) then
tmp = 0.08333333333333333d0 + ((0.25d0 / re) / re)
else
tmp = re * ((0.5d0 * (im ** 2.0d0)) + 1.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 490.0) {
tmp = Math.sin(re);
} else if (im <= 1.35e+121) {
tmp = 0.08333333333333333 + ((0.25 / re) / re);
} else {
tmp = re * ((0.5 * Math.pow(im, 2.0)) + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 490.0: tmp = math.sin(re) elif im <= 1.35e+121: tmp = 0.08333333333333333 + ((0.25 / re) / re) else: tmp = re * ((0.5 * math.pow(im, 2.0)) + 1.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 490.0) tmp = sin(re); elseif (im <= 1.35e+121) tmp = Float64(0.08333333333333333 + Float64(Float64(0.25 / re) / re)); else tmp = Float64(re * Float64(Float64(0.5 * (im ^ 2.0)) + 1.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 490.0) tmp = sin(re); elseif (im <= 1.35e+121) tmp = 0.08333333333333333 + ((0.25 / re) / re); else tmp = re * ((0.5 * (im ^ 2.0)) + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 490.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.35e+121], N[(0.08333333333333333 + N[(N[(0.25 / re), $MachinePrecision] / re), $MachinePrecision]), $MachinePrecision], N[(re * N[(N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 490:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+121}:\\
\;\;\;\;0.08333333333333333 + \frac{\frac{0.25}{re}}{re}\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot {im}^{2} + 1\right)\\
\end{array}
\end{array}
if im < 490Initial 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.9%
if 490 < im < 1.3500000000000001e121Initial 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-rr28.7%
Taylor expanded in re around 0 28.7%
associate-*r/28.7%
metadata-eval28.7%
Simplified28.7%
add-sqr-sqrt28.5%
sqrt-div28.5%
metadata-eval28.5%
unpow228.5%
sqrt-prod28.2%
add-sqr-sqrt45.8%
sqrt-div45.8%
metadata-eval45.8%
unpow245.8%
sqrt-prod28.2%
add-sqr-sqrt28.5%
Applied egg-rr28.7%
associate-*l/28.5%
associate-*r/28.5%
metadata-eval28.5%
Applied egg-rr28.7%
if 1.3500000000000001e121 < 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 78.3%
Simplified78.3%
Taylor expanded in re around 0 67.5%
Final simplification64.3%
(FPCore (re im)
:precision binary64
(if (<= im 490.0)
(sin re)
(if (<= im 1.35e+121)
(+ 0.08333333333333333 (/ (/ 0.25 re) re))
(* re (* 0.5 (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 490.0) {
tmp = sin(re);
} else if (im <= 1.35e+121) {
tmp = 0.08333333333333333 + ((0.25 / re) / re);
} 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 <= 490.0d0) then
tmp = sin(re)
else if (im <= 1.35d+121) then
tmp = 0.08333333333333333d0 + ((0.25d0 / re) / re)
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 <= 490.0) {
tmp = Math.sin(re);
} else if (im <= 1.35e+121) {
tmp = 0.08333333333333333 + ((0.25 / re) / re);
} else {
tmp = re * (0.5 * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 490.0: tmp = math.sin(re) elif im <= 1.35e+121: tmp = 0.08333333333333333 + ((0.25 / re) / re) else: tmp = re * (0.5 * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 490.0) tmp = sin(re); elseif (im <= 1.35e+121) tmp = Float64(0.08333333333333333 + Float64(Float64(0.25 / re) / re)); 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 <= 490.0) tmp = sin(re); elseif (im <= 1.35e+121) tmp = 0.08333333333333333 + ((0.25 / re) / re); else tmp = re * (0.5 * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 490.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.35e+121], N[(0.08333333333333333 + N[(N[(0.25 / re), $MachinePrecision] / re), $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 490:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+121}:\\
\;\;\;\;0.08333333333333333 + \frac{\frac{0.25}{re}}{re}\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 490Initial 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.9%
if 490 < im < 1.3500000000000001e121Initial 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-rr28.7%
Taylor expanded in re around 0 28.7%
associate-*r/28.7%
metadata-eval28.7%
Simplified28.7%
add-sqr-sqrt28.5%
sqrt-div28.5%
metadata-eval28.5%
unpow228.5%
sqrt-prod28.2%
add-sqr-sqrt45.8%
sqrt-div45.8%
metadata-eval45.8%
unpow245.8%
sqrt-prod28.2%
add-sqr-sqrt28.5%
Applied egg-rr28.7%
associate-*l/28.5%
associate-*r/28.5%
metadata-eval28.5%
Applied egg-rr28.7%
if 1.3500000000000001e121 < 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 re around 0 82.1%
Simplified82.1%
Taylor expanded in im around 0 67.5%
Taylor expanded in im around inf 67.5%
*-commutative67.5%
associate-*r*67.5%
*-commutative67.5%
associate-*r*67.5%
Simplified67.5%
Final simplification64.3%
(FPCore (re im) :precision binary64 (if (<= im 770.0) (sin re) (+ 0.08333333333333333 (/ (/ 0.25 re) re))))
double code(double re, double im) {
double tmp;
if (im <= 770.0) {
tmp = sin(re);
} else {
tmp = 0.08333333333333333 + ((0.25 / 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 <= 770.0d0) then
tmp = sin(re)
else
tmp = 0.08333333333333333d0 + ((0.25d0 / re) / re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 770.0) {
tmp = Math.sin(re);
} else {
tmp = 0.08333333333333333 + ((0.25 / re) / re);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 770.0: tmp = math.sin(re) else: tmp = 0.08333333333333333 + ((0.25 / re) / re) return tmp
function code(re, im) tmp = 0.0 if (im <= 770.0) tmp = sin(re); else tmp = Float64(0.08333333333333333 + Float64(Float64(0.25 / re) / re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 770.0) tmp = sin(re); else tmp = 0.08333333333333333 + ((0.25 / re) / re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 770.0], N[Sin[re], $MachinePrecision], N[(0.08333333333333333 + N[(N[(0.25 / re), $MachinePrecision] / re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 770:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;0.08333333333333333 + \frac{\frac{0.25}{re}}{re}\\
\end{array}
\end{array}
if im < 770Initial 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.9%
if 770 < 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-rr22.7%
Taylor expanded in re around 0 22.7%
associate-*r/22.7%
metadata-eval22.7%
Simplified22.7%
add-sqr-sqrt22.5%
sqrt-div22.5%
metadata-eval22.5%
unpow222.5%
sqrt-prod22.2%
add-sqr-sqrt38.8%
sqrt-div38.8%
metadata-eval38.8%
unpow238.8%
sqrt-prod22.2%
add-sqr-sqrt22.5%
Applied egg-rr22.7%
associate-*l/22.5%
associate-*r/22.5%
metadata-eval22.5%
Applied egg-rr22.7%
Final simplification57.0%
(FPCore (re im) :precision binary64 (if (<= im 0.29) re (+ 0.08333333333333333 (/ (/ 0.25 re) re))))
double code(double re, double im) {
double tmp;
if (im <= 0.29) {
tmp = re;
} else {
tmp = 0.08333333333333333 + ((0.25 / 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 <= 0.29d0) then
tmp = re
else
tmp = 0.08333333333333333d0 + ((0.25d0 / re) / re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 0.29) {
tmp = re;
} else {
tmp = 0.08333333333333333 + ((0.25 / re) / re);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.29: tmp = re else: tmp = 0.08333333333333333 + ((0.25 / re) / re) return tmp
function code(re, im) tmp = 0.0 if (im <= 0.29) tmp = re; else tmp = Float64(0.08333333333333333 + Float64(Float64(0.25 / re) / re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.29) tmp = re; else tmp = 0.08333333333333333 + ((0.25 / re) / re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.29], re, N[(0.08333333333333333 + N[(N[(0.25 / re), $MachinePrecision] / re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.29:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;0.08333333333333333 + \frac{\frac{0.25}{re}}{re}\\
\end{array}
\end{array}
if im < 0.28999999999999998Initial 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 64.3%
Simplified64.3%
Taylor expanded in im around 0 38.2%
if 0.28999999999999998 < 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-rr21.9%
Taylor expanded in re around 0 21.9%
associate-*r/21.9%
metadata-eval21.9%
Simplified21.9%
add-sqr-sqrt21.8%
sqrt-div21.8%
metadata-eval21.8%
unpow221.8%
sqrt-prod21.5%
add-sqr-sqrt37.6%
sqrt-div37.6%
metadata-eval37.6%
unpow237.6%
sqrt-prod21.5%
add-sqr-sqrt21.8%
Applied egg-rr21.9%
associate-*l/21.8%
associate-*r/21.8%
metadata-eval21.8%
Applied egg-rr21.9%
Final simplification34.5%
(FPCore (re im) :precision binary64 (if (<= im 1080.0) re (/ (/ 0.25 re) re)))
double code(double re, double im) {
double tmp;
if (im <= 1080.0) {
tmp = re;
} else {
tmp = (0.25 / re) / re;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1080.0d0) then
tmp = re
else
tmp = (0.25d0 / re) / re
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1080.0) {
tmp = re;
} else {
tmp = (0.25 / re) / re;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1080.0: tmp = re else: tmp = (0.25 / re) / re return tmp
function code(re, im) tmp = 0.0 if (im <= 1080.0) tmp = re; else tmp = Float64(Float64(0.25 / re) / re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1080.0) tmp = re; else tmp = (0.25 / re) / re; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1080.0], re, N[(N[(0.25 / re), $MachinePrecision] / re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1080:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.25}{re}}{re}\\
\end{array}
\end{array}
if im < 1080Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 63.7%
Simplified63.7%
Taylor expanded in im around 0 37.9%
if 1080 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Applied egg-rr22.7%
Taylor expanded in re around 0 22.5%
add-sqr-sqrt22.5%
sqrt-div22.5%
metadata-eval22.5%
unpow222.5%
sqrt-prod22.2%
add-sqr-sqrt38.8%
sqrt-div38.8%
metadata-eval38.8%
unpow238.8%
sqrt-prod22.2%
add-sqr-sqrt22.5%
Applied egg-rr22.5%
associate-*l/22.5%
associate-*r/22.5%
metadata-eval22.5%
Applied egg-rr22.5%
Final simplification34.5%
(FPCore (re im) :precision binary64 -4.0)
double code(double re, double im) {
return -4.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -4.0d0
end function
public static double code(double re, double im) {
return -4.0;
}
def code(re, im): return -4.0
function code(re, im) return -4.0 end
function tmp = code(re, im) tmp = -4.0; end
code[re_, im_] := -4.0
\begin{array}{l}
\\
-4
\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 77.9%
Simplified77.9%
Applied egg-rr4.2%
Final simplification4.2%
(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 im around 0 77.9%
Simplified77.9%
Applied egg-rr4.9%
Final simplification4.9%
(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 im around 0 77.9%
Simplified77.9%
Applied egg-rr4.2%
Final simplification4.2%
(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-rr12.1%
Taylor expanded in re around 0 12.1%
associate-*r/12.1%
metadata-eval12.1%
Simplified12.1%
Taylor expanded in re around inf 4.2%
Final simplification4.2%
(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 im around 0 77.9%
Simplified77.9%
Applied egg-rr4.3%
Final simplification4.3%
(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 im around 0 77.9%
Simplified77.9%
Applied egg-rr4.4%
Final simplification4.4%
(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 im around 0 77.9%
Simplified77.9%
Applied egg-rr4.5%
Final simplification4.5%
(FPCore (re im) :precision binary64 re)
double code(double re, double im) {
return re;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re
end function
public static double code(double re, double im) {
return re;
}
def code(re, im): return re
function code(re, im) return re end
function tmp = code(re, im) tmp = re; end
code[re_, im_] := re
\begin{array}{l}
\\
re
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 68.6%
Simplified68.6%
Taylor expanded in im around 0 30.1%
Final simplification30.1%
herbie shell --seed 2024040
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))