
(FPCore (x y z t) :precision binary64 (* (- (* x y) (* z y)) t))
double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * t;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x * y) - (z * y)) * t
end function
public static double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * t;
}
def code(x, y, z, t): return ((x * y) - (z * y)) * t
function code(x, y, z, t) return Float64(Float64(Float64(x * y) - Float64(z * y)) * t) end
function tmp = code(x, y, z, t) tmp = ((x * y) - (z * y)) * t; end
code[x_, y_, z_, t_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y - z \cdot y\right) \cdot t
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (* (- (* x y) (* z y)) t))
double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * t;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x * y) - (z * y)) * t
end function
public static double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * t;
}
def code(x, y, z, t): return ((x * y) - (z * y)) * t
function code(x, y, z, t) return Float64(Float64(Float64(x * y) - Float64(z * y)) * t) end
function tmp = code(x, y, z, t) tmp = ((x * y) - (z * y)) * t; end
code[x_, y_, z_, t_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y - z \cdot y\right) \cdot t
\end{array}
NOTE: y and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= y -3.7e-188) (pow (cbrt (* y (* t (- x z)))) 3.0) (* t (* y (- x z)))))
assert(y < t);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.7e-188) {
tmp = pow(cbrt((y * (t * (x - z)))), 3.0);
} else {
tmp = t * (y * (x - z));
}
return tmp;
}
assert y < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.7e-188) {
tmp = Math.pow(Math.cbrt((y * (t * (x - z)))), 3.0);
} else {
tmp = t * (y * (x - z));
}
return tmp;
}
y, t = sort([y, t]) function code(x, y, z, t) tmp = 0.0 if (y <= -3.7e-188) tmp = cbrt(Float64(y * Float64(t * Float64(x - z)))) ^ 3.0; else tmp = Float64(t * Float64(y * Float64(x - z))); end return tmp end
NOTE: y and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[y, -3.7e-188], N[Power[N[Power[N[(y * N[(t * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision], N[(t * N[(y * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.7 \cdot 10^{-188}:\\
\;\;\;\;{\left(\sqrt[3]{y \cdot \left(t \cdot \left(x - z\right)\right)}\right)}^{3}\\
\mathbf{else}:\\
\;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\
\end{array}
\end{array}
if y < -3.69999999999999972e-188Initial program 89.8%
*-commutative89.8%
distribute-rgt-out--92.6%
associate-*r*95.4%
*-commutative95.4%
Simplified95.4%
add-cube-cbrt94.3%
pow394.3%
associate-*l*97.7%
Applied egg-rr97.7%
if -3.69999999999999972e-188 < y Initial program 93.9%
distribute-rgt-out--95.9%
Simplified95.9%
Final simplification96.6%
NOTE: y and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= (- (* y x) (* y z)) (- INFINITY)) (* (- x z) (* y t)) (* t (* y (- x z)))))
assert(y < t);
double code(double x, double y, double z, double t) {
double tmp;
if (((y * x) - (y * z)) <= -((double) INFINITY)) {
tmp = (x - z) * (y * t);
} else {
tmp = t * (y * (x - z));
}
return tmp;
}
assert y < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (((y * x) - (y * z)) <= -Double.POSITIVE_INFINITY) {
tmp = (x - z) * (y * t);
} else {
tmp = t * (y * (x - z));
}
return tmp;
}
[y, t] = sort([y, t]) def code(x, y, z, t): tmp = 0 if ((y * x) - (y * z)) <= -math.inf: tmp = (x - z) * (y * t) else: tmp = t * (y * (x - z)) return tmp
y, t = sort([y, t]) function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(y * x) - Float64(y * z)) <= Float64(-Inf)) tmp = Float64(Float64(x - z) * Float64(y * t)); else tmp = Float64(t * Float64(y * Float64(x - z))); end return tmp end
y, t = num2cell(sort([y, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (((y * x) - (y * z)) <= -Inf)
tmp = (x - z) * (y * t);
else
tmp = t * (y * (x - z));
end
tmp_2 = tmp;
end
NOTE: y and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[N[(N[(y * x), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(N[(x - z), $MachinePrecision] * N[(y * t), $MachinePrecision]), $MachinePrecision], N[(t * N[(y * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot x - y \cdot z \leq -\infty:\\
\;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z y)) < -inf.0Initial program 73.4%
*-commutative73.4%
distribute-rgt-out--73.4%
associate-*r*99.9%
*-commutative99.9%
Simplified99.9%
if -inf.0 < (-.f64 (*.f64 x y) (*.f64 z y)) Initial program 93.9%
distribute-rgt-out--96.5%
Simplified96.5%
Final simplification96.7%
NOTE: y and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (or (<= z -0.038) (not (<= z 1.06e-10))) (- (* z (* y t))) (* t (* y x))))
assert(y < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -0.038) || !(z <= 1.06e-10)) {
tmp = -(z * (y * t));
} else {
tmp = t * (y * x);
}
return tmp;
}
NOTE: y and t should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((z <= (-0.038d0)) .or. (.not. (z <= 1.06d-10))) then
tmp = -(z * (y * t))
else
tmp = t * (y * x)
end if
code = tmp
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -0.038) || !(z <= 1.06e-10)) {
tmp = -(z * (y * t));
} else {
tmp = t * (y * x);
}
return tmp;
}
[y, t] = sort([y, t]) def code(x, y, z, t): tmp = 0 if (z <= -0.038) or not (z <= 1.06e-10): tmp = -(z * (y * t)) else: tmp = t * (y * x) return tmp
y, t = sort([y, t]) function code(x, y, z, t) tmp = 0.0 if ((z <= -0.038) || !(z <= 1.06e-10)) tmp = Float64(-Float64(z * Float64(y * t))); else tmp = Float64(t * Float64(y * x)); end return tmp end
y, t = num2cell(sort([y, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((z <= -0.038) || ~((z <= 1.06e-10)))
tmp = -(z * (y * t));
else
tmp = t * (y * x);
end
tmp_2 = tmp;
end
NOTE: y and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[Or[LessEqual[z, -0.038], N[Not[LessEqual[z, 1.06e-10]], $MachinePrecision]], (-N[(z * N[(y * t), $MachinePrecision]), $MachinePrecision]), N[(t * N[(y * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.038 \lor \neg \left(z \leq 1.06 \cdot 10^{-10}\right):\\
\;\;\;\;-z \cdot \left(y \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot \left(y \cdot x\right)\\
\end{array}
\end{array}
if z < -0.0379999999999999991 or 1.06e-10 < z Initial program 90.2%
*-commutative90.2%
distribute-rgt-out--94.4%
associate-*r*88.1%
*-commutative88.1%
Simplified88.1%
Taylor expanded in x around 0 78.4%
mul-1-neg78.4%
associate-*r*73.5%
distribute-rgt-neg-out73.5%
*-commutative73.5%
distribute-lft-neg-out73.5%
Simplified73.5%
if -0.0379999999999999991 < z < 1.06e-10Initial program 94.7%
distribute-rgt-out--94.7%
Simplified94.7%
Taylor expanded in x around inf 82.4%
Final simplification77.4%
NOTE: y and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (or (<= z -0.00098) (not (<= z 3.5e-12))) (* y (* t (- z))) (* t (* y x))))
assert(y < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -0.00098) || !(z <= 3.5e-12)) {
tmp = y * (t * -z);
} else {
tmp = t * (y * x);
}
return tmp;
}
NOTE: y and t should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((z <= (-0.00098d0)) .or. (.not. (z <= 3.5d-12))) then
tmp = y * (t * -z)
else
tmp = t * (y * x)
end if
code = tmp
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -0.00098) || !(z <= 3.5e-12)) {
tmp = y * (t * -z);
} else {
tmp = t * (y * x);
}
return tmp;
}
[y, t] = sort([y, t]) def code(x, y, z, t): tmp = 0 if (z <= -0.00098) or not (z <= 3.5e-12): tmp = y * (t * -z) else: tmp = t * (y * x) return tmp
y, t = sort([y, t]) function code(x, y, z, t) tmp = 0.0 if ((z <= -0.00098) || !(z <= 3.5e-12)) tmp = Float64(y * Float64(t * Float64(-z))); else tmp = Float64(t * Float64(y * x)); end return tmp end
y, t = num2cell(sort([y, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((z <= -0.00098) || ~((z <= 3.5e-12)))
tmp = y * (t * -z);
else
tmp = t * (y * x);
end
tmp_2 = tmp;
end
NOTE: y and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[Or[LessEqual[z, -0.00098], N[Not[LessEqual[z, 3.5e-12]], $MachinePrecision]], N[(y * N[(t * (-z)), $MachinePrecision]), $MachinePrecision], N[(t * N[(y * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.00098 \lor \neg \left(z \leq 3.5 \cdot 10^{-12}\right):\\
\;\;\;\;y \cdot \left(t \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot \left(y \cdot x\right)\\
\end{array}
\end{array}
if z < -9.7999999999999997e-4 or 3.5e-12 < z Initial program 90.2%
*-commutative90.2%
distribute-rgt-out--94.4%
associate-*r*88.1%
*-commutative88.1%
Simplified88.1%
Taylor expanded in x around 0 78.4%
mul-1-neg78.4%
distribute-rgt-neg-in78.4%
distribute-rgt-neg-out78.4%
Simplified78.4%
if -9.7999999999999997e-4 < z < 3.5e-12Initial program 94.7%
distribute-rgt-out--94.7%
Simplified94.7%
Taylor expanded in x around inf 82.4%
Final simplification80.2%
NOTE: y and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= z -0.037) (* y (* t (- z))) (if (<= z 2.1e-22) (* t (* y x)) (* t (* z (- y))))))
assert(y < t);
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.037) {
tmp = y * (t * -z);
} else if (z <= 2.1e-22) {
tmp = t * (y * x);
} else {
tmp = t * (z * -y);
}
return tmp;
}
NOTE: y and t should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-0.037d0)) then
tmp = y * (t * -z)
else if (z <= 2.1d-22) then
tmp = t * (y * x)
else
tmp = t * (z * -y)
end if
code = tmp
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.037) {
tmp = y * (t * -z);
} else if (z <= 2.1e-22) {
tmp = t * (y * x);
} else {
tmp = t * (z * -y);
}
return tmp;
}
[y, t] = sort([y, t]) def code(x, y, z, t): tmp = 0 if z <= -0.037: tmp = y * (t * -z) elif z <= 2.1e-22: tmp = t * (y * x) else: tmp = t * (z * -y) return tmp
y, t = sort([y, t]) function code(x, y, z, t) tmp = 0.0 if (z <= -0.037) tmp = Float64(y * Float64(t * Float64(-z))); elseif (z <= 2.1e-22) tmp = Float64(t * Float64(y * x)); else tmp = Float64(t * Float64(z * Float64(-y))); end return tmp end
y, t = num2cell(sort([y, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (z <= -0.037)
tmp = y * (t * -z);
elseif (z <= 2.1e-22)
tmp = t * (y * x);
else
tmp = t * (z * -y);
end
tmp_2 = tmp;
end
NOTE: y and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[z, -0.037], N[(y * N[(t * (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.1e-22], N[(t * N[(y * x), $MachinePrecision]), $MachinePrecision], N[(t * N[(z * (-y)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.037:\\
\;\;\;\;y \cdot \left(t \cdot \left(-z\right)\right)\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{-22}:\\
\;\;\;\;t \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot \left(z \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if z < -0.0369999999999999982Initial program 90.0%
*-commutative90.0%
distribute-rgt-out--93.8%
associate-*r*89.1%
*-commutative89.1%
Simplified89.1%
Taylor expanded in x around 0 80.5%
mul-1-neg80.5%
distribute-rgt-neg-in80.5%
distribute-rgt-neg-out80.5%
Simplified80.5%
if -0.0369999999999999982 < z < 2.10000000000000008e-22Initial program 94.6%
distribute-rgt-out--94.6%
Simplified94.6%
Taylor expanded in x around inf 82.9%
if 2.10000000000000008e-22 < z Initial program 90.8%
distribute-rgt-out--95.4%
Simplified95.4%
Taylor expanded in x around 0 75.0%
mul-1-neg75.0%
distribute-rgt-neg-out75.0%
Simplified75.0%
Final simplification80.2%
NOTE: y and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= z -2.7e+142) (* y (* t (- z))) (* (- x z) (* y t))))
assert(y < t);
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.7e+142) {
tmp = y * (t * -z);
} else {
tmp = (x - z) * (y * t);
}
return tmp;
}
NOTE: y and t should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-2.7d+142)) then
tmp = y * (t * -z)
else
tmp = (x - z) * (y * t)
end if
code = tmp
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.7e+142) {
tmp = y * (t * -z);
} else {
tmp = (x - z) * (y * t);
}
return tmp;
}
[y, t] = sort([y, t]) def code(x, y, z, t): tmp = 0 if z <= -2.7e+142: tmp = y * (t * -z) else: tmp = (x - z) * (y * t) return tmp
y, t = sort([y, t]) function code(x, y, z, t) tmp = 0.0 if (z <= -2.7e+142) tmp = Float64(y * Float64(t * Float64(-z))); else tmp = Float64(Float64(x - z) * Float64(y * t)); end return tmp end
y, t = num2cell(sort([y, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (z <= -2.7e+142)
tmp = y * (t * -z);
else
tmp = (x - z) * (y * t);
end
tmp_2 = tmp;
end
NOTE: y and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[z, -2.7e+142], N[(y * N[(t * (-z)), $MachinePrecision]), $MachinePrecision], N[(N[(x - z), $MachinePrecision] * N[(y * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.7 \cdot 10^{+142}:\\
\;\;\;\;y \cdot \left(t \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\
\end{array}
\end{array}
if z < -2.69999999999999983e142Initial program 86.1%
*-commutative86.1%
distribute-rgt-out--90.9%
associate-*r*79.8%
*-commutative79.8%
Simplified79.8%
Taylor expanded in x around 0 83.5%
mul-1-neg83.5%
distribute-rgt-neg-in83.5%
distribute-rgt-neg-out83.5%
Simplified83.5%
if -2.69999999999999983e142 < z Initial program 93.4%
*-commutative93.4%
distribute-rgt-out--95.3%
associate-*r*92.5%
*-commutative92.5%
Simplified92.5%
Final simplification91.0%
NOTE: y and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= t 2.05e-52) (* y (* t x)) (* x (* y t))))
assert(y < t);
double code(double x, double y, double z, double t) {
double tmp;
if (t <= 2.05e-52) {
tmp = y * (t * x);
} else {
tmp = x * (y * t);
}
return tmp;
}
NOTE: y and t should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (t <= 2.05d-52) then
tmp = y * (t * x)
else
tmp = x * (y * t)
end if
code = tmp
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= 2.05e-52) {
tmp = y * (t * x);
} else {
tmp = x * (y * t);
}
return tmp;
}
[y, t] = sort([y, t]) def code(x, y, z, t): tmp = 0 if t <= 2.05e-52: tmp = y * (t * x) else: tmp = x * (y * t) return tmp
y, t = sort([y, t]) function code(x, y, z, t) tmp = 0.0 if (t <= 2.05e-52) tmp = Float64(y * Float64(t * x)); else tmp = Float64(x * Float64(y * t)); end return tmp end
y, t = num2cell(sort([y, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (t <= 2.05e-52)
tmp = y * (t * x);
else
tmp = x * (y * t);
end
tmp_2 = tmp;
end
NOTE: y and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[t, 2.05e-52], N[(y * N[(t * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(y * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq 2.05 \cdot 10^{-52}:\\
\;\;\;\;y \cdot \left(t \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y \cdot t\right)\\
\end{array}
\end{array}
if t < 2.04999999999999994e-52Initial program 91.5%
*-commutative91.5%
distribute-rgt-out--93.1%
associate-*r*87.3%
*-commutative87.3%
Simplified87.3%
Taylor expanded in x around inf 56.5%
if 2.04999999999999994e-52 < t Initial program 94.1%
*-commutative94.1%
distribute-rgt-out--98.4%
associate-*r*98.5%
*-commutative98.5%
Simplified98.5%
Taylor expanded in x around inf 35.8%
associate-*r*46.5%
*-commutative46.5%
Simplified46.5%
Final simplification53.8%
NOTE: y and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (* x (* y t)))
assert(y < t);
double code(double x, double y, double z, double t) {
return x * (y * t);
}
NOTE: y and t should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x * (y * t)
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
return x * (y * t);
}
[y, t] = sort([y, t]) def code(x, y, z, t): return x * (y * t)
y, t = sort([y, t]) function code(x, y, z, t) return Float64(x * Float64(y * t)) end
y, t = num2cell(sort([y, t])){:}
function tmp = code(x, y, z, t)
tmp = x * (y * t);
end
NOTE: y and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[(x * N[(y * t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
x \cdot \left(y \cdot t\right)
\end{array}
Initial program 92.2%
*-commutative92.2%
distribute-rgt-out--94.6%
associate-*r*90.4%
*-commutative90.4%
Simplified90.4%
Taylor expanded in x around inf 50.9%
associate-*r*52.4%
*-commutative52.4%
Simplified52.4%
Final simplification52.4%
(FPCore (x y z t) :precision binary64 (if (< t -9.231879582886777e-80) (* (* y t) (- x z)) (if (< t 2.543067051564877e+83) (* y (* t (- x z))) (* (* y (- x z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (t < -9.231879582886777e-80) {
tmp = (y * t) * (x - z);
} else if (t < 2.543067051564877e+83) {
tmp = y * (t * (x - z));
} else {
tmp = (y * (x - z)) * t;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (t < (-9.231879582886777d-80)) then
tmp = (y * t) * (x - z)
else if (t < 2.543067051564877d+83) then
tmp = y * (t * (x - z))
else
tmp = (y * (x - z)) * t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t < -9.231879582886777e-80) {
tmp = (y * t) * (x - z);
} else if (t < 2.543067051564877e+83) {
tmp = y * (t * (x - z));
} else {
tmp = (y * (x - z)) * t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t < -9.231879582886777e-80: tmp = (y * t) * (x - z) elif t < 2.543067051564877e+83: tmp = y * (t * (x - z)) else: tmp = (y * (x - z)) * t return tmp
function code(x, y, z, t) tmp = 0.0 if (t < -9.231879582886777e-80) tmp = Float64(Float64(y * t) * Float64(x - z)); elseif (t < 2.543067051564877e+83) tmp = Float64(y * Float64(t * Float64(x - z))); else tmp = Float64(Float64(y * Float64(x - z)) * t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t < -9.231879582886777e-80) tmp = (y * t) * (x - z); elseif (t < 2.543067051564877e+83) tmp = y * (t * (x - z)); else tmp = (y * (x - z)) * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Less[t, -9.231879582886777e-80], N[(N[(y * t), $MachinePrecision] * N[(x - z), $MachinePrecision]), $MachinePrecision], If[Less[t, 2.543067051564877e+83], N[(y * N[(t * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * N[(x - z), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t < -9.231879582886777 \cdot 10^{-80}:\\
\;\;\;\;\left(y \cdot t\right) \cdot \left(x - z\right)\\
\mathbf{elif}\;t < 2.543067051564877 \cdot 10^{+83}:\\
\;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot \left(x - z\right)\right) \cdot t\\
\end{array}
\end{array}
herbie shell --seed 2023279
(FPCore (x y z t)
:name "Linear.Projection:inverseInfinitePerspective from linear-1.19.1.3"
:precision binary64
:herbie-target
(if (< t -9.231879582886777e-80) (* (* y t) (- x z)) (if (< t 2.543067051564877e+83) (* y (* t (- x z))) (* (* y (- x z)) t)))
(* (- (* x y) (* z y)) t))