
(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 9 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 (let* ((t_0 (+ (- y z) 1.0))) (if (<= (/ (* x t_0) z) -2e+41) (* t_0 (/ x z)) (/ x (/ z t_0)))))
double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if (((x * t_0) / z) <= -2e+41) {
tmp = t_0 * (x / z);
} else {
tmp = x / (z / 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 = (y - z) + 1.0d0
if (((x * t_0) / z) <= (-2d+41)) then
tmp = t_0 * (x / z)
else
tmp = x / (z / t_0)
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+41) {
tmp = t_0 * (x / z);
} else {
tmp = x / (z / t_0);
}
return tmp;
}
def code(x, y, z): t_0 = (y - z) + 1.0 tmp = 0 if ((x * t_0) / z) <= -2e+41: tmp = t_0 * (x / z) else: tmp = x / (z / t_0) 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+41) tmp = Float64(t_0 * Float64(x / z)); else tmp = Float64(x / Float64(z / t_0)); 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+41) tmp = t_0 * (x / z); else tmp = x / (z / t_0); 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+41], N[(t$95$0 * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(x / N[(z / t$95$0), $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^{+41}:\\
\;\;\;\;t_0 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < -2.00000000000000001e41Initial program 79.9%
associate-/l*94.1%
Simplified94.1%
associate-/r/99.8%
Applied egg-rr99.8%
if -2.00000000000000001e41 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) Initial program 89.8%
distribute-lft-in89.8%
*-rgt-identity89.8%
Applied egg-rr89.8%
Taylor expanded in x around 0 89.8%
associate-/l*97.8%
associate--l+97.8%
Simplified97.8%
Final simplification98.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -1.9e+65)
(- x)
(if (<= z -1.65e-5)
t_0
(if (<= z -1e-63)
(/ x z)
(if (<= z -5.2e-218)
t_0
(if (<= z 7.8e-200)
(/ x z)
(if (<= z 5.2e-160)
t_0
(if (<= z 1.75e-53)
(/ x z)
(if (<= z 2.3e+94) t_0 (- x)))))))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -1.9e+65) {
tmp = -x;
} else if (z <= -1.65e-5) {
tmp = t_0;
} else if (z <= -1e-63) {
tmp = x / z;
} else if (z <= -5.2e-218) {
tmp = t_0;
} else if (z <= 7.8e-200) {
tmp = x / z;
} else if (z <= 5.2e-160) {
tmp = t_0;
} else if (z <= 1.75e-53) {
tmp = x / z;
} else if (z <= 2.3e+94) {
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 <= (-1.9d+65)) then
tmp = -x
else if (z <= (-1.65d-5)) then
tmp = t_0
else if (z <= (-1d-63)) then
tmp = x / z
else if (z <= (-5.2d-218)) then
tmp = t_0
else if (z <= 7.8d-200) then
tmp = x / z
else if (z <= 5.2d-160) then
tmp = t_0
else if (z <= 1.75d-53) then
tmp = x / z
else if (z <= 2.3d+94) 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 <= -1.9e+65) {
tmp = -x;
} else if (z <= -1.65e-5) {
tmp = t_0;
} else if (z <= -1e-63) {
tmp = x / z;
} else if (z <= -5.2e-218) {
tmp = t_0;
} else if (z <= 7.8e-200) {
tmp = x / z;
} else if (z <= 5.2e-160) {
tmp = t_0;
} else if (z <= 1.75e-53) {
tmp = x / z;
} else if (z <= 2.3e+94) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -1.9e+65: tmp = -x elif z <= -1.65e-5: tmp = t_0 elif z <= -1e-63: tmp = x / z elif z <= -5.2e-218: tmp = t_0 elif z <= 7.8e-200: tmp = x / z elif z <= 5.2e-160: tmp = t_0 elif z <= 1.75e-53: tmp = x / z elif z <= 2.3e+94: 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 <= -1.9e+65) tmp = Float64(-x); elseif (z <= -1.65e-5) tmp = t_0; elseif (z <= -1e-63) tmp = Float64(x / z); elseif (z <= -5.2e-218) tmp = t_0; elseif (z <= 7.8e-200) tmp = Float64(x / z); elseif (z <= 5.2e-160) tmp = t_0; elseif (z <= 1.75e-53) tmp = Float64(x / z); elseif (z <= 2.3e+94) 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 <= -1.9e+65) tmp = -x; elseif (z <= -1.65e-5) tmp = t_0; elseif (z <= -1e-63) tmp = x / z; elseif (z <= -5.2e-218) tmp = t_0; elseif (z <= 7.8e-200) tmp = x / z; elseif (z <= 5.2e-160) tmp = t_0; elseif (z <= 1.75e-53) tmp = x / z; elseif (z <= 2.3e+94) 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, -1.9e+65], (-x), If[LessEqual[z, -1.65e-5], t$95$0, If[LessEqual[z, -1e-63], N[(x / z), $MachinePrecision], If[LessEqual[z, -5.2e-218], t$95$0, If[LessEqual[z, 7.8e-200], N[(x / z), $MachinePrecision], If[LessEqual[z, 5.2e-160], t$95$0, If[LessEqual[z, 1.75e-53], N[(x / z), $MachinePrecision], If[LessEqual[z, 2.3e+94], t$95$0, (-x)]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -1.9 \cdot 10^{+65}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -1.65 \cdot 10^{-5}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -1 \cdot 10^{-63}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq -5.2 \cdot 10^{-218}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 7.8 \cdot 10^{-200}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 5.2 \cdot 10^{-160}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.75 \cdot 10^{-53}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 2.3 \cdot 10^{+94}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1.90000000000000006e65 or 2.3e94 < z Initial program 70.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around inf 79.7%
neg-mul-179.7%
Simplified79.7%
if -1.90000000000000006e65 < z < -1.6500000000000001e-5 or -1.00000000000000007e-63 < z < -5.19999999999999966e-218 or 7.79999999999999998e-200 < z < 5.20000000000000007e-160 or 1.74999999999999997e-53 < z < 2.3e94Initial program 94.7%
associate-/l*94.5%
Simplified94.5%
Taylor expanded in y around inf 67.3%
associate-/r/73.6%
Applied egg-rr73.6%
if -1.6500000000000001e-5 < z < -1.00000000000000007e-63 or -5.19999999999999966e-218 < z < 7.79999999999999998e-200 or 5.20000000000000007e-160 < z < 1.74999999999999997e-53Initial program 99.9%
associate-/l*94.7%
Simplified94.7%
Taylor expanded in y around 0 73.2%
Taylor expanded in z around 0 72.1%
Final simplification75.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))) (t_1 (* x (/ y z))))
(if (<= z -4.2e+69)
(- x)
(if (<= z -1.42e-5)
t_1
(if (<= z -1.12e-63)
(/ x z)
(if (<= z -1.6e-217)
t_0
(if (<= z 1.25e-199)
(/ x z)
(if (<= z 4.2e-160)
t_0
(if (<= z 8.5e-53)
(/ x z)
(if (<= z 2.75e+94) t_1 (- x)))))))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double t_1 = x * (y / z);
double tmp;
if (z <= -4.2e+69) {
tmp = -x;
} else if (z <= -1.42e-5) {
tmp = t_1;
} else if (z <= -1.12e-63) {
tmp = x / z;
} else if (z <= -1.6e-217) {
tmp = t_0;
} else if (z <= 1.25e-199) {
tmp = x / z;
} else if (z <= 4.2e-160) {
tmp = t_0;
} else if (z <= 8.5e-53) {
tmp = x / z;
} else if (z <= 2.75e+94) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = y * (x / z)
t_1 = x * (y / z)
if (z <= (-4.2d+69)) then
tmp = -x
else if (z <= (-1.42d-5)) then
tmp = t_1
else if (z <= (-1.12d-63)) then
tmp = x / z
else if (z <= (-1.6d-217)) then
tmp = t_0
else if (z <= 1.25d-199) then
tmp = x / z
else if (z <= 4.2d-160) then
tmp = t_0
else if (z <= 8.5d-53) then
tmp = x / z
else if (z <= 2.75d+94) then
tmp = t_1
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 t_1 = x * (y / z);
double tmp;
if (z <= -4.2e+69) {
tmp = -x;
} else if (z <= -1.42e-5) {
tmp = t_1;
} else if (z <= -1.12e-63) {
tmp = x / z;
} else if (z <= -1.6e-217) {
tmp = t_0;
} else if (z <= 1.25e-199) {
tmp = x / z;
} else if (z <= 4.2e-160) {
tmp = t_0;
} else if (z <= 8.5e-53) {
tmp = x / z;
} else if (z <= 2.75e+94) {
tmp = t_1;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) t_1 = x * (y / z) tmp = 0 if z <= -4.2e+69: tmp = -x elif z <= -1.42e-5: tmp = t_1 elif z <= -1.12e-63: tmp = x / z elif z <= -1.6e-217: tmp = t_0 elif z <= 1.25e-199: tmp = x / z elif z <= 4.2e-160: tmp = t_0 elif z <= 8.5e-53: tmp = x / z elif z <= 2.75e+94: tmp = t_1 else: tmp = -x return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x / z)) t_1 = Float64(x * Float64(y / z)) tmp = 0.0 if (z <= -4.2e+69) tmp = Float64(-x); elseif (z <= -1.42e-5) tmp = t_1; elseif (z <= -1.12e-63) tmp = Float64(x / z); elseif (z <= -1.6e-217) tmp = t_0; elseif (z <= 1.25e-199) tmp = Float64(x / z); elseif (z <= 4.2e-160) tmp = t_0; elseif (z <= 8.5e-53) tmp = Float64(x / z); elseif (z <= 2.75e+94) tmp = t_1; else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (x / z); t_1 = x * (y / z); tmp = 0.0; if (z <= -4.2e+69) tmp = -x; elseif (z <= -1.42e-5) tmp = t_1; elseif (z <= -1.12e-63) tmp = x / z; elseif (z <= -1.6e-217) tmp = t_0; elseif (z <= 1.25e-199) tmp = x / z; elseif (z <= 4.2e-160) tmp = t_0; elseif (z <= 8.5e-53) tmp = x / z; elseif (z <= 2.75e+94) tmp = t_1; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.2e+69], (-x), If[LessEqual[z, -1.42e-5], t$95$1, If[LessEqual[z, -1.12e-63], N[(x / z), $MachinePrecision], If[LessEqual[z, -1.6e-217], t$95$0, If[LessEqual[z, 1.25e-199], N[(x / z), $MachinePrecision], If[LessEqual[z, 4.2e-160], t$95$0, If[LessEqual[z, 8.5e-53], N[(x / z), $MachinePrecision], If[LessEqual[z, 2.75e+94], t$95$1, (-x)]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
t_1 := x \cdot \frac{y}{z}\\
\mathbf{if}\;z \leq -4.2 \cdot 10^{+69}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -1.42 \cdot 10^{-5}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -1.12 \cdot 10^{-63}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq -1.6 \cdot 10^{-217}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.25 \cdot 10^{-199}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{-160}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 8.5 \cdot 10^{-53}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 2.75 \cdot 10^{+94}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -4.2000000000000003e69 or 2.7499999999999999e94 < z Initial program 70.2%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around inf 80.3%
neg-mul-180.3%
Simplified80.3%
if -4.2000000000000003e69 < z < -1.42e-5 or 8.50000000000000044e-53 < z < 2.7499999999999999e94Initial program 88.4%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 61.3%
associate-/l*67.8%
associate-/r/70.3%
Simplified70.3%
if -1.42e-5 < z < -1.12000000000000002e-63 or -1.6000000000000001e-217 < z < 1.2499999999999999e-199 or 4.2000000000000001e-160 < z < 8.50000000000000044e-53Initial program 99.9%
associate-/l*94.7%
Simplified94.7%
Taylor expanded in y around 0 73.2%
Taylor expanded in z around 0 72.1%
if -1.12000000000000002e-63 < z < -1.6000000000000001e-217 or 1.2499999999999999e-199 < z < 4.2000000000000001e-160Initial program 99.9%
associate-/l*90.5%
Simplified90.5%
Taylor expanded in y around inf 64.2%
associate-/r/75.4%
Applied egg-rr75.4%
Final simplification75.6%
(FPCore (x y z) :precision binary64 (if (<= z -2.7e+188) (- x) (if (<= z 4.2e+205) (* (+ (- y z) 1.0) (/ x z)) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.7e+188) {
tmp = -x;
} else if (z <= 4.2e+205) {
tmp = ((y - z) + 1.0) * (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 <= (-2.7d+188)) then
tmp = -x
else if (z <= 4.2d+205) then
tmp = ((y - z) + 1.0d0) * (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 <= -2.7e+188) {
tmp = -x;
} else if (z <= 4.2e+205) {
tmp = ((y - z) + 1.0) * (x / z);
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.7e+188: tmp = -x elif z <= 4.2e+205: tmp = ((y - z) + 1.0) * (x / z) else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.7e+188) tmp = Float64(-x); elseif (z <= 4.2e+205) tmp = Float64(Float64(Float64(y - z) + 1.0) * Float64(x / z)); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2.7e+188) tmp = -x; elseif (z <= 4.2e+205) tmp = ((y - z) + 1.0) * (x / z); else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.7e+188], (-x), If[LessEqual[z, 4.2e+205], N[(N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.7 \cdot 10^{+188}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{+205}:\\
\;\;\;\;\left(\left(y - z\right) + 1\right) \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -2.7e188 or 4.2000000000000001e205 < z Initial program 63.4%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in z around inf 95.8%
neg-mul-195.8%
Simplified95.8%
if -2.7e188 < z < 4.2000000000000001e205Initial program 92.3%
associate-/l*95.9%
Simplified95.9%
associate-/r/95.1%
Applied egg-rr95.1%
Final simplification95.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -195000000.0) (not (<= y 3.2e+65))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -195000000.0) || !(y <= 3.2e+65)) {
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 <= (-195000000.0d0)) .or. (.not. (y <= 3.2d+65))) 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 <= -195000000.0) || !(y <= 3.2e+65)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -195000000.0) or not (y <= 3.2e+65): tmp = y * (x / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -195000000.0) || !(y <= 3.2e+65)) 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 <= -195000000.0) || ~((y <= 3.2e+65))) tmp = y * (x / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -195000000.0], N[Not[LessEqual[y, 3.2e+65]], $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 -195000000 \lor \neg \left(y \leq 3.2 \cdot 10^{+65}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1.95e8 or 3.20000000000000007e65 < y Initial program 84.8%
associate-/l*92.8%
Simplified92.8%
Taylor expanded in y around inf 74.5%
associate-/r/77.0%
Applied egg-rr77.0%
if -1.95e8 < y < 3.20000000000000007e65Initial program 88.4%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 96.2%
Taylor expanded in z around 0 96.2%
neg-mul-196.2%
+-commutative96.2%
unsub-neg96.2%
Simplified96.2%
Final simplification87.3%
(FPCore (x y z) :precision binary64 (if (<= y -650000.0) (/ (* x y) z) (if (<= y 5.5e+65) (- (/ x z) x) (* y (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -650000.0) {
tmp = (x * y) / z;
} else if (y <= 5.5e+65) {
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 <= (-650000.0d0)) then
tmp = (x * y) / z
else if (y <= 5.5d+65) 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 <= -650000.0) {
tmp = (x * y) / z;
} else if (y <= 5.5e+65) {
tmp = (x / z) - x;
} else {
tmp = y * (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -650000.0: tmp = (x * y) / z elif y <= 5.5e+65: tmp = (x / z) - x else: tmp = y * (x / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -650000.0) tmp = Float64(Float64(x * y) / z); elseif (y <= 5.5e+65) 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 <= -650000.0) tmp = (x * y) / z; elseif (y <= 5.5e+65) tmp = (x / z) - x; else tmp = y * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -650000.0], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 5.5e+65], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -650000:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{+65}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\end{array}
\end{array}
if y < -6.5e5Initial program 87.7%
associate-/l*93.3%
Simplified93.3%
Taylor expanded in y around inf 68.5%
if -6.5e5 < y < 5.4999999999999996e65Initial program 88.4%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 96.2%
Taylor expanded in z around 0 96.2%
neg-mul-196.2%
+-commutative96.2%
unsub-neg96.2%
Simplified96.2%
if 5.4999999999999996e65 < y Initial program 82.4%
associate-/l*92.5%
Simplified92.5%
Taylor expanded in y around inf 83.6%
associate-/r/86.9%
Applied egg-rr86.9%
Final simplification88.0%
(FPCore (x y z) :precision binary64 (if (<= y -28000.0) (/ (+ x (* x y)) z) (if (<= y 7.2e+65) (- (/ x z) x) (* y (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -28000.0) {
tmp = (x + (x * y)) / z;
} else if (y <= 7.2e+65) {
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 <= (-28000.0d0)) then
tmp = (x + (x * y)) / z
else if (y <= 7.2d+65) 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 <= -28000.0) {
tmp = (x + (x * y)) / z;
} else if (y <= 7.2e+65) {
tmp = (x / z) - x;
} else {
tmp = y * (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -28000.0: tmp = (x + (x * y)) / z elif y <= 7.2e+65: tmp = (x / z) - x else: tmp = y * (x / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -28000.0) tmp = Float64(Float64(x + Float64(x * y)) / z); elseif (y <= 7.2e+65) 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 <= -28000.0) tmp = (x + (x * y)) / z; elseif (y <= 7.2e+65) tmp = (x / z) - x; else tmp = y * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -28000.0], N[(N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 7.2e+65], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -28000:\\
\;\;\;\;\frac{x + x \cdot y}{z}\\
\mathbf{elif}\;y \leq 7.2 \cdot 10^{+65}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\end{array}
\end{array}
if y < -28000Initial program 87.7%
distribute-lft-in87.7%
fma-def87.7%
*-rgt-identity87.7%
Simplified87.7%
Taylor expanded in z around 0 69.4%
if -28000 < y < 7.19999999999999957e65Initial program 88.4%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 96.2%
Taylor expanded in z around 0 96.2%
neg-mul-196.2%
+-commutative96.2%
unsub-neg96.2%
Simplified96.2%
if 7.19999999999999957e65 < y Initial program 82.4%
associate-/l*92.5%
Simplified92.5%
Taylor expanded in y around inf 83.6%
associate-/r/86.9%
Applied egg-rr86.9%
Final simplification88.2%
(FPCore (x y z) :precision binary64 (if (<= z -1.0) (- x) (if (<= z 1.0) (/ x z) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= 1.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 <= 1.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 <= 1.0) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.0: tmp = -x elif z <= 1.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 <= 1.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 <= 1.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, 1.0], N[(x / z), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 72.3%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around inf 71.5%
neg-mul-171.5%
Simplified71.5%
if -1 < z < 1Initial program 99.9%
associate-/l*93.7%
Simplified93.7%
Taylor expanded in y around 0 56.3%
Taylor expanded in z around 0 54.7%
Final simplification62.7%
(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 86.8%
associate-/l*96.7%
Simplified96.7%
Taylor expanded in z around inf 35.8%
neg-mul-135.8%
Simplified35.8%
Final simplification35.8%
(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 2023257
(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))