Proof that $3n(n^2+6)$ can't be an odd cube

Question: How can I prove that $3n(n^2+6)$ can't be an odd cube?
Comment: You mean an odd cube?
Answer: If $n$ is not a multiple of 3, $3n(n^2+6)$ is a multiple of 3 but not a multiple of 9, so it cannot be a cube. So let $n = 3m$, and we want to show $9m(9m^2+6) = 27(m(3m^2+2))$ cannot be an odd cube, or equivalently, that $m(3m^2+2)$ cannot be an odd cube.
Now, if it is an odd cube, $m$ must be odd, and thus $\gcd(m,3m^2+2) = 1.$ Therefore, both $m$ and $3m^2+2$ are cubes; let $m = k^3.$ Now, $3m^2+2 = 3k^6+2$ is a cube. But $3k^6+2$ is either 5 or 2 mod 7, while cubes are 1,0, or -1 mod 7. This can be calculated explicitly, or you can note that Fermat's little theorem tells us that $k^6$ is 1 mod 7 if $k$ is not a multiple of 7.
Comment: I got everything except the cubes are 1,0 or -1 mod 7
Comment: By Fermat's little theorem, either $x \equiv 0 \pmod{7}$ or $x^6 \equiv 1 \pmod{7}$. In the second case, we can factor that as $(x^3-1)(x^3+1) \equiv 0 \pmod{7}$, so if $x$ is not a multiple of 7, $x^3$ is 1 or -1 mod 7.
Answer: It is worth emphasis that the idea in only's answer works much more generally. Namely
Theorem $\ $ If $\rm\:a,b,j,k,m\:$ are naturals with $\rm\:(m,b) = 1,\:$ and $\rm\:jk+1 = p\:$ is prime then
$\rm\qquad\qquad\quad m\,(a\,m^{\,j} + b)\:$ is a $\rm\:k$-th power of a natural
$\rm\qquad\qquad\!\Rightarrow\ a+b\,\ \ or\,\ \ b\ $ is a $\rm\:k$-th power $\rm(mod\ p)$
Proof $\rm\,\ (m,\,a\,m^{\,j}+b) = (m,b) = 1,\:$ thus $\rm\:m\:$ and $\rm\:a\,m^{\,j}+b\:$ are coprime factors of a $\rm\:k$-th power hence, by unique factorization, they are themselves $\rm\:k$-th powers, say $\rm\:m = c^k,\:$ and $\rm\:d^k\! = a\,m^{\,j} + b = a\, c^{\,j\,k}\!+ b = a\, c^{\,p-1}\!+b\equiv a+b\ \ or\ \ b\pmod p\:$ by little Fermat. $\ \ $ QED
Remark $\ $ This consequence of unique factorization often proves very  useful in  number theory. Essentially this was exploited by Fermat in his method of infinite descent. Indeed, Weil wrote

Infinite descent a la Fermat depends ordinarily upon no
  more than the following simple observation: if the product
  $ab$ of two ordinary integers (resp. two integers in an algebraic
  number-field) is equal to an $n$-th power, and if the gcd
  of $a$ and $b$ can take its values only in a given finite set of
  integers (resp. of ideals), then both $a$ and $b$ are $n$-th powers,
  up to factors which can take their values only in some assignable finite set.
  For ordinary integers this is obvious; it
  is so for algebraic number-fields provided one takes for
  granted the finiteness of the number of ideal-classes and
  Dirichlet's theorem about units.


TWRP recovery installed but not opening

Question: I have Vivo y15s , I rooted my phone with fastboot (oem unlock)
I installed TWRP recovery.img using fastboot
But
My phone is not starting and TWRP recovery mode is not opening.
Only Fast Boot mode is working..
Comment: did you installed latest twrp for your device?
Answer: My suspicion is that you might have flashed the wrong TWRP image. TWRP images are specific per device. Look for your device here:
https://twrp.me/Devices/
If you find the correct one, then reflash stock OS, then oem unlock, then flash new recovery.

TWRP recovery installed but not opening


How to use a statistical test to compare samples before and after an event?

Question: I am doing a project for share repurchase in the US. I am trying to estimate the operating performance before and after the repurchase announcement. And I am trying to adjust the performance to the industry level. The paper saying the results was estimated by the two tailed Wilcoxon test. Regarding this test, could I just test the unadjusted performance as a whole and then the adjusted performance as a whole? or do I have to put them as two different samples to compare?
And how to use Stata to obtain such results? Do I have to find a code for that?
Comment: You need to change the title and edit the question. You seem to be interested in application of stat tests, but your title suggest a larger out-of-scope topic. You should focus the title and the text on the statistics test of interest. Another reason to be focused is that share repurchase study must take into account certain issues that are well known in corporate finance field. For instance, operating performance clearly impacts share repurchase decisions, so you got endogeneity problem to deal with.
Comment: It might help if you explain your data a bit. Do you have performance of firms before and after repurchase announcements? What does "adjust" mean?
Answer: In Stata you can use ranksum for that. As to the test, you can compare the performance before and after, which will give you two samples. You can report the results for both industry adjusted performance and unadjusted performance. But, adjusted performance makes more sense, since you are measuring the performance against your competitors.
Comment: It sounds like the OP has *matched* data, so it may be better to use the Wilcoxon matched-pairs `signrank` test, rather than a test that assumes independence over time.


How to calculate the overall harmonics of a system of tubes?

Question: Let's say there is a tube closed at one and and open from the other. The open end is connected to another tube (of smaller diameter) which is open from both ends. How can I calculate the overall harmonics of this system of tubes? I have already calculated theri individual harmonic frequency but can't find a way to find the overall one.
Can anyone help me regarding this?
Comment: The overall system is more complicated than just the "addition" of those two systems. The impedance at the end of the first tube is **not** infinite or zero (which is the case for closed and open tube ends respectively) which has to be put into the equation. This acts like a "silencer" used in HVAC tubes and exhaust pipes of cars and bikes. I suggest you take a look at some text (such as Fundamentals of Acoustics by Kinsler et al. - Chapter 10) on this topic (acoustical filters)
Answer: Summary:  There is not a simple way to obtain the fundamental frequency of the composite tube you are describing in any sort of accurate manner.  A more rigorous approach is necessary.

Longer Discussion:
As mentioned by @ZaellixA in the comments, this system is too complicated to give the simple solutions you may be used to.  I will derive the solution below, but please be aware that the results are probably not generalizable.
Consider two tubes of different lengths and cross-sectional areas joined together.  We will assume that the lengths are sufficiently long, the cross-sectional areas are sufficiently small, and the wavelengths are sufficiently large that we may treat the wave motion as one-dimensional (this is a standard assumption and if you think of these things as "tubes", it is almost certainly met).  The solution to the one-dimensional wave equation in each tube may then be written as
\begin{equation}
p_i = A_i\sin(k[x-l_i]),
\end{equation}
where $p_i$ is the acoustic pressure in the $i$th tube, $A_i$ is the amplitude, $x$ is the position in the tube, $k=\omega/c$ is the wavenumber (assuming the same fluid fills both tubes), $\omega$ is the angular frequency, $c$ is the wave speed, and $l_i$ is a phase factor for the $i$th tube.  Since we assume the tubes are open at the ends and we idealize the system to treat the open tubes as pressure release (zero acoustic pressure at the ends), we may then immediately identify $l_1$ as 0 (we will call this the left-end of the tube) and $l_2$ as $L_1+L_2$, the sum of the lengths of the two tubes.  At the intersection, $x=L_1$, we require the pressures to be equal (this prevents infinite acceleration of the fluid at interfaces), yielding the equation
\begin{equation}
  p_1(L_1) = A_1\sin(kL_1) = p_2(L_1) = A_2\sin(k[L_1-L_2-L_1]) = -A_2\sin(kL_2).
\end{equation}
We also require the volume velocity $U$ to be equal at the intersection.  The volume velocity may be written as
\begin{equation}
  U_i = \frac{-S_i}{-i\omega\rho}\frac{\partial p_i}{\partial x} = \frac{-iS_i}{Z}A_i\cos(k[x-l_i]),
\end{equation}
where $S_i$ is the cross-sectional area of the $i$th tube, $\rho$ is the mass density, and $Z=\rho c$ is the specific acoustic impedance.  Matching the volume velocities then yields the equation
\begin{equation}
S_1A_1\cos(kL_1) = S_2A_2\cos(kL_2).
\end{equation}
These two interface equations may be written in matrix form as
\begin{equation}
  \left[\begin{matrix}
    \sin(kL_1) & \sin(kL_2) \\
    S_1\cos(kL_1) & -S_2\cos(kL_2)
  \end{matrix}\right]
  \left[\begin{matrix}
    A_1 \\ A_2
  \end{matrix}\right]
  =
  \left[\begin{matrix}
    0 \\ 0
  \end{matrix}\right].
\end{equation}
The only way that one can have $A_1,A_2\ne0$ is to have the determinant of the matrix on the left be equal to zero, which yields
\begin{align}
  S_2\sin(kL_1)\cos(kL_2) + S_1\cos(kL_1)\sin(kL_2) &= 0.
\end{align}
At this point, you will probably need to numerically solve for $k$.  The fundamental frequency is the frequency associated with the smallest solution to $k$ that is non-zero.
There are a few special cases that yield explicit analytical solutions.  The first I will consider is the trivial case of $S_1=S_2$ (same tube size), which yields
\begin{equation}
  S_1\sin(k[L_1+L_2]) = 0,
\end{equation}
which has the solution
\begin{equation}
  f_n = \frac{nc}{2(L_1+L_2)};
\end{equation}
for $n=1$ you have the fundamental, half-wavelength mode.  Next you have the case where $L_1=L_2$ (same length of tube), which yields
\begin{equation}
  (S_1+S_2)\sin(kL_1)\cos(kL_1) = 0,
\end{equation}
which has the solution
\begin{equation}
  f_n = \frac{nc}{4L_1}.
\end{equation}
This solution is also the simple half-wavelength fundamental due to the symmetry of the problem.  The final case is for small changes in the cross-sectional area.  Let $S_2=S_1+\Delta S$, where $\Delta S$ is a small (compared to $S_1$) change in the cross-sectional area.  Using a perturbation analysis (which I will forgo providing the details and just give the solution) then yields
\begin{equation}
  f_n \approx \frac{nc}{2(L_1+L_2)} - \frac{\Delta S}{S_1}\frac{(-1)^{n}c}{4\pi(L_1+L_2)}\sin\left(\frac{n\pi[L_1-L_2]}{L_1+L_2}\right).
\end{equation}
If $n(L_1-L_2)/(L_1+L_2)\ll1$, we may further approximate this equation with
\begin{equation}
  f_n \approx \frac{nc}{2(L_1+L_2)} - (-1)^{n}\frac{\Delta S}{S_1}\frac{nc(L_1-L_2)}{4(L_1+L_2)^2}.
