
(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 11 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 (<= z -5e-19)
(- (* (/ (+ 1.0 y) z) x) x)
(if (<= z 3.5e-94)
(/ (/ x z) (/ 1.0 (+ 1.0 (- y z))))
(+ (* x (/ y z)) (- (/ x z) x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -5e-19) {
tmp = (((1.0 + y) / z) * x) - x;
} else if (z <= 3.5e-94) {
tmp = (x / z) / (1.0 / (1.0 + (y - z)));
} else {
tmp = (x * (y / z)) + ((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 (z <= (-5d-19)) then
tmp = (((1.0d0 + y) / z) * x) - x
else if (z <= 3.5d-94) then
tmp = (x / z) / (1.0d0 / (1.0d0 + (y - z)))
else
tmp = (x * (y / z)) + ((x / z) - x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -5e-19) {
tmp = (((1.0 + y) / z) * x) - x;
} else if (z <= 3.5e-94) {
tmp = (x / z) / (1.0 / (1.0 + (y - z)));
} else {
tmp = (x * (y / z)) + ((x / z) - x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -5e-19: tmp = (((1.0 + y) / z) * x) - x elif z <= 3.5e-94: tmp = (x / z) / (1.0 / (1.0 + (y - z))) else: tmp = (x * (y / z)) + ((x / z) - x) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -5e-19) tmp = Float64(Float64(Float64(Float64(1.0 + y) / z) * x) - x); elseif (z <= 3.5e-94) tmp = Float64(Float64(x / z) / Float64(1.0 / Float64(1.0 + Float64(y - z)))); else tmp = Float64(Float64(x * Float64(y / z)) + Float64(Float64(x / z) - x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -5e-19) tmp = (((1.0 + y) / z) * x) - x; elseif (z <= 3.5e-94) tmp = (x / z) / (1.0 / (1.0 + (y - z))); else tmp = (x * (y / z)) + ((x / z) - x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -5e-19], N[(N[(N[(N[(1.0 + y), $MachinePrecision] / z), $MachinePrecision] * x), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[z, 3.5e-94], N[(N[(x / z), $MachinePrecision] / N[(1.0 / N[(1.0 + N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] + N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{-19}:\\
\;\;\;\;\frac{1 + y}{z} \cdot x - x\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{-94}:\\
\;\;\;\;\frac{\frac{x}{z}}{\frac{1}{1 + \left(y - z\right)}}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{z} + \left(\frac{x}{z} - x\right)\\
\end{array}
\end{array}
if z < -5.0000000000000004e-19Initial program 72.6%
associate-/l*99.9%
div-inv99.9%
Applied egg-rr99.9%
un-div-inv99.9%
+-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in z around 0 88.7%
neg-mul-188.7%
+-commutative88.7%
unsub-neg88.7%
associate-/l*93.7%
associate-/r/100.0%
Simplified100.0%
if -5.0000000000000004e-19 < z < 3.49999999999999998e-94Initial program 99.9%
associate-/l*89.7%
div-inv89.6%
Applied egg-rr89.6%
un-div-inv89.7%
div-inv89.7%
associate-/r*100.0%
+-commutative100.0%
Applied egg-rr100.0%
if 3.49999999999999998e-94 < z Initial program 72.9%
distribute-lft-in72.9%
fma-def72.9%
*-rgt-identity72.9%
Simplified72.9%
Taylor expanded in y around 0 92.9%
associate-/l*96.3%
associate-/r/99.9%
+-commutative99.9%
neg-mul-199.9%
unsub-neg99.9%
Simplified99.9%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -51000000.0)
(- x)
(if (<= z 1.45e-232)
t_0
(if (<= z 1.22e-80) (/ x z) (if (<= z 4.4e+79) t_0 (- x)))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -51000000.0) {
tmp = -x;
} else if (z <= 1.45e-232) {
tmp = t_0;
} else if (z <= 1.22e-80) {
tmp = x / z;
} else if (z <= 4.4e+79) {
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 <= (-51000000.0d0)) then
tmp = -x
else if (z <= 1.45d-232) then
tmp = t_0
else if (z <= 1.22d-80) then
tmp = x / z
else if (z <= 4.4d+79) 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 <= -51000000.0) {
tmp = -x;
} else if (z <= 1.45e-232) {
tmp = t_0;
} else if (z <= 1.22e-80) {
tmp = x / z;
} else if (z <= 4.4e+79) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -51000000.0: tmp = -x elif z <= 1.45e-232: tmp = t_0 elif z <= 1.22e-80: tmp = x / z elif z <= 4.4e+79: 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 <= -51000000.0) tmp = Float64(-x); elseif (z <= 1.45e-232) tmp = t_0; elseif (z <= 1.22e-80) tmp = Float64(x / z); elseif (z <= 4.4e+79) 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 <= -51000000.0) tmp = -x; elseif (z <= 1.45e-232) tmp = t_0; elseif (z <= 1.22e-80) tmp = x / z; elseif (z <= 4.4e+79) 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, -51000000.0], (-x), If[LessEqual[z, 1.45e-232], t$95$0, If[LessEqual[z, 1.22e-80], N[(x / z), $MachinePrecision], If[LessEqual[z, 4.4e+79], t$95$0, (-x)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -51000000:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{-232}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.22 \cdot 10^{-80}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 4.4 \cdot 10^{+79}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -5.1e7 or 4.3999999999999998e79 < z Initial program 65.9%
Taylor expanded in z around inf 81.6%
neg-mul-181.6%
Simplified81.6%
if -5.1e7 < z < 1.45e-232 or 1.22e-80 < z < 4.3999999999999998e79Initial program 99.0%
associate-/l*91.4%
div-inv91.3%
Applied egg-rr91.3%
Taylor expanded in y around inf 57.8%
associate-*r/59.6%
Simplified59.6%
if 1.45e-232 < z < 1.22e-80Initial program 100.0%
Taylor expanded in z around 0 100.0%
Taylor expanded in y around 0 75.8%
Final simplification72.4%
(FPCore (x y z)
:precision binary64
(if (<= z -70000000.0)
(- x)
(if (<= z 1.3e-232)
(* y (/ x z))
(if (<= z 1.28e-80) (/ x z) (if (<= z 1.5e+80) (* x (/ y z)) (- x))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -70000000.0) {
tmp = -x;
} else if (z <= 1.3e-232) {
tmp = y * (x / z);
} else if (z <= 1.28e-80) {
tmp = x / z;
} else if (z <= 1.5e+80) {
tmp = x * (y / 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 <= (-70000000.0d0)) then
tmp = -x
else if (z <= 1.3d-232) then
tmp = y * (x / z)
else if (z <= 1.28d-80) then
tmp = x / z
else if (z <= 1.5d+80) then
tmp = x * (y / z)
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -70000000.0) {
tmp = -x;
} else if (z <= 1.3e-232) {
tmp = y * (x / z);
} else if (z <= 1.28e-80) {
tmp = x / z;
} else if (z <= 1.5e+80) {
tmp = x * (y / z);
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -70000000.0: tmp = -x elif z <= 1.3e-232: tmp = y * (x / z) elif z <= 1.28e-80: tmp = x / z elif z <= 1.5e+80: tmp = x * (y / z) else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -70000000.0) tmp = Float64(-x); elseif (z <= 1.3e-232) tmp = Float64(y * Float64(x / z)); elseif (z <= 1.28e-80) tmp = Float64(x / z); elseif (z <= 1.5e+80) tmp = Float64(x * Float64(y / z)); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -70000000.0) tmp = -x; elseif (z <= 1.3e-232) tmp = y * (x / z); elseif (z <= 1.28e-80) tmp = x / z; elseif (z <= 1.5e+80) tmp = x * (y / z); else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -70000000.0], (-x), If[LessEqual[z, 1.3e-232], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.28e-80], N[(x / z), $MachinePrecision], If[LessEqual[z, 1.5e+80], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision], (-x)]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -70000000:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{-232}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;z \leq 1.28 \cdot 10^{-80}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{+80}:\\
\;\;\;\;x \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -7e7 or 1.49999999999999993e80 < z Initial program 65.9%
Taylor expanded in z around inf 81.6%
neg-mul-181.6%
Simplified81.6%
if -7e7 < z < 1.29999999999999998e-232Initial program 99.9%
associate-/l*88.7%
div-inv88.6%
Applied egg-rr88.6%
Taylor expanded in y around inf 54.7%
associate-*r/57.3%
Simplified57.3%
if 1.29999999999999998e-232 < z < 1.28e-80Initial program 100.0%
Taylor expanded in z around 0 100.0%
Taylor expanded in y around 0 75.8%
if 1.28e-80 < z < 1.49999999999999993e80Initial program 96.4%
Taylor expanded in y around inf 67.3%
associate-/l*66.9%
associate-/r/66.9%
Simplified66.9%
Final simplification72.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.35e+16) (not (<= z 3.3e+15))) (- (* x (/ y z)) x) (* (/ x z) (+ 1.0 (- y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.35e+16) || !(z <= 3.3e+15)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x / z) * (1.0 + (y - 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 <= (-1.35d+16)) .or. (.not. (z <= 3.3d+15))) then
tmp = (x * (y / z)) - x
else
tmp = (x / z) * (1.0d0 + (y - z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.35e+16) || !(z <= 3.3e+15)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x / z) * (1.0 + (y - z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.35e+16) or not (z <= 3.3e+15): tmp = (x * (y / z)) - x else: tmp = (x / z) * (1.0 + (y - z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.35e+16) || !(z <= 3.3e+15)) tmp = Float64(Float64(x * Float64(y / z)) - x); else tmp = Float64(Float64(x / z) * Float64(1.0 + Float64(y - z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.35e+16) || ~((z <= 3.3e+15))) tmp = (x * (y / z)) - x; else tmp = (x / z) * (1.0 + (y - z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.35e+16], N[Not[LessEqual[z, 3.3e+15]], $MachinePrecision]], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(1.0 + N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.35 \cdot 10^{+16} \lor \neg \left(z \leq 3.3 \cdot 10^{+15}\right):\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(1 + \left(y - z\right)\right)\\
\end{array}
\end{array}
if z < -1.35e16 or 3.3e15 < z Initial program 67.1%
associate-/l*99.9%
div-inv99.9%
Applied egg-rr99.9%
un-div-inv99.9%
+-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in z around 0 89.0%
neg-mul-189.0%
+-commutative89.0%
unsub-neg89.0%
associate-/l*94.8%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
if -1.35e16 < z < 3.3e15Initial program 99.9%
associate-/l*91.9%
associate-/r/99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -2e-14) (not (<= z 2e-12))) (- (* (/ (+ 1.0 y) z) x) x) (* (/ x z) (+ 1.0 (- y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2e-14) || !(z <= 2e-12)) {
tmp = (((1.0 + y) / z) * x) - x;
} else {
tmp = (x / z) * (1.0 + (y - 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 <= (-2d-14)) .or. (.not. (z <= 2d-12))) then
tmp = (((1.0d0 + y) / z) * x) - x
else
tmp = (x / z) * (1.0d0 + (y - z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2e-14) || !(z <= 2e-12)) {
tmp = (((1.0 + y) / z) * x) - x;
} else {
tmp = (x / z) * (1.0 + (y - z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2e-14) or not (z <= 2e-12): tmp = (((1.0 + y) / z) * x) - x else: tmp = (x / z) * (1.0 + (y - z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2e-14) || !(z <= 2e-12)) tmp = Float64(Float64(Float64(Float64(1.0 + y) / z) * x) - x); else tmp = Float64(Float64(x / z) * Float64(1.0 + Float64(y - z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2e-14) || ~((z <= 2e-12))) tmp = (((1.0 + y) / z) * x) - x; else tmp = (x / z) * (1.0 + (y - z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2e-14], N[Not[LessEqual[z, 2e-12]], $MachinePrecision]], N[(N[(N[(N[(1.0 + y), $MachinePrecision] / z), $MachinePrecision] * x), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(1.0 + N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{-14} \lor \neg \left(z \leq 2 \cdot 10^{-12}\right):\\
\;\;\;\;\frac{1 + y}{z} \cdot x - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(1 + \left(y - z\right)\right)\\
\end{array}
\end{array}
if z < -2e-14 or 1.99999999999999996e-12 < z Initial program 70.1%
associate-/l*99.9%
div-inv99.9%
Applied egg-rr99.9%
un-div-inv99.9%
+-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in z around 0 90.0%
neg-mul-190.0%
+-commutative90.0%
unsub-neg90.0%
associate-/l*95.3%
associate-/r/100.0%
Simplified100.0%
if -2e-14 < z < 1.99999999999999996e-12Initial program 99.9%
associate-/l*91.0%
associate-/r/99.9%
Applied egg-rr99.9%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (- (* x (/ y z)) x) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = (x * (y / z)) - x;
} 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 <= (-1.0d0)) .or. (.not. (y <= 1.0d0))) then
tmp = (x * (y / z)) - x
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 <= -1.0) || !(y <= 1.0)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.0) or not (y <= 1.0): tmp = (x * (y / z)) - x else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.0) || !(y <= 1.0)) tmp = Float64(Float64(x * Float64(y / z)) - x); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.0) || ~((y <= 1.0))) tmp = (x * (y / z)) - x; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 82.3%
associate-/l*92.2%
div-inv92.2%
Applied egg-rr92.2%
un-div-inv92.2%
+-commutative92.2%
Applied egg-rr92.2%
Taylor expanded in z around 0 89.3%
neg-mul-189.3%
+-commutative89.3%
unsub-neg89.3%
associate-/l*94.9%
associate-/r/92.2%
Simplified92.2%
Taylor expanded in y around inf 91.6%
if -1 < y < 1Initial program 84.6%
associate-/l*100.0%
div-inv99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 84.2%
sub-neg84.2%
+-commutative84.2%
distribute-rgt1-in84.2%
cancel-sign-sub-inv84.2%
*-commutative84.2%
div-sub84.2%
associate-*l/86.4%
associate-/r/99.6%
*-inverses99.6%
/-rgt-identity99.6%
Simplified99.6%
Final simplification95.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 7.5e-31))) (- (* x (/ y z)) x) (/ (* (+ 1.0 y) x) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 7.5e-31)) {
tmp = (x * (y / z)) - x;
} else {
tmp = ((1.0 + 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 ((z <= (-1.0d0)) .or. (.not. (z <= 7.5d-31))) then
tmp = (x * (y / z)) - x
else
tmp = ((1.0d0 + y) * x) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 7.5e-31)) {
tmp = (x * (y / z)) - x;
} else {
tmp = ((1.0 + y) * x) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 7.5e-31): tmp = (x * (y / z)) - x else: tmp = ((1.0 + y) * x) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 7.5e-31)) tmp = Float64(Float64(x * Float64(y / z)) - x); else tmp = Float64(Float64(Float64(1.0 + y) * x) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 7.5e-31))) tmp = (x * (y / z)) - x; else tmp = ((1.0 + y) * x) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 7.5e-31]], $MachinePrecision]], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(N[(1.0 + y), $MachinePrecision] * x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 7.5 \cdot 10^{-31}\right):\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + y\right) \cdot x}{z}\\
\end{array}
\end{array}
if z < -1 or 7.49999999999999975e-31 < z Initial program 69.9%
associate-/l*99.9%
div-inv99.9%
Applied egg-rr99.9%
un-div-inv99.9%
+-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in z around 0 89.9%
neg-mul-189.9%
+-commutative89.9%
unsub-neg89.9%
associate-/l*95.2%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in y around inf 97.8%
if -1 < z < 7.49999999999999975e-31Initial program 99.9%
Taylor expanded in z around 0 98.3%
Final simplification98.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -5e+23) (not (<= y 4e+132))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5e+23) || !(y <= 4e+132)) {
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 <= (-5d+23)) .or. (.not. (y <= 4d+132))) 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 <= -5e+23) || !(y <= 4e+132)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5e+23) or not (y <= 4e+132): tmp = y * (x / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5e+23) || !(y <= 4e+132)) 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 <= -5e+23) || ~((y <= 4e+132))) tmp = y * (x / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5e+23], N[Not[LessEqual[y, 4e+132]], $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 -5 \cdot 10^{+23} \lor \neg \left(y \leq 4 \cdot 10^{+132}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -4.9999999999999999e23 or 3.99999999999999996e132 < y Initial program 85.1%
associate-/l*90.0%
div-inv90.0%
Applied egg-rr90.0%
Taylor expanded in y around inf 73.8%
associate-*r/70.9%
Simplified70.9%
if -4.9999999999999999e23 < y < 3.99999999999999996e132Initial program 82.4%
associate-/l*99.4%
div-inv99.3%
Applied egg-rr99.3%
Taylor expanded in y around 0 75.6%
sub-neg75.6%
+-commutative75.6%
distribute-rgt1-in75.6%
cancel-sign-sub-inv75.6%
*-commutative75.6%
div-sub75.7%
associate-*l/75.9%
associate-/r/93.2%
*-inverses93.2%
/-rgt-identity93.2%
Simplified93.2%
Final simplification84.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.65e+24) (not (<= y 1.6e+138))) (/ (* y x) z) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.65e+24) || !(y <= 1.6e+138)) {
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 <= (-1.65d+24)) .or. (.not. (y <= 1.6d+138))) 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 <= -1.65e+24) || !(y <= 1.6e+138)) {
tmp = (y * x) / z;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.65e+24) or not (y <= 1.6e+138): tmp = (y * x) / z else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.65e+24) || !(y <= 1.6e+138)) tmp = Float64(Float64(y * 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 <= -1.65e+24) || ~((y <= 1.6e+138))) tmp = (y * x) / z; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.65e+24], N[Not[LessEqual[y, 1.6e+138]], $MachinePrecision]], N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.65 \cdot 10^{+24} \lor \neg \left(y \leq 1.6 \cdot 10^{+138}\right):\\
\;\;\;\;\frac{y \cdot x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1.6499999999999999e24 or 1.6000000000000001e138 < y Initial program 85.1%
Taylor expanded in y around inf 73.8%
if -1.6499999999999999e24 < y < 1.6000000000000001e138Initial program 82.4%
associate-/l*99.4%
div-inv99.3%
Applied egg-rr99.3%
Taylor expanded in y around 0 75.6%
sub-neg75.6%
+-commutative75.6%
distribute-rgt1-in75.6%
cancel-sign-sub-inv75.6%
*-commutative75.6%
div-sub75.7%
associate-*l/75.9%
associate-/r/93.2%
*-inverses93.2%
/-rgt-identity93.2%
Simplified93.2%
Final simplification86.0%
(FPCore (x y z) :precision binary64 (if (<= z -1.0) (- x) (if (<= z 3.4e-42) (/ x z) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= 3.4e-42) {
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 <= 3.4d-42) 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 <= 3.4e-42) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.0: tmp = -x elif z <= 3.4e-42: 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 <= 3.4e-42) 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 <= 3.4e-42) tmp = x / z; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.0], (-x), If[LessEqual[z, 3.4e-42], N[(x / z), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 3.4 \cdot 10^{-42}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1 or 3.40000000000000022e-42 < z Initial program 70.1%
Taylor expanded in z around inf 73.7%
neg-mul-173.7%
Simplified73.7%
if -1 < z < 3.40000000000000022e-42Initial program 99.9%
Taylor expanded in z around 0 98.3%
Taylor expanded in y around 0 56.7%
Final simplification66.2%
(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 83.4%
Taylor expanded in z around inf 42.1%
neg-mul-142.1%
Simplified42.1%
Final simplification42.1%
(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 2023274
(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))