I was attempting a question on  in which i was required to precompute Cube Root. I approached via binary search method but I am getting wrong answer while checking if given no. is integer or double. I followed this if (ceil(num) == floor (num)) //integer  but I am getting wrong answer in floor (num), for example: 27 (floor = 2, ceil = 3), 125 (floor = 4, ceil = 5) Here is the code. #include &lt;iostream&gt; #include &lt;iomanip&gt; #include &lt;cmath&gt; #include &lt;vector&gt; #define Size 1000001  //vector for storing positions  std::vector&lt;int&gt; pos;  //function for calculating cube root double cubeRoot(int n) {    double low = 0;    double high = (double)n;    for (int i = 0; i &lt; 50; ++i) {      double mid = (low + (high - low) / 2.0);     if (mid * mid * mid &gt; n) high = mid;      else low = mid;    }    //std::cout &lt;&lt; &quot; low : &quot; &lt;&lt; low &lt;&lt; &quot; , high : &quot; &lt;&lt; high &lt;&lt; '\n';   return low; }  int main () {    std::ios_base::sync_with_stdio(0);   std::cout.tie(0);   std::cin.tie(0);    //resized according to the question requirement    pos.resize(Size, 0);   pos[1] = 1;    int currentPosition = 2;  //variable to store the current position.    for (int i = 2; i &lt;= Size; i++) {      double ans = cubeRoot(i);      //std::cout &lt;&lt; i &lt;&lt; ' ' &lt;&lt; std::setprecision (10) &lt;&lt; ans &lt;&lt; ' ' &lt;&lt; floor(ans) &lt;&lt; ' ' &lt;&lt; ceil(ans) &lt;&lt; '\n';     if (ceil (cubeRoot(i)) == floor (cubeRoot(i))) {       pos[i] = -1;        currentPosition --;     }     else {       pos[i] = 1 + currentPosition;       currentPosition ++;     }   }    int testCase;   std::cin &gt;&gt; testCase;    for (int test = 1; test &lt;= testCase; ++test) {      int num;      std::cin &gt;&gt; num;       //Output format     std::cout &lt;&lt; &quot;Case &quot; &lt;&lt; test &lt;&lt; &quot;: &quot;;     if (pos[num] == -1) std::cout &lt;&lt; &quot;Not Cube Free\n&quot;;     else std::cout &lt;&lt; pos[num] &lt;&lt; '\n';   } }
Consider the following code:   0.1 + 0.2 == 0.3  -&gt;  false   0.1 + 0.2         -&gt;  0.30000000000000004   Why do these inaccuracies happen?
How do I install a fingerprint reader on Lenovo ThinkPad? I have a  with a fingerprint reader:    How to make Ubuntu recognise it and use it for login?  I already tried:  sudo add-apt-repository ppa:fingerprint/fingerprint-gui sudo apt-get update   ... but this GUI did not recognizes my device. Does anyone knows any other option? TZInfo::DataSourceNotFound error starting Rails v4.1.0 server on Windows After upgrading from 10.04 to 12.04 I am trying to install different packages.  For instance ia32-libs and skype (4.0).  When trying to install these, I am getting the 'Unable to correct problems, you have held broken packages' error message.   Output of commands:  sudo apt-get install -f Reading package lists... Done Building dependency tree        Reading state information... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.   After running this:  sudo dpkg --configure -a foo@foo:~$ sudo apt-get install -f Reading package lists... Done Building dependency tree        Reading state information... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Changing content of footline in beamer "I let him do it" and "I allow him to do it", why exactly does one require 'to'? Why is the B field of a solenoid equal to $\mu_0 i n$ while that of a loop is $\frac{\mu_0 i R^2}{2(R^2+z^2)^{3/2}}$? what is PGP public key block? There's PGP public key block posted on some websites (eg. ).  It's not hex code. it uses much more alphabet characters. What is it?  Why is this information posted? how can i use it? Why do quantum effects dominates when the thermal de Broglie wavelength is on the order of or larger than the interparticle distance? We say that when the thermal de Broglie wavelength is much smaller than the interparticle distance, the gas can be considered to be a classical or Maxwell–Boltzmann gas. On the other hand, when the thermal de Broglie wavelength is on the order of or larger than the interparticle distance, quantum effects will dominate and the gas must be treated as a Fermi gas or a Bose gas, depending on the nature of the gas particles.  $(V/N)^{1/3} &lt; \lambda_{th} $. My question is why do quantum effects dominate? Proving that the given set has at most $2^{n-1}$ elements Segmentation fault on large array sizes I am trying to show that: \begin{equation} \frac{n}{\phi(n)} = \sum_{d \mid n} \frac{\mu^2(d)}{\phi(d)} \end{equation} where $\phi(n)$ is  and $\mu$ is the .  The identity clearly holds for $n=1$, so if we write $n=p_1^{a_1} \cdots p_k^{a_k}$ for the prime decomposition of $n$, the left-hand side becomes: \begin{eqnarray*} \frac{n}{\phi(n)} &amp; = &amp; \frac{p_1^{a_1} \cdots p_k^{a_k}}{\phi(p_1^{a_1}) \cdots \phi(p_k^{a_k})} \\ &amp; = &amp; \frac{p_1^{a_1} \cdots p_k^{a_k}}{(p_1^{a_1-1})(p_1-1) \cdots (p_k^{a_k})(p_k-1)} \\ &amp; = &amp; \frac{p_1 \cdots p_k}{(p_1-1)\cdots (p_k-1)} \end{eqnarray*}   Whereas the right-hand side becomes:  \begin{eqnarray*} \sum_{d \mid n} \frac{\mu^2(d)}{\phi(d)} &amp; = &amp; \sum_{\substack{d \mid n \\ p^2 \nmid d}} \frac{1}{\phi(d)} \\ &amp; = &amp; 1 + \frac{1}{\phi(p_1)} + \dots + \frac{1}{\phi(p_k)} + \frac{1}{\phi(p_1 p_2)} + \dots + \frac{1}{\phi(p_{k-1}p_k)} \\ &amp; + &amp; \dots + \frac{1}{\phi(p_1 \cdots p_k)} \\ &amp; = &amp; 1 + \frac{1}{p_1 - 1} + \dots + \frac{1}{p_k - 1} + \frac{1}{(p_1 - 1)(p_2 - 1)} + \dots + \frac{1}{(p_{k-1}-1)(p_k-1)} \\ &amp; + &amp; \dots + \frac{1}{(p_1 - 1) \cdots (p_k - 1)} \end{eqnarray*}  I am unsure of how to proceed from this point however. Any help would be much appreciated. This is Exercise 3.1.A. in      Suppose that $\pi: X\rightarrow Y$ is a continuous map of differentiable manifolds. Show that $\pi$ is differentiable if differentialble functions pull back to differentiable functions, i.e., if pullback by $\pi$ gives mpa $\mathcal{O}_Y\rightarrow \pi_*\mathcal{O}_X$.   Let $f: V\subseteq Y\rightarrow \mathbb{R}$ be a differentiable function on an open subset of $Y$. Let $(U,\phi)$ be a chart of $X$, $(V,\psi)$ be a chart of $Y$. Then $f\circ\pi(\phi^{-1})$ is differentiable and $f\circ\psi^{-1}$ is differentiable. We need to show that $\psi\circ\pi\circ\phi^{-1}$ is differentiable. I don't know how to prove this.   Can we say that since $(U,\psi\circ\pi)$ constructs a chart of $X$, by the compatibility, $\psi\circ\pi\circ\phi^{-1}$ is differentiable? This seems true but this does not use the fact that $f$ is differentiable.  Sorry I have no background of Differentiable Manifolds. Any help would be appreciated.  I also saw this post: , but I don't understand how $\gamma$ is smooth in the answer. $\gamma=\beta\circ\rho$, where $\rho$ is defined to be smooth, but $\beta$ is not. Since the final Black Hole (BH) had 3 solar masses less of mass than the original binary BH, it seems the 2 BHs lost mass, and with it event surface area, entropy, and information. If that came from inside the BHs it seems that it would be a contradiction of what a BH is --'nothing escapes its event horizon'. Some may say that came from the rotational energy of the pair, but the new BH now seems to have less than the two original ones summed. So, did some of that escape the horizons? I am trying to write a condition into a SQL WHERE clause that forces the column comparison to a variable to be compared in lowercase. However the addExpression function isn't accomplishing this (since that is putting the expression in the field selection, not the where clause.  Here is what I have tried:  $category = 'mobile wifi'; $query = db_select('taxonomy_term_data', 'ttd')     -&gt;fields('ttd', array('tid')); $query-&gt;innerJoin('taxonomy_vocabulary', 'tv', 'ttd.vid = tv.vid'); $query-&gt;addExpression("LOWER(ttd.name) = $category"); $result = $query-&gt;condition('machine_name', 'images_cat', '=')     -&gt;execute()     -&gt;fetchAssoc();   And this:  $category = 'mobile wifi'; $query = db_select('taxonomy_term_data', 'ttd')     -&gt;fields('ttd', array('tid')); $query-&gt;innerJoin('taxonomy_vocabulary', 'tv', 'ttd.vid = tv.vid'); $result = $query-&gt;condition('machine_name', 'images_cat', '=')     -&gt;condition('LOWER(ttd.name)', $category, '=')     -&gt;execute()     -&gt;fetchAssoc();   The second one becomes invalid and the first one causes the problem I mentioned above. Any thoughts or suggestions?  Thanks, Patrick Factor 2 in Heisenberg Uncertainty Principle: Which formula is correct? Some websites and textbooks refer to $$\Delta x \Delta p \geq \frac{\hbar}{2}$$ as the correct formula for the uncertainty principle whereas other sources use the formula $$\Delta x \Delta p \geq \hbar.$$ Question: Which one is correct and why?  The latter is used in the textbook "Physics II for Dummies" (German edition) for several examples and the author also derives that formula so I assume that this is not a typing error.  This is the mentioned derivation:     $\sin \theta = \frac{\lambda}{\Delta y}$      assuming $\theta$ is small:      $\tan \theta = \frac{\lambda}{\Delta y}$      de Broglie equation:      $\lambda = \frac{h}{p_x}$      $\Rightarrow \tan \theta \approx \frac{h}{p_x \cdot \Delta y}$      but also:      $\tan \theta = \frac{\Delta p_y}{p_x}$      equalize $\tan \theta$:      $\frac{h}{p_x \cdot \Delta y} \approx \frac{\Delta p_y}{p_x}$      $\Rightarrow \frac{h}{\Delta y} \approx \Delta p_y \Rightarrow \Delta p_y \Delta y \approx h$      $\Rightarrow \Delta p_y \Delta y \geq \frac{h}{2 \pi}$      $\Rightarrow \Delta p \Delta x \geq \frac{h}{2 \pi}$   So: Which one is correct and why? How to switch between tty and xorg session Browsing Quora, I saw the following  with contradicting answers.  For the :     The bits are represented by certain orientations of magnetic fields   which shouldn't have any effect on gravitational mass.   But,  contradicts that one:     Most importantly, higher information content correlates with a more   energetic configuration and this is true regardless of the particular   type of storage... Now, as per Einstein's most famous formula, energy   is equivalent to mass.   Which answer is correct? Module 'pdftexcmds' not found after update Yesterday I updated my distribution (tlmgr update --all) and now I cannot use TikZ with lualatex anymore.  Minimal working example:  \documentclass{article} \usepackage{tikz} \begin{document} a \end{document}   Compilation output:  &gt; lualatex a This is LuaTeX, Version 1.10.0 (TeX Live 2019)                                                                                                                                                                         restricted system commands enabled.                                                                                                                                                                                  (./a.tex                                                                                                                                                                                                              LaTeX2e &lt;2019-10-01&gt; patch level 3                                                                                                                                                                                     luaotfload | main : initialization completed in 0.098 seconds                                                                                                                                                         (/opt/texlive/2019/texmf-dist/tex/latex/base/article.cls                                                                                                                                                              Document Class: article 2019/10/25 v1.4k Standard LaTeX document class                                                                                                                                                (/opt/texlive/2019/texmf-dist/tex/latex/base/size10.clo))                                                                                                                                                             (/opt/texlive/2019/texmf-dist/tex/latex/pgf/frontendlayer/tikz.sty                                                                                                                                                    (/opt/texlive/2019/texmf-dist/tex/latex/pgf/basiclayer/pgf.sty                                                                                                                                                        (/opt/texlive/2019/texmf-dist/tex/latex/pgf/utilities/pgfrcs.sty              ...  (/opt/texlive/2019/texmf-dist/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex (/opt/texlive/2019/texmf-dist/tex/generic/pgf/libraries/pgflibraryplothandlers. code.tex) (/opt/texlive/2019/texmf-dist/tex/generic/pgf/modules/pgfmodulematrix.code.tex)  (/opt/texlive/2019/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikz librarytopaths.code.tex))) No file a.aux. ABD: EveryShipout initializing macros (/opt/texlive/2019/texmf-dist/tex/context/base/mkii/supp-pdf.mkii [Loading MPS to PDF converter (version 2006.09.02).] ) (/opt/texlive/2019/texmf-dist/tex/latex/epstopdf-pkg/epstopdf-base.sty[\direc tlua]:1: module 'pdftexcmds' not found:         no field package.preload['pdftexcmds']         [kpse lua searcher] file not found: 'pdftexcmds'         [kpse C searcher] file not found: 'pdftexcmds' stack traceback:         [C]: in function 'require'         [\directlua]:1: in main chunk. l.165       \directlua{require("pdftexcmds")}  ?    It seems that a Lua package is missing.  Is this a bug? Am I missing a package? I use Kali Linux and discovered the following "problem":  root@kali:/proc/self# ls -l cmdline -r--r--r-- l root root 0 May 27 13:43 cmdline root@kali:/proc/self# chmod 744 cmdline chmod: changing permissions of `cmdline': Operation not permitted   I am not allowed to change the permissions of that file... but I am root? Why is that? Are there ways to work around this? I allready tried some things like moving the file (what is obviously not possible), change the runlevel etc. How do I enable Remote Desktop connection on Xubuntu 11.10?