\end{equation}
If $L_1=5$ m, $L_2=4$ m, $S_1=5$ cm$^2$, and $S_2=4$ cm$^2$, the numerical solution for $f_1$ is 18.83 Hz, while the first and second approximations yield 18.85 Hz and 18.84 Hz, respectively.  Note that ignoring the $\Delta S$ correction term leads to $f_1\approx19.06$ Hz.  Compare this with the case of $L_2=1$ m and $S_2=1$ cm$^2$ and tube 1 is left unchanged.  In this case, the numerical solution yields $f_1=21.95$ Hz, while the first and second approximations yield 25.43 Hz and 20.96 Hz, respectively.  Ignoring the corrections altogether yields 28.58 Hz.
Incidentally, the best you can do with only knowing the fundamental frequencies of the two tubes, say $f_1^1$ and $f_1^2$, is to take the harmonic sum:
\begin{equation}
  \left(\frac{1}{f_1^1} + \frac{1}{f_1^2}\right)^{-1} = \left(\frac{2L_1}{c} + \frac{2L_2}{c}\right)^{-1} = \frac{c}{2(L_1+L_2)},
\end{equation}
which is the $\Delta S=0$ approximation.


How to install Cambridge dictionary without wine?

Question: I'm a very new ubuntu user just turned from windows. I was wondering if I can get the Cambridge off-line dictionary without wine ?
Any other easy way to do ?
I know there are alternatives to it but Cambridge dict. is the one I'm familiar with in my job so I work on it faster
Comment: Can you explain what's the problem with using WINE?
Comment: It's actually misses up every time I try ( **complicated to install** )
Answer: Software not intended for usage on Linux will not work with Linux.
All methods will envolve some sort of usage of Windows where virtualization with VMWare or VirtualBox is the best thing to use. Even far superior to WINE.
The best option to get rid of this (to me ;) ) unhealthy dependency you have on Windows is to take a plunge and try to get the hang of one of our native versions. Or to focus on a version that is independent of operating system.
This is a bit much to go on: https://askubuntu.com/a/417132/15811 but it is worth the effort ;)
Comment: Well. thank you Sir for that information I wish I could rate your answer up but still hates off :)
Comment: The first sentence is not technically correct. An open source software which was never intended for usage on Linux could be re-compiled for Linux depending on how portable the code is (albeit that doesn't apply to the OP's requirement).


What is this symbol on the Ghost

Question: What is this symbol on the Ghost? It's located on the side (possibly only the left) of the front loading bay.
Comment: I suspect it's got to be a model or class designation. [This answer](http://scifi.stackexchange.com/q/81523/51379) shows that the text beneath it in the schematics says "Corellian Engineering Corporation," but we don't see anything like that on the *Millenium Falcon*, nor I think other CEC ships.
Comment: I've looked into it. There hasn't been much mention of it online but [this post](http://fanofthewars.com/first-star-wars-rebels-merchandise-arrives/) seems to imply that it's the Ghost's symbol (not a model). I tried [tweeting  at Adam Bray](https://twitter.com/authoradambray/status/794641881812574208) (the author of the rebels visual guide) who said that Dave Filoni has addressed it, but I have yet to find anything.
Answer: Probably a model symbol
According to the schematics from Star Wars Rebels: The Visual Guide:

The Aurabesh text above the logo seems to read:

(Note that the cresh is backwards in my version, for some reason).
Or, in English, line-by-line:

VCX-100
LIGHT
FREIGHTER

That is, of course, the ship from which the Ghost was originally modified.
This answer might suggest  that it is the logo of the Corellian Engineering Corporation, since that is the text that appears below the symbol in the image presented there. However, this logo does does not appear on the Millenium Falcon or other ships manufactured by the CEC, so this seems unlikely.
Comment: Brilliant, brilliant, brilliant! +1
Answer: It's the symbol of the Ghost
This symbol first appeared on a pin given to people who attended the Star Wars: Rebels panel at Star Wars Celebration Europe 2013

This Blog post and a post in this thread suggest that the people who got the pins knew that the symbol was that of the Ghost. Seeing as how the show didn't air until 2014, someone official probably told them what the symbol was.
Just to note: the pin included a hidden url that lead to an early version of the  picture in @Adamant 's post.
Furthermore, the symbol has 2 elements that lend itself to being uniquely the Ghost:

Two green triangular tear drop shapes, and then 2 smaller green lines below that resemble Hera's leku (head tails). Remember, the Ghost is Hera's ship.
The shape of the symbol is reminiscent of the ship. (Octagon)

All this together leads me to believe that this is the symbol of the Ghost itself (and not of the VCX-100)
I used ColonialChrome's ghost reference in the picture above.

What is this symbol on the Ghost


.NET 3.5 CF on Windows CE Platform Builder 6

Question: I downloaded Platform Builder for Windows CE 6.0 and upgraded to R2 and R3. I am not able to see .NET CF 3.5 in the "Applications and Service Development" pane of the OS Design Wizard. I am able to see 2.0 only.
Please help. All the information on the internet says that 3.5 should be available if R3 is installed.
Answer: What QFE's have you installed?  Just installing PB probably won't get you there.  Install the 2009 Cumulative Rollup and you will get it.


Should I purchase a Tamron 70-300 USD VC or Canon 70-300 USM IS?

Question: Good day all.
I was almost decided on Canon 70-300 USM IS (non L) but recently came to know about the Tamron version (SP AF 70-300 F/4-5.6 Di VC USD) of this one.
Neither of these makes you a better photographer and the price is neck to neck as well. The Tamron version features a non rotating front element and full time manual focusing. Its VC is also slightly better reviewed than Canon IS. Sharpness is almost same. Color quality wise Tamron wins by margin, though it has CS issues. Tamron one is heavier and build quality is better.
I've found a few links which you can take a look.
Canon 70-300mm USM IS:
Review:

http://www.the-digital-picture.com/reviews/canon-ef-70-300mm-f-4-5.6-is-usm-lens-review.aspx
http://www.fredmiranda.com/reviews/showproduct.php?product=294

Tamron 70-300mm USD VC:
Review and Sample Photos:

http://www.aputure.com/blog/2010/09/10/new-tamron-70-300mm-vc-sample-photos/
http://www.aputure.com/blog/2010/08/11/new-tamron-70-300mm-vc-lens-pre-review/

Side by Side Comparison:

http://photography-on-the.net/forum/showthread.php?t=958631

If you were given a 550D body and 500$ to buy a lens, which one of the above would you've bought?
And about type of photography I want to do, I was thinking birds mostly, but also anything good thats far enough! =)
Auto focus is also reviewed as faster in Tamron considering the time it takes to focus from MFD to Infinity. Focus is acurate and with the help of FTM, you can fine tune as well. (after all its their anniversary lens!). Its slightly sharper than Canon beyond 200mm but also slightly softer than Canon below 200.
I dont know much about sharpness of other lenses (I do not own any L series lens) or what you guys call sharp, but you can take a look at this full size bird photos and let me know if they are sharp or not.

300mm. f/5.6 1/400 ISO 400
300mm, f/9 1/125 ISO 400
300mm, f/10 1/400 ISO 1250

All photos taken using a Canon EOS 50D with the Tamron 70-300 attached, Aperture Priority mode, handheld with the VC system On. More pictures taken by Tamron 70-300 can be found in Here (flickr).
Comment: I think you've pretty done your homework and therefore basically answered your own question as much as it can be really answered. Beyond what you've said, the rest is just subjective opinion.
Comment: In India the price difference is almost double for canon so considering the almost same quality, I guess Tamron was the right choice for me :-)
Comment: I too am having a similar dilemma, tamron 70-300 VC vs Canon 70-200 F4 L (non-IS) in my budget. Its tough as the IS can be great at the longer focal lengths in lower light to help prevent camera shake at slower shutter speeds. I would mainly wish to use this as an outdoor lens but in the UK outdoors light is not always the best. How does the sharpness/contrast/colours compare?
Comment: I use a Tamron 70-300 lens with my Nikon D90 and I am very happy with it for the money I paid. The lens delivers sharp images, the stabilizer is what I would call good (you can actually see it work!), it is not bulky.
Comment: I had a similar choice and a similar situation needing to shoot surf and birds in flight. Without budget restrictions, I chose the Canon 100-400 L and I have no regrets. If you can get past the weight, the advantages are huge. First, it's professional. Everyone gets out of your way and they don't enter the shot with a big white lens. Secondly, I can shoot fast and in low light. The 100-400 stops everything, perfectly and captures action without words to describe. You remove equipment limitations with L glass.
Answer: I was recently faced with the same dilemma.  I needed a long lens for surf photography and animal shots (zoo with kids).  I have a 7d, and wanted a decent lens.
My budget was not an issue.  I was prepared to spend money for L glass.  I spent three weeks reading every review on the net; I read all the pixel peepers comments, other pro's, and buyer reviews.  After all my research it was evident that there was no perfect lens, and you can find negative reviews of even the highest critically praised L glass.
I ended up purchasing the tamron because of the full time manual focus (good for video), new usd, and effective image stabilization.  Additionally,  the reviews have been very strong.
The value is unbelievable, as I have now had time to use and enjoy lens.  At the price of 399, nothing else even comes close.
Comment: well if budget wasn't an issue (which unfortunately is, for me) you should've gotten an L series telephoto prime. One thing I've learned about buying photo gears, in the end, you always get what you pay for. These ISO crops surely will tell you the story.

http://www.the-digital-picture.com/Reviews/ISO-12233-Sample-Crops.aspx?Lens=757&Camera=453&Sample=0&FLI=4&API=1&LensComp=358&CameraComp=453&SampleComp=0&FLIComp=4&APIComp=0
Comment: @ShutterBug, to me, those comparisons maybe show a wash between the two lenses. And at the short (70mm) f/4 end, then it seems the Tamron comes out ahead.
Answer: What I'd probably do - and I don't suggest you follow it in this particular case - is get the Canon lens, given from your description that the lenses are a very close match. This is because I am (sadly) a lens snob... From reviews and other opinions I read through time I get the impression that the Canon (or Nikon for that matter) build quality tends to be better than the competition - or more correctly, it is more consistent. The chances of getting a good copy are greater with the Canon.
That's not to discourage you from trying both and if you get a good copy of the Tamron and feel that the build quality is better (as you mentioned in your question), then by all means get it.
As for the test images - compared to what I got used to see from photographers like Scott Bourne then no, they are far from being sharp. However, with the equipment that he uses you could buy a 50D+Tamron for each member of your family...
Comment: well you should not compare it with the sharpest lens in the line. I've limited my choice within this two only, so Tamron's sharpness should be compared to Canon 70-300mm. Please note that, Tamrons 70-300 is on the top end of their products and Canons 70-300 is somewhere just above the bottom end. So, the question comes, if I should go for a low-ish end product of Canon or high end of Tamron.
+1 for this line "with the equipment that he uses you could buy a 50D+Tamron for each member of your family" :D
Answer: If price is the same, and both have all the features you want, I'd go for the Canon. Two reasons:

