
(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 13 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%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (pow im 2.0))))
(if (<= im 0.116)
(* (sin re) (+ t_0 1.0))
(if (<= im 1.35e+154)
(* (* 0.5 re) (+ (exp (- im)) (exp im)))
(* (sin re) t_0)))))
double code(double re, double im) {
double t_0 = 0.5 * pow(im, 2.0);
double tmp;
if (im <= 0.116) {
tmp = sin(re) * (t_0 + 1.0);
} else if (im <= 1.35e+154) {
tmp = (0.5 * re) * (exp(-im) + exp(im));
} 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.116d0) then
tmp = sin(re) * (t_0 + 1.0d0)
else if (im <= 1.35d+154) then
tmp = (0.5d0 * re) * (exp(-im) + exp(im))
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.116) {
tmp = Math.sin(re) * (t_0 + 1.0);
} else if (im <= 1.35e+154) {
tmp = (0.5 * re) * (Math.exp(-im) + Math.exp(im));
} 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.116: tmp = math.sin(re) * (t_0 + 1.0) elif im <= 1.35e+154: tmp = (0.5 * re) * (math.exp(-im) + math.exp(im)) 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.116) tmp = Float64(sin(re) * Float64(t_0 + 1.0)); elseif (im <= 1.35e+154) tmp = Float64(Float64(0.5 * re) * Float64(exp(Float64(-im)) + exp(im))); 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.116) tmp = sin(re) * (t_0 + 1.0); elseif (im <= 1.35e+154) tmp = (0.5 * re) * (exp(-im) + exp(im)); 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.116], N[(N[Sin[re], $MachinePrecision] * N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.35e+154], N[(N[(0.5 * re), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $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.116:\\
\;\;\;\;\sin re \cdot \left(t\_0 + 1\right)\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot t\_0\\
\end{array}
\end{array}
if im < 0.116000000000000006Initial 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 83.1%
Simplified83.1%
if 0.116000000000000006 < im < 1.35000000000000003e154Initial 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 85.2%
Simplified85.2%
if 1.35000000000000003e154 < 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%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification85.3%
(FPCore (re im)
:precision binary64
(if (<= im 0.00047)
(sin re)
(if (<= im 1.5e+154)
(* (* 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 <= 0.00047) {
tmp = sin(re);
} else if (im <= 1.5e+154) {
tmp = (0.5 * re) * (exp(-im) + exp(im));
} 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 <= 0.00047d0) then
tmp = sin(re)
else if (im <= 1.5d+154) then
tmp = (0.5d0 * re) * (exp(-im) + exp(im))
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 <= 0.00047) {
tmp = Math.sin(re);
} else if (im <= 1.5e+154) {
tmp = (0.5 * re) * (Math.exp(-im) + Math.exp(im));
} else {
tmp = Math.sin(re) * (0.5 * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.00047: tmp = math.sin(re) elif im <= 1.5e+154: tmp = (0.5 * re) * (math.exp(-im) + math.exp(im)) else: tmp = math.sin(re) * (0.5 * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 0.00047) tmp = sin(re); elseif (im <= 1.5e+154) 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
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.00047) tmp = sin(re); elseif (im <= 1.5e+154) tmp = (0.5 * re) * (exp(-im) + exp(im)); else tmp = sin(re) * (0.5 * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.00047], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.5e+154], 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 0.00047:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.5 \cdot 10^{+154}:\\
\;\;\;\;\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 < 4.69999999999999986e-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 im around 0 60.3%
if 4.69999999999999986e-4 < im < 1.50000000000000013e154Initial 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 85.2%
Simplified85.2%
if 1.50000000000000013e154 < 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%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification67.6%
(FPCore (re im)
:precision binary64
(if (<= im 650.0)
(sin re)
(if (<= im 1.05e+154)
(sqrt (pow re -8.0))
(* (sin re) (* 0.5 (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 650.0) {
tmp = sin(re);
} else if (im <= 1.05e+154) {
tmp = sqrt(pow(re, -8.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 <= 650.0d0) then
tmp = sin(re)
else if (im <= 1.05d+154) then
tmp = sqrt((re ** (-8.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 <= 650.0) {
tmp = Math.sin(re);
} else if (im <= 1.05e+154) {
tmp = Math.sqrt(Math.pow(re, -8.0));
} else {
tmp = Math.sin(re) * (0.5 * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 650.0: tmp = math.sin(re) elif im <= 1.05e+154: tmp = math.sqrt(math.pow(re, -8.0)) else: tmp = math.sin(re) * (0.5 * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 650.0) tmp = sin(re); elseif (im <= 1.05e+154) tmp = sqrt((re ^ -8.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 <= 650.0) tmp = sin(re); elseif (im <= 1.05e+154) tmp = sqrt((re ^ -8.0)); else tmp = sin(re) * (0.5 * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 650.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.05e+154], N[Sqrt[N[Power[re, -8.0], $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 650:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.05 \cdot 10^{+154}:\\
\;\;\;\;\sqrt{{re}^{-8}}\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\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 60.3%
if 650 < im < 1.04999999999999997e154Initial 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 85.2%
Simplified85.2%
Applied egg-rr30.4%
add-sqr-sqrt30.4%
sqrt-unprod30.3%
exp-to-pow30.3%
exp-to-pow30.6%
pow-prod-up30.6%
metadata-eval30.6%
Applied egg-rr30.6%
if 1.04999999999999997e154 < 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%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
(FPCore (re im)
:precision binary64
(if (<= im 700.0)
(sin re)
(if (<= im 6.5e+142)
(sqrt (pow re -8.0))
(+ re (* 0.5 (* re (pow im 2.0)))))))
double code(double re, double im) {
double tmp;
if (im <= 700.0) {
tmp = sin(re);
} else if (im <= 6.5e+142) {
tmp = sqrt(pow(re, -8.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 <= 700.0d0) then
tmp = sin(re)
else if (im <= 6.5d+142) then
tmp = sqrt((re ** (-8.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 <= 700.0) {
tmp = Math.sin(re);
} else if (im <= 6.5e+142) {
tmp = Math.sqrt(Math.pow(re, -8.0));
} else {
tmp = re + (0.5 * (re * Math.pow(im, 2.0)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 700.0: tmp = math.sin(re) elif im <= 6.5e+142: tmp = math.sqrt(math.pow(re, -8.0)) else: tmp = re + (0.5 * (re * math.pow(im, 2.0))) return tmp
function code(re, im) tmp = 0.0 if (im <= 700.0) tmp = sin(re); elseif (im <= 6.5e+142) tmp = sqrt((re ^ -8.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 <= 700.0) tmp = sin(re); elseif (im <= 6.5e+142) tmp = sqrt((re ^ -8.0)); else tmp = re + (0.5 * (re * (im ^ 2.0))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 700.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 6.5e+142], N[Sqrt[N[Power[re, -8.0], $MachinePrecision]], $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 700:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 6.5 \cdot 10^{+142}:\\
\;\;\;\;\sqrt{{re}^{-8}}\\
\mathbf{else}:\\
\;\;\;\;re + 0.5 \cdot \left(re \cdot {im}^{2}\right)\\
\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 60.3%
if 700 < im < 6.4999999999999997e142Initial 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 83.3%
Simplified83.3%
Applied egg-rr34.1%
add-sqr-sqrt34.1%
sqrt-unprod34.0%
exp-to-pow34.0%
exp-to-pow34.2%
pow-prod-up34.2%
metadata-eval34.2%
Applied egg-rr34.2%
if 6.4999999999999997e142 < 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.8%
Simplified75.8%
Taylor expanded in im around 0 72.8%
Final simplification59.4%
(FPCore (re im)
:precision binary64
(if (<= im 550.0)
(sin re)
(if (<= im 2.7e+62)
(log1p (expm1 re))
(if (<= im 3.8e+142) (pow re -4.0) (+ re (* 0.5 (* re (pow im 2.0))))))))
double code(double re, double im) {
double tmp;
if (im <= 550.0) {
tmp = sin(re);
} else if (im <= 2.7e+62) {
tmp = log1p(expm1(re));
} else if (im <= 3.8e+142) {
tmp = pow(re, -4.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 <= 550.0) {
tmp = Math.sin(re);
} else if (im <= 2.7e+62) {
tmp = Math.log1p(Math.expm1(re));
} else if (im <= 3.8e+142) {
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 <= 550.0: tmp = math.sin(re) elif im <= 2.7e+62: tmp = math.log1p(math.expm1(re)) elif im <= 3.8e+142: 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 <= 550.0) tmp = sin(re); elseif (im <= 2.7e+62) tmp = log1p(expm1(re)); elseif (im <= 3.8e+142) tmp = re ^ -4.0; else tmp = Float64(re + Float64(0.5 * Float64(re * (im ^ 2.0)))); end return tmp end
code[re_, im_] := If[LessEqual[im, 550.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 2.7e+62], N[Log[1 + N[(Exp[re] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 3.8e+142], 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 550:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 2.7 \cdot 10^{+62}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\
\mathbf{elif}\;im \leq 3.8 \cdot 10^{+142}:\\
\;\;\;\;{re}^{-4}\\
\mathbf{else}:\\
\;\;\;\;re + 0.5 \cdot \left(re \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%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 60.3%
if 550 < im < 2.7e62Initial 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%
Applied egg-rr42.5%
if 2.7e62 < im < 3.7999999999999999e142Initial 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 91.7%
Simplified91.7%
Applied egg-rr50.4%
if 3.7999999999999999e142 < 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.8%
Simplified75.8%
Taylor expanded in im around 0 72.8%
Final simplification60.6%
(FPCore (re im)
:precision binary64
(if (<= im 700.0)
(sin re)
(if (<= im 3.3e+135)
(/ 1.0 (pow re 4.0))
(+ re (* 0.5 (* re (pow im 2.0)))))))
double code(double re, double im) {
double tmp;
if (im <= 700.0) {
tmp = sin(re);
} else if (im <= 3.3e+135) {
tmp = 1.0 / 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 <= 700.0d0) then
tmp = sin(re)
else if (im <= 3.3d+135) then
tmp = 1.0d0 / (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 <= 700.0) {
tmp = Math.sin(re);
} else if (im <= 3.3e+135) {
tmp = 1.0 / 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 <= 700.0: tmp = math.sin(re) elif im <= 3.3e+135: tmp = 1.0 / 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 <= 700.0) tmp = sin(re); elseif (im <= 3.3e+135) tmp = Float64(1.0 / (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 <= 700.0) tmp = sin(re); elseif (im <= 3.3e+135) tmp = 1.0 / (re ^ 4.0); else tmp = re + (0.5 * (re * (im ^ 2.0))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 700.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 3.3e+135], N[(1.0 / N[Power[re, 4.0], $MachinePrecision]), $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 700:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 3.3 \cdot 10^{+135}:\\
\;\;\;\;\frac{1}{{re}^{4}}\\
\mathbf{else}:\\
\;\;\;\;re + 0.5 \cdot \left(re \cdot {im}^{2}\right)\\
\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 60.3%
if 700 < im < 3.2999999999999999e135Initial 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 83.3%
Simplified83.3%
Applied egg-rr34.1%
Taylor expanded in re around 0 34.3%
if 3.2999999999999999e135 < 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.8%
Simplified75.8%
Taylor expanded in im around 0 72.8%
Final simplification59.5%
(FPCore (re im) :precision binary64 (if (<= im 700.0) (sin re) (/ 1.0 (pow re 4.0))))
double code(double re, double im) {
double tmp;
if (im <= 700.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 <= 700.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 <= 700.0) {
tmp = Math.sin(re);
} else {
tmp = 1.0 / Math.pow(re, 4.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 700.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 <= 700.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 <= 700.0) tmp = sin(re); else tmp = 1.0 / (re ^ 4.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 700.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 700:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{{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 60.3%
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 78.9%
Simplified78.9%
Applied egg-rr28.7%
Taylor expanded in re around 0 29.1%
(FPCore (re im) :precision binary64 (if (<= im 720.0) (sin re) (pow re -4.0)))
double code(double re, double im) {
double tmp;
if (im <= 720.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 <= 720.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 <= 720.0) {
tmp = Math.sin(re);
} else {
tmp = Math.pow(re, -4.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 720.0: tmp = math.sin(re) else: tmp = math.pow(re, -4.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 720.0) tmp = sin(re); else tmp = re ^ -4.0; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 720.0) tmp = sin(re); else tmp = re ^ -4.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 720.0], N[Sin[re], $MachinePrecision], N[Power[re, -4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 720:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;{re}^{-4}\\
\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 60.3%
if 720 < 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 78.9%
Simplified78.9%
Applied egg-rr29.1%
(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 47.4%
(FPCore (re im) :precision binary64 (if (<= re 4.9e+20) re (/ re (+ re (- re re)))))
double code(double re, double im) {
double tmp;
if (re <= 4.9e+20) {
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 <= 4.9d+20) 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 <= 4.9e+20) {
tmp = re;
} else {
tmp = re / (re + (re - re));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 4.9e+20: tmp = re else: tmp = re / (re + (re - re)) return tmp
function code(re, im) tmp = 0.0 if (re <= 4.9e+20) 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 <= 4.9e+20) tmp = re; else tmp = re / (re + (re - re)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 4.9e+20], re, N[(re / N[(re + N[(re - re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 4.9 \cdot 10^{+20}:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;\frac{re}{re + \left(re - re\right)}\\
\end{array}
\end{array}
if re < 4.9e20Initial 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%
Taylor expanded in im around 0 31.1%
if 4.9e20 < 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 32.9%
Simplified32.9%
Applied egg-rr6.9%
(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 65.8%
Simplified65.8%
Taylor expanded in im around 0 23.8%
(FPCore (re im) :precision binary64 5.0)
double code(double re, double im) {
return 5.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 5.0d0
end function
public static double code(double re, double im) {
return 5.0;
}
def code(re, im): return 5.0
function code(re, im) return 5.0 end
function tmp = code(re, im) tmp = 5.0; end
code[re_, im_] := 5.0
\begin{array}{l}
\\
5
\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 65.8%
Simplified65.8%
Applied egg-rr2.4%
sub-neg2.4%
log1p-undefine2.4%
rem-exp-log3.0%
+-commutative3.0%
metadata-eval3.0%
Simplified3.0%
Taylor expanded in re around 0 4.1%
herbie shell --seed 2024087
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))