
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x + sin(y)) + (z * cos(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x + math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x + sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x + sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \sin y\right) + z \cdot \cos y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x + sin(y)) + (z * cos(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x + math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x + sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x + sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \sin y\right) + z \cdot \cos y
\end{array}
(FPCore (x y z) :precision binary64 (fma z (cos y) (+ x (sin y))))
double code(double x, double y, double z) {
return fma(z, cos(y), (x + sin(y)));
}
function code(x, y, z) return fma(z, cos(y), Float64(x + sin(y))) end
code[x_, y_, z_] := N[(z * N[Cos[y], $MachinePrecision] + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, \cos y, x + \sin y\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
fma-def99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= z -2.4e+62) (+ x (* z (cos y))) (if (<= z 2e-17) (+ z (+ x (sin y))) (fma z (cos y) x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.4e+62) {
tmp = x + (z * cos(y));
} else if (z <= 2e-17) {
tmp = z + (x + sin(y));
} else {
tmp = fma(z, cos(y), x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -2.4e+62) tmp = Float64(x + Float64(z * cos(y))); elseif (z <= 2e-17) tmp = Float64(z + Float64(x + sin(y))); else tmp = fma(z, cos(y), x); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -2.4e+62], N[(x + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2e-17], N[(z + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[Cos[y], $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.4 \cdot 10^{+62}:\\
\;\;\;\;x + z \cdot \cos y\\
\mathbf{elif}\;z \leq 2 \cdot 10^{-17}:\\
\;\;\;\;z + \left(x + \sin y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, \cos y, x\right)\\
\end{array}
\end{array}
if z < -2.4e62Initial program 100.0%
Taylor expanded in x around inf 100.0%
if -2.4e62 < z < 2.00000000000000014e-17Initial program 100.0%
Taylor expanded in y around 0 100.0%
if 2.00000000000000014e-17 < z Initial program 99.8%
+-commutative99.8%
fma-def99.9%
Simplified99.9%
Taylor expanded in x around inf 98.3%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x + sin(y)) + (z * cos(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x + math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x + sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x + sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \sin y\right) + z \cdot \cos y
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -6e-81) (not (<= x 4e-140))) (+ x (* z (cos y))) (+ z (sin y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -6e-81) || !(x <= 4e-140)) {
tmp = x + (z * cos(y));
} else {
tmp = z + sin(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 ((x <= (-6d-81)) .or. (.not. (x <= 4d-140))) then
tmp = x + (z * cos(y))
else
tmp = z + sin(y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -6e-81) || !(x <= 4e-140)) {
tmp = x + (z * Math.cos(y));
} else {
tmp = z + Math.sin(y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -6e-81) or not (x <= 4e-140): tmp = x + (z * math.cos(y)) else: tmp = z + math.sin(y) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -6e-81) || !(x <= 4e-140)) tmp = Float64(x + Float64(z * cos(y))); else tmp = Float64(z + sin(y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -6e-81) || ~((x <= 4e-140))) tmp = x + (z * cos(y)); else tmp = z + sin(y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -6e-81], N[Not[LessEqual[x, 4e-140]], $MachinePrecision]], N[(x + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z + N[Sin[y], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6 \cdot 10^{-81} \lor \neg \left(x \leq 4 \cdot 10^{-140}\right):\\
\;\;\;\;x + z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;z + \sin y\\
\end{array}
\end{array}
if x < -5.9999999999999998e-81 or 3.9999999999999999e-140 < x Initial program 99.9%
Taylor expanded in x around inf 95.6%
if -5.9999999999999998e-81 < x < 3.9999999999999999e-140Initial program 99.9%
Taylor expanded in y around 0 86.5%
Taylor expanded in x around 0 84.3%
Final simplification91.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.4e+62) (not (<= z 2e-17))) (+ x (* z (cos y))) (+ z (+ x (sin y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.4e+62) || !(z <= 2e-17)) {
tmp = x + (z * cos(y));
} else {
tmp = z + (x + sin(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 <= (-2.4d+62)) .or. (.not. (z <= 2d-17))) then
tmp = x + (z * cos(y))
else
tmp = z + (x + sin(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.4e+62) || !(z <= 2e-17)) {
tmp = x + (z * Math.cos(y));
} else {
tmp = z + (x + Math.sin(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.4e+62) or not (z <= 2e-17): tmp = x + (z * math.cos(y)) else: tmp = z + (x + math.sin(y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.4e+62) || !(z <= 2e-17)) tmp = Float64(x + Float64(z * cos(y))); else tmp = Float64(z + Float64(x + sin(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.4e+62) || ~((z <= 2e-17))) tmp = x + (z * cos(y)); else tmp = z + (x + sin(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.4e+62], N[Not[LessEqual[z, 2e-17]], $MachinePrecision]], N[(x + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.4 \cdot 10^{+62} \lor \neg \left(z \leq 2 \cdot 10^{-17}\right):\\
\;\;\;\;x + z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;z + \left(x + \sin y\right)\\
\end{array}
\end{array}
if z < -2.4e62 or 2.00000000000000014e-17 < z Initial program 99.9%
Taylor expanded in x around inf 98.8%
if -2.4e62 < z < 2.00000000000000014e-17Initial program 100.0%
Taylor expanded in y around 0 100.0%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (<= x -2.5e-71) (+ z x) (if (<= x 1.65e-52) (+ z (sin y)) (+ z x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.5e-71) {
tmp = z + x;
} else if (x <= 1.65e-52) {
tmp = z + sin(y);
} else {
tmp = 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 (x <= (-2.5d-71)) then
tmp = z + x
else if (x <= 1.65d-52) then
tmp = z + sin(y)
else
tmp = z + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2.5e-71) {
tmp = z + x;
} else if (x <= 1.65e-52) {
tmp = z + Math.sin(y);
} else {
tmp = z + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.5e-71: tmp = z + x elif x <= 1.65e-52: tmp = z + math.sin(y) else: tmp = z + x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.5e-71) tmp = Float64(z + x); elseif (x <= 1.65e-52) tmp = Float64(z + sin(y)); else tmp = Float64(z + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2.5e-71) tmp = z + x; elseif (x <= 1.65e-52) tmp = z + sin(y); else tmp = z + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.5e-71], N[(z + x), $MachinePrecision], If[LessEqual[x, 1.65e-52], N[(z + N[Sin[y], $MachinePrecision]), $MachinePrecision], N[(z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.5 \cdot 10^{-71}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{-52}:\\
\;\;\;\;z + \sin y\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if x < -2.49999999999999999e-71 or 1.64999999999999998e-52 < x Initial program 99.9%
Taylor expanded in y around 0 85.5%
if -2.49999999999999999e-71 < x < 1.64999999999999998e-52Initial program 99.9%
Taylor expanded in y around 0 86.4%
Taylor expanded in x around 0 84.5%
Final simplification85.1%
(FPCore (x y z) :precision binary64 (if (<= y -275000000000.0) (+ z x) (if (<= y 2e+27) (+ y (+ z x)) (+ z x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -275000000000.0) {
tmp = z + x;
} else if (y <= 2e+27) {
tmp = y + (z + x);
} else {
tmp = 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 <= (-275000000000.0d0)) then
tmp = z + x
else if (y <= 2d+27) then
tmp = y + (z + x)
else
tmp = z + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -275000000000.0) {
tmp = z + x;
} else if (y <= 2e+27) {
tmp = y + (z + x);
} else {
tmp = z + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -275000000000.0: tmp = z + x elif y <= 2e+27: tmp = y + (z + x) else: tmp = z + x return tmp
function code(x, y, z) tmp = 0.0 if (y <= -275000000000.0) tmp = Float64(z + x); elseif (y <= 2e+27) tmp = Float64(y + Float64(z + x)); else tmp = Float64(z + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -275000000000.0) tmp = z + x; elseif (y <= 2e+27) tmp = y + (z + x); else tmp = z + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -275000000000.0], N[(z + x), $MachinePrecision], If[LessEqual[y, 2e+27], N[(y + N[(z + x), $MachinePrecision]), $MachinePrecision], N[(z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -275000000000:\\
\;\;\;\;z + x\\
\mathbf{elif}\;y \leq 2 \cdot 10^{+27}:\\
\;\;\;\;y + \left(z + x\right)\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if y < -2.75e11 or 2e27 < y Initial program 99.9%
Taylor expanded in y around 0 49.7%
if -2.75e11 < y < 2e27Initial program 100.0%
Taylor expanded in y around 0 97.5%
Final simplification77.1%
(FPCore (x y z) :precision binary64 (if (<= x -1.2e-9) x (if (<= x 2.5e-51) (+ z y) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.2e-9) {
tmp = x;
} else if (x <= 2.5e-51) {
tmp = z + y;
} 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 (x <= (-1.2d-9)) then
tmp = x
else if (x <= 2.5d-51) then
tmp = z + y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.2e-9) {
tmp = x;
} else if (x <= 2.5e-51) {
tmp = z + y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.2e-9: tmp = x elif x <= 2.5e-51: tmp = z + y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.2e-9) tmp = x; elseif (x <= 2.5e-51) tmp = Float64(z + y); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.2e-9) tmp = x; elseif (x <= 2.5e-51) tmp = z + y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.2e-9], x, If[LessEqual[x, 2.5e-51], N[(z + y), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{-9}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{-51}:\\
\;\;\;\;z + y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.2e-9 or 2.50000000000000002e-51 < x Initial program 99.9%
+-commutative99.9%
fma-def100.0%
Simplified100.0%
Taylor expanded in x around inf 96.9%
Taylor expanded in z around 0 72.6%
if -1.2e-9 < x < 2.50000000000000002e-51Initial program 99.9%
Taylor expanded in y around 0 64.0%
Taylor expanded in x around 0 59.7%
Final simplification67.0%
(FPCore (x y z) :precision binary64 (if (<= x -9.8e-191) (+ z x) (if (<= x 4.6e-57) (+ z y) (+ z x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -9.8e-191) {
tmp = z + x;
} else if (x <= 4.6e-57) {
tmp = z + y;
} else {
tmp = 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 (x <= (-9.8d-191)) then
tmp = z + x
else if (x <= 4.6d-57) then
tmp = z + y
else
tmp = z + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -9.8e-191) {
tmp = z + x;
} else if (x <= 4.6e-57) {
tmp = z + y;
} else {
tmp = z + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -9.8e-191: tmp = z + x elif x <= 4.6e-57: tmp = z + y else: tmp = z + x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -9.8e-191) tmp = Float64(z + x); elseif (x <= 4.6e-57) tmp = Float64(z + y); else tmp = Float64(z + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -9.8e-191) tmp = z + x; elseif (x <= 4.6e-57) tmp = z + y; else tmp = z + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -9.8e-191], N[(z + x), $MachinePrecision], If[LessEqual[x, 4.6e-57], N[(z + y), $MachinePrecision], N[(z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.8 \cdot 10^{-191}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;x \leq 4.6 \cdot 10^{-57}:\\
\;\;\;\;z + y\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if x < -9.7999999999999999e-191 or 4.6e-57 < x Initial program 99.9%
Taylor expanded in y around 0 79.7%
if -9.7999999999999999e-191 < x < 4.6e-57Initial program 99.9%
Taylor expanded in y around 0 68.8%
Taylor expanded in x around 0 68.8%
Final simplification76.5%
(FPCore (x y z) :precision binary64 (if (<= x -9.8e-191) x (if (<= x 1.7e-52) y x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -9.8e-191) {
tmp = x;
} else if (x <= 1.7e-52) {
tmp = y;
} 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 (x <= (-9.8d-191)) then
tmp = x
else if (x <= 1.7d-52) then
tmp = y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -9.8e-191) {
tmp = x;
} else if (x <= 1.7e-52) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -9.8e-191: tmp = x elif x <= 1.7e-52: tmp = y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -9.8e-191) tmp = x; elseif (x <= 1.7e-52) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -9.8e-191) tmp = x; elseif (x <= 1.7e-52) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -9.8e-191], x, If[LessEqual[x, 1.7e-52], y, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.8 \cdot 10^{-191}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{-52}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -9.7999999999999999e-191 or 1.70000000000000009e-52 < x Initial program 99.9%
+-commutative99.9%
fma-def100.0%
Simplified100.0%
Taylor expanded in x around inf 90.9%
Taylor expanded in z around 0 61.8%
if -9.7999999999999999e-191 < x < 1.70000000000000009e-52Initial program 99.9%
Taylor expanded in y around 0 69.2%
Taylor expanded in y around inf 25.2%
Final simplification50.9%
(FPCore (x y z) :precision binary64 (if (<= x -1.7e-9) x (if (<= x 5.6e-51) z x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.7e-9) {
tmp = x;
} else if (x <= 5.6e-51) {
tmp = 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 (x <= (-1.7d-9)) then
tmp = x
else if (x <= 5.6d-51) then
tmp = z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.7e-9) {
tmp = x;
} else if (x <= 5.6e-51) {
tmp = z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.7e-9: tmp = x elif x <= 5.6e-51: tmp = z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.7e-9) tmp = x; elseif (x <= 5.6e-51) tmp = z; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.7e-9) tmp = x; elseif (x <= 5.6e-51) tmp = z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.7e-9], x, If[LessEqual[x, 5.6e-51], z, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{-9}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 5.6 \cdot 10^{-51}:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.6999999999999999e-9 or 5.6e-51 < x Initial program 99.9%
+-commutative99.9%
fma-def100.0%
Simplified100.0%
Taylor expanded in x around inf 96.9%
Taylor expanded in z around 0 72.6%
if -1.6999999999999999e-9 < x < 5.6e-51Initial program 99.9%
Taylor expanded in y around 0 64.0%
Taylor expanded in z around inf 44.9%
Final simplification60.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 x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 99.9%
+-commutative99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in x around inf 81.6%
Taylor expanded in z around 0 44.4%
Final simplification44.4%
herbie shell --seed 2023238
(FPCore (x y z)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, C"
:precision binary64
(+ (+ x (sin y)) (* z (cos y))))