
(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 -1.2e+59) (- (* x (/ y z)) x) (if (<= z 3.2e+16) (* (/ x z) (- (+ y 1.0) z)) (- (/ y (/ z x)) x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.2e+59) {
tmp = (x * (y / z)) - x;
} else if (z <= 3.2e+16) {
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 <= (-1.2d+59)) then
tmp = (x * (y / z)) - x
else if (z <= 3.2d+16) 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 <= -1.2e+59) {
tmp = (x * (y / z)) - x;
} else if (z <= 3.2e+16) {
tmp = (x / z) * ((y + 1.0) - z);
} else {
tmp = (y / (z / x)) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.2e+59: tmp = (x * (y / z)) - x elif z <= 3.2e+16: 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 <= -1.2e+59) tmp = Float64(Float64(x * Float64(y / z)) - x); elseif (z <= 3.2e+16) 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 <= -1.2e+59) tmp = (x * (y / z)) - x; elseif (z <= 3.2e+16) 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, -1.2e+59], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[z, 3.2e+16], 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 -1.2 \cdot 10^{+59}:\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{+16}:\\
\;\;\;\;\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 < -1.2000000000000001e59Initial program 74.1%
Simplified85.3%
Taylor expanded in y around inf 85.3%
associate-/l*94.0%
associate-/r/99.9%
Simplified99.9%
if -1.2000000000000001e59 < z < 3.2e16Initial program 99.9%
associate-/l*96.3%
Simplified96.3%
Taylor expanded in x around 0 99.9%
associate-*l/99.9%
Simplified99.9%
if 3.2e16 < z Initial program 77.3%
Simplified94.3%
Taylor expanded in y around inf 94.3%
associate-/l*100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -1.0)
(- x)
(if (<= z 9.6e-285)
(/ x z)
(if (<= z 2.5e-179)
t_0
(if (<= z 5.2e-34) (/ x z) (if (<= z 5.6e+60) t_0 (- x))))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= 9.6e-285) {
tmp = x / z;
} else if (z <= 2.5e-179) {
tmp = t_0;
} else if (z <= 5.2e-34) {
tmp = x / z;
} else if (z <= 5.6e+60) {
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 <= (-1.0d0)) then
tmp = -x
else if (z <= 9.6d-285) then
tmp = x / z
else if (z <= 2.5d-179) then
tmp = t_0
else if (z <= 5.2d-34) then
tmp = x / z
else if (z <= 5.6d+60) 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 <= -1.0) {
tmp = -x;
} else if (z <= 9.6e-285) {
tmp = x / z;
} else if (z <= 2.5e-179) {
tmp = t_0;
} else if (z <= 5.2e-34) {
tmp = x / z;
} else if (z <= 5.6e+60) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -1.0: tmp = -x elif z <= 9.6e-285: tmp = x / z elif z <= 2.5e-179: tmp = t_0 elif z <= 5.2e-34: tmp = x / z elif z <= 5.6e+60: 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 <= -1.0) tmp = Float64(-x); elseif (z <= 9.6e-285) tmp = Float64(x / z); elseif (z <= 2.5e-179) tmp = t_0; elseif (z <= 5.2e-34) tmp = Float64(x / z); elseif (z <= 5.6e+60) 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 <= -1.0) tmp = -x; elseif (z <= 9.6e-285) tmp = x / z; elseif (z <= 2.5e-179) tmp = t_0; elseif (z <= 5.2e-34) tmp = x / z; elseif (z <= 5.6e+60) 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, -1.0], (-x), If[LessEqual[z, 9.6e-285], N[(x / z), $MachinePrecision], If[LessEqual[z, 2.5e-179], t$95$0, If[LessEqual[z, 5.2e-34], N[(x / z), $MachinePrecision], If[LessEqual[z, 5.6e+60], t$95$0, (-x)]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -1:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 9.6 \cdot 10^{-285}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 2.5 \cdot 10^{-179}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 5.2 \cdot 10^{-34}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 5.6 \cdot 10^{+60}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1 or 5.6e60 < z Initial program 76.8%
Simplified90.4%
Taylor expanded in z around inf 79.6%
neg-mul-179.6%
Simplified79.6%
if -1 < z < 9.6000000000000001e-285 or 2.4999999999999999e-179 < z < 5.1999999999999999e-34Initial program 99.9%
associate-/l*97.4%
Simplified97.4%
Taylor expanded in z around 0 96.6%
Taylor expanded in y around 0 71.8%
if 9.6000000000000001e-285 < z < 2.4999999999999999e-179 or 5.1999999999999999e-34 < z < 5.6e60Initial program 97.4%
associate-/l*92.7%
Simplified92.7%
Taylor expanded in y around inf 66.8%
associate-/r/79.2%
Applied egg-rr79.2%
Final simplification76.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (- (* x (/ y z)) x) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x / z) - x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-1.0d0)) .or. (.not. (y <= 1.0d0))) then
tmp = (x * (y / z)) - x
else
tmp = (x / z) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.0) or not (y <= 1.0): tmp = (x * (y / z)) - x else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.0) || !(y <= 1.0)) tmp = Float64(Float64(x * Float64(y / z)) - x); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.0) || ~((y <= 1.0))) tmp = (x * (y / z)) - x; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 86.2%
Simplified89.6%
Taylor expanded in y around inf 87.9%
associate-/l*95.0%
associate-/r/93.0%
Simplified93.0%
if -1 < y < 1Initial program 92.3%
Simplified100.0%
Taylor expanded in y around 0 98.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 86.2%
Simplified89.6%
Taylor expanded in y around inf 87.9%
associate-/l*95.0%
Simplified95.0%
if -1 < y < 1Initial program 92.3%
Simplified100.0%
Taylor expanded in y around 0 98.8%
Final simplification97.2%
(FPCore (x y z) :precision binary64 (if (<= z -1.1) (- (* x (/ y z)) x) (if (<= z 1.0) (/ (* x (+ y 1.0)) z) (- (/ y (/ z x)) x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.1) {
tmp = (x * (y / z)) - x;
} else if (z <= 1.0) {
tmp = (x * (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 <= (-1.1d0)) then
tmp = (x * (y / z)) - x
else if (z <= 1.0d0) then
tmp = (x * (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 <= -1.1) {
tmp = (x * (y / z)) - x;
} else if (z <= 1.0) {
tmp = (x * (y + 1.0)) / z;
} else {
tmp = (y / (z / x)) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.1: tmp = (x * (y / z)) - x elif z <= 1.0: tmp = (x * (y + 1.0)) / z else: tmp = (y / (z / x)) - x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.1) tmp = Float64(Float64(x * Float64(y / z)) - x); elseif (z <= 1.0) tmp = Float64(Float64(x * 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 <= -1.1) tmp = (x * (y / z)) - x; elseif (z <= 1.0) tmp = (x * (y + 1.0)) / z; else tmp = (y / (z / x)) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.1], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[z, 1.0], N[(N[(x * N[(y + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.1:\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{x \cdot \left(y + 1\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{x}} - x\\
\end{array}
\end{array}
if z < -1.1000000000000001Initial program 77.3%
Simplified87.1%
Taylor expanded in y around inf 85.3%
associate-/l*92.9%
associate-/r/98.1%
Simplified98.1%
if -1.1000000000000001 < z < 1Initial program 99.9%
Taylor expanded in z around 0 99.3%
if 1 < z Initial program 78.5%
Simplified94.6%
Taylor expanded in y around inf 94.6%
associate-/l*99.9%
Simplified99.9%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (if (<= y -2.8e+54) (* y (/ x z)) (if (<= y 100000000000.0) (- (/ x z) x) (* x (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.8e+54) {
tmp = y * (x / z);
} else if (y <= 100000000000.0) {
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 <= (-2.8d+54)) then
tmp = y * (x / z)
else if (y <= 100000000000.0d0) 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 <= -2.8e+54) {
tmp = y * (x / z);
} else if (y <= 100000000000.0) {
tmp = (x / z) - x;
} else {
tmp = x * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.8e+54: tmp = y * (x / z) elif y <= 100000000000.0: tmp = (x / z) - x else: tmp = x * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.8e+54) tmp = Float64(y * Float64(x / z)); elseif (y <= 100000000000.0) tmp = Float64(Float64(x / z) - x); else tmp = Float64(x * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.8e+54) tmp = y * (x / z); elseif (y <= 100000000000.0) tmp = (x / z) - x; else tmp = x * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.8e+54], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 100000000000.0], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.8 \cdot 10^{+54}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 100000000000:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -2.80000000000000015e54Initial program 87.4%
associate-/l*90.5%
Simplified90.5%
Taylor expanded in y around inf 75.3%
associate-/r/84.1%
Applied egg-rr84.1%
if -2.80000000000000015e54 < y < 1e11Initial program 91.4%
Simplified99.3%
Taylor expanded in y around 0 94.8%
if 1e11 < y Initial program 86.1%
associate-/l*96.3%
Simplified96.3%
Taylor expanded in y around inf 74.9%
div-inv74.8%
clear-num74.9%
*-commutative74.9%
Applied egg-rr74.9%
Final simplification89.0%
(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 89.7%
associate-/l*97.8%
Simplified97.8%
Final simplification97.8%
(FPCore (x y z) :precision binary64 (if (<= z -1.0) (- x) (if (<= z 650000000.0) (/ x z) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= 650000000.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 <= 650000000.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 <= 650000000.0) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.0: tmp = -x elif z <= 650000000.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 <= 650000000.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 <= 650000000.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, 650000000.0], N[(x / z), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 650000000:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1 or 6.5e8 < z Initial program 77.4%
Simplified90.3%
Taylor expanded in z around inf 77.4%
neg-mul-177.4%
Simplified77.4%
if -1 < z < 6.5e8Initial program 99.9%
associate-/l*96.0%
Simplified96.0%
Taylor expanded in z around 0 95.4%
Taylor expanded in y around 0 65.1%
Final simplification70.7%
(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 89.7%
Simplified95.5%
Taylor expanded in z around inf 37.0%
neg-mul-137.0%
Simplified37.0%
Final simplification37.0%
(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 2023240
(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))