
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= z -1e-34) (not (<= z 2e-44))) (* x (/ (+ (- y z) 1.0) z)) (/ (* x (+ y 1.0)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1e-34) || !(z <= 2e-44)) {
tmp = x * (((y - z) + 1.0) / z);
} else {
tmp = (x * (y + 1.0)) / z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1d-34)) .or. (.not. (z <= 2d-44))) then
tmp = x * (((y - z) + 1.0d0) / z)
else
tmp = (x * (y + 1.0d0)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1e-34) || !(z <= 2e-44)) {
tmp = x * (((y - z) + 1.0) / z);
} else {
tmp = (x * (y + 1.0)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1e-34) or not (z <= 2e-44): tmp = x * (((y - z) + 1.0) / z) else: tmp = (x * (y + 1.0)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1e-34) || !(z <= 2e-44)) tmp = Float64(x * Float64(Float64(Float64(y - z) + 1.0) / z)); else tmp = Float64(Float64(x * Float64(y + 1.0)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1e-34) || ~((z <= 2e-44))) tmp = x * (((y - z) + 1.0) / z); else tmp = (x * (y + 1.0)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1e-34], N[Not[LessEqual[z, 2e-44]], $MachinePrecision]], N[(x * N[(N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(y + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{-34} \lor \neg \left(z \leq 2 \cdot 10^{-44}\right):\\
\;\;\;\;x \cdot \frac{\left(y - z\right) + 1}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(y + 1\right)}{z}\\
\end{array}
\end{array}
if z < -9.99999999999999928e-35 or 1.99999999999999991e-44 < z Initial program 79.1%
Taylor expanded in x around 0 79.1%
associate--l+79.1%
+-commutative79.1%
associate-*r/99.9%
+-commutative99.9%
Simplified99.9%
if -9.99999999999999928e-35 < z < 1.99999999999999991e-44Initial program 100.0%
Taylor expanded in z around 0 100.0%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (- y z) 1.0))) (if (<= (/ (* x t_0) z) 2e+158) (/ x (/ z t_0)) (/ t_0 (/ z x)))))
double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if (((x * t_0) / z) <= 2e+158) {
tmp = x / (z / t_0);
} else {
tmp = t_0 / (z / x);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (y - z) + 1.0d0
if (((x * t_0) / z) <= 2d+158) then
tmp = x / (z / t_0)
else
tmp = t_0 / (z / x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if (((x * t_0) / z) <= 2e+158) {
tmp = x / (z / t_0);
} else {
tmp = t_0 / (z / x);
}
return tmp;
}
def code(x, y, z): t_0 = (y - z) + 1.0 tmp = 0 if ((x * t_0) / z) <= 2e+158: tmp = x / (z / t_0) else: tmp = t_0 / (z / x) return tmp
function code(x, y, z) t_0 = Float64(Float64(y - z) + 1.0) tmp = 0.0 if (Float64(Float64(x * t_0) / z) <= 2e+158) tmp = Float64(x / Float64(z / t_0)); else tmp = Float64(t_0 / Float64(z / x)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y - z) + 1.0; tmp = 0.0; if (((x * t_0) / z) <= 2e+158) tmp = x / (z / t_0); else tmp = t_0 / (z / x); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[N[(N[(x * t$95$0), $MachinePrecision] / z), $MachinePrecision], 2e+158], N[(x / N[(z / t$95$0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[(z / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y - z\right) + 1\\
\mathbf{if}\;\frac{x \cdot t_0}{z} \leq 2 \cdot 10^{+158}:\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{\frac{z}{x}}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < 1.99999999999999991e158Initial program 88.8%
Taylor expanded in x around 0 88.8%
associate--l+88.8%
+-commutative88.8%
associate-*r/97.9%
+-commutative97.9%
Simplified97.9%
clear-num97.8%
un-div-inv97.9%
Applied egg-rr97.9%
if 1.99999999999999991e158 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) Initial program 84.7%
Taylor expanded in x around 0 84.7%
associate--l+84.7%
+-commutative84.7%
associate-*r/90.7%
+-commutative90.7%
Simplified90.7%
associate-*r/84.7%
associate-*l/99.8%
*-commutative99.8%
clear-num99.8%
un-div-inv99.9%
Applied egg-rr99.9%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (- y z) 1.0))) (if (<= (/ (* x t_0) z) 5e-89) (/ x (/ z t_0)) (* t_0 (/ x z)))))
double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if (((x * t_0) / z) <= 5e-89) {
tmp = x / (z / t_0);
} else {
tmp = t_0 * (x / z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (y - z) + 1.0d0
if (((x * t_0) / z) <= 5d-89) then
tmp = x / (z / t_0)
else
tmp = t_0 * (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if (((x * t_0) / z) <= 5e-89) {
tmp = x / (z / t_0);
} else {
tmp = t_0 * (x / z);
}
return tmp;
}
def code(x, y, z): t_0 = (y - z) + 1.0 tmp = 0 if ((x * t_0) / z) <= 5e-89: tmp = x / (z / t_0) else: tmp = t_0 * (x / z) return tmp
function code(x, y, z) t_0 = Float64(Float64(y - z) + 1.0) tmp = 0.0 if (Float64(Float64(x * t_0) / z) <= 5e-89) tmp = Float64(x / Float64(z / t_0)); else tmp = Float64(t_0 * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y - z) + 1.0; tmp = 0.0; if (((x * t_0) / z) <= 5e-89) tmp = x / (z / t_0); else tmp = t_0 * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[N[(N[(x * t$95$0), $MachinePrecision] / z), $MachinePrecision], 5e-89], N[(x / N[(z / t$95$0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y - z\right) + 1\\
\mathbf{if}\;\frac{x \cdot t_0}{z} \leq 5 \cdot 10^{-89}:\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{x}{z}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < 4.99999999999999967e-89Initial program 87.1%
Taylor expanded in x around 0 87.1%
associate--l+87.1%
+-commutative87.1%
associate-*r/97.6%
+-commutative97.6%
Simplified97.6%
clear-num97.5%
un-div-inv97.7%
Applied egg-rr97.7%
if 4.99999999999999967e-89 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) Initial program 89.3%
associate-/l*93.5%
associate-/r/99.8%
Applied egg-rr99.8%
Final simplification98.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -4.7e+126)
(- x)
(if (<= z -1.7e-90)
(* x (/ y z))
(if (<= z -8.3e-137)
(/ x z)
(if (<= z -1.15e-171)
t_0
(if (<= z 6.8e-71) (/ x z) (if (<= z 4.5e+46) t_0 (- x)))))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -4.7e+126) {
tmp = -x;
} else if (z <= -1.7e-90) {
tmp = x * (y / z);
} else if (z <= -8.3e-137) {
tmp = x / z;
} else if (z <= -1.15e-171) {
tmp = t_0;
} else if (z <= 6.8e-71) {
tmp = x / z;
} else if (z <= 4.5e+46) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = y * (x / z)
if (z <= (-4.7d+126)) then
tmp = -x
else if (z <= (-1.7d-90)) then
tmp = x * (y / z)
else if (z <= (-8.3d-137)) then
tmp = x / z
else if (z <= (-1.15d-171)) then
tmp = t_0
else if (z <= 6.8d-71) then
tmp = x / z
else if (z <= 4.5d+46) then
tmp = t_0
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -4.7e+126) {
tmp = -x;
} else if (z <= -1.7e-90) {
tmp = x * (y / z);
} else if (z <= -8.3e-137) {
tmp = x / z;
} else if (z <= -1.15e-171) {
tmp = t_0;
} else if (z <= 6.8e-71) {
tmp = x / z;
} else if (z <= 4.5e+46) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -4.7e+126: tmp = -x elif z <= -1.7e-90: tmp = x * (y / z) elif z <= -8.3e-137: tmp = x / z elif z <= -1.15e-171: tmp = t_0 elif z <= 6.8e-71: tmp = x / z elif z <= 4.5e+46: tmp = t_0 else: tmp = -x return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x / z)) tmp = 0.0 if (z <= -4.7e+126) tmp = Float64(-x); elseif (z <= -1.7e-90) tmp = Float64(x * Float64(y / z)); elseif (z <= -8.3e-137) tmp = Float64(x / z); elseif (z <= -1.15e-171) tmp = t_0; elseif (z <= 6.8e-71) tmp = Float64(x / z); elseif (z <= 4.5e+46) tmp = t_0; else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (x / z); tmp = 0.0; if (z <= -4.7e+126) tmp = -x; elseif (z <= -1.7e-90) tmp = x * (y / z); elseif (z <= -8.3e-137) tmp = x / z; elseif (z <= -1.15e-171) tmp = t_0; elseif (z <= 6.8e-71) tmp = x / z; elseif (z <= 4.5e+46) tmp = t_0; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.7e+126], (-x), If[LessEqual[z, -1.7e-90], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -8.3e-137], N[(x / z), $MachinePrecision], If[LessEqual[z, -1.15e-171], t$95$0, If[LessEqual[z, 6.8e-71], N[(x / z), $MachinePrecision], If[LessEqual[z, 4.5e+46], t$95$0, (-x)]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -4.7 \cdot 10^{+126}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -1.7 \cdot 10^{-90}:\\
\;\;\;\;x \cdot \frac{y}{z}\\
\mathbf{elif}\;z \leq -8.3 \cdot 10^{-137}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq -1.15 \cdot 10^{-171}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 6.8 \cdot 10^{-71}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{+46}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -4.6999999999999999e126 or 4.5000000000000001e46 < z Initial program 73.3%
Taylor expanded in z around inf 83.4%
neg-mul-183.4%
Simplified83.4%
if -4.6999999999999999e126 < z < -1.69999999999999997e-90Initial program 88.3%
Taylor expanded in x around 0 88.3%
associate--l+88.3%
+-commutative88.3%
associate-*r/99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in y around inf 50.2%
associate-*r/55.9%
Simplified55.9%
if -1.69999999999999997e-90 < z < -8.30000000000000018e-137 or -1.14999999999999989e-171 < z < 6.80000000000000007e-71Initial program 100.0%
Taylor expanded in y around 0 72.5%
associate-/l*72.5%
associate-/r/72.5%
Simplified72.5%
Taylor expanded in z around 0 72.5%
if -8.30000000000000018e-137 < z < -1.14999999999999989e-171 or 6.80000000000000007e-71 < z < 4.5000000000000001e46Initial program 97.3%
Taylor expanded in y around inf 70.2%
associate-/l*65.1%
associate-/r/75.0%
Simplified75.0%
Final simplification73.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ y z))))
(if (<= z -4.7e+126)
(- x)
(if (<= z -2e-87)
t_0
(if (<= z 1.02e-70) (/ x z) (if (<= z 5.8e+47) t_0 (- x)))))))
double code(double x, double y, double z) {
double t_0 = x * (y / z);
double tmp;
if (z <= -4.7e+126) {
tmp = -x;
} else if (z <= -2e-87) {
tmp = t_0;
} else if (z <= 1.02e-70) {
tmp = x / z;
} else if (z <= 5.8e+47) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = x * (y / z)
if (z <= (-4.7d+126)) then
tmp = -x
else if (z <= (-2d-87)) then
tmp = t_0
else if (z <= 1.02d-70) then
tmp = x / z
else if (z <= 5.8d+47) then
tmp = t_0
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (y / z);
double tmp;
if (z <= -4.7e+126) {
tmp = -x;
} else if (z <= -2e-87) {
tmp = t_0;
} else if (z <= 1.02e-70) {
tmp = x / z;
} else if (z <= 5.8e+47) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y / z) tmp = 0 if z <= -4.7e+126: tmp = -x elif z <= -2e-87: tmp = t_0 elif z <= 1.02e-70: tmp = x / z elif z <= 5.8e+47: tmp = t_0 else: tmp = -x return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y / z)) tmp = 0.0 if (z <= -4.7e+126) tmp = Float64(-x); elseif (z <= -2e-87) tmp = t_0; elseif (z <= 1.02e-70) tmp = Float64(x / z); elseif (z <= 5.8e+47) tmp = t_0; else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (y / z); tmp = 0.0; if (z <= -4.7e+126) tmp = -x; elseif (z <= -2e-87) tmp = t_0; elseif (z <= 1.02e-70) tmp = x / z; elseif (z <= 5.8e+47) tmp = t_0; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.7e+126], (-x), If[LessEqual[z, -2e-87], t$95$0, If[LessEqual[z, 1.02e-70], N[(x / z), $MachinePrecision], If[LessEqual[z, 5.8e+47], t$95$0, (-x)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{y}{z}\\
\mathbf{if}\;z \leq -4.7 \cdot 10^{+126}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -2 \cdot 10^{-87}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.02 \cdot 10^{-70}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 5.8 \cdot 10^{+47}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -4.6999999999999999e126 or 5.79999999999999961e47 < z Initial program 73.3%
Taylor expanded in z around inf 83.4%
neg-mul-183.4%
Simplified83.4%
if -4.6999999999999999e126 < z < -2.00000000000000004e-87 or 1.0200000000000001e-70 < z < 5.79999999999999961e47Initial program 91.6%
Taylor expanded in x around 0 91.6%
associate--l+91.6%
+-commutative91.6%
associate-*r/97.4%
+-commutative97.4%
Simplified97.4%
Taylor expanded in y around inf 56.5%
associate-*r/58.8%
Simplified58.8%
if -2.00000000000000004e-87 < z < 1.0200000000000001e-70Initial program 100.0%
Taylor expanded in y around 0 69.1%
associate-/l*69.1%
associate-/r/69.1%
Simplified69.1%
Taylor expanded in z around 0 69.1%
Final simplification71.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -40000000000.0) (not (<= y 7.8e+44))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -40000000000.0) || !(y <= 7.8e+44)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-40000000000.0d0)) .or. (.not. (y <= 7.8d+44))) then
tmp = y * (x / z)
else
tmp = (x / z) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -40000000000.0) || !(y <= 7.8e+44)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -40000000000.0) or not (y <= 7.8e+44): tmp = y * (x / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -40000000000.0) || !(y <= 7.8e+44)) tmp = Float64(y * Float64(x / z)); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -40000000000.0) || ~((y <= 7.8e+44))) tmp = y * (x / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -40000000000.0], N[Not[LessEqual[y, 7.8e+44]], $MachinePrecision]], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -40000000000 \lor \neg \left(y \leq 7.8 \cdot 10^{+44}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -4e10 or 7.8000000000000005e44 < y Initial program 89.5%
Taylor expanded in y around inf 75.5%
associate-/l*72.7%
associate-/r/75.7%
Simplified75.7%
if -4e10 < y < 7.8000000000000005e44Initial program 86.6%
Taylor expanded in x around 0 86.6%
associate--l+86.6%
+-commutative86.6%
associate-*r/99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 85.0%
*-commutative85.0%
associate-/l*83.1%
div-sub78.4%
associate-/r/78.4%
associate-*l/78.6%
*-lft-identity78.6%
associate-/r/98.4%
*-inverses98.4%
*-lft-identity98.4%
Simplified98.4%
Final simplification88.8%
(FPCore (x y z) :precision binary64 (if (<= y -2000000000000.0) (/ (* x y) z) (if (<= y 4.8e+43) (- (/ x z) x) (* y (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2000000000000.0) {
tmp = (x * y) / z;
} else if (y <= 4.8e+43) {
tmp = (x / z) - x;
} else {
tmp = y * (x / z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-2000000000000.0d0)) then
tmp = (x * y) / z
else if (y <= 4.8d+43) then
tmp = (x / z) - x
else
tmp = y * (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2000000000000.0) {
tmp = (x * y) / z;
} else if (y <= 4.8e+43) {
tmp = (x / z) - x;
} else {
tmp = y * (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2000000000000.0: tmp = (x * y) / z elif y <= 4.8e+43: tmp = (x / z) - x else: tmp = y * (x / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2000000000000.0) tmp = Float64(Float64(x * y) / z); elseif (y <= 4.8e+43) tmp = Float64(Float64(x / z) - x); else tmp = Float64(y * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2000000000000.0) tmp = (x * y) / z; elseif (y <= 4.8e+43) tmp = (x / z) - x; else tmp = y * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2000000000000.0], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 4.8e+43], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2000000000000:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+43}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\end{array}
\end{array}
if y < -2e12Initial program 92.7%
Taylor expanded in y around inf 73.9%
if -2e12 < y < 4.80000000000000046e43Initial program 86.6%
Taylor expanded in x around 0 86.6%
associate--l+86.6%
+-commutative86.6%
associate-*r/99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 85.0%
*-commutative85.0%
associate-/l*83.1%
div-sub78.4%
associate-/r/78.4%
associate-*l/78.6%
*-lft-identity78.6%
associate-/r/98.4%
*-inverses98.4%
*-lft-identity98.4%
Simplified98.4%
if 4.80000000000000046e43 < y Initial program 86.3%
Taylor expanded in y around inf 76.9%
associate-/l*76.7%
associate-/r/79.7%
Simplified79.7%
Final simplification89.3%
(FPCore (x y z) :precision binary64 (if (<= y -51000000000000.0) (/ (* x (+ y 1.0)) z) (if (<= y 4.4e+43) (- (/ x z) x) (* y (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -51000000000000.0) {
tmp = (x * (y + 1.0)) / z;
} else if (y <= 4.4e+43) {
tmp = (x / z) - x;
} else {
tmp = y * (x / z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-51000000000000.0d0)) then
tmp = (x * (y + 1.0d0)) / z
else if (y <= 4.4d+43) then
tmp = (x / z) - x
else
tmp = y * (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -51000000000000.0) {
tmp = (x * (y + 1.0)) / z;
} else if (y <= 4.4e+43) {
tmp = (x / z) - x;
} else {
tmp = y * (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -51000000000000.0: tmp = (x * (y + 1.0)) / z elif y <= 4.4e+43: tmp = (x / z) - x else: tmp = y * (x / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -51000000000000.0) tmp = Float64(Float64(x * Float64(y + 1.0)) / z); elseif (y <= 4.4e+43) tmp = Float64(Float64(x / z) - x); else tmp = Float64(y * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -51000000000000.0) tmp = (x * (y + 1.0)) / z; elseif (y <= 4.4e+43) tmp = (x / z) - x; else tmp = y * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -51000000000000.0], N[(N[(x * N[(y + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 4.4e+43], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -51000000000000:\\
\;\;\;\;\frac{x \cdot \left(y + 1\right)}{z}\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{+43}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\end{array}
\end{array}
if y < -5.1e13Initial program 92.7%
Taylor expanded in z around 0 74.0%
if -5.1e13 < y < 4.40000000000000001e43Initial program 86.6%
Taylor expanded in x around 0 86.6%
associate--l+86.6%
+-commutative86.6%
associate-*r/99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 85.0%
*-commutative85.0%
associate-/l*83.1%
div-sub78.4%
associate-/r/78.4%
associate-*l/78.6%
*-lft-identity78.6%
associate-/r/98.4%
*-inverses98.4%
*-lft-identity98.4%
Simplified98.4%
if 4.40000000000000001e43 < y Initial program 86.3%
Taylor expanded in y around inf 76.9%
associate-/l*76.7%
associate-/r/79.7%
Simplified79.7%
Final simplification89.3%
(FPCore (x y z) :precision binary64 (if (<= z -1.0) (- x) (if (<= z 980000.0) (/ x z) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= 980000.0) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-1.0d0)) then
tmp = -x
else if (z <= 980000.0d0) then
tmp = x / z
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= 980000.0) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.0: tmp = -x elif z <= 980000.0: tmp = x / z else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.0) tmp = Float64(-x); elseif (z <= 980000.0) tmp = Float64(x / z); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.0) tmp = -x; elseif (z <= 980000.0) tmp = x / z; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.0], (-x), If[LessEqual[z, 980000.0], N[(x / z), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 980000:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1 or 9.8e5 < z Initial program 75.1%
Taylor expanded in z around inf 72.7%
neg-mul-172.7%
Simplified72.7%
if -1 < z < 9.8e5Initial program 99.9%
Taylor expanded in y around 0 59.6%
associate-/l*59.6%
associate-/r/59.7%
Simplified59.7%
Taylor expanded in z around 0 56.9%
Final simplification64.6%
(FPCore (x y z) :precision binary64 (- x))
double code(double x, double y, double z) {
return -x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -x
end function
public static double code(double x, double y, double z) {
return -x;
}
def code(x, y, z): return -x
function code(x, y, z) return Float64(-x) end
function tmp = code(x, y, z) tmp = -x; end
code[x_, y_, z_] := (-x)
\begin{array}{l}
\\
-x
\end{array}
Initial program 87.8%
Taylor expanded in z around inf 37.3%
neg-mul-137.3%
Simplified37.3%
Final simplification37.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* (+ 1.0 y) (/ x z)) x)))
(if (< x -2.71483106713436e-162)
t_0
(if (< x 3.874108816439546e-197)
(* (* x (+ (- y z) 1.0)) (/ 1.0 z))
t_0))))
double code(double x, double y, double z) {
double t_0 = ((1.0 + y) * (x / z)) - x;
double tmp;
if (x < -2.71483106713436e-162) {
tmp = t_0;
} else if (x < 3.874108816439546e-197) {
tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = ((1.0d0 + y) * (x / z)) - x
if (x < (-2.71483106713436d-162)) then
tmp = t_0
else if (x < 3.874108816439546d-197) then
tmp = (x * ((y - z) + 1.0d0)) * (1.0d0 / z)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((1.0 + y) * (x / z)) - x;
double tmp;
if (x < -2.71483106713436e-162) {
tmp = t_0;
} else if (x < 3.874108816439546e-197) {
tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((1.0 + y) * (x / z)) - x tmp = 0 if x < -2.71483106713436e-162: tmp = t_0 elif x < 3.874108816439546e-197: tmp = (x * ((y - z) + 1.0)) * (1.0 / z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(1.0 + y) * Float64(x / z)) - x) tmp = 0.0 if (x < -2.71483106713436e-162) tmp = t_0; elseif (x < 3.874108816439546e-197) tmp = Float64(Float64(x * Float64(Float64(y - z) + 1.0)) * Float64(1.0 / z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((1.0 + y) * (x / z)) - x; tmp = 0.0; if (x < -2.71483106713436e-162) tmp = t_0; elseif (x < 3.874108816439546e-197) tmp = (x * ((y - z) + 1.0)) * (1.0 / z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(1.0 + y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]}, If[Less[x, -2.71483106713436e-162], t$95$0, If[Less[x, 3.874108816439546e-197], N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 + y\right) \cdot \frac{x}{z} - x\\
\mathbf{if}\;x < -2.71483106713436 \cdot 10^{-162}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x < 3.874108816439546 \cdot 10^{-197}:\\
\;\;\;\;\left(x \cdot \left(\left(y - z\right) + 1\right)\right) \cdot \frac{1}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
herbie shell --seed 2023275
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(if (< x -2.71483106713436e-162) (- (* (+ 1.0 y) (/ x z)) x) (if (< x 3.874108816439546e-197) (* (* x (+ (- y z) 1.0)) (/ 1.0 z)) (- (* (+ 1.0 y) (/ x z)) x)))
(/ (* x (+ (- y z) 1.0)) z))