
(FPCore (x y z t) :precision binary64 (/ x (- y (* z t))))
double code(double x, double y, double z, double t) {
return x / (y - (z * 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 * t))
end function
public static double code(double x, double y, double z, double t) {
return x / (y - (z * t));
}
def code(x, y, z, t): return x / (y - (z * t))
function code(x, y, z, t) return Float64(x / Float64(y - Float64(z * t))) end
function tmp = code(x, y, z, t) tmp = x / (y - (z * t)); end
code[x_, y_, z_, t_] := N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y - z \cdot t}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (/ x (- y (* z t))))
double code(double x, double y, double z, double t) {
return x / (y - (z * 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 * t))
end function
public static double code(double x, double y, double z, double t) {
return x / (y - (z * t));
}
def code(x, y, z, t): return x / (y - (z * t))
function code(x, y, z, t) return Float64(x / Float64(y - Float64(z * t))) end
function tmp = code(x, y, z, t) tmp = x / (y - (z * t)); end
code[x_, y_, z_, t_] := N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y - z \cdot t}
\end{array}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (or (<= (* z t) (- INFINITY)) (not (<= (* z t) 1e+228))) (/ (/ x (- t)) z) (/ x (- y (* z t)))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (((z * t) <= -((double) INFINITY)) || !((z * t) <= 1e+228)) {
tmp = (x / -t) / z;
} else {
tmp = x / (y - (z * t));
}
return tmp;
}
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (((z * t) <= -Double.POSITIVE_INFINITY) || !((z * t) <= 1e+228)) {
tmp = (x / -t) / z;
} else {
tmp = x / (y - (z * t));
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): tmp = 0 if ((z * t) <= -math.inf) or not ((z * t) <= 1e+228): tmp = (x / -t) / z else: tmp = x / (y - (z * t)) return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) tmp = 0.0 if ((Float64(z * t) <= Float64(-Inf)) || !(Float64(z * t) <= 1e+228)) tmp = Float64(Float64(x / Float64(-t)) / z); else tmp = Float64(x / Float64(y - Float64(z * t))); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (((z * t) <= -Inf) || ~(((z * t) <= 1e+228)))
tmp = (x / -t) / z;
else
tmp = x / (y - (z * t));
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[Or[LessEqual[N[(z * t), $MachinePrecision], (-Infinity)], N[Not[LessEqual[N[(z * t), $MachinePrecision], 1e+228]], $MachinePrecision]], N[(N[(x / (-t)), $MachinePrecision] / z), $MachinePrecision], N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -\infty \lor \neg \left(z \cdot t \leq 10^{+228}\right):\\
\;\;\;\;\frac{\frac{x}{-t}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y - z \cdot t}\\
\end{array}
\end{array}
if (*.f64 z t) < -inf.0 or 9.9999999999999992e227 < (*.f64 z t) Initial program 76.5%
Taylor expanded in y around 0 76.5%
associate-*r/76.5%
neg-mul-176.5%
Simplified76.5%
neg-mul-176.5%
times-frac99.8%
Applied egg-rr99.8%
associate-*r/99.9%
frac-2neg99.9%
metadata-eval99.9%
associate-*l/99.9%
*-un-lft-identity99.9%
Applied egg-rr99.9%
if -inf.0 < (*.f64 z t) < 9.9999999999999992e227Initial program 99.9%
Final simplification99.9%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (or (<= y -1.05e-9) (not (<= y 230000.0))) (/ x y) (/ (- x) (* z t))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.05e-9) || !(y <= 230000.0)) {
tmp = x / y;
} else {
tmp = -x / (z * t);
}
return tmp;
}
NOTE: x, y, z, 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 <= (-1.05d-9)) .or. (.not. (y <= 230000.0d0))) then
tmp = x / y
else
tmp = -x / (z * t)
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.05e-9) || !(y <= 230000.0)) {
tmp = x / y;
} else {
tmp = -x / (z * t);
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): tmp = 0 if (y <= -1.05e-9) or not (y <= 230000.0): tmp = x / y else: tmp = -x / (z * t) return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) tmp = 0.0 if ((y <= -1.05e-9) || !(y <= 230000.0)) tmp = Float64(x / y); else tmp = Float64(Float64(-x) / Float64(z * t)); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((y <= -1.05e-9) || ~((y <= 230000.0)))
tmp = x / y;
else
tmp = -x / (z * t);
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.05e-9], N[Not[LessEqual[y, 230000.0]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[((-x) / N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.05 \cdot 10^{-9} \lor \neg \left(y \leq 230000\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{-x}{z \cdot t}\\
\end{array}
\end{array}
if y < -1.0500000000000001e-9 or 2.3e5 < y Initial program 93.1%
Taylor expanded in y around inf 73.2%
if -1.0500000000000001e-9 < y < 2.3e5Initial program 95.9%
Taylor expanded in y around 0 77.0%
associate-*r/77.0%
neg-mul-177.0%
Simplified77.0%
Final simplification75.4%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (or (<= t -2.6e-84) (not (<= t 1.18e+106))) (/ (/ x (- t)) z) (/ x y)))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -2.6e-84) || !(t <= 1.18e+106)) {
tmp = (x / -t) / z;
} else {
tmp = x / y;
}
return tmp;
}
NOTE: x, y, z, 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.6d-84)) .or. (.not. (t <= 1.18d+106))) then
tmp = (x / -t) / z
else
tmp = x / y
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -2.6e-84) || !(t <= 1.18e+106)) {
tmp = (x / -t) / z;
} else {
tmp = x / y;
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): tmp = 0 if (t <= -2.6e-84) or not (t <= 1.18e+106): tmp = (x / -t) / z else: tmp = x / y return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) tmp = 0.0 if ((t <= -2.6e-84) || !(t <= 1.18e+106)) tmp = Float64(Float64(x / Float64(-t)) / z); else tmp = Float64(x / y); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((t <= -2.6e-84) || ~((t <= 1.18e+106)))
tmp = (x / -t) / z;
else
tmp = x / y;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[Or[LessEqual[t, -2.6e-84], N[Not[LessEqual[t, 1.18e+106]], $MachinePrecision]], N[(N[(x / (-t)), $MachinePrecision] / z), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.6 \cdot 10^{-84} \lor \neg \left(t \leq 1.18 \cdot 10^{+106}\right):\\
\;\;\;\;\frac{\frac{x}{-t}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if t < -2.6e-84 or 1.17999999999999993e106 < t Initial program 90.6%
Taylor expanded in y around 0 74.3%
associate-*r/74.3%
neg-mul-174.3%
Simplified74.3%
neg-mul-174.3%
times-frac77.0%
Applied egg-rr77.0%
associate-*r/80.4%
frac-2neg80.4%
metadata-eval80.4%
associate-*l/80.5%
*-un-lft-identity80.5%
Applied egg-rr80.5%
if -2.6e-84 < t < 1.17999999999999993e106Initial program 99.9%
Taylor expanded in y around inf 69.9%
Final simplification75.8%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= t -6.9e-93) (/ (/ (- x) z) t) (if (<= t 3.5e+106) (/ x y) (/ (/ x (- t)) z))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -6.9e-93) {
tmp = (-x / z) / t;
} else if (t <= 3.5e+106) {
tmp = x / y;
} else {
tmp = (x / -t) / z;
}
return tmp;
}
NOTE: x, y, z, 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 <= (-6.9d-93)) then
tmp = (-x / z) / t
else if (t <= 3.5d+106) then
tmp = x / y
else
tmp = (x / -t) / z
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -6.9e-93) {
tmp = (-x / z) / t;
} else if (t <= 3.5e+106) {
tmp = x / y;
} else {
tmp = (x / -t) / z;
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): tmp = 0 if t <= -6.9e-93: tmp = (-x / z) / t elif t <= 3.5e+106: tmp = x / y else: tmp = (x / -t) / z return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) tmp = 0.0 if (t <= -6.9e-93) tmp = Float64(Float64(Float64(-x) / z) / t); elseif (t <= 3.5e+106) tmp = Float64(x / y); else tmp = Float64(Float64(x / Float64(-t)) / z); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (t <= -6.9e-93)
tmp = (-x / z) / t;
elseif (t <= 3.5e+106)
tmp = x / y;
else
tmp = (x / -t) / z;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[t, -6.9e-93], N[(N[((-x) / z), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[t, 3.5e+106], N[(x / y), $MachinePrecision], N[(N[(x / (-t)), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6.9 \cdot 10^{-93}:\\
\;\;\;\;\frac{\frac{-x}{z}}{t}\\
\mathbf{elif}\;t \leq 3.5 \cdot 10^{+106}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{-t}}{z}\\
\end{array}
\end{array}
if t < -6.90000000000000031e-93Initial program 92.5%
Taylor expanded in y around 0 74.1%
associate-*r/74.1%
neg-mul-174.1%
*-commutative74.1%
associate-/r*75.3%
Simplified75.3%
if -6.90000000000000031e-93 < t < 3.49999999999999981e106Initial program 99.9%
Taylor expanded in y around inf 69.6%
if 3.49999999999999981e106 < t Initial program 87.6%
Taylor expanded in y around 0 73.3%
associate-*r/73.3%
neg-mul-173.3%
Simplified73.3%
neg-mul-173.3%
times-frac78.5%
Applied egg-rr78.5%
associate-*r/80.2%
frac-2neg80.2%
metadata-eval80.2%
associate-*l/80.4%
*-un-lft-identity80.4%
Applied egg-rr80.4%
Final simplification73.9%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (or (<= z -5.6e+158) (not (<= z 4.3e-59))) (/ x (* z t)) (/ x y)))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -5.6e+158) || !(z <= 4.3e-59)) {
tmp = x / (z * t);
} else {
tmp = x / y;
}
return tmp;
}
NOTE: x, y, z, 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 <= (-5.6d+158)) .or. (.not. (z <= 4.3d-59))) then
tmp = x / (z * t)
else
tmp = x / y
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -5.6e+158) || !(z <= 4.3e-59)) {
tmp = x / (z * t);
} else {
tmp = x / y;
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): tmp = 0 if (z <= -5.6e+158) or not (z <= 4.3e-59): tmp = x / (z * t) else: tmp = x / y return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) tmp = 0.0 if ((z <= -5.6e+158) || !(z <= 4.3e-59)) tmp = Float64(x / Float64(z * t)); else tmp = Float64(x / y); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((z <= -5.6e+158) || ~((z <= 4.3e-59)))
tmp = x / (z * t);
else
tmp = x / y;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[Or[LessEqual[z, -5.6e+158], N[Not[LessEqual[z, 4.3e-59]], $MachinePrecision]], N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.6 \cdot 10^{+158} \lor \neg \left(z \leq 4.3 \cdot 10^{-59}\right):\\
\;\;\;\;\frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if z < -5.60000000000000003e158 or 4.3000000000000003e-59 < z Initial program 92.3%
Taylor expanded in y around 0 73.9%
associate-*r/73.9%
neg-mul-173.9%
Simplified73.9%
associate-/l/76.2%
expm1-log1p-u72.9%
expm1-udef55.1%
associate-/r*55.1%
add-sqr-sqrt24.2%
sqrt-unprod48.8%
sqr-neg48.8%
sqrt-unprod28.1%
add-sqr-sqrt48.3%
Applied egg-rr48.3%
expm1-def45.4%
expm1-log1p45.4%
associate-/r*46.3%
Simplified46.3%
Taylor expanded in x around 0 45.4%
if -5.60000000000000003e158 < z < 4.3000000000000003e-59Initial program 96.6%
Taylor expanded in y around inf 60.2%
Final simplification53.7%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= z -6.2e+159) (/ (/ x z) t) (if (<= z 4.3e-59) (/ x y) (/ x (* z t)))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -6.2e+159) {
tmp = (x / z) / t;
} else if (z <= 4.3e-59) {
tmp = x / y;
} else {
tmp = x / (z * t);
}
return tmp;
}
NOTE: x, y, z, 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 <= (-6.2d+159)) then
tmp = (x / z) / t
else if (z <= 4.3d-59) then
tmp = x / y
else
tmp = x / (z * t)
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -6.2e+159) {
tmp = (x / z) / t;
} else if (z <= 4.3e-59) {
tmp = x / y;
} else {
tmp = x / (z * t);
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): tmp = 0 if z <= -6.2e+159: tmp = (x / z) / t elif z <= 4.3e-59: tmp = x / y else: tmp = x / (z * t) return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) tmp = 0.0 if (z <= -6.2e+159) tmp = Float64(Float64(x / z) / t); elseif (z <= 4.3e-59) tmp = Float64(x / y); else tmp = Float64(x / Float64(z * t)); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (z <= -6.2e+159)
tmp = (x / z) / t;
elseif (z <= 4.3e-59)
tmp = x / y;
else
tmp = x / (z * t);
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[z, -6.2e+159], N[(N[(x / z), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[z, 4.3e-59], N[(x / y), $MachinePrecision], N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.2 \cdot 10^{+159}:\\
\;\;\;\;\frac{\frac{x}{z}}{t}\\
\mathbf{elif}\;z \leq 4.3 \cdot 10^{-59}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z \cdot t}\\
\end{array}
\end{array}
if z < -6.1999999999999996e159Initial program 93.9%
Taylor expanded in y around 0 82.3%
associate-*r/82.3%
neg-mul-182.3%
Simplified82.3%
associate-/l/72.4%
expm1-log1p-u68.7%
expm1-udef49.3%
associate-/r*49.3%
add-sqr-sqrt19.7%
sqrt-unprod44.7%
sqr-neg44.7%
sqrt-unprod28.2%
add-sqr-sqrt45.0%
Applied egg-rr45.0%
expm1-def44.3%
expm1-log1p44.4%
associate-/r*44.7%
Simplified44.7%
if -6.1999999999999996e159 < z < 4.3000000000000003e-59Initial program 96.6%
Taylor expanded in y around inf 60.2%
if 4.3000000000000003e-59 < z Initial program 91.6%
Taylor expanded in y around 0 70.6%
associate-*r/70.6%
neg-mul-170.6%
Simplified70.6%
associate-/l/77.8%
expm1-log1p-u74.6%
expm1-udef57.4%
associate-/r*57.4%
add-sqr-sqrt26.0%
sqrt-unprod50.4%
sqr-neg50.4%
sqrt-unprod28.1%
add-sqr-sqrt49.6%
Applied egg-rr49.6%
expm1-def45.8%
expm1-log1p45.9%
associate-/r*46.9%
Simplified46.9%
Taylor expanded in x around 0 45.9%
Final simplification53.7%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (/ x y))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
return x / y;
}
NOTE: x, y, z, 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
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
return x / y;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): return x / y
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) return Float64(x / y) end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
tmp = x / y;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[(x / y), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\frac{x}{y}
\end{array}
Initial program 94.7%
Taylor expanded in y around inf 45.7%
Final simplification45.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ 1.0 (- (/ y x) (* (/ z x) t)))))
(if (< x -1.618195973607049e+50)
t_1
(if (< x 2.1378306434876444e+131) (/ x (- y (* z t))) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = 1.0 / ((y / x) - ((z / x) * t));
double tmp;
if (x < -1.618195973607049e+50) {
tmp = t_1;
} else if (x < 2.1378306434876444e+131) {
tmp = x / (y - (z * t));
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_1 = 1.0d0 / ((y / x) - ((z / x) * t))
if (x < (-1.618195973607049d+50)) then
tmp = t_1
else if (x < 2.1378306434876444d+131) then
tmp = x / (y - (z * t))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = 1.0 / ((y / x) - ((z / x) * t));
double tmp;
if (x < -1.618195973607049e+50) {
tmp = t_1;
} else if (x < 2.1378306434876444e+131) {
tmp = x / (y - (z * t));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = 1.0 / ((y / x) - ((z / x) * t)) tmp = 0 if x < -1.618195973607049e+50: tmp = t_1 elif x < 2.1378306434876444e+131: tmp = x / (y - (z * t)) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(1.0 / Float64(Float64(y / x) - Float64(Float64(z / x) * t))) tmp = 0.0 if (x < -1.618195973607049e+50) tmp = t_1; elseif (x < 2.1378306434876444e+131) tmp = Float64(x / Float64(y - Float64(z * t))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = 1.0 / ((y / x) - ((z / x) * t)); tmp = 0.0; if (x < -1.618195973607049e+50) tmp = t_1; elseif (x < 2.1378306434876444e+131) tmp = x / (y - (z * t)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(1.0 / N[(N[(y / x), $MachinePrecision] - N[(N[(z / x), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[x, -1.618195973607049e+50], t$95$1, If[Less[x, 2.1378306434876444e+131], N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{1}{\frac{y}{x} - \frac{z}{x} \cdot t}\\
\mathbf{if}\;x < -1.618195973607049 \cdot 10^{+50}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x < 2.1378306434876444 \cdot 10^{+131}:\\
\;\;\;\;\frac{x}{y - z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
herbie shell --seed 2024021
(FPCore (x y z t)
:name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, B"
:precision binary64
:herbie-target
(if (< x -1.618195973607049e+50) (/ 1.0 (- (/ y x) (* (/ z x) t))) (if (< x 2.1378306434876444e+131) (/ x (- y (* z t))) (/ 1.0 (- (/ y x) (* (/ z x) t)))))
(/ x (- y (* z t))))