
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
def code(x, y): return (x - y) / (2.0 - (x + y))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
def code(x, y): return (x - y) / (2.0 - (x + y))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
def code(x, y): return (x - y) / (2.0 - (x + y))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (- 2.0 x))))
(if (<= y -2.3e+46)
1.0
(if (<= y -1.7e-94)
t_0
(if (<= y -1.9e-130) (* y -0.5) (if (<= y 3.5e+63) t_0 1.0))))))
double code(double x, double y) {
double t_0 = x / (2.0 - x);
double tmp;
if (y <= -2.3e+46) {
tmp = 1.0;
} else if (y <= -1.7e-94) {
tmp = t_0;
} else if (y <= -1.9e-130) {
tmp = y * -0.5;
} else if (y <= 3.5e+63) {
tmp = t_0;
} else {
tmp = 1.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 = x / (2.0d0 - x)
if (y <= (-2.3d+46)) then
tmp = 1.0d0
else if (y <= (-1.7d-94)) then
tmp = t_0
else if (y <= (-1.9d-130)) then
tmp = y * (-0.5d0)
else if (y <= 3.5d+63) then
tmp = t_0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (2.0 - x);
double tmp;
if (y <= -2.3e+46) {
tmp = 1.0;
} else if (y <= -1.7e-94) {
tmp = t_0;
} else if (y <= -1.9e-130) {
tmp = y * -0.5;
} else if (y <= 3.5e+63) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = x / (2.0 - x) tmp = 0 if y <= -2.3e+46: tmp = 1.0 elif y <= -1.7e-94: tmp = t_0 elif y <= -1.9e-130: tmp = y * -0.5 elif y <= 3.5e+63: tmp = t_0 else: tmp = 1.0 return tmp
function code(x, y) t_0 = Float64(x / Float64(2.0 - x)) tmp = 0.0 if (y <= -2.3e+46) tmp = 1.0; elseif (y <= -1.7e-94) tmp = t_0; elseif (y <= -1.9e-130) tmp = Float64(y * -0.5); elseif (y <= 3.5e+63) tmp = t_0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (2.0 - x); tmp = 0.0; if (y <= -2.3e+46) tmp = 1.0; elseif (y <= -1.7e-94) tmp = t_0; elseif (y <= -1.9e-130) tmp = y * -0.5; elseif (y <= 3.5e+63) tmp = t_0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.3e+46], 1.0, If[LessEqual[y, -1.7e-94], t$95$0, If[LessEqual[y, -1.9e-130], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 3.5e+63], t$95$0, 1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -2.3 \cdot 10^{+46}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.7 \cdot 10^{-94}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.9 \cdot 10^{-130}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{+63}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.3000000000000001e46 or 3.50000000000000029e63 < y Initial program 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 82.8%
if -2.3000000000000001e46 < y < -1.6999999999999999e-94 or -1.8999999999999999e-130 < y < 3.50000000000000029e63Initial program 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 73.1%
if -1.6999999999999999e-94 < y < -1.8999999999999999e-130Initial program 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 84.5%
associate-*r/84.5%
mul-1-neg84.5%
Simplified84.5%
Taylor expanded in y around 0 84.5%
*-commutative84.5%
Simplified84.5%
Final simplification78.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))) (t_1 (/ x (- 2.0 x))))
(if (<= y -2.4e+46)
t_0
(if (<= y -5.5e-89)
t_1
(if (<= y -1.9e-130) (* y -0.5) (if (<= y 3.5e+63) t_1 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double t_1 = x / (2.0 - x);
double tmp;
if (y <= -2.4e+46) {
tmp = t_0;
} else if (y <= -5.5e-89) {
tmp = t_1;
} else if (y <= -1.9e-130) {
tmp = y * -0.5;
} else if (y <= 3.5e+63) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x / y)
t_1 = x / (2.0d0 - x)
if (y <= (-2.4d+46)) then
tmp = t_0
else if (y <= (-5.5d-89)) then
tmp = t_1
else if (y <= (-1.9d-130)) then
tmp = y * (-0.5d0)
else if (y <= 3.5d+63) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double t_1 = x / (2.0 - x);
double tmp;
if (y <= -2.4e+46) {
tmp = t_0;
} else if (y <= -5.5e-89) {
tmp = t_1;
} else if (y <= -1.9e-130) {
tmp = y * -0.5;
} else if (y <= 3.5e+63) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (x / y) t_1 = x / (2.0 - x) tmp = 0 if y <= -2.4e+46: tmp = t_0 elif y <= -5.5e-89: tmp = t_1 elif y <= -1.9e-130: tmp = y * -0.5 elif y <= 3.5e+63: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(x / y)) t_1 = Float64(x / Float64(2.0 - x)) tmp = 0.0 if (y <= -2.4e+46) tmp = t_0; elseif (y <= -5.5e-89) tmp = t_1; elseif (y <= -1.9e-130) tmp = Float64(y * -0.5); elseif (y <= 3.5e+63) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (x / y); t_1 = x / (2.0 - x); tmp = 0.0; if (y <= -2.4e+46) tmp = t_0; elseif (y <= -5.5e-89) tmp = t_1; elseif (y <= -1.9e-130) tmp = y * -0.5; elseif (y <= 3.5e+63) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.4e+46], t$95$0, If[LessEqual[y, -5.5e-89], t$95$1, If[LessEqual[y, -1.9e-130], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 3.5e+63], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
t_1 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -2.4 \cdot 10^{+46}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -5.5 \cdot 10^{-89}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -1.9 \cdot 10^{-130}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{+63}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -2.40000000000000008e46 or 3.50000000000000029e63 < y Initial program 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 83.2%
mul-1-neg83.2%
Simplified83.2%
Taylor expanded in x around 0 83.2%
associate-*r/83.2%
mul-1-neg83.2%
Simplified83.2%
if -2.40000000000000008e46 < y < -5.50000000000000012e-89 or -1.8999999999999999e-130 < y < 3.50000000000000029e63Initial program 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 73.1%
if -5.50000000000000012e-89 < y < -1.8999999999999999e-130Initial program 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 84.5%
associate-*r/84.5%
mul-1-neg84.5%
Simplified84.5%
Taylor expanded in y around 0 84.5%
*-commutative84.5%
Simplified84.5%
Final simplification78.3%
(FPCore (x y) :precision binary64 (if (<= x -7800000000.0) (/ x (- 2.0 x)) (if (<= x 1.55e+62) (/ (- x y) (- 2.0 y)) -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -7800000000.0) {
tmp = x / (2.0 - x);
} else if (x <= 1.55e+62) {
tmp = (x - y) / (2.0 - y);
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-7800000000.0d0)) then
tmp = x / (2.0d0 - x)
else if (x <= 1.55d+62) then
tmp = (x - y) / (2.0d0 - y)
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -7800000000.0) {
tmp = x / (2.0 - x);
} else if (x <= 1.55e+62) {
tmp = (x - y) / (2.0 - y);
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -7800000000.0: tmp = x / (2.0 - x) elif x <= 1.55e+62: tmp = (x - y) / (2.0 - y) else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -7800000000.0) tmp = Float64(x / Float64(2.0 - x)); elseif (x <= 1.55e+62) tmp = Float64(Float64(x - y) / Float64(2.0 - y)); else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -7800000000.0) tmp = x / (2.0 - x); elseif (x <= 1.55e+62) tmp = (x - y) / (2.0 - y); else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -7800000000.0], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.55e+62], N[(N[(x - y), $MachinePrecision] / N[(2.0 - y), $MachinePrecision]), $MachinePrecision], -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7800000000:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{+62}:\\
\;\;\;\;\frac{x - y}{2 - y}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -7.8e9Initial program 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 72.7%
if -7.8e9 < x < 1.55000000000000007e62Initial program 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 97.5%
if 1.55000000000000007e62 < x Initial program 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 78.5%
Final simplification87.1%
(FPCore (x y) :precision binary64 (if (<= x -8500000000.0) (/ x (- 2.0 x)) (if (<= x 3.1e+63) (/ (- y) (- 2.0 y)) -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -8500000000.0) {
tmp = x / (2.0 - x);
} else if (x <= 3.1e+63) {
tmp = -y / (2.0 - y);
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-8500000000.0d0)) then
tmp = x / (2.0d0 - x)
else if (x <= 3.1d+63) then
tmp = -y / (2.0d0 - y)
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -8500000000.0) {
tmp = x / (2.0 - x);
} else if (x <= 3.1e+63) {
tmp = -y / (2.0 - y);
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -8500000000.0: tmp = x / (2.0 - x) elif x <= 3.1e+63: tmp = -y / (2.0 - y) else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -8500000000.0) tmp = Float64(x / Float64(2.0 - x)); elseif (x <= 3.1e+63) tmp = Float64(Float64(-y) / Float64(2.0 - y)); else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -8500000000.0) tmp = x / (2.0 - x); elseif (x <= 3.1e+63) tmp = -y / (2.0 - y); else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -8500000000.0], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.1e+63], N[((-y) / N[(2.0 - y), $MachinePrecision]), $MachinePrecision], -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8500000000:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{+63}:\\
\;\;\;\;\frac{-y}{2 - y}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -8.5e9Initial program 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 72.7%
if -8.5e9 < x < 3.1000000000000001e63Initial program 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 82.3%
associate-*r/82.3%
mul-1-neg82.3%
Simplified82.3%
if 3.1000000000000001e63 < x Initial program 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 78.5%
Final simplification79.1%
(FPCore (x y)
:precision binary64
(if (<= y -3.25e+19)
1.0
(if (<= y -8.8e-94)
-1.0
(if (<= y -6e-199) (* y -0.5) (if (<= y 3.7e+63) -1.0 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -3.25e+19) {
tmp = 1.0;
} else if (y <= -8.8e-94) {
tmp = -1.0;
} else if (y <= -6e-199) {
tmp = y * -0.5;
} else if (y <= 3.7e+63) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-3.25d+19)) then
tmp = 1.0d0
else if (y <= (-8.8d-94)) then
tmp = -1.0d0
else if (y <= (-6d-199)) then
tmp = y * (-0.5d0)
else if (y <= 3.7d+63) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -3.25e+19) {
tmp = 1.0;
} else if (y <= -8.8e-94) {
tmp = -1.0;
} else if (y <= -6e-199) {
tmp = y * -0.5;
} else if (y <= 3.7e+63) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -3.25e+19: tmp = 1.0 elif y <= -8.8e-94: tmp = -1.0 elif y <= -6e-199: tmp = y * -0.5 elif y <= 3.7e+63: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -3.25e+19) tmp = 1.0; elseif (y <= -8.8e-94) tmp = -1.0; elseif (y <= -6e-199) tmp = Float64(y * -0.5); elseif (y <= 3.7e+63) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -3.25e+19) tmp = 1.0; elseif (y <= -8.8e-94) tmp = -1.0; elseif (y <= -6e-199) tmp = y * -0.5; elseif (y <= 3.7e+63) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -3.25e+19], 1.0, If[LessEqual[y, -8.8e-94], -1.0, If[LessEqual[y, -6e-199], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 3.7e+63], -1.0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.25 \cdot 10^{+19}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -8.8 \cdot 10^{-94}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -6 \cdot 10^{-199}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 3.7 \cdot 10^{+63}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.25e19 or 3.69999999999999968e63 < y Initial program 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 81.8%
if -3.25e19 < y < -8.80000000000000004e-94 or -5.99999999999999966e-199 < y < 3.69999999999999968e63Initial program 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 60.1%
if -8.80000000000000004e-94 < y < -5.99999999999999966e-199Initial program 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 54.3%
associate-*r/54.3%
mul-1-neg54.3%
Simplified54.3%
Taylor expanded in y around 0 54.3%
*-commutative54.3%
Simplified54.3%
Final simplification70.5%
(FPCore (x y)
:precision binary64
(if (<= y -10000000000.0)
(+ 1.0 (/ 2.0 y))
(if (<= y -9.5e-92)
-1.0
(if (<= y -6.4e-199) (* y -0.5) (if (<= y 3.5e+63) -1.0 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -10000000000.0) {
tmp = 1.0 + (2.0 / y);
} else if (y <= -9.5e-92) {
tmp = -1.0;
} else if (y <= -6.4e-199) {
tmp = y * -0.5;
} else if (y <= 3.5e+63) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-10000000000.0d0)) then
tmp = 1.0d0 + (2.0d0 / y)
else if (y <= (-9.5d-92)) then
tmp = -1.0d0
else if (y <= (-6.4d-199)) then
tmp = y * (-0.5d0)
else if (y <= 3.5d+63) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -10000000000.0) {
tmp = 1.0 + (2.0 / y);
} else if (y <= -9.5e-92) {
tmp = -1.0;
} else if (y <= -6.4e-199) {
tmp = y * -0.5;
} else if (y <= 3.5e+63) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -10000000000.0: tmp = 1.0 + (2.0 / y) elif y <= -9.5e-92: tmp = -1.0 elif y <= -6.4e-199: tmp = y * -0.5 elif y <= 3.5e+63: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -10000000000.0) tmp = Float64(1.0 + Float64(2.0 / y)); elseif (y <= -9.5e-92) tmp = -1.0; elseif (y <= -6.4e-199) tmp = Float64(y * -0.5); elseif (y <= 3.5e+63) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -10000000000.0) tmp = 1.0 + (2.0 / y); elseif (y <= -9.5e-92) tmp = -1.0; elseif (y <= -6.4e-199) tmp = y * -0.5; elseif (y <= 3.5e+63) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -10000000000.0], N[(1.0 + N[(2.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -9.5e-92], -1.0, If[LessEqual[y, -6.4e-199], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 3.5e+63], -1.0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -10000000000:\\
\;\;\;\;1 + \frac{2}{y}\\
\mathbf{elif}\;y \leq -9.5 \cdot 10^{-92}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -6.4 \cdot 10^{-199}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{+63}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1e10Initial program 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 74.9%
associate-*r/74.9%
mul-1-neg74.9%
Simplified74.9%
Taylor expanded in y around inf 74.9%
associate-*r/74.9%
metadata-eval74.9%
Simplified74.9%
if -1e10 < y < -9.49999999999999946e-92 or -6.3999999999999999e-199 < y < 3.50000000000000029e63Initial program 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 60.2%
if -9.49999999999999946e-92 < y < -6.3999999999999999e-199Initial program 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 54.3%
associate-*r/54.3%
mul-1-neg54.3%
Simplified54.3%
Taylor expanded in y around 0 54.3%
*-commutative54.3%
Simplified54.3%
if 3.50000000000000029e63 < y Initial program 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 89.2%
Final simplification70.5%
(FPCore (x y) :precision binary64 (if (<= y -2.5e+46) 1.0 (if (<= y 3.5e+63) -1.0 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -2.5e+46) {
tmp = 1.0;
} else if (y <= 3.5e+63) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-2.5d+46)) then
tmp = 1.0d0
else if (y <= 3.5d+63) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -2.5e+46) {
tmp = 1.0;
} else if (y <= 3.5e+63) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.5e+46: tmp = 1.0 elif y <= 3.5e+63: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -2.5e+46) tmp = 1.0; elseif (y <= 3.5e+63) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.5e+46) tmp = 1.0; elseif (y <= 3.5e+63) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.5e+46], 1.0, If[LessEqual[y, 3.5e+63], -1.0, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.5 \cdot 10^{+46}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{+63}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.5000000000000001e46 or 3.50000000000000029e63 < y Initial program 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 82.8%
if -2.5000000000000001e46 < y < 3.50000000000000029e63Initial program 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 55.2%
Final simplification68.6%
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
return -1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -1.0d0
end function
public static double code(double x, double y) {
return -1.0;
}
def code(x, y): return -1.0
function code(x, y) return -1.0 end
function tmp = code(x, y) tmp = -1.0; end
code[x_, y_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 37.3%
Final simplification37.3%
(FPCore (x y) :precision binary64 (let* ((t_0 (- 2.0 (+ x y)))) (- (/ x t_0) (/ y t_0))))
double code(double x, double y) {
double t_0 = 2.0 - (x + y);
return (x / t_0) - (y / t_0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = 2.0d0 - (x + y)
code = (x / t_0) - (y / t_0)
end function
public static double code(double x, double y) {
double t_0 = 2.0 - (x + y);
return (x / t_0) - (y / t_0);
}
def code(x, y): t_0 = 2.0 - (x + y) return (x / t_0) - (y / t_0)
function code(x, y) t_0 = Float64(2.0 - Float64(x + y)) return Float64(Float64(x / t_0) - Float64(y / t_0)) end
function tmp = code(x, y) t_0 = 2.0 - (x + y); tmp = (x / t_0) - (y / t_0); end
code[x_, y_] := Block[{t$95$0 = N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]}, N[(N[(x / t$95$0), $MachinePrecision] - N[(y / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 - \left(x + y\right)\\
\frac{x}{t_0} - \frac{y}{t_0}
\end{array}
\end{array}
herbie shell --seed 2023301
(FPCore (x y)
:name "Data.Colour.RGB:hslsv from colour-2.3.3, C"
:precision binary64
:herbie-target
(- (/ x (- 2.0 (+ x y))) (/ y (- 2.0 (+ x y))))
(/ (- x y) (- 2.0 (+ x y))))