
(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 9 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) y)))
double code(double x, double y) {
return 1.0 + ((y * x) - y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 + ((y * x) - y)
end function
public static double code(double x, double y) {
return 1.0 + ((y * x) - y);
}
def code(x, y): return 1.0 + ((y * x) - y)
function code(x, y) return Float64(1.0 + Float64(Float64(y * x) - y)) end
function tmp = code(x, y) tmp = 1.0 + ((y * x) - y); end
code[x_, y_] := N[(1.0 + N[(N[(y * x), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(y \cdot x - y\right)
\end{array}
Initial program 74.6%
+-commutative74.6%
sub-neg74.6%
+-commutative74.6%
distribute-rgt-in74.6%
*-lft-identity74.6%
associate-+r-74.6%
associate-+l-100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
mul-1-neg100.0%
mul-1-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
distribute-lft-out--100.0%
cancel-sign-sub-inv100.0%
*-rgt-identity100.0%
unsub-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(if (<= x -1e-6)
(* y x)
(if (<= x -1.45e-65)
(- y)
(if (<= x -9.2e-293)
1.0
(if (<= x 2.6e-271)
(- y)
(if (<= x 1.42e-129) 1.0 (if (<= x 1.0) (- y) (* y x))))))))
double code(double x, double y) {
double tmp;
if (x <= -1e-6) {
tmp = y * x;
} else if (x <= -1.45e-65) {
tmp = -y;
} else if (x <= -9.2e-293) {
tmp = 1.0;
} else if (x <= 2.6e-271) {
tmp = -y;
} else if (x <= 1.42e-129) {
tmp = 1.0;
} else if (x <= 1.0) {
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 (x <= (-1d-6)) then
tmp = y * x
else if (x <= (-1.45d-65)) then
tmp = -y
else if (x <= (-9.2d-293)) then
tmp = 1.0d0
else if (x <= 2.6d-271) then
tmp = -y
else if (x <= 1.42d-129) then
tmp = 1.0d0
else if (x <= 1.0d0) then
tmp = -y
else
tmp = y * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1e-6) {
tmp = y * x;
} else if (x <= -1.45e-65) {
tmp = -y;
} else if (x <= -9.2e-293) {
tmp = 1.0;
} else if (x <= 2.6e-271) {
tmp = -y;
} else if (x <= 1.42e-129) {
tmp = 1.0;
} else if (x <= 1.0) {
tmp = -y;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1e-6: tmp = y * x elif x <= -1.45e-65: tmp = -y elif x <= -9.2e-293: tmp = 1.0 elif x <= 2.6e-271: tmp = -y elif x <= 1.42e-129: tmp = 1.0 elif x <= 1.0: tmp = -y else: tmp = y * x return tmp
function code(x, y) tmp = 0.0 if (x <= -1e-6) tmp = Float64(y * x); elseif (x <= -1.45e-65) tmp = Float64(-y); elseif (x <= -9.2e-293) tmp = 1.0; elseif (x <= 2.6e-271) tmp = Float64(-y); elseif (x <= 1.42e-129) tmp = 1.0; elseif (x <= 1.0) tmp = Float64(-y); else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1e-6) tmp = y * x; elseif (x <= -1.45e-65) tmp = -y; elseif (x <= -9.2e-293) tmp = 1.0; elseif (x <= 2.6e-271) tmp = -y; elseif (x <= 1.42e-129) tmp = 1.0; elseif (x <= 1.0) tmp = -y; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1e-6], N[(y * x), $MachinePrecision], If[LessEqual[x, -1.45e-65], (-y), If[LessEqual[x, -9.2e-293], 1.0, If[LessEqual[x, 2.6e-271], (-y), If[LessEqual[x, 1.42e-129], 1.0, If[LessEqual[x, 1.0], (-y), N[(y * x), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-6}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;x \leq -1.45 \cdot 10^{-65}:\\
\;\;\;\;-y\\
\mathbf{elif}\;x \leq -9.2 \cdot 10^{-293}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-271}:\\
\;\;\;\;-y\\
\mathbf{elif}\;x \leq 1.42 \cdot 10^{-129}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;-y\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if x < -9.99999999999999955e-7 or 1 < x Initial program 53.9%
+-commutative53.9%
sub-neg53.9%
+-commutative53.9%
distribute-rgt-in53.9%
*-lft-identity53.9%
associate-+r-53.9%
associate-+l-100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
mul-1-neg100.0%
mul-1-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 98.7%
Taylor expanded in y around inf 74.9%
if -9.99999999999999955e-7 < x < -1.4499999999999999e-65 or -9.1999999999999998e-293 < x < 2.6e-271 or 1.42e-129 < x < 1Initial program 99.9%
+-commutative99.9%
sub-neg99.9%
+-commutative99.9%
distribute-rgt-in99.9%
*-lft-identity99.9%
associate-+r-99.9%
associate-+l-99.9%
+-inverses99.9%
--rgt-identity99.9%
+-commutative99.9%
distribute-lft-neg-out99.9%
distribute-rgt-neg-in99.9%
mul-1-neg99.9%
mul-1-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 99.9%
distribute-lft-out--100.0%
cancel-sign-sub-inv100.0%
*-rgt-identity100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 71.6%
Taylor expanded in x around 0 69.0%
mul-1-neg69.0%
Simplified69.0%
if -1.4499999999999999e-65 < x < -9.1999999999999998e-293 or 2.6e-271 < x < 1.42e-129Initial program 100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
distribute-rgt-in100.0%
*-lft-identity100.0%
associate-+r-100.0%
associate-+l-100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
mul-1-neg100.0%
mul-1-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 64.5%
Final simplification71.0%
(FPCore (x y) :precision binary64 (if (or (<= (- 1.0 y) -100.0) (not (<= (- 1.0 y) 1.0000002))) (* y (+ x -1.0)) (+ 1.0 (* y x))))
double code(double x, double y) {
double tmp;
if (((1.0 - y) <= -100.0) || !((1.0 - y) <= 1.0000002)) {
tmp = y * (x + -1.0);
} else {
tmp = 1.0 + (y * x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (((1.0d0 - y) <= (-100.0d0)) .or. (.not. ((1.0d0 - y) <= 1.0000002d0))) then
tmp = y * (x + (-1.0d0))
else
tmp = 1.0d0 + (y * x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (((1.0 - y) <= -100.0) || !((1.0 - y) <= 1.0000002)) {
tmp = y * (x + -1.0);
} else {
tmp = 1.0 + (y * x);
}
return tmp;
}
def code(x, y): tmp = 0 if ((1.0 - y) <= -100.0) or not ((1.0 - y) <= 1.0000002): tmp = y * (x + -1.0) else: tmp = 1.0 + (y * x) return tmp
function code(x, y) tmp = 0.0 if ((Float64(1.0 - y) <= -100.0) || !(Float64(1.0 - y) <= 1.0000002)) tmp = Float64(y * Float64(x + -1.0)); else tmp = Float64(1.0 + Float64(y * x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (((1.0 - y) <= -100.0) || ~(((1.0 - y) <= 1.0000002))) tmp = y * (x + -1.0); else tmp = 1.0 + (y * x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[(1.0 - y), $MachinePrecision], -100.0], N[Not[LessEqual[N[(1.0 - y), $MachinePrecision], 1.0000002]], $MachinePrecision]], N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(y * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 - y \leq -100 \lor \neg \left(1 - y \leq 1.0000002\right):\\
\;\;\;\;y \cdot \left(x + -1\right)\\
\mathbf{else}:\\
\;\;\;\;1 + y \cdot x\\
\end{array}
\end{array}
if (-.f64 1 y) < -100 or 1.00000019999999989 < (-.f64 1 y) Initial program 99.7%
+-commutative99.7%
sub-neg99.7%
+-commutative99.7%
distribute-rgt-in99.7%
*-lft-identity99.7%
associate-+r-99.7%
associate-+l-100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
mul-1-neg100.0%
mul-1-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
distribute-lft-out--100.0%
cancel-sign-sub-inv100.0%
*-rgt-identity100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 99.4%
if -100 < (-.f64 1 y) < 1.00000019999999989Initial program 50.3%
+-commutative50.3%
sub-neg50.3%
+-commutative50.3%
distribute-rgt-in50.3%
*-lft-identity50.3%
associate-+r-50.3%
associate-+l-100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
mul-1-neg100.0%
mul-1-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 98.5%
Final simplification98.9%
(FPCore (x y) :precision binary64 (if (or (<= (- 1.0 y) -100.0) (not (<= (- 1.0 y) 1.0000002))) (- (* y x) y) (+ 1.0 (* y x))))
double code(double x, double y) {
double tmp;
if (((1.0 - y) <= -100.0) || !((1.0 - y) <= 1.0000002)) {
tmp = (y * x) - y;
} else {
tmp = 1.0 + (y * x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (((1.0d0 - y) <= (-100.0d0)) .or. (.not. ((1.0d0 - y) <= 1.0000002d0))) then
tmp = (y * x) - y
else
tmp = 1.0d0 + (y * x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (((1.0 - y) <= -100.0) || !((1.0 - y) <= 1.0000002)) {
tmp = (y * x) - y;
} else {
tmp = 1.0 + (y * x);
}
return tmp;
}
def code(x, y): tmp = 0 if ((1.0 - y) <= -100.0) or not ((1.0 - y) <= 1.0000002): tmp = (y * x) - y else: tmp = 1.0 + (y * x) return tmp
function code(x, y) tmp = 0.0 if ((Float64(1.0 - y) <= -100.0) || !(Float64(1.0 - y) <= 1.0000002)) tmp = Float64(Float64(y * x) - y); else tmp = Float64(1.0 + Float64(y * x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (((1.0 - y) <= -100.0) || ~(((1.0 - y) <= 1.0000002))) tmp = (y * x) - y; else tmp = 1.0 + (y * x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[(1.0 - y), $MachinePrecision], -100.0], N[Not[LessEqual[N[(1.0 - y), $MachinePrecision], 1.0000002]], $MachinePrecision]], N[(N[(y * x), $MachinePrecision] - y), $MachinePrecision], N[(1.0 + N[(y * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 - y \leq -100 \lor \neg \left(1 - y \leq 1.0000002\right):\\
\;\;\;\;y \cdot x - y\\
\mathbf{else}:\\
\;\;\;\;1 + y \cdot x\\
\end{array}
\end{array}
if (-.f64 1 y) < -100 or 1.00000019999999989 < (-.f64 1 y) Initial program 99.7%
+-commutative99.7%
sub-neg99.7%
+-commutative99.7%
distribute-rgt-in99.7%
*-lft-identity99.7%
associate-+r-99.7%
associate-+l-100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
mul-1-neg100.0%
mul-1-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
distribute-lft-out--100.0%
cancel-sign-sub-inv100.0%
*-rgt-identity100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 99.4%
Taylor expanded in x around 0 99.4%
mul-1-neg99.4%
unsub-neg99.4%
Simplified99.4%
if -100 < (-.f64 1 y) < 1.00000019999999989Initial program 50.3%
+-commutative50.3%
sub-neg50.3%
+-commutative50.3%
distribute-rgt-in50.3%
*-lft-identity50.3%
associate-+r-50.3%
associate-+l-100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
mul-1-neg100.0%
mul-1-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 98.5%
Final simplification99.0%
(FPCore (x y) :precision binary64 (if (or (<= x -3.5e-13) (not (<= x 56000000000.0))) (* y (+ x -1.0)) (- 1.0 y)))
double code(double x, double y) {
double tmp;
if ((x <= -3.5e-13) || !(x <= 56000000000.0)) {
tmp = y * (x + -1.0);
} 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 <= (-3.5d-13)) .or. (.not. (x <= 56000000000.0d0))) then
tmp = y * (x + (-1.0d0))
else
tmp = 1.0d0 - y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -3.5e-13) || !(x <= 56000000000.0)) {
tmp = y * (x + -1.0);
} else {
tmp = 1.0 - y;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -3.5e-13) or not (x <= 56000000000.0): tmp = y * (x + -1.0) else: tmp = 1.0 - y return tmp
function code(x, y) tmp = 0.0 if ((x <= -3.5e-13) || !(x <= 56000000000.0)) tmp = Float64(y * Float64(x + -1.0)); else tmp = Float64(1.0 - y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -3.5e-13) || ~((x <= 56000000000.0))) tmp = y * (x + -1.0); else tmp = 1.0 - y; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -3.5e-13], N[Not[LessEqual[x, 56000000000.0]], $MachinePrecision]], N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \cdot 10^{-13} \lor \neg \left(x \leq 56000000000\right):\\
\;\;\;\;y \cdot \left(x + -1\right)\\
\mathbf{else}:\\
\;\;\;\;1 - y\\
\end{array}
\end{array}
if x < -3.5000000000000002e-13 or 5.6e10 < x Initial program 55.0%
+-commutative55.0%
sub-neg55.0%
+-commutative55.0%
distribute-rgt-in55.0%
*-lft-identity55.0%
associate-+r-55.0%
associate-+l-100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
mul-1-neg100.0%
mul-1-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
distribute-lft-out--100.0%
cancel-sign-sub-inv100.0%
*-rgt-identity100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 77.0%
if -3.5000000000000002e-13 < x < 5.6e10Initial program 99.8%
+-commutative99.8%
sub-neg99.8%
+-commutative99.8%
distribute-rgt-in99.8%
*-lft-identity99.8%
associate-+r-99.8%
associate-+l-100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
mul-1-neg100.0%
mul-1-neg100.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 simplification86.7%
(FPCore (x y) :precision binary64 (if (<= x -105000.0) (* y x) (if (<= x 35000000000.0) (- 1.0 y) (* y x))))
double code(double x, double y) {
double tmp;
if (x <= -105000.0) {
tmp = y * x;
} else if (x <= 35000000000.0) {
tmp = 1.0 - 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 (x <= (-105000.0d0)) then
tmp = y * x
else if (x <= 35000000000.0d0) then
tmp = 1.0d0 - y
else
tmp = y * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -105000.0) {
tmp = y * x;
} else if (x <= 35000000000.0) {
tmp = 1.0 - y;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -105000.0: tmp = y * x elif x <= 35000000000.0: tmp = 1.0 - y else: tmp = y * x return tmp
function code(x, y) tmp = 0.0 if (x <= -105000.0) tmp = Float64(y * x); elseif (x <= 35000000000.0) tmp = Float64(1.0 - y); else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -105000.0) tmp = y * x; elseif (x <= 35000000000.0) tmp = 1.0 - y; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -105000.0], N[(y * x), $MachinePrecision], If[LessEqual[x, 35000000000.0], N[(1.0 - y), $MachinePrecision], N[(y * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -105000:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;x \leq 35000000000:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if x < -105000 or 3.5e10 < x Initial program 53.4%
+-commutative53.4%
sub-neg53.4%
+-commutative53.4%
distribute-rgt-in53.5%
*-lft-identity53.5%
associate-+r-53.5%
associate-+l-100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
mul-1-neg100.0%
mul-1-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 99.0%
Taylor expanded in y around inf 75.9%
if -105000 < x < 3.5e10Initial program 99.7%
+-commutative99.7%
sub-neg99.7%
+-commutative99.7%
distribute-rgt-in99.7%
*-lft-identity99.7%
associate-+r-99.7%
associate-+l-100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
mul-1-neg100.0%
mul-1-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 98.3%
neg-mul-198.3%
unsub-neg98.3%
Simplified98.3%
Final simplification86.1%
(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 74.6%
+-commutative74.6%
sub-neg74.6%
+-commutative74.6%
distribute-rgt-in74.6%
*-lft-identity74.6%
associate-+r-74.6%
associate-+l-100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
mul-1-neg100.0%
mul-1-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (<= y -1.0) (- y) (if (<= y 0.016) 1.0 (- y))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = -y;
} else if (y <= 0.016) {
tmp = 1.0;
} else {
tmp = -y;
}
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)) then
tmp = -y
else if (y <= 0.016d0) then
tmp = 1.0d0
else
tmp = -y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = -y;
} else if (y <= 0.016) {
tmp = 1.0;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = -y elif y <= 0.016: tmp = 1.0 else: tmp = -y return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = Float64(-y); elseif (y <= 0.016) tmp = 1.0; else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.0) tmp = -y; elseif (y <= 0.016) tmp = 1.0; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], (-y), If[LessEqual[y, 0.016], 1.0, (-y)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;-y\\
\mathbf{elif}\;y \leq 0.016:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < -1 or 0.016 < y Initial program 99.9%
+-commutative99.9%
sub-neg99.9%
+-commutative99.9%
distribute-rgt-in99.9%
*-lft-identity99.9%
associate-+r-99.9%
associate-+l-100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
mul-1-neg100.0%
mul-1-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
distribute-lft-out--100.0%
cancel-sign-sub-inv100.0%
*-rgt-identity100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 99.4%
Taylor expanded in x around 0 45.0%
mul-1-neg45.0%
Simplified45.0%
if -1 < y < 0.016Initial program 50.0%
+-commutative50.0%
sub-neg50.0%
+-commutative50.0%
distribute-rgt-in50.1%
*-lft-identity50.1%
associate-+r-50.1%
associate-+l-100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
mul-1-neg100.0%
mul-1-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 69.6%
Final simplification57.5%
(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 74.6%
+-commutative74.6%
sub-neg74.6%
+-commutative74.6%
distribute-rgt-in74.6%
*-lft-identity74.6%
associate-+r-74.6%
associate-+l-100.0%
+-inverses100.0%
--rgt-identity100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
mul-1-neg100.0%
mul-1-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 36.7%
Final simplification36.7%
(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 2023268
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.Vectors:renderPlotVectors from Chart-1.5.3"
:precision binary64
:herbie-target
(- (* y x) (- y 1.0))
(+ x (* (- 1.0 x) (- 1.0 y))))