
(FPCore (x y) :precision binary64 (/ (* (* x 2.0) y) (- x y)))
double code(double x, double y) {
return ((x * 2.0) * y) / (x - y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * 2.0d0) * y) / (x - y)
end function
public static double code(double x, double y) {
return ((x * 2.0) * y) / (x - y);
}
def code(x, y): return ((x * 2.0) * y) / (x - y)
function code(x, y) return Float64(Float64(Float64(x * 2.0) * y) / Float64(x - y)) end
function tmp = code(x, y) tmp = ((x * 2.0) * y) / (x - y); end
code[x_, y_] := N[(N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* (* x 2.0) y) (- x y)))
double code(double x, double y) {
return ((x * 2.0) * y) / (x - y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * 2.0d0) * y) / (x - y)
end function
public static double code(double x, double y) {
return ((x * 2.0) * y) / (x - y);
}
def code(x, y): return ((x * 2.0) * y) / (x - y)
function code(x, y) return Float64(Float64(Float64(x * 2.0) * y) / Float64(x - y)) end
function tmp = code(x, y) tmp = ((x * 2.0) * y) / (x - y); end
code[x_, y_] := N[(N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\end{array}
(FPCore (x y) :precision binary64 (if (or (<= y -1e-64) (not (<= y 2e-7))) (/ (* x 2.0) (+ (/ x y) -1.0)) (/ y (fma (/ y x) -0.5 0.5))))
double code(double x, double y) {
double tmp;
if ((y <= -1e-64) || !(y <= 2e-7)) {
tmp = (x * 2.0) / ((x / y) + -1.0);
} else {
tmp = y / fma((y / x), -0.5, 0.5);
}
return tmp;
}
function code(x, y) tmp = 0.0 if ((y <= -1e-64) || !(y <= 2e-7)) tmp = Float64(Float64(x * 2.0) / Float64(Float64(x / y) + -1.0)); else tmp = Float64(y / fma(Float64(y / x), -0.5, 0.5)); end return tmp end
code[x_, y_] := If[Or[LessEqual[y, -1e-64], N[Not[LessEqual[y, 2e-7]], $MachinePrecision]], N[(N[(x * 2.0), $MachinePrecision] / N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(y / N[(N[(y / x), $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{-64} \lor \neg \left(y \leq 2 \cdot 10^{-7}\right):\\
\;\;\;\;\frac{x \cdot 2}{\frac{x}{y} + -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\mathsf{fma}\left(\frac{y}{x}, -0.5, 0.5\right)}\\
\end{array}
\end{array}
if y < -9.99999999999999965e-65 or 1.9999999999999999e-7 < y Initial program 83.4%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 100.0%
if -9.99999999999999965e-65 < y < 1.9999999999999999e-7Initial program 69.7%
*-commutative69.7%
associate-/l*99.1%
div-sub99.1%
sub-neg99.1%
+-commutative99.1%
distribute-neg-frac99.1%
neg-mul-199.1%
*-commutative99.1%
times-frac99.1%
metadata-eval99.1%
metadata-eval99.1%
metadata-eval99.1%
*-inverses99.1%
associate-/r*99.1%
*-commutative99.1%
associate-/r*100.0%
*-inverses100.0%
*-inverses100.0%
associate-/r*100.0%
*-commutative100.0%
fma-def100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(if (<= y -9e-108)
(/ x (fma 0.5 (/ x y) -0.5))
(if (<= y 9.2e-89)
(* y (/ (* x 2.0) (- x y)))
(/ (* x 2.0) (+ (/ x y) -1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -9e-108) {
tmp = x / fma(0.5, (x / y), -0.5);
} else if (y <= 9.2e-89) {
tmp = y * ((x * 2.0) / (x - y));
} else {
tmp = (x * 2.0) / ((x / y) + -1.0);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (y <= -9e-108) tmp = Float64(x / fma(0.5, Float64(x / y), -0.5)); elseif (y <= 9.2e-89) tmp = Float64(y * Float64(Float64(x * 2.0) / Float64(x - y))); else tmp = Float64(Float64(x * 2.0) / Float64(Float64(x / y) + -1.0)); end return tmp end
code[x_, y_] := If[LessEqual[y, -9e-108], N[(x / N[(0.5 * N[(x / y), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9.2e-89], N[(y * N[(N[(x * 2.0), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * 2.0), $MachinePrecision] / N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9 \cdot 10^{-108}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(0.5, \frac{x}{y}, -0.5\right)}\\
\mathbf{elif}\;y \leq 9.2 \cdot 10^{-89}:\\
\;\;\;\;y \cdot \frac{x \cdot 2}{x - y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot 2}{\frac{x}{y} + -1}\\
\end{array}
\end{array}
if y < -8.99999999999999941e-108Initial program 80.9%
associate-*l*82.0%
associate-/l*98.9%
div-sub98.9%
remove-double-neg98.9%
remove-double-neg98.9%
*-lft-identity98.9%
*-inverses98.9%
times-frac98.9%
*-inverses98.9%
*-inverses98.9%
associate-/r*98.9%
*-commutative98.9%
fma-neg98.9%
*-commutative98.9%
associate-/r*98.9%
*-inverses98.9%
metadata-eval98.9%
*-commutative98.9%
associate-/r*98.9%
*-inverses98.9%
metadata-eval98.9%
metadata-eval98.9%
Simplified98.9%
if -8.99999999999999941e-108 < y < 9.200000000000001e-89Initial program 65.6%
associate-*l/100.0%
Simplified100.0%
if 9.200000000000001e-89 < y Initial program 85.1%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 100.0%
Final simplification99.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* 2.0 (/ (* y x) (- x y)))))
(if (<= x -3.2e+145)
(/ y 0.5)
(if (<= x -7.6e-159)
t_0
(if (<= x 9.2e-172) (/ x -0.5) (if (<= x 1.78e+134) t_0 (/ y 0.5)))))))
double code(double x, double y) {
double t_0 = 2.0 * ((y * x) / (x - y));
double tmp;
if (x <= -3.2e+145) {
tmp = y / 0.5;
} else if (x <= -7.6e-159) {
tmp = t_0;
} else if (x <= 9.2e-172) {
tmp = x / -0.5;
} else if (x <= 1.78e+134) {
tmp = t_0;
} else {
tmp = y / 0.5;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = 2.0d0 * ((y * x) / (x - y))
if (x <= (-3.2d+145)) then
tmp = y / 0.5d0
else if (x <= (-7.6d-159)) then
tmp = t_0
else if (x <= 9.2d-172) then
tmp = x / (-0.5d0)
else if (x <= 1.78d+134) then
tmp = t_0
else
tmp = y / 0.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 2.0 * ((y * x) / (x - y));
double tmp;
if (x <= -3.2e+145) {
tmp = y / 0.5;
} else if (x <= -7.6e-159) {
tmp = t_0;
} else if (x <= 9.2e-172) {
tmp = x / -0.5;
} else if (x <= 1.78e+134) {
tmp = t_0;
} else {
tmp = y / 0.5;
}
return tmp;
}
def code(x, y): t_0 = 2.0 * ((y * x) / (x - y)) tmp = 0 if x <= -3.2e+145: tmp = y / 0.5 elif x <= -7.6e-159: tmp = t_0 elif x <= 9.2e-172: tmp = x / -0.5 elif x <= 1.78e+134: tmp = t_0 else: tmp = y / 0.5 return tmp
function code(x, y) t_0 = Float64(2.0 * Float64(Float64(y * x) / Float64(x - y))) tmp = 0.0 if (x <= -3.2e+145) tmp = Float64(y / 0.5); elseif (x <= -7.6e-159) tmp = t_0; elseif (x <= 9.2e-172) tmp = Float64(x / -0.5); elseif (x <= 1.78e+134) tmp = t_0; else tmp = Float64(y / 0.5); end return tmp end
function tmp_2 = code(x, y) t_0 = 2.0 * ((y * x) / (x - y)); tmp = 0.0; if (x <= -3.2e+145) tmp = y / 0.5; elseif (x <= -7.6e-159) tmp = t_0; elseif (x <= 9.2e-172) tmp = x / -0.5; elseif (x <= 1.78e+134) tmp = t_0; else tmp = y / 0.5; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(2.0 * N[(N[(y * x), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.2e+145], N[(y / 0.5), $MachinePrecision], If[LessEqual[x, -7.6e-159], t$95$0, If[LessEqual[x, 9.2e-172], N[(x / -0.5), $MachinePrecision], If[LessEqual[x, 1.78e+134], t$95$0, N[(y / 0.5), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 \cdot \frac{y \cdot x}{x - y}\\
\mathbf{if}\;x \leq -3.2 \cdot 10^{+145}:\\
\;\;\;\;\frac{y}{0.5}\\
\mathbf{elif}\;x \leq -7.6 \cdot 10^{-159}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 9.2 \cdot 10^{-172}:\\
\;\;\;\;\frac{x}{-0.5}\\
\mathbf{elif}\;x \leq 1.78 \cdot 10^{+134}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{0.5}\\
\end{array}
\end{array}
if x < -3.20000000000000008e145 or 1.78000000000000005e134 < x Initial program 65.2%
*-commutative65.2%
associate-/l*98.4%
div-sub98.4%
sub-neg98.4%
+-commutative98.4%
distribute-neg-frac98.4%
neg-mul-198.4%
*-commutative98.4%
times-frac98.4%
metadata-eval98.4%
metadata-eval98.4%
metadata-eval98.4%
*-inverses98.4%
associate-/r*98.4%
*-commutative98.4%
associate-/r*100.0%
*-inverses100.0%
*-inverses100.0%
associate-/r*100.0%
*-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in y around 0 86.6%
if -3.20000000000000008e145 < x < -7.6000000000000002e-159 or 9.1999999999999998e-172 < x < 1.78000000000000005e134Initial program 93.6%
*-commutative93.6%
associate-*l*93.6%
associate-*r/93.6%
Simplified93.6%
if -7.6000000000000002e-159 < x < 9.1999999999999998e-172Initial program 61.3%
associate-*l*61.3%
associate-/l*100.0%
div-sub100.0%
remove-double-neg100.0%
remove-double-neg100.0%
*-lft-identity100.0%
*-inverses100.0%
times-frac100.0%
*-inverses100.0%
*-inverses100.0%
associate-/r*100.0%
*-commutative100.0%
fma-neg100.0%
*-commutative100.0%
associate-/r*100.0%
*-inverses100.0%
metadata-eval100.0%
*-commutative100.0%
associate-/r*100.0%
*-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 86.1%
Final simplification89.7%
(FPCore (x y) :precision binary64 (if (or (<= y -1e-64) (not (<= y 0.0001))) (/ (* x 2.0) (+ (/ x y) -1.0)) (/ y (/ (- x y) (* x 2.0)))))
double code(double x, double y) {
double tmp;
if ((y <= -1e-64) || !(y <= 0.0001)) {
tmp = (x * 2.0) / ((x / y) + -1.0);
} else {
tmp = y / ((x - y) / (x * 2.0));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-1d-64)) .or. (.not. (y <= 0.0001d0))) then
tmp = (x * 2.0d0) / ((x / y) + (-1.0d0))
else
tmp = y / ((x - y) / (x * 2.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1e-64) || !(y <= 0.0001)) {
tmp = (x * 2.0) / ((x / y) + -1.0);
} else {
tmp = y / ((x - y) / (x * 2.0));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1e-64) or not (y <= 0.0001): tmp = (x * 2.0) / ((x / y) + -1.0) else: tmp = y / ((x - y) / (x * 2.0)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1e-64) || !(y <= 0.0001)) tmp = Float64(Float64(x * 2.0) / Float64(Float64(x / y) + -1.0)); else tmp = Float64(y / Float64(Float64(x - y) / Float64(x * 2.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1e-64) || ~((y <= 0.0001))) tmp = (x * 2.0) / ((x / y) + -1.0); else tmp = y / ((x - y) / (x * 2.0)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1e-64], N[Not[LessEqual[y, 0.0001]], $MachinePrecision]], N[(N[(x * 2.0), $MachinePrecision] / N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(y / N[(N[(x - y), $MachinePrecision] / N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{-64} \lor \neg \left(y \leq 0.0001\right):\\
\;\;\;\;\frac{x \cdot 2}{\frac{x}{y} + -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{x - y}{x \cdot 2}}\\
\end{array}
\end{array}
if y < -9.99999999999999965e-65 or 1.00000000000000005e-4 < y Initial program 83.4%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 100.0%
if -9.99999999999999965e-65 < y < 1.00000000000000005e-4Initial program 69.7%
associate-*l/99.0%
Simplified99.0%
*-commutative99.0%
clear-num99.0%
un-div-inv99.1%
Applied egg-rr99.1%
Final simplification99.6%
(FPCore (x y) :precision binary64 (if (<= y -7e+202) (/ x -0.5) (if (<= y 2.5e+143) (* y (/ (* x 2.0) (- x y))) (/ x -0.5))))
double code(double x, double y) {
double tmp;
if (y <= -7e+202) {
tmp = x / -0.5;
} else if (y <= 2.5e+143) {
tmp = y * ((x * 2.0) / (x - y));
} else {
tmp = x / -0.5;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-7d+202)) then
tmp = x / (-0.5d0)
else if (y <= 2.5d+143) then
tmp = y * ((x * 2.0d0) / (x - y))
else
tmp = x / (-0.5d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -7e+202) {
tmp = x / -0.5;
} else if (y <= 2.5e+143) {
tmp = y * ((x * 2.0) / (x - y));
} else {
tmp = x / -0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -7e+202: tmp = x / -0.5 elif y <= 2.5e+143: tmp = y * ((x * 2.0) / (x - y)) else: tmp = x / -0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= -7e+202) tmp = Float64(x / -0.5); elseif (y <= 2.5e+143) tmp = Float64(y * Float64(Float64(x * 2.0) / Float64(x - y))); else tmp = Float64(x / -0.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -7e+202) tmp = x / -0.5; elseif (y <= 2.5e+143) tmp = y * ((x * 2.0) / (x - y)); else tmp = x / -0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -7e+202], N[(x / -0.5), $MachinePrecision], If[LessEqual[y, 2.5e+143], N[(y * N[(N[(x * 2.0), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+202}:\\
\;\;\;\;\frac{x}{-0.5}\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+143}:\\
\;\;\;\;y \cdot \frac{x \cdot 2}{x - y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{-0.5}\\
\end{array}
\end{array}
if y < -6.99999999999999975e202 or 2.50000000000000006e143 < y Initial program 77.2%
associate-*l*77.2%
associate-/l*99.9%
div-sub100.0%
remove-double-neg100.0%
remove-double-neg100.0%
*-lft-identity100.0%
*-inverses100.0%
times-frac100.0%
*-inverses100.0%
*-inverses100.0%
associate-/r*100.0%
*-commutative100.0%
fma-neg100.0%
*-commutative100.0%
associate-/r*100.0%
*-inverses100.0%
metadata-eval100.0%
*-commutative100.0%
associate-/r*100.0%
*-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 92.1%
if -6.99999999999999975e202 < y < 2.50000000000000006e143Initial program 77.5%
associate-*l/95.9%
Simplified95.9%
Final simplification95.0%
(FPCore (x y) :precision binary64 (if (<= x -1.45e-5) (/ y 0.5) (if (<= x 9.5e+54) (/ x -0.5) (/ y 0.5))))
double code(double x, double y) {
double tmp;
if (x <= -1.45e-5) {
tmp = y / 0.5;
} else if (x <= 9.5e+54) {
tmp = x / -0.5;
} else {
tmp = y / 0.5;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.45d-5)) then
tmp = y / 0.5d0
else if (x <= 9.5d+54) then
tmp = x / (-0.5d0)
else
tmp = y / 0.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.45e-5) {
tmp = y / 0.5;
} else if (x <= 9.5e+54) {
tmp = x / -0.5;
} else {
tmp = y / 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.45e-5: tmp = y / 0.5 elif x <= 9.5e+54: tmp = x / -0.5 else: tmp = y / 0.5 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.45e-5) tmp = Float64(y / 0.5); elseif (x <= 9.5e+54) tmp = Float64(x / -0.5); else tmp = Float64(y / 0.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.45e-5) tmp = y / 0.5; elseif (x <= 9.5e+54) tmp = x / -0.5; else tmp = y / 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.45e-5], N[(y / 0.5), $MachinePrecision], If[LessEqual[x, 9.5e+54], N[(x / -0.5), $MachinePrecision], N[(y / 0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \cdot 10^{-5}:\\
\;\;\;\;\frac{y}{0.5}\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{+54}:\\
\;\;\;\;\frac{x}{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{0.5}\\
\end{array}
\end{array}
if x < -1.45e-5 or 9.4999999999999999e54 < x Initial program 75.8%
*-commutative75.8%
associate-/l*99.0%
div-sub99.0%
sub-neg99.0%
+-commutative99.0%
distribute-neg-frac99.0%
neg-mul-199.0%
*-commutative99.0%
times-frac99.0%
metadata-eval99.0%
metadata-eval99.0%
metadata-eval99.0%
*-inverses99.0%
associate-/r*99.0%
*-commutative99.0%
associate-/r*100.0%
*-inverses100.0%
*-inverses100.0%
associate-/r*100.0%
*-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in y around 0 78.5%
if -1.45e-5 < x < 9.4999999999999999e54Initial program 78.5%
associate-*l*78.5%
associate-/l*99.4%
div-sub99.4%
remove-double-neg99.4%
remove-double-neg99.4%
*-lft-identity99.4%
*-inverses99.4%
times-frac99.4%
*-inverses99.4%
*-inverses99.4%
associate-/r*99.4%
*-commutative99.4%
fma-neg99.4%
*-commutative99.4%
associate-/r*99.4%
*-inverses99.4%
metadata-eval99.4%
*-commutative99.4%
associate-/r*99.4%
*-inverses99.4%
metadata-eval99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around 0 76.4%
Final simplification77.3%
(FPCore (x y) :precision binary64 (/ x -0.5))
double code(double x, double y) {
return x / -0.5;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / (-0.5d0)
end function
public static double code(double x, double y) {
return x / -0.5;
}
def code(x, y): return x / -0.5
function code(x, y) return Float64(x / -0.5) end
function tmp = code(x, y) tmp = x / -0.5; end
code[x_, y_] := N[(x / -0.5), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{-0.5}
\end{array}
Initial program 77.4%
associate-*l*77.8%
associate-/l*89.4%
div-sub89.4%
remove-double-neg89.4%
remove-double-neg89.4%
*-lft-identity89.4%
*-inverses89.4%
times-frac89.4%
*-inverses89.4%
*-inverses89.4%
associate-/r*89.4%
*-commutative89.4%
fma-neg89.4%
*-commutative89.4%
associate-/r*89.4%
*-inverses89.4%
metadata-eval89.4%
*-commutative89.4%
associate-/r*89.4%
*-inverses89.4%
metadata-eval89.4%
metadata-eval89.4%
Simplified89.4%
Taylor expanded in x around 0 54.7%
Final simplification54.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (/ (* 2.0 x) (- x y)) y)))
(if (< x -1.7210442634149447e+81)
t_0
(if (< x 83645045635564430.0) (/ (* x 2.0) (/ (- x y) y)) t_0))))
double code(double x, double y) {
double t_0 = ((2.0 * x) / (x - y)) * y;
double tmp;
if (x < -1.7210442634149447e+81) {
tmp = t_0;
} else if (x < 83645045635564430.0) {
tmp = (x * 2.0) / ((x - y) / y);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = ((2.0d0 * x) / (x - y)) * y
if (x < (-1.7210442634149447d+81)) then
tmp = t_0
else if (x < 83645045635564430.0d0) then
tmp = (x * 2.0d0) / ((x - y) / y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = ((2.0 * x) / (x - y)) * y;
double tmp;
if (x < -1.7210442634149447e+81) {
tmp = t_0;
} else if (x < 83645045635564430.0) {
tmp = (x * 2.0) / ((x - y) / y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = ((2.0 * x) / (x - y)) * y tmp = 0 if x < -1.7210442634149447e+81: tmp = t_0 elif x < 83645045635564430.0: tmp = (x * 2.0) / ((x - y) / y) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(Float64(2.0 * x) / Float64(x - y)) * y) tmp = 0.0 if (x < -1.7210442634149447e+81) tmp = t_0; elseif (x < 83645045635564430.0) tmp = Float64(Float64(x * 2.0) / Float64(Float64(x - y) / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = ((2.0 * x) / (x - y)) * y; tmp = 0.0; if (x < -1.7210442634149447e+81) tmp = t_0; elseif (x < 83645045635564430.0) tmp = (x * 2.0) / ((x - y) / y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(2.0 * x), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]}, If[Less[x, -1.7210442634149447e+81], t$95$0, If[Less[x, 83645045635564430.0], N[(N[(x * 2.0), $MachinePrecision] / N[(N[(x - y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2 \cdot x}{x - y} \cdot y\\
\mathbf{if}\;x < -1.7210442634149447 \cdot 10^{+81}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x < 83645045635564430:\\
\;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
herbie shell --seed 2023238
(FPCore (x y)
:name "Linear.Projection:perspective from linear-1.19.1.3, B"
:precision binary64
:herbie-target
(if (< x -1.7210442634149447e+81) (* (/ (* 2.0 x) (- x y)) y) (if (< x 83645045635564430.0) (/ (* x 2.0) (/ (- x y) y)) (* (/ (* 2.0 x) (- x y)) y)))
(/ (* (* x 2.0) y) (- x y)))