
(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: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= (* z t) 2e+269) (/ 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) <= 2e+269) {
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) <= 2d+269) 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) <= 2e+269) {
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) <= 2e+269: 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) <= 2e+269) tmp = Float64(x / Float64(y - Float64(z * t))); else tmp = Float64(Float64(x / z) / Float64(-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+269)
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], 2e+269], 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 2 \cdot 10^{+269}:\\
\;\;\;\;\frac{x}{y - z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{z}}{-t}\\
\end{array}
\end{array}
if (*.f64 z t) < 2.0000000000000001e269Initial program 98.6%
if 2.0000000000000001e269 < (*.f64 z t) Initial program 61.9%
*-un-lft-identity61.9%
*-commutative61.9%
*-commutative61.9%
add-sqr-sqrt37.2%
associate-*l*37.2%
prod-diff18.0%
Applied egg-rr18.0%
Taylor expanded in z around 0 37.2%
distribute-rgt1-in37.2%
metadata-eval37.2%
mul0-lft37.2%
Simplified37.2%
Taylor expanded in y around 0 61.9%
associate-*r/61.9%
times-frac99.9%
metadata-eval99.9%
associate-/r*99.9%
neg-mul-199.9%
associate-*l/99.9%
*-lft-identity99.9%
Simplified99.9%
Final simplification98.7%
NOTE: z and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(if (or (<= t -7.8e-96)
(and (not (<= t 3.3e-17))
(or (<= t 11500000.0) (not (<= t 3.2e+115)))))
(/ (/ (- x) t) z)
(/ x y)))assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -7.8e-96) || (!(t <= 3.3e-17) && ((t <= 11500000.0) || !(t <= 3.2e+115)))) {
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 ((t <= (-7.8d-96)) .or. (.not. (t <= 3.3d-17)) .and. (t <= 11500000.0d0) .or. (.not. (t <= 3.2d+115))) 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 ((t <= -7.8e-96) || (!(t <= 3.3e-17) && ((t <= 11500000.0) || !(t <= 3.2e+115)))) {
tmp = (-x / t) / z;
} else {
tmp = x / y;
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if (t <= -7.8e-96) or (not (t <= 3.3e-17) and ((t <= 11500000.0) or not (t <= 3.2e+115))): 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 ((t <= -7.8e-96) || (!(t <= 3.3e-17) && ((t <= 11500000.0) || !(t <= 3.2e+115)))) tmp = Float64(Float64(Float64(-x) / t) / 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 ((t <= -7.8e-96) || (~((t <= 3.3e-17)) && ((t <= 11500000.0) || ~((t <= 3.2e+115)))))
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[t, -7.8e-96], And[N[Not[LessEqual[t, 3.3e-17]], $MachinePrecision], Or[LessEqual[t, 11500000.0], N[Not[LessEqual[t, 3.2e+115]], $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}\;t \leq -7.8 \cdot 10^{-96} \lor \neg \left(t \leq 3.3 \cdot 10^{-17}\right) \land \left(t \leq 11500000 \lor \neg \left(t \leq 3.2 \cdot 10^{+115}\right)\right):\\
\;\;\;\;\frac{\frac{-x}{t}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if t < -7.7999999999999997e-96 or 3.3e-17 < t < 1.15e7 or 3.2e115 < t Initial program 90.7%
Taylor expanded in y around 0 63.2%
mul-1-neg63.2%
associate-/r*68.4%
distribute-neg-frac68.4%
Simplified68.4%
if -7.7999999999999997e-96 < t < 3.3e-17 or 1.15e7 < t < 3.2e115Initial program 99.9%
Taylor expanded in y around inf 69.9%
Final simplification69.2%
NOTE: z and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (/ x z) (- t))))
(if (<= z -6.5e+154)
t_1
(if (<= z -3.1e+136)
(/ x y)
(if (<= z -9e+90) t_1 (if (<= z 8e-81) (/ x y) (/ (/ (- x) t) z)))))))assert(z < t);
double code(double x, double y, double z, double t) {
double t_1 = (x / z) / -t;
double tmp;
if (z <= -6.5e+154) {
tmp = t_1;
} else if (z <= -3.1e+136) {
tmp = x / y;
} else if (z <= -9e+90) {
tmp = t_1;
} else if (z <= 8e-81) {
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) :: t_1
real(8) :: tmp
t_1 = (x / z) / -t
if (z <= (-6.5d+154)) then
tmp = t_1
else if (z <= (-3.1d+136)) then
tmp = x / y
else if (z <= (-9d+90)) then
tmp = t_1
else if (z <= 8d-81) 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 t_1 = (x / z) / -t;
double tmp;
if (z <= -6.5e+154) {
tmp = t_1;
} else if (z <= -3.1e+136) {
tmp = x / y;
} else if (z <= -9e+90) {
tmp = t_1;
} else if (z <= 8e-81) {
tmp = x / y;
} else {
tmp = (-x / t) / z;
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): t_1 = (x / z) / -t tmp = 0 if z <= -6.5e+154: tmp = t_1 elif z <= -3.1e+136: tmp = x / y elif z <= -9e+90: tmp = t_1 elif z <= 8e-81: tmp = x / y else: tmp = (-x / t) / z return tmp
z, t = sort([z, t]) function code(x, y, z, t) t_1 = Float64(Float64(x / z) / Float64(-t)) tmp = 0.0 if (z <= -6.5e+154) tmp = t_1; elseif (z <= -3.1e+136) tmp = Float64(x / y); elseif (z <= -9e+90) tmp = t_1; elseif (z <= 8e-81) tmp = Float64(x / y); else tmp = Float64(Float64(Float64(-x) / t) / z); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
t_1 = (x / z) / -t;
tmp = 0.0;
if (z <= -6.5e+154)
tmp = t_1;
elseif (z <= -3.1e+136)
tmp = x / y;
elseif (z <= -9e+90)
tmp = t_1;
elseif (z <= 8e-81)
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_] := Block[{t$95$1 = N[(N[(x / z), $MachinePrecision] / (-t)), $MachinePrecision]}, If[LessEqual[z, -6.5e+154], t$95$1, If[LessEqual[z, -3.1e+136], N[(x / y), $MachinePrecision], If[LessEqual[z, -9e+90], t$95$1, If[LessEqual[z, 8e-81], N[(x / y), $MachinePrecision], N[(N[((-x) / t), $MachinePrecision] / z), $MachinePrecision]]]]]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
t_1 := \frac{\frac{x}{z}}{-t}\\
\mathbf{if}\;z \leq -6.5 \cdot 10^{+154}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -3.1 \cdot 10^{+136}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;z \leq -9 \cdot 10^{+90}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 8 \cdot 10^{-81}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-x}{t}}{z}\\
\end{array}
\end{array}
if z < -6.5000000000000005e154 or -3.09999999999999983e136 < z < -9e90Initial program 88.8%
*-un-lft-identity88.8%
*-commutative88.8%
*-commutative88.8%
add-sqr-sqrt47.5%
associate-*l*47.5%
prod-diff40.4%
Applied egg-rr40.4%
Taylor expanded in z around 0 47.5%
distribute-rgt1-in47.5%
metadata-eval47.5%
mul0-lft47.5%
Simplified47.5%
Taylor expanded in y around 0 71.0%
associate-*r/71.0%
times-frac82.1%
metadata-eval82.1%
associate-/r*82.1%
neg-mul-182.1%
associate-*l/82.0%
*-lft-identity82.0%
Simplified82.0%
if -6.5000000000000005e154 < z < -3.09999999999999983e136 or -9e90 < z < 7.9999999999999997e-81Initial program 99.1%
Taylor expanded in y around inf 73.1%
if 7.9999999999999997e-81 < z Initial program 92.7%
Taylor expanded in y around 0 65.8%
mul-1-neg65.8%
associate-/r*67.4%
distribute-neg-frac67.4%
Simplified67.4%
Final simplification72.8%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (or (<= y -1.26e-18) (not (<= y 3.3e-11))) (/ x y) (/ (- x) (* z t))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.26e-18) || !(y <= 3.3e-11)) {
tmp = x / y;
} 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 ((y <= (-1.26d-18)) .or. (.not. (y <= 3.3d-11))) then
tmp = x / y
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 ((y <= -1.26e-18) || !(y <= 3.3e-11)) {
tmp = x / y;
} else {
tmp = -x / (z * t);
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if (y <= -1.26e-18) or not (y <= 3.3e-11): tmp = x / y else: tmp = -x / (z * t) return tmp
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if ((y <= -1.26e-18) || !(y <= 3.3e-11)) tmp = Float64(x / y); else tmp = Float64(Float64(-x) / Float64(z * t)); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((y <= -1.26e-18) || ~((y <= 3.3e-11)))
tmp = x / y;
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[Or[LessEqual[y, -1.26e-18], N[Not[LessEqual[y, 3.3e-11]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[((-x) / N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.26 \cdot 10^{-18} \lor \neg \left(y \leq 3.3 \cdot 10^{-11}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{-x}{z \cdot t}\\
\end{array}
\end{array}
if y < -1.26000000000000004e-18 or 3.3000000000000002e-11 < y Initial program 95.7%
Taylor expanded in y around inf 77.8%
if -1.26000000000000004e-18 < y < 3.3000000000000002e-11Initial program 95.2%
Taylor expanded in y around 0 71.1%
associate-*r/71.1%
neg-mul-171.1%
Simplified71.1%
Final simplification74.5%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (or (<= z -4.6e+235) (not (<= z 3.8e+57))) (/ x (* z t)) (/ x y)))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -4.6e+235) || !(z <= 3.8e+57)) {
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 <= (-4.6d+235)) .or. (.not. (z <= 3.8d+57))) 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 <= -4.6e+235) || !(z <= 3.8e+57)) {
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 <= -4.6e+235) or not (z <= 3.8e+57): 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 <= -4.6e+235) || !(z <= 3.8e+57)) 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 <= -4.6e+235) || ~((z <= 3.8e+57)))
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, -4.6e+235], N[Not[LessEqual[z, 3.8e+57]], $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 -4.6 \cdot 10^{+235} \lor \neg \left(z \leq 3.8 \cdot 10^{+57}\right):\\
\;\;\;\;\frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if z < -4.6e235 or 3.7999999999999999e57 < z Initial program 87.3%
Taylor expanded in y around 0 73.5%
mul-1-neg73.5%
associate-/r*76.3%
distribute-neg-frac76.3%
Simplified76.3%
expm1-log1p-u62.2%
expm1-udef36.1%
add-sqr-sqrt21.2%
sqrt-unprod36.2%
sqr-neg36.2%
sqrt-unprod21.9%
add-sqr-sqrt34.6%
Applied egg-rr34.6%
expm1-def31.3%
expm1-log1p31.5%
associate-/r*31.8%
Simplified31.8%
if -4.6e235 < z < 3.7999999999999999e57Initial program 97.9%
Taylor expanded in y around inf 62.8%
Final simplification55.7%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= z -9.2e+157) (/ (/ x z) t) (if (<= z 3.8e+57) (/ x y) (/ x (* z t)))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -9.2e+157) {
tmp = (x / z) / t;
} else if (z <= 3.8e+57) {
tmp = x / y;
} 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 <= (-9.2d+157)) then
tmp = (x / z) / t
else if (z <= 3.8d+57) then
tmp = x / y
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 <= -9.2e+157) {
tmp = (x / z) / t;
} else if (z <= 3.8e+57) {
tmp = x / y;
} else {
tmp = x / (z * t);
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if z <= -9.2e+157: tmp = (x / z) / t elif z <= 3.8e+57: tmp = x / y else: tmp = x / (z * t) return tmp
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if (z <= -9.2e+157) tmp = Float64(Float64(x / z) / t); elseif (z <= 3.8e+57) tmp = Float64(x / y); else tmp = Float64(x / Float64(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 <= -9.2e+157)
tmp = (x / z) / t;
elseif (z <= 3.8e+57)
tmp = x / y;
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[z, -9.2e+157], N[(N[(x / z), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[z, 3.8e+57], N[(x / y), $MachinePrecision], N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.2 \cdot 10^{+157}:\\
\;\;\;\;\frac{\frac{x}{z}}{t}\\
\mathbf{elif}\;z \leq 3.8 \cdot 10^{+57}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z \cdot t}\\
\end{array}
\end{array}
if z < -9.20000000000000015e157Initial program 88.3%
Taylor expanded in y around 0 71.1%
mul-1-neg71.1%
associate-/r*71.0%
distribute-neg-frac71.0%
Simplified71.0%
expm1-log1p-u64.3%
expm1-udef40.6%
add-sqr-sqrt26.1%
sqrt-unprod40.2%
sqr-neg40.2%
sqrt-unprod23.4%
add-sqr-sqrt40.3%
Applied egg-rr40.3%
expm1-def35.1%
expm1-log1p35.1%
associate-/r*35.3%
Simplified35.3%
expm1-log1p-u35.3%
expm1-udef40.3%
Applied egg-rr40.3%
expm1-def35.3%
expm1-log1p35.3%
*-commutative35.3%
associate-/r*39.7%
Simplified39.7%
if -9.20000000000000015e157 < z < 3.7999999999999999e57Initial program 98.7%
Taylor expanded in y around inf 66.4%
if 3.7999999999999999e57 < z Initial program 88.1%
Taylor expanded in y around 0 74.0%
mul-1-neg74.0%
associate-/r*77.6%
distribute-neg-frac77.6%
Simplified77.6%
expm1-log1p-u60.1%
expm1-udef38.1%
add-sqr-sqrt24.1%
sqrt-unprod38.2%
sqr-neg38.2%
sqrt-unprod22.8%
add-sqr-sqrt36.2%
Applied egg-rr36.2%
expm1-def32.2%
expm1-log1p32.5%
associate-/r*32.8%
Simplified32.8%
Final simplification56.9%
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.4%
Taylor expanded in y around inf 54.8%
Final simplification54.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 2023320
(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))))