
(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 -1.1e-15) (not (<= z 5e-77))) (* x (/ (+ (- y z) 1.0) z)) (/ (* x (+ y 1.0)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.1e-15) || !(z <= 5e-77)) {
tmp = x * (((y - z) + 1.0) / z);
} else {
tmp = (x * (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) :: tmp
if ((z <= (-1.1d-15)) .or. (.not. (z <= 5d-77))) then
tmp = x * (((y - z) + 1.0d0) / z)
else
tmp = (x * (y + 1.0d0)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.1e-15) || !(z <= 5e-77)) {
tmp = x * (((y - z) + 1.0) / z);
} else {
tmp = (x * (y + 1.0)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.1e-15) or not (z <= 5e-77): tmp = x * (((y - z) + 1.0) / z) else: tmp = (x * (y + 1.0)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.1e-15) || !(z <= 5e-77)) tmp = Float64(x * Float64(Float64(Float64(y - z) + 1.0) / z)); else tmp = Float64(Float64(x * Float64(y + 1.0)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.1e-15) || ~((z <= 5e-77))) tmp = x * (((y - z) + 1.0) / z); else tmp = (x * (y + 1.0)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.1e-15], N[Not[LessEqual[z, 5e-77]], $MachinePrecision]], N[(x * N[(N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(y + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.1 \cdot 10^{-15} \lor \neg \left(z \leq 5 \cdot 10^{-77}\right):\\
\;\;\;\;x \cdot \frac{\left(y - z\right) + 1}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(y + 1\right)}{z}\\
\end{array}
\end{array}
if z < -1.09999999999999993e-15 or 4.99999999999999963e-77 < z Initial program 82.3%
associate-/l*99.9%
Simplified99.9%
if -1.09999999999999993e-15 < z < 4.99999999999999963e-77Initial program 99.9%
associate-/l*87.9%
Simplified87.9%
Taylor expanded in z around 0 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= x 0.21) (/ (fma x (- y z) x) z) (* x (/ (+ (- y z) 1.0) z))))
double code(double x, double y, double z) {
double tmp;
if (x <= 0.21) {
tmp = fma(x, (y - z), x) / z;
} else {
tmp = x * (((y - z) + 1.0) / z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 0.21) tmp = Float64(fma(x, Float64(y - z), x) / z); else tmp = Float64(x * Float64(Float64(Float64(y - z) + 1.0) / z)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 0.21], N[(N[(x * N[(y - z), $MachinePrecision] + x), $MachinePrecision] / z), $MachinePrecision], N[(x * N[(N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.21:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y - z, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\left(y - z\right) + 1}{z}\\
\end{array}
\end{array}
if x < 0.209999999999999992Initial program 92.5%
distribute-lft-in92.5%
fma-define92.5%
*-rgt-identity92.5%
Simplified92.5%
if 0.209999999999999992 < x Initial program 80.1%
associate-/l*99.9%
Simplified99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -1.3e+103)
(- x)
(if (<= z -1.18e-200)
t_0
(if (<= z 4.8e-209) (/ x z) (if (<= z 1.1e+18) t_0 (- x)))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -1.3e+103) {
tmp = -x;
} else if (z <= -1.18e-200) {
tmp = t_0;
} else if (z <= 4.8e-209) {
tmp = x / z;
} else if (z <= 1.1e+18) {
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.3d+103)) then
tmp = -x
else if (z <= (-1.18d-200)) then
tmp = t_0
else if (z <= 4.8d-209) then
tmp = x / z
else if (z <= 1.1d+18) 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.3e+103) {
tmp = -x;
} else if (z <= -1.18e-200) {
tmp = t_0;
} else if (z <= 4.8e-209) {
tmp = x / z;
} else if (z <= 1.1e+18) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -1.3e+103: tmp = -x elif z <= -1.18e-200: tmp = t_0 elif z <= 4.8e-209: tmp = x / z elif z <= 1.1e+18: 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.3e+103) tmp = Float64(-x); elseif (z <= -1.18e-200) tmp = t_0; elseif (z <= 4.8e-209) tmp = Float64(x / z); elseif (z <= 1.1e+18) 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.3e+103) tmp = -x; elseif (z <= -1.18e-200) tmp = t_0; elseif (z <= 4.8e-209) tmp = x / z; elseif (z <= 1.1e+18) 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.3e+103], (-x), If[LessEqual[z, -1.18e-200], t$95$0, If[LessEqual[z, 4.8e-209], N[(x / z), $MachinePrecision], If[LessEqual[z, 1.1e+18], t$95$0, (-x)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -1.3 \cdot 10^{+103}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -1.18 \cdot 10^{-200}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 4.8 \cdot 10^{-209}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 1.1 \cdot 10^{+18}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1.3000000000000001e103 or 1.1e18 < z Initial program 76.9%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in z around inf 85.3%
mul-1-neg85.3%
Simplified85.3%
if -1.3000000000000001e103 < z < -1.17999999999999996e-200 or 4.8000000000000002e-209 < z < 1.1e18Initial program 99.0%
associate-/l*90.8%
Simplified90.8%
Taylor expanded in x around 0 99.0%
associate--l+99.0%
+-commutative99.0%
associate-*l/99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in y around inf 66.1%
if -1.17999999999999996e-200 < z < 4.8000000000000002e-209Initial program 99.9%
associate-/l*91.2%
Simplified91.2%
Taylor expanded in y around 0 74.6%
associate-/l*74.5%
Simplified74.5%
Taylor expanded in z around 0 74.6%
Final simplification75.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ y z))))
(if (<= z -1.3e+103)
(- x)
(if (<= z -3.3e-202)
t_0
(if (<= z 5.7e-209) (/ x z) (if (<= z 1.4e+19) t_0 (- x)))))))
double code(double x, double y, double z) {
double t_0 = x * (y / z);
double tmp;
if (z <= -1.3e+103) {
tmp = -x;
} else if (z <= -3.3e-202) {
tmp = t_0;
} else if (z <= 5.7e-209) {
tmp = x / z;
} else if (z <= 1.4e+19) {
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 * (y / z)
if (z <= (-1.3d+103)) then
tmp = -x
else if (z <= (-3.3d-202)) then
tmp = t_0
else if (z <= 5.7d-209) then
tmp = x / z
else if (z <= 1.4d+19) 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 * (y / z);
double tmp;
if (z <= -1.3e+103) {
tmp = -x;
} else if (z <= -3.3e-202) {
tmp = t_0;
} else if (z <= 5.7e-209) {
tmp = x / z;
} else if (z <= 1.4e+19) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y / z) tmp = 0 if z <= -1.3e+103: tmp = -x elif z <= -3.3e-202: tmp = t_0 elif z <= 5.7e-209: tmp = x / z elif z <= 1.4e+19: tmp = t_0 else: tmp = -x return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y / z)) tmp = 0.0 if (z <= -1.3e+103) tmp = Float64(-x); elseif (z <= -3.3e-202) tmp = t_0; elseif (z <= 5.7e-209) tmp = Float64(x / z); elseif (z <= 1.4e+19) tmp = t_0; else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (y / z); tmp = 0.0; if (z <= -1.3e+103) tmp = -x; elseif (z <= -3.3e-202) tmp = t_0; elseif (z <= 5.7e-209) tmp = x / z; elseif (z <= 1.4e+19) tmp = t_0; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.3e+103], (-x), If[LessEqual[z, -3.3e-202], t$95$0, If[LessEqual[z, 5.7e-209], N[(x / z), $MachinePrecision], If[LessEqual[z, 1.4e+19], t$95$0, (-x)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{y}{z}\\
\mathbf{if}\;z \leq -1.3 \cdot 10^{+103}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -3.3 \cdot 10^{-202}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 5.7 \cdot 10^{-209}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 1.4 \cdot 10^{+19}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1.3000000000000001e103 or 1.4e19 < z Initial program 76.9%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in z around inf 85.3%
mul-1-neg85.3%
Simplified85.3%
if -1.3000000000000001e103 < z < -3.29999999999999989e-202 or 5.7000000000000004e-209 < z < 1.4e19Initial program 99.0%
associate-/l*90.8%
Simplified90.8%
Taylor expanded in y around inf 64.0%
associate-/l*55.1%
Simplified55.1%
if -3.29999999999999989e-202 < z < 5.7000000000000004e-209Initial program 99.9%
associate-/l*91.2%
Simplified91.2%
Taylor expanded in y around 0 74.6%
associate-/l*74.5%
Simplified74.5%
Taylor expanded in z around 0 74.6%
(FPCore (x y z) :precision binary64 (if (<= z -1.32e+103) (- x) (if (<= z 40000000000000.0) (/ (* x (+ y 1.0)) z) (- (/ x z) x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.32e+103) {
tmp = -x;
} else if (z <= 40000000000000.0) {
tmp = (x * (y + 1.0)) / 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 (z <= (-1.32d+103)) then
tmp = -x
else if (z <= 40000000000000.0d0) then
tmp = (x * (y + 1.0d0)) / 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 (z <= -1.32e+103) {
tmp = -x;
} else if (z <= 40000000000000.0) {
tmp = (x * (y + 1.0)) / z;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.32e+103: tmp = -x elif z <= 40000000000000.0: tmp = (x * (y + 1.0)) / z else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.32e+103) tmp = Float64(-x); elseif (z <= 40000000000000.0) tmp = Float64(Float64(x * Float64(y + 1.0)) / z); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.32e+103) tmp = -x; elseif (z <= 40000000000000.0) tmp = (x * (y + 1.0)) / z; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.32e+103], (-x), If[LessEqual[z, 40000000000000.0], N[(N[(x * N[(y + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.32 \cdot 10^{+103}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 40000000000000:\\
\;\;\;\;\frac{x \cdot \left(y + 1\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if z < -1.31999999999999999e103Initial program 73.3%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in z around inf 96.1%
mul-1-neg96.1%
Simplified96.1%
if -1.31999999999999999e103 < z < 4e13Initial program 99.2%
associate-/l*90.8%
Simplified90.8%
Taylor expanded in z around 0 92.4%
if 4e13 < z Initial program 80.4%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 61.1%
associate-/l*76.2%
Simplified76.2%
Taylor expanded in z around inf 76.2%
+-commutative76.2%
mul-1-neg76.2%
unsub-neg76.2%
Simplified76.2%
Final simplification89.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -6e+71) (not (<= y 1.85e+49))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6e+71) || !(y <= 1.85e+49)) {
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 <= (-6d+71)) .or. (.not. (y <= 1.85d+49))) 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 <= -6e+71) || !(y <= 1.85e+49)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6e+71) or not (y <= 1.85e+49): tmp = y * (x / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6e+71) || !(y <= 1.85e+49)) 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 <= -6e+71) || ~((y <= 1.85e+49))) tmp = y * (x / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6e+71], N[Not[LessEqual[y, 1.85e+49]], $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 -6 \cdot 10^{+71} \lor \neg \left(y \leq 1.85 \cdot 10^{+49}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -6.00000000000000025e71 or 1.85000000000000009e49 < y Initial program 89.1%
associate-/l*89.2%
Simplified89.2%
Taylor expanded in x around 0 89.1%
associate--l+89.1%
+-commutative89.1%
associate-*l/92.7%
+-commutative92.7%
Simplified92.7%
Taylor expanded in y around inf 77.5%
if -6.00000000000000025e71 < y < 1.85000000000000009e49Initial program 90.7%
associate-/l*99.1%
Simplified99.1%
Taylor expanded in y around 0 84.0%
associate-/l*93.1%
Simplified93.1%
Taylor expanded in z around inf 93.3%
+-commutative93.3%
mul-1-neg93.3%
unsub-neg93.3%
Simplified93.3%
Final simplification86.2%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (- y z) 1.0))) (if (<= x 0.21) (/ (* x t_0) z) (* x (/ t_0 z)))))
double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if (x <= 0.21) {
tmp = (x * t_0) / z;
} else {
tmp = x * (t_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 <= 0.21d0) then
tmp = (x * t_0) / z
else
tmp = x * (t_0 / 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 <= 0.21) {
tmp = (x * t_0) / z;
} else {
tmp = x * (t_0 / z);
}
return tmp;
}
def code(x, y, z): t_0 = (y - z) + 1.0 tmp = 0 if x <= 0.21: tmp = (x * t_0) / z else: tmp = x * (t_0 / z) return tmp
function code(x, y, z) t_0 = Float64(Float64(y - z) + 1.0) tmp = 0.0 if (x <= 0.21) tmp = Float64(Float64(x * t_0) / z); else tmp = Float64(x * Float64(t_0 / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y - z) + 1.0; tmp = 0.0; if (x <= 0.21) tmp = (x * t_0) / z; else tmp = x * (t_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[x, 0.21], N[(N[(x * t$95$0), $MachinePrecision] / z), $MachinePrecision], N[(x * N[(t$95$0 / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y - z\right) + 1\\
\mathbf{if}\;x \leq 0.21:\\
\;\;\;\;\frac{x \cdot t\_0}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{t\_0}{z}\\
\end{array}
\end{array}
if x < 0.209999999999999992Initial program 92.5%
if 0.209999999999999992 < x Initial program 80.1%
associate-/l*99.9%
Simplified99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 0.0033))) (- x) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 0.0033)) {
tmp = -x;
} else {
tmp = x / 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 <= (-1.0d0)) .or. (.not. (z <= 0.0033d0))) then
tmp = -x
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 0.0033)) {
tmp = -x;
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 0.0033): tmp = -x else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 0.0033)) tmp = Float64(-x); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 0.0033))) tmp = -x; else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 0.0033]], $MachinePrecision]], (-x), N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 0.0033\right):\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if z < -1 or 0.0033 < z Initial program 81.1%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around inf 74.6%
mul-1-neg74.6%
Simplified74.6%
if -1 < z < 0.0033Initial program 99.9%
associate-/l*88.8%
Simplified88.8%
Taylor expanded in y around 0 54.2%
associate-/l*54.1%
Simplified54.1%
Taylor expanded in z around 0 53.8%
Final simplification64.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.0%
associate-/l*94.7%
Simplified94.7%
Taylor expanded in z around inf 40.8%
mul-1-neg40.8%
Simplified40.8%
(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 90.0%
associate-/l*94.7%
Simplified94.7%
Taylor expanded in z around inf 40.8%
mul-1-neg40.8%
Simplified40.8%
neg-sub040.8%
sub-neg40.8%
add-sqr-sqrt24.4%
sqrt-unprod24.4%
sqr-neg24.4%
sqrt-unprod1.3%
add-sqr-sqrt2.8%
Applied egg-rr2.8%
Taylor expanded in x around 0 2.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 2024137
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
:alt
(! :herbie-platform default (if (< x -67870776678359/25000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (+ 1 y) (/ x z)) x) (if (< x 1937054408219773/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* (* x (+ (- y z) 1)) (/ 1 z)) (- (* (+ 1 y) (/ x z)) x))))
(/ (* x (+ (- y z) 1.0)) z))