
(FPCore (x y z) :precision binary64 (+ (+ (+ (+ (+ x y) y) x) z) x))
double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((((x + y) + y) + x) + z) + x
end function
public static double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + x;
}
def code(x, y, z): return ((((x + y) + y) + x) + z) + x
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x + y) + y) + x) + z) + x) end
function tmp = code(x, y, z) tmp = ((((x + y) + y) + x) + z) + x; end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x + y), $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (+ (+ (+ (+ x y) y) x) z) x))
double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((((x + y) + y) + x) + z) + x
end function
public static double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + x;
}
def code(x, y, z): return ((((x + y) + y) + x) + z) + x
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x + y) + y) + x) + z) + x) end
function tmp = code(x, y, z) tmp = ((((x + y) + y) + x) + z) + x; end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x + y), $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x
\end{array}
(FPCore (x y z) :precision binary64 (+ z (fma x 3.0 (* 2.0 y))))
double code(double x, double y, double z) {
return z + fma(x, 3.0, (2.0 * y));
}
function code(x, y, z) return Float64(z + fma(x, 3.0, Float64(2.0 * y))) end
code[x_, y_, z_] := N[(z + N[(x * 3.0 + N[(2.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z + \mathsf{fma}\left(x, 3, 2 \cdot y\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
remove-double-neg99.9%
distribute-neg-in99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
associate-+l+99.9%
+-commutative99.9%
associate-+r+99.9%
associate--l+99.9%
count-299.9%
*-commutative99.9%
fma-def99.9%
count-299.9%
neg-mul-199.9%
distribute-rgt-out--99.9%
metadata-eval99.9%
Simplified99.9%
add-log-exp22.4%
*-un-lft-identity22.4%
log-prod22.4%
metadata-eval22.4%
add-log-exp99.9%
fma-udef99.9%
+-commutative99.9%
fma-def99.9%
*-commutative99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(if (<= x -1.2e+47)
(* x 3.0)
(if (<= x -5.8e+18)
(* 2.0 y)
(if (<= x -1.45e-5)
(* x 3.0)
(if (<= x -1.15e-194)
z
(if (<= x -4e-261)
(* 2.0 y)
(if (<= x -1.6e-274)
z
(if (<= x 3100000000.0) (* 2.0 y) (* x 3.0)))))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.2e+47) {
tmp = x * 3.0;
} else if (x <= -5.8e+18) {
tmp = 2.0 * y;
} else if (x <= -1.45e-5) {
tmp = x * 3.0;
} else if (x <= -1.15e-194) {
tmp = z;
} else if (x <= -4e-261) {
tmp = 2.0 * y;
} else if (x <= -1.6e-274) {
tmp = z;
} else if (x <= 3100000000.0) {
tmp = 2.0 * y;
} else {
tmp = x * 3.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-1.2d+47)) then
tmp = x * 3.0d0
else if (x <= (-5.8d+18)) then
tmp = 2.0d0 * y
else if (x <= (-1.45d-5)) then
tmp = x * 3.0d0
else if (x <= (-1.15d-194)) then
tmp = z
else if (x <= (-4d-261)) then
tmp = 2.0d0 * y
else if (x <= (-1.6d-274)) then
tmp = z
else if (x <= 3100000000.0d0) then
tmp = 2.0d0 * y
else
tmp = x * 3.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.2e+47) {
tmp = x * 3.0;
} else if (x <= -5.8e+18) {
tmp = 2.0 * y;
} else if (x <= -1.45e-5) {
tmp = x * 3.0;
} else if (x <= -1.15e-194) {
tmp = z;
} else if (x <= -4e-261) {
tmp = 2.0 * y;
} else if (x <= -1.6e-274) {
tmp = z;
} else if (x <= 3100000000.0) {
tmp = 2.0 * y;
} else {
tmp = x * 3.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.2e+47: tmp = x * 3.0 elif x <= -5.8e+18: tmp = 2.0 * y elif x <= -1.45e-5: tmp = x * 3.0 elif x <= -1.15e-194: tmp = z elif x <= -4e-261: tmp = 2.0 * y elif x <= -1.6e-274: tmp = z elif x <= 3100000000.0: tmp = 2.0 * y else: tmp = x * 3.0 return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.2e+47) tmp = Float64(x * 3.0); elseif (x <= -5.8e+18) tmp = Float64(2.0 * y); elseif (x <= -1.45e-5) tmp = Float64(x * 3.0); elseif (x <= -1.15e-194) tmp = z; elseif (x <= -4e-261) tmp = Float64(2.0 * y); elseif (x <= -1.6e-274) tmp = z; elseif (x <= 3100000000.0) tmp = Float64(2.0 * y); else tmp = Float64(x * 3.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.2e+47) tmp = x * 3.0; elseif (x <= -5.8e+18) tmp = 2.0 * y; elseif (x <= -1.45e-5) tmp = x * 3.0; elseif (x <= -1.15e-194) tmp = z; elseif (x <= -4e-261) tmp = 2.0 * y; elseif (x <= -1.6e-274) tmp = z; elseif (x <= 3100000000.0) tmp = 2.0 * y; else tmp = x * 3.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.2e+47], N[(x * 3.0), $MachinePrecision], If[LessEqual[x, -5.8e+18], N[(2.0 * y), $MachinePrecision], If[LessEqual[x, -1.45e-5], N[(x * 3.0), $MachinePrecision], If[LessEqual[x, -1.15e-194], z, If[LessEqual[x, -4e-261], N[(2.0 * y), $MachinePrecision], If[LessEqual[x, -1.6e-274], z, If[LessEqual[x, 3100000000.0], N[(2.0 * y), $MachinePrecision], N[(x * 3.0), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{+47}:\\
\;\;\;\;x \cdot 3\\
\mathbf{elif}\;x \leq -5.8 \cdot 10^{+18}:\\
\;\;\;\;2 \cdot y\\
\mathbf{elif}\;x \leq -1.45 \cdot 10^{-5}:\\
\;\;\;\;x \cdot 3\\
\mathbf{elif}\;x \leq -1.15 \cdot 10^{-194}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq -4 \cdot 10^{-261}:\\
\;\;\;\;2 \cdot y\\
\mathbf{elif}\;x \leq -1.6 \cdot 10^{-274}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq 3100000000:\\
\;\;\;\;2 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot 3\\
\end{array}
\end{array}
if x < -1.20000000000000009e47 or -5.8e18 < x < -1.45e-5 or 3.1e9 < x Initial program 99.8%
+-commutative99.8%
associate-+l+99.8%
+-commutative99.8%
count-299.8%
Simplified99.8%
Taylor expanded in x around inf 69.9%
if -1.20000000000000009e47 < x < -5.8e18 or -1.15000000000000001e-194 < x < -3.99999999999999994e-261 or -1.59999999999999989e-274 < x < 3.1e9Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in y around inf 66.5%
if -1.45e-5 < x < -1.15000000000000001e-194 or -3.99999999999999994e-261 < x < -1.59999999999999989e-274Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in z around inf 63.5%
Final simplification67.5%
(FPCore (x y z)
:precision binary64
(if (or (<= y -4e+60)
(and (not (<= y -1.9e+33)) (or (<= y -2.6e-19) (not (<= y 3.9e-7)))))
(+ z (* 2.0 y))
(+ z (* x 3.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4e+60) || (!(y <= -1.9e+33) && ((y <= -2.6e-19) || !(y <= 3.9e-7)))) {
tmp = z + (2.0 * y);
} else {
tmp = z + (x * 3.0);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-4d+60)) .or. (.not. (y <= (-1.9d+33))) .and. (y <= (-2.6d-19)) .or. (.not. (y <= 3.9d-7))) then
tmp = z + (2.0d0 * y)
else
tmp = z + (x * 3.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -4e+60) || (!(y <= -1.9e+33) && ((y <= -2.6e-19) || !(y <= 3.9e-7)))) {
tmp = z + (2.0 * y);
} else {
tmp = z + (x * 3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4e+60) or (not (y <= -1.9e+33) and ((y <= -2.6e-19) or not (y <= 3.9e-7))): tmp = z + (2.0 * y) else: tmp = z + (x * 3.0) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4e+60) || (!(y <= -1.9e+33) && ((y <= -2.6e-19) || !(y <= 3.9e-7)))) tmp = Float64(z + Float64(2.0 * y)); else tmp = Float64(z + Float64(x * 3.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -4e+60) || (~((y <= -1.9e+33)) && ((y <= -2.6e-19) || ~((y <= 3.9e-7))))) tmp = z + (2.0 * y); else tmp = z + (x * 3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4e+60], And[N[Not[LessEqual[y, -1.9e+33]], $MachinePrecision], Or[LessEqual[y, -2.6e-19], N[Not[LessEqual[y, 3.9e-7]], $MachinePrecision]]]], N[(z + N[(2.0 * y), $MachinePrecision]), $MachinePrecision], N[(z + N[(x * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{+60} \lor \neg \left(y \leq -1.9 \cdot 10^{+33}\right) \land \left(y \leq -2.6 \cdot 10^{-19} \lor \neg \left(y \leq 3.9 \cdot 10^{-7}\right)\right):\\
\;\;\;\;z + 2 \cdot y\\
\mathbf{else}:\\
\;\;\;\;z + x \cdot 3\\
\end{array}
\end{array}
if y < -3.9999999999999998e60 or -1.90000000000000001e33 < y < -2.60000000000000013e-19 or 3.90000000000000025e-7 < y Initial program 99.9%
+-commutative99.9%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around 0 87.0%
if -3.9999999999999998e60 < y < -1.90000000000000001e33 or -2.60000000000000013e-19 < y < 3.90000000000000025e-7Initial program 99.8%
+-commutative99.8%
associate-+l+99.8%
remove-double-neg99.8%
distribute-neg-in99.8%
distribute-neg-in99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-+l+99.8%
+-commutative99.8%
associate-+r+99.8%
associate--l+99.8%
count-299.8%
*-commutative99.8%
fma-def99.8%
count-299.8%
neg-mul-199.8%
distribute-rgt-out--99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 93.5%
Final simplification90.3%
(FPCore (x y z) :precision binary64 (if (<= x -2.1e+179) (* x 3.0) (if (<= x 2.6e+44) (+ z (* 2.0 y)) (* x 3.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.1e+179) {
tmp = x * 3.0;
} else if (x <= 2.6e+44) {
tmp = z + (2.0 * y);
} else {
tmp = x * 3.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-2.1d+179)) then
tmp = x * 3.0d0
else if (x <= 2.6d+44) then
tmp = z + (2.0d0 * y)
else
tmp = x * 3.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2.1e+179) {
tmp = x * 3.0;
} else if (x <= 2.6e+44) {
tmp = z + (2.0 * y);
} else {
tmp = x * 3.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.1e+179: tmp = x * 3.0 elif x <= 2.6e+44: tmp = z + (2.0 * y) else: tmp = x * 3.0 return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.1e+179) tmp = Float64(x * 3.0); elseif (x <= 2.6e+44) tmp = Float64(z + Float64(2.0 * y)); else tmp = Float64(x * 3.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2.1e+179) tmp = x * 3.0; elseif (x <= 2.6e+44) tmp = z + (2.0 * y); else tmp = x * 3.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.1e+179], N[(x * 3.0), $MachinePrecision], If[LessEqual[x, 2.6e+44], N[(z + N[(2.0 * y), $MachinePrecision]), $MachinePrecision], N[(x * 3.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{+179}:\\
\;\;\;\;x \cdot 3\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{+44}:\\
\;\;\;\;z + 2 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot 3\\
\end{array}
\end{array}
if x < -2.0999999999999999e179 or 2.5999999999999999e44 < x Initial program 99.8%
+-commutative99.8%
associate-+l+99.8%
+-commutative99.8%
count-299.8%
Simplified99.8%
Taylor expanded in x around inf 82.5%
if -2.0999999999999999e179 < x < 2.5999999999999999e44Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in x around 0 83.8%
Final simplification83.4%
(FPCore (x y z) :precision binary64 (if (<= x -4.2e-28) (+ x (* 2.0 (+ x y))) (if (<= x 1800000000.0) (+ z (* 2.0 y)) (+ z (* x 3.0)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -4.2e-28) {
tmp = x + (2.0 * (x + y));
} else if (x <= 1800000000.0) {
tmp = z + (2.0 * y);
} else {
tmp = z + (x * 3.0);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-4.2d-28)) then
tmp = x + (2.0d0 * (x + y))
else if (x <= 1800000000.0d0) then
tmp = z + (2.0d0 * y)
else
tmp = z + (x * 3.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -4.2e-28) {
tmp = x + (2.0 * (x + y));
} else if (x <= 1800000000.0) {
tmp = z + (2.0 * y);
} else {
tmp = z + (x * 3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -4.2e-28: tmp = x + (2.0 * (x + y)) elif x <= 1800000000.0: tmp = z + (2.0 * y) else: tmp = z + (x * 3.0) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -4.2e-28) tmp = Float64(x + Float64(2.0 * Float64(x + y))); elseif (x <= 1800000000.0) tmp = Float64(z + Float64(2.0 * y)); else tmp = Float64(z + Float64(x * 3.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -4.2e-28) tmp = x + (2.0 * (x + y)); elseif (x <= 1800000000.0) tmp = z + (2.0 * y); else tmp = z + (x * 3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -4.2e-28], N[(x + N[(2.0 * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1800000000.0], N[(z + N[(2.0 * y), $MachinePrecision]), $MachinePrecision], N[(z + N[(x * 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.2 \cdot 10^{-28}:\\
\;\;\;\;x + 2 \cdot \left(x + y\right)\\
\mathbf{elif}\;x \leq 1800000000:\\
\;\;\;\;z + 2 \cdot y\\
\mathbf{else}:\\
\;\;\;\;z + x \cdot 3\\
\end{array}
\end{array}
if x < -4.20000000000000013e-28Initial program 99.8%
+-commutative99.8%
associate-+l+99.8%
+-commutative99.8%
count-299.8%
Simplified99.8%
Taylor expanded in z around 0 83.9%
if -4.20000000000000013e-28 < x < 1.8e9Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around 0 95.2%
if 1.8e9 < x Initial program 99.8%
+-commutative99.8%
associate-+l+99.8%
remove-double-neg99.8%
distribute-neg-in99.8%
distribute-neg-in99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-+l+99.8%
+-commutative99.8%
associate-+r+99.8%
associate--l+99.8%
count-299.8%
*-commutative99.8%
fma-def99.8%
count-299.8%
neg-mul-199.8%
distribute-rgt-out--99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 90.4%
Final simplification90.6%
(FPCore (x y z) :precision binary64 (if (<= x -4.2e-28) (+ (* 2.0 y) (* x 3.0)) (if (<= x 950000000.0) (+ z (* 2.0 y)) (+ z (* x 3.0)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -4.2e-28) {
tmp = (2.0 * y) + (x * 3.0);
} else if (x <= 950000000.0) {
tmp = z + (2.0 * y);
} else {
tmp = z + (x * 3.0);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-4.2d-28)) then
tmp = (2.0d0 * y) + (x * 3.0d0)
else if (x <= 950000000.0d0) then
tmp = z + (2.0d0 * y)
else
tmp = z + (x * 3.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -4.2e-28) {
tmp = (2.0 * y) + (x * 3.0);
} else if (x <= 950000000.0) {
tmp = z + (2.0 * y);
} else {
tmp = z + (x * 3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -4.2e-28: tmp = (2.0 * y) + (x * 3.0) elif x <= 950000000.0: tmp = z + (2.0 * y) else: tmp = z + (x * 3.0) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -4.2e-28) tmp = Float64(Float64(2.0 * y) + Float64(x * 3.0)); elseif (x <= 950000000.0) tmp = Float64(z + Float64(2.0 * y)); else tmp = Float64(z + Float64(x * 3.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -4.2e-28) tmp = (2.0 * y) + (x * 3.0); elseif (x <= 950000000.0) tmp = z + (2.0 * y); else tmp = z + (x * 3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -4.2e-28], N[(N[(2.0 * y), $MachinePrecision] + N[(x * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 950000000.0], N[(z + N[(2.0 * y), $MachinePrecision]), $MachinePrecision], N[(z + N[(x * 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.2 \cdot 10^{-28}:\\
\;\;\;\;2 \cdot y + x \cdot 3\\
\mathbf{elif}\;x \leq 950000000:\\
\;\;\;\;z + 2 \cdot y\\
\mathbf{else}:\\
\;\;\;\;z + x \cdot 3\\
\end{array}
\end{array}
if x < -4.20000000000000013e-28Initial program 99.8%
+-commutative99.8%
associate-+l+99.8%
remove-double-neg99.8%
distribute-neg-in99.8%
distribute-neg-in99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-+l+99.8%
+-commutative99.8%
associate-+r+99.8%
associate--l+99.8%
count-299.8%
*-commutative99.8%
fma-def99.8%
count-299.8%
neg-mul-199.8%
distribute-rgt-out--99.8%
metadata-eval99.8%
Simplified99.8%
add-log-exp14.1%
*-un-lft-identity14.1%
log-prod14.1%
metadata-eval14.1%
add-log-exp99.8%
fma-udef99.8%
+-commutative99.8%
fma-def99.9%
*-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in z around 0 83.9%
if -4.20000000000000013e-28 < x < 9.5e8Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around 0 95.2%
if 9.5e8 < x Initial program 99.8%
+-commutative99.8%
associate-+l+99.8%
remove-double-neg99.8%
distribute-neg-in99.8%
distribute-neg-in99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-+l+99.8%
+-commutative99.8%
associate-+r+99.8%
associate--l+99.8%
count-299.8%
*-commutative99.8%
fma-def99.8%
count-299.8%
neg-mul-199.8%
distribute-rgt-out--99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 90.4%
Final simplification90.6%
(FPCore (x y z) :precision binary64 (+ x (+ z (* 2.0 (+ x y)))))
double code(double x, double y, double z) {
return x + (z + (2.0 * (x + y)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + (z + (2.0d0 * (x + y)))
end function
public static double code(double x, double y, double z) {
return x + (z + (2.0 * (x + y)));
}
def code(x, y, z): return x + (z + (2.0 * (x + y)))
function code(x, y, z) return Float64(x + Float64(z + Float64(2.0 * Float64(x + y)))) end
function tmp = code(x, y, z) tmp = x + (z + (2.0 * (x + y))); end
code[x_, y_, z_] := N[(x + N[(z + N[(2.0 * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(z + 2 \cdot \left(x + y\right)\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (+ z (+ (* 2.0 y) (* x 3.0))))
double code(double x, double y, double z) {
return z + ((2.0 * y) + (x * 3.0));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z + ((2.0d0 * y) + (x * 3.0d0))
end function
public static double code(double x, double y, double z) {
return z + ((2.0 * y) + (x * 3.0));
}
def code(x, y, z): return z + ((2.0 * y) + (x * 3.0))
function code(x, y, z) return Float64(z + Float64(Float64(2.0 * y) + Float64(x * 3.0))) end
function tmp = code(x, y, z) tmp = z + ((2.0 * y) + (x * 3.0)); end
code[x_, y_, z_] := N[(z + N[(N[(2.0 * y), $MachinePrecision] + N[(x * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z + \left(2 \cdot y + x \cdot 3\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
remove-double-neg99.9%
distribute-neg-in99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
associate-+l+99.9%
+-commutative99.9%
associate-+r+99.9%
associate--l+99.9%
count-299.9%
*-commutative99.9%
fma-def99.9%
count-299.9%
neg-mul-199.9%
distribute-rgt-out--99.9%
metadata-eval99.9%
Simplified99.9%
fma-udef99.9%
+-commutative99.9%
*-commutative99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= y -2.1e-63) (* 2.0 y) (if (<= y 7.5e-23) z (* 2.0 y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.1e-63) {
tmp = 2.0 * y;
} else if (y <= 7.5e-23) {
tmp = z;
} else {
tmp = 2.0 * y;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-2.1d-63)) then
tmp = 2.0d0 * y
else if (y <= 7.5d-23) then
tmp = z
else
tmp = 2.0d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.1e-63) {
tmp = 2.0 * y;
} else if (y <= 7.5e-23) {
tmp = z;
} else {
tmp = 2.0 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.1e-63: tmp = 2.0 * y elif y <= 7.5e-23: tmp = z else: tmp = 2.0 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.1e-63) tmp = Float64(2.0 * y); elseif (y <= 7.5e-23) tmp = z; else tmp = Float64(2.0 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.1e-63) tmp = 2.0 * y; elseif (y <= 7.5e-23) tmp = z; else tmp = 2.0 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.1e-63], N[(2.0 * y), $MachinePrecision], If[LessEqual[y, 7.5e-23], z, N[(2.0 * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.1 \cdot 10^{-63}:\\
\;\;\;\;2 \cdot y\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{-23}:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;2 \cdot y\\
\end{array}
\end{array}
if y < -2.1e-63 or 7.4999999999999998e-23 < y Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in y around inf 62.7%
if -2.1e-63 < y < 7.4999999999999998e-23Initial program 99.8%
+-commutative99.8%
associate-+l+99.8%
+-commutative99.8%
count-299.8%
Simplified99.8%
Taylor expanded in z around inf 40.4%
Final simplification53.3%
(FPCore (x y z) :precision binary64 z)
double code(double x, double y, double z) {
return z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z
end function
public static double code(double x, double y, double z) {
return z;
}
def code(x, y, z): return z
function code(x, y, z) return z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
\begin{array}{l}
\\
z
\end{array}
Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in z around inf 28.1%
Final simplification28.1%
herbie shell --seed 2023275
(FPCore (x y z)
:name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendInside from plot-0.2.3.4"
:precision binary64
(+ (+ (+ (+ (+ x y) y) x) z) x))