
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * sin(re)) * (exp((0.0d0 - im)) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp((0.0 - im)) + Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp((0.0 - im)) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(0.0 - im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * sin(re)) * (exp((0.0d0 - im)) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp((0.0 - im)) + Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp((0.0 - im)) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(0.0 - im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)
\end{array}
(FPCore (re im) :precision binary64 (* (* 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 99.6%
distribute-lft-in99.6%
*-commutative99.6%
cancel-sign-sub99.6%
distribute-lft-neg-out99.6%
*-commutative99.6%
distribute-rgt-neg-out99.6%
neg-mul-199.6%
associate-*r*99.6%
distribute-rgt-out--99.6%
sub-neg99.6%
neg-sub099.6%
*-commutative99.6%
neg-mul-199.6%
remove-double-neg99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (re im)
:precision binary64
(if (<= im 0.036)
(+ (sin re) (* im (* (sin re) (* 0.5 im))))
(if (<= im 1.55e+152)
(* 0.5 (fma re (exp im) (/ re (exp im))))
(* (* 0.5 (sin re)) (+ 2.0 (* im im))))))
double code(double re, double im) {
double tmp;
if (im <= 0.036) {
tmp = sin(re) + (im * (sin(re) * (0.5 * im)));
} else if (im <= 1.55e+152) {
tmp = 0.5 * fma(re, exp(im), (re / exp(im)));
} else {
tmp = (0.5 * sin(re)) * (2.0 + (im * im));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 0.036) tmp = Float64(sin(re) + Float64(im * Float64(sin(re) * Float64(0.5 * im)))); elseif (im <= 1.55e+152) tmp = Float64(0.5 * fma(re, exp(im), Float64(re / exp(im)))); else tmp = Float64(Float64(0.5 * sin(re)) * Float64(2.0 + Float64(im * im))); end return tmp end
code[re_, im_] := If[LessEqual[im, 0.036], N[(N[Sin[re], $MachinePrecision] + N[(im * N[(N[Sin[re], $MachinePrecision] * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.55e+152], N[(0.5 * N[(re * N[Exp[im], $MachinePrecision] + N[(re / N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.036:\\
\;\;\;\;\sin re + im \cdot \left(\sin re \cdot \left(0.5 \cdot im\right)\right)\\
\mathbf{elif}\;im \leq 1.55 \cdot 10^{+152}:\\
\;\;\;\;0.5 \cdot \mathsf{fma}\left(re, e^{im}, \frac{re}{e^{im}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot im\right)\\
\end{array}
\end{array}
if im < 0.0359999999999999973Initial program 99.5%
distribute-lft-in99.5%
*-commutative99.5%
cancel-sign-sub99.5%
distribute-lft-neg-out99.5%
*-commutative99.5%
distribute-rgt-neg-out99.5%
neg-mul-199.5%
associate-*r*99.5%
distribute-rgt-out--99.5%
sub-neg99.5%
neg-sub099.5%
*-commutative99.5%
neg-mul-199.5%
remove-double-neg99.5%
Simplified99.5%
Taylor expanded in im around 0 93.4%
Simplified93.4%
Taylor expanded in re around inf 93.4%
associate-*r*93.4%
*-commutative93.4%
distribute-rgt-out93.4%
*-commutative93.4%
fma-def93.4%
fma-def93.4%
unpow293.4%
*-commutative93.4%
associate-*l*93.4%
Simplified93.4%
Taylor expanded in im around 0 82.0%
associate-*r*82.0%
*-commutative82.0%
unpow282.0%
associate-*r*82.0%
associate-*l*79.5%
Simplified79.5%
if 0.0359999999999999973 < im < 1.55e152Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 80.0%
Simplified80.0%
expm1-log1p-u37.1%
expm1-udef37.1%
*-commutative37.1%
cosh-undef37.1%
Applied egg-rr37.1%
expm1-def37.1%
expm1-log1p80.0%
associate-*l*80.0%
associate-*r*80.0%
metadata-eval80.0%
Simplified80.0%
Taylor expanded in re around 0 80.0%
distribute-lft-in80.0%
fma-def80.0%
associate-*r/80.0%
*-rgt-identity80.0%
Simplified80.0%
if 1.55e152 < im Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 97.2%
Simplified97.2%
Final simplification81.7%
(FPCore (re im)
:precision binary64
(if (<= im 0.048)
(+ (sin re) (* im (* (sin re) (* 0.5 im))))
(if (<= im 1.55e+152)
(* re (cosh im))
(* (* 0.5 (sin re)) (+ 2.0 (* im im))))))
double code(double re, double im) {
double tmp;
if (im <= 0.048) {
tmp = sin(re) + (im * (sin(re) * (0.5 * im)));
} else if (im <= 1.55e+152) {
tmp = re * cosh(im);
} else {
tmp = (0.5 * sin(re)) * (2.0 + (im * im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 0.048d0) then
tmp = sin(re) + (im * (sin(re) * (0.5d0 * im)))
else if (im <= 1.55d+152) then
tmp = re * cosh(im)
else
tmp = (0.5d0 * sin(re)) * (2.0d0 + (im * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 0.048) {
tmp = Math.sin(re) + (im * (Math.sin(re) * (0.5 * im)));
} else if (im <= 1.55e+152) {
tmp = re * Math.cosh(im);
} else {
tmp = (0.5 * Math.sin(re)) * (2.0 + (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.048: tmp = math.sin(re) + (im * (math.sin(re) * (0.5 * im))) elif im <= 1.55e+152: tmp = re * math.cosh(im) else: tmp = (0.5 * math.sin(re)) * (2.0 + (im * im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 0.048) tmp = Float64(sin(re) + Float64(im * Float64(sin(re) * Float64(0.5 * im)))); elseif (im <= 1.55e+152) tmp = Float64(re * cosh(im)); else tmp = Float64(Float64(0.5 * sin(re)) * Float64(2.0 + Float64(im * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.048) tmp = sin(re) + (im * (sin(re) * (0.5 * im))); elseif (im <= 1.55e+152) tmp = re * cosh(im); else tmp = (0.5 * sin(re)) * (2.0 + (im * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.048], N[(N[Sin[re], $MachinePrecision] + N[(im * N[(N[Sin[re], $MachinePrecision] * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.55e+152], N[(re * N[Cosh[im], $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.048:\\
\;\;\;\;\sin re + im \cdot \left(\sin re \cdot \left(0.5 \cdot im\right)\right)\\
\mathbf{elif}\;im \leq 1.55 \cdot 10^{+152}:\\
\;\;\;\;re \cdot \cosh im\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot im\right)\\
\end{array}
\end{array}
if im < 0.048000000000000001Initial program 99.5%
distribute-lft-in99.5%
*-commutative99.5%
cancel-sign-sub99.5%
distribute-lft-neg-out99.5%
*-commutative99.5%
distribute-rgt-neg-out99.5%
neg-mul-199.5%
associate-*r*99.5%
distribute-rgt-out--99.5%
sub-neg99.5%
neg-sub099.5%
*-commutative99.5%
neg-mul-199.5%
remove-double-neg99.5%
Simplified99.5%
Taylor expanded in im around 0 93.4%
Simplified93.4%
Taylor expanded in re around inf 93.4%
associate-*r*93.4%
*-commutative93.4%
distribute-rgt-out93.4%
*-commutative93.4%
fma-def93.4%
fma-def93.4%
unpow293.4%
*-commutative93.4%
associate-*l*93.4%
Simplified93.4%
Taylor expanded in im around 0 82.0%
associate-*r*82.0%
*-commutative82.0%
unpow282.0%
associate-*r*82.0%
associate-*l*79.5%
Simplified79.5%
if 0.048000000000000001 < im < 1.55e152Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 80.0%
Simplified80.0%
expm1-log1p-u37.1%
expm1-udef37.1%
*-commutative37.1%
cosh-undef37.1%
Applied egg-rr37.1%
expm1-def37.1%
expm1-log1p80.0%
associate-*l*80.0%
associate-*r*80.0%
metadata-eval80.0%
Simplified80.0%
expm1-log1p-u37.1%
expm1-udef37.1%
*-un-lft-identity37.1%
Applied egg-rr37.1%
expm1-def37.1%
expm1-log1p80.0%
Simplified80.0%
if 1.55e152 < im Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 97.2%
Simplified97.2%
Final simplification81.7%
(FPCore (re im) :precision binary64 (if (or (<= im 0.07) (not (<= im 1.55e+152))) (* (* 0.5 (sin re)) (+ 2.0 (* im im))) (* re (cosh im))))
double code(double re, double im) {
double tmp;
if ((im <= 0.07) || !(im <= 1.55e+152)) {
tmp = (0.5 * sin(re)) * (2.0 + (im * im));
} else {
tmp = re * cosh(im);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= 0.07d0) .or. (.not. (im <= 1.55d+152))) then
tmp = (0.5d0 * sin(re)) * (2.0d0 + (im * im))
else
tmp = re * cosh(im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= 0.07) || !(im <= 1.55e+152)) {
tmp = (0.5 * Math.sin(re)) * (2.0 + (im * im));
} else {
tmp = re * Math.cosh(im);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= 0.07) or not (im <= 1.55e+152): tmp = (0.5 * math.sin(re)) * (2.0 + (im * im)) else: tmp = re * math.cosh(im) return tmp
function code(re, im) tmp = 0.0 if ((im <= 0.07) || !(im <= 1.55e+152)) tmp = Float64(Float64(0.5 * sin(re)) * Float64(2.0 + Float64(im * im))); else tmp = Float64(re * cosh(im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= 0.07) || ~((im <= 1.55e+152))) tmp = (0.5 * sin(re)) * (2.0 + (im * im)); else tmp = re * cosh(im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, 0.07], N[Not[LessEqual[im, 1.55e+152]], $MachinePrecision]], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re * N[Cosh[im], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.07 \lor \neg \left(im \leq 1.55 \cdot 10^{+152}\right):\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;re \cdot \cosh im\\
\end{array}
\end{array}
if im < 0.070000000000000007 or 1.55e152 < im Initial program 99.6%
distribute-lft-in99.6%
*-commutative99.6%
cancel-sign-sub99.6%
distribute-lft-neg-out99.6%
*-commutative99.6%
distribute-rgt-neg-out99.6%
neg-mul-199.6%
associate-*r*99.6%
distribute-rgt-out--99.6%
sub-neg99.6%
neg-sub099.6%
*-commutative99.6%
neg-mul-199.6%
remove-double-neg99.6%
Simplified99.6%
Taylor expanded in im around 0 84.1%
Simplified84.1%
if 0.070000000000000007 < im < 1.55e152Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 80.0%
Simplified80.0%
expm1-log1p-u37.1%
expm1-udef37.1%
*-commutative37.1%
cosh-undef37.1%
Applied egg-rr37.1%
expm1-def37.1%
expm1-log1p80.0%
associate-*l*80.0%
associate-*r*80.0%
metadata-eval80.0%
Simplified80.0%
expm1-log1p-u37.1%
expm1-udef37.1%
*-un-lft-identity37.1%
Applied egg-rr37.1%
expm1-def37.1%
expm1-log1p80.0%
Simplified80.0%
Final simplification83.6%
(FPCore (re im) :precision binary64 (if (<= im 0.0115) (sin re) (* re (cosh im))))
double code(double re, double im) {
double tmp;
if (im <= 0.0115) {
tmp = sin(re);
} else {
tmp = re * cosh(im);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 0.0115d0) then
tmp = sin(re)
else
tmp = re * cosh(im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 0.0115) {
tmp = Math.sin(re);
} else {
tmp = re * Math.cosh(im);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.0115: tmp = math.sin(re) else: tmp = re * math.cosh(im) return tmp
function code(re, im) tmp = 0.0 if (im <= 0.0115) tmp = sin(re); else tmp = Float64(re * cosh(im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.0115) tmp = sin(re); else tmp = re * cosh(im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.0115], N[Sin[re], $MachinePrecision], N[(re * N[Cosh[im], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.0115:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;re \cdot \cosh im\\
\end{array}
\end{array}
if im < 0.0115Initial program 99.5%
distribute-lft-in99.5%
*-commutative99.5%
cancel-sign-sub99.5%
distribute-lft-neg-out99.5%
*-commutative99.5%
distribute-rgt-neg-out99.5%
neg-mul-199.5%
associate-*r*99.5%
distribute-rgt-out--99.5%
sub-neg99.5%
neg-sub099.5%
*-commutative99.5%
neg-mul-199.5%
remove-double-neg99.5%
Simplified99.5%
Taylor expanded in im around 0 70.8%
if 0.0115 < im Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 78.8%
Simplified78.8%
expm1-log1p-u36.4%
expm1-udef36.4%
*-commutative36.4%
cosh-undef36.4%
Applied egg-rr36.4%
expm1-def36.4%
expm1-log1p78.8%
associate-*l*78.8%
associate-*r*78.8%
metadata-eval78.8%
Simplified78.8%
expm1-log1p-u36.4%
expm1-udef36.4%
*-un-lft-identity36.4%
Applied egg-rr36.4%
expm1-def36.4%
expm1-log1p78.8%
Simplified78.8%
Final simplification72.9%
(FPCore (re im) :precision binary64 (if (<= im 0.021) (sin re) (+ re (* re (* im (* 0.5 im))))))
double code(double re, double im) {
double tmp;
if (im <= 0.021) {
tmp = sin(re);
} else {
tmp = re + (re * (im * (0.5 * im)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 0.021d0) then
tmp = sin(re)
else
tmp = re + (re * (im * (0.5d0 * im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 0.021) {
tmp = Math.sin(re);
} else {
tmp = re + (re * (im * (0.5 * im)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.021: tmp = math.sin(re) else: tmp = re + (re * (im * (0.5 * im))) return tmp
function code(re, im) tmp = 0.0 if (im <= 0.021) tmp = sin(re); else tmp = Float64(re + Float64(re * Float64(im * Float64(0.5 * im)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.021) tmp = sin(re); else tmp = re + (re * (im * (0.5 * im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.021], N[Sin[re], $MachinePrecision], N[(re + N[(re * N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.021:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;re + re \cdot \left(im \cdot \left(0.5 \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 0.0210000000000000013Initial program 99.5%
distribute-lft-in99.5%
*-commutative99.5%
cancel-sign-sub99.5%
distribute-lft-neg-out99.5%
*-commutative99.5%
distribute-rgt-neg-out99.5%
neg-mul-199.5%
associate-*r*99.5%
distribute-rgt-out--99.5%
sub-neg99.5%
neg-sub099.5%
*-commutative99.5%
neg-mul-199.5%
remove-double-neg99.5%
Simplified99.5%
Taylor expanded in im around 0 70.8%
if 0.0210000000000000013 < im Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 78.8%
Simplified78.8%
Taylor expanded in im around 0 49.8%
unpow249.8%
associate-*r*49.8%
associate-*r*49.8%
Simplified49.8%
Final simplification65.4%
(FPCore (re im) :precision binary64 (if (<= re -7.2e+201) (+ 0.08333333333333333 (* re (* re 0.016666666666666666))) (+ re (* re (* im (* 0.5 im))))))
double code(double re, double im) {
double tmp;
if (re <= -7.2e+201) {
tmp = 0.08333333333333333 + (re * (re * 0.016666666666666666));
} else {
tmp = re + (re * (im * (0.5 * im)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-7.2d+201)) then
tmp = 0.08333333333333333d0 + (re * (re * 0.016666666666666666d0))
else
tmp = re + (re * (im * (0.5d0 * im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -7.2e+201) {
tmp = 0.08333333333333333 + (re * (re * 0.016666666666666666));
} else {
tmp = re + (re * (im * (0.5 * im)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -7.2e+201: tmp = 0.08333333333333333 + (re * (re * 0.016666666666666666)) else: tmp = re + (re * (im * (0.5 * im))) return tmp
function code(re, im) tmp = 0.0 if (re <= -7.2e+201) tmp = Float64(0.08333333333333333 + Float64(re * Float64(re * 0.016666666666666666))); else tmp = Float64(re + Float64(re * Float64(im * Float64(0.5 * im)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -7.2e+201) tmp = 0.08333333333333333 + (re * (re * 0.016666666666666666)); else tmp = re + (re * (im * (0.5 * im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -7.2e+201], N[(0.08333333333333333 + N[(re * N[(re * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re + N[(re * N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -7.2 \cdot 10^{+201}:\\
\;\;\;\;0.08333333333333333 + re \cdot \left(re \cdot 0.016666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;re + re \cdot \left(im \cdot \left(0.5 \cdot im\right)\right)\\
\end{array}
\end{array}
if re < -7.19999999999999951e201Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Applied egg-rr7.4%
Taylor expanded in re around 0 29.3%
*-commutative29.3%
fma-def29.3%
unpow229.3%
associate-*r/29.3%
metadata-eval29.3%
unpow229.3%
Simplified29.3%
Taylor expanded in re around inf 29.3%
unpow229.3%
*-commutative29.3%
associate-*l*29.3%
Simplified29.3%
if -7.19999999999999951e201 < re Initial program 99.6%
distribute-lft-in99.6%
*-commutative99.6%
cancel-sign-sub99.6%
distribute-lft-neg-out99.6%
*-commutative99.6%
distribute-rgt-neg-out99.6%
neg-mul-199.6%
associate-*r*99.6%
distribute-rgt-out--99.6%
sub-neg99.6%
neg-sub099.6%
*-commutative99.6%
neg-mul-199.6%
remove-double-neg99.6%
Simplified99.6%
Taylor expanded in re around 0 67.7%
Simplified67.7%
Taylor expanded in im around 0 49.9%
unpow249.9%
associate-*r*49.9%
associate-*r*49.9%
Simplified49.9%
Final simplification47.3%
(FPCore (re im) :precision binary64 (if (<= im 2.6e+36) re (* (/ 0.5 re) (/ 0.5 re))))
double code(double re, double im) {
double tmp;
if (im <= 2.6e+36) {
tmp = re;
} else {
tmp = (0.5 / re) * (0.5 / 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+36) then
tmp = re
else
tmp = (0.5d0 / re) * (0.5d0 / re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2.6e+36) {
tmp = re;
} else {
tmp = (0.5 / re) * (0.5 / re);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.6e+36: tmp = re else: tmp = (0.5 / re) * (0.5 / re) return tmp
function code(re, im) tmp = 0.0 if (im <= 2.6e+36) tmp = re; else tmp = Float64(Float64(0.5 / re) * Float64(0.5 / re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.6e+36) tmp = re; else tmp = (0.5 / re) * (0.5 / re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.6e+36], re, N[(N[(0.5 / re), $MachinePrecision] * N[(0.5 / re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.6 \cdot 10^{+36}:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{re} \cdot \frac{0.5}{re}\\
\end{array}
\end{array}
if im < 2.6000000000000001e36Initial program 99.5%
distribute-lft-in99.5%
*-commutative99.5%
cancel-sign-sub99.5%
distribute-lft-neg-out99.5%
*-commutative99.5%
distribute-rgt-neg-out99.5%
neg-mul-199.5%
associate-*r*99.5%
distribute-rgt-out--99.5%
sub-neg99.5%
neg-sub099.5%
*-commutative99.5%
neg-mul-199.5%
remove-double-neg99.5%
Simplified99.5%
Taylor expanded in re around 0 56.8%
Simplified56.8%
Taylor expanded in im around 0 32.4%
if 2.6000000000000001e36 < im Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Applied egg-rr18.4%
Taylor expanded in re around 0 18.2%
unpow218.2%
Simplified18.2%
add-sqr-sqrt18.2%
sqrt-div18.2%
metadata-eval18.2%
sqrt-prod17.7%
add-sqr-sqrt29.2%
sqrt-div29.2%
metadata-eval29.2%
sqrt-prod17.7%
add-sqr-sqrt18.2%
Applied egg-rr18.2%
Final simplification29.1%
(FPCore (re im) :precision binary64 (if (<= im 250.0) re (+ 0.08333333333333333 (* re (* re 0.016666666666666666)))))
double code(double re, double im) {
double tmp;
if (im <= 250.0) {
tmp = re;
} else {
tmp = 0.08333333333333333 + (re * (re * 0.016666666666666666));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 250.0d0) then
tmp = re
else
tmp = 0.08333333333333333d0 + (re * (re * 0.016666666666666666d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 250.0) {
tmp = re;
} else {
tmp = 0.08333333333333333 + (re * (re * 0.016666666666666666));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 250.0: tmp = re else: tmp = 0.08333333333333333 + (re * (re * 0.016666666666666666)) return tmp
function code(re, im) tmp = 0.0 if (im <= 250.0) tmp = re; else tmp = Float64(0.08333333333333333 + Float64(re * Float64(re * 0.016666666666666666))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 250.0) tmp = re; else tmp = 0.08333333333333333 + (re * (re * 0.016666666666666666)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 250.0], re, N[(0.08333333333333333 + N[(re * N[(re * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 250:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;0.08333333333333333 + re \cdot \left(re \cdot 0.016666666666666666\right)\\
\end{array}
\end{array}
if im < 250Initial program 99.5%
distribute-lft-in99.5%
*-commutative99.5%
cancel-sign-sub99.5%
distribute-lft-neg-out99.5%
*-commutative99.5%
distribute-rgt-neg-out99.5%
neg-mul-199.5%
associate-*r*99.5%
distribute-rgt-out--99.5%
sub-neg99.5%
neg-sub099.5%
*-commutative99.5%
neg-mul-199.5%
remove-double-neg99.5%
Simplified99.5%
Taylor expanded in re around 0 55.2%
Simplified55.2%
Taylor expanded in im around 0 33.4%
if 250 < im Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Applied egg-rr16.5%
Taylor expanded in re around 0 35.7%
*-commutative35.7%
fma-def35.7%
unpow235.7%
associate-*r/35.7%
metadata-eval35.7%
unpow235.7%
Simplified35.7%
Taylor expanded in re around inf 21.0%
unpow221.0%
*-commutative21.0%
associate-*l*21.0%
Simplified21.0%
Final simplification30.2%
(FPCore (re im) :precision binary64 (if (<= im 3.7e+36) re (/ 0.25 (* re re))))
double code(double re, double im) {
double tmp;
if (im <= 3.7e+36) {
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 <= 3.7d+36) 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 <= 3.7e+36) {
tmp = re;
} else {
tmp = 0.25 / (re * re);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 3.7e+36: tmp = re else: tmp = 0.25 / (re * re) return tmp
function code(re, im) tmp = 0.0 if (im <= 3.7e+36) tmp = re; else tmp = Float64(0.25 / Float64(re * re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 3.7e+36) tmp = re; else tmp = 0.25 / (re * re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 3.7e+36], re, N[(0.25 / N[(re * re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 3.7 \cdot 10^{+36}:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{re \cdot re}\\
\end{array}
\end{array}
if im < 3.70000000000000029e36Initial program 99.5%
distribute-lft-in99.5%
*-commutative99.5%
cancel-sign-sub99.5%
distribute-lft-neg-out99.5%
*-commutative99.5%
distribute-rgt-neg-out99.5%
neg-mul-199.5%
associate-*r*99.5%
distribute-rgt-out--99.5%
sub-neg99.5%
neg-sub099.5%
*-commutative99.5%
neg-mul-199.5%
remove-double-neg99.5%
Simplified99.5%
Taylor expanded in re around 0 56.8%
Simplified56.8%
Taylor expanded in im around 0 32.4%
if 3.70000000000000029e36 < im Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Applied egg-rr18.4%
Taylor expanded in re around 0 18.2%
unpow218.2%
Simplified18.2%
Final simplification29.1%
(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 99.6%
distribute-lft-in99.6%
*-commutative99.6%
cancel-sign-sub99.6%
distribute-lft-neg-out99.6%
*-commutative99.6%
distribute-rgt-neg-out99.6%
neg-mul-199.6%
associate-*r*99.6%
distribute-rgt-out--99.6%
sub-neg99.6%
neg-sub099.6%
*-commutative99.6%
neg-mul-199.6%
remove-double-neg99.6%
Simplified99.6%
Applied egg-rr10.8%
Taylor expanded in re around 0 10.7%
associate-*r/10.7%
metadata-eval10.7%
unpow210.7%
Simplified10.7%
Taylor expanded in re around inf 5.0%
Final simplification5.0%
(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 99.6%
distribute-lft-in99.6%
*-commutative99.6%
cancel-sign-sub99.6%
distribute-lft-neg-out99.6%
*-commutative99.6%
distribute-rgt-neg-out99.6%
neg-mul-199.6%
associate-*r*99.6%
distribute-rgt-out--99.6%
sub-neg99.6%
neg-sub099.6%
*-commutative99.6%
neg-mul-199.6%
remove-double-neg99.6%
Simplified99.6%
Taylor expanded in re around 0 61.3%
Simplified61.3%
Taylor expanded in im around 0 25.5%
Final simplification25.5%
herbie shell --seed 2023283
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))