Lenses from third party manufacturers are reverse engineered. That means they buy a canon lens and try to figure out how the focusing system works on their own, without any specifications from Canon. They most certainly test their products good enough so that it's not a problem for current cameras. But you can't really be 100% sure if a 3rd party lens will work properly with future bodies.
I use Canon's post processing software DPP. They only have lens correction data for Canon lenses there. That's a factor for me, could be for you aswell?
Comment: Reverse-engineered? Not really. Some of the lenses sold under the brand of Nikon are outsourced to Tamron, so that only the upper-budget lenses are still produced by Nikon itself.


Customizing Lookup field in SharePoint (WSS)

Question: I've been having trouble with programmatically changing the behavior of a field in SharePoint.  Suppose I have a list called PROJECTS with project names and etc. Then I create another list called PROGRESS.  Now, I have a "lookup" field on the NewForm.aspx to add a project from the PROJECT list with various notes/details to the PROGRESS list pertaining to the project picked from the dropdown (lookup field).
Here is the twist -- some projects are manually edited to indicate that they've been closed. For instance, we have "Project A", "Project B", and "Project C." So then we close the first. Now we should have "[closed] Project A", "Project B", "Project C".  My goal is to be able to parse out the projects with the titles starting with '[closed]'. That is all.
I'm very new to SharePoint and .Net.. In any case, I don't really know where to go from here:
<code>SPSite rootSite = new SPSite("http://localhost");
SPWeb web = rootSite.AllWebs["ProjectSite"];
SPList progress = web.Lists["PROGRESS"];
SPListItemCollection progressItems = progress.Items;

foreach (SPItem item in progressItems)
{
    //What do I do next? (Note: Played with SPField and SPLookup classes with no luck.)
}
</code>
Doing more research on the subject matter in the meantime -- thanks for your time.
Answer: If you want to change the value in the lookup field ,you need to change the value in refernced list,not to your list item.
For eg: if your lookup field is referencing "x" list,change the value with prefixing closed tag..


jQuery with quicksearch plugin performance problems

Question: I'm using the jQuery quicksearch plugin to search for items in a table of data. Very slick and works fantastically well when there are a reasonable number of rows.
(Reasonable number: Less than 200 rows with 10 columns which an average of 20 characters per cell.)
When I increase the number of rows performance drops off and it becomes unusable.
I have 2 questions:

Are there any tips/tricks to improve performance of this plugin or something that I may have misconfigured to make it perform poorly?
What are the alternative jQuery plugins that I might consider to replace this one given that I anticipate having many rows in the table?
Answer: If you have large number of rows, try approach listed on this page:
http://kobikobi.wordpress.com/2008/09/15/using-jquery-to-filter-table-rows/
Basically, you try to create an 'index' from the row data and while filtering, you only search this index and not the whole table.


Optimizing k-means algorithm with Newton-Raphson in R

Question: I am in the final year of my undergraduate program and I am doing my capstone project related to k-means clustering. I am trying to get good results on my dataset by optimizing the k-means algorithm using the Newton-Rapshon method in R. The Newton-Raphson algorithm is a root solving function which takes an equation as an argument and gives out the approximate root. I can't understand how to integrate that with the k-means algorithm for optimization purposes. Can anyone help me out with this, it would be much appreciated.
Comment: I am in agreement with Dougal's answer. N-R + k-means wouldn't be a great combination. If you're really settled on trying to look at k-means, I suggest reading through this post first http://stats.stackexchange.com/questions/133656/how-to-understand-the-drawbacks-of-k-means/133694#133694

