
(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 (<= im 0.0016)
(sin re)
(if (<= im 2.9e+71)
(* (+ (exp (- im)) (exp im)) (* 0.5 re))
(* 0.041666666666666664 (* (sin re) (pow im 4.0))))))
double code(double re, double im) {
double tmp;
if (im <= 0.0016) {
tmp = sin(re);
} else if (im <= 2.9e+71) {
tmp = (exp(-im) + exp(im)) * (0.5 * re);
} else {
tmp = 0.041666666666666664 * (sin(re) * pow(im, 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 <= 0.0016d0) then
tmp = sin(re)
else if (im <= 2.9d+71) then
tmp = (exp(-im) + exp(im)) * (0.5d0 * re)
else
tmp = 0.041666666666666664d0 * (sin(re) * (im ** 4.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 0.0016) {
tmp = Math.sin(re);
} else if (im <= 2.9e+71) {
tmp = (Math.exp(-im) + Math.exp(im)) * (0.5 * re);
} else {
tmp = 0.041666666666666664 * (Math.sin(re) * Math.pow(im, 4.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.0016: tmp = math.sin(re) elif im <= 2.9e+71: tmp = (math.exp(-im) + math.exp(im)) * (0.5 * re) else: tmp = 0.041666666666666664 * (math.sin(re) * math.pow(im, 4.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 0.0016) tmp = sin(re); elseif (im <= 2.9e+71) tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 * re)); else tmp = Float64(0.041666666666666664 * Float64(sin(re) * (im ^ 4.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.0016) tmp = sin(re); elseif (im <= 2.9e+71) tmp = (exp(-im) + exp(im)) * (0.5 * re); else tmp = 0.041666666666666664 * (sin(re) * (im ^ 4.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.0016], N[Sin[re], $MachinePrecision], If[LessEqual[im, 2.9e+71], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(0.041666666666666664 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.0016:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 2.9 \cdot 10^{+71}:\\
\;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;0.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\right)\\
\end{array}
\end{array}
if im < 0.00160000000000000008Initial 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 69.3%
if 0.00160000000000000008 < im < 2.90000000000000007e71Initial program 99.9%
distribute-rgt-in99.9%
cancel-sign-sub99.9%
distribute-rgt-out--99.9%
sub-neg99.9%
remove-double-neg99.9%
neg-sub099.9%
Simplified99.9%
Taylor expanded in re around 0 86.6%
Simplified86.6%
if 2.90000000000000007e71 < 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 98.2%
Simplified98.2%
Taylor expanded in im around inf 100.0%
Final simplification76.4%
(FPCore (re im)
:precision binary64
(if (<= im 0.0054)
(* (sin re) (+ (* 0.5 (pow im 2.0)) 1.0))
(if (<= im 2.9e+71)
(* (+ (exp (- im)) (exp im)) (* 0.5 re))
(* 0.041666666666666664 (* (sin re) (pow im 4.0))))))
double code(double re, double im) {
double tmp;
if (im <= 0.0054) {
tmp = sin(re) * ((0.5 * pow(im, 2.0)) + 1.0);
} else if (im <= 2.9e+71) {
tmp = (exp(-im) + exp(im)) * (0.5 * re);
} else {
tmp = 0.041666666666666664 * (sin(re) * pow(im, 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 <= 0.0054d0) then
tmp = sin(re) * ((0.5d0 * (im ** 2.0d0)) + 1.0d0)
else if (im <= 2.9d+71) then
tmp = (exp(-im) + exp(im)) * (0.5d0 * re)
else
tmp = 0.041666666666666664d0 * (sin(re) * (im ** 4.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 0.0054) {
tmp = Math.sin(re) * ((0.5 * Math.pow(im, 2.0)) + 1.0);
} else if (im <= 2.9e+71) {
tmp = (Math.exp(-im) + Math.exp(im)) * (0.5 * re);
} else {
tmp = 0.041666666666666664 * (Math.sin(re) * Math.pow(im, 4.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.0054: tmp = math.sin(re) * ((0.5 * math.pow(im, 2.0)) + 1.0) elif im <= 2.9e+71: tmp = (math.exp(-im) + math.exp(im)) * (0.5 * re) else: tmp = 0.041666666666666664 * (math.sin(re) * math.pow(im, 4.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 0.0054) tmp = Float64(sin(re) * Float64(Float64(0.5 * (im ^ 2.0)) + 1.0)); elseif (im <= 2.9e+71) tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 * re)); else tmp = Float64(0.041666666666666664 * Float64(sin(re) * (im ^ 4.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.0054) tmp = sin(re) * ((0.5 * (im ^ 2.0)) + 1.0); elseif (im <= 2.9e+71) tmp = (exp(-im) + exp(im)) * (0.5 * re); else tmp = 0.041666666666666664 * (sin(re) * (im ^ 4.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.0054], N[(N[Sin[re], $MachinePrecision] * N[(N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.9e+71], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(0.041666666666666664 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.0054:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2} + 1\right)\\
\mathbf{elif}\;im \leq 2.9 \cdot 10^{+71}:\\
\;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;0.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\right)\\
\end{array}
\end{array}
if im < 0.0054000000000000003Initial 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 86.3%
Simplified86.3%
if 0.0054000000000000003 < im < 2.90000000000000007e71Initial program 99.9%
distribute-rgt-in99.9%
cancel-sign-sub99.9%
distribute-rgt-out--99.9%
sub-neg99.9%
remove-double-neg99.9%
neg-sub099.9%
Simplified99.9%
Taylor expanded in re around 0 86.6%
Simplified86.6%
if 2.90000000000000007e71 < 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 98.2%
Simplified98.2%
Taylor expanded in im around inf 100.0%
Final simplification89.0%
(FPCore (re im)
:precision binary64
(if (<= im 55.0)
(sin re)
(if (<= im 4.9e+68)
(log1p (expm1 re))
(* 0.041666666666666664 (* (sin re) (pow im 4.0))))))
double code(double re, double im) {
double tmp;
if (im <= 55.0) {
tmp = sin(re);
} else if (im <= 4.9e+68) {
tmp = log1p(expm1(re));
} else {
tmp = 0.041666666666666664 * (sin(re) * pow(im, 4.0));
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (im <= 55.0) {
tmp = Math.sin(re);
} else if (im <= 4.9e+68) {
tmp = Math.log1p(Math.expm1(re));
} else {
tmp = 0.041666666666666664 * (Math.sin(re) * Math.pow(im, 4.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 55.0: tmp = math.sin(re) elif im <= 4.9e+68: tmp = math.log1p(math.expm1(re)) else: tmp = 0.041666666666666664 * (math.sin(re) * math.pow(im, 4.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 55.0) tmp = sin(re); elseif (im <= 4.9e+68) tmp = log1p(expm1(re)); else tmp = Float64(0.041666666666666664 * Float64(sin(re) * (im ^ 4.0))); end return tmp end
code[re_, im_] := If[LessEqual[im, 55.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 4.9e+68], N[Log[1 + N[(Exp[re] - 1), $MachinePrecision]], $MachinePrecision], N[(0.041666666666666664 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 55:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 4.9 \cdot 10^{+68}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\right)\\
\end{array}
\end{array}
if im < 55Initial 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 69.1%
if 55 < im < 4.89999999999999978e68Initial 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 84.6%
Simplified84.6%
Applied egg-rr32.4%
if 4.89999999999999978e68 < 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 96.4%
Simplified96.4%
Taylor expanded in im around inf 98.2%
Final simplification73.2%
(FPCore (re im)
:precision binary64
(if (<= im 680.0)
(sin re)
(if (<= im 1.85e+67)
(pow re -8.0)
(* 0.041666666666666664 (* re (pow im 4.0))))))
double code(double re, double im) {
double tmp;
if (im <= 680.0) {
tmp = sin(re);
} else if (im <= 1.85e+67) {
tmp = pow(re, -8.0);
} else {
tmp = 0.041666666666666664 * (re * pow(im, 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 <= 680.0d0) then
tmp = sin(re)
else if (im <= 1.85d+67) then
tmp = re ** (-8.0d0)
else
tmp = 0.041666666666666664d0 * (re * (im ** 4.0d0))
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 if (im <= 1.85e+67) {
tmp = Math.pow(re, -8.0);
} else {
tmp = 0.041666666666666664 * (re * Math.pow(im, 4.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 680.0: tmp = math.sin(re) elif im <= 1.85e+67: tmp = math.pow(re, -8.0) else: tmp = 0.041666666666666664 * (re * math.pow(im, 4.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 680.0) tmp = sin(re); elseif (im <= 1.85e+67) tmp = re ^ -8.0; else tmp = Float64(0.041666666666666664 * Float64(re * (im ^ 4.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 680.0) tmp = sin(re); elseif (im <= 1.85e+67) tmp = re ^ -8.0; else tmp = 0.041666666666666664 * (re * (im ^ 4.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 680.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.85e+67], N[Power[re, -8.0], $MachinePrecision], N[(0.041666666666666664 * N[(re * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 680:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.85 \cdot 10^{+67}:\\
\;\;\;\;{re}^{-8}\\
\mathbf{else}:\\
\;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\
\end{array}
\end{array}
if im < 680Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 68.8%
if 680 < im < 1.8499999999999999e67Initial 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 81.8%
Simplified81.8%
Applied egg-rr37.1%
if 1.8499999999999999e67 < 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 94.7%
Simplified94.7%
Taylor expanded in im around inf 96.5%
Taylor expanded in re around 0 73.7%
Final simplification68.5%
(FPCore (re im) :precision binary64 (if (<= im 700.0) (sin re) (pow re -8.0)))
double code(double re, double im) {
double tmp;
if (im <= 700.0) {
tmp = sin(re);
} else {
tmp = pow(re, -8.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
tmp = re ** (-8.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 {
tmp = Math.pow(re, -8.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 700.0: tmp = math.sin(re) else: tmp = math.pow(re, -8.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 700.0) tmp = sin(re); else tmp = re ^ -8.0; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 700.0) tmp = sin(re); else tmp = re ^ -8.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 700.0], N[Sin[re], $MachinePrecision], N[Power[re, -8.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 700:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;{re}^{-8}\\
\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 68.8%
if 700 < 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 re around 0 76.6%
Simplified76.6%
Applied egg-rr30.6%
Final simplification59.3%
(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%
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 52.3%
Final simplification52.3%
(FPCore (re im) :precision binary64 (if (<= re 0.000235) re (/ re (+ re (- re re)))))
double code(double re, double im) {
double tmp;
if (re <= 0.000235) {
tmp = re;
} else {
tmp = re / (re + (re - re));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 0.000235d0) then
tmp = re
else
tmp = re / (re + (re - re))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 0.000235) {
tmp = re;
} else {
tmp = re / (re + (re - re));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 0.000235: tmp = re else: tmp = re / (re + (re - re)) return tmp
function code(re, im) tmp = 0.0 if (re <= 0.000235) tmp = re; else tmp = Float64(re / Float64(re + Float64(re - re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 0.000235) tmp = re; else tmp = re / (re + (re - re)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 0.000235], re, N[(re / N[(re + N[(re - re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 0.000235:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;\frac{re}{re + \left(re - re\right)}\\
\end{array}
\end{array}
if re < 2.34999999999999993e-4Initial 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 75.0%
Simplified75.0%
Taylor expanded in im around 0 33.5%
if 2.34999999999999993e-4 < re 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 re around 0 23.4%
Simplified23.4%
Applied egg-rr6.8%
Final simplification26.7%
(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 re around 0 61.9%
Simplified61.9%
Taylor expanded in im around 0 25.8%
Final simplification25.8%
herbie shell --seed 2024130
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))