
(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 9 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%
Final simplification100.0%
(FPCore (re im) :precision binary64 (if (or (<= im 460.0) (not (<= im 2e+152))) (* (sin re) (+ (* 0.5 (* im im)) 1.0)) (* (* 0.5 re) (+ (exp (- im)) (exp im)))))
double code(double re, double im) {
double tmp;
if ((im <= 460.0) || !(im <= 2e+152)) {
tmp = sin(re) * ((0.5 * (im * im)) + 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 <= 460.0d0) .or. (.not. (im <= 2d+152))) then
tmp = sin(re) * ((0.5d0 * (im * im)) + 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 <= 460.0) || !(im <= 2e+152)) {
tmp = Math.sin(re) * ((0.5 * (im * im)) + 1.0);
} else {
tmp = (0.5 * re) * (Math.exp(-im) + Math.exp(im));
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= 460.0) or not (im <= 2e+152): tmp = math.sin(re) * ((0.5 * (im * im)) + 1.0) else: tmp = (0.5 * re) * (math.exp(-im) + math.exp(im)) return tmp
function code(re, im) tmp = 0.0 if ((im <= 460.0) || !(im <= 2e+152)) tmp = Float64(sin(re) * Float64(Float64(0.5 * Float64(im * im)) + 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 <= 460.0) || ~((im <= 2e+152))) tmp = sin(re) * ((0.5 * (im * im)) + 1.0); else tmp = (0.5 * re) * (exp(-im) + exp(im)); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, 460.0], N[Not[LessEqual[im, 2e+152]], $MachinePrecision]], N[(N[Sin[re], $MachinePrecision] * N[(N[(0.5 * N[(im * im), $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 460 \lor \neg \left(im \leq 2 \cdot 10^{+152}\right):\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot \left(im \cdot im\right) + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{-im} + e^{im}\right)\\
\end{array}
\end{array}
if im < 460 or 2.0000000000000001e152 < 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 83.4%
Simplified83.4%
unpow245.1%
Applied egg-rr83.4%
if 460 < im < 2.0000000000000001e152Initial 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 69.7%
Simplified69.7%
Final simplification81.6%
(FPCore (re im) :precision binary64 (if (or (<= im 195000.0) (not (<= im 1.35e+154))) (* (sin re) (+ (* 0.5 (* im im)) 1.0)) (sqrt (/ 0.0625 (pow re 4.0)))))
double code(double re, double im) {
double tmp;
if ((im <= 195000.0) || !(im <= 1.35e+154)) {
tmp = sin(re) * ((0.5 * (im * im)) + 1.0);
} else {
tmp = sqrt((0.0625 / pow(re, 4.0)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= 195000.0d0) .or. (.not. (im <= 1.35d+154))) then
tmp = sin(re) * ((0.5d0 * (im * im)) + 1.0d0)
else
tmp = sqrt((0.0625d0 / (re ** 4.0d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= 195000.0) || !(im <= 1.35e+154)) {
tmp = Math.sin(re) * ((0.5 * (im * im)) + 1.0);
} else {
tmp = Math.sqrt((0.0625 / Math.pow(re, 4.0)));
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= 195000.0) or not (im <= 1.35e+154): tmp = math.sin(re) * ((0.5 * (im * im)) + 1.0) else: tmp = math.sqrt((0.0625 / math.pow(re, 4.0))) return tmp
function code(re, im) tmp = 0.0 if ((im <= 195000.0) || !(im <= 1.35e+154)) tmp = Float64(sin(re) * Float64(Float64(0.5 * Float64(im * im)) + 1.0)); else tmp = sqrt(Float64(0.0625 / (re ^ 4.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= 195000.0) || ~((im <= 1.35e+154))) tmp = sin(re) * ((0.5 * (im * im)) + 1.0); else tmp = sqrt((0.0625 / (re ^ 4.0))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, 195000.0], N[Not[LessEqual[im, 1.35e+154]], $MachinePrecision]], N[(N[Sin[re], $MachinePrecision] * N[(N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(0.0625 / N[Power[re, 4.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 195000 \lor \neg \left(im \leq 1.35 \cdot 10^{+154}\right):\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot \left(im \cdot im\right) + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{0.0625}{{re}^{4}}}\\
\end{array}
\end{array}
if im < 195000 or 1.35000000000000003e154 < 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 83.4%
Simplified83.4%
unpow245.1%
Applied egg-rr83.4%
if 195000 < im < 1.35000000000000003e154Initial 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-rr19.2%
Taylor expanded in re around 0 19.1%
add-sqr-sqrt19.1%
sqrt-unprod19.1%
frac-times19.1%
metadata-eval19.1%
pow-prod-up19.1%
metadata-eval19.1%
Applied egg-rr19.1%
Final simplification75.1%
(FPCore (re im) :precision binary64 (if (or (<= im 195000.0) (not (<= im 1.35e+154))) (* (sin re) (+ (* 0.5 (* im im)) 1.0)) (/ -0.25 (* re (- re)))))
double code(double re, double im) {
double tmp;
if ((im <= 195000.0) || !(im <= 1.35e+154)) {
tmp = sin(re) * ((0.5 * (im * im)) + 1.0);
} 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 <= 195000.0d0) .or. (.not. (im <= 1.35d+154))) then
tmp = sin(re) * ((0.5d0 * (im * im)) + 1.0d0)
else
tmp = (-0.25d0) / (re * -re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= 195000.0) || !(im <= 1.35e+154)) {
tmp = Math.sin(re) * ((0.5 * (im * im)) + 1.0);
} else {
tmp = -0.25 / (re * -re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= 195000.0) or not (im <= 1.35e+154): tmp = math.sin(re) * ((0.5 * (im * im)) + 1.0) else: tmp = -0.25 / (re * -re) return tmp
function code(re, im) tmp = 0.0 if ((im <= 195000.0) || !(im <= 1.35e+154)) tmp = Float64(sin(re) * Float64(Float64(0.5 * Float64(im * im)) + 1.0)); else tmp = Float64(-0.25 / Float64(re * Float64(-re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= 195000.0) || ~((im <= 1.35e+154))) tmp = sin(re) * ((0.5 * (im * im)) + 1.0); else tmp = -0.25 / (re * -re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, 195000.0], N[Not[LessEqual[im, 1.35e+154]], $MachinePrecision]], N[(N[Sin[re], $MachinePrecision] * N[(N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(-0.25 / N[(re * (-re)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 195000 \lor \neg \left(im \leq 1.35 \cdot 10^{+154}\right):\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot \left(im \cdot im\right) + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.25}{re \cdot \left(-re\right)}\\
\end{array}
\end{array}
if im < 195000 or 1.35000000000000003e154 < 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 83.4%
Simplified83.4%
unpow245.1%
Applied egg-rr83.4%
if 195000 < im < 1.35000000000000003e154Initial 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-rr19.2%
Taylor expanded in re around 0 19.1%
add-sqr-sqrt19.1%
sqrt-div19.1%
metadata-eval19.1%
sqrt-pow134.9%
metadata-eval34.9%
pow134.9%
sqrt-div34.9%
metadata-eval34.9%
sqrt-pow119.1%
metadata-eval19.1%
pow119.1%
Applied egg-rr19.1%
frac-2neg19.1%
frac-times19.1%
metadata-eval19.1%
metadata-eval19.1%
Applied egg-rr19.1%
Final simplification75.1%
(FPCore (re im)
:precision binary64
(if (<= im 195000.0)
(sin re)
(if (<= im 1e+154)
(/ -0.25 (* re (- re)))
(* re (+ (* 0.5 (* im im)) 1.0)))))
double code(double re, double im) {
double tmp;
if (im <= 195000.0) {
tmp = sin(re);
} else if (im <= 1e+154) {
tmp = -0.25 / (re * -re);
} else {
tmp = re * ((0.5 * (im * im)) + 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 <= 195000.0d0) then
tmp = sin(re)
else if (im <= 1d+154) then
tmp = (-0.25d0) / (re * -re)
else
tmp = re * ((0.5d0 * (im * im)) + 1.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 195000.0) {
tmp = Math.sin(re);
} else if (im <= 1e+154) {
tmp = -0.25 / (re * -re);
} else {
tmp = re * ((0.5 * (im * im)) + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 195000.0: tmp = math.sin(re) elif im <= 1e+154: tmp = -0.25 / (re * -re) else: tmp = re * ((0.5 * (im * im)) + 1.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 195000.0) tmp = sin(re); elseif (im <= 1e+154) tmp = Float64(-0.25 / Float64(re * Float64(-re))); else tmp = Float64(re * Float64(Float64(0.5 * Float64(im * im)) + 1.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 195000.0) tmp = sin(re); elseif (im <= 1e+154) tmp = -0.25 / (re * -re); else tmp = re * ((0.5 * (im * im)) + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 195000.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1e+154], N[(-0.25 / N[(re * (-re)), $MachinePrecision]), $MachinePrecision], N[(re * N[(N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 195000:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 10^{+154}:\\
\;\;\;\;\frac{-0.25}{re \cdot \left(-re\right)}\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot \left(im \cdot im\right) + 1\right)\\
\end{array}
\end{array}
if im < 195000Initial 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.5%
if 195000 < im < 1.00000000000000004e154Initial 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-rr19.2%
Taylor expanded in re around 0 19.1%
add-sqr-sqrt19.1%
sqrt-div19.1%
metadata-eval19.1%
sqrt-pow134.9%
metadata-eval34.9%
pow134.9%
sqrt-div34.9%
metadata-eval34.9%
sqrt-pow119.1%
metadata-eval19.1%
pow119.1%
Applied egg-rr19.1%
frac-2neg19.1%
frac-times19.1%
metadata-eval19.1%
metadata-eval19.1%
Applied egg-rr19.1%
if 1.00000000000000004e154 < 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 re around 0 72.0%
unpow272.0%
Applied egg-rr72.0%
Final simplification61.7%
(FPCore (re im) :precision binary64 (if (or (<= im 195000.0) (not (<= im 1.75e+152))) (* re (+ (* 0.5 (* im im)) 1.0)) (/ -0.25 (* re (- re)))))
double code(double re, double im) {
double tmp;
if ((im <= 195000.0) || !(im <= 1.75e+152)) {
tmp = re * ((0.5 * (im * im)) + 1.0);
} 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 <= 195000.0d0) .or. (.not. (im <= 1.75d+152))) then
tmp = re * ((0.5d0 * (im * im)) + 1.0d0)
else
tmp = (-0.25d0) / (re * -re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= 195000.0) || !(im <= 1.75e+152)) {
tmp = re * ((0.5 * (im * im)) + 1.0);
} else {
tmp = -0.25 / (re * -re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= 195000.0) or not (im <= 1.75e+152): tmp = re * ((0.5 * (im * im)) + 1.0) else: tmp = -0.25 / (re * -re) return tmp
function code(re, im) tmp = 0.0 if ((im <= 195000.0) || !(im <= 1.75e+152)) tmp = Float64(re * Float64(Float64(0.5 * Float64(im * im)) + 1.0)); else tmp = Float64(-0.25 / Float64(re * Float64(-re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= 195000.0) || ~((im <= 1.75e+152))) tmp = re * ((0.5 * (im * im)) + 1.0); else tmp = -0.25 / (re * -re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, 195000.0], N[Not[LessEqual[im, 1.75e+152]], $MachinePrecision]], N[(re * N[(N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(-0.25 / N[(re * (-re)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 195000 \lor \neg \left(im \leq 1.75 \cdot 10^{+152}\right):\\
\;\;\;\;re \cdot \left(0.5 \cdot \left(im \cdot im\right) + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.25}{re \cdot \left(-re\right)}\\
\end{array}
\end{array}
if im < 195000 or 1.74999999999999991e152 < 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 83.4%
Simplified83.4%
Taylor expanded in re around 0 45.1%
unpow245.1%
Applied egg-rr45.1%
if 195000 < im < 1.74999999999999991e152Initial 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-rr19.2%
Taylor expanded in re around 0 19.1%
add-sqr-sqrt19.1%
sqrt-div19.1%
metadata-eval19.1%
sqrt-pow134.9%
metadata-eval34.9%
pow134.9%
sqrt-div34.9%
metadata-eval34.9%
sqrt-pow119.1%
metadata-eval19.1%
pow119.1%
Applied egg-rr19.1%
frac-2neg19.1%
frac-times19.1%
metadata-eval19.1%
metadata-eval19.1%
Applied egg-rr19.1%
Final simplification41.8%
(FPCore (re im) :precision binary64 (if (<= im 195000.0) re (/ -0.25 (* re (- re)))))
double code(double re, double im) {
double tmp;
if (im <= 195000.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 <= 195000.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 <= 195000.0) {
tmp = re;
} else {
tmp = -0.25 / (re * -re);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 195000.0: tmp = re else: tmp = -0.25 / (re * -re) return tmp
function code(re, im) tmp = 0.0 if (im <= 195000.0) tmp = re; else tmp = Float64(-0.25 / Float64(re * Float64(-re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 195000.0) tmp = re; else tmp = -0.25 / (re * -re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 195000.0], re, N[(-0.25 / N[(re * (-re)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 195000:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.25}{re \cdot \left(-re\right)}\\
\end{array}
\end{array}
if im < 195000Initial 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 81.3%
Simplified81.3%
Taylor expanded in re around 0 41.7%
Taylor expanded in im around 0 30.3%
if 195000 < 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-rr16.9%
Taylor expanded in re around 0 16.7%
add-sqr-sqrt16.7%
sqrt-div16.7%
metadata-eval16.7%
sqrt-pow137.8%
metadata-eval37.8%
pow137.8%
sqrt-div37.8%
metadata-eval37.8%
sqrt-pow116.7%
metadata-eval16.7%
pow116.7%
Applied egg-rr16.7%
frac-2neg16.7%
frac-times16.7%
metadata-eval16.7%
metadata-eval16.7%
Applied egg-rr16.7%
Final simplification27.3%
(FPCore (re im) :precision binary64 (if (<= im 195000.0) re (/ (/ 0.25 re) re)))
double code(double re, double im) {
double tmp;
if (im <= 195000.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 <= 195000.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 <= 195000.0) {
tmp = re;
} else {
tmp = (0.25 / re) / re;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 195000.0: tmp = re else: tmp = (0.25 / re) / re return tmp
function code(re, im) tmp = 0.0 if (im <= 195000.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 <= 195000.0) tmp = re; else tmp = (0.25 / re) / re; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 195000.0], re, N[(N[(0.25 / re), $MachinePrecision] / re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 195000:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.25}{re}}{re}\\
\end{array}
\end{array}
if im < 195000Initial 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 81.3%
Simplified81.3%
Taylor expanded in re around 0 41.7%
Taylor expanded in im around 0 30.3%
if 195000 < 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-rr16.9%
Taylor expanded in re around 0 16.7%
add-sqr-sqrt16.7%
sqrt-div16.7%
metadata-eval16.7%
sqrt-pow137.8%
metadata-eval37.8%
pow137.8%
sqrt-div37.8%
metadata-eval37.8%
sqrt-pow116.7%
metadata-eval16.7%
pow116.7%
Applied egg-rr16.7%
associate-*l/16.7%
associate-*r/16.7%
metadata-eval16.7%
Applied egg-rr16.7%
Final simplification27.3%
(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%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 73.1%
Simplified73.1%
Taylor expanded in re around 0 41.1%
Taylor expanded in im around 0 23.9%
Final simplification23.9%
herbie shell --seed 2024095
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))