
(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 14 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%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (re im)
:precision binary64
(if (<= im 3.5e-9)
(sin re)
(if (<= im 1.35e+154)
(* (+ (exp (- im)) (exp im)) (* 0.5 re))
(* (sin re) (* 0.5 (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 3.5e-9) {
tmp = sin(re);
} else if (im <= 1.35e+154) {
tmp = (exp(-im) + exp(im)) * (0.5 * re);
} else {
tmp = sin(re) * (0.5 * 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 <= 3.5d-9) then
tmp = sin(re)
else if (im <= 1.35d+154) then
tmp = (exp(-im) + exp(im)) * (0.5d0 * re)
else
tmp = sin(re) * (0.5d0 * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 3.5e-9) {
tmp = Math.sin(re);
} else if (im <= 1.35e+154) {
tmp = (Math.exp(-im) + Math.exp(im)) * (0.5 * re);
} else {
tmp = Math.sin(re) * (0.5 * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 3.5e-9: tmp = math.sin(re) elif im <= 1.35e+154: tmp = (math.exp(-im) + math.exp(im)) * (0.5 * re) else: tmp = math.sin(re) * (0.5 * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 3.5e-9) tmp = sin(re); elseif (im <= 1.35e+154) tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 * re)); else tmp = Float64(sin(re) * Float64(0.5 * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 3.5e-9) tmp = sin(re); elseif (im <= 1.35e+154) tmp = (exp(-im) + exp(im)) * (0.5 * re); else tmp = sin(re) * (0.5 * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 3.5e-9], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.35e+154], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $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 3.5 \cdot 10^{-9}:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 3.4999999999999999e-9Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 69.6%
if 3.4999999999999999e-9 < im < 1.35000000000000003e154Initial program 99.9%
distribute-rgt-in99.9%
cancel-sign-sub99.9%
distribute-rgt-out--99.9%
sub-neg99.9%
neg-sub099.9%
remove-double-neg99.9%
Simplified99.9%
Taylor expanded in re around 0 83.8%
associate-*r*83.8%
Simplified83.8%
if 1.35000000000000003e154 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around inf 100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification75.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (pow im 2.0))))
(if (<= im 0.06)
(* (sin re) (+ t_0 1.0))
(if (<= im 1e+154)
(* (+ (exp (- im)) (exp im)) (* 0.5 re))
(* (sin re) t_0)))))
double code(double re, double im) {
double t_0 = 0.5 * pow(im, 2.0);
double tmp;
if (im <= 0.06) {
tmp = sin(re) * (t_0 + 1.0);
} else if (im <= 1e+154) {
tmp = (exp(-im) + exp(im)) * (0.5 * re);
} else {
tmp = sin(re) * 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 = 0.5d0 * (im ** 2.0d0)
if (im <= 0.06d0) then
tmp = sin(re) * (t_0 + 1.0d0)
else if (im <= 1d+154) then
tmp = (exp(-im) + exp(im)) * (0.5d0 * re)
else
tmp = sin(re) * t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * Math.pow(im, 2.0);
double tmp;
if (im <= 0.06) {
tmp = Math.sin(re) * (t_0 + 1.0);
} else if (im <= 1e+154) {
tmp = (Math.exp(-im) + Math.exp(im)) * (0.5 * re);
} else {
tmp = Math.sin(re) * t_0;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.pow(im, 2.0) tmp = 0 if im <= 0.06: tmp = math.sin(re) * (t_0 + 1.0) elif im <= 1e+154: tmp = (math.exp(-im) + math.exp(im)) * (0.5 * re) else: tmp = math.sin(re) * t_0 return tmp
function code(re, im) t_0 = Float64(0.5 * (im ^ 2.0)) tmp = 0.0 if (im <= 0.06) tmp = Float64(sin(re) * Float64(t_0 + 1.0)); elseif (im <= 1e+154) tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 * re)); else tmp = Float64(sin(re) * t_0); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (im ^ 2.0); tmp = 0.0; if (im <= 0.06) tmp = sin(re) * (t_0 + 1.0); elseif (im <= 1e+154) tmp = (exp(-im) + exp(im)) * (0.5 * re); else tmp = sin(re) * t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 0.06], N[(N[Sin[re], $MachinePrecision] * N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1e+154], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot {im}^{2}\\
\mathbf{if}\;im \leq 0.06:\\
\;\;\;\;\sin re \cdot \left(t\_0 + 1\right)\\
\mathbf{elif}\;im \leq 10^{+154}:\\
\;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot t\_0\\
\end{array}
\end{array}
if im < 0.059999999999999998Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 85.3%
associate-*r*85.3%
distribute-rgt1-in85.3%
Simplified85.3%
if 0.059999999999999998 < im < 1.00000000000000004e154Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 83.3%
associate-*r*83.3%
Simplified83.3%
if 1.00000000000000004e154 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around inf 100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification86.8%
(FPCore (re im)
:precision binary64
(if (<= im 550.0)
(sin re)
(if (<= im 6.5e+152)
(pow (* (sin re) -2.0) -2.0)
(* (sin re) (* 0.5 (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 550.0) {
tmp = sin(re);
} else if (im <= 6.5e+152) {
tmp = pow((sin(re) * -2.0), -2.0);
} else {
tmp = sin(re) * (0.5 * 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 <= 550.0d0) then
tmp = sin(re)
else if (im <= 6.5d+152) then
tmp = (sin(re) * (-2.0d0)) ** (-2.0d0)
else
tmp = sin(re) * (0.5d0 * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 550.0) {
tmp = Math.sin(re);
} else if (im <= 6.5e+152) {
tmp = Math.pow((Math.sin(re) * -2.0), -2.0);
} else {
tmp = Math.sin(re) * (0.5 * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 550.0: tmp = math.sin(re) elif im <= 6.5e+152: tmp = math.pow((math.sin(re) * -2.0), -2.0) else: tmp = math.sin(re) * (0.5 * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 550.0) tmp = sin(re); elseif (im <= 6.5e+152) tmp = Float64(sin(re) * -2.0) ^ -2.0; else tmp = Float64(sin(re) * Float64(0.5 * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 550.0) tmp = sin(re); elseif (im <= 6.5e+152) tmp = (sin(re) * -2.0) ^ -2.0; else tmp = sin(re) * (0.5 * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 550.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 6.5e+152], N[Power[N[(N[Sin[re], $MachinePrecision] * -2.0), $MachinePrecision], -2.0], $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 550:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 6.5 \cdot 10^{+152}:\\
\;\;\;\;{\left(\sin re \cdot -2\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 550Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 69.6%
if 550 < im < 6.4999999999999997e152Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Applied egg-rr31.5%
if 6.4999999999999997e152 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around inf 100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification68.8%
(FPCore (re im)
:precision binary64
(if (<= im 3800.0)
(sin re)
(if (<= im 6.5e+152)
(+ 0.08333333333333333 (sqrt (/ 0.0625 (pow re 4.0))))
(* (sin re) (* 0.5 (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 3800.0) {
tmp = sin(re);
} else if (im <= 6.5e+152) {
tmp = 0.08333333333333333 + sqrt((0.0625 / pow(re, 4.0)));
} else {
tmp = sin(re) * (0.5 * 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 <= 3800.0d0) then
tmp = sin(re)
else if (im <= 6.5d+152) then
tmp = 0.08333333333333333d0 + sqrt((0.0625d0 / (re ** 4.0d0)))
else
tmp = sin(re) * (0.5d0 * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 3800.0) {
tmp = Math.sin(re);
} else if (im <= 6.5e+152) {
tmp = 0.08333333333333333 + Math.sqrt((0.0625 / Math.pow(re, 4.0)));
} else {
tmp = Math.sin(re) * (0.5 * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 3800.0: tmp = math.sin(re) elif im <= 6.5e+152: tmp = 0.08333333333333333 + math.sqrt((0.0625 / math.pow(re, 4.0))) else: tmp = math.sin(re) * (0.5 * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 3800.0) tmp = sin(re); elseif (im <= 6.5e+152) tmp = Float64(0.08333333333333333 + sqrt(Float64(0.0625 / (re ^ 4.0)))); else tmp = Float64(sin(re) * Float64(0.5 * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 3800.0) tmp = sin(re); elseif (im <= 6.5e+152) tmp = 0.08333333333333333 + sqrt((0.0625 / (re ^ 4.0))); else tmp = sin(re) * (0.5 * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 3800.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 6.5e+152], N[(0.08333333333333333 + N[Sqrt[N[(0.0625 / N[Power[re, 4.0], $MachinePrecision]), $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 3800:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 6.5 \cdot 10^{+152}:\\
\;\;\;\;0.08333333333333333 + \sqrt{\frac{0.0625}{{re}^{4}}}\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 3800Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 69.6%
if 3800 < im < 6.4999999999999997e152Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Applied egg-rr31.5%
Taylor expanded in re around 0 31.5%
associate-*r/31.5%
metadata-eval31.5%
Simplified31.5%
add-sqr-sqrt31.5%
sqrt-unprod37.8%
frac-times37.8%
metadata-eval37.8%
pow-prod-up37.8%
metadata-eval37.8%
Applied egg-rr37.8%
if 6.4999999999999997e152 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around inf 100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification69.6%
(FPCore (re im)
:precision binary64
(if (<= im 620.0)
(sin re)
(if (<= im 6.2e+152)
(pow (* (sin re) -2.0) -2.0)
(* re (+ (* 0.5 (pow im 2.0)) 1.0)))))
double code(double re, double im) {
double tmp;
if (im <= 620.0) {
tmp = sin(re);
} else if (im <= 6.2e+152) {
tmp = pow((sin(re) * -2.0), -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 <= 620.0d0) then
tmp = sin(re)
else if (im <= 6.2d+152) then
tmp = (sin(re) * (-2.0d0)) ** (-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 <= 620.0) {
tmp = Math.sin(re);
} else if (im <= 6.2e+152) {
tmp = Math.pow((Math.sin(re) * -2.0), -2.0);
} else {
tmp = re * ((0.5 * Math.pow(im, 2.0)) + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 620.0: tmp = math.sin(re) elif im <= 6.2e+152: tmp = math.pow((math.sin(re) * -2.0), -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 <= 620.0) tmp = sin(re); elseif (im <= 6.2e+152) tmp = Float64(sin(re) * -2.0) ^ -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 <= 620.0) tmp = sin(re); elseif (im <= 6.2e+152) tmp = (sin(re) * -2.0) ^ -2.0; else tmp = re * ((0.5 * (im ^ 2.0)) + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 620.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 6.2e+152], N[Power[N[(N[Sin[re], $MachinePrecision] * -2.0), $MachinePrecision], -2.0], $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 620:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 6.2 \cdot 10^{+152}:\\
\;\;\;\;{\left(\sin re \cdot -2\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot {im}^{2} + 1\right)\\
\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%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 69.6%
if 620 < im < 6.2e152Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Applied egg-rr31.5%
if 6.2e152 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 87.1%
Final simplification67.3%
(FPCore (re im)
:precision binary64
(if (<= im 3800.0)
(sin re)
(if (<= im 1.7e+151)
(+ 0.08333333333333333 (* (/ 0.5 re) (/ 0.5 re)))
(* re (+ (* 0.5 (pow im 2.0)) 1.0)))))
double code(double re, double im) {
double tmp;
if (im <= 3800.0) {
tmp = sin(re);
} else if (im <= 1.7e+151) {
tmp = 0.08333333333333333 + ((0.5 / re) * (0.5 / re));
} 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 <= 3800.0d0) then
tmp = sin(re)
else if (im <= 1.7d+151) then
tmp = 0.08333333333333333d0 + ((0.5d0 / re) * (0.5d0 / re))
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 <= 3800.0) {
tmp = Math.sin(re);
} else if (im <= 1.7e+151) {
tmp = 0.08333333333333333 + ((0.5 / re) * (0.5 / re));
} else {
tmp = re * ((0.5 * Math.pow(im, 2.0)) + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 3800.0: tmp = math.sin(re) elif im <= 1.7e+151: tmp = 0.08333333333333333 + ((0.5 / re) * (0.5 / re)) else: tmp = re * ((0.5 * math.pow(im, 2.0)) + 1.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 3800.0) tmp = sin(re); elseif (im <= 1.7e+151) tmp = Float64(0.08333333333333333 + Float64(Float64(0.5 / re) * Float64(0.5 / re))); 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 <= 3800.0) tmp = sin(re); elseif (im <= 1.7e+151) tmp = 0.08333333333333333 + ((0.5 / re) * (0.5 / re)); else tmp = re * ((0.5 * (im ^ 2.0)) + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 3800.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.7e+151], N[(0.08333333333333333 + N[(N[(0.5 / re), $MachinePrecision] * N[(0.5 / re), $MachinePrecision]), $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 3800:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.7 \cdot 10^{+151}:\\
\;\;\;\;0.08333333333333333 + \frac{0.5}{re} \cdot \frac{0.5}{re}\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot {im}^{2} + 1\right)\\
\end{array}
\end{array}
if im < 3800Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 69.6%
if 3800 < im < 1.7e151Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Applied egg-rr31.5%
Taylor expanded in re around 0 31.5%
associate-*r/31.5%
metadata-eval31.5%
Simplified31.5%
add-sqr-sqrt31.5%
sqrt-div31.5%
metadata-eval31.5%
unpow231.5%
sqrt-prod31.0%
add-sqr-sqrt35.5%
sqrt-div35.5%
metadata-eval35.5%
unpow235.5%
sqrt-prod31.0%
add-sqr-sqrt31.5%
Applied egg-rr31.5%
if 1.7e151 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 87.1%
Final simplification67.3%
(FPCore (re im)
:precision binary64
(if (<= im 3800.0)
(sin re)
(if (<= im 2.6e+150)
(+ 0.08333333333333333 (* (/ 0.5 re) (/ 0.5 re)))
(* re (* 0.5 (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 3800.0) {
tmp = sin(re);
} else if (im <= 2.6e+150) {
tmp = 0.08333333333333333 + ((0.5 / re) * (0.5 / re));
} else {
tmp = re * (0.5 * 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 <= 3800.0d0) then
tmp = sin(re)
else if (im <= 2.6d+150) then
tmp = 0.08333333333333333d0 + ((0.5d0 / re) * (0.5d0 / re))
else
tmp = re * (0.5d0 * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 3800.0) {
tmp = Math.sin(re);
} else if (im <= 2.6e+150) {
tmp = 0.08333333333333333 + ((0.5 / re) * (0.5 / re));
} else {
tmp = re * (0.5 * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 3800.0: tmp = math.sin(re) elif im <= 2.6e+150: tmp = 0.08333333333333333 + ((0.5 / re) * (0.5 / re)) else: tmp = re * (0.5 * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 3800.0) tmp = sin(re); elseif (im <= 2.6e+150) tmp = Float64(0.08333333333333333 + Float64(Float64(0.5 / re) * Float64(0.5 / re))); else tmp = Float64(re * Float64(0.5 * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 3800.0) tmp = sin(re); elseif (im <= 2.6e+150) tmp = 0.08333333333333333 + ((0.5 / re) * (0.5 / re)); else tmp = re * (0.5 * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 3800.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 2.6e+150], N[(0.08333333333333333 + N[(N[(0.5 / re), $MachinePrecision] * N[(0.5 / re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 3800:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 2.6 \cdot 10^{+150}:\\
\;\;\;\;0.08333333333333333 + \frac{0.5}{re} \cdot \frac{0.5}{re}\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 3800Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 69.6%
if 3800 < im < 2.60000000000000006e150Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Applied egg-rr31.5%
Taylor expanded in re around 0 31.5%
associate-*r/31.5%
metadata-eval31.5%
Simplified31.5%
add-sqr-sqrt31.5%
sqrt-div31.5%
metadata-eval31.5%
unpow231.5%
sqrt-prod31.0%
add-sqr-sqrt35.5%
sqrt-div35.5%
metadata-eval35.5%
unpow235.5%
sqrt-prod31.0%
add-sqr-sqrt31.5%
Applied egg-rr31.5%
if 2.60000000000000006e150 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 87.1%
Taylor expanded in im around 0 87.1%
Taylor expanded in im around inf 87.1%
*-commutative87.1%
associate-*r*87.1%
*-commutative87.1%
associate-*r*87.1%
Simplified87.1%
Final simplification67.3%
(FPCore (re im) :precision binary64 (if (<= im 3800.0) (sin re) (+ 0.08333333333333333 (* (/ 0.5 re) (/ 0.5 re)))))
double code(double re, double im) {
double tmp;
if (im <= 3800.0) {
tmp = sin(re);
} else {
tmp = 0.08333333333333333 + ((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 <= 3800.0d0) then
tmp = sin(re)
else
tmp = 0.08333333333333333d0 + ((0.5d0 / re) * (0.5d0 / re))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 3800.0) {
tmp = Math.sin(re);
} else {
tmp = 0.08333333333333333 + ((0.5 / re) * (0.5 / re));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 3800.0: tmp = math.sin(re) else: tmp = 0.08333333333333333 + ((0.5 / re) * (0.5 / re)) return tmp
function code(re, im) tmp = 0.0 if (im <= 3800.0) tmp = sin(re); else tmp = Float64(0.08333333333333333 + Float64(Float64(0.5 / re) * Float64(0.5 / re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 3800.0) tmp = sin(re); else tmp = 0.08333333333333333 + ((0.5 / re) * (0.5 / re)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 3800.0], N[Sin[re], $MachinePrecision], N[(0.08333333333333333 + N[(N[(0.5 / re), $MachinePrecision] * N[(0.5 / re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 3800:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;0.08333333333333333 + \frac{0.5}{re} \cdot \frac{0.5}{re}\\
\end{array}
\end{array}
if im < 3800Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 69.6%
if 3800 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Applied egg-rr24.8%
Taylor expanded in re around 0 24.8%
associate-*r/24.8%
metadata-eval24.8%
Simplified24.8%
add-sqr-sqrt24.8%
sqrt-div24.8%
metadata-eval24.8%
unpow224.8%
sqrt-prod24.4%
add-sqr-sqrt32.1%
sqrt-div32.1%
metadata-eval32.1%
unpow232.1%
sqrt-prod24.4%
add-sqr-sqrt24.8%
Applied egg-rr24.8%
Final simplification58.9%
(FPCore (re im) :precision binary64 (if (<= im 3800.0) re (+ 0.08333333333333333 (* (/ 0.5 re) (/ 0.5 re)))))
double code(double re, double im) {
double tmp;
if (im <= 3800.0) {
tmp = re;
} else {
tmp = 0.08333333333333333 + ((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 <= 3800.0d0) then
tmp = re
else
tmp = 0.08333333333333333d0 + ((0.5d0 / re) * (0.5d0 / re))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 3800.0) {
tmp = re;
} else {
tmp = 0.08333333333333333 + ((0.5 / re) * (0.5 / re));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 3800.0: tmp = re else: tmp = 0.08333333333333333 + ((0.5 / re) * (0.5 / re)) return tmp
function code(re, im) tmp = 0.0 if (im <= 3800.0) tmp = re; else tmp = Float64(0.08333333333333333 + Float64(Float64(0.5 / re) * Float64(0.5 / re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 3800.0) tmp = re; else tmp = 0.08333333333333333 + ((0.5 / re) * (0.5 / re)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 3800.0], re, N[(0.08333333333333333 + N[(N[(0.5 / re), $MachinePrecision] * N[(0.5 / re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 3800:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;0.08333333333333333 + \frac{0.5}{re} \cdot \frac{0.5}{re}\\
\end{array}
\end{array}
if im < 3800Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 85.3%
Taylor expanded in re around 0 48.9%
Taylor expanded in im around 0 37.0%
if 3800 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Applied egg-rr24.8%
Taylor expanded in re around 0 24.8%
associate-*r/24.8%
metadata-eval24.8%
Simplified24.8%
add-sqr-sqrt24.8%
sqrt-div24.8%
metadata-eval24.8%
unpow224.8%
sqrt-prod24.4%
add-sqr-sqrt32.1%
sqrt-div32.1%
metadata-eval32.1%
unpow232.1%
sqrt-prod24.4%
add-sqr-sqrt24.8%
Applied egg-rr24.8%
Final simplification34.1%
(FPCore (re im) :precision binary64 (if (<= re 1.0) re 1.0))
double code(double re, double im) {
double tmp;
if (re <= 1.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 <= 1.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 <= 1.0) {
tmp = re;
} else {
tmp = 1.0;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1.0: tmp = re else: tmp = 1.0 return tmp
function code(re, im) tmp = 0.0 if (re <= 1.0) tmp = re; else tmp = 1.0; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 1.0) tmp = re; else tmp = 1.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1.0], re, 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if re < 1Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 75.1%
Taylor expanded in re around 0 57.7%
Taylor expanded in im around 0 37.1%
if 1 < re Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Applied egg-rr8.1%
+-inverses8.1%
+-rgt-identity8.1%
*-inverses8.1%
Simplified8.1%
Final simplification30.0%
(FPCore (re im) :precision binary64 0.0)
double code(double re, double im) {
return 0.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.0d0
end function
public static double code(double re, double im) {
return 0.0;
}
def code(re, im): return 0.0
function code(re, im) return 0.0 end
function tmp = code(re, im) tmp = 0.0; end
code[re_, im_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Applied egg-rr3.0%
pow-base-13.0%
metadata-eval3.0%
Simplified3.0%
Final simplification3.0%
(FPCore (re im) :precision binary64 0.08333333333333333)
double code(double re, double im) {
return 0.08333333333333333;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.08333333333333333d0
end function
public static double code(double re, double im) {
return 0.08333333333333333;
}
def code(re, im): return 0.08333333333333333
function code(re, im) return 0.08333333333333333 end
function tmp = code(re, im) tmp = 0.08333333333333333; end
code[re_, im_] := 0.08333333333333333
\begin{array}{l}
\\
0.08333333333333333
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Applied egg-rr12.5%
Taylor expanded in re around 0 12.3%
associate-*r/12.3%
metadata-eval12.3%
Simplified12.3%
Taylor expanded in re around inf 4.3%
Final simplification4.3%
(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%
neg-sub0100.0%
remove-double-neg100.0%
Simplified100.0%
Applied egg-rr4.9%
+-inverses4.9%
+-rgt-identity4.9%
*-inverses4.9%
Simplified4.9%
Final simplification4.9%
herbie shell --seed 2024039
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))