
(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 12 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 -0.015) (not (<= z 1.5e-34))) (* x (/ (+ y (- 1.0 z)) z)) (* (+ 1.0 (- y z)) (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.015) || !(z <= 1.5e-34)) {
tmp = x * ((y + (1.0 - z)) / z);
} else {
tmp = (1.0 + (y - z)) * (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 <= (-0.015d0)) .or. (.not. (z <= 1.5d-34))) then
tmp = x * ((y + (1.0d0 - z)) / z)
else
tmp = (1.0d0 + (y - z)) * (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.015) || !(z <= 1.5e-34)) {
tmp = x * ((y + (1.0 - z)) / z);
} else {
tmp = (1.0 + (y - z)) * (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.015) or not (z <= 1.5e-34): tmp = x * ((y + (1.0 - z)) / z) else: tmp = (1.0 + (y - z)) * (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.015) || !(z <= 1.5e-34)) tmp = Float64(x * Float64(Float64(y + Float64(1.0 - z)) / z)); else tmp = Float64(Float64(1.0 + Float64(y - z)) * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.015) || ~((z <= 1.5e-34))) tmp = x * ((y + (1.0 - z)) / z); else tmp = (1.0 + (y - z)) * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.015], N[Not[LessEqual[z, 1.5e-34]], $MachinePrecision]], N[(x * N[(N[(y + N[(1.0 - z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(y - z), $MachinePrecision]), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.015 \lor \neg \left(z \leq 1.5 \cdot 10^{-34}\right):\\
\;\;\;\;x \cdot \frac{y + \left(1 - z\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \left(y - z\right)\right) \cdot \frac{x}{z}\\
\end{array}
\end{array}
if z < -0.014999999999999999 or 1.5e-34 < z Initial program 76.2%
Taylor expanded in x around 0 76.2%
associate--l+76.2%
+-commutative76.2%
associate-*r/100.0%
associate-+l-100.0%
Simplified100.0%
if -0.014999999999999999 < z < 1.5e-34Initial program 99.9%
associate-/l*89.1%
associate-/r/99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= y -4e+29)
t_0
(if (<= y -6.7e-68)
(- x)
(if (<= y 1.35e-118) (/ x z) (if (<= y 30500000000.0) (- x) t_0))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (y <= -4e+29) {
tmp = t_0;
} else if (y <= -6.7e-68) {
tmp = -x;
} else if (y <= 1.35e-118) {
tmp = x / z;
} else if (y <= 30500000000.0) {
tmp = -x;
} 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 = y * (x / z)
if (y <= (-4d+29)) then
tmp = t_0
else if (y <= (-6.7d-68)) then
tmp = -x
else if (y <= 1.35d-118) then
tmp = x / z
else if (y <= 30500000000.0d0) then
tmp = -x
else
tmp = t_0
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 (y <= -4e+29) {
tmp = t_0;
} else if (y <= -6.7e-68) {
tmp = -x;
} else if (y <= 1.35e-118) {
tmp = x / z;
} else if (y <= 30500000000.0) {
tmp = -x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if y <= -4e+29: tmp = t_0 elif y <= -6.7e-68: tmp = -x elif y <= 1.35e-118: tmp = x / z elif y <= 30500000000.0: tmp = -x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x / z)) tmp = 0.0 if (y <= -4e+29) tmp = t_0; elseif (y <= -6.7e-68) tmp = Float64(-x); elseif (y <= 1.35e-118) tmp = Float64(x / z); elseif (y <= 30500000000.0) tmp = Float64(-x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (x / z); tmp = 0.0; if (y <= -4e+29) tmp = t_0; elseif (y <= -6.7e-68) tmp = -x; elseif (y <= 1.35e-118) tmp = x / z; elseif (y <= 30500000000.0) tmp = -x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4e+29], t$95$0, If[LessEqual[y, -6.7e-68], (-x), If[LessEqual[y, 1.35e-118], N[(x / z), $MachinePrecision], If[LessEqual[y, 30500000000.0], (-x), t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;y \leq -4 \cdot 10^{+29}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -6.7 \cdot 10^{-68}:\\
\;\;\;\;-x\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{-118}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 30500000000:\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -3.99999999999999966e29 or 3.05e10 < y Initial program 91.4%
Taylor expanded in y around inf 82.3%
associate-/l*72.9%
associate-/r/80.3%
Simplified80.3%
if -3.99999999999999966e29 < y < -6.6999999999999996e-68 or 1.34999999999999997e-118 < y < 3.05e10Initial program 78.3%
Taylor expanded in z around inf 71.1%
mul-1-neg71.1%
Simplified71.1%
if -6.6999999999999996e-68 < y < 1.34999999999999997e-118Initial program 89.2%
Taylor expanded in y around 0 89.2%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in z around 0 63.1%
Final simplification73.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -9.5e-17) (not (<= z 1.5e-34))) (* x (/ (+ y (- 1.0 z)) z)) (* (/ x z) (+ y 1.0))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -9.5e-17) || !(z <= 1.5e-34)) {
tmp = x * ((y + (1.0 - z)) / z);
} else {
tmp = (x / z) * (y + 1.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) :: tmp
if ((z <= (-9.5d-17)) .or. (.not. (z <= 1.5d-34))) then
tmp = x * ((y + (1.0d0 - z)) / z)
else
tmp = (x / z) * (y + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -9.5e-17) || !(z <= 1.5e-34)) {
tmp = x * ((y + (1.0 - z)) / z);
} else {
tmp = (x / z) * (y + 1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -9.5e-17) or not (z <= 1.5e-34): tmp = x * ((y + (1.0 - z)) / z) else: tmp = (x / z) * (y + 1.0) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -9.5e-17) || !(z <= 1.5e-34)) tmp = Float64(x * Float64(Float64(y + Float64(1.0 - z)) / z)); else tmp = Float64(Float64(x / z) * Float64(y + 1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -9.5e-17) || ~((z <= 1.5e-34))) tmp = x * ((y + (1.0 - z)) / z); else tmp = (x / z) * (y + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -9.5e-17], N[Not[LessEqual[z, 1.5e-34]], $MachinePrecision]], N[(x * N[(N[(y + N[(1.0 - z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.5 \cdot 10^{-17} \lor \neg \left(z \leq 1.5 \cdot 10^{-34}\right):\\
\;\;\;\;x \cdot \frac{y + \left(1 - z\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(y + 1\right)\\
\end{array}
\end{array}
if z < -9.50000000000000029e-17 or 1.5e-34 < z Initial program 76.5%
Taylor expanded in x around 0 76.5%
associate--l+76.5%
+-commutative76.5%
associate-*r/99.9%
associate-+l-99.9%
Simplified99.9%
if -9.50000000000000029e-17 < z < 1.5e-34Initial program 99.9%
Taylor expanded in z around 0 99.9%
associate-/l*88.9%
associate-/r/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= x 4.8e-14) (+ (/ (* x y) z) (/ (* x (- 1.0 z)) z)) (/ x (/ z (+ y (- 1.0 z))))))
double code(double x, double y, double z) {
double tmp;
if (x <= 4.8e-14) {
tmp = ((x * y) / z) + ((x * (1.0 - z)) / z);
} else {
tmp = x / (z / (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 (x <= 4.8d-14) then
tmp = ((x * y) / z) + ((x * (1.0d0 - z)) / z)
else
tmp = x / (z / (y + (1.0d0 - z)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 4.8e-14) {
tmp = ((x * y) / z) + ((x * (1.0 - z)) / z);
} else {
tmp = x / (z / (y + (1.0 - z)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 4.8e-14: tmp = ((x * y) / z) + ((x * (1.0 - z)) / z) else: tmp = x / (z / (y + (1.0 - z))) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 4.8e-14) tmp = Float64(Float64(Float64(x * y) / z) + Float64(Float64(x * Float64(1.0 - z)) / z)); else tmp = Float64(x / Float64(z / Float64(y + Float64(1.0 - z)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 4.8e-14) tmp = ((x * y) / z) + ((x * (1.0 - z)) / z); else tmp = x / (z / (y + (1.0 - z))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 4.8e-14], N[(N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision] + N[(N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(x / N[(z / N[(y + N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.8 \cdot 10^{-14}:\\
\;\;\;\;\frac{x \cdot y}{z} + \frac{x \cdot \left(1 - z\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{y + \left(1 - z\right)}}\\
\end{array}
\end{array}
if x < 4.8e-14Initial program 91.1%
Taylor expanded in y around 0 88.5%
if 4.8e-14 < x Initial program 75.7%
Taylor expanded in x around 0 75.7%
associate--l+75.7%
+-commutative75.7%
associate-*r/99.9%
associate-+l-99.9%
Simplified99.9%
clear-num99.8%
un-div-inv99.9%
*-un-lft-identity99.9%
*-un-lft-identity99.9%
sub-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
sub-neg99.9%
Applied egg-rr99.9%
Final simplification90.9%
(FPCore (x y z) :precision binary64 (if (<= y -2.6e+29) (/ (* x y) z) (if (<= y 27500000.0) (- (/ x z) x) (* (/ x z) (+ y 1.0)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.6e+29) {
tmp = (x * y) / z;
} else if (y <= 27500000.0) {
tmp = (x / z) - x;
} else {
tmp = (x / z) * (y + 1.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) :: tmp
if (y <= (-2.6d+29)) then
tmp = (x * y) / z
else if (y <= 27500000.0d0) then
tmp = (x / z) - x
else
tmp = (x / z) * (y + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.6e+29) {
tmp = (x * y) / z;
} else if (y <= 27500000.0) {
tmp = (x / z) - x;
} else {
tmp = (x / z) * (y + 1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.6e+29: tmp = (x * y) / z elif y <= 27500000.0: tmp = (x / z) - x else: tmp = (x / z) * (y + 1.0) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.6e+29) tmp = Float64(Float64(x * y) / z); elseif (y <= 27500000.0) tmp = Float64(Float64(x / z) - x); else tmp = Float64(Float64(x / z) * Float64(y + 1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.6e+29) tmp = (x * y) / z; elseif (y <= 27500000.0) tmp = (x / z) - x; else tmp = (x / z) * (y + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.6e+29], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 27500000.0], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.6 \cdot 10^{+29}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{elif}\;y \leq 27500000:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(y + 1\right)\\
\end{array}
\end{array}
if y < -2.6e29Initial program 89.5%
Taylor expanded in y around inf 80.6%
if -2.6e29 < y < 2.75e7Initial program 84.6%
Taylor expanded in x around 0 84.6%
associate--l+84.6%
+-commutative84.6%
associate-*r/99.8%
associate-+l-99.8%
Simplified99.8%
Taylor expanded in y around 0 83.1%
associate-*l/87.3%
sub-neg87.3%
distribute-lft-out85.8%
*-rgt-identity85.8%
*-commutative85.8%
distribute-lft-neg-out85.8%
unsub-neg85.8%
*-commutative85.8%
associate-*l/83.2%
associate-/l*98.6%
*-inverses98.6%
/-rgt-identity98.6%
Simplified98.6%
if 2.75e7 < y Initial program 93.5%
Taylor expanded in z around 0 84.6%
associate-/l*76.3%
associate-/r/86.0%
Simplified86.0%
Final simplification91.2%
(FPCore (x y z) :precision binary64 (if (<= y -5.3e+29) (/ (* x y) z) (if (<= y 13800000000.0) (/ x (/ z (- 1.0 z))) (* (/ x z) (+ y 1.0)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.3e+29) {
tmp = (x * y) / z;
} else if (y <= 13800000000.0) {
tmp = x / (z / (1.0 - z));
} else {
tmp = (x / z) * (y + 1.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) :: tmp
if (y <= (-5.3d+29)) then
tmp = (x * y) / z
else if (y <= 13800000000.0d0) then
tmp = x / (z / (1.0d0 - z))
else
tmp = (x / z) * (y + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5.3e+29) {
tmp = (x * y) / z;
} else if (y <= 13800000000.0) {
tmp = x / (z / (1.0 - z));
} else {
tmp = (x / z) * (y + 1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.3e+29: tmp = (x * y) / z elif y <= 13800000000.0: tmp = x / (z / (1.0 - z)) else: tmp = (x / z) * (y + 1.0) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.3e+29) tmp = Float64(Float64(x * y) / z); elseif (y <= 13800000000.0) tmp = Float64(x / Float64(z / Float64(1.0 - z))); else tmp = Float64(Float64(x / z) * Float64(y + 1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.3e+29) tmp = (x * y) / z; elseif (y <= 13800000000.0) tmp = x / (z / (1.0 - z)); else tmp = (x / z) * (y + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.3e+29], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 13800000000.0], N[(x / N[(z / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.3 \cdot 10^{+29}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{elif}\;y \leq 13800000000:\\
\;\;\;\;\frac{x}{\frac{z}{1 - z}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(y + 1\right)\\
\end{array}
\end{array}
if y < -5.3e29Initial program 89.5%
Taylor expanded in y around inf 80.6%
if -5.3e29 < y < 1.38e10Initial program 84.6%
Taylor expanded in y around 0 83.1%
associate-/l*98.6%
Simplified98.6%
if 1.38e10 < y Initial program 93.5%
Taylor expanded in z around 0 84.6%
associate-/l*76.3%
associate-/r/86.0%
Simplified86.0%
Final simplification91.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.55e+29) (not (<= y 92000000000.0))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.55e+29) || !(y <= 92000000000.0)) {
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 <= (-2.55d+29)) .or. (.not. (y <= 92000000000.0d0))) 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 <= -2.55e+29) || !(y <= 92000000000.0)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.55e+29) or not (y <= 92000000000.0): tmp = y * (x / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.55e+29) || !(y <= 92000000000.0)) 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 <= -2.55e+29) || ~((y <= 92000000000.0))) tmp = y * (x / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.55e+29], N[Not[LessEqual[y, 92000000000.0]], $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 -2.55 \cdot 10^{+29} \lor \neg \left(y \leq 92000000000\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -2.55e29 or 9.2e10 < y Initial program 91.4%
Taylor expanded in y around inf 82.3%
associate-/l*72.9%
associate-/r/80.3%
Simplified80.3%
if -2.55e29 < y < 9.2e10Initial program 84.6%
Taylor expanded in x around 0 84.6%
associate--l+84.6%
+-commutative84.6%
associate-*r/99.8%
associate-+l-99.8%
Simplified99.8%
Taylor expanded in y around 0 83.1%
associate-*l/87.3%
sub-neg87.3%
distribute-lft-out85.8%
*-rgt-identity85.8%
*-commutative85.8%
distribute-lft-neg-out85.8%
unsub-neg85.8%
*-commutative85.8%
associate-*l/83.2%
associate-/l*98.6%
*-inverses98.6%
/-rgt-identity98.6%
Simplified98.6%
Final simplification89.9%
(FPCore (x y z) :precision binary64 (if (<= y -3.5e+29) (/ (* x y) z) (if (<= y 1250000000000.0) (- (/ x z) x) (* y (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.5e+29) {
tmp = (x * y) / z;
} else if (y <= 1250000000000.0) {
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 <= (-3.5d+29)) then
tmp = (x * y) / z
else if (y <= 1250000000000.0d0) 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 <= -3.5e+29) {
tmp = (x * y) / z;
} else if (y <= 1250000000000.0) {
tmp = (x / z) - x;
} else {
tmp = y * (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.5e+29: tmp = (x * y) / z elif y <= 1250000000000.0: tmp = (x / z) - x else: tmp = y * (x / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.5e+29) tmp = Float64(Float64(x * y) / z); elseif (y <= 1250000000000.0) 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 <= -3.5e+29) tmp = (x * y) / z; elseif (y <= 1250000000000.0) tmp = (x / z) - x; else tmp = y * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.5e+29], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 1250000000000.0], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.5 \cdot 10^{+29}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{elif}\;y \leq 1250000000000:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\end{array}
\end{array}
if y < -3.49999999999999979e29Initial program 89.5%
Taylor expanded in y around inf 80.6%
if -3.49999999999999979e29 < y < 1.25e12Initial program 84.6%
Taylor expanded in x around 0 84.6%
associate--l+84.6%
+-commutative84.6%
associate-*r/99.8%
associate-+l-99.8%
Simplified99.8%
Taylor expanded in y around 0 83.1%
associate-*l/87.3%
sub-neg87.3%
distribute-lft-out85.8%
*-rgt-identity85.8%
*-commutative85.8%
distribute-lft-neg-out85.8%
unsub-neg85.8%
*-commutative85.8%
associate-*l/83.2%
associate-/l*98.6%
*-inverses98.6%
/-rgt-identity98.6%
Simplified98.6%
if 1.25e12 < y Initial program 93.5%
Taylor expanded in y around inf 84.1%
associate-/l*75.9%
associate-/r/85.5%
Simplified85.5%
Final simplification91.1%
(FPCore (x y z) :precision binary64 (if (<= x 2e-15) (/ (* x (+ 1.0 (- y z))) z) (/ x (/ z (+ y (- 1.0 z))))))
double code(double x, double y, double z) {
double tmp;
if (x <= 2e-15) {
tmp = (x * (1.0 + (y - z))) / z;
} else {
tmp = x / (z / (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 (x <= 2d-15) then
tmp = (x * (1.0d0 + (y - z))) / z
else
tmp = x / (z / (y + (1.0d0 - z)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 2e-15) {
tmp = (x * (1.0 + (y - z))) / z;
} else {
tmp = x / (z / (y + (1.0 - z)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 2e-15: tmp = (x * (1.0 + (y - z))) / z else: tmp = x / (z / (y + (1.0 - z))) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 2e-15) tmp = Float64(Float64(x * Float64(1.0 + Float64(y - z))) / z); else tmp = Float64(x / Float64(z / Float64(y + Float64(1.0 - z)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 2e-15) tmp = (x * (1.0 + (y - z))) / z; else tmp = x / (z / (y + (1.0 - z))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 2e-15], N[(N[(x * N[(1.0 + N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(x / N[(z / N[(y + N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2 \cdot 10^{-15}:\\
\;\;\;\;\frac{x \cdot \left(1 + \left(y - z\right)\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{y + \left(1 - z\right)}}\\
\end{array}
\end{array}
if x < 2.0000000000000002e-15Initial program 91.1%
if 2.0000000000000002e-15 < x Initial program 75.7%
Taylor expanded in x around 0 75.7%
associate--l+75.7%
+-commutative75.7%
associate-*r/99.9%
associate-+l-99.9%
Simplified99.9%
clear-num99.8%
un-div-inv99.9%
*-un-lft-identity99.9%
*-un-lft-identity99.9%
sub-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
sub-neg99.9%
Applied egg-rr99.9%
Final simplification93.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (- x) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = -x;
} else {
tmp = 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 <= 1.0d0))) then
tmp = -x
else
tmp = 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 <= 1.0)) {
tmp = -x;
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = -x else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(-x); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 1.0))) tmp = -x; else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], (-x), N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 74.0%
Taylor expanded in z around inf 72.8%
mul-1-neg72.8%
Simplified72.8%
if -1 < z < 1Initial program 99.9%
Taylor expanded in y around 0 54.8%
associate-/l*54.8%
Simplified54.8%
Taylor expanded in z around 0 53.6%
Final simplification62.5%
(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 35.6%
mul-1-neg35.6%
Simplified35.6%
Final simplification35.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 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 24.9%
associate-*r*24.9%
mul-1-neg24.9%
Simplified24.9%
div-inv24.9%
associate-*l*35.5%
div-inv35.6%
*-inverses35.6%
*-commutative35.6%
*-un-lft-identity35.6%
neg-sub035.6%
sub-neg35.6%
add-sqr-sqrt18.4%
sqrt-unprod17.6%
sqr-neg17.6%
sqrt-unprod1.4%
add-sqr-sqrt3.2%
Applied egg-rr3.2%
+-lft-identity3.2%
Simplified3.2%
Final simplification3.2%
(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 2024024
(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))