
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ -1.0 (/ (/ (+ (* c c) (* d d)) c) (- (/ a (/ c d)) b)))))
(if (<= c -8.6e+155)
(/ (- b (/ d (/ c a))) c)
(if (<= c -2.8e-32)
t_0
(if (<= c 9.2e-70)
(/ (- (/ (* c b) d) a) d)
(if (<= c 1.16e+111) t_0 (/ (+ b (* d (* a (/ -1.0 c)))) c)))))))
double code(double a, double b, double c, double d) {
double t_0 = -1.0 / ((((c * c) + (d * d)) / c) / ((a / (c / d)) - b));
double tmp;
if (c <= -8.6e+155) {
tmp = (b - (d / (c / a))) / c;
} else if (c <= -2.8e-32) {
tmp = t_0;
} else if (c <= 9.2e-70) {
tmp = (((c * b) / d) - a) / d;
} else if (c <= 1.16e+111) {
tmp = t_0;
} else {
tmp = (b + (d * (a * (-1.0 / c)))) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (-1.0d0) / ((((c * c) + (d * d)) / c) / ((a / (c / d)) - b))
if (c <= (-8.6d+155)) then
tmp = (b - (d / (c / a))) / c
else if (c <= (-2.8d-32)) then
tmp = t_0
else if (c <= 9.2d-70) then
tmp = (((c * b) / d) - a) / d
else if (c <= 1.16d+111) then
tmp = t_0
else
tmp = (b + (d * (a * ((-1.0d0) / c)))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = -1.0 / ((((c * c) + (d * d)) / c) / ((a / (c / d)) - b));
double tmp;
if (c <= -8.6e+155) {
tmp = (b - (d / (c / a))) / c;
} else if (c <= -2.8e-32) {
tmp = t_0;
} else if (c <= 9.2e-70) {
tmp = (((c * b) / d) - a) / d;
} else if (c <= 1.16e+111) {
tmp = t_0;
} else {
tmp = (b + (d * (a * (-1.0 / c)))) / c;
}
return tmp;
}
def code(a, b, c, d): t_0 = -1.0 / ((((c * c) + (d * d)) / c) / ((a / (c / d)) - b)) tmp = 0 if c <= -8.6e+155: tmp = (b - (d / (c / a))) / c elif c <= -2.8e-32: tmp = t_0 elif c <= 9.2e-70: tmp = (((c * b) / d) - a) / d elif c <= 1.16e+111: tmp = t_0 else: tmp = (b + (d * (a * (-1.0 / c)))) / c return tmp
function code(a, b, c, d) t_0 = Float64(-1.0 / Float64(Float64(Float64(Float64(c * c) + Float64(d * d)) / c) / Float64(Float64(a / Float64(c / d)) - b))) tmp = 0.0 if (c <= -8.6e+155) tmp = Float64(Float64(b - Float64(d / Float64(c / a))) / c); elseif (c <= -2.8e-32) tmp = t_0; elseif (c <= 9.2e-70) tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d); elseif (c <= 1.16e+111) tmp = t_0; else tmp = Float64(Float64(b + Float64(d * Float64(a * Float64(-1.0 / c)))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = -1.0 / ((((c * c) + (d * d)) / c) / ((a / (c / d)) - b)); tmp = 0.0; if (c <= -8.6e+155) tmp = (b - (d / (c / a))) / c; elseif (c <= -2.8e-32) tmp = t_0; elseif (c <= 9.2e-70) tmp = (((c * b) / d) - a) / d; elseif (c <= 1.16e+111) tmp = t_0; else tmp = (b + (d * (a * (-1.0 / c)))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(-1.0 / N[(N[(N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision] / N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -8.6e+155], N[(N[(b - N[(d / N[(c / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -2.8e-32], t$95$0, If[LessEqual[c, 9.2e-70], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1.16e+111], t$95$0, N[(N[(b + N[(d * N[(a * N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-1}{\frac{\frac{c \cdot c + d \cdot d}{c}}{\frac{a}{\frac{c}{d}} - b}}\\
\mathbf{if}\;c \leq -8.6 \cdot 10^{+155}:\\
\;\;\;\;\frac{b - \frac{d}{\frac{c}{a}}}{c}\\
\mathbf{elif}\;c \leq -2.8 \cdot 10^{-32}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 9.2 \cdot 10^{-70}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{elif}\;c \leq 1.16 \cdot 10^{+111}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b + d \cdot \left(a \cdot \frac{-1}{c}\right)}{c}\\
\end{array}
\end{array}
if c < -8.6000000000000005e155Initial program 33.8%
Taylor expanded in c around inf
/-lowering-/.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6485.7%
Simplified85.7%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6494.2%
Applied egg-rr94.2%
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6494.3%
Applied egg-rr94.3%
if -8.6000000000000005e155 < c < -2.7999999999999999e-32 or 9.20000000000000002e-70 < c < 1.16e111Initial program 74.1%
Taylor expanded in c around inf
*-lowering-*.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6474.1%
Simplified74.1%
clear-numN/A
frac-2negN/A
metadata-evalN/A
/-lowering-/.f64N/A
associate-/r*N/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
neg-sub0N/A
sub-negN/A
+-commutativeN/A
associate--r+N/A
neg-sub0N/A
remove-double-negN/A
--lowering--.f64N/A
Applied egg-rr82.1%
if -2.7999999999999999e-32 < c < 9.20000000000000002e-70Initial program 69.2%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
/-lowering-/.f64N/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6492.7%
Simplified92.7%
if 1.16e111 < c Initial program 47.3%
Taylor expanded in c around inf
/-lowering-/.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6482.0%
Simplified82.0%
clear-numN/A
associate-/r/N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f6488.8%
Applied egg-rr88.8%
Final simplification88.6%
(FPCore (a b c d)
:precision binary64
(if (<= c -8e+24)
(/ (- b (/ d (/ c a))) c)
(if (<= c 1.75e-68)
(/ (- (/ (* c b) d) a) d)
(if (<= c 2.15e+68)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(/ (+ b (* d (* a (/ -1.0 c)))) c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -8e+24) {
tmp = (b - (d / (c / a))) / c;
} else if (c <= 1.75e-68) {
tmp = (((c * b) / d) - a) / d;
} else if (c <= 2.15e+68) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = (b + (d * (a * (-1.0 / c)))) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-8d+24)) then
tmp = (b - (d / (c / a))) / c
else if (c <= 1.75d-68) then
tmp = (((c * b) / d) - a) / d
else if (c <= 2.15d+68) then
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
else
tmp = (b + (d * (a * ((-1.0d0) / c)))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -8e+24) {
tmp = (b - (d / (c / a))) / c;
} else if (c <= 1.75e-68) {
tmp = (((c * b) / d) - a) / d;
} else if (c <= 2.15e+68) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = (b + (d * (a * (-1.0 / c)))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -8e+24: tmp = (b - (d / (c / a))) / c elif c <= 1.75e-68: tmp = (((c * b) / d) - a) / d elif c <= 2.15e+68: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) else: tmp = (b + (d * (a * (-1.0 / c)))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -8e+24) tmp = Float64(Float64(b - Float64(d / Float64(c / a))) / c); elseif (c <= 1.75e-68) tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d); elseif (c <= 2.15e+68) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(Float64(b + Float64(d * Float64(a * Float64(-1.0 / c)))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -8e+24) tmp = (b - (d / (c / a))) / c; elseif (c <= 1.75e-68) tmp = (((c * b) / d) - a) / d; elseif (c <= 2.15e+68) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); else tmp = (b + (d * (a * (-1.0 / c)))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -8e+24], N[(N[(b - N[(d / N[(c / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 1.75e-68], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 2.15e+68], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(d * N[(a * N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -8 \cdot 10^{+24}:\\
\;\;\;\;\frac{b - \frac{d}{\frac{c}{a}}}{c}\\
\mathbf{elif}\;c \leq 1.75 \cdot 10^{-68}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{elif}\;c \leq 2.15 \cdot 10^{+68}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + d \cdot \left(a \cdot \frac{-1}{c}\right)}{c}\\
\end{array}
\end{array}
if c < -7.9999999999999999e24Initial program 52.4%
Taylor expanded in c around inf
/-lowering-/.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6481.4%
Simplified81.4%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6487.1%
Applied egg-rr87.1%
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6487.2%
Applied egg-rr87.2%
if -7.9999999999999999e24 < c < 1.75000000000000006e-68Initial program 70.2%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
/-lowering-/.f64N/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6488.2%
Simplified88.2%
if 1.75000000000000006e-68 < c < 2.1500000000000001e68Initial program 86.3%
if 2.1500000000000001e68 < c Initial program 47.3%
Taylor expanded in c around inf
/-lowering-/.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6477.7%
Simplified77.7%
clear-numN/A
associate-/r/N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f6484.0%
Applied egg-rr84.0%
Final simplification86.8%
(FPCore (a b c d)
:precision binary64
(if (<= c -2.1e+25)
(/ (- b (/ d (/ c a))) c)
(if (<= c 3.6e-56)
(/ (- (/ (* c b) d) a) d)
(/ (+ b (* d (* a (/ -1.0 c)))) c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.1e+25) {
tmp = (b - (d / (c / a))) / c;
} else if (c <= 3.6e-56) {
tmp = (((c * b) / d) - a) / d;
} else {
tmp = (b + (d * (a * (-1.0 / c)))) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-2.1d+25)) then
tmp = (b - (d / (c / a))) / c
else if (c <= 3.6d-56) then
tmp = (((c * b) / d) - a) / d
else
tmp = (b + (d * (a * ((-1.0d0) / c)))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.1e+25) {
tmp = (b - (d / (c / a))) / c;
} else if (c <= 3.6e-56) {
tmp = (((c * b) / d) - a) / d;
} else {
tmp = (b + (d * (a * (-1.0 / c)))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -2.1e+25: tmp = (b - (d / (c / a))) / c elif c <= 3.6e-56: tmp = (((c * b) / d) - a) / d else: tmp = (b + (d * (a * (-1.0 / c)))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -2.1e+25) tmp = Float64(Float64(b - Float64(d / Float64(c / a))) / c); elseif (c <= 3.6e-56) tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d); else tmp = Float64(Float64(b + Float64(d * Float64(a * Float64(-1.0 / c)))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -2.1e+25) tmp = (b - (d / (c / a))) / c; elseif (c <= 3.6e-56) tmp = (((c * b) / d) - a) / d; else tmp = (b + (d * (a * (-1.0 / c)))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.1e+25], N[(N[(b - N[(d / N[(c / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 3.6e-56], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b + N[(d * N[(a * N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.1 \cdot 10^{+25}:\\
\;\;\;\;\frac{b - \frac{d}{\frac{c}{a}}}{c}\\
\mathbf{elif}\;c \leq 3.6 \cdot 10^{-56}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + d \cdot \left(a \cdot \frac{-1}{c}\right)}{c}\\
\end{array}
\end{array}
if c < -2.0999999999999999e25Initial program 52.4%
Taylor expanded in c around inf
/-lowering-/.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6481.4%
Simplified81.4%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6487.1%
Applied egg-rr87.1%
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6487.2%
Applied egg-rr87.2%
if -2.0999999999999999e25 < c < 3.59999999999999978e-56Initial program 70.3%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
/-lowering-/.f64N/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6486.9%
Simplified86.9%
if 3.59999999999999978e-56 < c Initial program 60.3%
Taylor expanded in c around inf
/-lowering-/.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6472.7%
Simplified72.7%
clear-numN/A
associate-/r/N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f6477.0%
Applied egg-rr77.0%
Final simplification83.9%
(FPCore (a b c d) :precision binary64 (if (<= c -5.1e+25) (/ (- b (/ d (/ c a))) c) (if (<= c 4.2e-57) (/ (- (/ (* c b) d) a) d) (/ (- b (* d (/ a c))) c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.1e+25) {
tmp = (b - (d / (c / a))) / c;
} else if (c <= 4.2e-57) {
tmp = (((c * b) / d) - a) / d;
} else {
tmp = (b - (d * (a / c))) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-5.1d+25)) then
tmp = (b - (d / (c / a))) / c
else if (c <= 4.2d-57) then
tmp = (((c * b) / d) - a) / d
else
tmp = (b - (d * (a / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.1e+25) {
tmp = (b - (d / (c / a))) / c;
} else if (c <= 4.2e-57) {
tmp = (((c * b) / d) - a) / d;
} else {
tmp = (b - (d * (a / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -5.1e+25: tmp = (b - (d / (c / a))) / c elif c <= 4.2e-57: tmp = (((c * b) / d) - a) / d else: tmp = (b - (d * (a / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -5.1e+25) tmp = Float64(Float64(b - Float64(d / Float64(c / a))) / c); elseif (c <= 4.2e-57) tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d); else tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -5.1e+25) tmp = (b - (d / (c / a))) / c; elseif (c <= 4.2e-57) tmp = (((c * b) / d) - a) / d; else tmp = (b - (d * (a / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -5.1e+25], N[(N[(b - N[(d / N[(c / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 4.2e-57], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.1 \cdot 10^{+25}:\\
\;\;\;\;\frac{b - \frac{d}{\frac{c}{a}}}{c}\\
\mathbf{elif}\;c \leq 4.2 \cdot 10^{-57}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\end{array}
\end{array}
if c < -5.1000000000000004e25Initial program 52.4%
Taylor expanded in c around inf
/-lowering-/.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6481.4%
Simplified81.4%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6487.1%
Applied egg-rr87.1%
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6487.2%
Applied egg-rr87.2%
if -5.1000000000000004e25 < c < 4.1999999999999999e-57Initial program 70.3%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
/-lowering-/.f64N/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6486.9%
Simplified86.9%
if 4.1999999999999999e-57 < c Initial program 60.3%
Taylor expanded in c around inf
/-lowering-/.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6472.7%
Simplified72.7%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6477.0%
Applied egg-rr77.0%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ a (- 0.0 d)))) (if (<= d -2e+57) t_0 (if (<= d 1.06e+43) (/ (- b (/ (* d a) c)) c) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = a / (0.0 - d);
double tmp;
if (d <= -2e+57) {
tmp = t_0;
} else if (d <= 1.06e+43) {
tmp = (b - ((d * a) / c)) / c;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = a / (0.0d0 - d)
if (d <= (-2d+57)) then
tmp = t_0
else if (d <= 1.06d+43) then
tmp = (b - ((d * a) / c)) / c
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = a / (0.0 - d);
double tmp;
if (d <= -2e+57) {
tmp = t_0;
} else if (d <= 1.06e+43) {
tmp = (b - ((d * a) / c)) / c;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = a / (0.0 - d) tmp = 0 if d <= -2e+57: tmp = t_0 elif d <= 1.06e+43: tmp = (b - ((d * a) / c)) / c else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(a / Float64(0.0 - d)) tmp = 0.0 if (d <= -2e+57) tmp = t_0; elseif (d <= 1.06e+43) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = a / (0.0 - d); tmp = 0.0; if (d <= -2e+57) tmp = t_0; elseif (d <= 1.06e+43) tmp = (b - ((d * a) / c)) / c; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(a / N[(0.0 - d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2e+57], t$95$0, If[LessEqual[d, 1.06e+43], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{0 - d}\\
\mathbf{if}\;d \leq -2 \cdot 10^{+57}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 1.06 \cdot 10^{+43}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -2.0000000000000001e57 or 1.06000000000000006e43 < d Initial program 47.7%
Taylor expanded in c around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
/-lowering-/.f6470.5%
Simplified70.5%
if -2.0000000000000001e57 < d < 1.06000000000000006e43Initial program 74.0%
Taylor expanded in c around inf
/-lowering-/.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6482.3%
Simplified82.3%
Final simplification77.2%
(FPCore (a b c d) :precision binary64 (if (<= c -3.6e+14) (/ (- b (/ d (/ c a))) c) (if (<= c 1.5e-57) (/ a (- 0.0 d)) (/ (- b (* d (/ a c))) c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -3.6e+14) {
tmp = (b - (d / (c / a))) / c;
} else if (c <= 1.5e-57) {
tmp = a / (0.0 - d);
} else {
tmp = (b - (d * (a / c))) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-3.6d+14)) then
tmp = (b - (d / (c / a))) / c
else if (c <= 1.5d-57) then
tmp = a / (0.0d0 - d)
else
tmp = (b - (d * (a / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -3.6e+14) {
tmp = (b - (d / (c / a))) / c;
} else if (c <= 1.5e-57) {
tmp = a / (0.0 - d);
} else {
tmp = (b - (d * (a / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -3.6e+14: tmp = (b - (d / (c / a))) / c elif c <= 1.5e-57: tmp = a / (0.0 - d) else: tmp = (b - (d * (a / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -3.6e+14) tmp = Float64(Float64(b - Float64(d / Float64(c / a))) / c); elseif (c <= 1.5e-57) tmp = Float64(a / Float64(0.0 - d)); else tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -3.6e+14) tmp = (b - (d / (c / a))) / c; elseif (c <= 1.5e-57) tmp = a / (0.0 - d); else tmp = (b - (d * (a / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -3.6e+14], N[(N[(b - N[(d / N[(c / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 1.5e-57], N[(a / N[(0.0 - d), $MachinePrecision]), $MachinePrecision], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -3.6 \cdot 10^{+14}:\\
\;\;\;\;\frac{b - \frac{d}{\frac{c}{a}}}{c}\\
\mathbf{elif}\;c \leq 1.5 \cdot 10^{-57}:\\
\;\;\;\;\frac{a}{0 - d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\end{array}
\end{array}
if c < -3.6e14Initial program 54.4%
Taylor expanded in c around inf
/-lowering-/.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6479.5%
Simplified79.5%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6485.1%
Applied egg-rr85.1%
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6485.1%
Applied egg-rr85.1%
if -3.6e14 < c < 1.5e-57Initial program 69.5%
Taylor expanded in c around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
/-lowering-/.f6471.7%
Simplified71.7%
if 1.5e-57 < c Initial program 60.3%
Taylor expanded in c around inf
/-lowering-/.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6472.7%
Simplified72.7%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6477.0%
Applied egg-rr77.0%
Final simplification77.1%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (- b (* d (/ a c))) c))) (if (<= c -4.2e+14) t_0 (if (<= c 2e-56) (/ a (- 0.0 d)) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = (b - (d * (a / c))) / c;
double tmp;
if (c <= -4.2e+14) {
tmp = t_0;
} else if (c <= 2e-56) {
tmp = a / (0.0 - d);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (b - (d * (a / c))) / c
if (c <= (-4.2d+14)) then
tmp = t_0
else if (c <= 2d-56) then
tmp = a / (0.0d0 - d)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (b - (d * (a / c))) / c;
double tmp;
if (c <= -4.2e+14) {
tmp = t_0;
} else if (c <= 2e-56) {
tmp = a / (0.0 - d);
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b - (d * (a / c))) / c tmp = 0 if c <= -4.2e+14: tmp = t_0 elif c <= 2e-56: tmp = a / (0.0 - d) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(d * Float64(a / c))) / c) tmp = 0.0 if (c <= -4.2e+14) tmp = t_0; elseif (c <= 2e-56) tmp = Float64(a / Float64(0.0 - d)); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b - (d * (a / c))) / c; tmp = 0.0; if (c <= -4.2e+14) tmp = t_0; elseif (c <= 2e-56) tmp = a / (0.0 - d); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -4.2e+14], t$95$0, If[LessEqual[c, 2e-56], N[(a / N[(0.0 - d), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - d \cdot \frac{a}{c}}{c}\\
\mathbf{if}\;c \leq -4.2 \cdot 10^{+14}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 2 \cdot 10^{-56}:\\
\;\;\;\;\frac{a}{0 - d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -4.2e14 or 2.0000000000000001e-56 < c Initial program 57.5%
Taylor expanded in c around inf
/-lowering-/.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6476.0%
Simplified76.0%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6480.8%
Applied egg-rr80.8%
if -4.2e14 < c < 2.0000000000000001e-56Initial program 69.5%
Taylor expanded in c around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
/-lowering-/.f6471.7%
Simplified71.7%
Final simplification77.0%
(FPCore (a b c d) :precision binary64 (if (<= c -1.1e+18) (/ b c) (if (<= c 3.6e-56) (/ a (- 0.0 d)) (/ b c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.1e+18) {
tmp = b / c;
} else if (c <= 3.6e-56) {
tmp = a / (0.0 - d);
} else {
tmp = b / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-1.1d+18)) then
tmp = b / c
else if (c <= 3.6d-56) then
tmp = a / (0.0d0 - d)
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.1e+18) {
tmp = b / c;
} else if (c <= 3.6e-56) {
tmp = a / (0.0 - d);
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.1e+18: tmp = b / c elif c <= 3.6e-56: tmp = a / (0.0 - d) else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.1e+18) tmp = Float64(b / c); elseif (c <= 3.6e-56) tmp = Float64(a / Float64(0.0 - d)); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1.1e+18) tmp = b / c; elseif (c <= 3.6e-56) tmp = a / (0.0 - d); else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.1e+18], N[(b / c), $MachinePrecision], If[LessEqual[c, 3.6e-56], N[(a / N[(0.0 - d), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.1 \cdot 10^{+18}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 3.6 \cdot 10^{-56}:\\
\;\;\;\;\frac{a}{0 - d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -1.1e18 or 3.59999999999999978e-56 < c Initial program 56.9%
Taylor expanded in c around inf
/-lowering-/.f6467.6%
Simplified67.6%
if -1.1e18 < c < 3.59999999999999978e-56Initial program 70.1%
Taylor expanded in c around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
/-lowering-/.f6471.4%
Simplified71.4%
Final simplification69.2%
(FPCore (a b c d) :precision binary64 (/ b c))
double code(double a, double b, double c, double d) {
return b / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = b / c
end function
public static double code(double a, double b, double c, double d) {
return b / c;
}
def code(a, b, c, d): return b / c
function code(a, b, c, d) return Float64(b / c) end
function tmp = code(a, b, c, d) tmp = b / c; end
code[a_, b_, c_, d_] := N[(b / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{c}
\end{array}
Initial program 62.5%
Taylor expanded in c around inf
/-lowering-/.f6446.0%
Simplified46.0%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (abs(d) < abs(c)) then
tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
else
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (Math.abs(d) < Math.abs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (b - (a * (d / c))) / (c + (d * (d / c))) else: tmp = (-a + (b * (c / d))) / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (abs(d) < abs(c)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(Float64(-a) + Float64(b * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (abs(d) < abs(c)) tmp = (b - (a * (d / c))) / (c + (d * (d / c))); else tmp = (-a + (b * (c / d))) / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2024192
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
:alt
(! :herbie-platform default (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
(/ (- (* b c) (* a d)) (+ (* c c) (* d d))))