
(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 (if (or (<= z -0.0002) (not (<= z 4.6e+16))) (/ x (/ z (+ 1.0 (- y z)))) (/ (fma x (- y z) x) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.0002) || !(z <= 4.6e+16)) {
tmp = x / (z / (1.0 + (y - z)));
} else {
tmp = fma(x, (y - z), x) / z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((z <= -0.0002) || !(z <= 4.6e+16)) tmp = Float64(x / Float64(z / Float64(1.0 + Float64(y - z)))); else tmp = Float64(fma(x, Float64(y - z), x) / z); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.0002], N[Not[LessEqual[z, 4.6e+16]], $MachinePrecision]], N[(x / N[(z / N[(1.0 + N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(y - z), $MachinePrecision] + x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.0002 \lor \neg \left(z \leq 4.6 \cdot 10^{+16}\right):\\
\;\;\;\;\frac{x}{\frac{z}{1 + \left(y - z\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y - z, x\right)}{z}\\
\end{array}
\end{array}
if z < -2.0000000000000001e-4 or 4.6e16 < z Initial program 78.3%
div-inv78.2%
associate-*l*99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 78.3%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
if -2.0000000000000001e-4 < z < 4.6e16Initial program 99.9%
distribute-lft-in99.9%
fma-def99.9%
*-rgt-identity99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ y z))))
(if (<= z -6.8e+31)
(- x)
(if (<= z -6e-61)
t_0
(if (<= z -2.6e-150)
(/ x z)
(if (<= z -3.05e-192)
t_0
(if (<= z 2.4e-178)
(/ x z)
(if (<= z 6.1e-32)
t_0
(if (<= z 3.3e-10)
(/ x z)
(if (<= z 4.2e+62) t_0 (- x)))))))))))
double code(double x, double y, double z) {
double t_0 = x * (y / z);
double tmp;
if (z <= -6.8e+31) {
tmp = -x;
} else if (z <= -6e-61) {
tmp = t_0;
} else if (z <= -2.6e-150) {
tmp = x / z;
} else if (z <= -3.05e-192) {
tmp = t_0;
} else if (z <= 2.4e-178) {
tmp = x / z;
} else if (z <= 6.1e-32) {
tmp = t_0;
} else if (z <= 3.3e-10) {
tmp = x / z;
} else if (z <= 4.2e+62) {
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 <= (-6.8d+31)) then
tmp = -x
else if (z <= (-6d-61)) then
tmp = t_0
else if (z <= (-2.6d-150)) then
tmp = x / z
else if (z <= (-3.05d-192)) then
tmp = t_0
else if (z <= 2.4d-178) then
tmp = x / z
else if (z <= 6.1d-32) then
tmp = t_0
else if (z <= 3.3d-10) then
tmp = x / z
else if (z <= 4.2d+62) 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 <= -6.8e+31) {
tmp = -x;
} else if (z <= -6e-61) {
tmp = t_0;
} else if (z <= -2.6e-150) {
tmp = x / z;
} else if (z <= -3.05e-192) {
tmp = t_0;
} else if (z <= 2.4e-178) {
tmp = x / z;
} else if (z <= 6.1e-32) {
tmp = t_0;
} else if (z <= 3.3e-10) {
tmp = x / z;
} else if (z <= 4.2e+62) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y / z) tmp = 0 if z <= -6.8e+31: tmp = -x elif z <= -6e-61: tmp = t_0 elif z <= -2.6e-150: tmp = x / z elif z <= -3.05e-192: tmp = t_0 elif z <= 2.4e-178: tmp = x / z elif z <= 6.1e-32: tmp = t_0 elif z <= 3.3e-10: tmp = x / z elif z <= 4.2e+62: 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 <= -6.8e+31) tmp = Float64(-x); elseif (z <= -6e-61) tmp = t_0; elseif (z <= -2.6e-150) tmp = Float64(x / z); elseif (z <= -3.05e-192) tmp = t_0; elseif (z <= 2.4e-178) tmp = Float64(x / z); elseif (z <= 6.1e-32) tmp = t_0; elseif (z <= 3.3e-10) tmp = Float64(x / z); elseif (z <= 4.2e+62) 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 <= -6.8e+31) tmp = -x; elseif (z <= -6e-61) tmp = t_0; elseif (z <= -2.6e-150) tmp = x / z; elseif (z <= -3.05e-192) tmp = t_0; elseif (z <= 2.4e-178) tmp = x / z; elseif (z <= 6.1e-32) tmp = t_0; elseif (z <= 3.3e-10) tmp = x / z; elseif (z <= 4.2e+62) 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, -6.8e+31], (-x), If[LessEqual[z, -6e-61], t$95$0, If[LessEqual[z, -2.6e-150], N[(x / z), $MachinePrecision], If[LessEqual[z, -3.05e-192], t$95$0, If[LessEqual[z, 2.4e-178], N[(x / z), $MachinePrecision], If[LessEqual[z, 6.1e-32], t$95$0, If[LessEqual[z, 3.3e-10], N[(x / z), $MachinePrecision], If[LessEqual[z, 4.2e+62], t$95$0, (-x)]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{y}{z}\\
\mathbf{if}\;z \leq -6.8 \cdot 10^{+31}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -6 \cdot 10^{-61}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -2.6 \cdot 10^{-150}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq -3.05 \cdot 10^{-192}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 2.4 \cdot 10^{-178}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 6.1 \cdot 10^{-32}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 3.3 \cdot 10^{-10}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{+62}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -6.7999999999999996e31 or 4.2e62 < z Initial program 74.5%
Taylor expanded in z around inf 77.5%
neg-mul-177.5%
Simplified77.5%
if -6.7999999999999996e31 < z < -6.00000000000000024e-61 or -2.5999999999999998e-150 < z < -3.05e-192 or 2.40000000000000005e-178 < z < 6.09999999999999959e-32 or 3.3e-10 < z < 4.2e62Initial program 98.6%
div-inv98.5%
associate-*l*93.7%
Applied egg-rr93.7%
Taylor expanded in y around inf 73.2%
associate-*r/68.4%
Simplified68.4%
if -6.00000000000000024e-61 < z < -2.5999999999999998e-150 or -3.05e-192 < z < 2.40000000000000005e-178 or 6.09999999999999959e-32 < z < 3.3e-10Initial program 99.9%
Taylor expanded in y around 0 71.2%
associate-/l*71.2%
associate-/r/71.2%
Simplified71.2%
Taylor expanded in z around 0 70.7%
Final simplification72.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -4.3e+26)
(- x)
(if (<= z -2.3e-68)
t_0
(if (<= z -5e-147)
(/ x z)
(if (<= z 3.7e-296)
t_0
(if (<= z 5e-175)
(/ x z)
(if (<= z 6e-36)
t_0
(if (<= z 1.9e-9)
(/ x z)
(if (<= z 5.9e+63) (* x (/ y z)) (- x)))))))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -4.3e+26) {
tmp = -x;
} else if (z <= -2.3e-68) {
tmp = t_0;
} else if (z <= -5e-147) {
tmp = x / z;
} else if (z <= 3.7e-296) {
tmp = t_0;
} else if (z <= 5e-175) {
tmp = x / z;
} else if (z <= 6e-36) {
tmp = t_0;
} else if (z <= 1.9e-9) {
tmp = x / z;
} else if (z <= 5.9e+63) {
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) :: t_0
real(8) :: tmp
t_0 = y * (x / z)
if (z <= (-4.3d+26)) then
tmp = -x
else if (z <= (-2.3d-68)) then
tmp = t_0
else if (z <= (-5d-147)) then
tmp = x / z
else if (z <= 3.7d-296) then
tmp = t_0
else if (z <= 5d-175) then
tmp = x / z
else if (z <= 6d-36) then
tmp = t_0
else if (z <= 1.9d-9) then
tmp = x / z
else if (z <= 5.9d+63) 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 t_0 = y * (x / z);
double tmp;
if (z <= -4.3e+26) {
tmp = -x;
} else if (z <= -2.3e-68) {
tmp = t_0;
} else if (z <= -5e-147) {
tmp = x / z;
} else if (z <= 3.7e-296) {
tmp = t_0;
} else if (z <= 5e-175) {
tmp = x / z;
} else if (z <= 6e-36) {
tmp = t_0;
} else if (z <= 1.9e-9) {
tmp = x / z;
} else if (z <= 5.9e+63) {
tmp = x * (y / z);
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -4.3e+26: tmp = -x elif z <= -2.3e-68: tmp = t_0 elif z <= -5e-147: tmp = x / z elif z <= 3.7e-296: tmp = t_0 elif z <= 5e-175: tmp = x / z elif z <= 6e-36: tmp = t_0 elif z <= 1.9e-9: tmp = x / z elif z <= 5.9e+63: tmp = x * (y / z) else: tmp = -x return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x / z)) tmp = 0.0 if (z <= -4.3e+26) tmp = Float64(-x); elseif (z <= -2.3e-68) tmp = t_0; elseif (z <= -5e-147) tmp = Float64(x / z); elseif (z <= 3.7e-296) tmp = t_0; elseif (z <= 5e-175) tmp = Float64(x / z); elseif (z <= 6e-36) tmp = t_0; elseif (z <= 1.9e-9) tmp = Float64(x / z); elseif (z <= 5.9e+63) tmp = Float64(x * Float64(y / z)); 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.3e+26) tmp = -x; elseif (z <= -2.3e-68) tmp = t_0; elseif (z <= -5e-147) tmp = x / z; elseif (z <= 3.7e-296) tmp = t_0; elseif (z <= 5e-175) tmp = x / z; elseif (z <= 6e-36) tmp = t_0; elseif (z <= 1.9e-9) tmp = x / z; elseif (z <= 5.9e+63) tmp = x * (y / z); 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.3e+26], (-x), If[LessEqual[z, -2.3e-68], t$95$0, If[LessEqual[z, -5e-147], N[(x / z), $MachinePrecision], If[LessEqual[z, 3.7e-296], t$95$0, If[LessEqual[z, 5e-175], N[(x / z), $MachinePrecision], If[LessEqual[z, 6e-36], t$95$0, If[LessEqual[z, 1.9e-9], N[(x / z), $MachinePrecision], If[LessEqual[z, 5.9e+63], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision], (-x)]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -4.3 \cdot 10^{+26}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -2.3 \cdot 10^{-68}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -5 \cdot 10^{-147}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 3.7 \cdot 10^{-296}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 5 \cdot 10^{-175}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 6 \cdot 10^{-36}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.9 \cdot 10^{-9}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 5.9 \cdot 10^{+63}:\\
\;\;\;\;x \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -4.2999999999999998e26 or 5.90000000000000029e63 < z Initial program 75.0%
Taylor expanded in z around inf 77.0%
neg-mul-177.0%
Simplified77.0%
if -4.2999999999999998e26 < z < -2.29999999999999997e-68 or -5.00000000000000013e-147 < z < 3.70000000000000027e-296 or 5e-175 < z < 6.0000000000000003e-36Initial program 99.8%
Taylor expanded in y around inf 73.4%
associate-/l*64.0%
associate-/r/74.7%
Simplified74.7%
if -2.29999999999999997e-68 < z < -5.00000000000000013e-147 or 3.70000000000000027e-296 < z < 5e-175 or 6.0000000000000003e-36 < z < 1.90000000000000006e-9Initial program 100.0%
Taylor expanded in y around 0 78.2%
associate-/l*78.2%
associate-/r/78.2%
Simplified78.2%
Taylor expanded in z around 0 77.5%
if 1.90000000000000006e-9 < z < 5.90000000000000029e63Initial program 94.5%
div-inv94.5%
associate-*l*99.5%
Applied egg-rr99.5%
Taylor expanded in y around inf 62.8%
associate-*r/68.0%
Simplified68.0%
Final simplification75.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (- y z))))
(if (or (<= z -6e+27) (not (<= z 1.8e-111)))
(/ x (/ z t_0))
(* t_0 (/ x z)))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (y - z);
double tmp;
if ((z <= -6e+27) || !(z <= 1.8e-111)) {
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 = 1.0d0 + (y - z)
if ((z <= (-6d+27)) .or. (.not. (z <= 1.8d-111))) 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 = 1.0 + (y - z);
double tmp;
if ((z <= -6e+27) || !(z <= 1.8e-111)) {
tmp = x / (z / t_0);
} else {
tmp = t_0 * (x / z);
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (y - z) tmp = 0 if (z <= -6e+27) or not (z <= 1.8e-111): tmp = x / (z / t_0) else: tmp = t_0 * (x / z) return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(y - z)) tmp = 0.0 if ((z <= -6e+27) || !(z <= 1.8e-111)) 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 = 1.0 + (y - z); tmp = 0.0; if ((z <= -6e+27) || ~((z <= 1.8e-111))) 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[(1.0 + N[(y - z), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[z, -6e+27], N[Not[LessEqual[z, 1.8e-111]], $MachinePrecision]], 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 := 1 + \left(y - z\right)\\
\mathbf{if}\;z \leq -6 \cdot 10^{+27} \lor \neg \left(z \leq 1.8 \cdot 10^{-111}\right):\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{x}{z}\\
\end{array}
\end{array}
if z < -5.99999999999999953e27 or 1.80000000000000005e-111 < z Initial program 80.4%
div-inv80.3%
associate-*l*99.7%
Applied egg-rr99.7%
Taylor expanded in x around 0 80.4%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
if -5.99999999999999953e27 < z < 1.80000000000000005e-111Initial program 99.8%
associate-/l*90.1%
associate-/r/99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= z -1.06e+182) (- x) (if (<= z 7e+146) (* (+ 1.0 (- y z)) (/ x z)) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.06e+182) {
tmp = -x;
} else if (z <= 7e+146) {
tmp = (1.0 + (y - z)) * (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.06d+182)) then
tmp = -x
else if (z <= 7d+146) then
tmp = (1.0d0 + (y - z)) * (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.06e+182) {
tmp = -x;
} else if (z <= 7e+146) {
tmp = (1.0 + (y - z)) * (x / z);
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.06e+182: tmp = -x elif z <= 7e+146: tmp = (1.0 + (y - z)) * (x / z) else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.06e+182) tmp = Float64(-x); elseif (z <= 7e+146) tmp = Float64(Float64(1.0 + Float64(y - z)) * Float64(x / z)); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.06e+182) tmp = -x; elseif (z <= 7e+146) tmp = (1.0 + (y - z)) * (x / z); else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.06e+182], (-x), If[LessEqual[z, 7e+146], N[(N[(1.0 + N[(y - z), $MachinePrecision]), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.06 \cdot 10^{+182}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 7 \cdot 10^{+146}:\\
\;\;\;\;\left(1 + \left(y - z\right)\right) \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1.0599999999999999e182 or 7.0000000000000002e146 < z Initial program 72.1%
Taylor expanded in z around inf 84.3%
neg-mul-184.3%
Simplified84.3%
if -1.0599999999999999e182 < z < 7.0000000000000002e146Initial program 93.7%
associate-/l*94.4%
associate-/r/96.3%
Applied egg-rr96.3%
Final simplification93.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.2e+38) (not (<= y 1.14e+24))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.2e+38) || !(y <= 1.14e+24)) {
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 <= (-6.2d+38)) .or. (.not. (y <= 1.14d+24))) 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 <= -6.2e+38) || !(y <= 1.14e+24)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.2e+38) or not (y <= 1.14e+24): tmp = y * (x / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.2e+38) || !(y <= 1.14e+24)) 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 <= -6.2e+38) || ~((y <= 1.14e+24))) tmp = y * (x / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.2e+38], N[Not[LessEqual[y, 1.14e+24]], $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 -6.2 \cdot 10^{+38} \lor \neg \left(y \leq 1.14 \cdot 10^{+24}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -6.20000000000000035e38 or 1.14e24 < y Initial program 91.4%
Taylor expanded in y around inf 80.6%
associate-/l*75.8%
associate-/r/80.0%
Simplified80.0%
if -6.20000000000000035e38 < y < 1.14e24Initial program 86.5%
div-inv86.3%
associate-*l*99.0%
Applied egg-rr99.0%
Taylor expanded in y around 0 81.8%
*-commutative81.8%
associate-/l*81.8%
div-sub74.4%
associate-/r/74.3%
associate-*l/74.5%
*-lft-identity74.5%
associate-/r/95.3%
*-inverses95.3%
*-lft-identity95.3%
Simplified95.3%
Final simplification88.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.4e+41) (not (<= y 1.1e+24))) (/ (* x y) z) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.4e+41) || !(y <= 1.1e+24)) {
tmp = (x * y) / 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.4d+41)) .or. (.not. (y <= 1.1d+24))) then
tmp = (x * y) / 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.4e+41) || !(y <= 1.1e+24)) {
tmp = (x * y) / z;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.4e+41) or not (y <= 1.1e+24): tmp = (x * y) / z else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.4e+41) || !(y <= 1.1e+24)) tmp = Float64(Float64(x * y) / 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.4e+41) || ~((y <= 1.1e+24))) tmp = (x * y) / z; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.4e+41], N[Not[LessEqual[y, 1.1e+24]], $MachinePrecision]], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{+41} \lor \neg \left(y \leq 1.1 \cdot 10^{+24}\right):\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1.4e41 or 1.10000000000000001e24 < y Initial program 91.4%
Taylor expanded in y around inf 80.6%
if -1.4e41 < y < 1.10000000000000001e24Initial program 86.5%
div-inv86.3%
associate-*l*99.0%
Applied egg-rr99.0%
Taylor expanded in y around 0 81.8%
*-commutative81.8%
associate-/l*81.8%
div-sub74.4%
associate-/r/74.3%
associate-*l/74.5%
*-lft-identity74.5%
associate-/r/95.3%
*-inverses95.3%
*-lft-identity95.3%
Simplified95.3%
Final simplification88.3%
(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 78.6%
Taylor expanded in z around inf 68.4%
neg-mul-168.4%
Simplified68.4%
if -1 < z < 1Initial program 99.9%
Taylor expanded in y around 0 56.3%
associate-/l*56.3%
associate-/r/56.3%
Simplified56.3%
Taylor expanded in z around 0 55.1%
Final simplification62.0%
(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 88.8%
Taylor expanded in z around inf 37.2%
neg-mul-137.2%
Simplified37.2%
Final simplification37.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 2023280
(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))