
(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}
(FPCore (x y z t) :precision binary64 (if (<= (* z t) 2e+280) (/ x (- y (* z t))) (/ -1.0 (* t (/ z x)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= 2e+280) {
tmp = x / (y - (z * t));
} else {
tmp = -1.0 / (t * (z / x));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((z * t) <= 2d+280) then
tmp = x / (y - (z * t))
else
tmp = (-1.0d0) / (t * (z / x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= 2e+280) {
tmp = x / (y - (z * t));
} else {
tmp = -1.0 / (t * (z / x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z * t) <= 2e+280: tmp = x / (y - (z * t)) else: tmp = -1.0 / (t * (z / x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(z * t) <= 2e+280) tmp = Float64(x / Float64(y - Float64(z * t))); else tmp = Float64(-1.0 / Float64(t * Float64(z / x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z * t) <= 2e+280) tmp = x / (y - (z * t)); else tmp = -1.0 / (t * (z / x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * t), $MachinePrecision], 2e+280], N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 / N[(t * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq 2 \cdot 10^{+280}:\\
\;\;\;\;\frac{x}{y - z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{t \cdot \frac{z}{x}}\\
\end{array}
\end{array}
if (*.f64 z t) < 2.0000000000000001e280Initial program 98.2%
if 2.0000000000000001e280 < (*.f64 z t) Initial program 68.0%
flip3--0.0%
clear-num0.0%
Applied egg-rr0.0%
Taylor expanded in y around 0 68.0%
associate-/r*68.0%
Simplified68.0%
clear-num67.9%
inv-pow67.9%
associate-/r/68.0%
*-un-lft-identity68.0%
times-frac99.8%
frac-2neg99.8%
metadata-eval99.8%
remove-double-div99.9%
metadata-eval99.9%
frac-2neg99.9%
clear-num99.8%
frac-2neg99.8%
metadata-eval99.8%
remove-double-div99.9%
Applied egg-rr99.9%
unpow-199.9%
associate-*r/68.0%
clear-num68.0%
remove-double-neg68.0%
distribute-lft-neg-in68.0%
frac-2neg68.0%
neg-mul-168.0%
associate-/l*68.0%
associate-*r/99.9%
Applied egg-rr99.9%
Final simplification98.4%
(FPCore (x y z t)
:precision binary64
(if (or (<= y -5.6e-14)
(not (or (<= y -3.6e-38) (and (not (<= y -1.2e-87)) (<= y 3.4e-45)))))
(/ x y)
(/ (- x) (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -5.6e-14) || !((y <= -3.6e-38) || (!(y <= -1.2e-87) && (y <= 3.4e-45)))) {
tmp = x / y;
} else {
tmp = -x / (z * t);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((y <= (-5.6d-14)) .or. (.not. (y <= (-3.6d-38)) .or. (.not. (y <= (-1.2d-87))) .and. (y <= 3.4d-45))) then
tmp = x / y
else
tmp = -x / (z * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -5.6e-14) || !((y <= -3.6e-38) || (!(y <= -1.2e-87) && (y <= 3.4e-45)))) {
tmp = x / y;
} else {
tmp = -x / (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -5.6e-14) or not ((y <= -3.6e-38) or (not (y <= -1.2e-87) and (y <= 3.4e-45))): tmp = x / y else: tmp = -x / (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -5.6e-14) || !((y <= -3.6e-38) || (!(y <= -1.2e-87) && (y <= 3.4e-45)))) tmp = Float64(x / y); else tmp = Float64(Float64(-x) / Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -5.6e-14) || ~(((y <= -3.6e-38) || (~((y <= -1.2e-87)) && (y <= 3.4e-45))))) tmp = x / y; else tmp = -x / (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -5.6e-14], N[Not[Or[LessEqual[y, -3.6e-38], And[N[Not[LessEqual[y, -1.2e-87]], $MachinePrecision], LessEqual[y, 3.4e-45]]]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[((-x) / N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.6 \cdot 10^{-14} \lor \neg \left(y \leq -3.6 \cdot 10^{-38} \lor \neg \left(y \leq -1.2 \cdot 10^{-87}\right) \land y \leq 3.4 \cdot 10^{-45}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{-x}{z \cdot t}\\
\end{array}
\end{array}
if y < -5.6000000000000001e-14 or -3.6000000000000001e-38 < y < -1.2e-87 or 3.40000000000000004e-45 < y Initial program 94.2%
Taylor expanded in y around inf 76.2%
if -5.6000000000000001e-14 < y < -3.6000000000000001e-38 or -1.2e-87 < y < 3.40000000000000004e-45Initial program 96.8%
Taylor expanded in y around 0 79.8%
associate-*r/79.8%
neg-mul-179.8%
Simplified79.8%
Final simplification77.5%
(FPCore (x y z t) :precision binary64 (if (<= t -1.65e-164) (/ (/ (- x) t) z) (if (<= t 1.1e+61) (/ x y) (/ -1.0 (* t (/ z x))))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.65e-164) {
tmp = (-x / t) / z;
} else if (t <= 1.1e+61) {
tmp = x / y;
} else {
tmp = -1.0 / (t * (z / x));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (t <= (-1.65d-164)) then
tmp = (-x / t) / z
else if (t <= 1.1d+61) then
tmp = x / y
else
tmp = (-1.0d0) / (t * (z / x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.65e-164) {
tmp = (-x / t) / z;
} else if (t <= 1.1e+61) {
tmp = x / y;
} else {
tmp = -1.0 / (t * (z / x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1.65e-164: tmp = (-x / t) / z elif t <= 1.1e+61: tmp = x / y else: tmp = -1.0 / (t * (z / x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1.65e-164) tmp = Float64(Float64(Float64(-x) / t) / z); elseif (t <= 1.1e+61) tmp = Float64(x / y); else tmp = Float64(-1.0 / Float64(t * Float64(z / x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1.65e-164) tmp = (-x / t) / z; elseif (t <= 1.1e+61) tmp = x / y; else tmp = -1.0 / (t * (z / x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.65e-164], N[(N[((-x) / t), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[t, 1.1e+61], N[(x / y), $MachinePrecision], N[(-1.0 / N[(t * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.65 \cdot 10^{-164}:\\
\;\;\;\;\frac{\frac{-x}{t}}{z}\\
\mathbf{elif}\;t \leq 1.1 \cdot 10^{+61}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{t \cdot \frac{z}{x}}\\
\end{array}
\end{array}
if t < -1.65e-164Initial program 95.8%
Taylor expanded in y around 0 57.2%
mul-1-neg57.2%
associate-/r*58.1%
distribute-neg-frac58.1%
Simplified58.1%
if -1.65e-164 < t < 1.1e61Initial program 99.9%
Taylor expanded in y around inf 77.7%
if 1.1e61 < t Initial program 84.8%
flip3--18.2%
clear-num18.1%
Applied egg-rr18.1%
Taylor expanded in y around 0 57.2%
associate-/r*57.2%
Simplified57.2%
clear-num57.1%
inv-pow57.1%
associate-/r/57.1%
*-un-lft-identity57.1%
times-frac72.0%
frac-2neg72.0%
metadata-eval72.0%
remove-double-div72.0%
metadata-eval72.0%
frac-2neg72.0%
clear-num72.0%
frac-2neg72.0%
metadata-eval72.0%
remove-double-div72.0%
Applied egg-rr72.0%
unpow-172.0%
associate-*r/57.1%
clear-num57.2%
remove-double-neg57.2%
distribute-lft-neg-in57.2%
frac-2neg57.2%
neg-mul-157.2%
associate-/l*57.1%
associate-*r/72.0%
Applied egg-rr72.0%
Final simplification69.5%
(FPCore (x y z t) :precision binary64 (if (or (<= t -1.65e-164) (not (<= t 1.6e+61))) (/ (/ (- x) t) z) (/ x y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.65e-164) || !(t <= 1.6e+61)) {
tmp = (-x / t) / z;
} else {
tmp = x / y;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((t <= (-1.65d-164)) .or. (.not. (t <= 1.6d+61))) then
tmp = (-x / t) / z
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.65e-164) || !(t <= 1.6e+61)) {
tmp = (-x / t) / z;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -1.65e-164) or not (t <= 1.6e+61): tmp = (-x / t) / z else: tmp = x / y return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -1.65e-164) || !(t <= 1.6e+61)) tmp = Float64(Float64(Float64(-x) / t) / z); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -1.65e-164) || ~((t <= 1.6e+61))) tmp = (-x / t) / z; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -1.65e-164], N[Not[LessEqual[t, 1.6e+61]], $MachinePrecision]], N[(N[((-x) / t), $MachinePrecision] / z), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.65 \cdot 10^{-164} \lor \neg \left(t \leq 1.6 \cdot 10^{+61}\right):\\
\;\;\;\;\frac{\frac{-x}{t}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if t < -1.65e-164 or 1.5999999999999999e61 < t Initial program 91.5%
Taylor expanded in y around 0 56.9%
mul-1-neg56.9%
associate-/r*63.5%
distribute-neg-frac63.5%
Simplified63.5%
if -1.65e-164 < t < 1.5999999999999999e61Initial program 99.9%
Taylor expanded in y around inf 77.1%
Final simplification69.3%
(FPCore (x y z t) :precision binary64 (if (<= t -1.65e-164) (/ (/ (- x) t) z) (if (<= t 2.7e+60) (/ x y) (/ (/ x z) (- t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.65e-164) {
tmp = (-x / t) / z;
} else if (t <= 2.7e+60) {
tmp = x / y;
} else {
tmp = (x / z) / -t;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (t <= (-1.65d-164)) then
tmp = (-x / t) / z
else if (t <= 2.7d+60) then
tmp = x / y
else
tmp = (x / z) / -t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.65e-164) {
tmp = (-x / t) / z;
} else if (t <= 2.7e+60) {
tmp = x / y;
} else {
tmp = (x / z) / -t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1.65e-164: tmp = (-x / t) / z elif t <= 2.7e+60: tmp = x / y else: tmp = (x / z) / -t return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1.65e-164) tmp = Float64(Float64(Float64(-x) / t) / z); elseif (t <= 2.7e+60) tmp = Float64(x / y); else tmp = Float64(Float64(x / z) / Float64(-t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1.65e-164) tmp = (-x / t) / z; elseif (t <= 2.7e+60) tmp = x / y; else tmp = (x / z) / -t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.65e-164], N[(N[((-x) / t), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[t, 2.7e+60], N[(x / y), $MachinePrecision], N[(N[(x / z), $MachinePrecision] / (-t)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.65 \cdot 10^{-164}:\\
\;\;\;\;\frac{\frac{-x}{t}}{z}\\
\mathbf{elif}\;t \leq 2.7 \cdot 10^{+60}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{z}}{-t}\\
\end{array}
\end{array}
if t < -1.65e-164Initial program 95.8%
Taylor expanded in y around 0 57.2%
mul-1-neg57.2%
associate-/r*58.1%
distribute-neg-frac58.1%
Simplified58.1%
if -1.65e-164 < t < 2.6999999999999999e60Initial program 99.9%
Taylor expanded in y around inf 77.7%
if 2.6999999999999999e60 < t Initial program 84.8%
*-un-lft-identity84.8%
*-commutative84.8%
add-sqr-sqrt84.7%
sqrt-unprod53.2%
sqr-neg53.2%
sqrt-unprod0.0%
add-sqr-sqrt54.5%
distribute-rgt-neg-in54.5%
neg-mul-154.5%
add-sqr-sqrt54.5%
sqrt-unprod42.8%
sqr-neg42.8%
sqrt-unprod0.0%
add-sqr-sqrt84.8%
distribute-rgt-neg-in84.8%
prod-diff69.5%
Applied egg-rr69.5%
fma-udef69.5%
distribute-rgt-neg-in69.5%
metadata-eval69.5%
distribute-rgt-in69.5%
+-commutative69.5%
fma-def69.5%
*-lft-identity69.5%
fma-def69.5%
*-commutative69.5%
fma-def69.5%
fma-udef69.5%
distribute-lft-out69.5%
*-commutative69.5%
metadata-eval69.5%
Simplified69.5%
+-commutative69.5%
associate-*l*69.5%
fma-def84.7%
Applied egg-rr84.7%
Taylor expanded in t around inf 57.2%
distribute-rgt1-in57.2%
metadata-eval57.2%
neg-mul-157.2%
distribute-rgt-neg-in57.2%
*-commutative57.2%
distribute-rgt-neg-out57.2%
associate-/r*72.1%
Simplified72.1%
Final simplification69.5%
(FPCore (x y z t) :precision binary64 (if (<= t -395000.0) (/ x (* z t)) (if (<= t 3.3e+252) (/ x y) (/ (/ x t) z))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -395000.0) {
tmp = x / (z * t);
} else if (t <= 3.3e+252) {
tmp = x / y;
} else {
tmp = (x / t) / z;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (t <= (-395000.0d0)) then
tmp = x / (z * t)
else if (t <= 3.3d+252) then
tmp = x / y
else
tmp = (x / t) / z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -395000.0) {
tmp = x / (z * t);
} else if (t <= 3.3e+252) {
tmp = x / y;
} else {
tmp = (x / t) / z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -395000.0: tmp = x / (z * t) elif t <= 3.3e+252: tmp = x / y else: tmp = (x / t) / z return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -395000.0) tmp = Float64(x / Float64(z * t)); elseif (t <= 3.3e+252) tmp = Float64(x / y); else tmp = Float64(Float64(x / t) / z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -395000.0) tmp = x / (z * t); elseif (t <= 3.3e+252) tmp = x / y; else tmp = (x / t) / z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -395000.0], N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 3.3e+252], N[(x / y), $MachinePrecision], N[(N[(x / t), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -395000:\\
\;\;\;\;\frac{x}{z \cdot t}\\
\mathbf{elif}\;t \leq 3.3 \cdot 10^{+252}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{t}}{z}\\
\end{array}
\end{array}
if t < -395000Initial program 94.1%
Taylor expanded in y around 0 62.5%
mul-1-neg62.5%
associate-/r*63.8%
distribute-neg-frac63.8%
Simplified63.8%
expm1-log1p-u60.0%
expm1-udef38.8%
add-sqr-sqrt27.8%
sqrt-unprod33.8%
sqr-neg33.8%
sqrt-unprod25.0%
add-sqr-sqrt32.1%
Applied egg-rr32.1%
expm1-def29.4%
expm1-log1p29.8%
associate-/r*28.2%
Simplified28.2%
if -395000 < t < 3.3000000000000001e252Initial program 97.2%
Taylor expanded in y around inf 65.7%
if 3.3000000000000001e252 < t Initial program 79.0%
flip3--6.1%
clear-num6.0%
Applied egg-rr6.0%
Taylor expanded in y around 0 59.6%
associate-/r*59.7%
Simplified59.7%
clear-num59.6%
inv-pow59.6%
associate-/r/59.6%
*-un-lft-identity59.6%
times-frac80.4%
frac-2neg80.4%
metadata-eval80.4%
remove-double-div80.4%
metadata-eval80.4%
frac-2neg80.4%
clear-num80.4%
frac-2neg80.4%
metadata-eval80.4%
remove-double-div80.4%
Applied egg-rr80.4%
unpow-180.4%
associate-*r/59.6%
clear-num59.7%
associate-/r*85.6%
add-sqr-sqrt0.0%
sqrt-unprod36.4%
sqr-neg36.4%
sqrt-unprod35.4%
add-sqr-sqrt35.4%
Applied egg-rr35.4%
Final simplification54.2%
(FPCore (x y z t) :precision binary64 (if (<= z 3.8e+20) (/ x y) (/ x (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 3.8e+20) {
tmp = x / y;
} else {
tmp = x / (z * t);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= 3.8d+20) then
tmp = x / y
else
tmp = x / (z * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= 3.8e+20) {
tmp = x / y;
} else {
tmp = x / (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= 3.8e+20: tmp = x / y else: tmp = x / (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= 3.8e+20) tmp = Float64(x / y); else tmp = Float64(x / Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= 3.8e+20) tmp = x / y; else tmp = x / (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, 3.8e+20], N[(x / y), $MachinePrecision], N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 3.8 \cdot 10^{+20}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z \cdot t}\\
\end{array}
\end{array}
if z < 3.8e20Initial program 98.0%
Taylor expanded in y around inf 64.2%
if 3.8e20 < z Initial program 87.0%
Taylor expanded in y around 0 61.0%
mul-1-neg61.0%
associate-/r*73.8%
distribute-neg-frac73.8%
Simplified73.8%
expm1-log1p-u70.4%
expm1-udef37.7%
add-sqr-sqrt22.4%
sqrt-unprod36.4%
sqr-neg36.4%
sqrt-unprod26.1%
add-sqr-sqrt34.8%
Applied egg-rr34.8%
expm1-def29.1%
expm1-log1p29.3%
associate-/r*29.6%
Simplified29.6%
Final simplification55.3%
(FPCore (x y z t) :precision binary64 (/ x y))
double code(double x, double y, double z, double t) {
return x / y;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x / y
end function
public static double code(double x, double y, double z, double t) {
return x / y;
}
def code(x, y, z, t): return x / y
function code(x, y, z, t) return Float64(x / y) end
function tmp = code(x, y, z, t) tmp = x / y; end
code[x_, y_, z_, t_] := N[(x / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y}
\end{array}
Initial program 95.1%
Taylor expanded in y around inf 56.6%
Final simplification56.6%
(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 2023318
(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))))