
(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 10 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 8.0)
(* (sin re) (fma (* 0.5 im) im 1.0))
(if (<= im 2.15e+151)
(* (* 0.5 re) (+ (exp (- im)) (exp im)))
(* (sin re) (* 0.5 (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 8.0) {
tmp = sin(re) * fma((0.5 * im), im, 1.0);
} else if (im <= 2.15e+151) {
tmp = (0.5 * re) * (exp(-im) + exp(im));
} else {
tmp = sin(re) * (0.5 * pow(im, 2.0));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 8.0) tmp = Float64(sin(re) * fma(Float64(0.5 * im), im, 1.0)); elseif (im <= 2.15e+151) tmp = Float64(Float64(0.5 * re) * Float64(exp(Float64(-im)) + exp(im))); else tmp = Float64(sin(re) * Float64(0.5 * (im ^ 2.0))); end return tmp end
code[re_, im_] := If[LessEqual[im, 8.0], N[(N[Sin[re], $MachinePrecision] * N[(N[(0.5 * im), $MachinePrecision] * im + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.15e+151], N[(N[(0.5 * re), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 8:\\
\;\;\;\;\sin re \cdot \mathsf{fma}\left(0.5 \cdot im, im, 1\right)\\
\mathbf{elif}\;im \leq 2.15 \cdot 10^{+151}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 8Initial 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.1%
Simplified86.1%
unpow286.1%
associate-*r*86.1%
fma-define86.1%
Applied egg-rr86.1%
if 8 < im < 2.14999999999999991e151Initial 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.1%
Simplified81.1%
if 2.14999999999999991e151 < 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 simplification86.9%
(FPCore (re im)
:precision binary64
(if (<= im 750.0)
(sin re)
(if (<= im 9.5e+150)
(cbrt (pow re -12.0))
(* (sin re) (* 0.5 (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 750.0) {
tmp = sin(re);
} else if (im <= 9.5e+150) {
tmp = cbrt(pow(re, -12.0));
} else {
tmp = sin(re) * (0.5 * pow(im, 2.0));
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (im <= 750.0) {
tmp = Math.sin(re);
} else if (im <= 9.5e+150) {
tmp = Math.cbrt(Math.pow(re, -12.0));
} else {
tmp = Math.sin(re) * (0.5 * Math.pow(im, 2.0));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 750.0) tmp = sin(re); elseif (im <= 9.5e+150) tmp = cbrt((re ^ -12.0)); else tmp = Float64(sin(re) * Float64(0.5 * (im ^ 2.0))); end return tmp end
code[re_, im_] := If[LessEqual[im, 750.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 9.5e+150], N[Power[N[Power[re, -12.0], $MachinePrecision], 1/3], $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 750:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 9.5 \cdot 10^{+150}:\\
\;\;\;\;\sqrt[3]{{re}^{-12}}\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2}\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 66.9%
if 750 < im < 9.5000000000000001e150Initial 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 80.6%
Simplified80.6%
Applied egg-rr23.1%
add-cbrt-cube28.3%
pow1/328.3%
pow328.3%
exp-to-pow28.8%
pow-pow28.8%
metadata-eval28.8%
Applied egg-rr28.8%
unpow1/328.8%
Simplified28.8%
if 9.5000000000000001e150 < 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 95.0%
Simplified95.0%
Taylor expanded in im around inf 95.0%
Final simplification65.4%
(FPCore (re im)
:precision binary64
(if (<= im 750.0)
(* (sin re) (fma (* 0.5 im) im 1.0))
(if (<= im 9.5e+150)
(cbrt (pow re -12.0))
(* (sin re) (* 0.5 (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 750.0) {
tmp = sin(re) * fma((0.5 * im), im, 1.0);
} else if (im <= 9.5e+150) {
tmp = cbrt(pow(re, -12.0));
} else {
tmp = sin(re) * (0.5 * pow(im, 2.0));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 750.0) tmp = Float64(sin(re) * fma(Float64(0.5 * im), im, 1.0)); elseif (im <= 9.5e+150) tmp = cbrt((re ^ -12.0)); else tmp = Float64(sin(re) * Float64(0.5 * (im ^ 2.0))); end return tmp end
code[re_, im_] := If[LessEqual[im, 750.0], N[(N[Sin[re], $MachinePrecision] * N[(N[(0.5 * im), $MachinePrecision] * im + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 9.5e+150], N[Power[N[Power[re, -12.0], $MachinePrecision], 1/3], $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 750:\\
\;\;\;\;\sin re \cdot \mathsf{fma}\left(0.5 \cdot im, im, 1\right)\\
\mathbf{elif}\;im \leq 9.5 \cdot 10^{+150}:\\
\;\;\;\;\sqrt[3]{{re}^{-12}}\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2}\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 86.1%
Simplified86.1%
unpow286.1%
associate-*r*86.1%
fma-define86.1%
Applied egg-rr86.1%
if 750 < im < 9.5000000000000001e150Initial 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 80.6%
Simplified80.6%
Applied egg-rr23.1%
add-cbrt-cube28.3%
pow1/328.3%
pow328.3%
exp-to-pow28.8%
pow-pow28.8%
metadata-eval28.8%
Applied egg-rr28.8%
unpow1/328.8%
Simplified28.8%
if 9.5000000000000001e150 < 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 95.0%
Simplified95.0%
Taylor expanded in im around inf 95.0%
Final simplification79.3%
(FPCore (re im)
:precision binary64
(if (<= im 720.0)
(sin re)
(if (<= im 9.4e+120)
(cbrt (pow re -12.0))
(+ re (* 0.5 (* re (pow im 2.0)))))))
double code(double re, double im) {
double tmp;
if (im <= 720.0) {
tmp = sin(re);
} else if (im <= 9.4e+120) {
tmp = cbrt(pow(re, -12.0));
} else {
tmp = re + (0.5 * (re * pow(im, 2.0)));
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (im <= 720.0) {
tmp = Math.sin(re);
} else if (im <= 9.4e+120) {
tmp = Math.cbrt(Math.pow(re, -12.0));
} else {
tmp = re + (0.5 * (re * Math.pow(im, 2.0)));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 720.0) tmp = sin(re); elseif (im <= 9.4e+120) tmp = cbrt((re ^ -12.0)); else tmp = Float64(re + Float64(0.5 * Float64(re * (im ^ 2.0)))); end return tmp end
code[re_, im_] := If[LessEqual[im, 720.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 9.4e+120], N[Power[N[Power[re, -12.0], $MachinePrecision], 1/3], $MachinePrecision], N[(re + N[(0.5 * N[(re * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 720:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 9.4 \cdot 10^{+120}:\\
\;\;\;\;\sqrt[3]{{re}^{-12}}\\
\mathbf{else}:\\
\;\;\;\;re + 0.5 \cdot \left(re \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 720Initial 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 66.9%
if 720 < im < 9.39999999999999987e120Initial 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 80.6%
Simplified80.6%
Applied egg-rr23.6%
add-cbrt-cube29.6%
pow1/329.6%
pow329.6%
exp-to-pow30.0%
pow-pow30.0%
metadata-eval30.0%
Applied egg-rr30.0%
unpow1/330.0%
Simplified30.0%
if 9.39999999999999987e120 < 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 75.0%
Simplified75.0%
Taylor expanded in im around 0 70.2%
Final simplification63.0%
(FPCore (re im) :precision binary64 (if (<= im 720.0) (sin re) (if (<= im 8.6e+120) (pow re -4.0) (+ re (* 0.5 (* re (pow im 2.0)))))))
double code(double re, double im) {
double tmp;
if (im <= 720.0) {
tmp = sin(re);
} else if (im <= 8.6e+120) {
tmp = pow(re, -4.0);
} else {
tmp = re + (0.5 * (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 <= 720.0d0) then
tmp = sin(re)
else if (im <= 8.6d+120) then
tmp = re ** (-4.0d0)
else
tmp = re + (0.5d0 * (re * (im ** 2.0d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 720.0) {
tmp = Math.sin(re);
} else if (im <= 8.6e+120) {
tmp = Math.pow(re, -4.0);
} else {
tmp = re + (0.5 * (re * Math.pow(im, 2.0)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 720.0: tmp = math.sin(re) elif im <= 8.6e+120: tmp = math.pow(re, -4.0) else: tmp = re + (0.5 * (re * math.pow(im, 2.0))) return tmp
function code(re, im) tmp = 0.0 if (im <= 720.0) tmp = sin(re); elseif (im <= 8.6e+120) tmp = re ^ -4.0; else tmp = Float64(re + Float64(0.5 * Float64(re * (im ^ 2.0)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 720.0) tmp = sin(re); elseif (im <= 8.6e+120) tmp = re ^ -4.0; else tmp = re + (0.5 * (re * (im ^ 2.0))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 720.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 8.6e+120], N[Power[re, -4.0], $MachinePrecision], N[(re + N[(0.5 * N[(re * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 720:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 8.6 \cdot 10^{+120}:\\
\;\;\;\;{re}^{-4}\\
\mathbf{else}:\\
\;\;\;\;re + 0.5 \cdot \left(re \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 720Initial 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 66.9%
if 720 < im < 8.6000000000000003e120Initial 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 80.6%
Simplified80.6%
Applied egg-rr24.1%
if 8.6000000000000003e120 < 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 75.0%
Simplified75.0%
Taylor expanded in im around 0 70.2%
Final simplification62.2%
(FPCore (re im) :precision binary64 (if (<= im 700.0) (sin re) (pow re -4.0)))
double code(double re, double im) {
double tmp;
if (im <= 700.0) {
tmp = sin(re);
} else {
tmp = 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 <= 700.0d0) then
tmp = sin(re)
else
tmp = re ** (-4.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, -4.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 700.0: tmp = math.sin(re) else: tmp = math.pow(re, -4.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 700.0) tmp = sin(re); else tmp = re ^ -4.0; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 700.0) tmp = sin(re); else tmp = re ^ -4.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 700.0], N[Sin[re], $MachinePrecision], N[Power[re, -4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 700:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;{re}^{-4}\\
\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 66.9%
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 77.5%
Simplified77.5%
Applied egg-rr26.6%
Final simplification55.7%
(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 49.1%
Final simplification49.1%
(FPCore (re im) :precision binary64 (if (<= re 190000000000.0) re (/ re (+ re (- re re)))))
double code(double re, double im) {
double tmp;
if (re <= 190000000000.0) {
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 <= 190000000000.0d0) 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 <= 190000000000.0) {
tmp = re;
} else {
tmp = re / (re + (re - re));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 190000000000.0: tmp = re else: tmp = re / (re + (re - re)) return tmp
function code(re, im) tmp = 0.0 if (re <= 190000000000.0) 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 <= 190000000000.0) tmp = re; else tmp = re / (re + (re - re)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 190000000000.0], re, N[(re / N[(re + N[(re - re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 190000000000:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;\frac{re}{re + \left(re - re\right)}\\
\end{array}
\end{array}
if re < 1.9e11Initial 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.7%
Simplified76.7%
Taylor expanded in im around 0 32.2%
if 1.9e11 < 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 27.7%
Simplified27.7%
Applied egg-rr8.3%
Final simplification26.4%
(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 64.8%
Simplified64.8%
Taylor expanded in im around 0 25.2%
Final simplification25.2%
herbie shell --seed 2024075
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))