It should give you appropriate context about the limitations of k-means, then maybe you can think of a project where you try to "optimize" k-means.
Answer: The k-means algorithm is a specific algorithm that doesn't really have a spot to plug in Newton-Raphson.
You could consider using Newton-Raphson to optimize the k-means problem: finding assignments of points to sets to minimize the total squared distance from their means. The objective function is$\DeclareMathOperator*{\argmin}{\mathrm{arg\,min}}$
$$
\argmin_{S_1, \dots, S_k} \sum_{i=1}^k \sum_{x \in S_i} \left\lVert x - \frac{1}{\lvert S_i \rvert} \sum_{x' \in S_i} x' \right\rVert^2
.$$
Unfortunately, since the sets $S_i$ are discrete objects, it's going to be hard to phrase the problem in a way that Newton-Raphson can work on, since it's for functions on continuous input spaces.
I'm not sure why you decided to use Newton-Raphson – it's not a very natural fit. If you're just trying to analyze some data, use an existing k-means package. But if you're really dedicated to doing this idea, you could try a relaxation to soft assignments, like in a Gaussian mixture model. The standard thing to do there would be expectation maximization, but Newton-Raphson would also work.


How to monitor the progress of dd command in linux?

Question: I am copying this .img file to my USB flash drive using dd command. How can I check its progress ?
Answer: If you write to a slow drive, for example a USB drive, you may want to know not only the progress of the command dd itself, but also the progress of actual writing to the target device.
You can modify the dd command line to make it flush the buffers regularly, for example after writing each mibibyte, and at the same time show the progress, for example
  sudo dd if=file.img bs=1M of=/dev/sdx status=progress oflag=dsync

Please check and double-check, that you specify the correct target device. Otherwise you might overwrite valuable data. dd does what you tell it to do without any questions.

Edit: You can find several other methods in my answer as well as other answers at this link.
Answer: The easiest way to do this is by using progress in the status flag, it will display the seconds elapsed and speed of copying on your terminal.
sudo dd if=img-file of=/dev/sdc1 status=progress
Answer: dd by default uses 512 bytes blocks to copy data which could result in slow data transfers and increased CPU usage. I often prefer to use cat or pv instead, e.g.
pv -petrab img-file > /dev/sdc1


ASA 55x - Will management interface shutdown if I remove the IP

Question: I was asked to change the IP address of the management interface on our firewalls but not issue "no ip address" because it will put the interface in shutdown mode which needs to issue no shut again and simply just apply the new ip address. I could not try this to see if it actually happens because it's production environment so here I am. Is that right if I issue no ip address on the management interface, it goes to shutdown mode?
Comment: What IP are you actually connecting to?  If you are using the mgmt0/0 address, then it will drop the session if you clear  or change that address.
Comment: @cpt_fink I get connected to the FW through admin context mgmt interface so dropping session is not an issue here.
Answer: Issuing the No Ip Address command does not put the interface in a shutdown state. However, I believe your coworker is telling you that your telnet session will be dropped if you issue this command which is correct. Because you would no longer have a management address, you would also no longer have a session using the address set.
If you have to issue the No Ip addresscommand, do so from a console connection to avoid losing your session.
Comment: +1 for the: If you have to issue the No Ip addresscommand, do so from a console connection to avoid losing your session. And agree as well - 'no ipaddress' just removes any IP configuration.
Comment: Changing the IP address by issuing a different `ip address x.x.x.x y.y.y.y` command will still drop your session if you are connected to that address.
Comment: Yes, correct. But that other IP address will be reachable for a new session. Whereas issuing the no ip address command will leave you unable to initiate a remote session the mgmt.
Comment: I have an outbound connection to the device, but we use heavy logging so I did not want to cause any disruption for that matter.
Comment: If you're changing the IP address, there will be disruption.


What was Kant's accomplishment?

Question: I have to admit, that I don't know this:
I know that before Kant there were two groups of people that saw the world differently and Kant somehow synthesized the two positions and afterwords Hegel had something to criticized about his work and this is known as the "linguistic turn".
As you can see I don't know anything about one of the most important discourses in the history of philosophy and I want to change that. Please help me understand how this is all interconnected.
Comment: Before Kant the philosophers were strongly divided between the [empiricist](https://en.wikipedia.org/wiki/Empiricism) and [rationalist](https://en.wikipedia.org/wiki/Rationalist) schools of thought. Kant bridged that gap and also refuted a great deal of skepticism, all within the *Critique of Pure Reason*. I'm not really in a position to speak on Hegel but google reveals lots... have you done any of your own research here?
Comment: I'm going to close this for now pending some revision. We want to encourage people to do their own basic research before they ask a question...
Comment: Which sources have you read already? Have you looked at some basic encyclopedia articles on Kant and Hegel?  Or read any introductory works on the history of philosophy?
Comment: From your question I gather that you are probably referring to Kant's version of idealism. However, I think Kant's contributions to moral philosophy had a wider impact outside of philosophy itself, so Kant shouldn't be reduced to his accomplishments regarding idealism.
Comment: this is extremely broad... perhaps you should try to focus a little from what you know? it is hard to make a good question on something you know nothing about, and "tell me all about it" is not a real question...
Comment: @Openmedi yes... and we are all learning here... but I advise you to do a little research before posting a question here.. did you at least read some wiki on the topic?... use the question to clear the information you did not understand, but you have to be more specific.
Comment: I've looked into some basic encyclopedia articles. Can you suggest an introduction to Kant, Hegel, the linguistic turn and the argument rationalists vs. empirists?
Comment: I see. I  thought someone could paint me a picture of what happened in very broad strokes and would point me to an introduction/further reading for the turning points I mentioned in my explaination of the question. Who were the important persons? What was discussed? What did Kant? It's okay for me to not get an answer, though. I'm still learning. Thanks.
Comment: @DanBrumleve let's see if someone is willing to respond to that...
Answer: There are 4 pillars of European philosophy: Plato, Aristotle, Kant and Hegel. As you can see there was 2000 year gap between second and third.
As for his accomplishments.. you could have simply opened a wiki:
http://en.wikipedia.org/wiki/Immanuel_Kant#Influence

Kant's influence on Western thought has been profound. Over and above
  his influence on specific thinkers, Kant changed the framework within
  which philosophical inquiry has been carried out. He accomplished a
  paradigm shift: very little philosophy is now carried out as an
  extension, or in the style of pre-Kantian philosophy. This shift
  consists in several closely related innovations that have become
  axiomatic, in philosophy itself and in the social sciences and
  humanities generally:

Kant's "Copernican revolution", that placed the role of the human subject or knower at the center of inquiry into our knowledge, such
  that it is impossible to philosophize about things as they are
  independently of us or of how they are for us;
His invention of critical philosophy, that is of the notion of being able to discover and systematically explore possible inherent
  limits to our ability to know through philosophical reasoning
His creation of the concept of "conditions of possibility", as in his notion of "the conditions of possible experience" – that is that
  things, knowledge, and forms of consciousness rest on prior conditions
  that make them possible, so that, to understand or to know them, we
  must first understand these conditions
His theory that objective experience is actively constituted or constructed by the functioning of the human mind
His notion of moral autonomy as central to humanity
His assertion of the principle that human beings should be treated as ends rather than as means
Comment: it would be nice to get something other than ctrl+c ctrl+v from wiki. Anyway, I consider the question itself problematic to begin with
Comment: Plato, Aristotle, Kant and Hegel as the "4 pillars of European philosophy" is an interesting selection... :P

What was Kant's accomplishment?


Am I a kafir if I get married to a non Muslim man?

Question: I am a Muslim woman and I plan to get married to a man who is agnostic. I will not force him to become a Muslim but if he does then that's good. If not, that's okay to me too. I love him and I don't want to force anything on him. My question is just if the marriage will be valid and will I still remain a Muslim?
Comment: Also see [Is "X" kufr ?](https://islam.stackexchange.com/questions/70271).
Answer: It is not permissible for a muslim woman to marry a non-muslim man. And the evidence for the prohibition of that by the following Qur'anic verses:
{1}
......وَلَا تُنكِحُوا۟ ٱلْمُشْرِكِينَ حَتَّىٰ يُؤ ۚ وَلَعَبْدٌۭ مُّؤْمِنٌ خَيْرٌۭ مِّن مُّ....
--> [… Nor marry (your girls) to unbelievers until they believe: A man slave who believes is better than an unbeliever, even though he allures you. Unbelievers do (but) beckon you to the Fire. But Allah beckons by His Grace to the Garden (of bliss) and forgiveness, and makes His Signs clear to mankind: That they may celebrate His praise] [2:221]
{2}
يَـٰٓأَيُّهَا ٱلَّذِينَ ءَامَنُوٓا۟ إِذَا جَآءَكُمُ ٱلْمُؤْمِنَـٰتُ مُهَـٰجِرَٰتٍۢ فَٱمْتَحِنُوهُنَّ ۖ...
--> [O ye who believe! When believing women come unto you as fugitives, examine them. Allah is best aware of their faith. Then, if ye know them for true believers, send them not back unto the disbelievers. They are not lawful for the disbelievers, nor are the disbelievers lawful for them] (Al-Mumtahinah 60:10).
Thus, it should be crystal clear that all Muslim jurists have unanimously agreed that this kind of marriage is forbidden.


How to cite Andy Warhol's Marilyn

Question: In one of the images I made to illustrate my PhD thesis, I included a "Marilyn" by Andy Warhol (image below), and I cannot find the museum/collection where the painting is exhibited. How should I cite it? Should I change the painting?
Comment: Is this social sciences or image processing?  If the latter, you should credit the original painting but the more important citation is of the digitization you used as your algorithm input.
Answer: The original of this piece (the Marilyn Diptych) is held in the Tate Gallery in London.
Your question is rather serendipitous as in two days you can buy your own Warhol original print from the screen at auction. The sale prints were recently exhibited at the Rockefeller Centre.
I would cite the art work in the following manner:

Warhol, Andy (1962), Marilyn Diptych, Silkscreen on Canvas, Tate Gallery, London.

References:
(1) Wikipedia (2016), Marilyn Diptych, [Online] https://en.wikipedia.org/wiki/Marilyn_Diptych, [Accessed 1 May 2016]
(2) Tate Gallery Illustrated Companion (2016), Marilyn Diptych 1962, [online] http://www.tate.org.uk/art/artworks/warhol-marilyn-diptych-t03093/text-illustrated-companion [Accessed 1 May 2016]
Comment: I'm not so sure. Warhol did several Marilyn silkscreens, and the one at the Tate seems to be a different color scheme. I know I also saw some originals at the Andy Warhol Museum in Pittsburgh.
Comment: Also, I wouldn't cite the original. Just as you need to cite facsimile reprints as such, this should be as well, unless they took a picture or scanned the original themself.

How to cite Andy Warhol's Marilyn


The formula equivalent of EBITDA for personal finance?

Question: I am considering the idea of trying to run my household finance more like a business and I am looking for formulas to gauge household financial health. I am running into issues with EBITDA for example, because the household quarterly financial effects of interest, depreciation and amortization don't really have much effect on monthly basis. Is there away to modify the formula to work for a household or a different one to check financial health (like Distributable Cash Flow?).
Answer: This should not be taken to be financial advice or guidance. My opinions are my own and do not represent professional advice or consultation on my part or that my employer. Now that we have that clear...
Your idea is a very good one.
I'm not sure about the benefits of a EBITDA for personal financial planning (or for financial analysis, for that matter, but we will that matter to the side). If you have a moderate (>$40,000) income, then taxes should be one the largest, if not the largest chunk of your paycheck out the door.
I personally track my cash flow on a day-by-day basis. That is to say, I break out the actual cash payments (paychecks) that I receive and break them apart into the 14 day increments (paycheck/14). I then take my expenses and do the same. If you organize your expenses into categories, you will receive some meaningful numbers about your daily liquidity (i.e: cash flow before taxes, after taxes, cash flow after house expenses, ect)
This serves two purposes. One, you will understand how much you can actually spend on a day-to-day basis. Second, once you realize your flexibility on a day-to-day basis, it is easy to plan and forecast your expenses.


How can I install a macOS VM Guest under VirtualBox on a Mac host?

Question: How can I install macOS Mojave, macOS High Sierra, and macOS Yosemite as VirtualBox VM Guests on Mac hardware?
Answer: Here's the configuration I installed:
Late 2015 Retina iMac (probably any new enough Mac will work)
----- VirtualBox 5.2.19 (no foreseeable reason future revs of VirtualBox won't work)
--------- macOS High Sierra 10.13.6 (probably works with several macOS release versions)

First download High Sierra installer from app store. (App store app puts it into /Applications and launches it.
The autorun installer can be quit so that it can be converted to an ISO)
You can convert the installer DMG to an ISO, using the script at the end of this answer. Some other approaches work too.  You may need or want to tweak the file names or the name of the OS/Installer app depending on what OS you're trying to install, etc...
After creating the ISO, create a Virtual Machine with the following configuration settings:

OS Type: macOS 10.13 High Sierra (64-bit)
Base Memory: 4096 GB RAM
Disk Size: 32 GB disk size
Video RAM: 128 MB
2 CPUs
disable floppy
disable serial port
disable audio

From command line create the following VirtualBox extra data values for the VM.
NOTE: These seemed to be critical for me to get the installer to boot and run.
These extra data settings I found to be omitted from most or all of the Mac installation instructions that I found online.  I borrowed these values from Windows VirtualBox install instructions, and modified the system product to match my iMac's (iMac17,1).  Without these extra data settings, the installer failed mid-boot, infinitely looping with some error pertaining to trying to reboot MACH).
    VBoxManage setextradata  {vm name or ID} "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac17,1"
    VBoxManage setextradata  {vm name or ID} "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
    VBoxManage setextradata  {vm name or ID} "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
    VBoxManage setextradata  {vm name or ID} "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
    VBoxManage setextradata  {vm name or ID} "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1

Point the VM to the ISO you created in step 2, and boot it.

When the recovery partition's GUI comes up (wherein you have the option to reinstall (also used for initial install)), first choose Disk Utility, and find and format (e.g. Erase), the virtual disk you created during the initial creation of the VirtualBox Guest VM.  In Disk Utility, the hard disk will show up as a disk on the left. Erase/format it as Mac OS Extended Journaled.
If you don't first explicitly format the virtual disk, the macOS installer will not find any disks to install macOS on. If you haven't formatted the disk, the installer will not err out but will just sit there expecting you to choose a disk, with none listed, and no option to continue with the installation.
After the first reboot during installation, I got stuck at the UEFI shell prompt, which is obtuse and confusing for the uninitiated (i.e. I didn't know what to do about it).
The reason I got dumped in the UEFI boot shell is that macOS wasn't installed yet in the boot partition, and the boot loader doesn't automatically boot into the recovery partition if the first partition isn't valid.
To manually boot/execute code in recovery partition in order to complete the installation, do the following (credit to VirtualBox forums for this information):

At UEFI shell prompt: Type exit
You'll be brought into an EFI text-mode GUI.
Select Boot Maintenance Manager and click.
Select Boot From File and click

You should see a list populated with two cryptic looking entries (PCI bus paths)
The first is the PCI path to a boot partition that is not valid because you haven't installed macOS on it yet. After installing macOS the boot should find that partition and boot normally, without dumping you out at the UEFI shell.
The 2nd partition is the recovery partition, the one you need to boot from to do the macOS installation.

Click the 2nd entry, you should see (and then click): macOS Install Data
Then click: Locked Files
And finally click: boot.efi

At that point the installer boot will continue and you should get to the point where macOS can be installed.
Bash script to convert macOS installer app downloaded from app store to ISO

#!/bin/bash
installer="/Applications/Install macOS High Sierra.app"
hdiutil create -o /tmp/HighSierra.cdr -size 5500m -layout SPUD -fs HFS+J
hdiutil attach /tmp/HighSierra.cdr.dmg -noverify -mountpoint /Volumes/install_build
sudo "$installer"/Contents/Resources/createinstallmedia --volume /Volumes/install_build
mv /tmp/HighSierra.cdr.dmg ~/Downloads/InstallSystem.dmg
hdiutil detach /Volumes/Install\ macOS\ High\ Sierra
hdiutil convert ~/Downloads/InstallSystem.dmg -format UDTO -o ~/Downloads/HighSierra.iso

Answer: The linked create-bootable-installer script (https://samiyuru.com/blog/install-mac-on-vbox-on-mac) works well. It is important to make the script file executable with # sudo chmod 755 <filename> to work properly. You have to be an admin user to execute the script with sudo. After that I got a satisfying iso to install MacOS in VirtualBox 5.2 on an iMac with Mojave as host.


Intents and sharing my application

Question: I am having a lot of trouble getting my Sharing of my application to work.
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.exit: System.exit(0);
            break;

        case R.id.icontext: String url = "http://www.manaforged.com";
            String shareText = url + "\nCheck this gaming community out!";
            Intent sendIntent = new Intent(Intent.ACTION_SEND);
            sendIntent.setType("plain/text");
            sendIntent.putExtra(Intent.EXTRA_TEXT, shareText);
            startActivity(Intent.createChooser(sendIntent, "Share"));
            break;
    }
    return true;

I only get 2 options Gmail and some other random thing. I see screen shots of others using roughly the same code with a lot more options. I have facebook app ect installed on my phones. Did the API change and I am viewing old information? I am getting very frustrated with this. Any ideas?
Answer: change sendIntent.setType("plain/text") to sendIntent.setType("text/plain")
it will solve your problem..

Intents and sharing my application


What does it take to get the Selphy to print an edited JPG?

Question: We took a picture with a digital camera, and used GNU Image Manipulation Program (GIMP) to remove some stuff in the background, and tried to print it on our Canon Selphy CP1200.  The print failed, and the manual says "images may not be displayed or printed correctly if they have been edited on a computer".  What does it take to get the Selphy to print an edited JPG?
Answer: Had the same problem... Edited pictures were not recognised by the Canon Selphy CP1200. Here's what worked for me. When using GIMP, proceed to export the picture as a jpg. After clicking on the "EXPORT" button, another menu pops up. Hit the "+" on the "ADVANCED OPTIONS" to bring up more menu options. I removed the check marks from the "optimize" and "progressive" options, removed any comments in the comment section and changed the "DCT Method" from Integar to Floating-Point. Then pressed the "export" button. Pic then worked with the cp1200. Don't know which of these options or combination of these options causes the pics to work, but takes half a sec to do 'em all instead of mucking around to find out which options solved the problem.
Answer: You might try Export (in Gimp) with unchecked "Save EXIF data" and "Save XMP data" Advanced options (see here).
Then copy the original EXIF info from the untouched camera JPEG onto the exported image using ExifTool:
exiftool -TagsFromFile srcimage.jpg "-all:all>all:all" targetimage.jpg

srcimage.jpg is the original camera JPEG
targetimage.jpg is the Gimp exported JPEG without EXIF and XMP metadata
Notes:
I don't have such a printer so can't confirm that it will work.
Exiftool copy metadata example copied from here.


Transfer (export/import) url aliases and menu links automatically

Question: I want to transfer/synchronize url aliases and menu links from one site to another. Is there any way (drupal module, drush command, script) to do it automatically? The module menu_import looked promising but it does not take care of aliases.
Answer: A good idea for solving this issue (at least until a more definite solution is implemented, with uuid etc.) is described in this article:
http://margotskapacs.com/2014/04/solving-menu-import-issue-when-featuring-sample-data-in-drupal/
This is a related issue: data export import module how to keep alias drupal


When you do dehydrohalogenation of 1° alkyl halides, do you use a strong base or sterically hindered base?

Question: I know when do you dehydrohalogenation of 2° alkyl halides, you can do either a strong base like KOCH2CH3 to get the most substituted product or a sterically hindered base like t-butoxide to get the less substitued product. However, I do not understand whether you would use the strong base or sterically hindered base for 1° alkyl halide because there are not two options here.
Answer: It's misleading to state your choice as between a strong base and a sterically hindered base, as t-butoxide is in fact even stronger than ethoxide. Rather, you choose between two strong bases, one sterically hindered and one not (or less so).
To answer your question: yes, there is only a single possible product for the elimination reaction (hydride/alkyl shift isn't generally an issue as primary carbocations aren't formed in the first place). However, all bases are potentially also nucleophiles, and can also engage in substitution, in this case giving an ether instead of the desired alkene. If you want to minimize this reaction it would pay to use the more hindered base, as substitution is more sterically demanding than elimination and would be slowed down more by bulky substituents on the nucleophile/base.
Answer: Simply put, by Saytzeff / Zaitsev rule, the favoured product in dehydrohalogenation reactions is the alkene with the greatest amount of alkyl groups connected to the doubly bound carbon atoms.
However in this case the base does not matter actually as both Saytzeff and Hoffmann alkenes will look same (except in the case carbocation's hydride shift / methyl shift takes place).
So you can use whatever base fits your budget!
Update: It seems that using a bulkier base will reduce the probability of getting the product of a nucleophilic displacement. It will then want to follow substitution and act as a nucleophile rather than as a base. Thus if you want ONLY elimination to take place the bulkier base is better as it offers higher steric hindrance. [inputs from comments]
Also you will have to note that even conditions make a difference in the products.
SOURCE: Haloalkanes, NCERT
Comment: Use of a sterically hindered base reduces the possibility of getting the product of nucleophilic displacement


What is it in the composition of natural fabrics that cause them to retain smoke odors versus synthetics?

Question: Just an observation I notice when around smoker friends or when I visit Las Vegas - polyester clothing doesn't seem to stay smelling of smoke for the rest of the day like my cotton shirts do (or also my hair for that matter).
Comment: You would probably need to [edit] and reframe this question as something practical, like how to select odor resistant textiles.
Answer: Adsorption is a very complicated phenomenon which involves so many interactions. Smoke has thousands of chemicals too, therefore one cannot pin-point a single cause. It is just like the concept of stains. Some stains on cotton never come off easily, which means that molecular interaction is very strong between the dye in the stain and cotton fiber. As a rough estimate, the -OH groups on cellulose may be providing the hydrogen bonding sites to nitrogen containing aromatic (in a chemical sense) compounds, hence stick for a long time. I am drawing an crude analogy because silica which has plenty of silanols (Si-OH) groups bind amines too strongly.


What is the etymology of "flabbergasted"?

Question: Online Etymology dictionary suggests it's "likely an arbitrary formation from flabby or flapper and aghast". I'm wondering if anyone has any more insight.
Answer: Here's the OED's etymological note (lightly edited):

First mentioned in 1772 as a new piece of fashionable slang; possibly
  of dialectal origin; Moor 1823 records it as a Suffolk word, and
  Jamieson, Supplement 1825, has flabrigast, 'to gasconade' [to boast extravagantly], flabrigastit 'worn
  out with exertion', as used in Perthshire. The formation is unknown; it
  is plausibly conjectured that the word is an arbitrary invention
  suggested by flabby adj. or flap n. and aghast adj.
Comment: Thank you! And thank you also for "gasconade" - new vocab for Christmas, perfect.
Answer: Here's a little elaboration on the same from Quinion's WWW:

It turns up first in print in 1772, in an article on new words in the Annual Register. The writer couples two fashionable terms: "Now we are flabbergasted and bored from morning to night". (Bored — being wearied by something tedious — had appeared only a few years earlier.) Presumably some unsung genius had put together flabber and aghast to make one word.
The source of the first part is obscure. It might be linked to flabby, suggesting that somebody is so astonished that they shake like a jelly. It can't be connected with flapper, in the sense of a person who fusses or panics, as some have suggested, as that sense only emerged at the end of the nineteenth century. But flabbergasted could have been an existing dialect word, as one early nineteenth-century writer claimed to have found it in Suffolk dialect and another — in the form flabrigast — in Perthshire. Further than this, nobody can go with any certainty.

And here's the clip from the above-mentioned 1772 Annual Register:
Comment: thank you very much. I have already selected a good answer I'm afraid but would have loved to give this one the honor! Upvote all the same.
Comment: @Lunivore: No worries. Just adding bits here and there for the benefit of all.
Answer: Note that French translation of verb "flabbergast" is given in many reputable dictionaries as "estomaquer", meaning "hit in the stomach" (cf. gaster/gastros = stomach/estomac in ancient Greek), which gives credence to "flabber" coming from "flappen" = hit in Dutch. The suggestion that it comes from "flabby" + "aghast" is totally fanciful.
Answer: Just an idea:  I wonder if "flabbergast" has anything to do with OE frófregást (Old High German fluobargeist), a word meaning literally "consoler" or "comforter" and coined to translate the Greco-Latin paracletus which sometimes refers to the Holy Spirit in Vulgate translations of the New Testament.  It is easy to imagine the possibly playful coinage of a participial form "flabbergasted" that would originally have meant to be somehow overwhelmed or dumbstruck by the Holy Spirit, the modern usage having completely lost any specifically religious connotation.
Comment: It is difficult to see how "consoler" or "comforter" could take on the meaning of "completely astonished."
Answer: It's pretty obvious and supported by historical corpora that it is simple sound metathesis.
For example, it is well known that the term butterfly, which has the false folk-etymology of a fly that likes butter, comes from metathesis of the periphrastic descriptive 'flutter by' (the natural action of the insect).
In a similar manner, 'flabbergast' has the tenuous folk etymology mentioned already when in reality, it comes from the more salient but archaic 'glabberfast' combining a variant of 'glabrous', meaning 'smooth' to the point of speechlessness and 'fast' (for not having eaten), with the intention that you are so surprised it's like you're so hungry you're speechless.
Comment: Learn something every day.
Answer: I concur with the reference to the Holy Spirit.  gast, gust, ghast and ghost are surely pointing in the same windy direction as spirit or breath of life, which is also latent in inspire, respire, expire. We find "he gave up the ghost" in some versions of the Bible. We use ghost, ghostly and ghastly in the same context spiritual beings -- phantoms.  As for flabber, surely flutter is a possible cognate for the shudder or intake of breath we do when startled or taken aback (again referencing wind). I'd like to hear from someone with German and possibly Scandinavian language ability, where wind and spirit seem as closely connected as they are in English.
Answer: Surely this word is related to being dumb struck. The Dutch Flappen being struck, hit or physical blow and the aghast part being without breath. Surely a gasp - a sharp intake of breath confirms this as does the word Slap.
Comment: Hi @RobertNash, welcome to ELU!  This is an interesting observation; do you have any documented evidence for it, or is it just based on your own understanding of the words?
Answer: I read the above etymology with interest, but see no reference to the possible metamorphosis of "To Gasp", i.e. the sudden intake of breathe at an astonishing fact. This combined with the {as mentioned}  "To Flabby/ flabber" 'wobbly or jelly-like' instability. Things have Frequently passed from One consonant to another via mis-interpretation of manuscript writings. In this case the 'p' could be misconstrued as a 'T' and continued as such.
Comment: Welcome to EL&U! Thank you for your answer. It could be greatly improved by some references, since Stack Exchange is not a place for original research.
Answer: From the answers above, we have "flappen" – Dutch to hit - and gast - from the Dutch "geest" – ghost/spirit/soul.
We have the word's use in Perthshire and Suffolk - both of which had an historic trading links with the Low Countries.
It is not unreasonable to suspect that the meaning of flabbergast is to be struck/hit in the soul. This seems to be a fair definition.


What is the difference between Acceptance Test-Driven Planning and Acceptance Test-Driven Development?

Question: What is the difference between Acceptance Test--Driven Planning and Acceptance Test--Driven Development? Are they the same?
Answer: Acceptance Test-Driven Planning is an extension of XP Planning.  It involves the following steps:

Getting our story straight
Show and tell
Retrospective
(optional) Technical Retrospective
Iteration Planning Workshop
(optional) Big, up-front thinking
Cutting the iteration.

This planning process is supposed to take up about 10% of the time, the development effort 90%.
Acceptance Test-Driven Development is an extension of Test-Driven Development.  Note that in the diagram below, traditional Test-Driven Development is referred to as Unit Test-Driven Development (UTDD)
Comment: I treat unit test to acceptance test as merely a matter of scale, but +1 for the cool diagram!
Comment: Why is Test and Driven are usually separated by using two dashes rather one? Shouldn't it be "Acceptance-Test-Driven Planning"?
Comment: +1 for picture (although not drawn by hand)
Answer: Answering my own question (based on some research):
In "The RSpec Book" David Chelimsky et. al. says that Acceptance Test--Driven Planning is one of three core practices of Behavior Driven Development (BDD). They describe Acceptance Test--Driven Planning (ATDP) as an extension of Acceptance Test--Driven Development (ATDD) and say that in ATDP acceptance tests are agreed on during or before an interation planing meeting. This helps the development team to better understand the requirements and estimate the work required for an implementation. In contrast, the general practice of ATDD simply means collaborating with customers on acceptance tests before developers write code and doesn't specify whether tests should be written before or after an iteration planning meeting.
In the paper "Acceptance Test Driven Planning" (published in the book "Extreme Programming and Agile Methods") Richard Watt and David Leigh-Fellows emphasize the importance of "Getting Our Stories Straight" as a key phase of the development process. They describe marathon planning sessions where the full development team sought to clarify requirements from the customer before deciding on a list of implementation tasks and estimating time required. To improve the process, they assigned a developer and QA engineer to work with a customer to write acceptance tests before the full team met for a planning session. Creating acceptance tests at this early stage encourages the customer to express the requirements clearly; it gives the developers a better understanding of the requirements and helps them to know when their work is done; and makes it easier to break down tasks and estimate work effort.
ATDP means the development team considers acceptance tests as well as user stories before implementation tasks are identified and assigned. In practice, ATDP means acceptance tests become the focal point of of all planning and development activities.


How do I show that the eigenstates of a Hamiltonian can be made orthonormal?

Question: I've been tearing my hair out over this all evening. It should be simple but I must be missing something somewhere. Can someone show me how to prove that the eigenstates of a Hamiltonian can be made orthonormal, please?
Comment: Hint: use the fact that the Hamiltonian is Hermitian, and consider the inner product $\langle f | Hg \rangle$.
Comment: To use @BrianBi 's hint you must also assume that the eigenvalues corresponding to the eigenstates are different. If the eigenvalues are the same, then you can arrange for them to be orthogonal by Gramm-Schmidt.
Comment: Related: http://physics.stackexchange.com/q/16678/2451 , http://physics.stackexchange.com/q/39602/2451 , http://physics.stackexchange.com/q/54154/2451 and links therein.
Comment: With regards your answer in that second link, Qmechanic, I don't see the problem with non-orthogonal eigenspaces, providing we modify our Born rule to 'the probability of collapse into the state $\vec{e}_1$ is the squared $\vec{e}_1$  _component_ of the vector $\psi$ in the basis $\vec{e}_i$'. For an orthonormal basis, we can get this component by taking the inner product with $\vec{e}_1$ (recovering the Born rule), but in an arbitrary basis we can still extract a component, we just need the reciprocal basis vector. Projections still have meaning in non-orthonormal bases.
Answer:
We first prove orthogonality of non-degenerate eigenvectors of the
Hamiltonian. Consider the braket and act with the Hamiltonian in
both directions,
$ \left\langle\alpha | H |\beta\right\rangle =
    E_\alpha\left\langle\alpha  |\beta\right\rangle = E
    _\beta\left\langle\alpha  |\beta\right\rangle $
If the states are not orthogonal ($\left\langle\alpha
    |\beta\right\rangle \neq 0 $) then we would get a contradiction
since we assume the states are non-degenerate ($E_\alpha\neq E_\beta
    $). So we must have
$\left\langle\alpha  |\beta\right\rangle = 0 $
for distinct states.
Now we need to prove that the braket of two eigenstates is equal to
$1$ up to a phase. Consider the braket:
$ \left\langle\alpha  |\alpha\right\rangle = \sum_n
    \left\langle\alpha  |n\right\rangle \left\langle n
    |\alpha\right\rangle = \left\langle\alpha  |\alpha\right\rangle
    \left\langle\alpha  |\alpha\right\rangle $
where we have inserted a sum over the states of the Hamiltonian and
then used the orthogonality relation that we proved above. Now we
can divide both sides by $\left\langle\alpha  |\alpha\right\rangle $
to get
$\left\langle\alpha  |\alpha\right\rangle = 1 $
Thus for we have only considered non-degenerate eigenvectors.
Degenerate eigenvectors can't be distinguished and they don't need
to be orthogonal to each other. However, for any set of linearly
independent vectors (all wavefunctions of a Hamiltonian are linearly
independent) there exists linear combinations of them that are orthogonal which can be found through the Gram–Schmidt procedure. Thus one can choose the vectors to be linearly independent.
Comment: +1 You probably need to add that if the eigenvalues are equal, then you can *arrange* a finite set of degenerate eigenvectors to be orthogonal by the Gramm-Schmidt process.


Delete older logs within a log file

Question: I have multiple log file appended every day since 2 years, want to cleanup the logs older than 90days in each log file. Can i include dates for the past few year? Like 90..1000 to delete files older than 3 months to past few years?
Comment: What is the data format? I have logs with `2023-04-09T04:02:02.876067-04:00`, `2023-04-09T08:13:45Z`, `[Oct 23 09:22:37.912]`, `[09/Apr/2023:09:50:53 -0400]`, and `[Sun Apr 09 04:02:26.077019 2023]` and that is with checking only a few files. In looking closer, your question is unclear. Do you have a single log file that is appended to or do you have a directory with multiple files?
Comment: `logrotate` is probably a better solution for what you are trying to accomplish.
Comment: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Answer: Managing log files by hand is complex. How is your log file used? Is it periodically updated or does a long running process (daemon) have it open constantly? If the latter, you'll have to do something (signal, or restart) with the daemon. Read the man page for the daemon.
When the logfile (big.log) is not open by any process (check via sudo lsof $PWD/big.log), use the date command (man date) with the "--date="today - 90 days"" and "+" formatting options to produce 90 days ago's in the same format as used in big.log.
# Warning: bash pseudo-code due to fuzziness of spec
# Warning: run any derived code through https://shellcheck.net
# **UNTESTED**
# You: Backup big.log, Just In Case

longago="$(date --date="today - 90 days" +"%...")"
# find the line number of the first occurence of the long ago date.
# only want the 1st match,
# only want the line number (up to the colon)
firstkeep="$(grep -n "$longago" big.log | head -n1 | cut -d: -f1)"
# left as an exercise: what if there are no logs on $longago?
# simple check?
[[ -z "$firstkeep" ]] && \
    error ...
# now, just keep from $firstkeep to the end
tail -n "$firstkeep" big.log
 >small.log

# now, check small.log (add tests)
wc -l big.log small.log

# when you're satisfied with small.log

# If the first mv works, do the second
mv big.log big.log.old && mv small.log big.log

# finally, when you're satisfied with the new, smaller big.log.
df.;rm big.log.old;df .

All of these commands have man pages. Read them as needed along with man bash.

Delete older logs within a log file


After migrating site to another server Magento 2 functionalities not working

Question: I migrated site to another server and now functionalists not working like  account creation , email registration , checkout etc . On last server everything is perfect. What is going on here ? Any idea ?
Comment: any console error or deploy static content try
Comment: @SaurabhRanjan  I ran all commads , upgrade , deploy , reindex etc . no error . all css and javascript is perfect just mangento functionalities are missing
Comment: is any php version change or is there any error log on server or even in Magento , plz check
Comment: how to check that changes @SaurabhRanjan ?
Answer: There may be any reason but most common issues may be :
1) PHP version issues
Check php version on old server as well as new server.

To check the php version

create a new file lets say phpinfo.php at root level of both server
In phpinfo.php
<?php

phpinfo();

and execute this file like below
2) Check errors in console.
3) Check log files of your website as well as of your server.

open error.log

inrsaurabh@maddyboy:/var/log/apache2$ sudo nano error.log

4) Start disabling external extension one by one and check if problem solved.
Comment: I got a clue .Exception #0 (Magento\Framework\Exception\NoSuchEntityException): Requested store is not found   . but I dont know how to access my online bitnami phpmyadmin to run a sql command
Comment: @ephemeral congrats , where you found the this log ?
Comment: @plz share a bit more info about your server sir.
Comment: No it was not in log . my general -> web   setting was not opening. Now few errors fixed due to this . but now still some errors happening . like login and sign up etc I think that are because of  I migrated some tables from magento 1  of customers


Basis of Polynomials over a Finite Field

Question: I'm trying to show that $1, x, x^2, .... x^k$ are a basis for the space of all polynomials with degree less than or k over a finite field $\mathbb{K}$ with p elements. I know that over the reals I would take $a_1 + a_2x + ... a_kx^k = 0$, let $x = 0$ to show $a_1=0$, take the derivative, and continue on in a similar way, but I don't see how to show independence over a finite field.
Answer: Over any field $F$, these polynomials form a basis for the mentioned vector space. They clearly span the vector space. To show they are independent you need to realize that a polynomial in the context of algebra is not a function. Two polynomials over a field $F$ are equal if, and only if, their coefficients are identical. This immediately establishes that the set of polynomials mentioned is an independent set.
The confusion arises since when the field is $\mathbb R$ (or more generally, for any infinite field) a polynomial induces a unique polynomial function. That means that functional methods can be used to proof independence (this is essentially the argument you supplied). But, when the field $F$ is finite, two different polynomials may give rise to the exact same polynomial function. In analysis we would consider these two polynomials as the same, but in algebra we don't. For example, the polynomials $X^n + X$, for $n\ge 1$, when considered as polynomials with coefficients in $\mathbb Z_2$, are all different, yet they all induce the same polynomial function (check which one).


mod squared of wave function probability density?

Question: Okay so this has been bugging me for a while now because everyone I talked to so far didn't know the answer. I'm an A level student but I got quite interested in quantum physics and so I decided to buy Griffiths introductory QM book and just try to understand the maths and how things fit together (I'm only on the first few pages, maybe 24 I think). So far the only thing I didn't understand was that why the mod squared of the wave function is the probability density. I mean I understand that it has to be real but then why don't we square root it afterwards? Is it something that just works or there is an actual reason behind the whole thing?
Answer: The main reason is that the probability density, constructed as you indicated, leads to a CONSERVED overall probability over all space.
In most QM books it is shown that the modulus square of the wave function, integrated over all space, does not depend on time. It can then be normalized to 1. The derivation of the conservation of the probability over all space being conserved is from the Schrodinger equation. I've not used Griffith but if it's a standard book it should have that derivation. The 'trick' is to find a current j in terms of the wave function and its complex conjugate such that the divergence of j plus the partial of the probability density with time is zero. By Gauss's theorem then the derivative wrt time of the integral of the density over space is zero.
You can then use the prob. density to get the average (I.e., expectation) values of dynamical valuable, or observables, like position and momentum, and get the Newton equations for those expectation values, and appropriate conserved quantities.
You can in more advanced books get the current density j and probability density from the Lagrangian for the quantum theory (Schrodinger or later relativistic quantum field theories) In a continuity of probability equation that conserves the probability integrated over the appropriate space.
There are also hysical reasons such as the similarity with the energy density in electromagnetism. It is also the the wave variables, E and B, squared, and then the energy is conserved when integrated over space.
The square root of the modulus square has been shown to not obey a conservation equation, so that was ruled out.
You can see a little of the math and essentially the same answer, stated with some differences, at  Born Interpretation of Wave Function
Comment: Ah yes, his book has that derivation also the expectation values of momentum and everything else and it makes sense but so is it the main reason that it is the mod squared because this way we can show that the probability doesn't depend on time hence the wave function stays normalised for any future time once you normalised it lets say at t=0 because otherwise the whole statistical interpretation would fall apart? Griffiths book talks about this but it didn't say anything about why it is the modulus squared. And so they discarded the square rooting idea because it didn't work?
Comment: The first question: the total probability of finding the particle at some x, or some p or some other variable, has to be 1. If it's so  it means that some prob. Current flows in or out of a certain box then the prob. Increases or decreases the same way. It means you have a consistent interpretation. This is used also for the density of a fluid for instance, to mathematically state matter conservation. All physics conservation laws are this way. The second question, right, it is not conserved. The square is, the modulus is not
Answer: In my opinion, the more natural function is that a state is a positive linear functional of norm 1 on the observable algebra. The value of this functional at an observable gives the expected value of the observable.
If we follow the intuition that observables can be represented as something like a matrix algebra, then all linear functionals should all expressible as linear combinations of basic functions of the form
$$ \psi_{v,w}(A) = v^* A w $$
where $v$ and $w$ are vectors. Think making $v$ and $w$ standard basis vectors, in which case $\psi_{v,w}$ is simply picking out a single matrix component of $A$.
If we restrict ourselves to Hermitian matrices real-valued functionals, then these can be expressed in terms of the quadratic functionals
$$ (v^* A w) + (v^* A w)^* = (v+w)^* A (v+w) - v^* A v - w^* A w $$
That is, we expect all real-valued linear functionals on Hermitian matrices to be linear combinations of functionals of the form $\phi_v(A) = v^* A v$.
If $A$ is a "proposition" — i.e. a Hermitian matrix with eigenvalues $1$ (corresponding to when an event happens) and $0$ (corresponding to when it doesn't happen), then after making a change of basis to diagonalize $A$, $v^* A v$ is simply the sum of $v_i^* v_i = |v_i|^2$ over all of the components of $v$ corresponding to the event happening.
So that's where the modulus squared comes from: it's drawn from the abstract case of converting a matrix into a scalar by multiplying it on both sides by a vector.
With the idea in hand, there are general constructions and theorems: e.g. the GNS construction.

The bit I find somewhat surprising is that you can get away with doing so much with a single Hilbert space and not having to appeal to the greater theory that describes what's actually going on with everything.


Can I use SkyDemon as a passenger on a commercial flight?

Question: Could I use SkyDemon as a passenger on a commercial flight in an A320 or similar? Would doing so break any laws or safety regulations, assuming I set the callsign correctly?
Answer: SkyDemon on its own does not transmit your callsign or type. The reason you enter your aircraft details is for your own benefit of being able to store weight and balance info, fuel burn etc so some calculations can be done for you in the app itself.
So long as you follow the instructions of the crew, with regard to usage of personal electronic devices in this case, you will not be breaking any regulation.
For what its worth, I almost always have SkyDemon running when I'm departing or arriving back to the UK on a commercial flight, because yes I'm a geek :D and I can usually spot places I'm familiar with using a bit of location awareness.
Comment: @cloud Safesky for sure
Comment: Hey Jamie, well it's interesting you say that, because when I landed at Popham recently, they said "make sure you change your Sky Echo call sign as it doesn't match your aircraft"... Now I don't have a sky echo, but I did have Safesky and skydemon running. I wonder which one they "saw" me on...


Is it possible to regenerate my seed phrase if I have my private key?

Question: The thing is I lost my seed phrase for MetaMask wallet. Luckily I had also backed up my private key. Is it possible to regenerate my "seed phrase" from my private key? It would be great if I could do it offline on my local computer because I don't want to share my private key on any online website.
Answer: I guess you can not generate seed phase from private key. But private key is everything for your account. So if had multiple accounts with some balance and you remember private keys for all addresses, then you are a lucky man.
If this is the case, you can simply create new account in metamask and get a new phrase. And then you can import your accounts to your metamask wallet using private Key.
Answer: yes. a private key gives you access to all your funds. But it cannot generate the seed phrase it came from. Also note, when you import you private key to a new Metamask wallet, The private key will still have nothing to do with your new Metamask seed words.
Answer: In this library that I share here in its version for dart.
Simply, use the mnemonicToEntropy() method. and a private keys can be reversed.
But it does not seem to me to be the original seed that generated the key. Nor is it clear to me that it is the private key of an individual address.
It would be interesting to find out what it is doing and if it is actually useful:
Mystery solved:
What can be reversed is the decimal entropy generated by the seed. But hexadecimal entropy cannot be reversed.

  String mnemonic = await bip39.entropyToMnemonic('00000000000000000000000000000000');
    // => 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'

    String entropy = bip39.mnemonicToEntropy(mnemonic)
    // => String '00000000000000000000000000000000'


Why is my hermit crab more active after passing away of his fellow crab?

Question: I started with two hermit crabs, and they would run through the normal hermit crab cycle of not being out much during the day and being more active at night. Recently, one of my hermit crabs died and, as unfortunate as that is, I have begun to see a lot more activity in my other crab. I'm not so concerned, I'm just wondering why this spike of activity has happened directly after my first crab's death. Is he lonely, or is he maybe looking for my other crab?
Answer: Hermit crabs are known to fight, so this might be a result of it feeling safer now once the other one is gone.
Lots of crustaceans have problems living close to each other, and one can see this in crabs-crayfish-lobsters; they will fight and hurt each other.
So your hermit crab does probably feel safer now and this is why it is more active now.
Comment: I always read that hermit crabs were social creatures and often needed another crab there to feel more comfortable. Should I just heep him and not get another crab now that I see him being more active?
Comment: you can take a look here http://www.hermit-crabs.com/ you will see hermit crabs can have different behaviour.


Conceptual Understanding behind a Limit

Question: Before I ask anything, let me first express my apologies for this question.
$$$$When starting with Calculus, my Maths teacher had never felt the need to explain the conceptual understanding behind Limits, or when we take them and why we take them. All that we needed to know (according to him) was:$$$$ "if a function $f(x)$ is not defined at $x=a$ and $f(x)$ seems to approach a certain value L as $x$ approaches $a$, then $L$ is the Limit of $f(x)$ $$$$ Immediately after taking this down, we had been asked to evaluate $\dfrac{1}{x}$ at $x=0$, and the answer we got (contrary to the standard 'Not Defined' answer we had learnt till now) was $\infty$. Without pausing to explain, he had then given us another problem: evaluate $\dfrac{\sin(x)}{x}$ at $x=0$. $$$$
Would somebody please explain what Limits truly are? Why do we need to take Limits? Wen would we use Limits? How can we actually evaluate a function at a point where it does not exist (for example: how is $\dfrac{1}{0}=\infty$?)? $$$$
I woul be truly grateful if somebody could please help clear these doubts I face. Many many thanks in advance.
Comment: There are different points of view... the "purists" says that $\infty$ is **not** a number, and thus saying that $lim=\infty$ is only a shorthand for "greatar than any number".
Comment: The concept of limit allows us to define what it means for a function to be continuous.  Intuitively it means that points that are close get taken to points that are close. Without the concept of limits, it's much harder to make sense of the concept of continuity.  That's just one use of limits though. Another use is to make sense of the area under a curve as a limit of better and better approximations. We can make rectangular shapes better and better approximate curved shapes so that in the limit the areas are equal. There are many other uses for limits, you really can't do math without them.
Comment: There are a lot of very good sources out there for these questions: "Why limits? How one limits? What limits? [This search](http://math.stackexchange.com/search?tab=votes&q=%5breference-request%5d%20calculus) probably reveals some of those source materials, but in any case know that there are (not real data) $\geq 100$ such questions on this site (and $50$ of them contain references to Spivak). Not to accuse you or anything, just so you know that you can probably find what you're looking for (...)
Comment: (...) But **nothing** substitutes the intuition you form naturally after dealing with limits daily. And if you do deal with limits daily, this will happen. I would say that your teacher is incorrect if he did suggest that limits are a way to evaluate functions where they are not defined.
Comment: If you're going to try and follow your professor's thinking, you should probably first consider the even simpler example: the behavior of $\frac{x}{x}$ at/near $0$. (for reference, the functions $\frac{x}{x}$ and $1$ are not equal, because the domains of the left and right hand sides are different: the left hand side is not defined at $0$ but the right hand side is)
Answer: Limits are about how functions behave close to but NOT at the chosen point. When you speak about $\lim_{x\to 0} f(x)$ the information you get is about what $f(x)$ does for small nonzero values of $x$. The limit doesn't care about what $f(0)$ or even whether $f(0)$ has a defined value.
It is definitely wrong to think of $\lim_{x\to 0}\frac1x=\infty$ as a claim that $\frac10=\infty$. On the contrary $\lim_{x\to 0} f(x)$ has nothing to do with what $f$ does at $0$ -- only what it does near $0$.
For example, consider $g(x)=\begin{cases} 2 & \text{when }x=0 \\ 1+x & \text{otherwise}. \end{cases}$
(Sketch a graph of this!). Then we have that $\lim_{x\to 0} g(x) = 1$, no matter that $g(0)$ is $2$ rather than $1$.
In the particular case that the function is continuous, the limit $\lim_{x\to a} f(x)$ will be the same as $f(a)$, but that is a special case that you cannot rely on as an explanation of what a limit is -- on the contrary the point that this identity isn't always true, which it why it can be used as a technical definition of "continuous".
But a limit MUST NOT be thought of as just a roundabout way to evaluate the function.

How about limits being infinity? That's because a function can behave in several different ways near-but-not-at $0$. Some of them are common enough that we give them names. Coming near a particular number is one named behavior; we then say that this number is the limit.
But if there's no number the function comes near -- such that in the $\frac1x$ case -- the function may still behave in a way that it is useful to recognize to have a way to speak about. For example $\frac1x$ has the property that when $x$ approaches $0$, the value of $\frac1x$ moves away from every number. This property is what we notate as $\lim_{x\to 0}f(x)=\infty$. It doesn't mean that $\infty$ is a number that $f(x)$ goes towards; $\infty$ is not a number! It's just suggestive notation that is chosen to look like that of $\lim_{x\to 0} g(x)=1$ to make it easier to remember, even though its technical definition is different.
Beware that $\lim_{x\to 0} f(x)=\infty$ does not merely mean that the limit isn't a number. There are functions where $\lim_{x\to 0}$ is neither a number nor $\infty$. For example, consider:
$$ h(x) = \frac{\sin(1/x)}x \quad \text{ defined on } \mathbb R\setminus\{0\} $$
It has the strange property that for every real number we can find a small nonzero $x$ -- which can be as small as we want! -- such that $h(x)$ is that number. This means that $h$ doesn't have any number as its limit for $x\to 0$ -- the informal definition you have seen may not make this clear, in which case you should pester your teacher to explain why not -- and it doesn't have $\infty$ as a limit either.
We would say that $\lim_{x\to 0} \frac{\sin(1/x)}x$ is not defined, which means neither more nor less than we haven't chosen a word or notation for this kind of behavior yet.
If we want to, we can perfectly well choose a notation for speaking about $h$-like behavior -- for example, we could decide to write
$$\lim_{x\to 0} \frac{\sin(1/x)}x ={\updownarrow}$$
Of course we'd need to give a proper definition of what exactly we mean by that, but once that is done $\lim_{x\to 0} \frac{\sin(1/x)}x$ would not be undefined any more.
Comment: One thing: if you use $\lim\limits_{x\to 0} \frac 1x=\infty$ you should point out that it only exists as a one-sided limit. To be more precise: $\lim\limits_{x\downarrow 0} \frac 1x=\infty$ and $\lim\limits_{x\uparrow 0}\frac 1x=-\infty$ whereas $\lim\limits_{x\to 0}\frac 1x$ doesn't exist.
Comment: @Hirshy: That depends on which definition one uses. For me (and apparently for the OP's teacher) $\lim_{x\to a} f(x)=\infty$ means $$\forall N : \exists\delta>0 : \forall x\in[a-\delta,a+\delta]\setminus\{a\}: |f(x)|> N $$ I would notate your stricter concept as $\lim_{x\to 0^+} \frac1x = +\infty$. (And I would say that both of $\lim_{x\to 0^+} \frac1x=\infty$ and $\lim_{x\to 0^+}\frac1x=+\infty$ are true, but the latter tells us more than the former).
Comment: true, I was too focused on my definition. In that context it would be helpful to know if the teacher has given a mathematical definition which really shows what he means.
Answer: Your question touches one of the basic principles of calculus/mathematical analysis. First I'll try to break down the meaning of a limit (of a sequence) and find a "real world" application for it.
Let's assume you are working in a biology lab with some bacterial culture and you are monitoring the number of living bacteria at any given time $n$. For easier observation purposes let's assume you are checking every hour and count the number of living bacteria, so we have $n=1,2,\dots$. Further we assume that our fairy godmother has provided us with a formula for the number living bacteria at any given time $n$. So if $a_n$ is the number of bacteria after $n$ hours, she told us that $$a_n=\frac{8n^2+n-1}{2n^2-n+5}.$$ We ignore that this would give us some fraction of bacteria and continue working with that. Now we could ask ourselves: will the number of living bacteria increase over time? And if so, will the number grow beyond any limits? While the first question is also important, the second question aims for a (very naive) understanding of the limit of a sequence. Of course this scenario is laughable, but it holds some scientific truth. When you are monitoring something (be it biology, physics, chemistry), you are often not interested at the number of living bacteria at a certain time $n$, but you ask for the long-term development. In our scenario, this long-term development of the number of living bacteria would be the limit of the sequence: $$\lim\limits_{n\to\infty} \frac{8n^2+n-1}{2n^2-n+5}=4.$$
A famous paradox from ancient times when the limit of a sequence wasn't known yet also points out the importance of the concept of a limit.
Starting with the understanding of the limit of a sequence, one can now progress to study (real-valued) functions $f:\mathbb R\rightarrow\mathbb R$. Although one can define the continuity of a function without using limits, in my oppinion the approach using the definition in terms of limits of sequences feels more natural to work with. Same goes for the limit of a function.
Now for your remaining questions:
First I'd like to point out, that your definition of a limit is at least questionable. For the definition of the limit $\lim\limits_{x\to a} f(x)$ there is no need for $f$ to be not defined at $x=a$. The expression "seems to approach" is far away from providing a correct, mathematical view on this subject (e.g. one could say that the function $f:\mathbb R^*\rightarrow \mathbb R,~x\mapsto \frac 1x$ seems to approach $L=-42$ as $x\rightarrow \infty$, as the distance between $\frac 1x$ and $-42$ gets smaller and smaller, but one wouldn't say that this is the limit), but for visualization purposes one can work with that
Second I'd like to say, that (if it happened like you wrote) that your teacher is wrong. The limit of $\frac 1x$ as $x\rightarrow 0$ is not $\infty$ nor is it $-\infty$ or $0$ or anything else, this limit just doesn't exist. Also to use this as a claim to define $\frac 10=\infty$ is not correct.
Now what the limit $\lim\limits_{x\to a} f(x)$ does, is to provide information what your function $f$ does or how it behaves, when you "get near" to $x=a$. Again, this has got nothing to do what $f(a)$ truly is or if it is even defined, all the limit tells you what is happening "close to $x=a$".
Let's use this for your other function, $f(x)=\frac{\sin(x)}{x}$. This function is obviously not defined for $x=0$, but the limit of this function still exists in a "natural way". One can show that if you get closer and closer to $0$, using symbols $x\rightarrow 0$, that $\frac{\sin(x)}{x}$ gets closer and closer to $1$. So in a neighbourhood of $x=0$ (meaning little left or little bit right of $0$ but very close to it), your function will give values very close to $1$ and thus "approach the limit $L=1$".
One closer look at $\lim\limits_{x\to 0} \frac 1x$: it is true, that if you look at positive numbers close to $x=0$, your function will give you very big numbers e.g. for $x=\frac{1}{10}$ you will get $f(x)=10$, for $x=\frac{1}{100}$ you will get $f(x)=100$ etc., so getting "closer" to $0$, your numbers will increase. One might think that $\lim\limits_{x\to 0} \frac 1x=\infty$ meaning that it will grow beyond any limits and leaving every other behind. But this only holds if you use positive numbers. If you take $x=-\frac{1}{10}$ you will get $f(x)=-10$, so your numbers will decrease if you get "closer" to $0$ from the negative direction. So why wouldn't you say $\lim\limits_{x\to 0} \frac 1x = -\infty$? This obviously is a contradiction, thus one says this limit does not exist.
Still it is possible to define $L=\infty$ as the limit of a function, but in general one wants to have the limit be not depending on the side of which you're approaching $a$.
Answer: Here, traveler, bolted to the castle wall: the enchanted Crossbow of Augustine. Let me show you how it works.
Notice that the crossbow is always aimed at the horizon. Turning this wheel here turns the bow back and forth—try it. Yes, the relationship between the position of the wheel and the direction of the bow is complicated. That's the price of magic, I guess. The horizon is marked off in degrees, from $-90$ to $90$, and the wheel's got numbers scratched on it too, from $0$ to $1$. Don't know who came up with that, but now we're stuck with it. A wizard once told me I should think of the positions of the wheel as the interval $X = (0, 1)$ and the points on the horizon as the interval $Y = (-90, 90)$, so the relationship between the position of the wheel and the direction of the bow is a function $f$ from $X$ to $Y$. I never understood that, though maybe you do.
Now, here's the tricky bit. If you put the wheel at exactly $\frac{1}{3}$, you can shoot an arrow at $0$ degrees. I've seen it—my buddy Robin can do it, pretty sure she's got some elf blood in her. But normal folks can't put the wheel at exactly anywhere, our hands shake too much. Look, I'll try it. The wheel's at $\frac{1}{3}$, or at least it looks like $\frac{1}{3}$ to me, but—zing—the arrow goes off at around $40$ degrees. That sounds like bad news. The $\frac{1}{3}$ position puts an arrow at $0$ degrees—$f(\frac{1}{3}) = 0$, as the wizard would say—but if you set the wheel even the tiniest bit off, the arrow goes somewhere else.
But there's good news! It turns out that if you set the wheel close enough to $\frac{1}{3}$, the arrow always goes off at around $40$ degrees—unless you put the wheel at exactly $\frac{1}{3}$, of course, but nobody's unlucky enough to do that by accident. Even better: the closer the wheel is to $\frac{1}{3}$, the closer the arrow goes to $40$ degrees. So, with practice, you can set the wheel near enough $\frac{1}{3}$ to hit any creature that wanders across the $40$-degree mark, no matter how skinny it is. The wizard got real excited about that when I showed him, started slapping his knees and laughing, "Oh, of course that trickster would have! Yes,
$$\lim_{x \to \frac{1}{3}} f(x) = 40,$$
that's brilliant!" I don't see why it's funny, but I'm grateful for it: it's what makes the crossbow usable, for ordinary folks like me.
Now, there's some places where the news is not so good. As you turn the wheel toward $\frac{3}{4}$, for example, the bow waggles back and forth between $-15$ and $-10$ degrees, and only sheer luck or magic can aim it any better than that. There's no point you can home in on by getting the wheel close enough to $\frac{3}{4}$. The wizard's eyes gleamed when he saw that. "Ah, looks like $f$ doesn't have a limit at $\frac{3}{4}$. A place where a function has no limit—that's where real magic can happen." I never understood that either, but I was reminded of it years later, during a terrible battle. A whole column of goblins was marching up that pass between $-15$ and $-10$ degrees, and poor Robin with her arm all mangled could barely turn the wheel, but she said "Just put it as close as you can to $\frac{3}{4}$, and I'll do the rest." So we did, and she mowed them all down without hardly touching the wheel. Yeah, sometimes I think this bow wasn't made for clumsy hands like ours.
Well, let's not dwell on that. I'll put the wheel somewhere more sensible. How about $\frac{1}{2}$, that's a fun one! Here, try setting the wheel at almost $\frac{1}{2}$, but just a hair off to the left. You can see the bow's at nearly $-90$ degrees. Now, tap the wheel over so it's still at almost $\frac{1}{2}$, but just a hair off to the right. Now the bow's at nearly $90$ degrees! As the wheel closes in on $\frac{1}{2}$, the bow closes in on $-90$ degrees if you come from the left, and $90$ degrees if you come from the right. With practice, you can hit any creature that steps across the $-90$-degree mark or the $90$-degree mark by setting the wheel close enough to $\frac{1}{2}$; you just have to be careful about which side of $\frac{1}{2}$ you're on. The wizard muttered something complicated about that, like, "Technically $f$ has no limit at $\frac{1}{2}$ either, but it's got the left and right limits
$$
\lim_{x \to \frac{1}{2}{}^-} f(x) = -90
\qquad\text{and}\qquad
\lim_{x \to \frac{1}{2}{}^+} f(x) = 90,
$$
so it's hardly any trouble for you."
It'll be dark soon; you'd better head inside. If you go to the library, you'll find some stuff the wizard left—pictures and scraps of writing he said our crossbow reminded him of, though it's hard to see how.
$\frac{1}{3}$ x | $\frac{3}{4}$ x x | $\frac{1}{2}$ x x x x
No, it's been lovely, but I'm staying out here. Someone's got to turn that wheel.
Comment: This is pretty well written, and highly underrated!
Comment: @MateenUlhaq, I'm glad you enjoyed it!

Conceptual Understanding behind a Limit