
(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
(let* ((t_0 (sqrt (pow re -8.0))))
(if (<= im 8500000000.0)
(sin re)
(if (<= im 3.8e+127)
t_0
(if (<= im 3.4e+145)
(log1p (expm1 re))
(if (<= im 1.1e+154) t_0 (+ re (* 0.5 (* re (pow im 2.0))))))))))
double code(double re, double im) {
double t_0 = sqrt(pow(re, -8.0));
double tmp;
if (im <= 8500000000.0) {
tmp = sin(re);
} else if (im <= 3.8e+127) {
tmp = t_0;
} else if (im <= 3.4e+145) {
tmp = log1p(expm1(re));
} else if (im <= 1.1e+154) {
tmp = t_0;
} else {
tmp = re + (0.5 * (re * pow(im, 2.0)));
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = Math.sqrt(Math.pow(re, -8.0));
double tmp;
if (im <= 8500000000.0) {
tmp = Math.sin(re);
} else if (im <= 3.8e+127) {
tmp = t_0;
} else if (im <= 3.4e+145) {
tmp = Math.log1p(Math.expm1(re));
} else if (im <= 1.1e+154) {
tmp = t_0;
} else {
tmp = re + (0.5 * (re * Math.pow(im, 2.0)));
}
return tmp;
}
def code(re, im): t_0 = math.sqrt(math.pow(re, -8.0)) tmp = 0 if im <= 8500000000.0: tmp = math.sin(re) elif im <= 3.8e+127: tmp = t_0 elif im <= 3.4e+145: tmp = math.log1p(math.expm1(re)) elif im <= 1.1e+154: tmp = t_0 else: tmp = re + (0.5 * (re * math.pow(im, 2.0))) return tmp
function code(re, im) t_0 = sqrt((re ^ -8.0)) tmp = 0.0 if (im <= 8500000000.0) tmp = sin(re); elseif (im <= 3.8e+127) tmp = t_0; elseif (im <= 3.4e+145) tmp = log1p(expm1(re)); elseif (im <= 1.1e+154) tmp = t_0; else tmp = Float64(re + Float64(0.5 * Float64(re * (im ^ 2.0)))); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[Sqrt[N[Power[re, -8.0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[im, 8500000000.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 3.8e+127], t$95$0, If[LessEqual[im, 3.4e+145], N[Log[1 + N[(Exp[re] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 1.1e+154], t$95$0, N[(re + N[(0.5 * N[(re * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{{re}^{-8}}\\
\mathbf{if}\;im \leq 8500000000:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 3.8 \cdot 10^{+127}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;im \leq 3.4 \cdot 10^{+145}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\
\mathbf{elif}\;im \leq 1.1 \cdot 10^{+154}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;re + 0.5 \cdot \left(re \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 8.5e9Initial 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 63.6%
if 8.5e9 < im < 3.7999999999999998e127 or 3.3999999999999999e145 < im < 1.1000000000000001e154Initial 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 72.4%
Simplified72.4%
Applied egg-rr15.0%
add-sqr-sqrt15.0%
sqrt-unprod18.2%
exp-to-pow18.2%
exp-to-pow18.3%
pow-prod-up18.3%
metadata-eval18.3%
Applied egg-rr18.3%
if 3.7999999999999998e127 < im < 3.3999999999999999e145Initial 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 50.0%
Simplified50.0%
Applied egg-rr50.0%
if 1.1000000000000001e154 < 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 71.0%
Simplified71.0%
Taylor expanded in im around 0 71.0%
Final simplification59.2%
(FPCore (re im)
:precision binary64
(if (<= im 0.00052)
(sin re)
(if (<= im 6.6e+76)
(* (* 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 <= 0.00052) {
tmp = sin(re);
} else if (im <= 6.6e+76) {
tmp = (0.5 * re) * (exp(-im) + exp(im));
} else {
tmp = 0.041666666666666664 * (sin(re) * pow(im, 4.0));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 0.00052d0) then
tmp = sin(re)
else if (im <= 6.6d+76) then
tmp = (0.5d0 * re) * (exp(-im) + exp(im))
else
tmp = 0.041666666666666664d0 * (sin(re) * (im ** 4.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 0.00052) {
tmp = Math.sin(re);
} else if (im <= 6.6e+76) {
tmp = (0.5 * re) * (Math.exp(-im) + Math.exp(im));
} else {
tmp = 0.041666666666666664 * (Math.sin(re) * Math.pow(im, 4.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.00052: tmp = math.sin(re) elif im <= 6.6e+76: tmp = (0.5 * re) * (math.exp(-im) + math.exp(im)) else: tmp = 0.041666666666666664 * (math.sin(re) * math.pow(im, 4.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 0.00052) tmp = sin(re); elseif (im <= 6.6e+76) 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
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.00052) tmp = sin(re); elseif (im <= 6.6e+76) tmp = (0.5 * re) * (exp(-im) + exp(im)); else tmp = 0.041666666666666664 * (sin(re) * (im ^ 4.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.00052], N[Sin[re], $MachinePrecision], If[LessEqual[im, 6.6e+76], 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 0.00052:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 6.6 \cdot 10^{+76}:\\
\;\;\;\;\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 < 5.19999999999999954e-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 64.3%
if 5.19999999999999954e-4 < im < 6.6000000000000001e76Initial 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 68.8%
Simplified68.8%
if 6.6000000000000001e76 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 96.2%
Simplified96.2%
Taylor expanded in im around inf 100.0%
Final simplification71.5%
(FPCore (re im)
:precision binary64
(if (<= im 0.0007)
(* (sin re) (+ (* 0.5 (pow im 2.0)) 1.0))
(if (<= im 6.6e+76)
(* (* 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 <= 0.0007) {
tmp = sin(re) * ((0.5 * pow(im, 2.0)) + 1.0);
} else if (im <= 6.6e+76) {
tmp = (0.5 * re) * (exp(-im) + exp(im));
} else {
tmp = 0.041666666666666664 * (sin(re) * pow(im, 4.0));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 0.0007d0) then
tmp = sin(re) * ((0.5d0 * (im ** 2.0d0)) + 1.0d0)
else if (im <= 6.6d+76) then
tmp = (0.5d0 * re) * (exp(-im) + exp(im))
else
tmp = 0.041666666666666664d0 * (sin(re) * (im ** 4.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 0.0007) {
tmp = Math.sin(re) * ((0.5 * Math.pow(im, 2.0)) + 1.0);
} else if (im <= 6.6e+76) {
tmp = (0.5 * re) * (Math.exp(-im) + Math.exp(im));
} else {
tmp = 0.041666666666666664 * (Math.sin(re) * Math.pow(im, 4.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.0007: tmp = math.sin(re) * ((0.5 * math.pow(im, 2.0)) + 1.0) elif im <= 6.6e+76: tmp = (0.5 * re) * (math.exp(-im) + math.exp(im)) else: tmp = 0.041666666666666664 * (math.sin(re) * math.pow(im, 4.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 0.0007) tmp = Float64(sin(re) * Float64(Float64(0.5 * (im ^ 2.0)) + 1.0)); elseif (im <= 6.6e+76) 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
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.0007) tmp = sin(re) * ((0.5 * (im ^ 2.0)) + 1.0); elseif (im <= 6.6e+76) tmp = (0.5 * re) * (exp(-im) + exp(im)); else tmp = 0.041666666666666664 * (sin(re) * (im ^ 4.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.0007], N[(N[Sin[re], $MachinePrecision] * N[(N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 6.6e+76], 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 0.0007:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2} + 1\right)\\
\mathbf{elif}\;im \leq 6.6 \cdot 10^{+76}:\\
\;\;\;\;\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 < 6.99999999999999993e-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 81.7%
Simplified81.7%
if 6.99999999999999993e-4 < im < 6.6000000000000001e76Initial 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 68.8%
Simplified68.8%
if 6.6000000000000001e76 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 96.2%
Simplified96.2%
Taylor expanded in im around inf 100.0%
Final simplification84.5%
(FPCore (re im)
:precision binary64
(if (<= im 8500000000.0)
(sin re)
(if (<= im 6.6e+76)
(sqrt (pow re -8.0))
(* 0.041666666666666664 (* (sin re) (pow im 4.0))))))
double code(double re, double im) {
double tmp;
if (im <= 8500000000.0) {
tmp = sin(re);
} else if (im <= 6.6e+76) {
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 <= 8500000000.0d0) then
tmp = sin(re)
else if (im <= 6.6d+76) 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 <= 8500000000.0) {
tmp = Math.sin(re);
} else if (im <= 6.6e+76) {
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 <= 8500000000.0: tmp = math.sin(re) elif im <= 6.6e+76: 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 <= 8500000000.0) tmp = sin(re); elseif (im <= 6.6e+76) 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 <= 8500000000.0) tmp = sin(re); elseif (im <= 6.6e+76) 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, 8500000000.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 6.6e+76], 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 8500000000:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 6.6 \cdot 10^{+76}:\\
\;\;\;\;\sqrt{{re}^{-8}}\\
\mathbf{else}:\\
\;\;\;\;0.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\right)\\
\end{array}
\end{array}
if im < 8.5e9Initial 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 63.6%
if 8.5e9 < im < 6.6000000000000001e76Initial 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 71.4%
Simplified71.4%
Applied egg-rr15.7%
add-sqr-sqrt15.7%
sqrt-unprod22.5%
exp-to-pow22.5%
exp-to-pow22.6%
pow-prod-up22.6%
metadata-eval22.6%
Applied egg-rr22.6%
if 6.6000000000000001e76 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 96.2%
Simplified96.2%
Taylor expanded in im around inf 100.0%
Final simplification68.5%
(FPCore (re im) :precision binary64 (if (<= im 8500000000.0) (sin re) (if (<= im 2.4e+110) (pow re -4.0) (+ re (* 0.5 (* re (pow im 2.0)))))))
double code(double re, double im) {
double tmp;
if (im <= 8500000000.0) {
tmp = sin(re);
} else if (im <= 2.4e+110) {
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 <= 8500000000.0d0) then
tmp = sin(re)
else if (im <= 2.4d+110) 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 <= 8500000000.0) {
tmp = Math.sin(re);
} else if (im <= 2.4e+110) {
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 <= 8500000000.0: tmp = math.sin(re) elif im <= 2.4e+110: 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 <= 8500000000.0) tmp = sin(re); elseif (im <= 2.4e+110) 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 <= 8500000000.0) tmp = sin(re); elseif (im <= 2.4e+110) tmp = re ^ -4.0; else tmp = re + (0.5 * (re * (im ^ 2.0))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 8500000000.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 2.4e+110], 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 8500000000:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 2.4 \cdot 10^{+110}:\\
\;\;\;\;{re}^{-4}\\
\mathbf{else}:\\
\;\;\;\;re + 0.5 \cdot \left(re \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 8.5e9Initial 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 63.6%
if 8.5e9 < im < 2.40000000000000012e110Initial 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 72.2%
Simplified72.2%
Applied egg-rr12.5%
if 2.40000000000000012e110 < 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 69.6%
Simplified69.6%
Taylor expanded in im around 0 57.2%
Final simplification58.9%
(FPCore (re im) :precision binary64 (if (<= im 8500000000.0) (sin re) (pow re -4.0)))
double code(double re, double im) {
double tmp;
if (im <= 8500000000.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 <= 8500000000.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 <= 8500000000.0) {
tmp = Math.sin(re);
} else {
tmp = Math.pow(re, -4.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 8500000000.0: tmp = math.sin(re) else: tmp = math.pow(re, -4.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 8500000000.0) tmp = sin(re); else tmp = re ^ -4.0; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 8500000000.0) tmp = sin(re); else tmp = re ^ -4.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 8500000000.0], N[Sin[re], $MachinePrecision], N[Power[re, -4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 8500000000:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;{re}^{-4}\\
\end{array}
\end{array}
if im < 8.5e9Initial 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 63.6%
if 8.5e9 < 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.3%
Simplified70.3%
Applied egg-rr15.3%
Final simplification51.6%
(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 48.4%
Final simplification48.4%
(FPCore (re im) :precision binary64 (if (<= re 0.0078) re (/ re (+ re (- re re)))))
double code(double re, double im) {
double tmp;
if (re <= 0.0078) {
tmp = re;
} else {
tmp = re / (re + (re - re));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 0.0078d0) then
tmp = re
else
tmp = re / (re + (re - re))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 0.0078) {
tmp = re;
} else {
tmp = re / (re + (re - re));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 0.0078: tmp = re else: tmp = re / (re + (re - re)) return tmp
function code(re, im) tmp = 0.0 if (re <= 0.0078) tmp = re; else tmp = Float64(re / Float64(re + Float64(re - re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 0.0078) tmp = re; else tmp = re / (re + (re - re)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 0.0078], re, N[(re / N[(re + N[(re - re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 0.0078:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;\frac{re}{re + \left(re - re\right)}\\
\end{array}
\end{array}
if re < 0.0077999999999999996Initial 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.3%
Simplified76.3%
Taylor expanded in im around 0 34.7%
if 0.0077999999999999996 < 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 29.7%
Simplified29.7%
Applied egg-rr6.8%
Final simplification26.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 63.2%
Simplified63.2%
Taylor expanded in im around 0 25.8%
Final simplification25.8%
herbie shell --seed 2024089
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))