
(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 (<= z -2e+63) (- (* x (/ y z)) x) (if (<= z 1e+19) (* (/ x z) (- (+ y 1.0) z)) (- (/ y (/ z x)) x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2e+63) {
tmp = (x * (y / z)) - x;
} else if (z <= 1e+19) {
tmp = (x / z) * ((y + 1.0) - z);
} else {
tmp = (y / (z / x)) - 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 <= (-2d+63)) then
tmp = (x * (y / z)) - x
else if (z <= 1d+19) then
tmp = (x / z) * ((y + 1.0d0) - z)
else
tmp = (y / (z / x)) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2e+63) {
tmp = (x * (y / z)) - x;
} else if (z <= 1e+19) {
tmp = (x / z) * ((y + 1.0) - z);
} else {
tmp = (y / (z / x)) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2e+63: tmp = (x * (y / z)) - x elif z <= 1e+19: tmp = (x / z) * ((y + 1.0) - z) else: tmp = (y / (z / x)) - x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2e+63) tmp = Float64(Float64(x * Float64(y / z)) - x); elseif (z <= 1e+19) tmp = Float64(Float64(x / z) * Float64(Float64(y + 1.0) - z)); else tmp = Float64(Float64(y / Float64(z / x)) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2e+63) tmp = (x * (y / z)) - x; elseif (z <= 1e+19) tmp = (x / z) * ((y + 1.0) - z); else tmp = (y / (z / x)) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2e+63], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[z, 1e+19], N[(N[(x / z), $MachinePrecision] * N[(N[(y + 1.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision], N[(N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+63}:\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{elif}\;z \leq 10^{+19}:\\
\;\;\;\;\frac{x}{z} \cdot \left(\left(y + 1\right) - z\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{x}} - x\\
\end{array}
\end{array}
if z < -2.00000000000000012e63Initial program 73.9%
Simplified93.8%
Taylor expanded in y around inf 93.8%
associate-/l*96.9%
associate-/r/99.9%
Simplified99.9%
if -2.00000000000000012e63 < z < 1e19Initial program 99.9%
associate-/l*91.2%
Simplified91.2%
associate-/r/99.9%
+-commutative99.9%
associate-+r-99.9%
Applied egg-rr99.9%
if 1e19 < z Initial program 72.2%
Simplified89.7%
Taylor expanded in y around inf 89.7%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -3.4e+60)
(- x)
(if (<= z -7.5e-70)
t_0
(if (<= z -5.9e-106)
(/ x z)
(if (<= z -3.15e-276)
t_0
(if (<= z 1.8e-307)
(/ x z)
(if (<= z 3.2e-220)
t_0
(if (<= z 1.16e-85)
(/ x z)
(if (<= z 3.7e+70) t_0 (- x)))))))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -3.4e+60) {
tmp = -x;
} else if (z <= -7.5e-70) {
tmp = t_0;
} else if (z <= -5.9e-106) {
tmp = x / z;
} else if (z <= -3.15e-276) {
tmp = t_0;
} else if (z <= 1.8e-307) {
tmp = x / z;
} else if (z <= 3.2e-220) {
tmp = t_0;
} else if (z <= 1.16e-85) {
tmp = x / z;
} else if (z <= 3.7e+70) {
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 <= (-3.4d+60)) then
tmp = -x
else if (z <= (-7.5d-70)) then
tmp = t_0
else if (z <= (-5.9d-106)) then
tmp = x / z
else if (z <= (-3.15d-276)) then
tmp = t_0
else if (z <= 1.8d-307) then
tmp = x / z
else if (z <= 3.2d-220) then
tmp = t_0
else if (z <= 1.16d-85) then
tmp = x / z
else if (z <= 3.7d+70) 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 <= -3.4e+60) {
tmp = -x;
} else if (z <= -7.5e-70) {
tmp = t_0;
} else if (z <= -5.9e-106) {
tmp = x / z;
} else if (z <= -3.15e-276) {
tmp = t_0;
} else if (z <= 1.8e-307) {
tmp = x / z;
} else if (z <= 3.2e-220) {
tmp = t_0;
} else if (z <= 1.16e-85) {
tmp = x / z;
} else if (z <= 3.7e+70) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -3.4e+60: tmp = -x elif z <= -7.5e-70: tmp = t_0 elif z <= -5.9e-106: tmp = x / z elif z <= -3.15e-276: tmp = t_0 elif z <= 1.8e-307: tmp = x / z elif z <= 3.2e-220: tmp = t_0 elif z <= 1.16e-85: tmp = x / z elif z <= 3.7e+70: 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 <= -3.4e+60) tmp = Float64(-x); elseif (z <= -7.5e-70) tmp = t_0; elseif (z <= -5.9e-106) tmp = Float64(x / z); elseif (z <= -3.15e-276) tmp = t_0; elseif (z <= 1.8e-307) tmp = Float64(x / z); elseif (z <= 3.2e-220) tmp = t_0; elseif (z <= 1.16e-85) tmp = Float64(x / z); elseif (z <= 3.7e+70) 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 <= -3.4e+60) tmp = -x; elseif (z <= -7.5e-70) tmp = t_0; elseif (z <= -5.9e-106) tmp = x / z; elseif (z <= -3.15e-276) tmp = t_0; elseif (z <= 1.8e-307) tmp = x / z; elseif (z <= 3.2e-220) tmp = t_0; elseif (z <= 1.16e-85) tmp = x / z; elseif (z <= 3.7e+70) 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, -3.4e+60], (-x), If[LessEqual[z, -7.5e-70], t$95$0, If[LessEqual[z, -5.9e-106], N[(x / z), $MachinePrecision], If[LessEqual[z, -3.15e-276], t$95$0, If[LessEqual[z, 1.8e-307], N[(x / z), $MachinePrecision], If[LessEqual[z, 3.2e-220], t$95$0, If[LessEqual[z, 1.16e-85], N[(x / z), $MachinePrecision], If[LessEqual[z, 3.7e+70], t$95$0, (-x)]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -3.4 \cdot 10^{+60}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -7.5 \cdot 10^{-70}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -5.9 \cdot 10^{-106}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq -3.15 \cdot 10^{-276}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{-307}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{-220}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.16 \cdot 10^{-85}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 3.7 \cdot 10^{+70}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -3.4e60 or 3.69999999999999989e70 < z Initial program 71.5%
Simplified91.7%
Taylor expanded in z around inf 87.3%
neg-mul-187.3%
Simplified87.3%
if -3.4e60 < z < -7.49999999999999973e-70 or -5.8999999999999997e-106 < z < -3.1499999999999999e-276 or 1.80000000000000003e-307 < z < 3.20000000000000005e-220 or 1.16e-85 < z < 3.69999999999999989e70Initial program 98.9%
associate-/l*89.1%
Simplified89.1%
associate-/r/99.9%
+-commutative99.9%
associate-+r-99.9%
Applied egg-rr99.9%
Taylor expanded in y around inf 71.5%
if -7.49999999999999973e-70 < z < -5.8999999999999997e-106 or -3.1499999999999999e-276 < z < 1.80000000000000003e-307 or 3.20000000000000005e-220 < z < 1.16e-85Initial program 100.0%
Taylor expanded in z around 0 100.0%
Taylor expanded in y around 0 76.3%
Final simplification78.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (- y z) 1.0)))
(if (<= (/ (* x t_0) z) 1e-14)
(/ x (/ z t_0))
(* (/ x z) (- (+ y 1.0) z)))))
double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if (((x * t_0) / z) <= 1e-14) {
tmp = x / (z / t_0);
} 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) :: t_0
real(8) :: tmp
t_0 = (y - z) + 1.0d0
if (((x * t_0) / z) <= 1d-14) then
tmp = x / (z / t_0)
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 t_0 = (y - z) + 1.0;
double tmp;
if (((x * t_0) / z) <= 1e-14) {
tmp = x / (z / t_0);
} else {
tmp = (x / z) * ((y + 1.0) - z);
}
return tmp;
}
def code(x, y, z): t_0 = (y - z) + 1.0 tmp = 0 if ((x * t_0) / z) <= 1e-14: tmp = x / (z / t_0) else: tmp = (x / z) * ((y + 1.0) - z) return tmp
function code(x, y, z) t_0 = Float64(Float64(y - z) + 1.0) tmp = 0.0 if (Float64(Float64(x * t_0) / z) <= 1e-14) tmp = Float64(x / Float64(z / t_0)); else tmp = Float64(Float64(x / z) * Float64(Float64(y + 1.0) - z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y - z) + 1.0; tmp = 0.0; if (((x * t_0) / z) <= 1e-14) tmp = x / (z / t_0); else tmp = (x / z) * ((y + 1.0) - z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[N[(N[(x * t$95$0), $MachinePrecision] / z), $MachinePrecision], 1e-14], N[(x / N[(z / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(N[(y + 1.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y - z\right) + 1\\
\mathbf{if}\;\frac{x \cdot t_0}{z} \leq 10^{-14}:\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(\left(y + 1\right) - z\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < 9.99999999999999999e-15Initial program 94.2%
associate-/l*98.8%
Simplified98.8%
if 9.99999999999999999e-15 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) Initial program 79.2%
associate-/l*87.5%
Simplified87.5%
associate-/r/99.8%
+-commutative99.8%
associate-+r-99.8%
Applied egg-rr99.8%
Final simplification99.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* x (/ y z)) x)))
(if (<= y -1.0)
t_0
(if (<= y 1.0) (- (/ x z) x) (if (<= y 2.1e+209) t_0 (/ (* x y) z))))))
double code(double x, double y, double z) {
double t_0 = (x * (y / z)) - x;
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 1.0) {
tmp = (x / z) - x;
} else if (y <= 2.1e+209) {
tmp = t_0;
} else {
tmp = (x * 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) :: t_0
real(8) :: tmp
t_0 = (x * (y / z)) - x
if (y <= (-1.0d0)) then
tmp = t_0
else if (y <= 1.0d0) then
tmp = (x / z) - x
else if (y <= 2.1d+209) then
tmp = t_0
else
tmp = (x * y) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x * (y / z)) - x;
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 1.0) {
tmp = (x / z) - x;
} else if (y <= 2.1e+209) {
tmp = t_0;
} else {
tmp = (x * y) / z;
}
return tmp;
}
def code(x, y, z): t_0 = (x * (y / z)) - x tmp = 0 if y <= -1.0: tmp = t_0 elif y <= 1.0: tmp = (x / z) - x elif y <= 2.1e+209: tmp = t_0 else: tmp = (x * y) / z return tmp
function code(x, y, z) t_0 = Float64(Float64(x * Float64(y / z)) - x) tmp = 0.0 if (y <= -1.0) tmp = t_0; elseif (y <= 1.0) tmp = Float64(Float64(x / z) - x); elseif (y <= 2.1e+209) tmp = t_0; else tmp = Float64(Float64(x * y) / z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x * (y / z)) - x; tmp = 0.0; if (y <= -1.0) tmp = t_0; elseif (y <= 1.0) tmp = (x / z) - x; elseif (y <= 2.1e+209) tmp = t_0; else tmp = (x * y) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]}, If[LessEqual[y, -1.0], t$95$0, If[LessEqual[y, 1.0], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[y, 2.1e+209], t$95$0, N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{y}{z} - x\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{+209}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\end{array}
\end{array}
if y < -1 or 1 < y < 2.1e209Initial program 86.8%
Simplified91.1%
Taylor expanded in y around inf 91.1%
associate-/l*99.4%
associate-/r/91.4%
Simplified91.4%
if -1 < y < 1Initial program 88.7%
Simplified100.0%
Taylor expanded in y around 0 99.7%
if 2.1e209 < y Initial program 99.8%
Taylor expanded in y around inf 97.8%
Final simplification96.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (- (/ y (/ z x)) x) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = (y / (z / x)) - 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 = (y / (z / x)) - 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 = (y / (z / x)) - 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 = (y / (z / x)) - 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(y / Float64(z / x)) - 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 = (y / (z / x)) - 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[(y / N[(z / x), $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):\\
\;\;\;\;\frac{y}{\frac{z}{x}} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 89.0%
Simplified92.6%
Taylor expanded in y around inf 92.6%
associate-/l*98.7%
Simplified98.7%
if -1 < y < 1Initial program 88.7%
Simplified100.0%
Taylor expanded in y around 0 99.7%
Final simplification99.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -800000000.0) (not (<= y 6e+69))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -800000000.0) || !(y <= 6e+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 <= (-800000000.0d0)) .or. (.not. (y <= 6d+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 <= -800000000.0) || !(y <= 6e+69)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -800000000.0) or not (y <= 6e+69): tmp = y * (x / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -800000000.0) || !(y <= 6e+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 <= -800000000.0) || ~((y <= 6e+69))) tmp = y * (x / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -800000000.0], N[Not[LessEqual[y, 6e+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 -800000000 \lor \neg \left(y \leq 6 \cdot 10^{+69}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -8e8 or 5.99999999999999967e69 < y Initial program 89.1%
associate-/l*88.3%
Simplified88.3%
associate-/r/93.2%
+-commutative93.2%
associate-+r-93.2%
Applied egg-rr93.2%
Taylor expanded in y around inf 76.8%
if -8e8 < y < 5.99999999999999967e69Initial program 88.7%
Simplified99.3%
Taylor expanded in y around 0 98.1%
Final simplification88.6%
(FPCore (x y z) :precision binary64 (if (<= y -1100000000.0) (* y (/ x z)) (if (<= y 6.2e+69) (- (/ x z) x) (/ (* x y) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1100000000.0) {
tmp = y * (x / z);
} else if (y <= 6.2e+69) {
tmp = (x / z) - x;
} else {
tmp = (x * 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 (y <= (-1100000000.0d0)) then
tmp = y * (x / z)
else if (y <= 6.2d+69) then
tmp = (x / z) - x
else
tmp = (x * y) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1100000000.0) {
tmp = y * (x / z);
} else if (y <= 6.2e+69) {
tmp = (x / z) - x;
} else {
tmp = (x * y) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1100000000.0: tmp = y * (x / z) elif y <= 6.2e+69: tmp = (x / z) - x else: tmp = (x * y) / z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1100000000.0) tmp = Float64(y * Float64(x / z)); elseif (y <= 6.2e+69) tmp = Float64(Float64(x / z) - x); else tmp = Float64(Float64(x * y) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1100000000.0) tmp = y * (x / z); elseif (y <= 6.2e+69) tmp = (x / z) - x; else tmp = (x * y) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1100000000.0], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6.2e+69], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1100000000:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{+69}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\end{array}
\end{array}
if y < -1.1e9Initial program 90.6%
associate-/l*92.0%
Simplified92.0%
associate-/r/95.1%
+-commutative95.1%
associate-+r-95.1%
Applied egg-rr95.1%
Taylor expanded in y around inf 78.1%
if -1.1e9 < y < 6.1999999999999997e69Initial program 88.7%
Simplified99.3%
Taylor expanded in y around 0 98.1%
if 6.1999999999999997e69 < y Initial program 87.3%
Taylor expanded in y around inf 77.1%
Final simplification89.0%
(FPCore (x y z) :precision binary64 (if (<= z -1.4e-6) (- x) (if (<= z 1.0) (/ x z) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.4e-6) {
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.4d-6)) 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.4e-6) {
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.4e-6: 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.4e-6) 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.4e-6) 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.4e-6], (-x), If[LessEqual[z, 1.0], N[(x / z), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.4 \cdot 10^{-6}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1.39999999999999994e-6 or 1 < z Initial program 74.9%
Simplified92.1%
Taylor expanded in z around inf 78.8%
neg-mul-178.8%
Simplified78.8%
if -1.39999999999999994e-6 < z < 1Initial program 99.9%
Taylor expanded in z around 0 99.3%
Taylor expanded in y around 0 54.3%
Final simplification65.1%
(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%
Simplified96.5%
Taylor expanded in z around inf 36.6%
neg-mul-136.6%
Simplified36.6%
Final simplification36.6%
(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 2023229
(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))