
(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 7 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 (/ x (/ z (+ (- y z) 1.0))))
double code(double x, double y, double z) {
return x / (z / ((y - z) + 1.0));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x / (z / ((y - z) + 1.0d0))
end function
public static double code(double x, double y, double z) {
return x / (z / ((y - z) + 1.0));
}
def code(x, y, z): return x / (z / ((y - z) + 1.0))
function code(x, y, z) return Float64(x / Float64(z / Float64(Float64(y - z) + 1.0))) end
function tmp = code(x, y, z) tmp = x / (z / ((y - z) + 1.0)); end
code[x_, y_, z_] := N[(x / N[(z / N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\frac{z}{\left(y - z\right) + 1}}
\end{array}
Initial program 87.4%
associate-/l*97.0%
Simplified97.0%
Final simplification97.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -4.1e+73)
(- x)
(if (<= z -1.25e-44)
t_0
(if (<= z -3e-208)
(/ x z)
(if (<= z -5.8e-270)
t_0
(if (<= z 1.06e-191)
(/ x z)
(if (<= z 6.2e-65) t_0 (if (<= z 1.0) (/ x z) (- x))))))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -4.1e+73) {
tmp = -x;
} else if (z <= -1.25e-44) {
tmp = t_0;
} else if (z <= -3e-208) {
tmp = x / z;
} else if (z <= -5.8e-270) {
tmp = t_0;
} else if (z <= 1.06e-191) {
tmp = x / z;
} else if (z <= 6.2e-65) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = y * (x / z)
if (z <= (-4.1d+73)) then
tmp = -x
else if (z <= (-1.25d-44)) then
tmp = t_0
else if (z <= (-3d-208)) then
tmp = x / z
else if (z <= (-5.8d-270)) then
tmp = t_0
else if (z <= 1.06d-191) then
tmp = x / z
else if (z <= 6.2d-65) then
tmp = t_0
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 t_0 = y * (x / z);
double tmp;
if (z <= -4.1e+73) {
tmp = -x;
} else if (z <= -1.25e-44) {
tmp = t_0;
} else if (z <= -3e-208) {
tmp = x / z;
} else if (z <= -5.8e-270) {
tmp = t_0;
} else if (z <= 1.06e-191) {
tmp = x / z;
} else if (z <= 6.2e-65) {
tmp = t_0;
} else if (z <= 1.0) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -4.1e+73: tmp = -x elif z <= -1.25e-44: tmp = t_0 elif z <= -3e-208: tmp = x / z elif z <= -5.8e-270: tmp = t_0 elif z <= 1.06e-191: tmp = x / z elif z <= 6.2e-65: tmp = t_0 elif z <= 1.0: tmp = x / z else: tmp = -x return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x / z)) tmp = 0.0 if (z <= -4.1e+73) tmp = Float64(-x); elseif (z <= -1.25e-44) tmp = t_0; elseif (z <= -3e-208) tmp = Float64(x / z); elseif (z <= -5.8e-270) tmp = t_0; elseif (z <= 1.06e-191) tmp = Float64(x / z); elseif (z <= 6.2e-65) tmp = t_0; elseif (z <= 1.0) tmp = Float64(x / 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.1e+73) tmp = -x; elseif (z <= -1.25e-44) tmp = t_0; elseif (z <= -3e-208) tmp = x / z; elseif (z <= -5.8e-270) tmp = t_0; elseif (z <= 1.06e-191) tmp = x / z; elseif (z <= 6.2e-65) tmp = t_0; elseif (z <= 1.0) tmp = x / 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.1e+73], (-x), If[LessEqual[z, -1.25e-44], t$95$0, If[LessEqual[z, -3e-208], N[(x / z), $MachinePrecision], If[LessEqual[z, -5.8e-270], t$95$0, If[LessEqual[z, 1.06e-191], N[(x / z), $MachinePrecision], If[LessEqual[z, 6.2e-65], t$95$0, If[LessEqual[z, 1.0], N[(x / z), $MachinePrecision], (-x)]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -4.1 \cdot 10^{+73}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -1.25 \cdot 10^{-44}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -3 \cdot 10^{-208}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq -5.8 \cdot 10^{-270}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.06 \cdot 10^{-191}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 6.2 \cdot 10^{-65}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -4.0999999999999998e73 or 1 < z Initial program 74.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around inf 76.9%
neg-mul-176.9%
Simplified76.9%
if -4.0999999999999998e73 < z < -1.2500000000000001e-44 or -2.99999999999999986e-208 < z < -5.79999999999999965e-270 or 1.05999999999999994e-191 < z < 6.20000000000000032e-65Initial program 96.7%
associate-/l*91.9%
Simplified91.9%
Taylor expanded in y around inf 69.0%
*-commutative69.0%
associate-/l*64.1%
Simplified64.1%
associate-/r/75.2%
Applied egg-rr75.2%
if -1.2500000000000001e-44 < z < -2.99999999999999986e-208 or -5.79999999999999965e-270 < z < 1.05999999999999994e-191 or 6.20000000000000032e-65 < z < 1Initial program 99.9%
associate-/l*96.3%
Simplified96.3%
Taylor expanded in z around 0 95.1%
Taylor expanded in y around 0 72.2%
Final simplification75.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -1.7e+74)
(- x)
(if (<= z -5.8e-43)
(* x (/ y z))
(if (<= z -1.25e-208)
(/ x z)
(if (<= z -3.6e-270)
t_0
(if (<= z 4.8e-191)
(/ x z)
(if (<= z 4e-65) t_0 (if (<= z 1.0) (/ x z) (- x))))))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -1.7e+74) {
tmp = -x;
} else if (z <= -5.8e-43) {
tmp = x * (y / z);
} else if (z <= -1.25e-208) {
tmp = x / z;
} else if (z <= -3.6e-270) {
tmp = t_0;
} else if (z <= 4.8e-191) {
tmp = x / z;
} else if (z <= 4e-65) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = y * (x / z)
if (z <= (-1.7d+74)) then
tmp = -x
else if (z <= (-5.8d-43)) then
tmp = x * (y / z)
else if (z <= (-1.25d-208)) then
tmp = x / z
else if (z <= (-3.6d-270)) then
tmp = t_0
else if (z <= 4.8d-191) then
tmp = x / z
else if (z <= 4d-65) then
tmp = t_0
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 t_0 = y * (x / z);
double tmp;
if (z <= -1.7e+74) {
tmp = -x;
} else if (z <= -5.8e-43) {
tmp = x * (y / z);
} else if (z <= -1.25e-208) {
tmp = x / z;
} else if (z <= -3.6e-270) {
tmp = t_0;
} else if (z <= 4.8e-191) {
tmp = x / z;
} else if (z <= 4e-65) {
tmp = t_0;
} else if (z <= 1.0) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -1.7e+74: tmp = -x elif z <= -5.8e-43: tmp = x * (y / z) elif z <= -1.25e-208: tmp = x / z elif z <= -3.6e-270: tmp = t_0 elif z <= 4.8e-191: tmp = x / z elif z <= 4e-65: tmp = t_0 elif z <= 1.0: tmp = x / z else: tmp = -x return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x / z)) tmp = 0.0 if (z <= -1.7e+74) tmp = Float64(-x); elseif (z <= -5.8e-43) tmp = Float64(x * Float64(y / z)); elseif (z <= -1.25e-208) tmp = Float64(x / z); elseif (z <= -3.6e-270) tmp = t_0; elseif (z <= 4.8e-191) tmp = Float64(x / z); elseif (z <= 4e-65) tmp = t_0; elseif (z <= 1.0) tmp = Float64(x / 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 <= -1.7e+74) tmp = -x; elseif (z <= -5.8e-43) tmp = x * (y / z); elseif (z <= -1.25e-208) tmp = x / z; elseif (z <= -3.6e-270) tmp = t_0; elseif (z <= 4.8e-191) tmp = x / z; elseif (z <= 4e-65) tmp = t_0; elseif (z <= 1.0) tmp = x / 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, -1.7e+74], (-x), If[LessEqual[z, -5.8e-43], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -1.25e-208], N[(x / z), $MachinePrecision], If[LessEqual[z, -3.6e-270], t$95$0, If[LessEqual[z, 4.8e-191], N[(x / z), $MachinePrecision], If[LessEqual[z, 4e-65], t$95$0, If[LessEqual[z, 1.0], N[(x / z), $MachinePrecision], (-x)]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -1.7 \cdot 10^{+74}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -5.8 \cdot 10^{-43}:\\
\;\;\;\;x \cdot \frac{y}{z}\\
\mathbf{elif}\;z \leq -1.25 \cdot 10^{-208}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq -3.6 \cdot 10^{-270}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 4.8 \cdot 10^{-191}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 4 \cdot 10^{-65}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1.7e74 or 1 < z Initial program 74.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around inf 76.9%
neg-mul-176.9%
Simplified76.9%
if -1.7e74 < z < -5.8000000000000003e-43Initial program 89.5%
associate-/l*99.3%
Simplified99.3%
Taylor expanded in y around inf 73.7%
associate-/l*78.5%
associate-/r/83.8%
Simplified83.8%
if -5.8000000000000003e-43 < z < -1.24999999999999991e-208 or -3.5999999999999998e-270 < z < 4.7999999999999998e-191 or 3.99999999999999969e-65 < z < 1Initial program 99.9%
associate-/l*96.3%
Simplified96.3%
Taylor expanded in z around 0 95.1%
Taylor expanded in y around 0 72.2%
if -1.24999999999999991e-208 < z < -3.5999999999999998e-270 or 4.7999999999999998e-191 < z < 3.99999999999999969e-65Initial program 99.9%
associate-/l*88.6%
Simplified88.6%
Taylor expanded in y around inf 66.9%
*-commutative66.9%
associate-/l*55.6%
Simplified55.6%
associate-/r/73.7%
Applied egg-rr73.7%
Final simplification75.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -7.5e+19) (not (<= y 5.8e+69))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -7.5e+19) || !(y <= 5.8e+69)) {
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 <= (-7.5d+19)) .or. (.not. (y <= 5.8d+69))) 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 <= -7.5e+19) || !(y <= 5.8e+69)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -7.5e+19) or not (y <= 5.8e+69): tmp = y * (x / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -7.5e+19) || !(y <= 5.8e+69)) 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 <= -7.5e+19) || ~((y <= 5.8e+69))) tmp = y * (x / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -7.5e+19], N[Not[LessEqual[y, 5.8e+69]], $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 -7.5 \cdot 10^{+19} \lor \neg \left(y \leq 5.8 \cdot 10^{+69}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -7.5e19 or 5.7999999999999997e69 < y Initial program 86.1%
associate-/l*93.0%
Simplified93.0%
Taylor expanded in y around inf 69.9%
*-commutative69.9%
associate-/l*72.4%
Simplified72.4%
associate-/r/76.6%
Applied egg-rr76.6%
if -7.5e19 < y < 5.7999999999999997e69Initial program 88.4%
Taylor expanded in y around 0 84.1%
*-commutative84.1%
sub-neg84.1%
distribute-lft-in84.2%
*-rgt-identity84.2%
distribute-rgt-neg-in84.2%
*-commutative84.2%
unsub-neg84.2%
*-commutative84.2%
Simplified84.2%
Taylor expanded in x around 0 84.1%
*-commutative84.1%
sub-neg84.1%
distribute-lft-in84.2%
*-rgt-identity84.2%
distribute-rgt-neg-out84.2%
sub-neg84.2%
div-sub84.1%
associate-*l/79.7%
associate-/r/95.7%
*-inverses95.7%
/-rgt-identity95.7%
Simplified95.7%
Final simplification87.6%
(FPCore (x y z) :precision binary64 (if (<= y -5.8e+20) (* y (/ x z)) (if (<= y 5.5e+69) (- (/ x z) x) (/ y (/ z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.8e+20) {
tmp = y * (x / z);
} else if (y <= 5.5e+69) {
tmp = (x / z) - x;
} else {
tmp = y / (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 <= (-5.8d+20)) then
tmp = y * (x / z)
else if (y <= 5.5d+69) then
tmp = (x / z) - x
else
tmp = y / (z / x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5.8e+20) {
tmp = y * (x / z);
} else if (y <= 5.5e+69) {
tmp = (x / z) - x;
} else {
tmp = y / (z / x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.8e+20: tmp = y * (x / z) elif y <= 5.5e+69: tmp = (x / z) - x else: tmp = y / (z / x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.8e+20) tmp = Float64(y * Float64(x / z)); elseif (y <= 5.5e+69) tmp = Float64(Float64(x / z) - x); else tmp = Float64(y / Float64(z / x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.8e+20) tmp = y * (x / z); elseif (y <= 5.5e+69) tmp = (x / z) - x; else tmp = y / (z / x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.8e+20], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.5e+69], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.8 \cdot 10^{+20}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{+69}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\
\end{array}
\end{array}
if y < -5.8e20Initial program 81.0%
associate-/l*91.2%
Simplified91.2%
Taylor expanded in y around inf 61.2%
*-commutative61.2%
associate-/l*64.6%
Simplified64.6%
associate-/r/71.3%
Applied egg-rr71.3%
if -5.8e20 < y < 5.50000000000000002e69Initial program 88.4%
Taylor expanded in y around 0 84.1%
*-commutative84.1%
sub-neg84.1%
distribute-lft-in84.2%
*-rgt-identity84.2%
distribute-rgt-neg-in84.2%
*-commutative84.2%
unsub-neg84.2%
*-commutative84.2%
Simplified84.2%
Taylor expanded in x around 0 84.1%
*-commutative84.1%
sub-neg84.1%
distribute-lft-in84.2%
*-rgt-identity84.2%
distribute-rgt-neg-out84.2%
sub-neg84.2%
div-sub84.1%
associate-*l/79.7%
associate-/r/95.7%
*-inverses95.7%
/-rgt-identity95.7%
Simplified95.7%
if 5.50000000000000002e69 < y Initial program 91.2%
associate-/l*94.7%
Simplified94.7%
Taylor expanded in y around inf 78.4%
associate-/l*81.8%
Simplified81.8%
Final simplification87.6%
(FPCore (x y z) :precision binary64 (if (<= z -0.0016) (- x) (if (<= z 1.0) (/ x z) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.0016) {
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 <= (-0.0016d0)) 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 <= -0.0016) {
tmp = -x;
} else if (z <= 1.0) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -0.0016: tmp = -x elif z <= 1.0: tmp = x / z else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -0.0016) 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 <= -0.0016) tmp = -x; elseif (z <= 1.0) tmp = x / z; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -0.0016], (-x), If[LessEqual[z, 1.0], N[(x / z), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.0016:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -0.00160000000000000008 or 1 < z Initial program 76.1%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around inf 70.3%
neg-mul-170.3%
Simplified70.3%
if -0.00160000000000000008 < z < 1Initial program 99.9%
associate-/l*93.8%
Simplified93.8%
Taylor expanded in z around 0 92.8%
Taylor expanded in y around 0 62.6%
Final simplification66.6%
(FPCore (x y z) :precision binary64 (- x))
double code(double x, double y, double z) {
return -x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -x
end function
public static double code(double x, double y, double z) {
return -x;
}
def code(x, y, z): return -x
function code(x, y, z) return Float64(-x) end
function tmp = code(x, y, z) tmp = -x; end
code[x_, y_, z_] := (-x)
\begin{array}{l}
\\
-x
\end{array}
Initial program 87.4%
associate-/l*97.0%
Simplified97.0%
Taylor expanded in z around inf 38.3%
neg-mul-138.3%
Simplified38.3%
Final simplification38.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* (+ 1.0 y) (/ x z)) x)))
(if (< x -2.71483106713436e-162)
t_0
(if (< x 3.874108816439546e-197)
(* (* x (+ (- y z) 1.0)) (/ 1.0 z))
t_0))))
double code(double x, double y, double z) {
double t_0 = ((1.0 + y) * (x / z)) - x;
double tmp;
if (x < -2.71483106713436e-162) {
tmp = t_0;
} else if (x < 3.874108816439546e-197) {
tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = ((1.0d0 + y) * (x / z)) - x
if (x < (-2.71483106713436d-162)) then
tmp = t_0
else if (x < 3.874108816439546d-197) then
tmp = (x * ((y - z) + 1.0d0)) * (1.0d0 / z)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((1.0 + y) * (x / z)) - x;
double tmp;
if (x < -2.71483106713436e-162) {
tmp = t_0;
} else if (x < 3.874108816439546e-197) {
tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((1.0 + y) * (x / z)) - x tmp = 0 if x < -2.71483106713436e-162: tmp = t_0 elif x < 3.874108816439546e-197: tmp = (x * ((y - z) + 1.0)) * (1.0 / z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(1.0 + y) * Float64(x / z)) - x) tmp = 0.0 if (x < -2.71483106713436e-162) tmp = t_0; elseif (x < 3.874108816439546e-197) tmp = Float64(Float64(x * Float64(Float64(y - z) + 1.0)) * Float64(1.0 / z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((1.0 + y) * (x / z)) - x; tmp = 0.0; if (x < -2.71483106713436e-162) tmp = t_0; elseif (x < 3.874108816439546e-197) tmp = (x * ((y - z) + 1.0)) * (1.0 / z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(1.0 + y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]}, If[Less[x, -2.71483106713436e-162], t$95$0, If[Less[x, 3.874108816439546e-197], N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 + y\right) \cdot \frac{x}{z} - x\\
\mathbf{if}\;x < -2.71483106713436 \cdot 10^{-162}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x < 3.874108816439546 \cdot 10^{-197}:\\
\;\;\;\;\left(x \cdot \left(\left(y - z\right) + 1\right)\right) \cdot \frac{1}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
herbie shell --seed 2023174
(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))