
(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 10 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 -14.5) (not (<= z 1.35e-16))) (- (* x (/ y z)) x) (/ (* x (+ 1.0 y)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -14.5) || !(z <= 1.35e-16)) {
tmp = (x * (y / z)) - x;
} 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 <= (-14.5d0)) .or. (.not. (z <= 1.35d-16))) then
tmp = (x * (y / z)) - x
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 <= -14.5) || !(z <= 1.35e-16)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x * (1.0 + y)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -14.5) or not (z <= 1.35e-16): tmp = (x * (y / z)) - x else: tmp = (x * (1.0 + y)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -14.5) || !(z <= 1.35e-16)) tmp = Float64(Float64(x * Float64(y / z)) - x); 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 <= -14.5) || ~((z <= 1.35e-16))) tmp = (x * (y / z)) - x; else tmp = (x * (1.0 + y)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -14.5], N[Not[LessEqual[z, 1.35e-16]], $MachinePrecision]], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x * N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -14.5 \lor \neg \left(z \leq 1.35 \cdot 10^{-16}\right):\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(1 + y\right)}{z}\\
\end{array}
\end{array}
if z < -14.5 or 1.35e-16 < z Initial program 75.9%
Taylor expanded in z around 0 88.6%
neg-mul-188.6%
+-commutative88.6%
unsub-neg88.6%
associate-/l*99.9%
associate-/r/97.8%
Simplified97.8%
Taylor expanded in y around inf 87.7%
associate-*r/99.0%
Simplified99.0%
if -14.5 < z < 1.35e-16Initial program 99.9%
Taylor expanded in z around 0 99.9%
Final simplification99.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ x z) y)))
(if (<= z -8.5e+54)
(- x)
(if (<= z -1.28e-123)
t_0
(if (<= z 2.8e-277)
(/ x z)
(if (<= z 6e-197)
t_0
(if (<= z 1.92e-83)
(/ x z)
(if (<= z 1.42e-56)
t_0
(if (<= z 8.5e-17)
(/ x z)
(if (<= z 9.8e+107) t_0 (- x)))))))))))
double code(double x, double y, double z) {
double t_0 = (x / z) * y;
double tmp;
if (z <= -8.5e+54) {
tmp = -x;
} else if (z <= -1.28e-123) {
tmp = t_0;
} else if (z <= 2.8e-277) {
tmp = x / z;
} else if (z <= 6e-197) {
tmp = t_0;
} else if (z <= 1.92e-83) {
tmp = x / z;
} else if (z <= 1.42e-56) {
tmp = t_0;
} else if (z <= 8.5e-17) {
tmp = x / z;
} else if (z <= 9.8e+107) {
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 <= (-8.5d+54)) then
tmp = -x
else if (z <= (-1.28d-123)) then
tmp = t_0
else if (z <= 2.8d-277) then
tmp = x / z
else if (z <= 6d-197) then
tmp = t_0
else if (z <= 1.92d-83) then
tmp = x / z
else if (z <= 1.42d-56) then
tmp = t_0
else if (z <= 8.5d-17) then
tmp = x / z
else if (z <= 9.8d+107) 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 <= -8.5e+54) {
tmp = -x;
} else if (z <= -1.28e-123) {
tmp = t_0;
} else if (z <= 2.8e-277) {
tmp = x / z;
} else if (z <= 6e-197) {
tmp = t_0;
} else if (z <= 1.92e-83) {
tmp = x / z;
} else if (z <= 1.42e-56) {
tmp = t_0;
} else if (z <= 8.5e-17) {
tmp = x / z;
} else if (z <= 9.8e+107) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = (x / z) * y tmp = 0 if z <= -8.5e+54: tmp = -x elif z <= -1.28e-123: tmp = t_0 elif z <= 2.8e-277: tmp = x / z elif z <= 6e-197: tmp = t_0 elif z <= 1.92e-83: tmp = x / z elif z <= 1.42e-56: tmp = t_0 elif z <= 8.5e-17: tmp = x / z elif z <= 9.8e+107: 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 <= -8.5e+54) tmp = Float64(-x); elseif (z <= -1.28e-123) tmp = t_0; elseif (z <= 2.8e-277) tmp = Float64(x / z); elseif (z <= 6e-197) tmp = t_0; elseif (z <= 1.92e-83) tmp = Float64(x / z); elseif (z <= 1.42e-56) tmp = t_0; elseif (z <= 8.5e-17) tmp = Float64(x / z); elseif (z <= 9.8e+107) 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 <= -8.5e+54) tmp = -x; elseif (z <= -1.28e-123) tmp = t_0; elseif (z <= 2.8e-277) tmp = x / z; elseif (z <= 6e-197) tmp = t_0; elseif (z <= 1.92e-83) tmp = x / z; elseif (z <= 1.42e-56) tmp = t_0; elseif (z <= 8.5e-17) tmp = x / z; elseif (z <= 9.8e+107) 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, -8.5e+54], (-x), If[LessEqual[z, -1.28e-123], t$95$0, If[LessEqual[z, 2.8e-277], N[(x / z), $MachinePrecision], If[LessEqual[z, 6e-197], t$95$0, If[LessEqual[z, 1.92e-83], N[(x / z), $MachinePrecision], If[LessEqual[z, 1.42e-56], t$95$0, If[LessEqual[z, 8.5e-17], N[(x / z), $MachinePrecision], If[LessEqual[z, 9.8e+107], t$95$0, (-x)]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{z} \cdot y\\
\mathbf{if}\;z \leq -8.5 \cdot 10^{+54}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -1.28 \cdot 10^{-123}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{-277}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 6 \cdot 10^{-197}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.92 \cdot 10^{-83}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 1.42 \cdot 10^{-56}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 8.5 \cdot 10^{-17}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 9.8 \cdot 10^{+107}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -8.4999999999999995e54 or 9.8000000000000003e107 < z Initial program 70.3%
Taylor expanded in z around inf 85.7%
neg-mul-185.7%
Simplified85.7%
if -8.4999999999999995e54 < z < -1.28000000000000002e-123 or 2.79999999999999976e-277 < z < 6.00000000000000051e-197 or 1.92000000000000014e-83 < z < 1.42e-56 or 8.5e-17 < z < 9.8000000000000003e107Initial program 98.7%
Taylor expanded in y around inf 73.8%
associate-/l*70.9%
associate-/r/73.7%
Simplified73.7%
if -1.28000000000000002e-123 < z < 2.79999999999999976e-277 or 6.00000000000000051e-197 < z < 1.92000000000000014e-83 or 1.42e-56 < z < 8.5e-17Initial program 99.9%
Taylor expanded in z around 0 99.9%
neg-mul-199.9%
+-commutative99.9%
unsub-neg99.9%
associate-/l*95.7%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in y around 0 77.3%
Taylor expanded in z around 0 77.3%
Final simplification79.3%
(FPCore (x y z)
:precision binary64
(if (or (<= y -14.0)
(and (not (<= y 6.5e+83))
(or (<= y 1.22e+151) (not (<= y 4.1e+193)))))
(* (/ x z) y)
(- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -14.0) || (!(y <= 6.5e+83) && ((y <= 1.22e+151) || !(y <= 4.1e+193)))) {
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 <= (-14.0d0)) .or. (.not. (y <= 6.5d+83)) .and. (y <= 1.22d+151) .or. (.not. (y <= 4.1d+193))) 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 <= -14.0) || (!(y <= 6.5e+83) && ((y <= 1.22e+151) || !(y <= 4.1e+193)))) {
tmp = (x / z) * y;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -14.0) or (not (y <= 6.5e+83) and ((y <= 1.22e+151) or not (y <= 4.1e+193))): tmp = (x / z) * y else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -14.0) || (!(y <= 6.5e+83) && ((y <= 1.22e+151) || !(y <= 4.1e+193)))) 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 <= -14.0) || (~((y <= 6.5e+83)) && ((y <= 1.22e+151) || ~((y <= 4.1e+193))))) tmp = (x / z) * y; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -14.0], And[N[Not[LessEqual[y, 6.5e+83]], $MachinePrecision], Or[LessEqual[y, 1.22e+151], N[Not[LessEqual[y, 4.1e+193]], $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 -14 \lor \neg \left(y \leq 6.5 \cdot 10^{+83}\right) \land \left(y \leq 1.22 \cdot 10^{+151} \lor \neg \left(y \leq 4.1 \cdot 10^{+193}\right)\right):\\
\;\;\;\;\frac{x}{z} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -14 or 6.5000000000000003e83 < y < 1.22000000000000005e151 or 4.0999999999999997e193 < y Initial program 88.8%
Taylor expanded in y around inf 78.1%
associate-/l*76.2%
associate-/r/79.4%
Simplified79.4%
if -14 < y < 6.5000000000000003e83 or 1.22000000000000005e151 < y < 4.0999999999999997e193Initial program 88.6%
Taylor expanded in z around 0 98.7%
neg-mul-198.7%
+-commutative98.7%
unsub-neg98.7%
associate-/l*99.4%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in y around 0 94.8%
Final simplification88.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ x z) y)) (t_1 (- (/ x z) x)))
(if (<= y -10.0)
t_0
(if (<= y 3.1e+84)
t_1
(if (<= y 1.22e+151) t_0 (if (<= y 4.1e+193) t_1 (/ x (/ z y))))))))
double code(double x, double y, double z) {
double t_0 = (x / z) * y;
double t_1 = (x / z) - x;
double tmp;
if (y <= -10.0) {
tmp = t_0;
} else if (y <= 3.1e+84) {
tmp = t_1;
} else if (y <= 1.22e+151) {
tmp = t_0;
} else if (y <= 4.1e+193) {
tmp = t_1;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (x / z) * y
t_1 = (x / z) - x
if (y <= (-10.0d0)) then
tmp = t_0
else if (y <= 3.1d+84) then
tmp = t_1
else if (y <= 1.22d+151) then
tmp = t_0
else if (y <= 4.1d+193) then
tmp = t_1
else
tmp = x / (z / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x / z) * y;
double t_1 = (x / z) - x;
double tmp;
if (y <= -10.0) {
tmp = t_0;
} else if (y <= 3.1e+84) {
tmp = t_1;
} else if (y <= 1.22e+151) {
tmp = t_0;
} else if (y <= 4.1e+193) {
tmp = t_1;
} else {
tmp = x / (z / y);
}
return tmp;
}
def code(x, y, z): t_0 = (x / z) * y t_1 = (x / z) - x tmp = 0 if y <= -10.0: tmp = t_0 elif y <= 3.1e+84: tmp = t_1 elif y <= 1.22e+151: tmp = t_0 elif y <= 4.1e+193: tmp = t_1 else: tmp = x / (z / y) return tmp
function code(x, y, z) t_0 = Float64(Float64(x / z) * y) t_1 = Float64(Float64(x / z) - x) tmp = 0.0 if (y <= -10.0) tmp = t_0; elseif (y <= 3.1e+84) tmp = t_1; elseif (y <= 1.22e+151) tmp = t_0; elseif (y <= 4.1e+193) tmp = t_1; else tmp = Float64(x / Float64(z / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x / z) * y; t_1 = (x / z) - x; tmp = 0.0; if (y <= -10.0) tmp = t_0; elseif (y <= 3.1e+84) tmp = t_1; elseif (y <= 1.22e+151) tmp = t_0; elseif (y <= 4.1e+193) tmp = t_1; else tmp = x / (z / y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]}, If[LessEqual[y, -10.0], t$95$0, If[LessEqual[y, 3.1e+84], t$95$1, If[LessEqual[y, 1.22e+151], t$95$0, If[LessEqual[y, 4.1e+193], t$95$1, N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{z} \cdot y\\
t_1 := \frac{x}{z} - x\\
\mathbf{if}\;y \leq -10:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 3.1 \cdot 10^{+84}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 1.22 \cdot 10^{+151}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 4.1 \cdot 10^{+193}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\
\end{array}
\end{array}
if y < -10 or 3.10000000000000003e84 < y < 1.22000000000000005e151Initial program 91.4%
Taylor expanded in y around inf 77.2%
associate-/l*73.6%
associate-/r/78.5%
Simplified78.5%
if -10 < y < 3.10000000000000003e84 or 1.22000000000000005e151 < y < 4.0999999999999997e193Initial program 88.6%
Taylor expanded in z around 0 98.7%
neg-mul-198.7%
+-commutative98.7%
unsub-neg98.7%
associate-/l*99.4%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in y around 0 94.8%
if 4.0999999999999997e193 < y Initial program 81.1%
Taylor expanded in y around inf 81.1%
associate-/l*84.0%
Simplified84.0%
Final simplification88.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -14.5) (not (<= z 1.35e-16))) (- (* x (/ y z)) x) (* (/ x z) (+ 1.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -14.5) || !(z <= 1.35e-16)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x / z) * (1.0 + 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 ((z <= (-14.5d0)) .or. (.not. (z <= 1.35d-16))) then
tmp = (x * (y / z)) - x
else
tmp = (x / z) * (1.0d0 + y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -14.5) || !(z <= 1.35e-16)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x / z) * (1.0 + y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -14.5) or not (z <= 1.35e-16): tmp = (x * (y / z)) - x else: tmp = (x / z) * (1.0 + y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -14.5) || !(z <= 1.35e-16)) tmp = Float64(Float64(x * Float64(y / z)) - x); else tmp = Float64(Float64(x / z) * Float64(1.0 + y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -14.5) || ~((z <= 1.35e-16))) tmp = (x * (y / z)) - x; else tmp = (x / z) * (1.0 + y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -14.5], N[Not[LessEqual[z, 1.35e-16]], $MachinePrecision]], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(1.0 + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -14.5 \lor \neg \left(z \leq 1.35 \cdot 10^{-16}\right):\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(1 + y\right)\\
\end{array}
\end{array}
if z < -14.5 or 1.35e-16 < z Initial program 75.9%
Taylor expanded in z around 0 88.6%
neg-mul-188.6%
+-commutative88.6%
unsub-neg88.6%
associate-/l*99.9%
associate-/r/97.8%
Simplified97.8%
Taylor expanded in y around inf 87.7%
associate-*r/99.0%
Simplified99.0%
if -14.5 < z < 1.35e-16Initial program 99.9%
Taylor expanded in z around 0 99.9%
associate-/l*94.9%
associate-/r/99.9%
Simplified99.9%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (<= z -4e+56) (- x) (if (<= z 9.8e+107) (* (/ x z) (+ 1.0 y)) (- (/ x z) x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -4e+56) {
tmp = -x;
} else if (z <= 9.8e+107) {
tmp = (x / z) * (1.0 + 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 (z <= (-4d+56)) then
tmp = -x
else if (z <= 9.8d+107) then
tmp = (x / z) * (1.0d0 + 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 (z <= -4e+56) {
tmp = -x;
} else if (z <= 9.8e+107) {
tmp = (x / z) * (1.0 + y);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4e+56: tmp = -x elif z <= 9.8e+107: tmp = (x / z) * (1.0 + y) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4e+56) tmp = Float64(-x); elseif (z <= 9.8e+107) tmp = Float64(Float64(x / z) * Float64(1.0 + y)); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -4e+56) tmp = -x; elseif (z <= 9.8e+107) tmp = (x / z) * (1.0 + y); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4e+56], (-x), If[LessEqual[z, 9.8e+107], N[(N[(x / z), $MachinePrecision] * N[(1.0 + y), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4 \cdot 10^{+56}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 9.8 \cdot 10^{+107}:\\
\;\;\;\;\frac{x}{z} \cdot \left(1 + y\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if z < -4.00000000000000037e56Initial program 69.7%
Taylor expanded in z around inf 84.4%
neg-mul-184.4%
Simplified84.4%
if -4.00000000000000037e56 < z < 9.8000000000000003e107Initial program 99.4%
Taylor expanded in z around 0 93.9%
associate-/l*90.3%
associate-/r/93.9%
Simplified93.9%
if 9.8000000000000003e107 < z Initial program 71.6%
Taylor expanded in z around 0 93.3%
neg-mul-193.3%
+-commutative93.3%
unsub-neg93.3%
associate-/l*99.9%
associate-/r/97.8%
Simplified97.8%
Taylor expanded in y around 0 88.6%
Final simplification90.9%
(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 88.7%
Taylor expanded in z around 0 94.6%
neg-mul-194.6%
+-commutative94.6%
unsub-neg94.6%
associate-/l*97.3%
associate-/r/98.9%
Simplified98.9%
Final simplification98.9%
(FPCore (x y z) :precision binary64 (if (<= z -14.5) (- x) (if (<= z 1.35e-16) (/ x z) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -14.5) {
tmp = -x;
} else if (z <= 1.35e-16) {
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 <= (-14.5d0)) then
tmp = -x
else if (z <= 1.35d-16) 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 <= -14.5) {
tmp = -x;
} else if (z <= 1.35e-16) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -14.5: tmp = -x elif z <= 1.35e-16: tmp = x / z else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -14.5) tmp = Float64(-x); elseif (z <= 1.35e-16) tmp = Float64(x / z); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -14.5) tmp = -x; elseif (z <= 1.35e-16) tmp = x / z; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -14.5], (-x), If[LessEqual[z, 1.35e-16], N[(x / z), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -14.5:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 1.35 \cdot 10^{-16}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -14.5 or 1.35e-16 < z Initial program 75.9%
Taylor expanded in z around inf 74.4%
neg-mul-174.4%
Simplified74.4%
if -14.5 < z < 1.35e-16Initial program 99.9%
Taylor expanded in z around 0 99.9%
neg-mul-199.9%
+-commutative99.9%
unsub-neg99.9%
associate-/l*94.9%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in y around 0 59.1%
Taylor expanded in z around 0 59.1%
Final simplification66.3%
(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.7%
Taylor expanded in z around inf 36.5%
neg-mul-136.5%
Simplified36.5%
Final simplification36.5%
(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 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.7%
Taylor expanded in z around inf 28.0%
associate-*r*28.0%
neg-mul-128.0%
Simplified28.0%
div-inv27.9%
associate-*l*36.4%
div-inv36.5%
*-inverses36.5%
*-commutative36.5%
*-un-lft-identity36.5%
neg-sub036.5%
metadata-eval36.5%
sub-neg36.5%
metadata-eval36.5%
add-sqr-sqrt15.7%
sqrt-unprod17.3%
sqr-neg17.3%
sqrt-unprod1.5%
add-sqr-sqrt3.1%
Applied egg-rr3.1%
+-lft-identity3.1%
Simplified3.1%
Final simplification3.1%
(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 2023293
(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))