
(FPCore (x y) :precision binary64 (+ x (* (- 1.0 x) (- 1.0 y))))
double code(double x, double y) {
return x + ((1.0 - x) * (1.0 - y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + ((1.0d0 - x) * (1.0d0 - y))
end function
public static double code(double x, double y) {
return x + ((1.0 - x) * (1.0 - y));
}
def code(x, y): return x + ((1.0 - x) * (1.0 - y))
function code(x, y) return Float64(x + Float64(Float64(1.0 - x) * Float64(1.0 - y))) end
function tmp = code(x, y) tmp = x + ((1.0 - x) * (1.0 - y)); end
code[x_, y_] := N[(x + N[(N[(1.0 - x), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(1 - x\right) \cdot \left(1 - y\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (+ x (* (- 1.0 x) (- 1.0 y))))
double code(double x, double y) {
return x + ((1.0 - x) * (1.0 - y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + ((1.0d0 - x) * (1.0d0 - y))
end function
public static double code(double x, double y) {
return x + ((1.0 - x) * (1.0 - y));
}
def code(x, y): return x + ((1.0 - x) * (1.0 - y))
function code(x, y) return Float64(x + Float64(Float64(1.0 - x) * Float64(1.0 - y))) end
function tmp = code(x, y) tmp = x + ((1.0 - x) * (1.0 - y)); end
code[x_, y_] := N[(x + N[(N[(1.0 - x), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(1 - x\right) \cdot \left(1 - y\right)
\end{array}
(FPCore (x y) :precision binary64 (+ 1.0 (* y (+ x -1.0))))
double code(double x, double y) {
return 1.0 + (y * (x + -1.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 + (y * (x + (-1.0d0)))
end function
public static double code(double x, double y) {
return 1.0 + (y * (x + -1.0));
}
def code(x, y): return 1.0 + (y * (x + -1.0))
function code(x, y) return Float64(1.0 + Float64(y * Float64(x + -1.0))) end
function tmp = code(x, y) tmp = 1.0 + (y * (x + -1.0)); end
code[x_, y_] := N[(1.0 + N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + y \cdot \left(x + -1\right)
\end{array}
Initial program 76.1%
+-commutative76.1%
remove-double-neg76.1%
unsub-neg76.1%
sub-neg76.1%
+-commutative76.1%
distribute-rgt-in76.1%
*-lft-identity76.1%
associate-+r-76.1%
associate--l-100.0%
sub-neg100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
(FPCore (x y)
:precision binary64
(if (<= y -9.2e+23)
(- y)
(if (<= y -1.65e-47)
(* y x)
(if (<= y 27000.0) 1.0 (if (<= y 9.5e+108) (- y) (* y x))))))
double code(double x, double y) {
double tmp;
if (y <= -9.2e+23) {
tmp = -y;
} else if (y <= -1.65e-47) {
tmp = y * x;
} else if (y <= 27000.0) {
tmp = 1.0;
} else if (y <= 9.5e+108) {
tmp = -y;
} else {
tmp = y * x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-9.2d+23)) then
tmp = -y
else if (y <= (-1.65d-47)) then
tmp = y * x
else if (y <= 27000.0d0) then
tmp = 1.0d0
else if (y <= 9.5d+108) then
tmp = -y
else
tmp = y * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -9.2e+23) {
tmp = -y;
} else if (y <= -1.65e-47) {
tmp = y * x;
} else if (y <= 27000.0) {
tmp = 1.0;
} else if (y <= 9.5e+108) {
tmp = -y;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -9.2e+23: tmp = -y elif y <= -1.65e-47: tmp = y * x elif y <= 27000.0: tmp = 1.0 elif y <= 9.5e+108: tmp = -y else: tmp = y * x return tmp
function code(x, y) tmp = 0.0 if (y <= -9.2e+23) tmp = Float64(-y); elseif (y <= -1.65e-47) tmp = Float64(y * x); elseif (y <= 27000.0) tmp = 1.0; elseif (y <= 9.5e+108) tmp = Float64(-y); else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -9.2e+23) tmp = -y; elseif (y <= -1.65e-47) tmp = y * x; elseif (y <= 27000.0) tmp = 1.0; elseif (y <= 9.5e+108) tmp = -y; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -9.2e+23], (-y), If[LessEqual[y, -1.65e-47], N[(y * x), $MachinePrecision], If[LessEqual[y, 27000.0], 1.0, If[LessEqual[y, 9.5e+108], (-y), N[(y * x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.2 \cdot 10^{+23}:\\
\;\;\;\;-y\\
\mathbf{elif}\;y \leq -1.65 \cdot 10^{-47}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 27000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{+108}:\\
\;\;\;\;-y\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if y < -9.2000000000000002e23 or 27000 < y < 9.50000000000000097e108Initial program 99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
sub-neg99.9%
+-commutative99.9%
distribute-rgt-in100.0%
*-lft-identity100.0%
associate-+r-100.0%
associate--l-100.0%
sub-neg100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
Taylor expanded in y around inf 99.0%
Taylor expanded in x around 0 66.0%
neg-mul-166.0%
Simplified66.0%
if -9.2000000000000002e23 < y < -1.65000000000000002e-47 or 9.50000000000000097e108 < y Initial program 86.4%
+-commutative86.4%
remove-double-neg86.4%
unsub-neg86.4%
sub-neg86.4%
+-commutative86.4%
distribute-rgt-in86.4%
*-lft-identity86.4%
associate-+r-86.4%
associate--l-100.0%
sub-neg100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around inf 99.9%
Taylor expanded in x around inf 65.1%
if -1.65000000000000002e-47 < y < 27000Initial program 56.8%
+-commutative56.8%
remove-double-neg56.8%
unsub-neg56.8%
sub-neg56.8%
+-commutative56.8%
distribute-rgt-in56.8%
*-lft-identity56.8%
associate-+r-56.8%
associate--l-100.0%
sub-neg100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 77.5%
(FPCore (x y) :precision binary64 (if (<= x -8.2e+36) (+ 1.0 (* y x)) (if (<= x 1.0) (- 1.0 y) (* y (+ x (/ 1.0 y))))))
double code(double x, double y) {
double tmp;
if (x <= -8.2e+36) {
tmp = 1.0 + (y * x);
} else if (x <= 1.0) {
tmp = 1.0 - y;
} else {
tmp = y * (x + (1.0 / y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-8.2d+36)) then
tmp = 1.0d0 + (y * x)
else if (x <= 1.0d0) then
tmp = 1.0d0 - y
else
tmp = y * (x + (1.0d0 / y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -8.2e+36) {
tmp = 1.0 + (y * x);
} else if (x <= 1.0) {
tmp = 1.0 - y;
} else {
tmp = y * (x + (1.0 / y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -8.2e+36: tmp = 1.0 + (y * x) elif x <= 1.0: tmp = 1.0 - y else: tmp = y * (x + (1.0 / y)) return tmp
function code(x, y) tmp = 0.0 if (x <= -8.2e+36) tmp = Float64(1.0 + Float64(y * x)); elseif (x <= 1.0) tmp = Float64(1.0 - y); else tmp = Float64(y * Float64(x + Float64(1.0 / y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -8.2e+36) tmp = 1.0 + (y * x); elseif (x <= 1.0) tmp = 1.0 - y; else tmp = y * (x + (1.0 / y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -8.2e+36], N[(1.0 + N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(1.0 - y), $MachinePrecision], N[(y * N[(x + N[(1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.2 \cdot 10^{+36}:\\
\;\;\;\;1 + y \cdot x\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x + \frac{1}{y}\right)\\
\end{array}
\end{array}
if x < -8.20000000000000026e36Initial program 45.4%
+-commutative45.4%
remove-double-neg45.4%
unsub-neg45.4%
sub-neg45.4%
+-commutative45.4%
distribute-rgt-in45.4%
*-lft-identity45.4%
associate-+r-45.4%
associate--l-100.0%
sub-neg100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
*-commutative100.0%
Simplified100.0%
if -8.20000000000000026e36 < x < 1Initial program 97.3%
+-commutative97.3%
remove-double-neg97.3%
unsub-neg97.3%
sub-neg97.3%
+-commutative97.3%
distribute-rgt-in97.3%
*-lft-identity97.3%
associate-+r-97.3%
associate--l-100.0%
sub-neg100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 99.3%
neg-mul-199.3%
unsub-neg99.3%
Simplified99.3%
if 1 < x Initial program 51.3%
+-commutative51.3%
remove-double-neg51.3%
unsub-neg51.3%
sub-neg51.3%
+-commutative51.3%
distribute-rgt-in51.4%
*-lft-identity51.4%
associate-+r-51.4%
associate--l-100.0%
sub-neg100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 99.3%
*-commutative99.3%
Simplified99.3%
Taylor expanded in y around inf 99.3%
(FPCore (x y) :precision binary64 (if (or (<= x -8.2e+36) (not (<= x 1.0))) (+ 1.0 (* y x)) (- 1.0 y)))
double code(double x, double y) {
double tmp;
if ((x <= -8.2e+36) || !(x <= 1.0)) {
tmp = 1.0 + (y * x);
} else {
tmp = 1.0 - y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-8.2d+36)) .or. (.not. (x <= 1.0d0))) then
tmp = 1.0d0 + (y * x)
else
tmp = 1.0d0 - y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -8.2e+36) || !(x <= 1.0)) {
tmp = 1.0 + (y * x);
} else {
tmp = 1.0 - y;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -8.2e+36) or not (x <= 1.0): tmp = 1.0 + (y * x) else: tmp = 1.0 - y return tmp
function code(x, y) tmp = 0.0 if ((x <= -8.2e+36) || !(x <= 1.0)) tmp = Float64(1.0 + Float64(y * x)); else tmp = Float64(1.0 - y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -8.2e+36) || ~((x <= 1.0))) tmp = 1.0 + (y * x); else tmp = 1.0 - y; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -8.2e+36], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(1.0 + N[(y * x), $MachinePrecision]), $MachinePrecision], N[(1.0 - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.2 \cdot 10^{+36} \lor \neg \left(x \leq 1\right):\\
\;\;\;\;1 + y \cdot x\\
\mathbf{else}:\\
\;\;\;\;1 - y\\
\end{array}
\end{array}
if x < -8.20000000000000026e36 or 1 < x Initial program 48.3%
+-commutative48.3%
remove-double-neg48.3%
unsub-neg48.3%
sub-neg48.3%
+-commutative48.3%
distribute-rgt-in48.3%
*-lft-identity48.3%
associate-+r-48.3%
associate--l-100.0%
sub-neg100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 99.6%
*-commutative99.6%
Simplified99.6%
if -8.20000000000000026e36 < x < 1Initial program 97.3%
+-commutative97.3%
remove-double-neg97.3%
unsub-neg97.3%
sub-neg97.3%
+-commutative97.3%
distribute-rgt-in97.3%
*-lft-identity97.3%
associate-+r-97.3%
associate--l-100.0%
sub-neg100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 99.3%
neg-mul-199.3%
unsub-neg99.3%
Simplified99.3%
Final simplification99.4%
(FPCore (x y) :precision binary64 (if (<= x -8.8e+36) (* y x) (if (<= x 3.7e-9) (- 1.0 y) (* y (+ x -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -8.8e+36) {
tmp = y * x;
} else if (x <= 3.7e-9) {
tmp = 1.0 - y;
} else {
tmp = y * (x + -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 <= (-8.8d+36)) then
tmp = y * x
else if (x <= 3.7d-9) then
tmp = 1.0d0 - y
else
tmp = y * (x + (-1.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -8.8e+36) {
tmp = y * x;
} else if (x <= 3.7e-9) {
tmp = 1.0 - y;
} else {
tmp = y * (x + -1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -8.8e+36: tmp = y * x elif x <= 3.7e-9: tmp = 1.0 - y else: tmp = y * (x + -1.0) return tmp
function code(x, y) tmp = 0.0 if (x <= -8.8e+36) tmp = Float64(y * x); elseif (x <= 3.7e-9) tmp = Float64(1.0 - y); else tmp = Float64(y * Float64(x + -1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -8.8e+36) tmp = y * x; elseif (x <= 3.7e-9) tmp = 1.0 - y; else tmp = y * (x + -1.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -8.8e+36], N[(y * x), $MachinePrecision], If[LessEqual[x, 3.7e-9], N[(1.0 - y), $MachinePrecision], N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.8 \cdot 10^{+36}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;x \leq 3.7 \cdot 10^{-9}:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x + -1\right)\\
\end{array}
\end{array}
if x < -8.80000000000000002e36Initial program 45.4%
+-commutative45.4%
remove-double-neg45.4%
unsub-neg45.4%
sub-neg45.4%
+-commutative45.4%
distribute-rgt-in45.4%
*-lft-identity45.4%
associate-+r-45.4%
associate--l-100.0%
sub-neg100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around inf 99.9%
Taylor expanded in x around inf 74.1%
if -8.80000000000000002e36 < x < 3.7e-9Initial program 97.3%
+-commutative97.3%
remove-double-neg97.3%
unsub-neg97.3%
sub-neg97.3%
+-commutative97.3%
distribute-rgt-in97.3%
*-lft-identity97.3%
associate-+r-97.3%
associate--l-100.0%
sub-neg100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
if 3.7e-9 < x Initial program 53.1%
+-commutative53.1%
remove-double-neg53.1%
unsub-neg53.1%
sub-neg53.1%
+-commutative53.1%
distribute-rgt-in53.1%
*-lft-identity53.1%
associate-+r-53.1%
associate--l-99.9%
sub-neg99.9%
+-inverses99.9%
--rgt-identity99.9%
+-commutative99.9%
distribute-lft-neg-out99.9%
distribute-rgt-neg-in99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in y around inf 100.0%
Taylor expanded in y around inf 81.3%
Final simplification90.2%
(FPCore (x y) :precision binary64 (if (or (<= x -1.46e+37) (not (<= x 1.95e+29))) (* y x) (- 1.0 y)))
double code(double x, double y) {
double tmp;
if ((x <= -1.46e+37) || !(x <= 1.95e+29)) {
tmp = y * x;
} else {
tmp = 1.0 - y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-1.46d+37)) .or. (.not. (x <= 1.95d+29))) then
tmp = y * x
else
tmp = 1.0d0 - y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.46e+37) || !(x <= 1.95e+29)) {
tmp = y * x;
} else {
tmp = 1.0 - y;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.46e+37) or not (x <= 1.95e+29): tmp = y * x else: tmp = 1.0 - y return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.46e+37) || !(x <= 1.95e+29)) tmp = Float64(y * x); else tmp = Float64(1.0 - y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.46e+37) || ~((x <= 1.95e+29))) tmp = y * x; else tmp = 1.0 - y; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.46e+37], N[Not[LessEqual[x, 1.95e+29]], $MachinePrecision]], N[(y * x), $MachinePrecision], N[(1.0 - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.46 \cdot 10^{+37} \lor \neg \left(x \leq 1.95 \cdot 10^{+29}\right):\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;1 - y\\
\end{array}
\end{array}
if x < -1.4599999999999999e37 or 1.94999999999999984e29 < x Initial program 48.2%
+-commutative48.2%
remove-double-neg48.2%
unsub-neg48.2%
sub-neg48.2%
+-commutative48.2%
distribute-rgt-in48.2%
*-lft-identity48.2%
associate-+r-48.2%
associate--l-100.0%
sub-neg100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
Taylor expanded in x around inf 78.3%
if -1.4599999999999999e37 < x < 1.94999999999999984e29Initial program 96.1%
+-commutative96.1%
remove-double-neg96.1%
unsub-neg96.1%
sub-neg96.1%
+-commutative96.1%
distribute-rgt-in96.1%
*-lft-identity96.1%
associate-+r-96.1%
associate--l-100.0%
sub-neg100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 98.0%
neg-mul-198.0%
unsub-neg98.0%
Simplified98.0%
Final simplification89.7%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 27000.0))) (- y) 1.0))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 27000.0)) {
tmp = -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 ((y <= (-1.0d0)) .or. (.not. (y <= 27000.0d0))) then
tmp = -y
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 27000.0)) {
tmp = -y;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 27000.0): tmp = -y else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 27000.0)) tmp = Float64(-y); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.0) || ~((y <= 27000.0))) tmp = -y; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 27000.0]], $MachinePrecision]], (-y), 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 27000\right):\\
\;\;\;\;-y\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 27000 < y Initial program 100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-rgt-in100.0%
*-lft-identity100.0%
associate-+r-100.0%
associate--l-100.0%
sub-neg100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
Taylor expanded in y around inf 98.7%
Taylor expanded in x around 0 55.9%
neg-mul-155.9%
Simplified55.9%
if -1 < y < 27000Initial program 55.6%
+-commutative55.6%
remove-double-neg55.6%
unsub-neg55.6%
sub-neg55.6%
+-commutative55.6%
distribute-rgt-in55.6%
*-lft-identity55.6%
associate-+r-55.6%
associate--l-100.0%
sub-neg100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 73.9%
Final simplification65.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 76.1%
+-commutative76.1%
remove-double-neg76.1%
unsub-neg76.1%
sub-neg76.1%
+-commutative76.1%
distribute-rgt-in76.1%
*-lft-identity76.1%
associate-+r-76.1%
associate--l-100.0%
sub-neg100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 41.2%
(FPCore (x y) :precision binary64 (- (* y x) (- y 1.0)))
double code(double x, double y) {
return (y * x) - (y - 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (y * x) - (y - 1.0d0)
end function
public static double code(double x, double y) {
return (y * x) - (y - 1.0);
}
def code(x, y): return (y * x) - (y - 1.0)
function code(x, y) return Float64(Float64(y * x) - Float64(y - 1.0)) end
function tmp = code(x, y) tmp = (y * x) - (y - 1.0); end
code[x_, y_] := N[(N[(y * x), $MachinePrecision] - N[(y - 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot x - \left(y - 1\right)
\end{array}
herbie shell --seed 2024186
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.Vectors:renderPlotVectors from Chart-1.5.3"
:precision binary64
:alt
(! :herbie-platform default (- (* y x) (- y 1)))
(+ x (* (- 1.0 x) (- 1.0 y))))