
(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 (fma (+ x -1.0) y 1.0))
double code(double x, double y) {
return fma((x + -1.0), y, 1.0);
}
function code(x, y) return fma(Float64(x + -1.0), y, 1.0) end
code[x_, y_] := N[(N[(x + -1.0), $MachinePrecision] * y + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x + -1, y, 1\right)
\end{array}
Initial program 75.5%
+-commutative75.5%
remove-double-neg75.5%
unsub-neg75.5%
sub-neg75.5%
+-commutative75.5%
distribute-rgt-in75.5%
*-lft-identity75.5%
associate-+r-75.5%
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%
+-commutative100.0%
*-commutative100.0%
fma-define100.0%
Applied egg-rr100.0%
(FPCore (x y)
:precision binary64
(if (<= x -1.9e+38)
(* x y)
(if (<= x 2.1e-255)
1.0
(if (<= x 4.55e-57) (- y) (if (<= x 5.5e+43) 1.0 (* x y))))))
double code(double x, double y) {
double tmp;
if (x <= -1.9e+38) {
tmp = x * y;
} else if (x <= 2.1e-255) {
tmp = 1.0;
} else if (x <= 4.55e-57) {
tmp = -y;
} else if (x <= 5.5e+43) {
tmp = 1.0;
} else {
tmp = x * 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.9d+38)) then
tmp = x * y
else if (x <= 2.1d-255) then
tmp = 1.0d0
else if (x <= 4.55d-57) then
tmp = -y
else if (x <= 5.5d+43) then
tmp = 1.0d0
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.9e+38) {
tmp = x * y;
} else if (x <= 2.1e-255) {
tmp = 1.0;
} else if (x <= 4.55e-57) {
tmp = -y;
} else if (x <= 5.5e+43) {
tmp = 1.0;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.9e+38: tmp = x * y elif x <= 2.1e-255: tmp = 1.0 elif x <= 4.55e-57: tmp = -y elif x <= 5.5e+43: tmp = 1.0 else: tmp = x * y return tmp
function code(x, y) tmp = 0.0 if (x <= -1.9e+38) tmp = Float64(x * y); elseif (x <= 2.1e-255) tmp = 1.0; elseif (x <= 4.55e-57) tmp = Float64(-y); elseif (x <= 5.5e+43) tmp = 1.0; else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.9e+38) tmp = x * y; elseif (x <= 2.1e-255) tmp = 1.0; elseif (x <= 4.55e-57) tmp = -y; elseif (x <= 5.5e+43) tmp = 1.0; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.9e+38], N[(x * y), $MachinePrecision], If[LessEqual[x, 2.1e-255], 1.0, If[LessEqual[x, 4.55e-57], (-y), If[LessEqual[x, 5.5e+43], 1.0, N[(x * y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9 \cdot 10^{+38}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{-255}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 4.55 \cdot 10^{-57}:\\
\;\;\;\;-y\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{+43}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if x < -1.8999999999999999e38 or 5.49999999999999989e43 < x Initial program 47.3%
+-commutative47.3%
remove-double-neg47.3%
unsub-neg47.3%
sub-neg47.3%
+-commutative47.3%
distribute-rgt-in47.3%
*-lft-identity47.3%
associate-+r-47.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%
+-commutative100.0%
*-commutative100.0%
fma-define100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 82.0%
*-commutative82.0%
Simplified82.0%
if -1.8999999999999999e38 < x < 2.1e-255 or 4.55000000000000017e-57 < x < 5.49999999999999989e43Initial program 90.5%
+-commutative90.5%
remove-double-neg90.5%
unsub-neg90.5%
sub-neg90.5%
+-commutative90.5%
distribute-rgt-in90.5%
*-lft-identity90.5%
associate-+r-90.5%
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 61.0%
if 2.1e-255 < x < 4.55000000000000017e-57Initial 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 x around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 71.3%
neg-mul-171.3%
Simplified71.3%
Final simplification70.4%
(FPCore (x y) :precision binary64 (if (or (<= (- 1.0 y) -2e+15) (not (<= (- 1.0 y) 1.002))) (* (+ x -1.0) y) (+ 1.0 (* x y))))
double code(double x, double y) {
double tmp;
if (((1.0 - y) <= -2e+15) || !((1.0 - y) <= 1.002)) {
tmp = (x + -1.0) * y;
} else {
tmp = 1.0 + (x * y);
}
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) <= (-2d+15)) .or. (.not. ((1.0d0 - y) <= 1.002d0))) then
tmp = (x + (-1.0d0)) * y
else
tmp = 1.0d0 + (x * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (((1.0 - y) <= -2e+15) || !((1.0 - y) <= 1.002)) {
tmp = (x + -1.0) * y;
} else {
tmp = 1.0 + (x * y);
}
return tmp;
}
def code(x, y): tmp = 0 if ((1.0 - y) <= -2e+15) or not ((1.0 - y) <= 1.002): tmp = (x + -1.0) * y else: tmp = 1.0 + (x * y) return tmp
function code(x, y) tmp = 0.0 if ((Float64(1.0 - y) <= -2e+15) || !(Float64(1.0 - y) <= 1.002)) tmp = Float64(Float64(x + -1.0) * y); else tmp = Float64(1.0 + Float64(x * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (((1.0 - y) <= -2e+15) || ~(((1.0 - y) <= 1.002))) tmp = (x + -1.0) * y; else tmp = 1.0 + (x * y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[(1.0 - y), $MachinePrecision], -2e+15], N[Not[LessEqual[N[(1.0 - y), $MachinePrecision], 1.002]], $MachinePrecision]], N[(N[(x + -1.0), $MachinePrecision] * y), $MachinePrecision], N[(1.0 + N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 - y \leq -2 \cdot 10^{+15} \lor \neg \left(1 - y \leq 1.002\right):\\
\;\;\;\;\left(x + -1\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot y\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) y) < -2e15 or 1.002 < (-.f64 #s(literal 1 binary64) y) Initial program 99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
sub-neg99.9%
+-commutative99.9%
distribute-rgt-in99.9%
*-lft-identity99.9%
associate-+r-99.9%
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%
+-commutative100.0%
*-commutative100.0%
fma-define100.0%
Applied egg-rr100.0%
Taylor expanded in y around inf 99.1%
if -2e15 < (-.f64 #s(literal 1 binary64) y) < 1.002Initial 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 x around inf 98.9%
*-commutative98.9%
Simplified98.9%
Final simplification99.0%
(FPCore (x y) :precision binary64 (if (<= x -5.5e+51) (* x y) (if (<= x 9e+41) (- 1.0 y) (* (+ x -1.0) y))))
double code(double x, double y) {
double tmp;
if (x <= -5.5e+51) {
tmp = x * y;
} else if (x <= 9e+41) {
tmp = 1.0 - y;
} else {
tmp = (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 <= (-5.5d+51)) then
tmp = x * y
else if (x <= 9d+41) then
tmp = 1.0d0 - y
else
tmp = (x + (-1.0d0)) * y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -5.5e+51) {
tmp = x * y;
} else if (x <= 9e+41) {
tmp = 1.0 - y;
} else {
tmp = (x + -1.0) * y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -5.5e+51: tmp = x * y elif x <= 9e+41: tmp = 1.0 - y else: tmp = (x + -1.0) * y return tmp
function code(x, y) tmp = 0.0 if (x <= -5.5e+51) tmp = Float64(x * y); elseif (x <= 9e+41) tmp = Float64(1.0 - y); else tmp = Float64(Float64(x + -1.0) * y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -5.5e+51) tmp = x * y; elseif (x <= 9e+41) tmp = 1.0 - y; else tmp = (x + -1.0) * y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5.5e+51], N[(x * y), $MachinePrecision], If[LessEqual[x, 9e+41], N[(1.0 - y), $MachinePrecision], N[(N[(x + -1.0), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \cdot 10^{+51}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+41}:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;\left(x + -1\right) \cdot y\\
\end{array}
\end{array}
if x < -5.5e51Initial program 54.0%
+-commutative54.0%
remove-double-neg54.0%
unsub-neg54.0%
sub-neg54.0%
+-commutative54.0%
distribute-rgt-in54.0%
*-lft-identity54.0%
associate-+r-54.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%
+-commutative100.0%
*-commutative100.0%
fma-define100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 82.8%
*-commutative82.8%
Simplified82.8%
if -5.5e51 < x < 9.0000000000000002e41Initial program 92.2%
+-commutative92.2%
remove-double-neg92.2%
unsub-neg92.2%
sub-neg92.2%
+-commutative92.2%
distribute-rgt-in92.2%
*-lft-identity92.2%
associate-+r-92.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 x around 0 95.4%
neg-mul-195.4%
unsub-neg95.4%
Simplified95.4%
if 9.0000000000000002e41 < x Initial program 39.6%
+-commutative39.6%
remove-double-neg39.6%
unsub-neg39.6%
sub-neg39.6%
+-commutative39.6%
distribute-rgt-in39.6%
*-lft-identity39.6%
associate-+r-39.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%
+-commutative100.0%
*-commutative100.0%
fma-define100.0%
Applied egg-rr100.0%
Taylor expanded in y around inf 82.6%
Final simplification90.7%
(FPCore (x y) :precision binary64 (if (or (<= x -1.45e+52) (not (<= x 3.4e+38))) (* x y) (- 1.0 y)))
double code(double x, double y) {
double tmp;
if ((x <= -1.45e+52) || !(x <= 3.4e+38)) {
tmp = x * y;
} 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.45d+52)) .or. (.not. (x <= 3.4d+38))) then
tmp = x * y
else
tmp = 1.0d0 - y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.45e+52) || !(x <= 3.4e+38)) {
tmp = x * y;
} else {
tmp = 1.0 - y;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.45e+52) or not (x <= 3.4e+38): tmp = x * y else: tmp = 1.0 - y return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.45e+52) || !(x <= 3.4e+38)) tmp = Float64(x * y); else tmp = Float64(1.0 - y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.45e+52) || ~((x <= 3.4e+38))) tmp = x * y; else tmp = 1.0 - y; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.45e+52], N[Not[LessEqual[x, 3.4e+38]], $MachinePrecision]], N[(x * y), $MachinePrecision], N[(1.0 - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \cdot 10^{+52} \lor \neg \left(x \leq 3.4 \cdot 10^{+38}\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;1 - y\\
\end{array}
\end{array}
if x < -1.45e52 or 3.39999999999999996e38 < x Initial program 47.2%
+-commutative47.2%
remove-double-neg47.2%
unsub-neg47.2%
sub-neg47.2%
+-commutative47.2%
distribute-rgt-in47.2%
*-lft-identity47.2%
associate-+r-47.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%
+-commutative100.0%
*-commutative100.0%
fma-define100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 82.7%
*-commutative82.7%
Simplified82.7%
if -1.45e52 < x < 3.39999999999999996e38Initial program 92.2%
+-commutative92.2%
remove-double-neg92.2%
unsub-neg92.2%
sub-neg92.2%
+-commutative92.2%
distribute-rgt-in92.2%
*-lft-identity92.2%
associate-+r-92.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 x around 0 95.4%
neg-mul-195.4%
unsub-neg95.4%
Simplified95.4%
Final simplification90.7%
(FPCore (x y) :precision binary64 (if (or (<= y -0.0029) (not (<= y 1.0))) (- y) 1.0))
double code(double x, double y) {
double tmp;
if ((y <= -0.0029) || !(y <= 1.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 <= (-0.0029d0)) .or. (.not. (y <= 1.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 <= -0.0029) || !(y <= 1.0)) {
tmp = -y;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -0.0029) or not (y <= 1.0): tmp = -y else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if ((y <= -0.0029) || !(y <= 1.0)) tmp = Float64(-y); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -0.0029) || ~((y <= 1.0))) tmp = -y; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -0.0029], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], (-y), 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.0029 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;-y\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -0.0029 or 1 < y Initial program 99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
sub-neg99.9%
+-commutative99.9%
distribute-rgt-in99.9%
*-lft-identity99.9%
associate-+r-99.9%
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 60.3%
neg-mul-160.3%
unsub-neg60.3%
Simplified60.3%
Taylor expanded in y around inf 59.5%
neg-mul-159.5%
Simplified59.5%
if -0.0029 < y < 1Initial 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 71.8%
Final simplification66.3%
(FPCore (x y) :precision binary64 (+ 1.0 (* (+ x -1.0) y)))
double code(double x, double y) {
return 1.0 + ((x + -1.0) * y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 + ((x + (-1.0d0)) * y)
end function
public static double code(double x, double y) {
return 1.0 + ((x + -1.0) * y);
}
def code(x, y): return 1.0 + ((x + -1.0) * y)
function code(x, y) return Float64(1.0 + Float64(Float64(x + -1.0) * y)) end
function tmp = code(x, y) tmp = 1.0 + ((x + -1.0) * y); end
code[x_, y_] := N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(x + -1\right) \cdot y
\end{array}
Initial program 75.5%
+-commutative75.5%
remove-double-neg75.5%
unsub-neg75.5%
sub-neg75.5%
+-commutative75.5%
distribute-rgt-in75.5%
*-lft-identity75.5%
associate-+r-75.5%
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%
Final simplification100.0%
(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 75.5%
+-commutative75.5%
remove-double-neg75.5%
unsub-neg75.5%
sub-neg75.5%
+-commutative75.5%
distribute-rgt-in75.5%
*-lft-identity75.5%
associate-+r-75.5%
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 40.9%
(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 2024180
(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))))