
(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 (<= t 1.08e-17) (* y (- (* t x) (* t z))) (* (- x z) (* t y))))
assert(y < t);
double code(double x, double y, double z, double t) {
double tmp;
if (t <= 1.08e-17) {
tmp = y * ((t * x) - (t * z));
} else {
tmp = (x - z) * (t * 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 (t <= 1.08d-17) then
tmp = y * ((t * x) - (t * z))
else
tmp = (x - z) * (t * 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 (t <= 1.08e-17) {
tmp = y * ((t * x) - (t * z));
} else {
tmp = (x - z) * (t * y);
}
return tmp;
}
[y, t] = sort([y, t]) def code(x, y, z, t): tmp = 0 if t <= 1.08e-17: tmp = y * ((t * x) - (t * z)) else: tmp = (x - z) * (t * y) return tmp
y, t = sort([y, t]) function code(x, y, z, t) tmp = 0.0 if (t <= 1.08e-17) tmp = Float64(y * Float64(Float64(t * x) - Float64(t * z))); else tmp = Float64(Float64(x - z) * Float64(t * y)); end return tmp end
y, t = num2cell(sort([y, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (t <= 1.08e-17)
tmp = y * ((t * x) - (t * z));
else
tmp = (x - z) * (t * 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[t, 1.08e-17], N[(y * N[(N[(t * x), $MachinePrecision] - N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - z), $MachinePrecision] * N[(t * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq 1.08 \cdot 10^{-17}:\\
\;\;\;\;y \cdot \left(t \cdot x - t \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x - z\right) \cdot \left(t \cdot y\right)\\
\end{array}
\end{array}
if t < 1.07999999999999995e-17Initial program 86.1%
distribute-rgt-out--87.3%
associate-*l*92.9%
Simplified92.9%
*-commutative92.9%
sub-neg92.9%
distribute-rgt-in91.7%
Applied egg-rr91.7%
if 1.07999999999999995e-17 < t Initial program 92.1%
distribute-rgt-out--98.0%
Simplified98.0%
*-commutative98.0%
flip--73.7%
associate-*l/70.3%
Applied egg-rr70.3%
Taylor expanded in x around inf 46.1%
unpow246.1%
Simplified46.1%
Taylor expanded in x around inf 79.6%
+-commutative79.6%
associate-*r*82.2%
mul-1-neg82.2%
associate-*r*82.1%
distribute-rgt-neg-in82.1%
distribute-lft-in98.4%
sub-neg98.4%
*-commutative98.4%
Simplified98.4%
Final simplification93.5%
NOTE: y and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* t (* y x))))
(if (<= x -4.3e+83)
t_1
(if (<= x 5.2e-289)
(* y (* t (- z)))
(if (<= x 3200000000000.0) (* t (* y (- z))) t_1)))))assert(y < t);
double code(double x, double y, double z, double t) {
double t_1 = t * (y * x);
double tmp;
if (x <= -4.3e+83) {
tmp = t_1;
} else if (x <= 5.2e-289) {
tmp = y * (t * -z);
} else if (x <= 3200000000000.0) {
tmp = t * (y * -z);
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_1 = t * (y * x)
if (x <= (-4.3d+83)) then
tmp = t_1
else if (x <= 5.2d-289) then
tmp = y * (t * -z)
else if (x <= 3200000000000.0d0) then
tmp = t * (y * -z)
else
tmp = t_1
end if
code = tmp
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
double t_1 = t * (y * x);
double tmp;
if (x <= -4.3e+83) {
tmp = t_1;
} else if (x <= 5.2e-289) {
tmp = y * (t * -z);
} else if (x <= 3200000000000.0) {
tmp = t * (y * -z);
} else {
tmp = t_1;
}
return tmp;
}
[y, t] = sort([y, t]) def code(x, y, z, t): t_1 = t * (y * x) tmp = 0 if x <= -4.3e+83: tmp = t_1 elif x <= 5.2e-289: tmp = y * (t * -z) elif x <= 3200000000000.0: tmp = t * (y * -z) else: tmp = t_1 return tmp
y, t = sort([y, t]) function code(x, y, z, t) t_1 = Float64(t * Float64(y * x)) tmp = 0.0 if (x <= -4.3e+83) tmp = t_1; elseif (x <= 5.2e-289) tmp = Float64(y * Float64(t * Float64(-z))); elseif (x <= 3200000000000.0) tmp = Float64(t * Float64(y * Float64(-z))); else tmp = t_1; end return tmp end
y, t = num2cell(sort([y, t])){:}
function tmp_2 = code(x, y, z, t)
t_1 = t * (y * x);
tmp = 0.0;
if (x <= -4.3e+83)
tmp = t_1;
elseif (x <= 5.2e-289)
tmp = y * (t * -z);
elseif (x <= 3200000000000.0)
tmp = t * (y * -z);
else
tmp = t_1;
end
tmp_2 = tmp;
end
NOTE: y and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t * N[(y * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.3e+83], t$95$1, If[LessEqual[x, 5.2e-289], N[(y * N[(t * (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3200000000000.0], N[(t * N[(y * (-z)), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
t_1 := t \cdot \left(y \cdot x\right)\\
\mathbf{if}\;x \leq -4.3 \cdot 10^{+83}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-289}:\\
\;\;\;\;y \cdot \left(t \cdot \left(-z\right)\right)\\
\mathbf{elif}\;x \leq 3200000000000:\\
\;\;\;\;t \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -4.3e83 or 3.2e12 < x Initial program 82.5%
distribute-rgt-out--87.7%
Simplified87.7%
Taylor expanded in x around inf 75.1%
if -4.3e83 < x < 5.1999999999999998e-289Initial program 94.3%
distribute-rgt-out--94.3%
associate-*l*92.3%
Simplified92.3%
Taylor expanded in x around 0 80.2%
mul-1-neg80.2%
*-commutative80.2%
distribute-rgt-neg-in80.2%
Simplified80.2%
if 5.1999999999999998e-289 < x < 3.2e12Initial program 90.2%
distribute-rgt-out--90.2%
Simplified90.2%
Taylor expanded in x around 0 69.2%
mul-1-neg69.2%
distribute-rgt-neg-out69.2%
Simplified69.2%
Final simplification75.2%
NOTE: y and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (or (<= x -1.6e+82) (not (<= x 2500000000000.0))) (* t (* y x)) (* y (* t (- z)))))
assert(y < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.6e+82) || !(x <= 2500000000000.0)) {
tmp = t * (y * x);
} else {
tmp = y * (t * -z);
}
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 ((x <= (-1.6d+82)) .or. (.not. (x <= 2500000000000.0d0))) then
tmp = t * (y * x)
else
tmp = y * (t * -z)
end if
code = tmp
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.6e+82) || !(x <= 2500000000000.0)) {
tmp = t * (y * x);
} else {
tmp = y * (t * -z);
}
return tmp;
}
[y, t] = sort([y, t]) def code(x, y, z, t): tmp = 0 if (x <= -1.6e+82) or not (x <= 2500000000000.0): tmp = t * (y * x) else: tmp = y * (t * -z) return tmp
y, t = sort([y, t]) function code(x, y, z, t) tmp = 0.0 if ((x <= -1.6e+82) || !(x <= 2500000000000.0)) tmp = Float64(t * Float64(y * x)); else tmp = Float64(y * Float64(t * Float64(-z))); end return tmp end
y, t = num2cell(sort([y, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((x <= -1.6e+82) || ~((x <= 2500000000000.0)))
tmp = t * (y * x);
else
tmp = y * (t * -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[Or[LessEqual[x, -1.6e+82], N[Not[LessEqual[x, 2500000000000.0]], $MachinePrecision]], N[(t * N[(y * x), $MachinePrecision]), $MachinePrecision], N[(y * N[(t * (-z)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{+82} \lor \neg \left(x \leq 2500000000000\right):\\
\;\;\;\;t \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(t \cdot \left(-z\right)\right)\\
\end{array}
\end{array}
if x < -1.59999999999999987e82 or 2.5e12 < x Initial program 82.5%
distribute-rgt-out--87.7%
Simplified87.7%
Taylor expanded in x around inf 75.1%
if -1.59999999999999987e82 < x < 2.5e12Initial program 92.5%
distribute-rgt-out--92.5%
associate-*l*94.2%
Simplified94.2%
Taylor expanded in x around 0 78.2%
mul-1-neg78.2%
*-commutative78.2%
distribute-rgt-neg-in78.2%
Simplified78.2%
Final simplification76.7%
NOTE: y and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= y -4.4e-65) (* y (* t (- x z))) (* t (* y (- x z)))))
assert(y < t);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.4e-65) {
tmp = y * (t * (x - z));
} else {
tmp = t * (y * (x - z));
}
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 (y <= (-4.4d-65)) then
tmp = y * (t * (x - z))
else
tmp = t * (y * (x - z))
end if
code = tmp
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.4e-65) {
tmp = y * (t * (x - z));
} else {
tmp = t * (y * (x - z));
}
return tmp;
}
[y, t] = sort([y, t]) def code(x, y, z, t): tmp = 0 if y <= -4.4e-65: tmp = y * (t * (x - z)) else: tmp = t * (y * (x - z)) return tmp
y, t = sort([y, t]) function code(x, y, z, t) tmp = 0.0 if (y <= -4.4e-65) tmp = Float64(y * Float64(t * Float64(x - z))); 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 <= -4.4e-65)
tmp = y * (t * (x - z));
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[y, -4.4e-65], N[(y * N[(t * N[(x - z), $MachinePrecision]), $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 \leq -4.4 \cdot 10^{-65}:\\
\;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\
\end{array}
\end{array}
if y < -4.40000000000000042e-65Initial program 86.4%
distribute-rgt-out--91.1%
associate-*l*98.3%
Simplified98.3%
if -4.40000000000000042e-65 < y Initial program 88.1%
distribute-rgt-out--89.8%
Simplified89.8%
Final simplification92.0%
NOTE: y and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= t 1.18e-17) (* y (* t (- x z))) (* (- x z) (* t y))))
assert(y < t);
double code(double x, double y, double z, double t) {
double tmp;
if (t <= 1.18e-17) {
tmp = y * (t * (x - z));
} else {
tmp = (x - z) * (t * 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 (t <= 1.18d-17) then
tmp = y * (t * (x - z))
else
tmp = (x - z) * (t * 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 (t <= 1.18e-17) {
tmp = y * (t * (x - z));
} else {
tmp = (x - z) * (t * y);
}
return tmp;
}
[y, t] = sort([y, t]) def code(x, y, z, t): tmp = 0 if t <= 1.18e-17: tmp = y * (t * (x - z)) else: tmp = (x - z) * (t * y) return tmp
y, t = sort([y, t]) function code(x, y, z, t) tmp = 0.0 if (t <= 1.18e-17) tmp = Float64(y * Float64(t * Float64(x - z))); else tmp = Float64(Float64(x - z) * Float64(t * y)); end return tmp end
y, t = num2cell(sort([y, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (t <= 1.18e-17)
tmp = y * (t * (x - z));
else
tmp = (x - z) * (t * 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[t, 1.18e-17], N[(y * N[(t * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - z), $MachinePrecision] * N[(t * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq 1.18 \cdot 10^{-17}:\\
\;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x - z\right) \cdot \left(t \cdot y\right)\\
\end{array}
\end{array}
if t < 1.18000000000000004e-17Initial program 86.1%
distribute-rgt-out--87.3%
associate-*l*92.9%
Simplified92.9%
if 1.18000000000000004e-17 < t Initial program 92.1%
distribute-rgt-out--98.0%
Simplified98.0%
*-commutative98.0%
flip--73.7%
associate-*l/70.3%
Applied egg-rr70.3%
Taylor expanded in x around inf 46.1%
unpow246.1%
Simplified46.1%
Taylor expanded in x around inf 79.6%
+-commutative79.6%
associate-*r*82.2%
mul-1-neg82.2%
associate-*r*82.1%
distribute-rgt-neg-in82.1%
distribute-lft-in98.4%
sub-neg98.4%
*-commutative98.4%
Simplified98.4%
Final simplification94.3%
NOTE: y and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= t 1e-11) (* y (* t x)) (* x (* t y))))
assert(y < t);
double code(double x, double y, double z, double t) {
double tmp;
if (t <= 1e-11) {
tmp = y * (t * x);
} else {
tmp = x * (t * 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 (t <= 1d-11) then
tmp = y * (t * x)
else
tmp = x * (t * 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 (t <= 1e-11) {
tmp = y * (t * x);
} else {
tmp = x * (t * y);
}
return tmp;
}
[y, t] = sort([y, t]) def code(x, y, z, t): tmp = 0 if t <= 1e-11: tmp = y * (t * x) else: tmp = x * (t * y) return tmp
y, t = sort([y, t]) function code(x, y, z, t) tmp = 0.0 if (t <= 1e-11) tmp = Float64(y * Float64(t * x)); else tmp = Float64(x * Float64(t * y)); end return tmp end
y, t = num2cell(sort([y, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (t <= 1e-11)
tmp = y * (t * x);
else
tmp = x * (t * 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[t, 1e-11], N[(y * N[(t * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(t * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq 10^{-11}:\\
\;\;\;\;y \cdot \left(t \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(t \cdot y\right)\\
\end{array}
\end{array}
if t < 9.99999999999999939e-12Initial program 86.2%
distribute-rgt-out--87.4%
associate-*l*92.9%
Simplified92.9%
Taylor expanded in x around inf 53.5%
if 9.99999999999999939e-12 < t Initial program 91.9%
distribute-rgt-out--98.0%
associate-*l*91.1%
Simplified91.1%
add-cube-cbrt90.2%
pow390.2%
Applied egg-rr90.2%
Taylor expanded in z around 0 54.4%
pow-base-154.4%
*-lft-identity54.4%
associate-*r*64.4%
Simplified64.4%
Final simplification56.3%
NOTE: y and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (* y (* t (- x z))))
assert(y < t);
double code(double x, double y, double z, double t) {
return y * (t * (x - z));
}
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 = y * (t * (x - z))
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
return y * (t * (x - z));
}
[y, t] = sort([y, t]) def code(x, y, z, t): return y * (t * (x - z))
y, t = sort([y, t]) function code(x, y, z, t) return Float64(y * Float64(t * Float64(x - z))) end
y, t = num2cell(sort([y, t])){:}
function tmp = code(x, y, z, t)
tmp = y * (t * (x - z));
end
NOTE: y and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[(y * N[(t * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
y \cdot \left(t \cdot \left(x - z\right)\right)
\end{array}
Initial program 87.7%
distribute-rgt-out--90.2%
associate-*l*92.5%
Simplified92.5%
Final simplification92.5%
NOTE: y and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (* y (* t x)))
assert(y < t);
double code(double x, double y, double z, double t) {
return y * (t * x);
}
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 = y * (t * x)
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
return y * (t * x);
}
[y, t] = sort([y, t]) def code(x, y, z, t): return y * (t * x)
y, t = sort([y, t]) function code(x, y, z, t) return Float64(y * Float64(t * x)) end
y, t = num2cell(sort([y, t])){:}
function tmp = code(x, y, z, t)
tmp = y * (t * x);
end
NOTE: y and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[(y * N[(t * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
y \cdot \left(t \cdot x\right)
\end{array}
Initial program 87.7%
distribute-rgt-out--90.2%
associate-*l*92.5%
Simplified92.5%
Taylor expanded in x around inf 53.7%
Final simplification53.7%
(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 2023182
(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))