So I'm taking an online Java course and the task is as follows:  In this program we are going to practice using the Math class by computing some important values on the unit circle. Starting at 0 and going up by  PI/4 radians (or 45 degrees), print out information of the format below.      Radians: (cos, sin)     0.0: 1.0, 0.0     0.79: 0.7, 0.71     1.57: 0.0, 1.0     2.36: -0.71, 0.7     3.14: -1.0, 0.0     3.93: -0.7, -0.71     4.71: 0.0, -1.0     5.5: 0.71, -0.71   Hint: You’ll need to use the Math.sin, Math.cos methods  and the Math.PI constant!  You’ll also need to loop from 0 to 2*PI  Here is what I came up with:      public class UnitCircle extends ConsoleProgram     {         public void run()         {             System.out.println("Radians: (cos, sin)");             for(double count = 0; count &lt;= Math.PI * 2; count += Math.PI / 4)             {                 System.out.println(count + ": " + Math.cos(count) + ", " + Math.sin(count));             }         }     }   However when I run it, this is what I get:      Radians: (cos, sin)     0.0: 1.0, 0.0     0.7853981633974483: 0.7071067811865476, 0.7071067811865475     1.5707963267948966: 6.123233995736766E-17, 1.0     2.356194490192345: -0.7071067811865475, 0.7071067811865476     3.141592653589793: -1.0, 1.2246467991473532E-16     3.9269908169872414: -0.7071067811865477, -0.7071067811865475     4.71238898038469: -1.8369701987210297E-16, -1.0     5.497787143782138: 0.7071067811865474, -0.7071067811865477     6.283185307179586: 1.0, -2.4492935982947064E-16   What's up with that? Could it be that I need to limit the calculations to round to 2 decimal places? What else am I doing wrong? Any help would be greatly appreciated.
What I would like is a method to convert a double to a string which rounds using the half-up method - i.e. if the decimal to be rounded is 5, it always rounds up to the next number. This is the standard method of rounding most people expect in most situations.  I also would like only significant digits to be displayed - i.e. there should not be any trailing zeroes.  I know one method of doing this is to use the String.format method:  String.format("%.5g%n", 0.912385);   returns:  0.91239   which is great, however it always displays numbers with 5 decimal places even if they are not significant:   String.format("%.5g%n", 0.912300);   returns:  0.91230   Another method is to use the DecimalFormatter:  DecimalFormat df = new DecimalFormat("#.#####"); df.format(0.912385);   returns:  0.91238   However as you can see this uses half-even rounding. That is it will round down if the previous digit is even. What I'd like is this:  0.912385 -&gt; 0.91239 0.912300 -&gt; 0.9123   What is the best way to achieve this in Java?
What is the fate of the Asgardians at the start of Avengers: Infinity War? Thor: Ragnarok ends with the remaining people of Asgard aboard a refugee ship that meets Thanos' ship. Avengers: Infinity War opens with      Thanos and his minions having commandeered the ship and several bodies can be seen on the floor.   This begs the question, what happened to these characters:   Korg Miek Asguardian extra #3 Valkyrie Where's the BIOS on an Intel Mac? Does $x^2 - y^2 = 12345678$ (x,y are integers) have any solutions? This question appeared in KVPY online exam held on Nov 5. This equation is the equation of a hyperbola so any solution must be of the form $a\sec(k),a\tan(k)$. So no solutions. How to show that $f_{0}f_{1}+f_{1}f_{2}+...+f_{2n-1}f_{2n} = f^{2}_{2n}$ The following problem:  The Fibonacci number is denoted by  $f_{n}$, show that the following holds when $n$ is a positive integer:  $f_{0}f_{1}+f_{1}f_{2}+...+f_{2n-1}f_{2n} = f^{2}_{2n}$  My idea was to do an induction proof, which holds for $n$ = 1  $f_{0}f_{1} + f_{1}f_{2} = f^{2}_{2}$  So we assume it holds for $n$ and show for $n+1$  $f_{0}f_{1}+f_{1}f_{2}+...+f_{2n-1}f_{2n} + f_{2n}f_{2n+1} = f^{2}_{2n} + f_{2n}f_{2n+1}$  I fail to get  $f^{2}_{2n+1}$ out of the term  $f^{2}_{2n} + f_{2n}f_{2n+1}$  Is there a difference between "show that" and "prove that". So might be induction the wrong tool here?  Many thanks for your hints in advance :-) I created a interior scene and  i don't know how to bake a texture using cycles bake. I have a  repository which contains a number of subdirectories. Now I have found that one of the subdirectories is unrelated to the other and should be detached to a separate repository.  How can I do this while keeping the history of the files within the subdirectory?  I guess I could make a clone and remove the unwanted parts of each clone, but I suppose this would give me the complete tree when checking out an older revision etc. This might be acceptable, but I would prefer to be able to pretend that the two repositories doesn't have a shared history.  Just to make it clear, I have the following structure:  XYZ/     .git/     XY1/     ABC/     XY2/   But I would like this instead:  XYZ/     .git/     XY1/     XY2/ ABC/     .git/     ABC/ I've just upgraded my computer hardware(cpu + motherboard + graphic card + memory + hard disk), so that install a new OS is needed. I tried to download debian-6.0.6-amd64-netinst.iso with wget command but the speed is so slow that I could not bear. 4Kb/s ~ 17 Kb/s, slow like a running turtle, or even more slower if I use Chrome.  I've read the help information of wget, it seems like there are no options could make it more faster.  Is there anyway to make wget faster? Or is it possible to make it multi-threading download?  PS: my bandwidth is 4M. I use this command:  wget -c url  http://hammurabi.acc.umu.se/debian-cd/6.0.6/amd64/iso-cd/debian-6.0.6-amd64-netinst.iso I installed Windows 7 fresh and installed SP1. Now, when I try to check manually for Windows Updates it just hangs on the Checking for updates screen.    I tried running the tools in , but this did not fix the issue either:  No matter what I do it just hangs on the "Checking for updates..." screen and goes no further. I have got this problem on limits  $$ \lim_{x \rightarrow 0}\left(\frac{\sin(x)}{x}\right)^\frac{1}{x^2}$$ What I am doing here is that taking log and then applying L-Hospital's Rule $$y= \lim_{x \rightarrow 0}\left(\frac{\sin(x)}{x}\right)^\frac{1}{x^2} $$ then $$\ln(y)=\lim_{x \rightarrow 0} \frac{1}{x^2}\ln\left(\frac{\sin(x)}{x}\right)$$ now it becomes $\frac{0}{0}$ type , but problem is how to take derivative here? when differentiating $\ln\left(\frac{\sin(x)}{x}\right)$ it will become $\frac{x}{\sin(x)}$ then we'll have to differentiate one more time like we do in case of $f(f(x))$ ? $\sin(x)$ and $x$ will be separately differentiated or together ? show that a distance function is continuous Let $X$ be a metric space with metric $d$. Define $d: X \times X \to \mathbb{R}$, show that $d$ is continuous.  I would like to show that the function is continuous the topology way (since it is a course on topology).   Let $(a,b)$ be a basic open set in $\mathbb{R}$, then $d^{-1}(a,b) = \{(x,y): a&lt;d(x,y)&lt;b\}$. Define $A= \bigcup_{x \in X} B_{b} (x)$, where $B_b (x) = \{y \in X| d(x,y)&lt;b$}. Clearly $A$ is open. Now define $C = \{(x,y):d(x,y)&gt;a \}.$ Essentially I hope that $A \cap C$ is open. But I am stuck in showing that $C$ is open.  Any help please? :) How to iterate over arguments in a Bash script I have a complex command that I'd like to make a shell/bash script of.  I can write it in terms of $1 easily:  foo $1 args -o $1.ext   I want to be able to pass multiple input names to the script. What's the right way to do it?    And, of course, I want to handle filenames with spaces in them. e.force:navigateToURL: [Cannot read property 'setParams' of undefined] What is numeric promotion? How did Sauron remain in control of the Nazgûl? The One Ring gave Sauron control of the Nine, yet when it was taken from him he still possessed the power to control them (or, at least he regained it towards the end of the third age).  Why is this?   mentions that he drew the Nine to him, but not how. Buy a second seat in order to bring an extra bag? How can I write multiple lines in a subscript? Is there a way to force a line break inside a math mode text?  My example:  \[   \underbrace{....}_\text{Some long text that should be multiline} \]   Trying  \text{Some long text that\\ should be multiline}   Didn't do the trick. Find generator of multiplicative group of $\mathbb{F}_{27}$ I have a finite field $\mathbb{F}_{27}$. I need to find an element of order 13. I know that multiplicative group of this field is cyclic with order 26. So I want to find a generator $g$ of this cyclic group, then $g^2$ will have order 13. Also I know that all elements of this field can be represented by polynomials from $\mathbb{F}_3[t]$, where t is root of irreducible polynom $x^3-x-1$.  Probably we can find generator of $\mathbb{Z}_{26}$ and than build an isomorphism to $\mathbb{F}_{27}\setminus 0$.  Anyway I don't know were to start.  Thanks! I'm getting "jumpy" loadings in rollapply PCA in R. Can I fix it? I have 10 years of daily returns data for 28 different currencies. I wish to extract the first principal component, but rather than operate PCA on the whole 10 years, I want to rollapply a 2 year window, because the currencies' behaviours evolve and so I wish to reflect this. However I have a major problem, that is that both the princomp() and prcomp() functions will often jump from positive to negative loadings in adjacent PCA analyses (ie 1 day apart). Have a look at the loading chart for the EUR currency:    Clearly I can't use this because adjacent loadings will jump from positive to negative, so my series which uses them will be erroneous. Now take a look at the absolute value of the EUR currency loading:    The problem is of course that I still cannot use this because you can see from the top chart that the loading does go from negative to positive and back at times, a characteristic which I need to preserve.   Is there any way I can get around this problem? Can I force the eigenvector orientation to always be the same in adjacent PCAs?   By the way this problem also occurs with the FactoMineR PCA() function. The code for the rollapply is here:  rollapply(retmat, windowl, function(x) summary(princomp(x))$loadings[, 1], by.column = FALSE, align = "right") -&gt; princomproll Python is quite cool, but unfortunately, its debugger is not as good as perl -d.    One thing that I do very commonly when experimenting with code is to call a function from within the debugger, and step into that function, like so:  # NOTE THAT THIS PROGRAM EXITS IMMEDIATELY WITHOUT CALLING FOO() ~&gt; cat -n /tmp/show_perl.pl 1  #!/usr/local/bin/perl 2 3  sub foo { 4      print "hi\n"; 5      print "bye\n"; 6  } 7 8  exit 0;  ~&gt; perl -d /tmp/show_perl.pl  Loading DB routines from perl5db.pl version 1.28 Editor support available.  Enter h or `h h' for help, or `man perldebug' for more help.  main::(/tmp/show_perl.pl:8):    exit 0;  # MAGIC HAPPENS HERE -- I AM STEPPING INTO A FUNCTION THAT I AM CALLING INTERACTIVELY   DB&lt;1&gt; s foo()  main::((eval 6)[/usr/local/lib/perl5/5.8.6/perl5db.pl:628]:3): 3:      foo();     DB&lt;&lt;2&gt;&gt; s main::foo(/tmp/show_perl.pl:4):     print "hi\n";     DB&lt;&lt;2&gt;&gt; n hi main::foo(/tmp/show_perl.pl:5):     print "bye\n";     DB&lt;&lt;2&gt;&gt; n bye     DB&lt;2&gt; n Debugged program terminated.  Use q to quit or R to restart,   use O inhibit_exit to avoid stopping after program termination,   h q, h R or h O to get additional info.      DB&lt;2&gt; q   This is incredibly useful when trying to step through a function's handling of various different inputs to figure out why it fails.  However, it does not seem to work in either pdb or pydb (I'd show an equivalent python example to the one above but it results in a large exception stack dump).  So my question is twofold:   Am I missing something? Is there a python debugger that would indeed let me do this?   Obviously I could put the calls in the code myself, but I love working interactively, eg. not having to start from scratch when I want to try calling with a slightly different set of arguments. What formula would you use to add up a column based on results from two drop down menus?