
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * sin(re)) * (exp((0.0d0 - im)) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp((0.0 - im)) + Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp((0.0 - im)) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(0.0 - im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * sin(re)) * (exp((0.0d0 - im)) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp((0.0 - im)) + Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp((0.0 - im)) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(0.0 - im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)
\end{array}
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (+ (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp(-im) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * sin(re)) * (exp(-im) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp(-im) + Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp(-im) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp(-im) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right)
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
(FPCore (re im) :precision binary64 (if (or (<= im 0.42) (not (<= im 2.55e+154))) (* (sin re) (+ (* 0.5 (pow im 2.0)) 1.0)) (* (* 0.5 re) (+ (exp (- im)) (exp im)))))
double code(double re, double im) {
double tmp;
if ((im <= 0.42) || !(im <= 2.55e+154)) {
tmp = sin(re) * ((0.5 * pow(im, 2.0)) + 1.0);
} else {
tmp = (0.5 * re) * (exp(-im) + exp(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.42d0) .or. (.not. (im <= 2.55d+154))) then
tmp = sin(re) * ((0.5d0 * (im ** 2.0d0)) + 1.0d0)
else
tmp = (0.5d0 * re) * (exp(-im) + exp(im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= 0.42) || !(im <= 2.55e+154)) {
tmp = Math.sin(re) * ((0.5 * Math.pow(im, 2.0)) + 1.0);
} else {
tmp = (0.5 * re) * (Math.exp(-im) + Math.exp(im));
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= 0.42) or not (im <= 2.55e+154): tmp = math.sin(re) * ((0.5 * math.pow(im, 2.0)) + 1.0) else: tmp = (0.5 * re) * (math.exp(-im) + math.exp(im)) return tmp
function code(re, im) tmp = 0.0 if ((im <= 0.42) || !(im <= 2.55e+154)) tmp = Float64(sin(re) * Float64(Float64(0.5 * (im ^ 2.0)) + 1.0)); else tmp = Float64(Float64(0.5 * re) * Float64(exp(Float64(-im)) + exp(im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= 0.42) || ~((im <= 2.55e+154))) tmp = sin(re) * ((0.5 * (im ^ 2.0)) + 1.0); else tmp = (0.5 * re) * (exp(-im) + exp(im)); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, 0.42], N[Not[LessEqual[im, 2.55e+154]], $MachinePrecision]], N[(N[Sin[re], $MachinePrecision] * N[(N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.42 \lor \neg \left(im \leq 2.55 \cdot 10^{+154}\right):\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2} + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{-im} + e^{im}\right)\\
\end{array}
\end{array}
if im < 0.419999999999999984 or 2.55e154 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 85.3%
Simplified85.3%
if 0.419999999999999984 < im < 2.55e154Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in re around 0 71.8%
Simplified71.8%
Final simplification82.9%
(FPCore (re im)
:precision binary64
(if (<= im 0.4)
(sin re)
(if (<= im 2.55e+154)
(* (* 0.5 re) (+ (exp (- im)) (exp im)))
(* 0.5 (* (sin re) (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 0.4) {
tmp = sin(re);
} else if (im <= 2.55e+154) {
tmp = (0.5 * re) * (exp(-im) + exp(im));
} else {
tmp = 0.5 * (sin(re) * pow(im, 2.0));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 0.4d0) then
tmp = sin(re)
else if (im <= 2.55d+154) then
tmp = (0.5d0 * re) * (exp(-im) + exp(im))
else
tmp = 0.5d0 * (sin(re) * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 0.4) {
tmp = Math.sin(re);
} else if (im <= 2.55e+154) {
tmp = (0.5 * re) * (Math.exp(-im) + Math.exp(im));
} else {
tmp = 0.5 * (Math.sin(re) * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.4: tmp = math.sin(re) elif im <= 2.55e+154: tmp = (0.5 * re) * (math.exp(-im) + math.exp(im)) else: tmp = 0.5 * (math.sin(re) * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 0.4) tmp = sin(re); elseif (im <= 2.55e+154) tmp = Float64(Float64(0.5 * re) * Float64(exp(Float64(-im)) + exp(im))); else tmp = Float64(0.5 * Float64(sin(re) * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.4) tmp = sin(re); elseif (im <= 2.55e+154) tmp = (0.5 * re) * (exp(-im) + exp(im)); else tmp = 0.5 * (sin(re) * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.4], N[Sin[re], $MachinePrecision], If[LessEqual[im, 2.55e+154], N[(N[(0.5 * re), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.4:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 2.55 \cdot 10^{+154}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 0.40000000000000002Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 68.0%
if 0.40000000000000002 < im < 2.55e154Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in re around 0 71.8%
Simplified71.8%
if 2.55e154 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
Final simplification72.9%
(FPCore (re im)
:precision binary64
(if (<= im 700.0)
(sin re)
(if (<= im 5.6e+153)
(cbrt (pow (/ 0.5 re) 6.0))
(* 0.5 (* (sin re) (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 700.0) {
tmp = sin(re);
} else if (im <= 5.6e+153) {
tmp = cbrt(pow((0.5 / re), 6.0));
} else {
tmp = 0.5 * (sin(re) * pow(im, 2.0));
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (im <= 700.0) {
tmp = Math.sin(re);
} else if (im <= 5.6e+153) {
tmp = Math.cbrt(Math.pow((0.5 / re), 6.0));
} else {
tmp = 0.5 * (Math.sin(re) * Math.pow(im, 2.0));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 700.0) tmp = sin(re); elseif (im <= 5.6e+153) tmp = cbrt((Float64(0.5 / re) ^ 6.0)); else tmp = Float64(0.5 * Float64(sin(re) * (im ^ 2.0))); end return tmp end
code[re_, im_] := If[LessEqual[im, 700.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 5.6e+153], N[Power[N[Power[N[(0.5 / re), $MachinePrecision], 6.0], $MachinePrecision], 1/3], $MachinePrecision], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 700:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 5.6 \cdot 10^{+153}:\\
\;\;\;\;\sqrt[3]{{\left(\frac{0.5}{re}\right)}^{6}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 700Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 67.7%
if 700 < im < 5.5999999999999997e153Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr18.3%
Taylor expanded in re around 0 18.2%
add-cbrt-cube26.5%
pow1/326.5%
pow326.5%
add-sqr-sqrt26.5%
pow226.5%
pow-pow26.5%
sqrt-div26.5%
metadata-eval26.5%
sqrt-pow126.5%
metadata-eval26.5%
pow126.5%
metadata-eval26.5%
Applied egg-rr26.5%
unpow1/326.5%
Simplified26.5%
if 5.5999999999999997e153 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 97.4%
Simplified97.4%
Taylor expanded in im around inf 97.4%
Final simplification64.9%
(FPCore (re im)
:precision binary64
(if (<= im 750.0)
(sin re)
(if (<= im 2.15e+153)
(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.15e+153) {
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.15e+153) {
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.15e+153) 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.15e+153], 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.15 \cdot 10^{+153}:\\
\;\;\;\;\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%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 67.7%
if 750 < im < 2.1499999999999999e153Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr18.3%
Taylor expanded in re around 0 18.2%
add-cbrt-cube26.5%
pow1/326.5%
pow326.5%
add-sqr-sqrt26.5%
pow226.5%
pow-pow26.5%
sqrt-div26.5%
metadata-eval26.5%
sqrt-pow126.5%
metadata-eval26.5%
pow126.5%
metadata-eval26.5%
Applied egg-rr26.5%
unpow1/326.5%
Simplified26.5%
if 2.1499999999999999e153 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 97.4%
Simplified97.4%
Taylor expanded in re around 0 66.9%
Final simplification60.6%
(FPCore (re im)
:precision binary64
(if (<= im 700.0)
(sin re)
(if (<= im 1.5e+99)
(/ 0.25 (pow re 2.0))
(* re (+ (* 0.5 (pow im 2.0)) 1.0)))))
double code(double re, double im) {
double tmp;
if (im <= 700.0) {
tmp = sin(re);
} else if (im <= 1.5e+99) {
tmp = 0.25 / pow(re, 2.0);
} 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 <= 700.0d0) then
tmp = sin(re)
else if (im <= 1.5d+99) then
tmp = 0.25d0 / (re ** 2.0d0)
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 <= 700.0) {
tmp = Math.sin(re);
} else if (im <= 1.5e+99) {
tmp = 0.25 / Math.pow(re, 2.0);
} else {
tmp = re * ((0.5 * Math.pow(im, 2.0)) + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 700.0: tmp = math.sin(re) elif im <= 1.5e+99: tmp = 0.25 / math.pow(re, 2.0) else: tmp = re * ((0.5 * math.pow(im, 2.0)) + 1.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 700.0) tmp = sin(re); elseif (im <= 1.5e+99) tmp = Float64(0.25 / (re ^ 2.0)); 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 <= 700.0) tmp = sin(re); elseif (im <= 1.5e+99) tmp = 0.25 / (re ^ 2.0); else tmp = re * ((0.5 * (im ^ 2.0)) + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 700.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.5e+99], N[(0.25 / N[Power[re, 2.0], $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 700:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.5 \cdot 10^{+99}:\\
\;\;\;\;\frac{0.25}{{re}^{2}}\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot {im}^{2} + 1\right)\\
\end{array}
\end{array}
if im < 700Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 67.7%
if 700 < im < 1.50000000000000007e99Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr20.1%
Taylor expanded in re around 0 20.0%
if 1.50000000000000007e99 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 76.2%
Simplified76.2%
Taylor expanded in re around 0 58.2%
Final simplification60.0%
(FPCore (re im) :precision binary64 (if (<= im 580.0) (sin re) (if (<= im 1.75e+99) (/ 0.25 (pow re 2.0)) (* (pow im 2.0) (* 0.5 re)))))
double code(double re, double im) {
double tmp;
if (im <= 580.0) {
tmp = sin(re);
} else if (im <= 1.75e+99) {
tmp = 0.25 / pow(re, 2.0);
} else {
tmp = pow(im, 2.0) * (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 <= 580.0d0) then
tmp = sin(re)
else if (im <= 1.75d+99) then
tmp = 0.25d0 / (re ** 2.0d0)
else
tmp = (im ** 2.0d0) * (0.5d0 * re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 580.0) {
tmp = Math.sin(re);
} else if (im <= 1.75e+99) {
tmp = 0.25 / Math.pow(re, 2.0);
} else {
tmp = Math.pow(im, 2.0) * (0.5 * re);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 580.0: tmp = math.sin(re) elif im <= 1.75e+99: tmp = 0.25 / math.pow(re, 2.0) else: tmp = math.pow(im, 2.0) * (0.5 * re) return tmp
function code(re, im) tmp = 0.0 if (im <= 580.0) tmp = sin(re); elseif (im <= 1.75e+99) tmp = Float64(0.25 / (re ^ 2.0)); else tmp = Float64((im ^ 2.0) * Float64(0.5 * re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 580.0) tmp = sin(re); elseif (im <= 1.75e+99) tmp = 0.25 / (re ^ 2.0); else tmp = (im ^ 2.0) * (0.5 * re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 580.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.75e+99], N[(0.25 / N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision], N[(N[Power[im, 2.0], $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 580:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.75 \cdot 10^{+99}:\\
\;\;\;\;\frac{0.25}{{re}^{2}}\\
\mathbf{else}:\\
\;\;\;\;{im}^{2} \cdot \left(0.5 \cdot re\right)\\
\end{array}
\end{array}
if im < 580Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 67.7%
if 580 < im < 1.7499999999999999e99Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr20.1%
Taylor expanded in re around 0 20.0%
if 1.7499999999999999e99 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 76.2%
Simplified76.2%
Taylor expanded in re around 0 58.2%
Taylor expanded in im around inf 58.2%
*-commutative58.2%
associate-*r*58.2%
Simplified58.2%
Final simplification60.0%
(FPCore (re im) :precision binary64 (if (<= im 620.0) (sin re) (* 0.25 (pow re -2.0))))
double code(double re, double im) {
double tmp;
if (im <= 620.0) {
tmp = sin(re);
} else {
tmp = 0.25 * pow(re, -2.0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 620.0d0) then
tmp = sin(re)
else
tmp = 0.25d0 * (re ** (-2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 620.0) {
tmp = Math.sin(re);
} else {
tmp = 0.25 * Math.pow(re, -2.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 620.0: tmp = math.sin(re) else: tmp = 0.25 * math.pow(re, -2.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 620.0) tmp = sin(re); else tmp = Float64(0.25 * (re ^ -2.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 620.0) tmp = sin(re); else tmp = 0.25 * (re ^ -2.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 620.0], N[Sin[re], $MachinePrecision], N[(0.25 * N[Power[re, -2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 620:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot {re}^{-2}\\
\end{array}
\end{array}
if im < 620Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 67.7%
if 620 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr15.9%
Taylor expanded in re around 0 15.8%
clear-num15.8%
associate-/r/16.7%
pow-flip16.7%
metadata-eval16.7%
Applied egg-rr16.7%
Final simplification51.9%
(FPCore (re im) :precision binary64 (if (<= im 680.0) (sin re) (* (/ 0.5 re) (/ 0.5 re))))
double code(double re, double im) {
double tmp;
if (im <= 680.0) {
tmp = sin(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 <= 680.0d0) then
tmp = sin(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 <= 680.0) {
tmp = Math.sin(re);
} else {
tmp = (0.5 / re) * (0.5 / re);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 680.0: tmp = math.sin(re) else: tmp = (0.5 / re) * (0.5 / re) return tmp
function code(re, im) tmp = 0.0 if (im <= 680.0) tmp = sin(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 <= 680.0) tmp = sin(re); else tmp = (0.5 / re) * (0.5 / re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 680.0], N[Sin[re], $MachinePrecision], N[(N[(0.5 / re), $MachinePrecision] * N[(0.5 / re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 680:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{re} \cdot \frac{0.5}{re}\\
\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%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 67.7%
if 680 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr15.9%
Taylor expanded in re around 0 15.8%
add-sqr-sqrt15.8%
sqrt-div15.8%
metadata-eval15.8%
sqrt-pow123.9%
metadata-eval23.9%
pow123.9%
sqrt-div23.9%
metadata-eval23.9%
sqrt-pow115.8%
metadata-eval15.8%
pow115.8%
Applied egg-rr15.8%
(FPCore (re im) :precision binary64 (if (<= im 240.0) re (* (/ 0.5 re) (/ 0.5 re))))
double code(double re, double im) {
double tmp;
if (im <= 240.0) {
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 <= 240.0d0) 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 <= 240.0) {
tmp = re;
} else {
tmp = (0.5 / re) * (0.5 / re);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 240.0: tmp = re else: tmp = (0.5 / re) * (0.5 / re) return tmp
function code(re, im) tmp = 0.0 if (im <= 240.0) 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 <= 240.0) tmp = re; else tmp = (0.5 / re) * (0.5 / re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 240.0], re, N[(N[(0.5 / re), $MachinePrecision] * N[(0.5 / re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 240:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{re} \cdot \frac{0.5}{re}\\
\end{array}
\end{array}
if im < 240Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in re around 0 58.7%
Simplified58.7%
Taylor expanded in im around 0 34.6%
if 240 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr15.7%
Taylor expanded in re around 0 15.6%
add-sqr-sqrt15.6%
sqrt-div15.6%
metadata-eval15.6%
sqrt-pow123.7%
metadata-eval23.7%
pow123.7%
sqrt-div23.7%
metadata-eval23.7%
sqrt-pow115.6%
metadata-eval15.6%
pow115.6%
Applied egg-rr15.6%
(FPCore (re im) :precision binary64 (if (<= re 22.0) re -1.0))
double code(double re, double im) {
double tmp;
if (re <= 22.0) {
tmp = re;
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 22.0d0) then
tmp = re
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 22.0) {
tmp = re;
} else {
tmp = -1.0;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 22.0: tmp = re else: tmp = -1.0 return tmp
function code(re, im) tmp = 0.0 if (re <= 22.0) tmp = re; else tmp = -1.0; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 22.0) tmp = re; else tmp = -1.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 22.0], re, -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 22:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if re < 22Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in re around 0 73.6%
Simplified73.6%
Taylor expanded in im around 0 30.7%
if 22 < re Initial program 100.0%
distribute-rgt-in99.9%
cancel-sign-sub99.9%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 69.1%
Simplified69.1%
Applied egg-rr5.7%
(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%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 71.1%
Simplified71.1%
Applied egg-rr5.1%
(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%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 71.1%
Simplified71.1%
Applied egg-rr4.9%
(FPCore (re im) :precision binary64 0.25)
double code(double re, double im) {
return 0.25;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.25d0
end function
public static double code(double re, double im) {
return 0.25;
}
def code(re, im): return 0.25
function code(re, im) return 0.25 end
function tmp = code(re, im) tmp = 0.25; end
code[re_, im_] := 0.25
\begin{array}{l}
\\
0.25
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 71.1%
Simplified71.1%
Applied egg-rr4.8%
(FPCore (re im) :precision binary64 0.125)
double code(double re, double im) {
return 0.125;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.125d0
end function
public static double code(double re, double im) {
return 0.125;
}
def code(re, im): return 0.125
function code(re, im) return 0.125 end
function tmp = code(re, im) tmp = 0.125; end
code[re_, im_] := 0.125
\begin{array}{l}
\\
0.125
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 71.1%
Simplified71.1%
Applied egg-rr4.6%
(FPCore (re im) :precision binary64 0.0625)
double code(double re, double im) {
return 0.0625;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.0625d0
end function
public static double code(double re, double im) {
return 0.0625;
}
def code(re, im): return 0.0625
function code(re, im) return 0.0625 end
function tmp = code(re, im) tmp = 0.0625; end
code[re_, im_] := 0.0625
\begin{array}{l}
\\
0.0625
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 71.1%
Simplified71.1%
Applied egg-rr4.5%
(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%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 71.1%
Simplified71.1%
Applied egg-rr3.9%
(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%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 71.1%
Simplified71.1%
Applied egg-rr3.6%
herbie shell --seed 2024103
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))