
(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 8 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 -1e-16) (not (<= z 9.8e-23))) (* x (/ (+ 1.0 (- y z)) z)) (/ (* x (+ 1.0 y)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1e-16) || !(z <= 9.8e-23)) {
tmp = x * ((1.0 + (y - z)) / z);
} else {
tmp = (x * (1.0 + 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 ((z <= (-1d-16)) .or. (.not. (z <= 9.8d-23))) then
tmp = x * ((1.0d0 + (y - z)) / z)
else
tmp = (x * (1.0d0 + y)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1e-16) || !(z <= 9.8e-23)) {
tmp = x * ((1.0 + (y - z)) / z);
} else {
tmp = (x * (1.0 + y)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1e-16) or not (z <= 9.8e-23): tmp = x * ((1.0 + (y - z)) / z) else: tmp = (x * (1.0 + y)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1e-16) || !(z <= 9.8e-23)) tmp = Float64(x * Float64(Float64(1.0 + Float64(y - z)) / z)); else tmp = Float64(Float64(x * Float64(1.0 + y)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1e-16) || ~((z <= 9.8e-23))) tmp = x * ((1.0 + (y - z)) / z); else tmp = (x * (1.0 + y)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1e-16], N[Not[LessEqual[z, 9.8e-23]], $MachinePrecision]], N[(x * N[(N[(1.0 + N[(y - z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{-16} \lor \neg \left(z \leq 9.8 \cdot 10^{-23}\right):\\
\;\;\;\;x \cdot \frac{1 + \left(y - z\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(1 + y\right)}{z}\\
\end{array}
\end{array}
if z < -9.9999999999999998e-17 or 9.7999999999999996e-23 < z Initial program 83.2%
Taylor expanded in x around 0 83.2%
associate--l+83.2%
+-commutative83.2%
associate-*r/99.8%
+-commutative99.8%
Simplified99.8%
if -9.9999999999999998e-17 < z < 9.7999999999999996e-23Initial program 99.8%
Taylor expanded in z around 0 99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ x z) y)))
(if (<= z -1.05e+79)
(- x)
(if (<= z -1e-197)
t_0
(if (<= z 2.8e-291)
(/ x z)
(if (<= z 7.5e-82)
t_0
(if (<= z 4.5e-15) (/ x z) (if (<= z 2.7e+25) t_0 (- x)))))))))
double code(double x, double y, double z) {
double t_0 = (x / z) * y;
double tmp;
if (z <= -1.05e+79) {
tmp = -x;
} else if (z <= -1e-197) {
tmp = t_0;
} else if (z <= 2.8e-291) {
tmp = x / z;
} else if (z <= 7.5e-82) {
tmp = t_0;
} else if (z <= 4.5e-15) {
tmp = x / z;
} else if (z <= 2.7e+25) {
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 / z) * y
if (z <= (-1.05d+79)) then
tmp = -x
else if (z <= (-1d-197)) then
tmp = t_0
else if (z <= 2.8d-291) then
tmp = x / z
else if (z <= 7.5d-82) then
tmp = t_0
else if (z <= 4.5d-15) then
tmp = x / z
else if (z <= 2.7d+25) 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 / z) * y;
double tmp;
if (z <= -1.05e+79) {
tmp = -x;
} else if (z <= -1e-197) {
tmp = t_0;
} else if (z <= 2.8e-291) {
tmp = x / z;
} else if (z <= 7.5e-82) {
tmp = t_0;
} else if (z <= 4.5e-15) {
tmp = x / z;
} else if (z <= 2.7e+25) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = (x / z) * y tmp = 0 if z <= -1.05e+79: tmp = -x elif z <= -1e-197: tmp = t_0 elif z <= 2.8e-291: tmp = x / z elif z <= 7.5e-82: tmp = t_0 elif z <= 4.5e-15: tmp = x / z elif z <= 2.7e+25: tmp = t_0 else: tmp = -x return tmp
function code(x, y, z) t_0 = Float64(Float64(x / z) * y) tmp = 0.0 if (z <= -1.05e+79) tmp = Float64(-x); elseif (z <= -1e-197) tmp = t_0; elseif (z <= 2.8e-291) tmp = Float64(x / z); elseif (z <= 7.5e-82) tmp = t_0; elseif (z <= 4.5e-15) tmp = Float64(x / z); elseif (z <= 2.7e+25) tmp = t_0; else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x / z) * y; tmp = 0.0; if (z <= -1.05e+79) tmp = -x; elseif (z <= -1e-197) tmp = t_0; elseif (z <= 2.8e-291) tmp = x / z; elseif (z <= 7.5e-82) tmp = t_0; elseif (z <= 4.5e-15) tmp = x / z; elseif (z <= 2.7e+25) tmp = t_0; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[z, -1.05e+79], (-x), If[LessEqual[z, -1e-197], t$95$0, If[LessEqual[z, 2.8e-291], N[(x / z), $MachinePrecision], If[LessEqual[z, 7.5e-82], t$95$0, If[LessEqual[z, 4.5e-15], N[(x / z), $MachinePrecision], If[LessEqual[z, 2.7e+25], t$95$0, (-x)]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{z} \cdot y\\
\mathbf{if}\;z \leq -1.05 \cdot 10^{+79}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -1 \cdot 10^{-197}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{-291}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 7.5 \cdot 10^{-82}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{-15}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 2.7 \cdot 10^{+25}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1.05000000000000004e79 or 2.7e25 < z Initial program 76.1%
Taylor expanded in z around inf 80.7%
neg-mul-180.7%
Simplified80.7%
if -1.05000000000000004e79 < z < -9.9999999999999999e-198 or 2.8e-291 < z < 7.4999999999999997e-82 or 4.4999999999999998e-15 < z < 2.7e25Initial program 99.8%
Taylor expanded in y around inf 65.7%
associate-/l*57.8%
associate-/r/67.2%
Simplified67.2%
if -9.9999999999999999e-198 < z < 2.8e-291 or 7.4999999999999997e-82 < z < 4.4999999999999998e-15Initial program 99.9%
Taylor expanded in z around 0 99.8%
Taylor expanded in y around 0 80.6%
Final simplification74.3%
(FPCore (x y z)
:precision binary64
(if (or (<= y -1.75e+43)
(and (not (<= y 750000000000.0))
(or (<= y 1.12e+52) (not (<= y 3.05e+106)))))
(* (/ x z) y)
(- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.75e+43) || (!(y <= 750000000000.0) && ((y <= 1.12e+52) || !(y <= 3.05e+106)))) {
tmp = (x / z) * y;
} 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.75d+43)) .or. (.not. (y <= 750000000000.0d0)) .and. (y <= 1.12d+52) .or. (.not. (y <= 3.05d+106))) then
tmp = (x / z) * y
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.75e+43) || (!(y <= 750000000000.0) && ((y <= 1.12e+52) || !(y <= 3.05e+106)))) {
tmp = (x / z) * y;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.75e+43) or (not (y <= 750000000000.0) and ((y <= 1.12e+52) or not (y <= 3.05e+106))): tmp = (x / z) * y else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.75e+43) || (!(y <= 750000000000.0) && ((y <= 1.12e+52) || !(y <= 3.05e+106)))) tmp = Float64(Float64(x / z) * y); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.75e+43) || (~((y <= 750000000000.0)) && ((y <= 1.12e+52) || ~((y <= 3.05e+106))))) tmp = (x / z) * y; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.75e+43], And[N[Not[LessEqual[y, 750000000000.0]], $MachinePrecision], Or[LessEqual[y, 1.12e+52], N[Not[LessEqual[y, 3.05e+106]], $MachinePrecision]]]], N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.75 \cdot 10^{+43} \lor \neg \left(y \leq 750000000000\right) \land \left(y \leq 1.12 \cdot 10^{+52} \lor \neg \left(y \leq 3.05 \cdot 10^{+106}\right)\right):\\
\;\;\;\;\frac{x}{z} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1.7500000000000001e43 or 7.5e11 < y < 1.12000000000000002e52 or 3.05e106 < y Initial program 92.4%
Taylor expanded in y around inf 83.9%
associate-/l*79.1%
associate-/r/86.9%
Simplified86.9%
if -1.7500000000000001e43 < y < 7.5e11 or 1.12000000000000002e52 < y < 3.05e106Initial program 89.2%
Taylor expanded in z around 0 100.0%
neg-mul-1100.0%
+-commutative100.0%
unsub-neg100.0%
associate-/l*99.6%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in y around 0 96.5%
Final simplification92.2%
(FPCore (x y z)
:precision binary64
(if (<= y -1.75e+43)
(/ (* x y) z)
(if (or (<= y 3.2e+17) (and (not (<= y 6e+53)) (<= y 3.8e+106)))
(- (/ x z) x)
(* (/ x z) y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.75e+43) {
tmp = (x * y) / z;
} else if ((y <= 3.2e+17) || (!(y <= 6e+53) && (y <= 3.8e+106))) {
tmp = (x / z) - x;
} else {
tmp = (x / z) * y;
}
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.75d+43)) then
tmp = (x * y) / z
else if ((y <= 3.2d+17) .or. (.not. (y <= 6d+53)) .and. (y <= 3.8d+106)) then
tmp = (x / z) - x
else
tmp = (x / z) * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.75e+43) {
tmp = (x * y) / z;
} else if ((y <= 3.2e+17) || (!(y <= 6e+53) && (y <= 3.8e+106))) {
tmp = (x / z) - x;
} else {
tmp = (x / z) * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.75e+43: tmp = (x * y) / z elif (y <= 3.2e+17) or (not (y <= 6e+53) and (y <= 3.8e+106)): tmp = (x / z) - x else: tmp = (x / z) * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.75e+43) tmp = Float64(Float64(x * y) / z); elseif ((y <= 3.2e+17) || (!(y <= 6e+53) && (y <= 3.8e+106))) tmp = Float64(Float64(x / z) - x); else tmp = Float64(Float64(x / z) * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.75e+43) tmp = (x * y) / z; elseif ((y <= 3.2e+17) || (~((y <= 6e+53)) && (y <= 3.8e+106))) tmp = (x / z) - x; else tmp = (x / z) * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.75e+43], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], If[Or[LessEqual[y, 3.2e+17], And[N[Not[LessEqual[y, 6e+53]], $MachinePrecision], LessEqual[y, 3.8e+106]]], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.75 \cdot 10^{+43}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+17} \lor \neg \left(y \leq 6 \cdot 10^{+53}\right) \land y \leq 3.8 \cdot 10^{+106}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot y\\
\end{array}
\end{array}
if y < -1.7500000000000001e43Initial program 96.1%
Taylor expanded in y around inf 83.3%
if -1.7500000000000001e43 < y < 3.2e17 or 5.99999999999999996e53 < y < 3.7999999999999998e106Initial program 89.2%
Taylor expanded in z around 0 100.0%
neg-mul-1100.0%
+-commutative100.0%
unsub-neg100.0%
associate-/l*99.6%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in y around 0 96.5%
if 3.2e17 < y < 5.99999999999999996e53 or 3.7999999999999998e106 < y Initial program 89.0%
Taylor expanded in y around inf 84.5%
associate-/l*79.8%
associate-/r/90.6%
Simplified90.6%
Final simplification92.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -15000000.0) (not (<= y 7.3e-9))) (- (/ (* x y) z) x) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -15000000.0) || !(y <= 7.3e-9)) {
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 <= (-15000000.0d0)) .or. (.not. (y <= 7.3d-9))) 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 <= -15000000.0) || !(y <= 7.3e-9)) {
tmp = ((x * y) / z) - x;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -15000000.0) or not (y <= 7.3e-9): tmp = ((x * y) / z) - x else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -15000000.0) || !(y <= 7.3e-9)) tmp = Float64(Float64(Float64(x * 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 <= -15000000.0) || ~((y <= 7.3e-9))) tmp = ((x * y) / z) - x; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -15000000.0], N[Not[LessEqual[y, 7.3e-9]], $MachinePrecision]], N[(N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -15000000 \lor \neg \left(y \leq 7.3 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{x \cdot y}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1.5e7 or 7.30000000000000002e-9 < y Initial program 91.5%
Taylor expanded in z around 0 93.6%
neg-mul-193.6%
+-commutative93.6%
unsub-neg93.6%
associate-/l*91.3%
associate-/r/98.2%
Simplified98.2%
Taylor expanded in y around inf 93.3%
if -1.5e7 < y < 7.30000000000000002e-9Initial program 89.6%
Taylor expanded in z around 0 100.0%
neg-mul-1100.0%
+-commutative100.0%
unsub-neg100.0%
associate-/l*100.0%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in y around 0 99.9%
Final simplification96.3%
(FPCore (x y z) :precision binary64 (- (* (/ x z) (+ 1.0 y)) x))
double code(double x, double y, double z) {
return ((x / z) * (1.0 + y)) - 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 / z) * (1.0d0 + y)) - x
end function
public static double code(double x, double y, double z) {
return ((x / z) * (1.0 + y)) - x;
}
def code(x, y, z): return ((x / z) * (1.0 + y)) - x
function code(x, y, z) return Float64(Float64(Float64(x / z) * Float64(1.0 + y)) - x) end
function tmp = code(x, y, z) tmp = ((x / z) * (1.0 + y)) - x; end
code[x_, y_, z_] := N[(N[(N[(x / z), $MachinePrecision] * N[(1.0 + y), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{z} \cdot \left(1 + y\right) - x
\end{array}
Initial program 90.6%
Taylor expanded in z around 0 96.5%
neg-mul-196.5%
+-commutative96.5%
unsub-neg96.5%
associate-/l*95.3%
associate-/r/99.0%
Simplified99.0%
Final simplification99.0%
(FPCore (x y z) :precision binary64 (if (<= z -2.9) (- x) (if (<= z 1.15) (/ x z) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.9) {
tmp = -x;
} else if (z <= 1.15) {
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 <= (-2.9d0)) then
tmp = -x
else if (z <= 1.15d0) 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 <= -2.9) {
tmp = -x;
} else if (z <= 1.15) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.9: tmp = -x elif z <= 1.15: tmp = x / z else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.9) tmp = Float64(-x); elseif (z <= 1.15) tmp = Float64(x / z); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2.9) tmp = -x; elseif (z <= 1.15) tmp = x / z; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.9], (-x), If[LessEqual[z, 1.15], N[(x / z), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.9:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 1.15:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -2.89999999999999991 or 1.1499999999999999 < z Initial program 81.9%
Taylor expanded in z around inf 71.0%
neg-mul-171.0%
Simplified71.0%
if -2.89999999999999991 < z < 1.1499999999999999Initial program 99.8%
Taylor expanded in z around 0 99.6%
Taylor expanded in y around 0 54.0%
Final simplification62.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 90.6%
Taylor expanded in z around inf 37.8%
neg-mul-137.8%
Simplified37.8%
Final simplification37.8%
(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 2023271
(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))