
(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 8 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: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= (* z t) -5e+303) (/ (/ x t) (- z)) (if (<= (* z t) 2e+151) (/ x (fma z (- t) y)) (* (/ x t) (/ -1.0 z)))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -5e+303) {
tmp = (x / t) / -z;
} else if ((z * t) <= 2e+151) {
tmp = x / fma(z, -t, y);
} else {
tmp = (x / t) * (-1.0 / z);
}
return tmp;
}
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if (Float64(z * t) <= -5e+303) tmp = Float64(Float64(x / t) / Float64(-z)); elseif (Float64(z * t) <= 2e+151) tmp = Float64(x / fma(z, Float64(-t), y)); else tmp = Float64(Float64(x / t) * Float64(-1.0 / z)); end return tmp end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[N[(z * t), $MachinePrecision], -5e+303], N[(N[(x / t), $MachinePrecision] / (-z)), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+151], N[(x / N[(z * (-t) + y), $MachinePrecision]), $MachinePrecision], N[(N[(x / t), $MachinePrecision] * N[(-1.0 / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+303}:\\
\;\;\;\;\frac{\frac{x}{t}}{-z}\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+151}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(z, -t, y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{t} \cdot \frac{-1}{z}\\
\end{array}
\end{array}
if (*.f64 z t) < -4.9999999999999997e303Initial program 63.5%
Taylor expanded in y around 0 63.5%
associate-*r/63.5%
neg-mul-163.5%
*-commutative63.5%
associate-/r*100.0%
Simplified100.0%
associate-/l/63.5%
neg-mul-163.5%
*-commutative63.5%
times-frac99.7%
Applied egg-rr99.7%
*-commutative99.7%
frac-2neg99.7%
metadata-eval99.7%
un-div-inv99.8%
Applied egg-rr99.8%
if -4.9999999999999997e303 < (*.f64 z t) < 2.00000000000000003e151Initial program 99.9%
cancel-sign-sub-inv99.9%
+-commutative99.9%
distribute-lft-neg-out99.9%
distribute-rgt-neg-out99.9%
fma-def99.9%
Simplified99.9%
if 2.00000000000000003e151 < (*.f64 z t) Initial program 66.1%
Taylor expanded in y around 0 66.1%
associate-*r/66.1%
neg-mul-166.1%
*-commutative66.1%
associate-/r*99.8%
Simplified99.8%
associate-/l/66.1%
neg-mul-166.1%
*-commutative66.1%
times-frac99.8%
Applied egg-rr99.8%
Final simplification99.9%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= (* z t) -5e+303) (/ (/ x t) (- z)) (if (<= (* z t) 2e+151) (/ x (- y (* z t))) (* (/ x t) (/ -1.0 z)))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -5e+303) {
tmp = (x / t) / -z;
} else if ((z * t) <= 2e+151) {
tmp = x / (y - (z * t));
} else {
tmp = (x / t) * (-1.0 / z);
}
return tmp;
}
NOTE: 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 * t) <= (-5d+303)) then
tmp = (x / t) / -z
else if ((z * t) <= 2d+151) then
tmp = x / (y - (z * t))
else
tmp = (x / t) * ((-1.0d0) / z)
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -5e+303) {
tmp = (x / t) / -z;
} else if ((z * t) <= 2e+151) {
tmp = x / (y - (z * t));
} else {
tmp = (x / t) * (-1.0 / z);
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if (z * t) <= -5e+303: tmp = (x / t) / -z elif (z * t) <= 2e+151: tmp = x / (y - (z * t)) else: tmp = (x / t) * (-1.0 / z) return tmp
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if (Float64(z * t) <= -5e+303) tmp = Float64(Float64(x / t) / Float64(-z)); elseif (Float64(z * t) <= 2e+151) tmp = Float64(x / Float64(y - Float64(z * t))); else tmp = Float64(Float64(x / t) * Float64(-1.0 / z)); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((z * t) <= -5e+303)
tmp = (x / t) / -z;
elseif ((z * t) <= 2e+151)
tmp = x / (y - (z * t));
else
tmp = (x / t) * (-1.0 / z);
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[N[(z * t), $MachinePrecision], -5e+303], N[(N[(x / t), $MachinePrecision] / (-z)), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+151], N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / t), $MachinePrecision] * N[(-1.0 / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+303}:\\
\;\;\;\;\frac{\frac{x}{t}}{-z}\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+151}:\\
\;\;\;\;\frac{x}{y - z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{t} \cdot \frac{-1}{z}\\
\end{array}
\end{array}
if (*.f64 z t) < -4.9999999999999997e303Initial program 63.5%
Taylor expanded in y around 0 63.5%
associate-*r/63.5%
neg-mul-163.5%
*-commutative63.5%
associate-/r*100.0%
Simplified100.0%
associate-/l/63.5%
neg-mul-163.5%
*-commutative63.5%
times-frac99.7%
Applied egg-rr99.7%
*-commutative99.7%
frac-2neg99.7%
metadata-eval99.7%
un-div-inv99.8%
Applied egg-rr99.8%
if -4.9999999999999997e303 < (*.f64 z t) < 2.00000000000000003e151Initial program 99.9%
if 2.00000000000000003e151 < (*.f64 z t) Initial program 66.1%
Taylor expanded in y around 0 66.1%
associate-*r/66.1%
neg-mul-166.1%
*-commutative66.1%
associate-/r*99.8%
Simplified99.8%
associate-/l/66.1%
neg-mul-166.1%
*-commutative66.1%
times-frac99.8%
Applied egg-rr99.8%
Final simplification99.9%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= y -4.5e-25) (/ x y) (if (<= y 3.5e-99) (/ -1.0 (* z (/ t x))) (/ x y))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.5e-25) {
tmp = x / y;
} else if (y <= 3.5e-99) {
tmp = -1.0 / (z * (t / x));
} else {
tmp = x / y;
}
return tmp;
}
NOTE: 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 <= (-4.5d-25)) then
tmp = x / y
else if (y <= 3.5d-99) then
tmp = (-1.0d0) / (z * (t / x))
else
tmp = x / y
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.5e-25) {
tmp = x / y;
} else if (y <= 3.5e-99) {
tmp = -1.0 / (z * (t / x));
} else {
tmp = x / y;
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if y <= -4.5e-25: tmp = x / y elif y <= 3.5e-99: tmp = -1.0 / (z * (t / x)) else: tmp = x / y return tmp
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if (y <= -4.5e-25) tmp = Float64(x / y); elseif (y <= 3.5e-99) tmp = Float64(-1.0 / Float64(z * Float64(t / x))); else tmp = Float64(x / y); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (y <= -4.5e-25)
tmp = x / y;
elseif (y <= 3.5e-99)
tmp = -1.0 / (z * (t / x));
else
tmp = x / y;
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[y, -4.5e-25], N[(x / y), $MachinePrecision], If[LessEqual[y, 3.5e-99], N[(-1.0 / N[(z * N[(t / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.5 \cdot 10^{-25}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{-99}:\\
\;\;\;\;\frac{-1}{z \cdot \frac{t}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if y < -4.5000000000000001e-25 or 3.4999999999999999e-99 < y Initial program 95.0%
Taylor expanded in y around inf 75.2%
if -4.5000000000000001e-25 < y < 3.4999999999999999e-99Initial program 92.2%
Taylor expanded in y around 0 78.5%
associate-*r/78.5%
neg-mul-178.5%
*-commutative78.5%
associate-/r*81.6%
Simplified81.6%
associate-/l/78.5%
neg-mul-178.5%
*-commutative78.5%
times-frac80.2%
Applied egg-rr80.2%
*-commutative80.2%
clear-num80.1%
frac-times80.7%
metadata-eval80.7%
Applied egg-rr80.7%
Final simplification77.4%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= y -1.5e-27) (/ x y) (if (<= y 5e-8) (/ (- x) (* z t)) (/ x y))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.5e-27) {
tmp = x / y;
} else if (y <= 5e-8) {
tmp = -x / (z * t);
} else {
tmp = x / y;
}
return tmp;
}
NOTE: 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.5d-27)) then
tmp = x / y
else if (y <= 5d-8) then
tmp = -x / (z * t)
else
tmp = x / y
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.5e-27) {
tmp = x / y;
} else if (y <= 5e-8) {
tmp = -x / (z * t);
} else {
tmp = x / y;
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if y <= -1.5e-27: tmp = x / y elif y <= 5e-8: tmp = -x / (z * t) else: tmp = x / y return tmp
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if (y <= -1.5e-27) tmp = Float64(x / y); elseif (y <= 5e-8) tmp = Float64(Float64(-x) / Float64(z * t)); else tmp = Float64(x / y); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (y <= -1.5e-27)
tmp = x / y;
elseif (y <= 5e-8)
tmp = -x / (z * t);
else
tmp = x / y;
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[y, -1.5e-27], N[(x / y), $MachinePrecision], If[LessEqual[y, 5e-8], N[((-x) / N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.5 \cdot 10^{-27}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq 5 \cdot 10^{-8}:\\
\;\;\;\;\frac{-x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if y < -1.5000000000000001e-27 or 4.9999999999999998e-8 < y Initial program 94.4%
Taylor expanded in y around inf 79.1%
if -1.5000000000000001e-27 < y < 4.9999999999999998e-8Initial program 93.3%
Taylor expanded in y around 0 75.4%
associate-*r/75.4%
neg-mul-175.4%
Simplified75.4%
Final simplification77.3%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= y -6.8e-25) (/ x y) (if (<= y 8e-11) (/ (/ x t) (- z)) (/ x y))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -6.8e-25) {
tmp = x / y;
} else if (y <= 8e-11) {
tmp = (x / t) / -z;
} else {
tmp = x / y;
}
return tmp;
}
NOTE: 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 <= (-6.8d-25)) then
tmp = x / y
else if (y <= 8d-11) then
tmp = (x / t) / -z
else
tmp = x / y
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -6.8e-25) {
tmp = x / y;
} else if (y <= 8e-11) {
tmp = (x / t) / -z;
} else {
tmp = x / y;
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if y <= -6.8e-25: tmp = x / y elif y <= 8e-11: tmp = (x / t) / -z else: tmp = x / y return tmp
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if (y <= -6.8e-25) tmp = Float64(x / y); elseif (y <= 8e-11) tmp = Float64(Float64(x / t) / Float64(-z)); else tmp = Float64(x / y); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (y <= -6.8e-25)
tmp = x / y;
elseif (y <= 8e-11)
tmp = (x / t) / -z;
else
tmp = x / y;
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[y, -6.8e-25], N[(x / y), $MachinePrecision], If[LessEqual[y, 8e-11], N[(N[(x / t), $MachinePrecision] / (-z)), $MachinePrecision], N[(x / y), $MachinePrecision]]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.8 \cdot 10^{-25}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq 8 \cdot 10^{-11}:\\
\;\;\;\;\frac{\frac{x}{t}}{-z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if y < -6.80000000000000003e-25 or 7.99999999999999952e-11 < y Initial program 94.4%
Taylor expanded in y around inf 79.1%
if -6.80000000000000003e-25 < y < 7.99999999999999952e-11Initial program 93.3%
Taylor expanded in y around 0 75.4%
associate-*r/75.4%
neg-mul-175.4%
*-commutative75.4%
associate-/r*76.6%
Simplified76.6%
associate-/l/75.4%
neg-mul-175.4%
*-commutative75.4%
times-frac76.6%
Applied egg-rr76.6%
*-commutative76.6%
frac-2neg76.6%
metadata-eval76.6%
un-div-inv76.8%
Applied egg-rr76.8%
Final simplification78.0%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (or (<= z -2e+215) (not (<= z 2.95e-33))) (/ x (* z t)) (/ x y)))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2e+215) || !(z <= 2.95e-33)) {
tmp = x / (z * t);
} else {
tmp = x / y;
}
return tmp;
}
NOTE: 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 <= (-2d+215)) .or. (.not. (z <= 2.95d-33))) then
tmp = x / (z * t)
else
tmp = x / y
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2e+215) || !(z <= 2.95e-33)) {
tmp = x / (z * t);
} else {
tmp = x / y;
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if (z <= -2e+215) or not (z <= 2.95e-33): tmp = x / (z * t) else: tmp = x / y return tmp
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if ((z <= -2e+215) || !(z <= 2.95e-33)) tmp = Float64(x / Float64(z * t)); else tmp = Float64(x / y); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((z <= -2e+215) || ~((z <= 2.95e-33)))
tmp = x / (z * t);
else
tmp = x / y;
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[Or[LessEqual[z, -2e+215], N[Not[LessEqual[z, 2.95e-33]], $MachinePrecision]], N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+215} \lor \neg \left(z \leq 2.95 \cdot 10^{-33}\right):\\
\;\;\;\;\frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if z < -1.99999999999999981e215 or 2.94999999999999993e-33 < z Initial program 85.5%
Taylor expanded in y around 0 61.1%
associate-*r/61.1%
neg-mul-161.1%
*-commutative61.1%
associate-/r*70.6%
Simplified70.6%
expm1-log1p-u64.4%
expm1-udef33.4%
associate-/l/33.4%
add-sqr-sqrt16.1%
*-commutative16.1%
sqrt-unprod23.5%
sqr-neg23.5%
sqrt-unprod12.0%
add-sqr-sqrt24.3%
Applied egg-rr24.3%
expm1-def22.7%
expm1-log1p23.0%
*-commutative23.0%
Simplified23.0%
if -1.99999999999999981e215 < z < 2.94999999999999993e-33Initial program 98.7%
Taylor expanded in y around inf 67.4%
Final simplification51.1%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= t 7.2e+207) (/ x y) (/ (/ x t) z)))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (t <= 7.2e+207) {
tmp = x / y;
} else {
tmp = (x / t) / z;
}
return tmp;
}
NOTE: 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 <= 7.2d+207) then
tmp = x / y
else
tmp = (x / t) / z
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= 7.2e+207) {
tmp = x / y;
} else {
tmp = (x / t) / z;
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if t <= 7.2e+207: tmp = x / y else: tmp = (x / t) / z return tmp
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if (t <= 7.2e+207) tmp = Float64(x / y); else tmp = Float64(Float64(x / t) / z); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (t <= 7.2e+207)
tmp = x / y;
else
tmp = (x / t) / z;
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[t, 7.2e+207], N[(x / y), $MachinePrecision], N[(N[(x / t), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq 7.2 \cdot 10^{+207}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{t}}{z}\\
\end{array}
\end{array}
if t < 7.20000000000000028e207Initial program 94.9%
Taylor expanded in y around inf 55.9%
if 7.20000000000000028e207 < t Initial program 84.4%
Taylor expanded in y around 0 64.9%
associate-*r/64.9%
neg-mul-164.9%
*-commutative64.9%
associate-/r*76.5%
Simplified76.5%
expm1-log1p-u76.1%
expm1-udef64.2%
associate-/l/68.0%
add-sqr-sqrt47.0%
*-commutative47.0%
sqrt-unprod63.5%
sqr-neg63.5%
sqrt-unprod21.0%
add-sqr-sqrt60.1%
Applied egg-rr60.1%
expm1-def48.1%
expm1-log1p48.2%
*-commutative48.2%
Simplified48.2%
add-sqr-sqrt17.0%
sqrt-unprod60.0%
sqr-neg60.0%
sqrt-unprod47.7%
add-sqr-sqrt64.9%
expm1-log1p-u64.4%
expm1-udef68.0%
add-sqr-sqrt47.0%
sqrt-unprod63.5%
sqr-neg63.5%
sqrt-unprod21.0%
add-sqr-sqrt60.1%
*-commutative60.1%
Applied egg-rr60.1%
expm1-def48.1%
expm1-log1p48.2%
associate-/l/59.8%
Simplified59.8%
Final simplification56.2%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (/ x y))
assert(z < t);
double code(double x, double y, double z, double t) {
return x / y;
}
NOTE: 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 z < t;
public static double code(double x, double y, double z, double t) {
return x / y;
}
[z, t] = sort([z, t]) def code(x, y, z, t): return x / y
z, t = sort([z, t]) function code(x, y, z, t) return Float64(x / y) end
z, t = num2cell(sort([z, t])){:}
function tmp = code(x, y, z, t)
tmp = x / y;
end
NOTE: 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}
[z, t] = \mathsf{sort}([z, t])\\
\\
\frac{x}{y}
\end{array}
Initial program 93.9%
Taylor expanded in y around inf 54.5%
Final simplification54.5%
(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 2023275
(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))))