
(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}
(FPCore (x y z t) :precision binary64 (if (<= (* z t) (- INFINITY)) (/ (/ x t) (- z)) (if (<= (* z t) 2e+262) (/ x (- y (* z t))) (/ -1.0 (* z (/ t x))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -((double) INFINITY)) {
tmp = (x / t) / -z;
} else if ((z * t) <= 2e+262) {
tmp = x / (y - (z * t));
} else {
tmp = -1.0 / (z * (t / x));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -Double.POSITIVE_INFINITY) {
tmp = (x / t) / -z;
} else if ((z * t) <= 2e+262) {
tmp = x / (y - (z * t));
} else {
tmp = -1.0 / (z * (t / x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z * t) <= -math.inf: tmp = (x / t) / -z elif (z * t) <= 2e+262: tmp = x / (y - (z * t)) else: tmp = -1.0 / (z * (t / x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(z * t) <= Float64(-Inf)) tmp = Float64(Float64(x / t) / Float64(-z)); elseif (Float64(z * t) <= 2e+262) tmp = Float64(x / Float64(y - Float64(z * t))); else tmp = Float64(-1.0 / Float64(z * Float64(t / x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z * t) <= -Inf) tmp = (x / t) / -z; elseif ((z * t) <= 2e+262) tmp = x / (y - (z * t)); else tmp = -1.0 / (z * (t / x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * t), $MachinePrecision], (-Infinity)], N[(N[(x / t), $MachinePrecision] / (-z)), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+262], N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 / N[(z * N[(t / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -\infty:\\
\;\;\;\;\frac{\frac{x}{t}}{-z}\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+262}:\\
\;\;\;\;\frac{x}{y - z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{z \cdot \frac{t}{x}}\\
\end{array}
\end{array}
if (*.f64 z t) < -inf.0Initial program 66.6%
clear-num66.6%
associate-/r/66.6%
Applied egg-rr66.6%
Taylor expanded in y around 0 66.6%
mul-1-neg66.6%
associate-/r*99.8%
distribute-neg-frac299.8%
Simplified99.8%
if -inf.0 < (*.f64 z t) < 2e262Initial program 99.9%
if 2e262 < (*.f64 z t) Initial program 71.6%
Taylor expanded in t around -inf 90.0%
Taylor expanded in z around inf 99.9%
clear-num99.9%
un-div-inv99.9%
div-inv99.8%
clear-num99.9%
Applied egg-rr99.9%
Taylor expanded in t around 0 71.6%
associate-*l/100.0%
*-commutative100.0%
Simplified100.0%
(FPCore (x y z t) :precision binary64 (if (or (<= t -4.5e-161) (not (<= t 3.8e+54))) (/ (/ x t) (- z)) (/ x y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -4.5e-161) || !(t <= 3.8e+54)) {
tmp = (x / t) / -z;
} else {
tmp = x / y;
}
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 <= (-4.5d-161)) .or. (.not. (t <= 3.8d+54))) then
tmp = (x / t) / -z
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -4.5e-161) || !(t <= 3.8e+54)) {
tmp = (x / t) / -z;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -4.5e-161) or not (t <= 3.8e+54): tmp = (x / t) / -z else: tmp = x / y return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -4.5e-161) || !(t <= 3.8e+54)) tmp = Float64(Float64(x / t) / Float64(-z)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -4.5e-161) || ~((t <= 3.8e+54))) tmp = (x / t) / -z; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -4.5e-161], N[Not[LessEqual[t, 3.8e+54]], $MachinePrecision]], N[(N[(x / t), $MachinePrecision] / (-z)), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.5 \cdot 10^{-161} \lor \neg \left(t \leq 3.8 \cdot 10^{+54}\right):\\
\;\;\;\;\frac{\frac{x}{t}}{-z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if t < -4.4999999999999996e-161 or 3.8000000000000002e54 < t Initial program 91.7%
clear-num90.8%
associate-/r/91.6%
Applied egg-rr91.6%
Taylor expanded in y around 0 60.2%
mul-1-neg60.2%
associate-/r*70.7%
distribute-neg-frac270.7%
Simplified70.7%
if -4.4999999999999996e-161 < t < 3.8000000000000002e54Initial program 99.9%
Taylor expanded in y around inf 70.9%
Final simplification70.8%
(FPCore (x y z t) :precision binary64 (if (or (<= t -3.8e-161) (not (<= t 3.4e+90))) (/ (- x) (* z t)) (/ x y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -3.8e-161) || !(t <= 3.4e+90)) {
tmp = -x / (z * t);
} else {
tmp = x / y;
}
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 <= (-3.8d-161)) .or. (.not. (t <= 3.4d+90))) then
tmp = -x / (z * t)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -3.8e-161) || !(t <= 3.4e+90)) {
tmp = -x / (z * t);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -3.8e-161) or not (t <= 3.4e+90): tmp = -x / (z * t) else: tmp = x / y return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -3.8e-161) || !(t <= 3.4e+90)) tmp = Float64(Float64(-x) / Float64(z * t)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -3.8e-161) || ~((t <= 3.4e+90))) tmp = -x / (z * t); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -3.8e-161], N[Not[LessEqual[t, 3.4e+90]], $MachinePrecision]], N[((-x) / N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.8 \cdot 10^{-161} \lor \neg \left(t \leq 3.4 \cdot 10^{+90}\right):\\
\;\;\;\;\frac{-x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if t < -3.8000000000000001e-161 or 3.40000000000000018e90 < t Initial program 91.5%
Taylor expanded in y around 0 61.1%
associate-*r/61.1%
neg-mul-161.1%
Simplified61.1%
if -3.8000000000000001e-161 < t < 3.40000000000000018e90Initial program 99.9%
Taylor expanded in y around inf 71.9%
Final simplification65.9%
(FPCore (x y z t) :precision binary64 (if (or (<= t -1.15e+24) (not (<= t 5.1e+178))) (/ x (* z t)) (/ x y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.15e+24) || !(t <= 5.1e+178)) {
tmp = x / (z * t);
} else {
tmp = x / y;
}
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 <= (-1.15d+24)) .or. (.not. (t <= 5.1d+178))) then
tmp = x / (z * t)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.15e+24) || !(t <= 5.1e+178)) {
tmp = x / (z * t);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -1.15e+24) or not (t <= 5.1e+178): tmp = x / (z * t) else: tmp = x / y return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -1.15e+24) || !(t <= 5.1e+178)) tmp = Float64(x / Float64(z * t)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -1.15e+24) || ~((t <= 5.1e+178))) tmp = x / (z * t); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -1.15e+24], N[Not[LessEqual[t, 5.1e+178]], $MachinePrecision]], N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.15 \cdot 10^{+24} \lor \neg \left(t \leq 5.1 \cdot 10^{+178}\right):\\
\;\;\;\;\frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if t < -1.15e24 or 5.0999999999999997e178 < t Initial program 90.1%
Taylor expanded in y around 0 66.7%
associate-*r/66.7%
neg-mul-166.7%
Simplified66.7%
neg-sub066.7%
sub-neg66.7%
add-sqr-sqrt35.0%
sqrt-unprod51.2%
sqr-neg51.2%
sqrt-unprod16.0%
add-sqr-sqrt37.9%
Applied egg-rr37.9%
+-lft-identity37.9%
Simplified37.9%
if -1.15e24 < t < 5.0999999999999997e178Initial program 98.2%
Taylor expanded in y around inf 65.2%
Final simplification55.2%
(FPCore (x y z t) :precision binary64 (if (<= t -1.15e+24) (/ x (* z t)) (if (<= t 5.8e+178) (/ x y) (/ (/ x t) z))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.15e+24) {
tmp = x / (z * t);
} else if (t <= 5.8e+178) {
tmp = x / y;
} else {
tmp = (x / t) / z;
}
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 <= (-1.15d+24)) then
tmp = x / (z * t)
else if (t <= 5.8d+178) then
tmp = x / y
else
tmp = (x / t) / z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.15e+24) {
tmp = x / (z * t);
} else if (t <= 5.8e+178) {
tmp = x / y;
} else {
tmp = (x / t) / z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1.15e+24: tmp = x / (z * t) elif t <= 5.8e+178: tmp = x / y else: tmp = (x / t) / z return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1.15e+24) tmp = Float64(x / Float64(z * t)); elseif (t <= 5.8e+178) tmp = Float64(x / y); else tmp = Float64(Float64(x / t) / z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1.15e+24) tmp = x / (z * t); elseif (t <= 5.8e+178) tmp = x / y; else tmp = (x / t) / z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.15e+24], N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 5.8e+178], N[(x / y), $MachinePrecision], N[(N[(x / t), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.15 \cdot 10^{+24}:\\
\;\;\;\;\frac{x}{z \cdot t}\\
\mathbf{elif}\;t \leq 5.8 \cdot 10^{+178}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{t}}{z}\\
\end{array}
\end{array}
if t < -1.15e24Initial program 89.1%
Taylor expanded in y around 0 56.8%
associate-*r/56.8%
neg-mul-156.8%
Simplified56.8%
neg-sub056.8%
sub-neg56.8%
add-sqr-sqrt32.1%
sqrt-unprod55.7%
sqr-neg55.7%
sqrt-unprod18.3%
add-sqr-sqrt39.4%
Applied egg-rr39.4%
+-lft-identity39.4%
Simplified39.4%
if -1.15e24 < t < 5.8000000000000001e178Initial program 98.2%
Taylor expanded in y around inf 65.2%
if 5.8000000000000001e178 < t Initial program 91.8%
Taylor expanded in t around -inf 66.2%
Taylor expanded in z around inf 80.6%
associate-/l/83.5%
associate-*r/83.5%
neg-mul-183.5%
add-sqr-sqrt39.9%
sqrt-unprod43.6%
sqr-neg43.6%
sqrt-unprod12.0%
add-sqr-sqrt35.5%
associate-/r*35.5%
Applied egg-rr35.5%
Final simplification55.2%
(FPCore (x y z t) :precision binary64 (if (<= z -2.6e+181) (/ (/ x z) t) (/ x y)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.6e+181) {
tmp = (x / z) / t;
} else {
tmp = x / y;
}
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 (z <= (-2.6d+181)) then
tmp = (x / z) / t
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.6e+181) {
tmp = (x / z) / t;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -2.6e+181: tmp = (x / z) / t else: tmp = x / y return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -2.6e+181) tmp = Float64(Float64(x / z) / t); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -2.6e+181) tmp = (x / z) / t; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -2.6e+181], N[(N[(x / z), $MachinePrecision] / t), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.6 \cdot 10^{+181}:\\
\;\;\;\;\frac{\frac{x}{z}}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if z < -2.6e181Initial program 89.6%
Taylor expanded in y around inf 86.0%
mul-1-neg86.0%
unsub-neg86.0%
associate-/l*71.8%
Simplified71.8%
Taylor expanded in y around 0 82.7%
mul-1-neg82.7%
associate-/l/90.7%
distribute-frac-neg290.7%
Simplified90.7%
neg-sub090.7%
sub-neg90.7%
add-sqr-sqrt57.4%
sqrt-unprod61.7%
sqr-neg61.7%
sqrt-unprod15.5%
add-sqr-sqrt54.7%
Applied egg-rr54.7%
+-lft-identity54.7%
Simplified54.7%
if -2.6e181 < z Initial program 95.9%
Taylor expanded in y around inf 57.9%
(FPCore (x y z t) :precision binary64 (/ x y))
double code(double x, double y, double z, double t) {
return x / y;
}
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
public static double code(double x, double y, double z, double t) {
return x / y;
}
def code(x, y, z, t): return x / y
function code(x, y, z, t) return Float64(x / y) end
function tmp = code(x, y, z, t) tmp = x / y; end
code[x_, y_, z_, t_] := N[(x / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y}
\end{array}
Initial program 95.2%
Taylor expanded in y around inf 53.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 2024116
(FPCore (x y z t)
:name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, B"
:precision binary64
:alt
(! :herbie-platform default (if (< x -161819597360704900000000000000000000000000000000000) (/ 1 (- (/ y x) (* (/ z x) t))) (if (< x 213783064348764440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ x (- y (* z t))) (/ 1 (- (/ y x) (* (/ z x) t))))))
(/ x (- y (* z t))))