
(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.02e-104) (* 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.02e-104) {
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.02d-104) 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.02e-104) {
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.02e-104: 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.02e-104) 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.02e-104)
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.02e-104], 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.02 \cdot 10^{-104}:\\
\;\;\;\;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.02000000000000001e-104Initial program 88.3%
distribute-rgt-out--88.9%
associate-*l*92.5%
*-commutative92.5%
Simplified92.5%
if 1.02000000000000001e-104 < t Initial program 95.3%
distribute-rgt-out--97.6%
associate-*l*93.3%
*-commutative93.3%
Simplified93.3%
associate-*r*97.3%
flip3--49.0%
associate-*r/44.6%
associate-/l*48.9%
*-un-lft-identity48.9%
associate-/l*48.9%
flip3--97.2%
Applied egg-rr97.2%
frac-2neg97.2%
clear-num97.2%
associate-/r/97.3%
distribute-neg-frac97.3%
metadata-eval97.3%
associate-/r/97.3%
metadata-eval97.3%
neg-mul-197.3%
neg-sub097.3%
sub-neg97.3%
+-commutative97.3%
associate--r+97.3%
add-sqr-sqrt55.6%
sqrt-unprod76.1%
sqr-neg76.1%
sqrt-unprod24.2%
add-sqr-sqrt51.8%
neg-sub051.8%
add-sqr-sqrt27.7%
sqrt-unprod63.8%
sqr-neg63.8%
sqrt-unprod41.7%
add-sqr-sqrt97.3%
distribute-rgt-neg-in97.3%
Applied egg-rr97.3%
Final simplification94.2%
NOTE: y and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (or (<= z -2.15e+61) (not (<= z 7.2e-24))) (* y (* z (- t))) (* x (* t y))))
assert(y < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.15e+61) || !(z <= 7.2e-24)) {
tmp = y * (z * -t);
} 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 ((z <= (-2.15d+61)) .or. (.not. (z <= 7.2d-24))) then
tmp = y * (z * -t)
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 ((z <= -2.15e+61) || !(z <= 7.2e-24)) {
tmp = y * (z * -t);
} else {
tmp = x * (t * y);
}
return tmp;
}
[y, t] = sort([y, t]) def code(x, y, z, t): tmp = 0 if (z <= -2.15e+61) or not (z <= 7.2e-24): tmp = y * (z * -t) else: tmp = x * (t * y) return tmp
y, t = sort([y, t]) function code(x, y, z, t) tmp = 0.0 if ((z <= -2.15e+61) || !(z <= 7.2e-24)) tmp = Float64(y * Float64(z * Float64(-t))); 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 ((z <= -2.15e+61) || ~((z <= 7.2e-24)))
tmp = y * (z * -t);
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[Or[LessEqual[z, -2.15e+61], N[Not[LessEqual[z, 7.2e-24]], $MachinePrecision]], N[(y * N[(z * (-t)), $MachinePrecision]), $MachinePrecision], N[(x * N[(t * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.15 \cdot 10^{+61} \lor \neg \left(z \leq 7.2 \cdot 10^{-24}\right):\\
\;\;\;\;y \cdot \left(z \cdot \left(-t\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(t \cdot y\right)\\
\end{array}
\end{array}
if z < -2.1500000000000001e61 or 7.2000000000000002e-24 < z Initial program 88.1%
distribute-rgt-out--89.6%
associate-*l*94.6%
*-commutative94.6%
Simplified94.6%
Taylor expanded in x around 0 79.2%
mul-1-neg79.2%
distribute-rgt-neg-out79.2%
Simplified79.2%
if -2.1500000000000001e61 < z < 7.2000000000000002e-24Initial program 93.5%
distribute-rgt-out--94.3%
associate-*l*90.9%
*-commutative90.9%
Simplified90.9%
associate-*r*95.1%
flip3--47.3%
associate-*r/42.4%
associate-/l*47.3%
*-un-lft-identity47.3%
associate-/l*47.3%
flip3--95.0%
Applied egg-rr95.0%
Taylor expanded in x around inf 79.4%
associate-/r/79.5%
/-rgt-identity79.5%
Applied egg-rr79.5%
Final simplification79.3%
NOTE: y and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= z -1.45e+63) (* z (* y (- t))) (if (<= z 2.55e-24) (* x (* t y)) (* y (* z (- t))))))
assert(y < t);
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.45e+63) {
tmp = z * (y * -t);
} else if (z <= 2.55e-24) {
tmp = x * (t * y);
} else {
tmp = y * (z * -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 <= (-1.45d+63)) then
tmp = z * (y * -t)
else if (z <= 2.55d-24) then
tmp = x * (t * y)
else
tmp = y * (z * -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 <= -1.45e+63) {
tmp = z * (y * -t);
} else if (z <= 2.55e-24) {
tmp = x * (t * y);
} else {
tmp = y * (z * -t);
}
return tmp;
}
[y, t] = sort([y, t]) def code(x, y, z, t): tmp = 0 if z <= -1.45e+63: tmp = z * (y * -t) elif z <= 2.55e-24: tmp = x * (t * y) else: tmp = y * (z * -t) return tmp
y, t = sort([y, t]) function code(x, y, z, t) tmp = 0.0 if (z <= -1.45e+63) tmp = Float64(z * Float64(y * Float64(-t))); elseif (z <= 2.55e-24) tmp = Float64(x * Float64(t * y)); else tmp = Float64(y * Float64(z * Float64(-t))); end return tmp end
y, t = num2cell(sort([y, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (z <= -1.45e+63)
tmp = z * (y * -t);
elseif (z <= 2.55e-24)
tmp = x * (t * y);
else
tmp = y * (z * -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, -1.45e+63], N[(z * N[(y * (-t)), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.55e-24], N[(x * N[(t * y), $MachinePrecision]), $MachinePrecision], N[(y * N[(z * (-t)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.45 \cdot 10^{+63}:\\
\;\;\;\;z \cdot \left(y \cdot \left(-t\right)\right)\\
\mathbf{elif}\;z \leq 2.55 \cdot 10^{-24}:\\
\;\;\;\;x \cdot \left(t \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot \left(-t\right)\right)\\
\end{array}
\end{array}
if z < -1.45e63Initial program 82.9%
distribute-rgt-out--86.4%
associate-*l*93.0%
*-commutative93.0%
Simplified93.0%
associate-*r*90.6%
flip3--23.1%
associate-*r/19.9%
associate-/l*23.1%
*-un-lft-identity23.1%
associate-/l*23.1%
flip3--90.5%
Applied egg-rr90.5%
Taylor expanded in x around 0 76.9%
div-inv76.9%
associate-/r/77.0%
metadata-eval77.0%
neg-mul-177.0%
Applied egg-rr77.0%
if -1.45e63 < z < 2.55000000000000013e-24Initial program 93.5%
distribute-rgt-out--94.3%
associate-*l*90.9%
*-commutative90.9%
Simplified90.9%
associate-*r*95.1%
flip3--47.3%
associate-*r/42.4%
associate-/l*47.3%
*-un-lft-identity47.3%
associate-/l*47.3%
flip3--95.0%
Applied egg-rr95.0%
Taylor expanded in x around inf 79.4%
associate-/r/79.5%
/-rgt-identity79.5%
Applied egg-rr79.5%
if 2.55000000000000013e-24 < z Initial program 92.1%
distribute-rgt-out--92.1%
associate-*l*95.9%
*-commutative95.9%
Simplified95.9%
Taylor expanded in x around 0 78.3%
mul-1-neg78.3%
distribute-rgt-neg-out78.3%
Simplified78.3%
Final simplification78.6%
NOTE: y and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= z -1.12e+61) (* t (* y (- z))) (if (<= z 1.4e-25) (* x (* t y)) (* y (* t (- z))))))
assert(y < t);
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.12e+61) {
tmp = t * (y * -z);
} else if (z <= 1.4e-25) {
tmp = x * (t * y);
} 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 (z <= (-1.12d+61)) then
tmp = t * (y * -z)
else if (z <= 1.4d-25) then
tmp = x * (t * y)
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 (z <= -1.12e+61) {
tmp = t * (y * -z);
} else if (z <= 1.4e-25) {
tmp = x * (t * y);
} else {
tmp = y * (t * -z);
}
return tmp;
}
[y, t] = sort([y, t]) def code(x, y, z, t): tmp = 0 if z <= -1.12e+61: tmp = t * (y * -z) elif z <= 1.4e-25: tmp = x * (t * y) else: tmp = y * (t * -z) return tmp
y, t = sort([y, t]) function code(x, y, z, t) tmp = 0.0 if (z <= -1.12e+61) tmp = Float64(t * Float64(y * Float64(-z))); elseif (z <= 1.4e-25) tmp = Float64(x * Float64(t * y)); 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 (z <= -1.12e+61)
tmp = t * (y * -z);
elseif (z <= 1.4e-25)
tmp = x * (t * y);
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[LessEqual[z, -1.12e+61], N[(t * N[(y * (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.4e-25], N[(x * N[(t * y), $MachinePrecision]), $MachinePrecision], N[(y * N[(t * (-z)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.12 \cdot 10^{+61}:\\
\;\;\;\;t \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{elif}\;z \leq 1.4 \cdot 10^{-25}:\\
\;\;\;\;x \cdot \left(t \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(t \cdot \left(-z\right)\right)\\
\end{array}
\end{array}
if z < -1.12e61Initial program 82.9%
distribute-rgt-out--86.4%
Simplified86.4%
Taylor expanded in x around 0 73.0%
associate-*r*73.0%
neg-mul-173.0%
*-commutative73.0%
Simplified73.0%
if -1.12e61 < z < 1.39999999999999994e-25Initial program 93.5%
distribute-rgt-out--94.3%
associate-*l*90.9%
*-commutative90.9%
Simplified90.9%
associate-*r*95.1%
flip3--47.3%
associate-*r/42.4%
associate-/l*47.3%
*-un-lft-identity47.3%
associate-/l*47.3%
flip3--95.0%
Applied egg-rr95.0%
Taylor expanded in x around inf 79.4%
associate-/r/79.5%
/-rgt-identity79.5%
Applied egg-rr79.5%
if 1.39999999999999994e-25 < z Initial program 92.1%
distribute-rgt-out--92.1%
associate-*l*95.9%
*-commutative95.9%
Simplified95.9%
Taylor expanded in x around 0 78.3%
mul-1-neg78.3%
distribute-rgt-neg-out78.3%
Simplified78.3%
Final simplification77.7%
NOTE: y and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= t 1.35e-105) (* y (* t (- x z))) (* t (* y (- x z)))))
assert(y < t);
double code(double x, double y, double z, double t) {
double tmp;
if (t <= 1.35e-105) {
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 (t <= 1.35d-105) 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 (t <= 1.35e-105) {
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 t <= 1.35e-105: 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 (t <= 1.35e-105) 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 (t <= 1.35e-105)
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[t, 1.35e-105], 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}\;t \leq 1.35 \cdot 10^{-105}:\\
\;\;\;\;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 t < 1.34999999999999996e-105Initial program 88.3%
distribute-rgt-out--88.9%
associate-*l*92.5%
*-commutative92.5%
Simplified92.5%
if 1.34999999999999996e-105 < t Initial program 95.3%
distribute-rgt-out--97.6%
Simplified97.6%
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 3e-106) (* y (* t x)) (* x (* t y))))
assert(y < t);
double code(double x, double y, double z, double t) {
double tmp;
if (t <= 3e-106) {
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 <= 3d-106) 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 <= 3e-106) {
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 <= 3e-106: 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 <= 3e-106) 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 <= 3e-106)
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, 3e-106], 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 3 \cdot 10^{-106}:\\
\;\;\;\;y \cdot \left(t \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(t \cdot y\right)\\
\end{array}
\end{array}
if t < 3.00000000000000019e-106Initial program 88.8%
distribute-rgt-out--89.4%
associate-*l*92.5%
*-commutative92.5%
Simplified92.5%
Taylor expanded in x around inf 49.8%
if 3.00000000000000019e-106 < t Initial program 94.4%
distribute-rgt-out--96.7%
associate-*l*93.4%
*-commutative93.4%
Simplified93.4%
associate-*r*97.4%
flip3--48.5%
associate-*r/44.1%
associate-/l*48.4%
*-un-lft-identity48.4%
associate-/l*48.3%
flip3--97.2%
Applied egg-rr97.2%
Taylor expanded in x around inf 57.8%
associate-/r/57.9%
/-rgt-identity57.9%
Applied egg-rr57.9%
Final simplification52.6%
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 90.7%
distribute-rgt-out--91.9%
associate-*l*92.8%
*-commutative92.8%
Simplified92.8%
Final simplification92.8%
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 90.7%
distribute-rgt-out--91.9%
associate-*l*92.8%
*-commutative92.8%
Simplified92.8%
Taylor expanded in x around inf 50.2%
Final simplification50.2%
(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 2023301
(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))