
(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: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= (* z t) 2e+244) (/ x (fma z (- t) y)) (/ (- (/ x t)) z)))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= 2e+244) {
tmp = x / fma(z, -t, 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 (Float64(z * t) <= 2e+244) tmp = Float64(x / fma(z, Float64(-t), y)); else tmp = Float64(Float64(-Float64(x / t)) / z); end return 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[N[(z * t), $MachinePrecision], 2e+244], N[(x / N[(z * (-t) + y), $MachinePrecision]), $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}\;z \cdot t \leq 2 \cdot 10^{+244}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(z, -t, y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\frac{x}{t}}{z}\\
\end{array}
\end{array}
if (*.f64 z t) < 2.00000000000000015e244Initial program 98.6%
cancel-sign-sub-inv98.6%
+-commutative98.6%
distribute-lft-neg-out98.6%
distribute-rgt-neg-out98.6%
fma-def98.7%
Simplified98.7%
if 2.00000000000000015e244 < (*.f64 z t) Initial program 76.6%
Taylor expanded in y around 0 76.6%
mul-1-neg76.6%
associate-/r*99.9%
distribute-neg-frac99.9%
Simplified99.9%
Final simplification98.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 (<= (* z t) 2e+244) (/ x (- y (* z t))) (/ (- (/ x t)) z)))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= 2e+244) {
tmp = x / (y - (z * t));
} 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 ((z * t) <= 2d+244) then
tmp = x / (y - (z * t))
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 ((z * t) <= 2e+244) {
tmp = x / (y - (z * t));
} 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 (z * t) <= 2e+244: tmp = x / (y - (z * t)) 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 (Float64(z * t) <= 2e+244) tmp = Float64(x / Float64(y - Float64(z * t))); else tmp = Float64(Float64(-Float64(x / 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 ((z * t) <= 2e+244)
tmp = x / (y - (z * t));
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[N[(z * t), $MachinePrecision], 2e+244], N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $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}\;z \cdot t \leq 2 \cdot 10^{+244}:\\
\;\;\;\;\frac{x}{y - z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\frac{x}{t}}{z}\\
\end{array}
\end{array}
if (*.f64 z t) < 2.00000000000000015e244Initial program 98.6%
if 2.00000000000000015e244 < (*.f64 z t) Initial program 76.6%
Taylor expanded in y around 0 76.6%
mul-1-neg76.6%
associate-/r*99.9%
distribute-neg-frac99.9%
Simplified99.9%
Final simplification98.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 (or (<= t -1.65e-103) (not (<= t 12500000.0))) (/ (- 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 ((t <= -1.65e-103) || !(t <= 12500000.0)) {
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 ((t <= (-1.65d-103)) .or. (.not. (t <= 12500000.0d0))) 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 ((t <= -1.65e-103) || !(t <= 12500000.0)) {
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 (t <= -1.65e-103) or not (t <= 12500000.0): 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 ((t <= -1.65e-103) || !(t <= 12500000.0)) tmp = Float64(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 ((t <= -1.65e-103) || ~((t <= 12500000.0)))
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[t, -1.65e-103], N[Not[LessEqual[t, 12500000.0]], $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}\;t \leq -1.65 \cdot 10^{-103} \lor \neg \left(t \leq 12500000\right):\\
\;\;\;\;\frac{-x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if t < -1.64999999999999995e-103 or 1.25e7 < t Initial program 94.3%
Taylor expanded in y around 0 71.3%
associate-*r/71.3%
neg-mul-171.3%
Simplified71.3%
if -1.64999999999999995e-103 < t < 1.25e7Initial program 100.0%
Taylor expanded in y around inf 81.7%
Final simplification75.3%
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 -1.65e-103) (not (<= t 1800000.0))) (/ (- (/ 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 <= -1.65e-103) || !(t <= 1800000.0)) {
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 <= (-1.65d-103)) .or. (.not. (t <= 1800000.0d0))) 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 <= -1.65e-103) || !(t <= 1800000.0)) {
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 <= -1.65e-103) or not (t <= 1800000.0): 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 <= -1.65e-103) || !(t <= 1800000.0)) tmp = Float64(Float64(-Float64(x / 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 <= -1.65e-103) || ~((t <= 1800000.0)))
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, -1.65e-103], N[Not[LessEqual[t, 1800000.0]], $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 -1.65 \cdot 10^{-103} \lor \neg \left(t \leq 1800000\right):\\
\;\;\;\;\frac{-\frac{x}{t}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if t < -1.64999999999999995e-103 or 1.8e6 < t Initial program 94.3%
Taylor expanded in y around 0 71.3%
mul-1-neg71.3%
associate-/r*74.8%
distribute-neg-frac74.8%
Simplified74.8%
if -1.64999999999999995e-103 < t < 1.8e6Initial program 100.0%
Taylor expanded in y around inf 81.7%
Final simplification77.5%
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 -1.4e-103) (/ (/ x z) (- t)) (if (<= t 10200000.0) (/ 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 <= -1.4e-103) {
tmp = (x / z) / -t;
} else if (t <= 10200000.0) {
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 <= (-1.4d-103)) then
tmp = (x / z) / -t
else if (t <= 10200000.0d0) 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 <= -1.4e-103) {
tmp = (x / z) / -t;
} else if (t <= 10200000.0) {
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 <= -1.4e-103: tmp = (x / z) / -t elif t <= 10200000.0: 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 <= -1.4e-103) tmp = Float64(Float64(x / z) / Float64(-t)); elseif (t <= 10200000.0) tmp = Float64(x / y); else tmp = Float64(Float64(-Float64(x / 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 <= -1.4e-103)
tmp = (x / z) / -t;
elseif (t <= 10200000.0)
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, -1.4e-103], N[(N[(x / z), $MachinePrecision] / (-t)), $MachinePrecision], If[LessEqual[t, 10200000.0], 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 -1.4 \cdot 10^{-103}:\\
\;\;\;\;\frac{\frac{x}{z}}{-t}\\
\mathbf{elif}\;t \leq 10200000:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\frac{x}{t}}{z}\\
\end{array}
\end{array}
if t < -1.40000000000000011e-103Initial program 94.6%
Taylor expanded in y around 0 67.1%
mul-1-neg67.1%
associate-/r*71.5%
distribute-neg-frac71.5%
Simplified71.5%
distribute-neg-frac71.5%
associate-/r*67.1%
neg-mul-167.1%
times-frac69.4%
Applied egg-rr69.4%
*-commutative69.4%
frac-2neg69.4%
metadata-eval69.4%
un-div-inv69.4%
Applied egg-rr69.4%
if -1.40000000000000011e-103 < t < 1.02e7Initial program 100.0%
Taylor expanded in y around inf 81.7%
if 1.02e7 < t Initial program 93.7%
Taylor expanded in y around 0 77.6%
mul-1-neg77.6%
associate-/r*79.7%
distribute-neg-frac79.7%
Simplified79.7%
Final simplification76.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 (or (<= z -1.6e+263) (not (<= z 0.00043))) (/ 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 <= -1.6e+263) || !(z <= 0.00043)) {
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 <= (-1.6d+263)) .or. (.not. (z <= 0.00043d0))) 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 <= -1.6e+263) || !(z <= 0.00043)) {
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 <= -1.6e+263) or not (z <= 0.00043): 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 <= -1.6e+263) || !(z <= 0.00043)) 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 <= -1.6e+263) || ~((z <= 0.00043)))
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, -1.6e+263], N[Not[LessEqual[z, 0.00043]], $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 -1.6 \cdot 10^{+263} \lor \neg \left(z \leq 0.00043\right):\\
\;\;\;\;\frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if z < -1.6e263 or 4.29999999999999989e-4 < z Initial program 93.7%
Taylor expanded in y around 0 77.5%
mul-1-neg77.5%
associate-/r*83.7%
distribute-neg-frac83.7%
Simplified83.7%
distribute-neg-frac83.7%
associate-/r*77.5%
expm1-log1p-u73.1%
expm1-udef57.4%
add-sqr-sqrt27.1%
sqrt-unprod50.9%
sqr-neg50.9%
sqrt-unprod26.6%
add-sqr-sqrt53.8%
Applied egg-rr53.8%
expm1-def48.1%
expm1-log1p48.2%
Simplified48.2%
if -1.6e263 < z < 4.29999999999999989e-4Initial program 97.7%
Taylor expanded in y around inf 63.3%
Final simplification58.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 (<= z -2.2e+213) (/ (/ x z) t) (if (<= z 0.00066) (/ 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 <= -2.2e+213) {
tmp = (x / z) / t;
} else if (z <= 0.00066) {
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 <= (-2.2d+213)) then
tmp = (x / z) / t
else if (z <= 0.00066d0) 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 <= -2.2e+213) {
tmp = (x / z) / t;
} else if (z <= 0.00066) {
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 <= -2.2e+213: tmp = (x / z) / t elif z <= 0.00066: 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 <= -2.2e+213) tmp = Float64(Float64(x / z) / t); elseif (z <= 0.00066) 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 <= -2.2e+213)
tmp = (x / z) / t;
elseif (z <= 0.00066)
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, -2.2e+213], N[(N[(x / z), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[z, 0.00066], 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 -2.2 \cdot 10^{+213}:\\
\;\;\;\;\frac{\frac{x}{z}}{t}\\
\mathbf{elif}\;z \leq 0.00066:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z \cdot t}\\
\end{array}
\end{array}
if z < -2.1999999999999999e213Initial program 87.5%
Taylor expanded in y around 0 81.4%
mul-1-neg81.4%
associate-/r*93.7%
distribute-neg-frac93.7%
Simplified93.7%
distribute-neg-frac93.7%
associate-/r*81.4%
neg-mul-181.4%
times-frac96.8%
Applied egg-rr96.8%
associate-*l/96.8%
associate-*r/96.8%
neg-mul-196.8%
add-sqr-sqrt0.0%
sqrt-unprod63.0%
sqr-neg63.0%
sqrt-unprod62.3%
add-sqr-sqrt62.3%
frac-2neg62.3%
Applied egg-rr62.3%
if -2.1999999999999999e213 < z < 6.6e-4Initial program 98.7%
Taylor expanded in y around inf 64.6%
if 6.6e-4 < z Initial program 94.6%
Taylor expanded in y around 0 72.3%
mul-1-neg72.3%
associate-/r*77.6%
distribute-neg-frac77.6%
Simplified77.6%
distribute-neg-frac77.6%
associate-/r*72.3%
expm1-log1p-u66.2%
expm1-udef53.1%
add-sqr-sqrt24.4%
sqrt-unprod46.0%
sqr-neg46.0%
sqrt-unprod23.6%
add-sqr-sqrt48.1%
Applied egg-rr48.1%
expm1-def40.4%
expm1-log1p40.5%
Simplified40.5%
Final simplification59.1%
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 96.5%
Taylor expanded in y around inf 53.8%
Final simplification53.8%
(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 2023322
(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))))