
(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 7 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
(if (<= y -5.3e-6)
1.0
(if (<= y -7.5e-34)
-1.0
(if (<= y -8e-87)
(* y -0.5)
(if (<= y 2.3e-281)
-1.0
(if (<= y 2.7e-257)
(* x 0.5)
(if (<= y 4.65e-66)
-1.0
(if (<= y 3.7e-9) (* y -0.5) (if (<= y 1e+45) -1.0 1.0)))))))))
double code(double x, double y) {
double tmp;
if (y <= -5.3e-6) {
tmp = 1.0;
} else if (y <= -7.5e-34) {
tmp = -1.0;
} else if (y <= -8e-87) {
tmp = y * -0.5;
} else if (y <= 2.3e-281) {
tmp = -1.0;
} else if (y <= 2.7e-257) {
tmp = x * 0.5;
} else if (y <= 4.65e-66) {
tmp = -1.0;
} else if (y <= 3.7e-9) {
tmp = y * -0.5;
} else if (y <= 1e+45) {
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 <= (-5.3d-6)) then
tmp = 1.0d0
else if (y <= (-7.5d-34)) then
tmp = -1.0d0
else if (y <= (-8d-87)) then
tmp = y * (-0.5d0)
else if (y <= 2.3d-281) then
tmp = -1.0d0
else if (y <= 2.7d-257) then
tmp = x * 0.5d0
else if (y <= 4.65d-66) then
tmp = -1.0d0
else if (y <= 3.7d-9) then
tmp = y * (-0.5d0)
else if (y <= 1d+45) 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 <= -5.3e-6) {
tmp = 1.0;
} else if (y <= -7.5e-34) {
tmp = -1.0;
} else if (y <= -8e-87) {
tmp = y * -0.5;
} else if (y <= 2.3e-281) {
tmp = -1.0;
} else if (y <= 2.7e-257) {
tmp = x * 0.5;
} else if (y <= 4.65e-66) {
tmp = -1.0;
} else if (y <= 3.7e-9) {
tmp = y * -0.5;
} else if (y <= 1e+45) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -5.3e-6: tmp = 1.0 elif y <= -7.5e-34: tmp = -1.0 elif y <= -8e-87: tmp = y * -0.5 elif y <= 2.3e-281: tmp = -1.0 elif y <= 2.7e-257: tmp = x * 0.5 elif y <= 4.65e-66: tmp = -1.0 elif y <= 3.7e-9: tmp = y * -0.5 elif y <= 1e+45: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -5.3e-6) tmp = 1.0; elseif (y <= -7.5e-34) tmp = -1.0; elseif (y <= -8e-87) tmp = Float64(y * -0.5); elseif (y <= 2.3e-281) tmp = -1.0; elseif (y <= 2.7e-257) tmp = Float64(x * 0.5); elseif (y <= 4.65e-66) tmp = -1.0; elseif (y <= 3.7e-9) tmp = Float64(y * -0.5); elseif (y <= 1e+45) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -5.3e-6) tmp = 1.0; elseif (y <= -7.5e-34) tmp = -1.0; elseif (y <= -8e-87) tmp = y * -0.5; elseif (y <= 2.3e-281) tmp = -1.0; elseif (y <= 2.7e-257) tmp = x * 0.5; elseif (y <= 4.65e-66) tmp = -1.0; elseif (y <= 3.7e-9) tmp = y * -0.5; elseif (y <= 1e+45) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -5.3e-6], 1.0, If[LessEqual[y, -7.5e-34], -1.0, If[LessEqual[y, -8e-87], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 2.3e-281], -1.0, If[LessEqual[y, 2.7e-257], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 4.65e-66], -1.0, If[LessEqual[y, 3.7e-9], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1e+45], -1.0, 1.0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.3 \cdot 10^{-6}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -7.5 \cdot 10^{-34}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -8 \cdot 10^{-87}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{-281}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{-257}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 4.65 \cdot 10^{-66}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 3.7 \cdot 10^{-9}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 10^{+45}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -5.3000000000000001e-6 or 9.9999999999999993e44 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 82.6%
if -5.3000000000000001e-6 < y < -7.5000000000000004e-34 or -8.00000000000000014e-87 < y < 2.29999999999999989e-281 or 2.6999999999999999e-257 < y < 4.65000000000000014e-66 or 3.7e-9 < y < 9.9999999999999993e44Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in x around inf 67.1%
if -7.5000000000000004e-34 < y < -8.00000000000000014e-87 or 4.65000000000000014e-66 < y < 3.7e-9Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 81.3%
mul-1-neg81.3%
distribute-neg-frac81.3%
Simplified81.3%
Taylor expanded in y around 0 79.5%
*-commutative79.5%
Simplified79.5%
if 2.29999999999999989e-281 < y < 2.6999999999999999e-257Initial program 99.8%
associate--r+99.8%
Simplified99.8%
Taylor expanded in y around 0 91.2%
Taylor expanded in x around 0 70.2%
*-commutative70.2%
Simplified70.2%
Final simplification74.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (- 2.0 x))))
(if (<= y -4.5e+20)
1.0
(if (<= y -1.55e-31)
t_0
(if (<= y -3.9e-59)
(* y -0.5)
(if (<= y 1.35e-64)
t_0
(if (<= y 3.7e-9) (* y -0.5) (if (<= y 3.5e+61) t_0 1.0))))))))
double code(double x, double y) {
double t_0 = x / (2.0 - x);
double tmp;
if (y <= -4.5e+20) {
tmp = 1.0;
} else if (y <= -1.55e-31) {
tmp = t_0;
} else if (y <= -3.9e-59) {
tmp = y * -0.5;
} else if (y <= 1.35e-64) {
tmp = t_0;
} else if (y <= 3.7e-9) {
tmp = y * -0.5;
} else if (y <= 3.5e+61) {
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 <= (-4.5d+20)) then
tmp = 1.0d0
else if (y <= (-1.55d-31)) then
tmp = t_0
else if (y <= (-3.9d-59)) then
tmp = y * (-0.5d0)
else if (y <= 1.35d-64) then
tmp = t_0
else if (y <= 3.7d-9) then
tmp = y * (-0.5d0)
else if (y <= 3.5d+61) 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 <= -4.5e+20) {
tmp = 1.0;
} else if (y <= -1.55e-31) {
tmp = t_0;
} else if (y <= -3.9e-59) {
tmp = y * -0.5;
} else if (y <= 1.35e-64) {
tmp = t_0;
} else if (y <= 3.7e-9) {
tmp = y * -0.5;
} else if (y <= 3.5e+61) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = x / (2.0 - x) tmp = 0 if y <= -4.5e+20: tmp = 1.0 elif y <= -1.55e-31: tmp = t_0 elif y <= -3.9e-59: tmp = y * -0.5 elif y <= 1.35e-64: tmp = t_0 elif y <= 3.7e-9: tmp = y * -0.5 elif y <= 3.5e+61: 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 <= -4.5e+20) tmp = 1.0; elseif (y <= -1.55e-31) tmp = t_0; elseif (y <= -3.9e-59) tmp = Float64(y * -0.5); elseif (y <= 1.35e-64) tmp = t_0; elseif (y <= 3.7e-9) tmp = Float64(y * -0.5); elseif (y <= 3.5e+61) 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 <= -4.5e+20) tmp = 1.0; elseif (y <= -1.55e-31) tmp = t_0; elseif (y <= -3.9e-59) tmp = y * -0.5; elseif (y <= 1.35e-64) tmp = t_0; elseif (y <= 3.7e-9) tmp = y * -0.5; elseif (y <= 3.5e+61) 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, -4.5e+20], 1.0, If[LessEqual[y, -1.55e-31], t$95$0, If[LessEqual[y, -3.9e-59], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.35e-64], t$95$0, If[LessEqual[y, 3.7e-9], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 3.5e+61], t$95$0, 1.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -4.5 \cdot 10^{+20}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.55 \cdot 10^{-31}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -3.9 \cdot 10^{-59}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{-64}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 3.7 \cdot 10^{-9}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{+61}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -4.5e20 or 3.50000000000000018e61 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 85.4%
if -4.5e20 < y < -1.55e-31 or -3.90000000000000019e-59 < y < 1.34999999999999993e-64 or 3.7e-9 < y < 3.50000000000000018e61Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 83.6%
if -1.55e-31 < y < -3.90000000000000019e-59 or 1.34999999999999993e-64 < y < 3.7e-9Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 93.9%
mul-1-neg93.9%
distribute-neg-frac93.9%
Simplified93.9%
Taylor expanded in y around 0 91.5%
*-commutative91.5%
Simplified91.5%
Final simplification84.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (+ y -2.0))))
(if (<= y -4.5e-8)
t_0
(if (<= y -6.5e-35)
-1.0
(if (or (<= y -7e-59) (not (<= y 2.65e-65))) t_0 (/ x (- 2.0 x)))))))
double code(double x, double y) {
double t_0 = y / (y + -2.0);
double tmp;
if (y <= -4.5e-8) {
tmp = t_0;
} else if (y <= -6.5e-35) {
tmp = -1.0;
} else if ((y <= -7e-59) || !(y <= 2.65e-65)) {
tmp = t_0;
} else {
tmp = x / (2.0 - x);
}
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 = y / (y + (-2.0d0))
if (y <= (-4.5d-8)) then
tmp = t_0
else if (y <= (-6.5d-35)) then
tmp = -1.0d0
else if ((y <= (-7d-59)) .or. (.not. (y <= 2.65d-65))) then
tmp = t_0
else
tmp = x / (2.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y / (y + -2.0);
double tmp;
if (y <= -4.5e-8) {
tmp = t_0;
} else if (y <= -6.5e-35) {
tmp = -1.0;
} else if ((y <= -7e-59) || !(y <= 2.65e-65)) {
tmp = t_0;
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): t_0 = y / (y + -2.0) tmp = 0 if y <= -4.5e-8: tmp = t_0 elif y <= -6.5e-35: tmp = -1.0 elif (y <= -7e-59) or not (y <= 2.65e-65): tmp = t_0 else: tmp = x / (2.0 - x) return tmp
function code(x, y) t_0 = Float64(y / Float64(y + -2.0)) tmp = 0.0 if (y <= -4.5e-8) tmp = t_0; elseif (y <= -6.5e-35) tmp = -1.0; elseif ((y <= -7e-59) || !(y <= 2.65e-65)) tmp = t_0; else tmp = Float64(x / Float64(2.0 - x)); end return tmp end
function tmp_2 = code(x, y) t_0 = y / (y + -2.0); tmp = 0.0; if (y <= -4.5e-8) tmp = t_0; elseif (y <= -6.5e-35) tmp = -1.0; elseif ((y <= -7e-59) || ~((y <= 2.65e-65))) tmp = t_0; else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.5e-8], t$95$0, If[LessEqual[y, -6.5e-35], -1.0, If[Or[LessEqual[y, -7e-59], N[Not[LessEqual[y, 2.65e-65]], $MachinePrecision]], t$95$0, N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y + -2}\\
\mathbf{if}\;y \leq -4.5 \cdot 10^{-8}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -6.5 \cdot 10^{-35}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -7 \cdot 10^{-59} \lor \neg \left(y \leq 2.65 \cdot 10^{-65}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if y < -4.49999999999999993e-8 or -6.4999999999999999e-35 < y < -7.0000000000000002e-59 or 2.65000000000000019e-65 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 82.3%
mul-1-neg82.3%
distribute-neg-frac82.3%
Simplified82.3%
frac-2neg82.3%
div-inv82.1%
remove-double-neg82.1%
sub-neg82.1%
distribute-neg-in82.1%
metadata-eval82.1%
remove-double-neg82.1%
Applied egg-rr82.1%
associate-*r/82.3%
*-rgt-identity82.3%
+-commutative82.3%
Simplified82.3%
if -4.49999999999999993e-8 < y < -6.4999999999999999e-35Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
if -7.0000000000000002e-59 < y < 2.65000000000000019e-65Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 87.1%
Final simplification84.9%
(FPCore (x y)
:precision binary64
(if (<= y -5.3e-6)
1.0
(if (<= y 2.4e-281)
-1.0
(if (<= y 6.1e-255) (* x 0.5) (if (<= y 5e+45) -1.0 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -5.3e-6) {
tmp = 1.0;
} else if (y <= 2.4e-281) {
tmp = -1.0;
} else if (y <= 6.1e-255) {
tmp = x * 0.5;
} else if (y <= 5e+45) {
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 <= (-5.3d-6)) then
tmp = 1.0d0
else if (y <= 2.4d-281) then
tmp = -1.0d0
else if (y <= 6.1d-255) then
tmp = x * 0.5d0
else if (y <= 5d+45) 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 <= -5.3e-6) {
tmp = 1.0;
} else if (y <= 2.4e-281) {
tmp = -1.0;
} else if (y <= 6.1e-255) {
tmp = x * 0.5;
} else if (y <= 5e+45) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -5.3e-6: tmp = 1.0 elif y <= 2.4e-281: tmp = -1.0 elif y <= 6.1e-255: tmp = x * 0.5 elif y <= 5e+45: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -5.3e-6) tmp = 1.0; elseif (y <= 2.4e-281) tmp = -1.0; elseif (y <= 6.1e-255) tmp = Float64(x * 0.5); elseif (y <= 5e+45) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -5.3e-6) tmp = 1.0; elseif (y <= 2.4e-281) tmp = -1.0; elseif (y <= 6.1e-255) tmp = x * 0.5; elseif (y <= 5e+45) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -5.3e-6], 1.0, If[LessEqual[y, 2.4e-281], -1.0, If[LessEqual[y, 6.1e-255], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 5e+45], -1.0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.3 \cdot 10^{-6}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{-281}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 6.1 \cdot 10^{-255}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+45}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -5.3000000000000001e-6 or 5e45 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 82.6%
if -5.3000000000000001e-6 < y < 2.4e-281 or 6.1e-255 < y < 5e45Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 59.2%
if 2.4e-281 < y < 6.1e-255Initial program 99.8%
associate--r+99.8%
Simplified99.8%
Taylor expanded in y around 0 91.2%
Taylor expanded in x around 0 70.2%
*-commutative70.2%
Simplified70.2%
Final simplification69.4%
(FPCore (x y) :precision binary64 (if (<= y -5.3e-6) 1.0 (if (<= y 6.5e+45) -1.0 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -5.3e-6) {
tmp = 1.0;
} else if (y <= 6.5e+45) {
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 <= (-5.3d-6)) then
tmp = 1.0d0
else if (y <= 6.5d+45) 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 <= -5.3e-6) {
tmp = 1.0;
} else if (y <= 6.5e+45) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -5.3e-6: tmp = 1.0 elif y <= 6.5e+45: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -5.3e-6) tmp = 1.0; elseif (y <= 6.5e+45) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -5.3e-6) tmp = 1.0; elseif (y <= 6.5e+45) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -5.3e-6], 1.0, If[LessEqual[y, 6.5e+45], -1.0, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.3 \cdot 10^{-6}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 6.5 \cdot 10^{+45}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -5.3000000000000001e-6 or 6.50000000000000034e45 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 82.6%
if -5.3000000000000001e-6 < y < 6.50000000000000034e45Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in x around inf 56.8%
Final simplification67.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%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 39.9%
Final simplification39.9%
(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 2023187
(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))))