
(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) -1e+270) (/ (/ x t) (- z)) (if (<= (* z t) 2e+220) (/ x (fma (- z) t y)) (/ (/ (- x) z) t))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -1e+270) {
tmp = (x / t) / -z;
} else if ((z * t) <= 2e+220) {
tmp = x / fma(-z, t, y);
} else {
tmp = (-x / z) / t;
}
return tmp;
}
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if (Float64(z * t) <= -1e+270) tmp = Float64(Float64(x / t) / Float64(-z)); elseif (Float64(z * t) <= 2e+220) tmp = Float64(x / fma(Float64(-z), t, y)); else tmp = Float64(Float64(Float64(-x) / z) / t); 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], -1e+270], N[(N[(x / t), $MachinePrecision] / (-z)), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+220], N[(x / N[((-z) * t + y), $MachinePrecision]), $MachinePrecision], N[(N[((-x) / z), $MachinePrecision] / t), $MachinePrecision]]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+270}:\\
\;\;\;\;\frac{\frac{x}{t}}{-z}\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+220}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(-z, t, y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-x}{z}}{t}\\
\end{array}
\end{array}
if (*.f64 z t) < -1e270Initial program 75.4%
Taylor expanded in y around 0 75.4%
associate-*r/75.4%
neg-mul-175.4%
Simplified75.4%
neg-mul-175.4%
*-commutative75.4%
times-frac99.9%
Applied egg-rr99.9%
*-commutative99.9%
frac-2neg99.9%
metadata-eval99.9%
un-div-inv99.9%
Applied egg-rr99.9%
if -1e270 < (*.f64 z t) < 2e220Initial program 99.8%
sub-neg99.8%
+-commutative99.8%
distribute-lft-neg-in99.8%
fma-def99.8%
Applied egg-rr99.8%
if 2e220 < (*.f64 z t) Initial program 76.2%
clear-num76.2%
associate-/r/76.2%
Applied egg-rr76.2%
Taylor expanded in y around 0 76.2%
associate-*r/76.2%
neg-mul-176.2%
*-commutative76.2%
associate-/r*99.8%
Simplified99.8%
Final simplification99.8%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= (* z t) -2e+26) (/ (/ x t) (- z)) (if (<= (* z t) 500000.0) (/ x y) (/ -1.0 (/ z (/ x t))))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -2e+26) {
tmp = (x / t) / -z;
} else if ((z * t) <= 500000.0) {
tmp = x / y;
} else {
tmp = -1.0 / (z / (x / t));
}
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) <= (-2d+26)) then
tmp = (x / t) / -z
else if ((z * t) <= 500000.0d0) then
tmp = x / y
else
tmp = (-1.0d0) / (z / (x / t))
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) <= -2e+26) {
tmp = (x / t) / -z;
} else if ((z * t) <= 500000.0) {
tmp = x / y;
} else {
tmp = -1.0 / (z / (x / t));
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if (z * t) <= -2e+26: tmp = (x / t) / -z elif (z * t) <= 500000.0: tmp = x / y else: tmp = -1.0 / (z / (x / t)) return tmp
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if (Float64(z * t) <= -2e+26) tmp = Float64(Float64(x / t) / Float64(-z)); elseif (Float64(z * t) <= 500000.0) tmp = Float64(x / y); else tmp = Float64(-1.0 / Float64(z / Float64(x / t))); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((z * t) <= -2e+26)
tmp = (x / t) / -z;
elseif ((z * t) <= 500000.0)
tmp = x / y;
else
tmp = -1.0 / (z / (x / t));
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], -2e+26], N[(N[(x / t), $MachinePrecision] / (-z)), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 500000.0], N[(x / y), $MachinePrecision], N[(-1.0 / N[(z / N[(x / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+26}:\\
\;\;\;\;\frac{\frac{x}{t}}{-z}\\
\mathbf{elif}\;z \cdot t \leq 500000:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{z}{\frac{x}{t}}}\\
\end{array}
\end{array}
if (*.f64 z t) < -2.0000000000000001e26Initial program 91.5%
Taylor expanded in y around 0 72.5%
associate-*r/72.5%
neg-mul-172.5%
Simplified72.5%
neg-mul-172.5%
*-commutative72.5%
times-frac78.2%
Applied egg-rr78.2%
*-commutative78.2%
frac-2neg78.2%
metadata-eval78.2%
un-div-inv78.3%
Applied egg-rr78.3%
if -2.0000000000000001e26 < (*.f64 z t) < 5e5Initial program 99.9%
Taylor expanded in y around inf 85.3%
if 5e5 < (*.f64 z t) Initial program 92.4%
add-cube-cbrt91.4%
pow391.4%
Applied egg-rr91.4%
Taylor expanded in y around 0 79.1%
associate-*r/79.9%
neg-mul-179.9%
Simplified79.1%
rem-cube-cbrt79.9%
neg-mul-179.9%
associate-/l*80.8%
*-commutative80.8%
add-sqr-sqrt46.1%
sqrt-unprod49.5%
sqr-neg49.5%
sqrt-unprod14.1%
add-sqr-sqrt31.3%
associate-/l*32.5%
add-sqr-sqrt15.2%
sqrt-unprod49.5%
sqr-neg49.5%
sqrt-unprod46.1%
add-sqr-sqrt81.8%
Applied egg-rr81.8%
Final simplification82.7%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= (* z t) -1e+270) (/ (/ x t) (- z)) (if (<= (* z t) 2e+220) (/ x (- y (* z t))) (/ (/ (- x) z) t))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -1e+270) {
tmp = (x / t) / -z;
} else if ((z * t) <= 2e+220) {
tmp = x / (y - (z * t));
} else {
tmp = (-x / z) / t;
}
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) <= (-1d+270)) then
tmp = (x / t) / -z
else if ((z * t) <= 2d+220) then
tmp = x / (y - (z * t))
else
tmp = (-x / z) / t
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) <= -1e+270) {
tmp = (x / t) / -z;
} else if ((z * t) <= 2e+220) {
tmp = x / (y - (z * t));
} else {
tmp = (-x / z) / t;
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if (z * t) <= -1e+270: tmp = (x / t) / -z elif (z * t) <= 2e+220: tmp = x / (y - (z * t)) else: tmp = (-x / z) / t return tmp
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if (Float64(z * t) <= -1e+270) tmp = Float64(Float64(x / t) / Float64(-z)); elseif (Float64(z * t) <= 2e+220) tmp = Float64(x / Float64(y - Float64(z * t))); else tmp = Float64(Float64(Float64(-x) / z) / t); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((z * t) <= -1e+270)
tmp = (x / t) / -z;
elseif ((z * t) <= 2e+220)
tmp = x / (y - (z * t));
else
tmp = (-x / z) / t;
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], -1e+270], N[(N[(x / t), $MachinePrecision] / (-z)), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+220], N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-x) / z), $MachinePrecision] / t), $MachinePrecision]]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+270}:\\
\;\;\;\;\frac{\frac{x}{t}}{-z}\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+220}:\\
\;\;\;\;\frac{x}{y - z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-x}{z}}{t}\\
\end{array}
\end{array}
if (*.f64 z t) < -1e270Initial program 75.4%
Taylor expanded in y around 0 75.4%
associate-*r/75.4%
neg-mul-175.4%
Simplified75.4%
neg-mul-175.4%
*-commutative75.4%
times-frac99.9%
Applied egg-rr99.9%
*-commutative99.9%
frac-2neg99.9%
metadata-eval99.9%
un-div-inv99.9%
Applied egg-rr99.9%
if -1e270 < (*.f64 z t) < 2e220Initial program 99.8%
if 2e220 < (*.f64 z t) Initial program 76.2%
clear-num76.2%
associate-/r/76.2%
Applied egg-rr76.2%
Taylor expanded in y around 0 76.2%
associate-*r/76.2%
neg-mul-176.2%
*-commutative76.2%
associate-/r*99.8%
Simplified99.8%
Final simplification99.8%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (or (<= (* z t) -2e+26) (not (<= (* z t) 500000.0))) (/ (- x) (* z t)) (/ x y)))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (((z * t) <= -2e+26) || !((z * t) <= 500000.0)) {
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 * t) <= (-2d+26)) .or. (.not. ((z * t) <= 500000.0d0))) 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 * t) <= -2e+26) || !((z * t) <= 500000.0)) {
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 * t) <= -2e+26) or not ((z * t) <= 500000.0): 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 ((Float64(z * t) <= -2e+26) || !(Float64(z * t) <= 500000.0)) 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 (((z * t) <= -2e+26) || ~(((z * t) <= 500000.0)))
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[N[(z * t), $MachinePrecision], -2e+26], N[Not[LessEqual[N[(z * t), $MachinePrecision], 500000.0]], $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 \cdot t \leq -2 \cdot 10^{+26} \lor \neg \left(z \cdot t \leq 500000\right):\\
\;\;\;\;\frac{-x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (*.f64 z t) < -2.0000000000000001e26 or 5e5 < (*.f64 z t) Initial program 92.0%
Taylor expanded in y around 0 76.2%
associate-*r/76.2%
neg-mul-176.2%
Simplified76.2%
if -2.0000000000000001e26 < (*.f64 z t) < 5e5Initial program 99.9%
Taylor expanded in y around inf 85.3%
Final simplification80.7%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (or (<= (* z t) -2e+26) (not (<= (* z t) 500000.0))) (/ (/ x t) (- z)) (/ x y)))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (((z * t) <= -2e+26) || !((z * t) <= 500000.0)) {
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 (((z * t) <= (-2d+26)) .or. (.not. ((z * t) <= 500000.0d0))) 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 (((z * t) <= -2e+26) || !((z * t) <= 500000.0)) {
tmp = (x / t) / -z;
} else {
tmp = x / y;
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if ((z * t) <= -2e+26) or not ((z * t) <= 500000.0): 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 ((Float64(z * t) <= -2e+26) || !(Float64(z * t) <= 500000.0)) 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 (((z * t) <= -2e+26) || ~(((z * t) <= 500000.0)))
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[Or[LessEqual[N[(z * t), $MachinePrecision], -2e+26], N[Not[LessEqual[N[(z * t), $MachinePrecision], 500000.0]], $MachinePrecision]], 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}\;z \cdot t \leq -2 \cdot 10^{+26} \lor \neg \left(z \cdot t \leq 500000\right):\\
\;\;\;\;\frac{\frac{x}{t}}{-z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (*.f64 z t) < -2.0000000000000001e26 or 5e5 < (*.f64 z t) Initial program 92.0%
Taylor expanded in y around 0 76.2%
associate-*r/76.2%
neg-mul-176.2%
Simplified76.2%
neg-mul-176.2%
*-commutative76.2%
times-frac80.1%
Applied egg-rr80.1%
*-commutative80.1%
frac-2neg80.1%
metadata-eval80.1%
un-div-inv80.2%
Applied egg-rr80.2%
if -2.0000000000000001e26 < (*.f64 z t) < 5e5Initial program 99.9%
Taylor expanded in y around inf 85.3%
Final simplification82.8%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (or (<= (* z t) -2.8e+118) (not (<= (* z t) 5.4e+138))) (/ x (* z t)) (/ x y)))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (((z * t) <= -2.8e+118) || !((z * t) <= 5.4e+138)) {
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 * t) <= (-2.8d+118)) .or. (.not. ((z * t) <= 5.4d+138))) 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 * t) <= -2.8e+118) || !((z * t) <= 5.4e+138)) {
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 * t) <= -2.8e+118) or not ((z * t) <= 5.4e+138): 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 ((Float64(z * t) <= -2.8e+118) || !(Float64(z * t) <= 5.4e+138)) 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 * t) <= -2.8e+118) || ~(((z * t) <= 5.4e+138)))
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[N[(z * t), $MachinePrecision], -2.8e+118], N[Not[LessEqual[N[(z * t), $MachinePrecision], 5.4e+138]], $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 \cdot t \leq -2.8 \cdot 10^{+118} \lor \neg \left(z \cdot t \leq 5.4 \cdot 10^{+138}\right):\\
\;\;\;\;\frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (*.f64 z t) < -2.79999999999999986e118 or 5.40000000000000018e138 < (*.f64 z t) Initial program 86.9%
add-cube-cbrt86.2%
pow386.2%
Applied egg-rr86.2%
Taylor expanded in y around 0 81.8%
associate-*r/82.4%
neg-mul-182.4%
Simplified81.8%
rem-cube-cbrt82.4%
add-sqr-sqrt31.3%
sqrt-unprod49.0%
sqr-neg49.0%
sqrt-unprod22.1%
add-sqr-sqrt43.6%
*-commutative43.6%
Applied egg-rr43.6%
if -2.79999999999999986e118 < (*.f64 z t) < 5.40000000000000018e138Initial program 99.8%
Taylor expanded in y around inf 71.0%
Final simplification62.6%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= (* z t) -2e+118) (/ x (* z t)) (if (<= (* z t) 2e+131) (/ x y) (/ (/ x t) z))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -2e+118) {
tmp = x / (z * t);
} else if ((z * t) <= 2e+131) {
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 ((z * t) <= (-2d+118)) then
tmp = x / (z * t)
else if ((z * t) <= 2d+131) 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 ((z * t) <= -2e+118) {
tmp = x / (z * t);
} else if ((z * t) <= 2e+131) {
tmp = x / y;
} else {
tmp = (x / t) / z;
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if (z * t) <= -2e+118: tmp = x / (z * t) elif (z * t) <= 2e+131: 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 (Float64(z * t) <= -2e+118) tmp = Float64(x / Float64(z * t)); elseif (Float64(z * t) <= 2e+131) 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 ((z * t) <= -2e+118)
tmp = x / (z * t);
elseif ((z * t) <= 2e+131)
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[N[(z * t), $MachinePrecision], -2e+118], N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+131], 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}\;z \cdot t \leq -2 \cdot 10^{+118}:\\
\;\;\;\;\frac{x}{z \cdot t}\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+131}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{t}}{z}\\
\end{array}
\end{array}
if (*.f64 z t) < -1.99999999999999993e118Initial program 86.4%
add-cube-cbrt85.5%
pow385.6%
Applied egg-rr85.6%
Taylor expanded in y around 0 78.6%
associate-*r/79.2%
neg-mul-179.2%
Simplified78.6%
rem-cube-cbrt79.2%
add-sqr-sqrt35.6%
sqrt-unprod49.4%
sqr-neg49.4%
sqrt-unprod17.0%
add-sqr-sqrt40.4%
*-commutative40.4%
Applied egg-rr40.4%
if -1.99999999999999993e118 < (*.f64 z t) < 1.9999999999999998e131Initial program 99.8%
Taylor expanded in y around inf 71.4%
if 1.9999999999999998e131 < (*.f64 z t) Initial program 88.3%
add-cube-cbrt87.7%
pow387.7%
Applied egg-rr87.7%
Taylor expanded in y around 0 83.8%
associate-*r/84.4%
neg-mul-184.4%
Simplified83.8%
rem-cube-cbrt84.4%
add-sqr-sqrt27.8%
sqrt-unprod49.0%
sqr-neg49.0%
sqrt-unprod26.9%
add-sqr-sqrt45.4%
associate-/r*47.1%
Applied egg-rr47.1%
Final simplification62.7%
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 95.9%
Taylor expanded in y around inf 54.9%
Final simplification54.9%
(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 2023200
(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))))