
(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%
sub0-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (re im)
:precision binary64
(if (or (<= im -1.35e+154)
(not (or (<= im -2.6) (and (not (<= im 1.95)) (<= im 1.2e+247)))))
(+ (sin re) (* 0.5 (* im (* (sin re) im))))
(* (* 0.5 re) (+ (exp (- im)) (exp im)))))
double code(double re, double im) {
double tmp;
if ((im <= -1.35e+154) || !((im <= -2.6) || (!(im <= 1.95) && (im <= 1.2e+247)))) {
tmp = sin(re) + (0.5 * (im * (sin(re) * im)));
} 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 <= (-1.35d+154)) .or. (.not. (im <= (-2.6d0)) .or. (.not. (im <= 1.95d0)) .and. (im <= 1.2d+247))) then
tmp = sin(re) + (0.5d0 * (im * (sin(re) * im)))
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 <= -1.35e+154) || !((im <= -2.6) || (!(im <= 1.95) && (im <= 1.2e+247)))) {
tmp = Math.sin(re) + (0.5 * (im * (Math.sin(re) * im)));
} else {
tmp = (0.5 * re) * (Math.exp(-im) + Math.exp(im));
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -1.35e+154) or not ((im <= -2.6) or (not (im <= 1.95) and (im <= 1.2e+247))): tmp = math.sin(re) + (0.5 * (im * (math.sin(re) * im))) else: tmp = (0.5 * re) * (math.exp(-im) + math.exp(im)) return tmp
function code(re, im) tmp = 0.0 if ((im <= -1.35e+154) || !((im <= -2.6) || (!(im <= 1.95) && (im <= 1.2e+247)))) tmp = Float64(sin(re) + Float64(0.5 * Float64(im * Float64(sin(re) * im)))); 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 <= -1.35e+154) || ~(((im <= -2.6) || (~((im <= 1.95)) && (im <= 1.2e+247))))) tmp = sin(re) + (0.5 * (im * (sin(re) * im))); else tmp = (0.5 * re) * (exp(-im) + exp(im)); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -1.35e+154], N[Not[Or[LessEqual[im, -2.6], And[N[Not[LessEqual[im, 1.95]], $MachinePrecision], LessEqual[im, 1.2e+247]]]], $MachinePrecision]], N[(N[Sin[re], $MachinePrecision] + N[(0.5 * N[(im * N[(N[Sin[re], $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]), $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 -1.35 \cdot 10^{+154} \lor \neg \left(im \leq -2.6 \lor \neg \left(im \leq 1.95\right) \land im \leq 1.2 \cdot 10^{+247}\right):\\
\;\;\;\;\sin re + 0.5 \cdot \left(im \cdot \left(\sin re \cdot im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{-im} + e^{im}\right)\\
\end{array}
\end{array}
if im < -1.35000000000000003e154 or -2.60000000000000009 < im < 1.94999999999999996 or 1.2e247 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 99.1%
Simplified99.1%
Taylor expanded in re around inf 99.1%
Simplified95.8%
if -1.35000000000000003e154 < im < -2.60000000000000009 or 1.94999999999999996 < im < 1.2e247Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 74.7%
Simplified74.7%
Final simplification88.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* 0.5 re) (+ (exp (- im)) (exp im))))
(t_1 (+ (sin re) (* (* 0.5 (sin re)) (* im im)))))
(if (<= im -1.35e+154)
t_1
(if (<= im -2.6)
t_0
(if (<= im 1.95)
(+ (sin re) (* 0.5 (* im (* (sin re) im))))
(if (<= im 1.4e+154) t_0 t_1))))))
double code(double re, double im) {
double t_0 = (0.5 * re) * (exp(-im) + exp(im));
double t_1 = sin(re) + ((0.5 * sin(re)) * (im * im));
double tmp;
if (im <= -1.35e+154) {
tmp = t_1;
} else if (im <= -2.6) {
tmp = t_0;
} else if (im <= 1.95) {
tmp = sin(re) + (0.5 * (im * (sin(re) * im)));
} else if (im <= 1.4e+154) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (0.5d0 * re) * (exp(-im) + exp(im))
t_1 = sin(re) + ((0.5d0 * sin(re)) * (im * im))
if (im <= (-1.35d+154)) then
tmp = t_1
else if (im <= (-2.6d0)) then
tmp = t_0
else if (im <= 1.95d0) then
tmp = sin(re) + (0.5d0 * (im * (sin(re) * im)))
else if (im <= 1.4d+154) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = (0.5 * re) * (Math.exp(-im) + Math.exp(im));
double t_1 = Math.sin(re) + ((0.5 * Math.sin(re)) * (im * im));
double tmp;
if (im <= -1.35e+154) {
tmp = t_1;
} else if (im <= -2.6) {
tmp = t_0;
} else if (im <= 1.95) {
tmp = Math.sin(re) + (0.5 * (im * (Math.sin(re) * im)));
} else if (im <= 1.4e+154) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = (0.5 * re) * (math.exp(-im) + math.exp(im)) t_1 = math.sin(re) + ((0.5 * math.sin(re)) * (im * im)) tmp = 0 if im <= -1.35e+154: tmp = t_1 elif im <= -2.6: tmp = t_0 elif im <= 1.95: tmp = math.sin(re) + (0.5 * (im * (math.sin(re) * im))) elif im <= 1.4e+154: tmp = t_0 else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(Float64(0.5 * re) * Float64(exp(Float64(-im)) + exp(im))) t_1 = Float64(sin(re) + Float64(Float64(0.5 * sin(re)) * Float64(im * im))) tmp = 0.0 if (im <= -1.35e+154) tmp = t_1; elseif (im <= -2.6) tmp = t_0; elseif (im <= 1.95) tmp = Float64(sin(re) + Float64(0.5 * Float64(im * Float64(sin(re) * im)))); elseif (im <= 1.4e+154) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = (0.5 * re) * (exp(-im) + exp(im)); t_1 = sin(re) + ((0.5 * sin(re)) * (im * im)); tmp = 0.0; if (im <= -1.35e+154) tmp = t_1; elseif (im <= -2.6) tmp = t_0; elseif (im <= 1.95) tmp = sin(re) + (0.5 * (im * (sin(re) * im))); elseif (im <= 1.4e+154) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * re), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[re], $MachinePrecision] + N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.35e+154], t$95$1, If[LessEqual[im, -2.6], t$95$0, If[LessEqual[im, 1.95], N[(N[Sin[re], $MachinePrecision] + N[(0.5 * N[(im * N[(N[Sin[re], $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.4e+154], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(0.5 \cdot re\right) \cdot \left(e^{-im} + e^{im}\right)\\
t_1 := \sin re + \left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im\right)\\
\mathbf{if}\;im \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -2.6:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 1.95:\\
\;\;\;\;\sin re + 0.5 \cdot \left(im \cdot \left(\sin re \cdot im\right)\right)\\
\mathbf{elif}\;im \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -1.35000000000000003e154 or 1.4e154 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
if -1.35000000000000003e154 < im < -2.60000000000000009 or 1.94999999999999996 < im < 1.4e154Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 73.0%
Simplified73.0%
if -2.60000000000000009 < im < 1.94999999999999996Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 98.8%
Simplified98.8%
Taylor expanded in re around inf 98.8%
Simplified98.8%
Final simplification91.6%
(FPCore (re im) :precision binary64 (if (or (<= im -0.000195) (not (<= im 6.2e-6))) (* (* 0.5 re) (+ (exp (- im)) (exp im))) (sin re)))
double code(double re, double im) {
double tmp;
if ((im <= -0.000195) || !(im <= 6.2e-6)) {
tmp = (0.5 * re) * (exp(-im) + exp(im));
} else {
tmp = sin(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.000195d0)) .or. (.not. (im <= 6.2d-6))) then
tmp = (0.5d0 * re) * (exp(-im) + exp(im))
else
tmp = sin(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -0.000195) || !(im <= 6.2e-6)) {
tmp = (0.5 * re) * (Math.exp(-im) + Math.exp(im));
} else {
tmp = Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -0.000195) or not (im <= 6.2e-6): tmp = (0.5 * re) * (math.exp(-im) + math.exp(im)) else: tmp = math.sin(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -0.000195) || !(im <= 6.2e-6)) tmp = Float64(Float64(0.5 * re) * Float64(exp(Float64(-im)) + exp(im))); else tmp = sin(re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -0.000195) || ~((im <= 6.2e-6))) tmp = (0.5 * re) * (exp(-im) + exp(im)); else tmp = sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -0.000195], N[Not[LessEqual[im, 6.2e-6]], $MachinePrecision]], N[(N[(0.5 * re), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[re], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -0.000195 \lor \neg \left(im \leq 6.2 \cdot 10^{-6}\right):\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re\\
\end{array}
\end{array}
if im < -1.94999999999999996e-4 or 6.1999999999999999e-6 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 68.9%
Simplified68.9%
if -1.94999999999999996e-4 < im < 6.1999999999999999e-6Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 99.8%
Final simplification83.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (+ re (* 0.5 (* re (pow im 2.0))))))
(if (<= im -5.9e+125)
t_0
(if (<= im -2300000000000.0)
(log1p (expm1 re))
(if (<= im 4e+18) (sin re) (if (<= im 9.5e+94) (pow re -512.0) t_0))))))
double code(double re, double im) {
double t_0 = re + (0.5 * (re * pow(im, 2.0)));
double tmp;
if (im <= -5.9e+125) {
tmp = t_0;
} else if (im <= -2300000000000.0) {
tmp = log1p(expm1(re));
} else if (im <= 4e+18) {
tmp = sin(re);
} else if (im <= 9.5e+94) {
tmp = pow(re, -512.0);
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = re + (0.5 * (re * Math.pow(im, 2.0)));
double tmp;
if (im <= -5.9e+125) {
tmp = t_0;
} else if (im <= -2300000000000.0) {
tmp = Math.log1p(Math.expm1(re));
} else if (im <= 4e+18) {
tmp = Math.sin(re);
} else if (im <= 9.5e+94) {
tmp = Math.pow(re, -512.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = re + (0.5 * (re * math.pow(im, 2.0))) tmp = 0 if im <= -5.9e+125: tmp = t_0 elif im <= -2300000000000.0: tmp = math.log1p(math.expm1(re)) elif im <= 4e+18: tmp = math.sin(re) elif im <= 9.5e+94: tmp = math.pow(re, -512.0) else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(re + Float64(0.5 * Float64(re * (im ^ 2.0)))) tmp = 0.0 if (im <= -5.9e+125) tmp = t_0; elseif (im <= -2300000000000.0) tmp = log1p(expm1(re)); elseif (im <= 4e+18) tmp = sin(re); elseif (im <= 9.5e+94) tmp = re ^ -512.0; else tmp = t_0; end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(re + N[(0.5 * N[(re * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -5.9e+125], t$95$0, If[LessEqual[im, -2300000000000.0], N[Log[1 + N[(Exp[re] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 4e+18], N[Sin[re], $MachinePrecision], If[LessEqual[im, 9.5e+94], N[Power[re, -512.0], $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := re + 0.5 \cdot \left(re \cdot {im}^{2}\right)\\
\mathbf{if}\;im \leq -5.9 \cdot 10^{+125}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -2300000000000:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\
\mathbf{elif}\;im \leq 4 \cdot 10^{+18}:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 9.5 \cdot 10^{+94}:\\
\;\;\;\;{re}^{-512}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -5.9000000000000001e125 or 9.4999999999999998e94 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 67.5%
Simplified67.5%
Taylor expanded in im around 0 52.1%
if -5.9000000000000001e125 < im < -2.3e12Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 70.4%
Simplified70.4%
Applied egg-rr41.4%
if -2.3e12 < im < 4e18Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 94.3%
if 4e18 < im < 9.4999999999999998e94Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 68.8%
Simplified68.8%
Applied egg-rr50.5%
Final simplification72.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (+ re (* 0.5 (* re (pow im 2.0))))))
(if (<= im -0.00019)
t_0
(if (<= im 3.9e+18) (sin re) (if (<= im 1.8e+95) (pow re -512.0) t_0)))))
double code(double re, double im) {
double t_0 = re + (0.5 * (re * pow(im, 2.0)));
double tmp;
if (im <= -0.00019) {
tmp = t_0;
} else if (im <= 3.9e+18) {
tmp = sin(re);
} else if (im <= 1.8e+95) {
tmp = pow(re, -512.0);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = re + (0.5d0 * (re * (im ** 2.0d0)))
if (im <= (-0.00019d0)) then
tmp = t_0
else if (im <= 3.9d+18) then
tmp = sin(re)
else if (im <= 1.8d+95) then
tmp = re ** (-512.0d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = re + (0.5 * (re * Math.pow(im, 2.0)));
double tmp;
if (im <= -0.00019) {
tmp = t_0;
} else if (im <= 3.9e+18) {
tmp = Math.sin(re);
} else if (im <= 1.8e+95) {
tmp = Math.pow(re, -512.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = re + (0.5 * (re * math.pow(im, 2.0))) tmp = 0 if im <= -0.00019: tmp = t_0 elif im <= 3.9e+18: tmp = math.sin(re) elif im <= 1.8e+95: tmp = math.pow(re, -512.0) else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(re + Float64(0.5 * Float64(re * (im ^ 2.0)))) tmp = 0.0 if (im <= -0.00019) tmp = t_0; elseif (im <= 3.9e+18) tmp = sin(re); elseif (im <= 1.8e+95) tmp = re ^ -512.0; else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = re + (0.5 * (re * (im ^ 2.0))); tmp = 0.0; if (im <= -0.00019) tmp = t_0; elseif (im <= 3.9e+18) tmp = sin(re); elseif (im <= 1.8e+95) tmp = re ^ -512.0; else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(re + N[(0.5 * N[(re * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -0.00019], t$95$0, If[LessEqual[im, 3.9e+18], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.8e+95], N[Power[re, -512.0], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := re + 0.5 \cdot \left(re \cdot {im}^{2}\right)\\
\mathbf{if}\;im \leq -0.00019:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 3.9 \cdot 10^{+18}:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.8 \cdot 10^{+95}:\\
\;\;\;\;{re}^{-512}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -1.9000000000000001e-4 or 1.79999999999999989e95 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 68.2%
Simplified68.2%
Taylor expanded in im around 0 43.0%
if -1.9000000000000001e-4 < im < 3.9e18Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 95.9%
if 3.9e18 < im < 1.79999999999999989e95Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 68.8%
Simplified68.8%
Applied egg-rr50.5%
Final simplification70.3%
(FPCore (re im) :precision binary64 (if (<= im -1.6e+18) (pow re -512.0) (if (<= im 3.9e+18) (sin re) (pow re -512.0))))
double code(double re, double im) {
double tmp;
if (im <= -1.6e+18) {
tmp = pow(re, -512.0);
} else if (im <= 3.9e+18) {
tmp = sin(re);
} else {
tmp = pow(re, -512.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.6d+18)) then
tmp = re ** (-512.0d0)
else if (im <= 3.9d+18) then
tmp = sin(re)
else
tmp = re ** (-512.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= -1.6e+18) {
tmp = Math.pow(re, -512.0);
} else if (im <= 3.9e+18) {
tmp = Math.sin(re);
} else {
tmp = Math.pow(re, -512.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= -1.6e+18: tmp = math.pow(re, -512.0) elif im <= 3.9e+18: tmp = math.sin(re) else: tmp = math.pow(re, -512.0) return tmp
function code(re, im) tmp = 0.0 if (im <= -1.6e+18) tmp = re ^ -512.0; elseif (im <= 3.9e+18) tmp = sin(re); else tmp = re ^ -512.0; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= -1.6e+18) tmp = re ^ -512.0; elseif (im <= 3.9e+18) tmp = sin(re); else tmp = re ^ -512.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, -1.6e+18], N[Power[re, -512.0], $MachinePrecision], If[LessEqual[im, 3.9e+18], N[Sin[re], $MachinePrecision], N[Power[re, -512.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.6 \cdot 10^{+18}:\\
\;\;\;\;{re}^{-512}\\
\mathbf{elif}\;im \leq 3.9 \cdot 10^{+18}:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;{re}^{-512}\\
\end{array}
\end{array}
if im < -1.6e18 or 3.9e18 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 68.6%
Simplified68.6%
Applied egg-rr21.5%
if -1.6e18 < im < 3.9e18Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 93.0%
Final simplification59.2%
(FPCore (re im) :precision binary64 (sin re))
double code(double re, double im) {
return sin(re);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = sin(re)
end function
public static double code(double re, double im) {
return Math.sin(re);
}
def code(re, im): return math.sin(re)
function code(re, im) return sin(re) end
function tmp = code(re, im) tmp = sin(re); end
code[re_, im_] := N[Sin[re], $MachinePrecision]
\begin{array}{l}
\\
\sin re
\end{array}
Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 50.3%
Final simplification50.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%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 61.3%
Simplified61.3%
Taylor expanded in im around 0 27.5%
Final simplification27.5%
herbie shell --seed 2023174
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))