
(FPCore (x y z) :precision binary64 (+ (+ (+ (* x y) (* z z)) (* z z)) (* z z)))
double code(double x, double y, double z) {
return (((x * y) + (z * z)) + (z * z)) + (z * z);
}
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) + (z * z)) + (z * z)) + (z * z)
end function
public static double code(double x, double y, double z) {
return (((x * y) + (z * z)) + (z * z)) + (z * z);
}
def code(x, y, z): return (((x * y) + (z * z)) + (z * z)) + (z * z)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * y) + Float64(z * z)) + Float64(z * z)) + Float64(z * z)) end
function tmp = code(x, y, z) tmp = (((x * y) + (z * z)) + (z * z)) + (z * z); end
code[x_, y_, z_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (+ (+ (* x y) (* z z)) (* z z)) (* z z)))
double code(double x, double y, double z) {
return (((x * y) + (z * z)) + (z * z)) + (z * z);
}
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) + (z * z)) + (z * z)) + (z * z)
end function
public static double code(double x, double y, double z) {
return (((x * y) + (z * z)) + (z * z)) + (z * z);
}
def code(x, y, z): return (((x * y) + (z * z)) + (z * z)) + (z * z)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * y) + Float64(z * z)) + Float64(z * z)) + Float64(z * z)) end
function tmp = code(x, y, z) tmp = (((x * y) + (z * z)) + (z * z)) + (z * z); end
code[x_, y_, z_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
\end{array}
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= x -5.4e+72) (* x (+ y (* 3.0 (* z (* z (/ 1.0 x)))))) (+ (* z z) (+ (* z z) (+ (* z z) (* x y))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (x <= -5.4e+72) {
tmp = x * (y + (3.0 * (z * (z * (1.0 / x)))));
} else {
tmp = (z * z) + ((z * z) + ((z * z) + (x * y)));
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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 <= (-5.4d+72)) then
tmp = x * (y + (3.0d0 * (z * (z * (1.0d0 / x)))))
else
tmp = (z * z) + ((z * z) + ((z * z) + (x * y)))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (x <= -5.4e+72) {
tmp = x * (y + (3.0 * (z * (z * (1.0 / x)))));
} else {
tmp = (z * z) + ((z * z) + ((z * z) + (x * y)));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if x <= -5.4e+72: tmp = x * (y + (3.0 * (z * (z * (1.0 / x))))) else: tmp = (z * z) + ((z * z) + ((z * z) + (x * y))) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (x <= -5.4e+72) tmp = Float64(x * Float64(y + Float64(3.0 * Float64(z * Float64(z * Float64(1.0 / x)))))); else tmp = Float64(Float64(z * z) + Float64(Float64(z * z) + Float64(Float64(z * z) + Float64(x * y)))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (x <= -5.4e+72)
tmp = x * (y + (3.0 * (z * (z * (1.0 / x)))));
else
tmp = (z * z) + ((z * z) + ((z * z) + (x * y)));
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[x, -5.4e+72], N[(x * N[(y + N[(3.0 * N[(z * N[(z * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z * z), $MachinePrecision] + N[(N[(z * z), $MachinePrecision] + N[(N[(z * z), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.4 \cdot 10^{+72}:\\
\;\;\;\;x \cdot \left(y + 3 \cdot \left(z \cdot \left(z \cdot \frac{1}{x}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot z + \left(z \cdot z + \left(z \cdot z + x \cdot y\right)\right)\\
\end{array}
\end{array}
if x < -5.4000000000000001e72Initial program 90.8%
Taylor expanded in x around inf 98.1%
Simplified98.1%
div-inv98.1%
unpow298.1%
associate-*l*99.9%
Applied egg-rr99.9%
if -5.4000000000000001e72 < x Initial program 97.3%
Final simplification97.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (fma z z (fma x y (* 2.0 (* z z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
return fma(z, z, fma(x, y, (2.0 * (z * z))));
}
x, y, z = sort([x, y, z]) function code(x, y, z) return fma(z, z, fma(x, y, Float64(2.0 * Float64(z * z)))) end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(z * z + N[(x * y + N[(2.0 * N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\mathsf{fma}\left(z, z, \mathsf{fma}\left(x, y, 2 \cdot \left(z \cdot z\right)\right)\right)
\end{array}
Initial program 95.9%
+-commutative95.9%
fma-define96.0%
associate-+l+96.0%
fma-define99.2%
count-299.2%
Simplified99.2%
Final simplification99.2%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (fma x y (* z (* z 3.0))))
assert(x < y && y < z);
double code(double x, double y, double z) {
return fma(x, y, (z * (z * 3.0)));
}
x, y, z = sort([x, y, z]) function code(x, y, z) return fma(x, y, Float64(z * Float64(z * 3.0))) end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(x * y + N[(z * N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\mathsf{fma}\left(x, y, z \cdot \left(z \cdot 3\right)\right)
\end{array}
Initial program 95.9%
associate-+l+95.9%
associate-+l+95.9%
fma-define99.1%
associate-+r+99.1%
distribute-lft-out99.1%
distribute-lft-out99.1%
remove-double-neg99.1%
unsub-neg99.1%
count-299.1%
neg-mul-199.1%
distribute-rgt-out--99.1%
metadata-eval99.1%
Simplified99.1%
Final simplification99.1%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= x -3.8e-130) (* x (+ y (* 3.0 (/ z (/ x z))))) (* y (+ x (* 3.0 (* z (/ z y)))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (x <= -3.8e-130) {
tmp = x * (y + (3.0 * (z / (x / z))));
} else {
tmp = y * (x + (3.0 * (z * (z / y))));
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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 <= (-3.8d-130)) then
tmp = x * (y + (3.0d0 * (z / (x / z))))
else
tmp = y * (x + (3.0d0 * (z * (z / y))))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (x <= -3.8e-130) {
tmp = x * (y + (3.0 * (z / (x / z))));
} else {
tmp = y * (x + (3.0 * (z * (z / y))));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if x <= -3.8e-130: tmp = x * (y + (3.0 * (z / (x / z)))) else: tmp = y * (x + (3.0 * (z * (z / y)))) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (x <= -3.8e-130) tmp = Float64(x * Float64(y + Float64(3.0 * Float64(z / Float64(x / z))))); else tmp = Float64(y * Float64(x + Float64(3.0 * Float64(z * Float64(z / y))))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (x <= -3.8e-130)
tmp = x * (y + (3.0 * (z / (x / z))));
else
tmp = y * (x + (3.0 * (z * (z / y))));
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[x, -3.8e-130], N[(x * N[(y + N[(3.0 * N[(z / N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(x + N[(3.0 * N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.8 \cdot 10^{-130}:\\
\;\;\;\;x \cdot \left(y + 3 \cdot \frac{z}{\frac{x}{z}}\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x + 3 \cdot \left(z \cdot \frac{z}{y}\right)\right)\\
\end{array}
\end{array}
if x < -3.7999999999999998e-130Initial program 94.3%
Taylor expanded in x around inf 96.7%
Simplified96.7%
unpow296.7%
associate-/l*97.8%
Applied egg-rr97.8%
clear-num97.7%
un-div-inv97.8%
Applied egg-rr97.8%
if -3.7999999999999998e-130 < x Initial program 96.8%
Taylor expanded in y around inf 91.8%
Simplified91.8%
unpow291.8%
associate-/l*92.4%
Applied egg-rr92.4%
Final simplification94.3%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= x -9.6e-136) (* x (+ y (* 3.0 (/ z (/ x z))))) (* y (+ x (* 3.0 (/ z (/ y z)))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (x <= -9.6e-136) {
tmp = x * (y + (3.0 * (z / (x / z))));
} else {
tmp = y * (x + (3.0 * (z / (y / z))));
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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 <= (-9.6d-136)) then
tmp = x * (y + (3.0d0 * (z / (x / z))))
else
tmp = y * (x + (3.0d0 * (z / (y / z))))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (x <= -9.6e-136) {
tmp = x * (y + (3.0 * (z / (x / z))));
} else {
tmp = y * (x + (3.0 * (z / (y / z))));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if x <= -9.6e-136: tmp = x * (y + (3.0 * (z / (x / z)))) else: tmp = y * (x + (3.0 * (z / (y / z)))) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (x <= -9.6e-136) tmp = Float64(x * Float64(y + Float64(3.0 * Float64(z / Float64(x / z))))); else tmp = Float64(y * Float64(x + Float64(3.0 * Float64(z / Float64(y / z))))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (x <= -9.6e-136)
tmp = x * (y + (3.0 * (z / (x / z))));
else
tmp = y * (x + (3.0 * (z / (y / z))));
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[x, -9.6e-136], N[(x * N[(y + N[(3.0 * N[(z / N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(x + N[(3.0 * N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.6 \cdot 10^{-136}:\\
\;\;\;\;x \cdot \left(y + 3 \cdot \frac{z}{\frac{x}{z}}\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x + 3 \cdot \frac{z}{\frac{y}{z}}\right)\\
\end{array}
\end{array}
if x < -9.5999999999999994e-136Initial program 94.3%
Taylor expanded in x around inf 96.7%
Simplified96.7%
unpow296.7%
associate-/l*97.8%
Applied egg-rr97.8%
clear-num97.7%
un-div-inv97.8%
Applied egg-rr97.8%
if -9.5999999999999994e-136 < x Initial program 96.8%
Taylor expanded in y around inf 91.8%
Simplified91.8%
unpow291.8%
associate-/l*92.4%
Applied egg-rr92.4%
clear-num92.4%
un-div-inv92.5%
Applied egg-rr92.5%
Final simplification94.3%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= x -2.5e-95) (* x (+ y (* 3.0 (/ z (/ x z))))) (* y (+ x (/ (* z 3.0) (/ y z))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (x <= -2.5e-95) {
tmp = x * (y + (3.0 * (z / (x / z))));
} else {
tmp = y * (x + ((z * 3.0) / (y / z)));
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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.5d-95)) then
tmp = x * (y + (3.0d0 * (z / (x / z))))
else
tmp = y * (x + ((z * 3.0d0) / (y / z)))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2.5e-95) {
tmp = x * (y + (3.0 * (z / (x / z))));
} else {
tmp = y * (x + ((z * 3.0) / (y / z)));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if x <= -2.5e-95: tmp = x * (y + (3.0 * (z / (x / z)))) else: tmp = y * (x + ((z * 3.0) / (y / z))) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (x <= -2.5e-95) tmp = Float64(x * Float64(y + Float64(3.0 * Float64(z / Float64(x / z))))); else tmp = Float64(y * Float64(x + Float64(Float64(z * 3.0) / Float64(y / z)))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (x <= -2.5e-95)
tmp = x * (y + (3.0 * (z / (x / z))));
else
tmp = y * (x + ((z * 3.0) / (y / z)));
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[x, -2.5e-95], N[(x * N[(y + N[(3.0 * N[(z / N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(x + N[(N[(z * 3.0), $MachinePrecision] / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.5 \cdot 10^{-95}:\\
\;\;\;\;x \cdot \left(y + 3 \cdot \frac{z}{\frac{x}{z}}\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x + \frac{z \cdot 3}{\frac{y}{z}}\right)\\
\end{array}
\end{array}
if x < -2.4999999999999999e-95Initial program 93.8%
Taylor expanded in x around inf 98.6%
Simplified98.6%
unpow298.6%
associate-/l*99.8%
Applied egg-rr99.8%
clear-num99.8%
un-div-inv99.8%
Applied egg-rr99.8%
if -2.4999999999999999e-95 < x Initial program 97.0%
Taylor expanded in y around inf 91.7%
Simplified91.7%
unpow291.7%
associate-/l*92.3%
Applied egg-rr92.3%
clear-num92.3%
un-div-inv92.3%
Applied egg-rr92.3%
associate-*l/92.3%
Applied egg-rr92.3%
Final simplification94.7%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* x (+ y (* 3.0 (* z (/ z x))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
return x * (y + (3.0 * (z * (z / x))));
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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 + (3.0d0 * (z * (z / x))))
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return x * (y + (3.0 * (z * (z / x))));
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return x * (y + (3.0 * (z * (z / x))))
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(x * Float64(y + Float64(3.0 * Float64(z * Float64(z / x))))) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = x * (y + (3.0 * (z * (z / x))));
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(x * N[(y + N[(3.0 * N[(z * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
x \cdot \left(y + 3 \cdot \left(z \cdot \frac{z}{x}\right)\right)
\end{array}
Initial program 95.9%
Taylor expanded in x around inf 90.7%
Simplified90.7%
unpow290.7%
associate-/l*91.5%
Applied egg-rr91.5%
Final simplification91.5%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* x (+ y (/ (* z 3.0) (/ x z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
return x * (y + ((z * 3.0) / (x / z)));
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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 + ((z * 3.0d0) / (x / z)))
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return x * (y + ((z * 3.0) / (x / z)));
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return x * (y + ((z * 3.0) / (x / z)))
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(x * Float64(y + Float64(Float64(z * 3.0) / Float64(x / z)))) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = x * (y + ((z * 3.0) / (x / z)));
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(x * N[(y + N[(N[(z * 3.0), $MachinePrecision] / N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
x \cdot \left(y + \frac{z \cdot 3}{\frac{x}{z}}\right)
\end{array}
Initial program 95.9%
Taylor expanded in x around inf 90.7%
Simplified90.7%
unpow290.7%
associate-/l*91.5%
Applied egg-rr91.5%
clear-num91.4%
un-div-inv91.5%
Applied egg-rr91.5%
associate-*l/91.5%
Applied egg-rr91.5%
Final simplification91.5%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (+ (* z z) (* x y)))
assert(x < y && y < z);
double code(double x, double y, double z) {
return (z * z) + (x * y);
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (z * z) + (x * y)
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return (z * z) + (x * y);
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return (z * z) + (x * y)
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(Float64(z * z) + Float64(x * y)) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = (z * z) + (x * y);
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(z * z), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
z \cdot z + x \cdot y
\end{array}
Initial program 95.9%
Taylor expanded in x around inf 75.2%
Taylor expanded in x around inf 74.6%
Final simplification74.6%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* x y))
assert(x < y && y < z);
double code(double x, double y, double z) {
return x * y;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return x * y;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return x * y
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(x * y) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = x * y;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(x * y), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
x \cdot y
\end{array}
Initial program 95.9%
Taylor expanded in y around inf 91.4%
Simplified91.4%
Taylor expanded in x around inf 49.4%
Final simplification49.4%
(FPCore (x y z) :precision binary64 (+ (* (* 3.0 z) z) (* y x)))
double code(double x, double y, double z) {
return ((3.0 * z) * z) + (y * x);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((3.0d0 * z) * z) + (y * x)
end function
public static double code(double x, double y, double z) {
return ((3.0 * z) * z) + (y * x);
}
def code(x, y, z): return ((3.0 * z) * z) + (y * x)
function code(x, y, z) return Float64(Float64(Float64(3.0 * z) * z) + Float64(y * x)) end
function tmp = code(x, y, z) tmp = ((3.0 * z) * z) + (y * x); end
code[x_, y_, z_] := N[(N[(N[(3.0 * z), $MachinePrecision] * z), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(3 \cdot z\right) \cdot z + y \cdot x
\end{array}
herbie shell --seed 2024071
(FPCore (x y z)
:name "Linear.Quaternion:$c/ from linear-1.19.1.3, A"
:precision binary64
:alt
(+ (* (* 3.0 z) z) (* y x))
(+ (+ (+ (* x y) (* z z)) (* z z)) (* z z)))