
(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 11 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 7.8)
(* (* 0.5 (sin re)) (fma im im 2.0))
(if (<= im 1.15e+77)
(* (* 0.5 re) (+ (exp (- im)) (exp im)))
(* 0.041666666666666664 (* (sin re) (pow im 4.0))))))
double code(double re, double im) {
double tmp;
if (im <= 7.8) {
tmp = (0.5 * sin(re)) * fma(im, im, 2.0);
} else if (im <= 1.15e+77) {
tmp = (0.5 * re) * (exp(-im) + exp(im));
} else {
tmp = 0.041666666666666664 * (sin(re) * pow(im, 4.0));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 7.8) tmp = Float64(Float64(0.5 * sin(re)) * fma(im, im, 2.0)); elseif (im <= 1.15e+77) tmp = Float64(Float64(0.5 * re) * Float64(exp(Float64(-im)) + exp(im))); else tmp = Float64(0.041666666666666664 * Float64(sin(re) * (im ^ 4.0))); end return tmp end
code[re_, im_] := If[LessEqual[im, 7.8], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.15e+77], N[(N[(0.5 * re), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $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 7.8:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;0.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\right)\\
\end{array}
\end{array}
if im < 7.79999999999999982Initial 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.4%
Simplified86.4%
if 7.79999999999999982 < im < 1.14999999999999997e77Initial 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.3%
Simplified64.3%
if 1.14999999999999997e77 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
Final simplification87.5%
(FPCore (re im)
:precision binary64
(if (<= im 620.0)
(sin re)
(if (<= im 1.15e+77)
(sqrt (pow re -8.0))
(* 0.041666666666666664 (* (sin re) (pow im 4.0))))))
double code(double re, double im) {
double tmp;
if (im <= 620.0) {
tmp = sin(re);
} else if (im <= 1.15e+77) {
tmp = sqrt(pow(re, -8.0));
} 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 <= 620.0d0) then
tmp = sin(re)
else if (im <= 1.15d+77) then
tmp = sqrt((re ** (-8.0d0)))
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 <= 620.0) {
tmp = Math.sin(re);
} else if (im <= 1.15e+77) {
tmp = Math.sqrt(Math.pow(re, -8.0));
} else {
tmp = 0.041666666666666664 * (Math.sin(re) * Math.pow(im, 4.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 620.0: tmp = math.sin(re) elif im <= 1.15e+77: tmp = math.sqrt(math.pow(re, -8.0)) else: tmp = 0.041666666666666664 * (math.sin(re) * math.pow(im, 4.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 620.0) tmp = sin(re); elseif (im <= 1.15e+77) tmp = sqrt((re ^ -8.0)); 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 <= 620.0) tmp = sin(re); elseif (im <= 1.15e+77) tmp = sqrt((re ^ -8.0)); else tmp = 0.041666666666666664 * (sin(re) * (im ^ 4.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 620.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.15e+77], N[Sqrt[N[Power[re, -8.0], $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 620:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\
\;\;\;\;\sqrt{{re}^{-8}}\\
\mathbf{else}:\\
\;\;\;\;0.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\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%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 68.4%
if 620 < im < 1.14999999999999997e77Initial 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.3%
Simplified64.3%
Applied egg-rr15.5%
add-sqr-sqrt15.5%
sqrt-unprod22.2%
exp-to-pow22.2%
exp-to-pow22.5%
pow-prod-up22.5%
metadata-eval22.5%
Applied egg-rr22.5%
if 1.14999999999999997e77 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
Final simplification71.3%
(FPCore (re im)
:precision binary64
(if (<= im 720.0)
(* (* 0.5 (sin re)) (fma im im 2.0))
(if (<= im 1.15e+77)
(sqrt (pow re -8.0))
(* 0.041666666666666664 (* (sin re) (pow im 4.0))))))
double code(double re, double im) {
double tmp;
if (im <= 720.0) {
tmp = (0.5 * sin(re)) * fma(im, im, 2.0);
} else if (im <= 1.15e+77) {
tmp = sqrt(pow(re, -8.0));
} else {
tmp = 0.041666666666666664 * (sin(re) * pow(im, 4.0));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 720.0) tmp = Float64(Float64(0.5 * sin(re)) * fma(im, im, 2.0)); elseif (im <= 1.15e+77) tmp = sqrt((re ^ -8.0)); else tmp = Float64(0.041666666666666664 * Float64(sin(re) * (im ^ 4.0))); end return tmp end
code[re_, im_] := If[LessEqual[im, 720.0], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.15e+77], N[Sqrt[N[Power[re, -8.0], $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 720:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\
\;\;\;\;\sqrt{{re}^{-8}}\\
\mathbf{else}:\\
\;\;\;\;0.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\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 86.4%
Simplified86.4%
if 720 < im < 1.14999999999999997e77Initial 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.3%
Simplified64.3%
Applied egg-rr15.5%
add-sqr-sqrt15.5%
sqrt-unprod22.2%
exp-to-pow22.2%
exp-to-pow22.5%
pow-prod-up22.5%
metadata-eval22.5%
Applied egg-rr22.5%
if 1.14999999999999997e77 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
Final simplification85.2%
(FPCore (re im)
:precision binary64
(if (<= im 750.0)
(sin re)
(if (<= im 5.1e+76)
(sqrt (pow re -8.0))
(* (pow im 4.0) (* re 0.041666666666666664)))))
double code(double re, double im) {
double tmp;
if (im <= 750.0) {
tmp = sin(re);
} else if (im <= 5.1e+76) {
tmp = sqrt(pow(re, -8.0));
} else {
tmp = pow(im, 4.0) * (re * 0.041666666666666664);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 750.0d0) then
tmp = sin(re)
else if (im <= 5.1d+76) then
tmp = sqrt((re ** (-8.0d0)))
else
tmp = (im ** 4.0d0) * (re * 0.041666666666666664d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 750.0) {
tmp = Math.sin(re);
} else if (im <= 5.1e+76) {
tmp = Math.sqrt(Math.pow(re, -8.0));
} else {
tmp = Math.pow(im, 4.0) * (re * 0.041666666666666664);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 750.0: tmp = math.sin(re) elif im <= 5.1e+76: tmp = math.sqrt(math.pow(re, -8.0)) else: tmp = math.pow(im, 4.0) * (re * 0.041666666666666664) return tmp
function code(re, im) tmp = 0.0 if (im <= 750.0) tmp = sin(re); elseif (im <= 5.1e+76) tmp = sqrt((re ^ -8.0)); else tmp = Float64((im ^ 4.0) * Float64(re * 0.041666666666666664)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 750.0) tmp = sin(re); elseif (im <= 5.1e+76) tmp = sqrt((re ^ -8.0)); else tmp = (im ^ 4.0) * (re * 0.041666666666666664); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 750.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 5.1e+76], N[Sqrt[N[Power[re, -8.0], $MachinePrecision]], $MachinePrecision], N[(N[Power[im, 4.0], $MachinePrecision] * N[(re * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 750:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 5.1 \cdot 10^{+76}:\\
\;\;\;\;\sqrt{{re}^{-8}}\\
\mathbf{else}:\\
\;\;\;\;{im}^{4} \cdot \left(re \cdot 0.041666666666666664\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 68.4%
if 750 < im < 5.1000000000000002e76Initial 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.3%
Simplified64.3%
Applied egg-rr15.5%
add-sqr-sqrt15.5%
sqrt-unprod22.2%
exp-to-pow22.2%
exp-to-pow22.5%
pow-prod-up22.5%
metadata-eval22.5%
Applied egg-rr22.5%
if 5.1000000000000002e76 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
Taylor expanded in re around 0 72.7%
*-commutative72.7%
associate-*l*72.7%
Simplified72.7%
Final simplification66.6%
(FPCore (re im)
:precision binary64
(if (<= im 750.0)
(sin re)
(if (<= im 2.6e+74)
(pow re -4.0)
(* (pow im 4.0) (* re 0.041666666666666664)))))
double code(double re, double im) {
double tmp;
if (im <= 750.0) {
tmp = sin(re);
} else if (im <= 2.6e+74) {
tmp = pow(re, -4.0);
} else {
tmp = pow(im, 4.0) * (re * 0.041666666666666664);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 750.0d0) then
tmp = sin(re)
else if (im <= 2.6d+74) then
tmp = re ** (-4.0d0)
else
tmp = (im ** 4.0d0) * (re * 0.041666666666666664d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 750.0) {
tmp = Math.sin(re);
} else if (im <= 2.6e+74) {
tmp = Math.pow(re, -4.0);
} else {
tmp = Math.pow(im, 4.0) * (re * 0.041666666666666664);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 750.0: tmp = math.sin(re) elif im <= 2.6e+74: tmp = math.pow(re, -4.0) else: tmp = math.pow(im, 4.0) * (re * 0.041666666666666664) return tmp
function code(re, im) tmp = 0.0 if (im <= 750.0) tmp = sin(re); elseif (im <= 2.6e+74) tmp = re ^ -4.0; else tmp = Float64((im ^ 4.0) * Float64(re * 0.041666666666666664)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 750.0) tmp = sin(re); elseif (im <= 2.6e+74) tmp = re ^ -4.0; else tmp = (im ^ 4.0) * (re * 0.041666666666666664); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 750.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 2.6e+74], N[Power[re, -4.0], $MachinePrecision], N[(N[Power[im, 4.0], $MachinePrecision] * N[(re * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 750:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 2.6 \cdot 10^{+74}:\\
\;\;\;\;{re}^{-4}\\
\mathbf{else}:\\
\;\;\;\;{im}^{4} \cdot \left(re \cdot 0.041666666666666664\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 68.4%
if 750 < im < 2.6000000000000001e74Initial 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.3%
Simplified64.3%
Applied egg-rr15.8%
if 2.6000000000000001e74 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
Taylor expanded in re around 0 72.7%
*-commutative72.7%
associate-*l*72.7%
Simplified72.7%
Final simplification66.3%
(FPCore (re im) :precision binary64 (if (<= im 650.0) (sin re) (/ 1.0 (pow re 4.0))))
double code(double re, double im) {
double tmp;
if (im <= 650.0) {
tmp = sin(re);
} else {
tmp = 1.0 / 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 <= 650.0d0) then
tmp = sin(re)
else
tmp = 1.0d0 / (re ** 4.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 650.0) {
tmp = Math.sin(re);
} else {
tmp = 1.0 / Math.pow(re, 4.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 650.0: tmp = math.sin(re) else: tmp = 1.0 / math.pow(re, 4.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 650.0) tmp = sin(re); else tmp = Float64(1.0 / (re ^ 4.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 650.0) tmp = sin(re); else tmp = 1.0 / (re ^ 4.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 650.0], N[Sin[re], $MachinePrecision], N[(1.0 / N[Power[re, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 650:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{{re}^{4}}\\
\end{array}
\end{array}
if im < 650Initial 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.4%
if 650 < 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 70.7%
Simplified70.7%
Applied egg-rr11.2%
Taylor expanded in re around 0 11.6%
Final simplification55.5%
(FPCore (re im) :precision binary64 (if (<= im 500.0) (sin re) (pow re -4.0)))
double code(double re, double im) {
double tmp;
if (im <= 500.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 <= 500.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 <= 500.0) {
tmp = Math.sin(re);
} else {
tmp = Math.pow(re, -4.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 500.0: tmp = math.sin(re) else: tmp = math.pow(re, -4.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 500.0) tmp = sin(re); else tmp = re ^ -4.0; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 500.0) tmp = sin(re); else tmp = re ^ -4.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 500.0], N[Sin[re], $MachinePrecision], N[Power[re, -4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 500:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;{re}^{-4}\\
\end{array}
\end{array}
if im < 500Initial 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.4%
if 500 < 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 70.7%
Simplified70.7%
Applied egg-rr11.6%
Final simplification55.5%
(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 53.5%
Final simplification53.5%
(FPCore (re im) :precision binary64 (if (<= re 8000000000000.0) re 1.0))
double code(double re, double im) {
double tmp;
if (re <= 8000000000000.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 <= 8000000000000.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 <= 8000000000000.0) {
tmp = re;
} else {
tmp = 1.0;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 8000000000000.0: tmp = re else: tmp = 1.0 return tmp
function code(re, im) tmp = 0.0 if (re <= 8000000000000.0) tmp = re; else tmp = 1.0; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 8000000000000.0) tmp = re; else tmp = 1.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 8000000000000.0], re, 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 8000000000000:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if re < 8e12Initial 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 73.3%
Simplified73.3%
Taylor expanded in im around 0 36.7%
if 8e12 < 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 im around 0 87.8%
Simplified87.8%
Applied egg-rr7.1%
+-inverses7.1%
+-rgt-identity7.1%
*-inverses7.1%
Simplified7.1%
Final simplification29.6%
(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%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 89.2%
Simplified89.2%
Applied egg-rr4.7%
+-inverses4.7%
+-rgt-identity4.7%
*-inverses4.7%
Simplified4.7%
Final simplification4.7%
herbie shell --seed 2024084
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))