Does on-sensor phase detection autofocus need adjustment for accuracy?

Question: Is autofocus adjustment actually no longer required with on-imaging-sensor autofocus that's phase-detection only i.e. not relying on contrast detection? If not, why? How does lens autofocus adjustment come into play?
Answer: Consider the evolution of AF systems over the past several decades:
With traditional DSLR cameras, fine tuning of PDAF autofocus based on a separate sensor is needed to overcome several different possible errors. Among those errors are:

Slightly different optical distances between the imaging sensor and the lens when compared to the optical distance between the PDAF sensor and the lens.
Lens positioning errors when the lens actually moves a slightly different distance than the camera instructed it to move. This could be as simple a thing as mechanical wear and tear in the lens' focusing mechanism or a slightly misadjusted electro-mechanical focus position sensor located in the lens.
Slight variation in the lens' registration distance (a/k/a flange focal distance or, in the cinema world, back focus distance). If the lens is slightly closer or further from the imaging sensor and the PDAF sensor than the design specification, then different adjustments may be needed for near and far focus because the lens was designed to be used at the specified registration distance and movements of the focusing mechanism will not be in the exact ratio of distances needed.

With most cameras that use focusing based on information from the imaging sensor, none of these things really matter since the final focusing is done using contrast detection, rather than phase detection, methods. The earliest CDAF systems had no PDAF capability so all focusing was done using CDAF. But this is also the case for cameras that have "hybrid" sensor-based PDAF combined with CDAF.

If the camera includes main imaging sensor based PDAF capability, the PDAF functionality is used to bring the lens to near the desired focus distance very quickly, and then CDAF is used to either confirm or fine-tune the focus position further.
There's obviously no difference in the length of the optical path from the lens to the sensor since it is the exact same sensor.
Adjustments to the lens position using contrast detection are also not susceptible to errors in the amount of movement instructed by the camera compared to the amount of movement actually made by the lens, because the camera just continues to move the lens until it finds the position that has the highest amount of contrast, rather than telling the lens how far to move and depending on the lens to precisely follow that instruction.
Any mechanical wear and tear, registration errors, or misalignment of focus position sensors are moot since the camera doesn't depend on them for the final focus position. Instead it measures the contrast in the image projected by the lens onto the sensor and moves the lens until contrast is maximized.

A simple analogy between focusing using a dedicated PDAF sensor and focusing using imaging sensor based CDAF (including hybrid PDAF+CDAF) would be to compare focusing the lens on an old Speed graphic camera to focusing using an old manual focus SLR.

The Speed Graphic provided no through the lens viewfinder. The photographer estimated (or measured using a measuring device external to the camera) the distance between the camera and subject. The photographer then adjusted the lens' focus distance using the indexed distance marks on the lens. Focus was only as accurate as the proper placement of the distance marks on the lens and the proper estimation/measurement of the camera to subject distance.
The film SLR provided a through the lens view of the subject. The photographer moved the focusing mechanism on the lens (typically by rotating the focus ring) until the subject appeared most in focus. Assuming the camera's mirror and focusing screen were properly aligned, it did not matter how accurate or inaccurate the distance scale indexed on the lens was, because in that case the photographer wasn't focusing the lens based on the distance scale, they were focusing it based on what they saw through the viewfinder.
A hybrid PDAF+CDAF imaging sensor based AF system would be like using the lens' distance scale to get close to the subject distance, and then looking through the viewfinder to dial it in even closer.

With the main imaging sensor based PDAF-only system used by Canon's Dual Pixel CMOS AF in Live View for both video and still imaging, aspects of off-sensor PDAF and on-sensor CDAF are combined. Instead of a one-and-done AF measurement followed by a single instruction to the lens regarding how far to move, which is what typical PDAF does using a separate PDAF sensor¹, Canon's DP CMOS AF takes additional measurements as the lens is being moved, which is what is normally done with CDAF. This is possible because PDAF is being done using the main imaging sensor, thus there's no time used to flip up the reflex mirror between the PDAF measurement and before the image can be captured. PDAF can remain active until the imaging sensor needs to be cleared in advance of capturing the image without slowing down the camera's shooting speed.

There's obviously no difference in the length of the optical path from the lens to the sensor since it is the exact same sensor.
Adjustments to the lens position using 'rinse-and-repeat' measurements are also not as susceptible to errors in the amount of movement instructed by the camera compared to the amount of movement actually made by the lens, because the camera continues to optically measure focus and update it instructions for how far to move the lens until it finds the position that has the highest amount of contrast², rather than telling the lens how far to move one time and then depending on the lens to precisely follow that instruction without optically rechecking.
Any mechanical wear and tear, registration errors, or misalignment of focus position sensors are moot since the camera doesn't depend on them for the final focus position. Instead it measures the contrast in the image projected by the lens onto the sensor and moves the lens until contrast is maximized.

In summary:

PDAF based on a dedicated AF sensor measures how out of focus the subject is, calculates how far and in which direction the lens need to move, and instructs the lens to move to that position. It does not usually optically remeasure to confirm that the lens actually moved the exact distance instructed, or that the subject is now in acceptable focus. This is because PDAF is designed primarily for speed. If it confirms the lens moved the instructed distance, it is usually accomplished via a mechanical position sensor in the lens, rather than by measuring it optically. This is because the mirror can already be swinging up (in which case the PDAF sensor is 'blind') as the lens position sensor is used to adjust the final position of the lens to match what the camera instructed.
CDAF measures how much contrast the subject has and moves the lens until it finds the position which provides maximum contrast. It doesn't rely on a specific position of the lens providing correct focus at a specific distance, but only relies on finding the position of the lens that provides the most contrast.
Imaging sensor based PDAF can use follow-up measurements and revised instructions the same way that CDAF does to "zero in" on the AF target. As the amount of distance the lens is instructed to move is reduced, so are any associated errors if the lens moves a slightly different distance than instructed. When using STM lenses, the smallest unit of movement possible is one step of the stepping motor and AF will not be able to get any closer than the nearest step, regardless of what AF technology is being used.

I infer on-sensor pdaf without cdaf still has to overcome errors (i.e. flange focal distance, lens positioning). Does on-sensor pdaf allow to overcome such errors maybe by iterations?

Most, if not all, of the errors are the same for focussing as for when the image is actually taken, and are thus cancelled out, because PDAF is being done in the main imaging sensor instead of a separate PDAF sensor. Main imaging sensor based PDAF also has the advantage of not being 'blind' without a reflex mirror blocking the main imaging sensor. There's not near as much of a speed penalty for remeasuring focus after the lens is moved following the initial measurement and before the image is taken without a mirror in the mix. By being able to take incremental measurements as the lens is moved, errors resulting from differences between intructed and actual amounts of movement can be significantly reduced. A 1% error for a 0.1mm movement will be significantly less than a 1% error for a 10mm movement by a factor of 100.
¹ Even in 'Servo' AF or 'Continuous' AF, the process is One PDAF measurement → One lens movement → One PDAF measurement → One lens movement → ad infinitum until the shutter button is fully pressed. There's no refinement of the lens position to "zero in" on a stationary subject distance. Rather, it's based on the assumption the subject will most likely be at a different distance for each PDAF measurement → Lens movement cycle. Each additional measurement is done to measure how the subject has moved, not how close the lens got to properly focussing the subject on the previous measure → move cycle. Predictive logic is also used to estimate where the subject will be in an x.x number of microseconds when the shutter opens after the mirror is flipped up.
² Both PDAF and CDAF depnd upon contrast between details in the subject to measure how focused the lens is.
Comment: Good description of mirrorless camera operation. However, my 5Ds R (no phase sensing on the main imager) only uses contrast focusing in live view and recording movies. Classic single shot pics only use the phase detectors which are a separate assembly hence the 5Ds R provides microfocus settings that one can set for specific lenses. Mirrorless cameras and cameras with phase sensor capability on the main imager, can benefit from the rapid, and direction sensing, capability of phase detectors as well as the more precise fine focus of contrast maximization. Very good combo.
Comment: Answer updated.
Answer: It does not depend on the sensor type (dedicated PDAF vs image sensor PDAF).
The need for adjustment comes from the fact that the phase-based autofocus works by using sensor data to determine the absolute lens focusing distance. If what the lens does is not what the camera commands (because of the physical imperfections, incompatibilities across lenses) the focusing precision suffers.
(By contrast, the contrast-based autofocus ;-) drives the lens without knowing or needing absolute positions - and therefore without a need for precise adjustments. It just tells the lens to move forwards or backwards, until the result is acceptable. Even if the lens machinery is slightly off, it will still eventually come to the correct focus.)
On a deeper level, no digital camera really needs autofocus adjustments. It is a relic from ancient times, when film cameras could not verify what is really captured. Nowadays every camera might simply learn from the immediately accesible results and auto tune the phase detection autofocus distances with little user intervention. But as far I know, they don't do it.
Comment: On sensor PDAF doesn't suffer from registration errors that separate PDAFs do. Additionally, DSLRs that have separate PDAFs can't use them in live view or recording and contrast info is the only thing available if the camera doesn't have on sensor PDAFs. Contrast does not determine the direction the lens must move focus while PDAFs do. The result is that focus hunting can occur when the sensor doesn't have PDAFs. That doesn't occur with on sensor PDAFs since the direction required to achieve focus is known.
Comment: @szulat The primary problem with 'automated learning modes' is that different focus distances can often need different calibration adjustments for the same body/lens combo based upon things such as slight errors in registration distance (at a single-digit micron scale), focus position sensor location in the lens, and mechanical tolerances in the focusing mechanism. There's also the issue in the real world that what provides the highest area of contrast within an AF point's area of sensitivity is not always the intended subject. http://blogs.stonesteps.ca/showpost.aspx?pid=54


Can a freely available add-in to a proprietary softare be considered open source?

Question: In a paper that I read recently, the authors promote their software as open source because it was released on GitHub under the Apache License 2.0. However, the software is an add-in to a proprietary (closed source) and non-free software. Furthermore, it was developed using C# and the .NET Framework, which, historically at least, has not been considered open source or free software. Based on this, is it really correct to label this add-in open source software?
Comment: .NET Core is open source, furthermore, the add-on is still open source
Comment: How is this question not about software? The question concerns a software add-in, is that not within the scope of this site?
Comment: The question is about if a library written in a specific language can be considered open source if it has a certain license applied to it.  The close reason simply indicates that not every question about software is within scope.  I selected that particular close reason since you are going to get a lot of opinions on the matter.
Answer: Based on the information you give, the add-in is absolutely free and open source.  The "free" part is the fact it is licensed under the Apache license.  And it is open source as they are offering the source code.
The fact that the add-is made for a non-free closed source application is irrelevant.  That application is a completely different entity and has no bearing on the add-ins "freeness" or it's source.  The same goes for the programming language.  You are able to take the add-in and redistribute it under the terms of the Apache license and modify the source code which is given.
Comment: I didn't touch on licensing, but it may be interesting to discuss infectious licenses... Compile-time or run-time linking (if it's a DLL) can cause "_things to happen_" from a legal point-of-view, depending on the license.
Answer: The answer to this is a somewhat hotly debated topic... perhaps mainly within the Open Source Hardware community.
Fundamentally - "Is it permissible to refer to a project as open source if the tools required to edit / build the sources are not themselves free for use?"
Examples:

Projects with build-time dependencies on tools that are not free-to-use (e.g: hardware projects designed using Altium)
Projects with run-time dependencies and operating environments that are not free-to-use (e.g: software projects designed for use on Windows)

In my mind, if the answer was "No", then an extreme example would be that any software that only runs on a non-free operating such as Windows cannot be referred to as "Open Source"... Even if it could be run in an emulated environment such as Wine, it wasn't designed for this usage.

However, my view is that if the sources are open for anyone to inspect and review, then "Yes" it's permissible to refer to the project as "Open Source".
Bear in mind that the "Source" in "Open Source" is referring to the source files - the original component parts of a project which are used with various tools to produce a usable end result.
"Sources" covers:

Application source code
Build infrastructure or scripts (e.g: Makefiles)
Project files (e.g: VCProj)
Documentation
etc...

opensource.com defines "Open Source" as:

something people can modify and share because its design is publicly accessible

Note that the C# tools and .NET are indeed "free-to-use", but they are "closed source":
https://visualstudio.microsoft.com/downloads

Visual Studio Community 2017
Free, fully-featured IDE for students, open-source and individual developers
Answer: If somebody says anything is "open source", you should ask yourself, whether you are able to look at the complete code this product consists of. If the answer is yes, than it is indeed "open". Of course, the OSI has a clear definition of "open source", that give you a lot more rights and takes away many restrictions. "Open source" is generally viewed as less strict than "free software" based on the definition by Richard M. Stallman and the Free Software Foundation. Some of the reasoning from his point of view can be found here.
I would say, in your case, the software seems to be actually open source in the OSI sense, because the license gives you all the rights. That the software isn't much help without the .NET Framework is another story - you can still use the software without legal restrictions to .NET Framework. You may have a look, maybe the add-on itself could be actually run with .NET Standard, who knows - but this doesn't change the fact, that it most likely is "open source". I wouldn't got so far as to describe it as free software, because I don't know how the program treats its users. There I don't necessarily agree with @keltari .


Need some hint with limit with multiple variables

Question: The limit
$$ \lim_{(x,y)\to(0,0)} \frac{x^{1/3}y^2}{x+y^3} $$
does exist since when we set $y=0$, $x=0$, and $x=y$ (it all equals to $0$). So now we need to evaluate the limit. The L'Hospital rule does not apply with multiple variables, so I am stuck of how to approach it. I understand that I need to somehow manipulate it, but I have no idea how. Any hints?
Comment: Does it? What about the limits along the paths $x = y^3$ and $x = 2y^3$?
Comment: It doesn't exist.
Answer: Are you sure that it exists? The fact that you get the same value of the limit along three different trajectories is NOT sufficient to conclude that the limit exists. The limit must be the same along all possible trajectories (approaching the given point). And you have only tried three, not all, so it's way too early to jump to any conclusions.
Hint: try the curve $x=y^3$ as the trajectory. To express the fact that $(x,y)\to(0,0)$ along this trajectory, substitute $x=y^3$ and then find the limit as you let $y\to0$ (along this curve).


Testing residuals from a cox model with time dependent covariates

Question: I'm doing survival analysis with time dependent covariates, using the counting process style. I already have a set of models and I want to test de residuals.
I'm having trouble with the lack of information about this subject, it makes sense to test Schoenfield residuals for time-dependent covariates?
I'm using R.
Answer: You can plot the martingale residuals for each subject. For me deviance residuals are more clear, both can be computed in R.
<code>dev <- resid(fit,type = "deviance")
</code>
In particular, these plots will enable outlying observations to be identified.
However, diagnostic plots for covariates are not so useful because there are a number of tdc for any, and it is not clear what the residuals for the null model should be plotted against.


2 GFCIs out of one box to different circuits

Question: I just rewired my garage using what was there and have non-functional brand new GFCI outlets. They both come out of one box and feed separate circuits in my garage (one to a wall and other to my openers). They worked before supplying one circuit to my openers. Is having 2 GFCIs in parallel causing this? There is also a mysterious ground coming into the box feeding them that I tied together with the incoming ground.
Comment: I am not sure you are using the word "circuit" properly.  A circuit is everything connected to a breaker i.e. that loses power when the breaker is cut.  If a circuit splits and goes off two directions, I call those branches or forks (not to be confused with branch circuit). "Parallel" is a term that is equivalent to "bad". If you know the tricks, you only need 1 GFCI per circuit .  We need more info to understand what you are doing.
Answer: "mysterious grounding" may be the problem. A GFCI is very sensitive to grounding problems - by design. A few questions:
1 - Do the GFCIs trip and not reset? Or do they NOT trip but simply "don't work"? There is a big difference. If they trip and won't reset then there is a real grounding problem. If they don't trip then they may be bad, though unusual to have two brand new bad outlets.
2 - I'm a little confused about the circuits. "feed separate circuits" implies 2. "They worked before supplying one circuit" implies 1. Do you have 2 separate circuits - i.e., two separate circuit breakers in the panel? Or do you have 1 circuit that originally supplied the openers and now also supplies an outlet? If you only have one circuit then you should only have one GFCI installed.
In addition to any other "mysterious ground", it is possible you have a problem with the openers - i.e., a fault that is minor enough to not trip the regular circuit breaker but is enough to trip the GFCI.
I don't know whether an opener circuit by itself (i.e., no outlets on the same circuit) needs GFCI protection according to code or not. Harper or ThreePhaseEel or one of the other code experts can answer that.
Comment: GFCIs are not even aware that ground exists. However the presence of ground makes it easier for faulty devices with current leakage to leak it somewhere it'll complete a circuit, which means fault current is more likely to flow,  which means it's more likely to trip a GFCI.  If no device is defective, grounded or ungrounded makes no difference.
Comment: True. But "mysterious grounding" could be something gong to ground that shouldn't as opposed to just the ground itself being "bad".


Create network user with remote home folder

Question: I have Mac Server with OpenDirectory configured. Then I create some network users with home folder located on server. Due to the high bandwidth of user usage, I want to add another server that only host user home folders, so the traffic transferred between user and new server while authentication still via old server.
Is this possible to do that? If not, is there any walk around that fix my issue?
Answer: Yes this is possible. When prompted for the location of the home folder for the user you can choose any shared folder that you have configured to be used as storage for home folders in the File Sharing service. This folder can be anywhere on the machine or anywhere on the network.
Comment: 1. In Server.app, when editing user, I can choose only Local/None or shared folder on the MacServer.
2. If I mount the network folder to Mac Server, then choose it as home folder for network user, the traffic from client will transit via Mac Server to the shared folder. That means Mac Server still waste its bandwidth.
3. I use Workgroup Manager to edit user home folder to "afp://files_server/mount_point", but then couldn't login. It show error: You are unable to log in to the user account... at this time. Logging in to the account failed because and error occoured. => It seems couldn't mount
Comment: Thank you @grgarside, I did it, I type the wrong Full path for user homedir in Workgroup Manager.


What is the first instance of a Swayamvar in Hinduism?

Question: What is the first instance of a Swayamvar in Hinduism? I know of a few popular ones like Draupadi's Swayamvar, Amba's Swayamvar, and Sita's Swayamvar. But what is the first instance of a Swayamvar?
Comment: What do you mean by first?  Do you mean what is the earliest reference to a Swayamvara in Hindu scripture, or do you mean the chronologically earliest Swayamvara?
Comment: It will have to be Sati devi selecting Shiva as her husband. Her subsequent avatara also chose her own consort. In fact, there is  swaymvara parvati devata and mantra also.If you are referring to the procedure whereby various kings are invited and one is selected, Damayanti swayamvara is probably one of the earlier instances.
Comment: @moonstar2001 I found the Sundara Kandam quote: http://www.valmikiramayan.net/utf8/sundara/sarga24/sundarasans24.htm#Verse10 "Like the highly fortunate Sachi who waits upon Indra, like Arundhati on Vasishta, like Rohini on the Moon God, like Lopamudra on Agastya, like Sukanya on Chyavana, like Savitri on Satyavanta, like Srimati on Kapila, like Madayanti on Saudasa, like Kesini on Sagara, like Damayanti the daughter of Bhima, devoted to husband Nala, in the same way I am devoted to my husband Rama, the best in Ikshvaku dynasty."
Comment: @KeshavSrinivasan  chronologically earliest Swayamvara
Comment: @moonstar2001 Did the story of Nala and Damayanti take place before the Ramayana?
Comment: yes. Sita devi refers to Nala Damayanti in one instance in the sundara kanda.
Comment: Another one before Ramayana would be the Swayamvar in which Narad was given face of a monkey by Lord Vishnu
Answer: Literally SWAYAM-VAR may refer simply to a girl choosing her own husband, with or without her parent's approval, and Devi Sati's selection of Shiva against her father's wishes may be the earliest instance.
But if you are asking about the Swayamvar ritual in which a father let her daughter choose her husband, the earliest example could be that of Satyavati mentioned in the Mahabharat. As mentioned in the Sundar Kaand Shlok shared by Keshav I am assuming this to be much before Sita Swayamvar.
Vana Parva SECTION CCLXLI states that when Savitri has come of age, her father, King Ashwapati of Madra asks her to choose her own husband:

And seeing his own daughter resembling a celestial damsel arrived at puberty, and unsought by people, the king became sad. And the king said, 'Daughter, the time for bestowing thee is come! Yet none asketh thee. Do thou (therefore) thyself seek for a husband equal to thee in qualities! That person who may be desired by thee should be notified to me.
Do thou choose for thy husband as thou listest. I shall bestow thee with deliberation. Do thou, O auspicious one, listen to me as I tell thee the words which I heard recited by the twice-born ones. The father that doth not bestow his daughter cometh by disgrace. And the husband that knoweth not his wife in her season meeteth with disgrace. And the son that doth not protect his mother when her husband is dead, also suffereth disgrace.
Hearing these words of mine, do thou engage thyself in search of a husband. Do thou act in such a way that we may not be censured by the gods!'

That the practice of Swayamvar was an accepted one is attested to by the Manu Smriti that mentions in the Verse 9.90 -

त्रीणि वर्षाण्युदीक्षेत कुमार्यर्तुमती सती ।
  ऊर्ध्वं तु कालादेतस्माद् विन्देत सदृशं पतिम् ॥ ९० ॥
Having reached puberty, the maiden may wait for three years; after that time, she shall procure a suitable husband.—(90)

Verse 9.91 states:

अदीयमाना भर्तारमधिगच्छेद् यदि स्वयम् ।
  नैनः किं चिदवाप्नोति न च यं साऽधिगच्छति ॥ ९१ ॥
When a maiden, when not given away, herself procures a husband, she incurs no sort of sin; nor does the man whom she weds.—(91)

If you're looking for the mention of a proper ceremony where kings had come to attend and test their mettle against each other, it would perhaps be Damyanti Swayamvar though I doubt its timeline in relation to Sita ji's Swayamvar.
It may have actually happened later because as per the genealogy mentioned in the Puraans, Nala belonged to the lineage of Rama's son Kush unless he is a different person altogether.
Comment: Kusha's descendant Nala is different from Damayanti's husband Nala.  Damayanti's husband Nala learned dice from Rama's ancestor Rituparna.  Rituparna is described in this chapter of the Srimad Bhagavatam: https://www.vedabase.com/en/sb/9/9/


Programmatic way to switch apps?

Question: Is there any programmatic way - Apex, Lightning, URL, etc - to switch a user from being in one Lightning App to another? E.g. the equivalent of the user clicking the upper-left dots menu, choosing something in App Launcher, and ending up in that app?
Answer: I have done some debugging using lightning inspector and found out what event is fired when we click on a app in app launcher.
So event fired is force:switchApp with parameters
    var appEvent = $A.get("e.force:switchApp");
    appEvent.setParams({
        "tabsetId": "02uU0000000DtzAIAS",
        "startUrl": "/one/one.app#/sObject/02uU0000000DtzAIAS"
    });
    appEvent.fire();

One thing I was not able to find out how to get tabsetid. TabsetId is of sobjectType TabSet.
But TabSet cannot be queried. :(
I queried appDefination and tabDefination but no luck there also. So only way to find tabsetId is using lightning inspector and then go to event log and find app id.
Edit
As suggested by Charles in comments we can use tooling api to get app id using
SELECT AppId, Label, Active, SortOrder FROM MenuItem WHERE MenuType = 'AppSwitcher'

Comment: That's a good find Manjot. :)

Just a caveat, e.force:switchApp is not documented and might just stop working without notice. I have happened before so should not be relied on as a concrete solution,
Comment: Also you can query these `02u` IDs via Tooling API as such: `SELECT AppId, Label, Active, SortOrder FROM MenuItem WHERE MenuType = 'AppSwitcher'`. Try in Developer Console with the Use Tooling API box checked.
Comment: Yes, agree don't use this solution until absolutely necessary or sales force comes with documented solution
Comment: Thanks for the insight! Possible workaround to obtain the app ID programmatically. Create a permission set and assign it only one thing: The one app you want to switch to. Now you can query `SetupEntityAccess` and you will see a record with `SetupEntityType = TabSet`, and `SetupEntityId` starting with `02u`.
Comment: I guess this could be a whole other question, but did you find any way to detect which Lightning app a component is running in?
Answer: In case someone finds this and doesn't know about recent developments: you can navigate to Salesforce apps using Page References with aura and lwc with the lightning/navigation component.
You can also just navigate to a url e.g. https://myInstance.lightning.force.com/lightning/app/c__MyCustomApp or  https://myInstance.lightning.force.com/lightning/app/standard__LightningSales.

Programmatic way to switch apps?


What is meant by 'probability of transition per unit time'?

Question: Today I came across a term used by Feynman in his thirteenth lecture: 'probability per unit time' to go from $| 1\rangle$ to $|2\rangle$ while initially being at $|1\rangle$. This is the excerpt from his lecture (emphasis mine):

$$
i\hbar\,\frac{d{C_n(t)}}{dt}=E_0C_n(t)-AC_{n+1}(t)-AC_{n-1}(t).$$
  The first coefficient on the right, $E_0$, is, physically, the energy the electron would have if it couldn't leak away from one of the atoms. [...] The next term represents the amplitude per unit time that the electron is leaking into the $n$th pit from the $(n+1)$st pit; and the last term is the amplitude for leakage from the $(n−1)$st pit. As usual, we'll assume that $A$ is a constant (independent of $t$).

Then I googled a bit came before Fermi's golden rule which states:

In quantum physics, Fermi's golden rule is a simple formula for the constant transition rate (probability of transition per unit time) from one energy eigenstate of a quantum system into other energy eigenstates in a continuum, effected by a perturbation.
  $$
\Gamma_{i\to k} = \frac{d}{dt} |a_k(t)|^2 = \frac{2|\langle k | H^\prime | i\rangle |^2}{\hbar^2}\frac{\sin\omega t}{\omega}
$$

So, the probability of transition per unit time is given by the derivative $$\frac{d}{dt}|a_k(t)|^2.$$ But isn't it the change in probability of transition with respect to time & not just probability of transition per unit time? After all, I learnt that derivatives represent how fast some quantity change instantaneously with respect to change in some other quantity(ies); applying it here, I couldn't find any reason why it shouldn't be called change in probability of transition with respect to time. I am not understanding why  probability of transition per unit time is related to the derivative as derivative does represent the rate of change of some quantity & not the quantity; isn't it ridiculous to call $\dfrac{dv}{dt}$ velocity per unit time? I'm not understanding what probability of transition per unit time actually means. Can anyone please, please explain this to me?
Comment: The phrase you mention doesn't appear in Feynman's text.
Answer: I'm not sure what might be confusing you. Assume, as in most cases with the Golden rule, that the transition rate is constant, $\Gamma$.  So, for small times, the
cumulative transition probability is $W=\Gamma t$.
Think of the transition as leakage from a vessel. At $t=0$, no water has been lost, but with a constant rate of leakage, $\Gamma$, the longer the leakage lasts, the more water is lost to the vessel, so then the leakage rate, the transition rate, is $\frac{\mathrm{d}W}{\mathrm{d}t}=\Gamma$. The picture is the same if you gave $\Gamma$ a time dependence, when $W=\int\Gamma \, \mathrm{d}t$.
As for English usage, what does "elevation gain per unit of time" tell you when going up the mountain in a gondola?


What is zero-order transmission spectrum?

Question: In the paper The extraordinary optical transmission through subwavelength hole arrays by T. W. Ebbesen it is shown at particular wavelength there is a peak observed in zero order transmission spectrum. I am not understanding what exactly this zero order transmission spectrum means?
Answer: Likely, the "zero order transmission spectrum" naming comes from considering the hole array as a transmission grating.
(Illustration of the different orders of a transmission grating here, for example.)
The zero order is just the beam that goes straight through the hole array with no deviation.


Why do we chose exponential function as a trial solution for second order linear differential equation with constant coefficient?

Question: Why do we chose exponential function as a trial solution for second order linear differential equation with constant coefficient ? Can any other function be taken as a trial solution ?
Answer: Consider a homogeneous linear second order ODE with constant coefficients, say
$$ay''+by'+cy=0.$$
Denote by $E$ the vector space of real-valued functions of class $C^\infty$ on $\mathbb{R}$ and define the endomorphism $\partial$ of $E$ as
$$\forall f\in E,\ \partial f=f'$$
(yes, just the derivative).
Our equation can be written as
$$\bigl(a\partial^2+b\partial+c\text{id}\bigr)y=0,$$
(where $\text{id}$ denotes the identity endomorphism of $E$)
so the solutions can be seen as the kernel of the endomorphism $\bigl(a\partial^2+b\partial+c\bigr)$.
Now factor (in $\mathbb{C}$ if needed) the polynomial $aX^2+bX+c$, say
$$aX^2+bX+c=a(X-\alpha_1)(X-\alpha_2).$$
It is straightforward to check that
$$a\partial^2+b\partial+c\text{id}=a(\partial-\alpha_1\text{id})\circ(\partial-\alpha_2\text{id}).$$
If you hit non-real numbers in the previous factorization, you might want to extend your field of scalars to $\mathbb{C}$ and consider $E\otimes_{\mathbb{R}}\mathbb{C}$ instead of $E$.
The eigenvectors of $\partial$ being the exponentials, it's quite natural to use them.
In fact, this factorization of the pseudo-differential operator in the spirit of Weyl algebras leads to a nice proof of the form of the solutions of the ODE.
With this point of view, it seems natural that there are no sensible trial functions other than the elements in the characteristic spaces of $\partial$, namely the functions of the form
$$x\mapsto P(x)\mathrm{e}^{\lambda x}$$
where $P$ is a polynomial function and $\lambda\in\mathbb{R}$ or $\lambda\in\mathbb{C}$. In the case $\alpha_1=\alpha_2$ we actually see such solutions.
All this can be generalized to ODEs of any order, with constant coefficients; for non-constant coefficients you can, depending on how the coefficients are, do a similar study. With non-constant coefficients, the problem will be in factorizing the pseudo-differential operator.
Comment: @gnourf_gnourf...... I am still in undergraduate level. Can you please explain me the answer in ome other way so that i can understand.
Comment: @Bob: nothing to do with groups. Let $f$ be any function of class $C^\infty$.
Then
$(\partial-\alpha_2\text{id})(f)=f'-\alpha_2f$ and
\begin{align*}
   a(\partial-\alpha_1\text{id})\circ(\partial-\alpha_2\text{id})(f)&=
a(\partial-\alpha_1\text{id})(f'-\alpha_2f)\\
&=a\bigl((f'-\alpha_2f)'-\alpha_1(f'-\alpha_2f)\bigr)\\
&=af''-a\alpha_2f'-a\alpha_1f'+a\alpha_1\alpha_2f\\
&=af''+bf'+cf,
\end{align*}
since $-a(\alpha_1+\alpha_2)=b$ and $a\alpha_1\alpha_2=c$. That was for the
factorization part.
Comment: @Bob do you know vector spaces?
Comment: @gniourf_gniourf....... yes
Comment: @Bob alright. Now, do you understand what the operator $\partial$ is and how it's an endomorphism of $E$? Do you understand what we mean by $a\partial^2+b\partial+c\text{id}=(\partial-\alpha_1\text{id})\circ(\partial-\alpha_2\text{id})$?
Comment: sorry but no..... i don't have much idea about groups
Comment: In fact, this factorization of the pseudo-differential operator in the spirit of Weyl algebras leads to a nice proof of the form of the solutions of the ODE. @gniourf_gniourf can you please explain .
Answer: The exponential function $e^{\lambda x}$ is special because its derivative is a multiple of itself.  Thus, substituting it into the ODE gives a quadratic equation in $\lambda$, which is easy to solve.  In general, this method gives us ALL the possible solutions to the ODE, and so using other functions as guess solutions won't work.
Comment: Can you prove that other function won't work for the equation .
Comment: Can you give a prove stating that other functions won't work.
Comment: @Bob http://en.wikipedia.org/wiki/Picard%E2%80%93Lindel%C3%B6f_theorem
Answer: If $y'=ay$ consider $z=e^{-ax}y$. We have $z'=-ae^{-ax}y+e^{-ax}y'=e^{-ax}(y'-ay)=0$
It is elementary then that $z=A$ where $A$ is a constant and therefore $y=Ae^{ax}$
Now suppose $$y''-(a+b)y'+aby=0$$ and take $p=y'-ay; q=y'-by$ so that we find $$p'-bp=0; q'-aq=0$$
whence (from the first result) $$y'-ay=p=Ae^{bx}; y'-by=q=Be^{ax}$$
Now considering $p-q$ we eliminate $y'$ to give $$(b-a)y=Be^{ax}-Ae^{bx}$$Which is a solution of the form you wanted - and the logic (which depends on the mean value theorem) shows that this is the inevitable form of the solution to the equation, which is why we choose it as a test solution and determine the constants from the boundary conditions if necessary.
Obviously this goes wrong when $a=b$, but I will leave you to explore that case yourself.
Answer: Hey this might be too late but here is a less rigorous but I think easier to follow explanation of why a 2nd order linear differential equation with constant efficient takes the form of an exponential.
Let $a\ddot x+b \dot x +cx=0$ which can be rewritten as $(aD^2+bD+c)x=0$ where $D$ is the differential operator (AKA taking the derivative). Since differentiation is a linear operator it allows the equation to be rewritten in the form of         $$(D+\alpha)(D+\beta)x=0$$
where $\alpha \beta=c/a$ and $ (\alpha + \beta)=-b/a$

now $(D+\beta)x$ must be some function of $t$ call it $f(t)=\dot x +\beta x$, this turns the problem into a first order differential equation:
$$(D+\alpha)f(t)=0$$
we can use an integrating factor to solve this first order differential equation
$$\dot f+\alpha f=0$$
$$f(t)=Ce^{-\alpha t}$$
Now that we know what $f$ is we can solve for $x$:
$$\dot x + \beta x=f(t)=Ce^{-\alpha t}$$
we can use the method of integrating factor again to solve for $x$.
You will see that $x(t)$ will then take the form of an exponential. Keep in mind that when find the solution to $\dot x + \beta x=f(t)=Ce^{-\alpha t}$ the solution to $\dot x + \beta x=0$ needs to be considered as well.
Comment: Thank you for your answer. Could you elaborate why linearity allows to rewrite the equation in the form you've provided?


Partitions into parts differing by 2

Question: If we look at the difference between the number of partitions of $n$ with distinct parts that have an even number of parts and the number of partitions of $n$ with distinct parts that have an odd number of parts we get Euler's pentagonal theorem. What happens when we look at the difference between the number of partitions of $n$ with parts differing by at least 2 that have an even number of parts and the number of partitions of $n$ parts differing by at least 2 that have an odd number of parts. Is this difference limited some way? Is it ever bigger in absolute value than one? Are there known upper or lower bounds as n goes to infinity?
Comment: It is 2 for $n=8$ :)
Comment: Related: Rogers' Theorem, at https://en.wikipedia.org/wiki/Glaisher%27s_theorem
Answer: The graph certainly looks promising :)

As for the generating function - what I managed to get is a very strange "downside-up continued fraction"
$$
1-q-q^2\frac{1-q^2-q^4\frac{1-q^3-q^6 \frac{1-q^4-q^8\frac{
   1-q^5-q^{10}\frac{1-q^6-q^{12}\cdots}{1-q^5}}{1-q^4}}{1-q^3}}{1-q^2}}{1-q}
$$
Looks like it is A039924, in which case this generating function is equal to
$$
1-\frac q{1-q}+\frac{q^4}{(1-q) \left(1-q^2\right)}-\frac{q^9}{(1-q) \left(1-q^2\right) \left(1-q^3\right)}+...$$
Comment: I assume this is a graph of the difference in question. How was it computed? Could it be extended further or are there computational obstacles preventing this after 50. It raises some more questions: Does this graph ever stabilize at one sign? Is its increase or decrease as n goes to n+1 limited by some integer? What is that integer if it exists? Can you show the absolute value exceeds any integer?
Comment: I used quick and dirty Mathematica code `ListPlot[Table[With[{l = Select[IntegerPartitions[n], Max[Differences[#]] < -1 &]}, 2Length[Select[l, EvenQ@*Length]] - Length[l]], {n, 50}], Joined -> True]`, surely it can be done much better
Comment: @KristalCantwell Thanks for accepting but this does not really answer any of your questions :D So I will leave it cw I think...
Comment: It was useful especially the link to A039924.

Partitions into parts differing by 2


Linux, find all files matching pattern and delete

Question: Looking to find all files (recursively) which have an underscore in their file name and then delete them via command line.
Answer: This is the safest and fastest variant:
find /path -type f -name '*_*' -delete

It does not require piping and doesn't break if files contain spaces or globbing characters or anything else that other constructs would choke on. The easiest rule to remember here is to never parse find output.  And never grep on filenames if you want to do something with them later. You can do almost anything with find directly.
See also: GNU find Manual – Deleting Files
Comment: In all these years I never noticed the -delete option. Thanks.
Answer: This includes directories which are considered files. Some of the other examples using xargs will fail if the filename contains spaces.
find . -name '*_*' -exec rm -rf {} \;

If you only want regular files:
find . -type f -name '*_*' -exec rm -f {} \;

Comment: Just a hint, if you use `\+` instead of `\;` your command will be faster since it [will substitute the name of *all* found files](http://www.gnu.org/software/findutils/manual/html_mono/find.html#Multiple-Files) instead of calling `rm` one at a time.
Answer: Alright, let's do this progressively.
As a first pass, this is just a simple exercise in passing a wildcard to the find command, remembering to quote it of course, and executing the rm command for every file found:
find ${BASE_DIR}/ -name '*_*' -exec rm {} \;

But of course that's dreadfully inefficient.  It starts up a whole rm process for each individual file.  So while we could take a short detour through \+ that's not where we are going to end up, so let's take the shorter route and bring in xargs to batch up the filenames into groups:
find ${BASE_DIR}/ -name '*_*' -print | xargs rm

But that has two security holes.  First, if any filename found happens to begin with a minus sign rm will treat it as a command-line option rather than a filename, and generate an error.  (The -exec rm {} version also has this problem.)  Second, filenames containing whitespace will not be handled properly by xargs.  So a further iteration is to make this a little more bulletproof:
find ${BASE_DIR}/ -name '*_*' -print0 | xargs -0 rm --

And, of course, there are the interactive features of rm that you probably don't want:
find ${BASE_DIR}/ -name '*_*' -print0 | xargs -0 rm -f --

The -print0 and -0 options are not standard, but the GNU find and xargs, as well as the FreeBSD find and xargs, understand them.  However, even this is improvable.  We don't need to spawn any extra processes at all.  The GNU and FreeBSD finds can both invoke the unlink(2) system call directly:
find ${BASE_DIR}/ -name '*_*' -delete

As a last preventative measure to stop you doing more than you intended in certain circumstances, remember that the filesystem can contain more than just regular files:
find ${BASE_DIR}/ -name '*_*' -type f -delete

Answer: find . -type f -regex ".*_.*" | xargs rm -f
explanation
-type f finds only files
-regex ".*_.*" selects only files that have an underscore in them
xargs rm -f then removes the selected file forcefully (never prompts before deleting)
Comment: To handle files with spaces: `find . -type f -regex ".*_.*" -print0 | xargs -0 rm -f`, but then it still doesn't handler directories


Smart switch in a 4 gang box

Question: I am trying to replace 4 switches from old style to smart switches. I first tried to just hook up the wires like they were on the old switch (no light). I then undid the bundle of white wires (8 of them pulled one out and put it in the neutral wire place bundled the balance of the wires now the light just blinks.
Comment: Current flows in loops, everywhere hot goes to, neutral must come back from or you don't have a loop.  So if you grab one neutral out of a bundle, that means one branch of the circuit is unable to complete its loop.  So any such bundles need to be kept together and added to - never removed from. But 8 is too many to easily splice - something is odd about this box.  Can you post photos?
Comment: Old analog switches and new digital (smart) switches are wired differently as you found out. You need to precisely follow the instructions for the smart switches. If you still don't know what you're doing - stop! Make sure power is off and take some pictures of the inside of the boxes and edit them into your question. Pls provide make and model # for the new switches and someone will help you.
Answer: You can't just steal a random white wire from a bundle like that. They all need to stay connected for everything to work.
If you get "lucky" and pull the neutral that goes back to your electrical panel, the smart switch will have power, but none of your loads will have a complete circuit back to the panel. If you grab a load neutral wire, the switch won't function.
The correct approach is to use a "pigtail", a short piece of wire from the switch to the existing neutral bundle. Or if the switch has its own wires attached (and they're long enough) put that wire in the existing neutral bundle. Of course if you really had 8 white wires all wire-nutted together, you may end up with too many wires for one wire nut. They can be split into groups each small enough for one wire nut, joined by a pigtail.
Comment: Click the "edit" link under the question and use the icon that looks like a mountain (sixth from the left).
Comment: how do you add pictures to a question?
Answer: Pictures would help. The following is based on a common (but not the only) way of doing things.
Not sure how/why you have 8 white wires. The typical setup would be:

One cable coming in (hot/neutral from panel)
One cable going out for each switch = 4 cables
One cable going on to the next location

That would be 6 black hot/switched hot and 6 white/neutral, as follows for "dumb" switches:

Incoming hot pigtailed to hot wires for all 4 switches and the outgoing hot. Alternatively could be daisy-chained between the switches.
All white neutrals together.
Each switch's second connection (switched hot) connected to a switched hot going to one load.

Smart switches (generally) need neutral and they generally care about hot vs. switched hot, where dumb switches don't care if you have hot on top and switched hot on bottom or vice versa (or left/right - screw configuration depends on the particular type of switch). Which means:

The hots and switched hots are connected the same as before. However, you need to make sure you know which wires are hot and which are switched hot. Simply connecting (assuming old and new have, for example, hot and switched hot on the same side of every switch) "old top of switch wire to new top of switch screw, old bottom of switch wire to new bottom of switch screw" may not be correct.
You need to add 4 additional pigtails (white wire) from the neutrals of the new switches to the combined existing (6 by my count, 8 in original post) white neutral wires.

You can't normally put 10 wires in one wire nut. You may be able to do some daisy-chaining, or you may just need to use 2 or 3 wire nuts instead of 1. For example, 10 neutrals connected together could be:

3 existing wires in first wire nut + 2 new pigtails
3 existing wires in second wire nut + 1 pigtail from first bunch
4 new wires (the 4 smart switches) in third wire nut + 1 pigtail from first bunch

Smart switch in a 4 gang box


If I charge 3 capacitors in series, then connect themin parallel, where does the remaining energy go?

Question: I'll get into the math straight away
$C_1, C_2, C_3$ each are charged to $q$. The energy is $$\frac{q^2}{2\left(\frac{1}{\frac{1}{C_1}\frac{1}{C_2}\frac{1}{C_3}}\right)}$$
$$\frac{1}{2}\left(\frac{q^2}{C_1} + \frac{q^2}{C_2} + \frac{q^2}{C_3}\right)$$
 If I then connect them in parallel, the energy now is
$$\frac{1}{2}\left(\frac{9q^2}{C_1 + C_2 + C_3}\right)$$
They are obviuosly not equal. Can someone tell me where the difference in energy goes (and also how it gets dissipated.)
Comment: It is not obvious that these are not equal.   All capacitors being equal, it would seem that 3/2 ( q^2/C) is the first energy sum, and 9/6 (q^2/C) is the second sum.
Comment: @Whit3rd If every symbol is assigned the value of its subscript, you'll see that they are not equal.
Answer: If all the capacitors are identical, then the voltages across each individual capacitor are equal.  When attaching them in parallel, no current flows and no energy is lost.
If the capacitors are not identical, then there are different voltages across each capacitor.  Placing them in parallel causes current to flow.  The wires in the circuit will have some resistance and will cause energy loss as the current flows.  In addition, your equation for the energy in the steady-state case will not be correct.  When connected in parallel, the different capacitors will all have the same voltage, but not the same charge.  So saying each has charge $q$ after being attached is not valid.
In the case where the wires have very low resistance, energy will oscillate for a period of time between being stored entirely in the capacitors and being partially stored in the magnetic field due to inductance from the current flow.
Let's do an example.  Assume $C_1$ is $1\text{F}$ and $C_2$ is $2\text{F}$, and both are charged with $q=1\text{C}$.
$$U = \frac{Q^2}{2C}$$
$$U_1 = 0.5\text{J}$$
$$U_2 = 0.25\text{J}$$
$$U_{tot} = 0.75\text{J}$$
This agrees with your first formula, because it's just a sum of the energy on each capacitor.
Connecting them in parallel means that each must have the same voltage.
$$V_1 = V_2$$
$$\frac{Q_1}{C_1} = \frac{Q_2}{C_2}$$
But the total charge is conserved so
$$Q_1 + Q_2 = 2\text{C}$$
$$Q_2 = 2\text{C} - Q_1$$
Solving these two equations means steady-state afterward is
$$Q_1 = 0.66\text{C}$$
$$Q_2 = 1.33\text{C}$$
And the energy in this configuration is
$$U_1 = \frac{(0.66\text{C})^2}{1\text{F}} = 0.22J$$
$$U_2 = \frac{(1.33\text{C})^2}{2\text{F}} = 0.44J$$
$$U_{tot} = 0.67J$$
So there was a bit of loss from attaching.  Oops.  Did this wrong the first time, but this agrees with your equation (modified for 2 caps)
$$U_{tot} = \frac{1}{2}\left(\frac{4q^2}{C_1 + C_2 + C_3}\right) = \frac{1}{2}\left(\frac{4(1\text{C})^2}{3\text{F}}\right) = 0.67\text{J}$$
Comment: But if I consider the threee capacitors as one with the equivalen capacitance, then it has a charge of $3q$ across it. So, shouldn't the $9q^2$ be valid?
Comment: Also, I was reading about how the energy stred in a configuration of capacitors is the same in series and parallel, but then wouldn't this violate that?
Comment: If you hook (non-identical) capacitors in parallel, then the charges move around.  The charge on each doesn't stay the same after attached.
Comment: I agree, but the net charge on each side remains the same (conservation of charge), so what I'm saying shouldn't be wrong/
Comment: Charge conservation does not imply energy conservation.   Either you charge an inductor (and disconnect it while its current is still nonzer0) or you heat a resistor (and lose energy in the resistor).   Either way, your energy account does not balance with capacitive energy storage alone.
Comment: No. $9q^2$ is still completely valid.  Could you elaborate?
Comment: +1, this answer is completely correct (there isn't any wiggle room insofar as $Q$ and $C$ go). The moral of the story is: You can't expect to short different voltages to each other without energy loss!
Answer: It is not obvious that these are not equal. All capacitors being equal, it would seem that 3/2 ( q^2/C) is the first energy sum, and 9/6 (q^2/C) is the second sum.
If, on the other hand, the capacitances are NOT equal, then the equal charges
imply unequal terminal voltages.   When two different-voltage capacitors
are connected, the final wire attachment makes an LRC circuit, which oscillates and damps down, eventually.  True, one can ignore the L part if the resistance
dominates (because energy 1/2 I^2 * L is negligible when I is an arbitrarily
small trickle after equilibration), or one can ignore the R part if L dominates
(because I^2 L can be large in the first phase of the first oscillation cycle,
when little heating has yet occurred).  Interrupting, however, the connection
when voltages are equal would leave energy in the inductor (because the oscillation condition does not have I and V zero at the same moment).
So, simplest case is to consider a resistor between the two capacitors.
You will find that resistive energy loss is the missing term in the energy
after connection.   Taking the limit, as R approaches zero, does  not
change the energy lost in making the connection.


Do 'Seeking' ranged weapons work against nonconcealment miss chances? (3.5)

Question: The phrasing in the DMG seems (to me) to indicate Seeking weapons would work against any miss chance, including Entropic Shield or Blink. Is there disagreement regarding this?
Answer: As Written There's No Disagreement...
The seeking weapon special ability has the effect of "negating any miss chances, ...such as from concealment" (DMG 225). Honestly, that's about as absolute as this game gets.
...Unless the DM's Really, Really Out to Nerf It
The only disagreement I can see arising is that the spell used in the manufacture of the seeking weapon special ability is true seeing [div] (PH 296), which explicitly "does not help the viewer... spot creatures who are simply hiding." A DM who's very, very angry at a an archer ignoring miss chances on his creatures could on that basis house rule that the seeking weapon special ability can't overcome mundane concealment because the spell used in its creation can't either. That's a really mean house rule, though. Archery's hard enough as it is.
"What If the DM Does Do That?"
The spell corpse candle [conj] (SpC 53) reveals hidden creatures.
Comment: Thanks.  I don't think the true seeing thing should be an issue either.
Answer: If it is writen as a miss chance, a seeking weapon will ignore it, but it is better to study individual effects:

Concealment says it grants a miss chance, so it is negated by a
seeking weapon.
Entropic Shield provides a miss chance that "works like
concealment", so it is fully negated. Blur works almost in the
same way (it states it grants concealment)
Invisibility per se cannot be negated by seeking weapons. Unless
you manage to pinpoint the exact square in which the target is hidding,that is. In
that case, he would be protected only by a full concealment status, which
is negated by seeking weapons.
Blink is kinda hard to explain...and read. But there is two ways it can interact
with seeking weapons. Blink says you have 50% miss chance against the blinking target,
which would be negated by seeking weapons just fine, but there is also the tricky part,
where it says:

Since you spend about half your time on the Ethereal Plane, you can see and
  even attack ethereal creatures....
An ethereal creature is invisible, incorporeal, and capable of moving
  in any direction, even up or down. As an incorporeal
  creature, you can move through solid objects, ...

If this mean you are a truly incorporeal creature, then:

Even when hit by spells or magic weapons, it has a 50% chance to
  ignore any damage from a corporeal source (except for positive energy,
  negative energy, force effects such as magic missile, or attacks made
  with ghost touch weapons).

50% chance to ignore damage is not 50% miss chance. So seeking weapons will not work unless they are ghost touch weapons too. Of course, the spell is so badly written you do not know if you become incorporeal all the time, 50% of the time, 20% of the time or if you ever become incorporeal at all.
Comment: But the *blink* spell's nonconcealment-based miss chance (*from being on a another plane*, which is a pretty extreme kind of miss chance) is just another kind of miss chance, hence covered by the *seeking* weapon special ability.
Comment: 'Seeking' states it negates all miss chances, not just from concealment. Anything more than that is a House Rule, even if it makes sense.
Comment: Also, ghost touch is useless against blink (it only works against incorporeality, not etherealness).  Lord, how I hate how Blink is written up, it gives me a headache.


ConnectionError: (7, "couldn't connect to host")

Question: I parse the following webstie: http://zakupki.gov.ru/
Two weeks ago everything was fine with 3500 requests but now it crashes after about 500 and give me the above-mentioned ConnectionError. Then I switch the connection from one wi-fi connection to other and the code works again until the same Error appears. Then I switch to 3g and it works again, but the same Error repeats. I tried to change DNS to Google's but it doesn't help. What problem might it be?
Would appreciate any help!
Answer: Probably they block your IP after a number of connections for denial of service protection.


Can I run `phpunit` on an open PHP file inside vim?

Question: Is there an easy way to run phpunit on open php test file inside vim?
Answer: I don't know PHPUnit's call syntax by heart, but probably something like :!phpunit % may help.
Answer: I personally like to set up a key mapping for running different tools. My mapping for PHPUnit looks like this (added to ~/.vim/ftplugin/php.vim, accessible at https://github.com/archwisp/linux-home/blob/master/.vim/ftplugin/php.vim):
nnoremap ,u :!./bin/runtests %<CR>

Thus, when editing a unit test file, I just press, ",u" and the runtests script specific to the project is executed with the current file name as an argument. I create a runtests script for each project because each project is set up differently and this allows me to use the same key mapping for each project. The other added benefit is that this script can be run from the command-line or by a continuous integration package.
An example runtests script can be seen here: https://github.com/archwisp/MindFrame2/blob/master/bin/runtests
Answer: I don't know PHPUnit either, however, I'd have set &makeprg to phpunit, and then called make on %:
:set makeprg=phpunit
:make %

and then navigate among the failed assertions with :copen, :cc, :cn, :cp (:h quickfix) -- assuming phpunit failed assertions are compatible with the usual error format: "file:line:error message", otherwise some tuning on &efm would be necessary.


AMD PSP 2.0 AMD Secure Processor

Question: Simple question or hard,
How run AMD PSP 2.0 device (AMD Secure Processor) in Ubuntu 16.04 ?
Answer: From https://libreboot.org/faq/#amdpsp:

This is basically AMD's own version of the Intel Management Engine. It
  has all of the same basic security and freedom issues, although the
  implementation is wildly different.

Effectively, PSP is an isolated, low-level, proprietary co-processor that cross-checks your BIOS firmware with its own. If the BIOS firmware doesn't contain AMD-PSP firmware, then your computer will not boot.
AMD PSP isn't something that you run- it runs at boot, and while you use your computer. As a matter of fact, it can be quite unsafe- once a cracker gains access to the PSP, he/she can effectively control most, if not all, aspects of your hardware.
You may want to give this a read: https://libreboot.org/faq/#intelme
Comment: Hi,problem is wider , and my apologies I don't provided it. I can't connect with my WiFi card , this is Atheros chipset, and if I try to connect with password I receive message that connection cant be done etc. This is the same in Windows 10 if I don't install this driver. How can I connect by WiFi ?
Comment: @DarofromPoland Huh? AMD PSP has *nothing* to do with your wireless card. Open a new question detailing your issues with your wireless card; I've answered your question here.
Comment: Ok, for sure I check it again in windows 10 if is the same, thx for replies and sorry for disinformation.
Comment: Yes, I confirm you right, It looks it has no matter, I installed this driver in Windows 10 and seems the same , WiFi don't want connect. I receive connection can't be done -etc. Case is solved.

AMD PSP 2.0 AMD Secure Processor


Does 'graduate program' mean MSc or Ph.D.?

Question: What is the actual meaning of a graduate program? Is it Masters? Or Ph.D. or Both? Does the definition vary from country to country?
Comment: Note that in some countries (e.g. UK, Aus, NZ), the term "postgraduate studies" is often used for beyond Bachelor level.
Comment: All master's (MA, MBA, MFA ...) and doctorate programs (MD, DO, DNP, ...) are graduate programs. I think "graduate" is most common in the US  but "postgraduate" is definitely understood @JW
Comment: I know of one university where all MSc and PhD go to the graduate programm and becoming a 'full' PhD student required a certain GPA and passing the Qualifying Examination QE after 2 years or so; otherwise you had the only option to completer your Masters degree.
Answer: It means both. It just means any programme that requires an undergraduate degree (such as a Bachelors: BSc, BA etc.) to enter.
It can be a taught course or a research programme, as there are both taught and research masters degrees. One has to look at the programme details to discover more.
I believe the definition does not vary from country to country as it just relates to the semantics of the English word.
Comment: This is correct, but it is worth noting that you cannot necessarily infer whether a degree is a graduate (BrE 'postgraduate') course from the course name. For example, in the UK there are now many 'integrated masters' courses which are a first degree and have names like MMath. There are isolated special cases too like the Oxford BPhil which is a second degree or Scottish MAs which are first degrees.
Comment: As a side note, when I went around calling myself a graduate student, everyone assumed I was a master's student. It's similar to how a "medallist" of a competition would be assumed to hold a bronze medal, rather than a gold. It took me some time to realize this, as the term "graduate student" was common at my old institution, which had no master's students.
Comment: The definition does not vary across countries, but the question whether a Master's program is normally entered after a Bachelor's, or *instead of* pursuing the same, may depend on the country, on the century, and indeed on the actual program.  By now, international student mobility programs have gradually pushed Master's programs in most countries to become graduate programs (see "Bologna process").
Answer:
What is the actual meaning of a graduate program? Is it Masters? Or Ph.D. or Both?

Both.
Answer:
What is the actual meaning of a graduate program?

It's a degree program for people who have graduated (with a Bachelor's degree) from college.


I am unable to save a component. (80040356) Unable to save item length cannot be less than zero

Question: Can anyone help me. I am trying to embed a data visualization and it get an error about the length being less than zero but I cannot find a length parameter anywhere.
Answer: Welcome to the community Kylo! There is a hotfix available with SDL for this.
You can refer to the following link for the issue. The hotfix information should be available here.


Watchguard Firewall - bridge a public IP to another interface?

Question: I have a Watchguard XTM 8 series firewall, and it is setup in mixed routing mode. I have a /24 public IP range and I want to pass one of those IPs to another interface on the firewall WITHOUT using NAT - because I want to connect a Cisco router to it to do VPN Clients for Macs, which won't work behind NAT. Is there anyway to do this? I cannot figure it out for the life of me.
Comment: I have tried creating a subnet of the /24 down to /30 on another interface...example pulic interface is 22.214.171.124/24 I created another interface of 126.96.36.199/30 and assigned 22.214.171.124/30 to the cisco router....I am able to ping .253 and .1 but I cannot ping beyond the router. I created firewall rules that allow any-external to/from the asa but still won't route beyond the watchguard.
Answer: As they have a separate bridge feature that you need to configure - and you can't configure it to bridge external interfaces - I'm not too surprised it doesn't know how to deal with overlapping subnets configured on two external interfaces.
If you have a switch on the external side of the Watchguard, you could connect the Cisco router to it and they would both be in the same /24. You would lose having it behind the Watchguard, but that doesn't sound like a lot of change in security.
Otherwise, I think you need to look at drop-in mode.
The Watchguard SSL VPN client is available for Mac, too.
Comment: figured as much. I was able to put a switch on WAN side to accomplish what I needed. Didn't want to go that route and add another point of failure but it facilitates for now.


How to respond when you are asked for an estimate?

Question: We, as programmers, are constantly being asked 'How long will it take'?
And you know, the situation is almost always like this:

The requirements are unclear. Nobody has done an in depth analysis of all the implications.
The new feature will probably break some assumptions you made in your code and you start thinking immediately of all the things you might have to refactor.
You have other things to do from past assignments and you will have to come up with an estimate that takes that other work into account.
The 'done' definition is probably unclear: When will it be done? 'Done' as in just finished coding it, or 'done' as in "the users are using it"?
No matter how conscious you are of all these things, sometimes your "programmer's pride" makes you give/accept shorter times than you originally suppose it might take. Specially when you feel the pressure of deadlines and management expectations.

Many of these are organizational or cultural issues that are not simple and easy to solve, but in the end the reality is that you are being asked for an estimate and they expect you to give a reasonable answer. It's part of your job. You cannot simply say: I don't know.
As a result, I always end up giving estimates that I later realize I cannot fulfill. It has happened countless of times, and I always promise it won't happen again. But it does.
What is your personal process for deciding and delivering an estimate? What techniques have you found useful?
Comment: See also [How to explain that it's hard to estimate the time required for a bigger software project?](http://programmers.stackexchange.com/q/102856/31260)
[How to learn to make better estimates?](http://programmers.stackexchange.com/q/16326/31260)
[Getting non-programmers to understand the development process](http://programmers.stackexchange.com/q/4/31260) and
[What can I do to get better at estimating how long projects are going to take?](http://programmers.stackexchange.com/q/39411/31260)
Comment: If the requirements are not so clear, you can estimate with a 50% error margin (wider range). If the requirements are clear, you can estimate with a 20% error margin.
Another good strategy that worked for me is to split a project into stages. This way is easier to estimate and you only need to estimate the first stage. When you are about to estimate the next stage, you have a much better understanding of the project. Also, trust between you and your contractor should be better.
I also always write my assumptions and preconditions. Never write "it will work on IE8 or higher", be specific.
Comment: @r.pankevicius Honestly, I just stopped giving estimates: https://rclayton.silvrback.com/software-estimation-is-a-losing-game
Comment: I think it's also important to see the nuance between "estimates" and "deadlines". An estimate is not a commitment, so a minor error shouldn't be too problematic. I wrote a lengthy blog post about this here in case anyone is interested: http://marcgg.com/blog/2015/08/27/deadlines-estimates-software-startup/
Comment: Sergio, "As a result, I always end up giving estimates that I later realize I cannot fulfill. It has happened countless of times, and I always promise it won't happen again. But it does."

How much do you feel improved today?
Comment: You may want to read about the "Cone of Uncertainty"
Comment: Maybe the pareto principle could help? 80% is preparation, and 20% is actual work. From the past, look at how much time you needed to write a certain amount of code, multiply that by four and add that time to your initial estimated time.
Answer: From The Pragmatic Programmer: From Journeyman to Master:

What to Say When Asked for an Estimate
You say "I'll get back to you."
You almost always get better results if you slow the process down and spend some time going through the steps we describe in this section. Estimates given at the coffee machine will (like the coffee) come back to haunt you.

In the section, the authors recommend the following process:

Determine the accuracy that you need. Based on the duration, you can quote the estimate in different precision. Saying "5 to 6 months" is different than saying "150 days". If you slip a little into the 7th month, you're still pretty accurate. But if you slip into the 180th or 210th day, not so much.
Make sure you understand what is being asked. Determine the scope of the problem.
Model the system. A model might be a mental model, diagrams, or existing data records. Decompose this model and build estimates from the components. Assign values and error ranges (+/-) to each value.
Calculate the estimate based on your model.
Track your estimates. Record information about the problem you are estimating, your estimate, and the actual values.
Other things to include in your estimate are developing and documenting requirements or changes to requirements specifications, creating or updating design documents and specifications, testing (unit, integration, and acceptance), creating or updating user's manuals or READMEs with the changes. If 2 or more people working together, there's overhead of communication (phone calls, emails, meetings) and merging source code. If it's a long task, account for things like other work, time off (holidays, vacation, sick time), meetings, and other overhead tasks when picking a delivery date.
Comment: You can *always* say "I'll get back to you."  If someone says "Well, I need an answer," say "If I give you an answer now, it will be a lie.  I do not have enough information right now.  It would be a disservice to us both for me to make something up on the spot."
Comment: This is also a big part of McConnells's "Black Art of Software Estimation". *Never* off-the-cuff it.
Comment: @AndyLester - plenty of situations arise where if YOU don't give an answer now, someone else will, and either take the project and the money with them, or still pin the blame on you in the end for missing an estimate you had nothing to do with.  It sucks, and it's wrong, but it's unfortunately reality.
Comment: I highly recommend the McConnell book. If possible, ask anyone who needs an estimate from you to take his estimating quiz:
http://www.codinghorror.com/blog/2006/06/how-good-an-estimator-are-you.html
You can present it as a game, but it often helps to get the message across.
Comment: @ThomasOwens I'd never use a shooting-from-the-hip estimate for a contract but I do use those estimates before the contract stage.  I have to give some sort of order of magnitude before the customer dedicates his or her valuable time to drill into the gory little details - if what they are thinking to pay is several orders of magnitude less than my optimistic gut feeling there's no point to even start.
Comment: @MadKeithV I have never been in that situation, and I've sat in and been involved with multiple project proposals for multi-million dollar contracts on both sides of the fence. In fact, in my experiences, after an RFP is published, the bidders have ample time to review the documents, ask questions, and produce estimates for cost and time.
Comment: "Determine the accuracy that you need" should be changed to "Determine the precision you need".  Sorry to be pedantic but it's a really really important point you are making here.  The biggest challenges I see around estimates is the lack of understanding of precision and accuracy and how they relate to each other.
Comment: I haven't read Black Art of Software Estimation yet. Its the only Steve McConnell book I haven't read (well, I've never read After the Gold Rush, but I did read the second incarnation of it - Professional Software Development).
Comment: @MadKeithV That concept is foreign to me. Perhaps it's just not how it works in the defense industry, or at least on the types of projects that I've worked on. There's just an RFP, some back-and-forth, and then bids. The customer creates some type of conops document or system requirements and draws up an RFP. Then, bidders review these documents, ask questions, and eventually submit a bid. I've never seen pre-RFP discussions, although I have seen RFPs that just go nowhere because of what the bids look like.
Comment: I usually take my personal (accurate) estimate, and multiply it by four or five, it has the advantage of being both competitive AND relaxing. But then if you're not ten times faster than most people, this won't work.
Comment: A much better question in this situation is "When should I ask you about the estimate again?" - sometimes this will require a second derivative answer: "I will know answer to THAT in three days." It rarely goes more meta than this. Otherwise, I'm giving a wiiiide bracket: "Anything between an hour and two weeks. We're searching; it's an hour since found until fixed, but it first needs to be found."
Comment: And there's always... "It's six hours of work. Now when will these six hours of work be scheduled, that's out of my hands, talk to my boss."
Comment: Statistically we under-estimate by 30%. So just multiply your estimates with 1.3 and it should be accurate :)
Comment: +1 take time to make a decision. If your employer won't allow you to make an educated guess, then they are bad at their job and shouldn't be working with software developers. I always split my task into sub-tasks, decide how long each sub-task should take given past experience, then add 1 day for each sub-task for expected technical debt. Then I give it to my boss. If he wants it done sooner, he can choose what feature to cut.
Comment: When did suggesting that one purchase a book become an acceptable answer?
Comment: @JorisTimmermans This is true, but usually if stakeholders prefer someone who gives the answer "now", it means they are bad and this is a project doomed to fail. You have all to gain by staying out of it.
Comment: @DarioFumagalli I disagree that you always have "all to gain" by staying out of it.  If you're a freelancer and you need the work, then taking on a sensible amount of extra risk (in the schedule) for an actual paycheck and food on the table can be a very sensible choice.  There are other factors at play too, such as "how much could I deliver to make the customer more flexible in allowing slippage from the original schedule".  I do prefer to work on projects where planning and estimation is done properly, but sometimes that's an unaffordable luxury.
Comment: I am a 1 man operation, I've learned over 35 years that a bad deal is a bad deal and "desperation for food" does not turn it into a good deal. If you are forced to do it by lack of other work, then do it. But if you have a choice, don't.
Comment: How do you track your estimations?
Comment: @ThomasOwens I just edited that question you just deleted to make it conform to the rules of the community. Could you please give it a look and undelete it? Thank you.
Answer: Software estimation is the most difficult single task in software engineering- a close second being requirements elicitation.
There are a lot of tactics for creating them, all based on getting good requirements first.  But when your back's against the wall and they refuse to give you better details, Fake It:

Take a good look at the requirements you have.
Make assumptions to fill in the gaps based on your best guess of what they want
Write down all your assumptions
Make them sit down, read, and agree to your assumptions (or, if you're lucky, get them to give in and give you real requirements).
Now you have detailed requirements that you can estimate from.

It's like my mother used to threaten when I was a kid "Hurry up and pick out some clothes, or I'll pick them out for you!"
Comment: How long does it take to write good requirements?
Comment: I asked a follow up question concerning your 3rd point. http://programmers.stackexchange.com/questions/132970/how-to-infer-my-assumptions-i-based-my-time-estimate-on
Answer: I did development for a guy who was very adamant about wanting accurate estimates.  What we settled on, which worked very well, was this:

I billed for all the time I spent estimating.  It came to around 20-25% of what I billed.
I did extremely detailed examination of the tasks.  No shooting from the hip.  I went into the code, figured out what lines needed to be changed, what other parts of the program it would affect, how much testing I'd have to do to ensure that things still worked.  I'd estimate each piece in units of .1 hours (6 minutes).
I sent him my estimate for each task along with that detailed breakdown.

20-25% of billing sounds like a lot.
But he'd ask me to make change XYZ, thinking it'd take about 2 hours.  In 1 hour of detailed estimating, I'd determine it'd take 8.5 hours.  So he'd decide whether it was worth 8.5 hours of pay.  If not, then he saved 7.5 hours over what it would've cost him if I'd done it without an estimate.
And if he did want to invest the 8.5 hours, the detail work I did for the estimate was work I'd have had to do anyway.
I found that with this method I was able to bring most tasks in on time or even early, without having to heavily overestimate.  Because the time was broken down so minutely, I could tell early on if I was slipping.  If I hit roadblocks so that after 3 hours I could tell that my 8.5-hour task was going to take 12, I could talk to him about it before more time passed so he could reevaluate and yank the feature if he was concerned about the cost.
Was he nickel-and-diming?  No, I looked at it as letting him apply his money where he saw the most benefit.  And I was glad to get experience in estimating, which I'd always been terrible at.
Comment: That sounds like a very adequate technique. In fact, when you are making an estimate for your own company the estimate time is being paid as part of your salary also. I'm afraid, however, that the problem is that most organizations want estimates of much bigger tasks than the ones that can be expressed in .1 hour chunks. Thanks for your answer. (Are you the same Kyralessa from the joel on software boards?)
Comment: So if it is like 5 months project you should be estimating it for a month or more. Probably managers will not accept that :)
Comment: Yes, the same one.
Comment: @Darius.V, you make a good point.  In this case the client's decisions were Yes or No to particular features, not an overall Yes or No to the entire project.  This technique is certainly more challenging if doing the entire project or not depends on the overall estimate.  On the other hand, if you're budgeting for six months for a project, but the project might actually take a year, would you rather find that out after six months, or after two or three?
Comment: @SergioAcosta the point is you use the analysis/estimation time to break down the task into smaller chunks. This is the best answer, imho.
Comment: @Darius.V yah your comment actually makes sense, that's why you get those RFPs in which they want a detailed proposal sent back. I didn't really get it until this particular post detailed out for some reason. You end up screwing yourself over if you don't do the due diligence as the tldr;
Comment: @Kyralessa this technique works if you have code or precedents which you can use to base the estimating on. With greenfield projects or features where even the technology being considered might be new there are several unknown unknowns and a different estimation technique may have to be followed from what you're suggesting
Comment: @pcodex In that case, those "unknown unknowns" are called _risks_, and they need to be mitigated.  One way is to simply tackle them head-on: Do those parts of the project first.  Another way is to do accurate estimates for the knowns, and much wider estimates for the unknowns, to reflect the uncertainty.  A good project manager (and I don't claim to be trained as a project manager, mind you) will have tools to deal with this situation.
Comment: " is to simply tackle them head-on: Do those parts of the project first.." .....don't agree with you here. With unknown unknowns there would be nothing to tackle head-on and no there can be no definite risk mitigation plan since they are unknown in the first place. We can only be sure of what has occurred and an empirical approach is what would make sense in the situation I've outlined not your approach of trying to do an upfront estimation.
Comment: @pcodex You mitigate unknown unknowns by building more slack into the project plan.
Answer: We're often asked for an "ballpark estimate" during meetings where we're given very broad and vauge ideas of what they'd like to do.  I always say, "if you want an answer today it's a year and a million dollars.  If you'd like to give me a lot more details and some time to review them then I can refine those numbers for you."
They almost always get the point.
Comment: When they say it's too much, I pretend to think for a minute then say, "You're right!  it is 18 months and 2 million".
Answer: It depends on what the estimate is for.
For an initial, high-level estimate for a business case then the key things are:

Speed. Whatever method you use it needs to be quick. The whole point is the stakeholders aren't sure if it is even worth doing the project - which is why they need the numbers for the business case. If the business case was solid they wouldn't need your estimates. The bulk of these projects won't go ahead so it is important that too much effort isn't expended providing the estimate.
Give a range. Make it broad. You have had no time to analyse requirements, workshop with stakeholders, validate assumptions. A wide range tells the recipient of the estimate "Software projects are naturally complex and risky - if you want a proper estimate you need to give me more details and more time". The problem with giving a single number or a narrow range is that it paints you into a corner by setting expectations before any real analysis is done.

I find the best technique to pick a comparable project that "feels" the same. "Feel" is completely subjective - but with this kind of estimate my experience tells me you won't find objective measurements. Then provide a wide range. I've read some books that say a range of -50% to +100% is good but it depends on many factors.
For a detailed, low-level estimate:

You need a baseline. If the baseline isn't stable the estimate is meaningless.
Bottom up is best. Get a detailed work breakdown, estimate each component then roll it up into a larger number. I find planning poker to be a great technique here.
Document contingency. Make it clear where any contingency (if any) is added. Is it added to each line item? Or to the whole estimate? Or to specific risks? Or is there none?
State your assumptions. Validate as many as possible given the time frame.
State explicitly what is included and excluded in the estimate. For example, is review included? Are technical delays included?
Answer: Some advice from the dark side from one who learned the hard way.

The requirements are unclear. Nobody has done an in depth analysis of
  all the implications.

Don't do an estimate at this point. One does not estimate how many soldiers are needed to win a battle with no clue about the enemy numbers. The estimate is made after scouting. This is unless you already fought this enemy.

The new feature will probably break some assumptions you made in your
  code and you start thinking immediately of all the things you might
  have to refactor.

This is your responsibility to factor in unless you expect others to have the expertise about this area.

You have other things to do from past assignments and you will have to
  come up with an estimate that takes that other work into account.

Same as above, even for unanticipated work that's created by a slob team mate next to you with a near non-existent test procedure which causes your code to glitch out that you can't perfectly predict in advance. It's a weather forecast.

The 'done' definition is probably unclear: When will it be done?
  'Done' as in just finished coding it, or 'done' as in "the users are
  using it"?

Understand the user-end requirement here, think like a user. Don't do what your peers do if they estimate something to be "done" just because some basic functionality with a barebones workflow that no user can possibly tolerate is what they consider to be "done". Think of it from the user standpoint, because that's all the client you're making the estimate for will typically understand. Estimate towards the complete user-end requirements, not towards the barebone technical requirements. And realize that your clients asking for estimates will be totally inaccurate here about how they word things and understand the technical aspects of what you say.

No matter how conscious you are of all these things, sometimes your
  "programmer's pride" makes you give/accept shorter times than you
  originally suppose it might take. Specially when you feel the pressure
  of deadlines and management expectations.

Don't do this! You sound like a self-motivated hard worker and possibly one who gives in easily to coercion.
The problem here is this: let's say you and Joe made time estimates for the same task (but between two separate employees, unaware of both estimates at one time). You estimate valiantly, "one week". It's okay you think, you'll work over 100+ hours a week, unpaid overtime. Now you're three days late.
Meanwhile, Joe estimates 5 months. You think this is ridiculous, you think you can pull this off in one week. How much does Joe work? 10 hours a week? ... except he finishes on time in exactly 5 months.
Guess who gets perceived as the jackass? That's right, you. Joe seems like a great worker, you seem unreliable now. It doesn't matter so much that you might have achieved an even better result in ~7% of the time that Joe took. What matters is that you were 3 days off from a one week estimate.
Never err on the side of the tighter estimate. Err on the side of the looser estimate. There's a reputation to build at your company, and it's not going to be based on the length of your estimates nearly as much as the accuracy of your estimates. It's easy to be accurate with an estimate that's too long, you just get more time to work on the problem and solve it better. An estimate that's too short leaves no breathing room at all, you either meet it desperately or you're screwed.
Answer: "Two weeks!"
Seriously.  My first estimate is always two weeks.  Because I have some sort of bizarre mental block that makes me think everything sounds like it'll two weeks.
I try to work around it, try to really think about how long I think something will take, trying to identify all the potential trouble spots and bits that look too black-box-y for me to be accurately estimating.  And try to recognize that if my answer is "Two weeks!", I've likely failed to do so.
Pretty much every good manager I've had has learned to recognize "Two weeks!" as an answer that requires a mild verbal pimp-slap in response.
Comment: Probably this is why most of teams do 2 week sprints :)
Answer: There is a blog entry that outlines how to keep a record of how accurate your previous estimations have gone, and then next time you say to someone "it'll be two weeks", you can look at your previous history and see how long it actually took last time you said "it'll be two weeks".
I haven't tried it myself, but I'd like to, to see how accurate my estimations are.
Comment: Joel's Fogbugz goes further on that and analyses your data for you using evidence based scheduling.  Ie, each developer enters how long they think each task will take, and later, how long that task took, and it guages how accurate each developer is with their estimates to produce a probability curve for a finish date.
Answer: It depends on the organization and how the estimates are used.
If the estimate is just to provide a general idea on when it will be ready, I can generally do a quick estimate based on my experience. Often times I will include any uncertainty or possible variations with the estimate along with how the changes may impact other areas of the system and the extent of regression testing required.
If the estimate is used for anything contractual or in a scenario where more precise timing is required, I do a full work break down. This is more work and requires more in depth thinking about the design and changes to the system, but is much more accurate, especially for larger pieces of work.
In either case, on-going communication is key. If you do run into something unexpected, make it known at the time instead of waiting until the deadline. If the requirements are not-clear, make sure you document your understanding of them and the functionality that you plan to deliver. This is also helpful with any assumptions you make. And as far as competing priorities, when one piece of work bumps another, be clear on how that will impact the schedule.
Comment: +1 for the need for on-going communication. IMO, this is **the** most useful part of the Agile model.
Comment: This is the first decent answer here simply because it's the only one thusfar (I'm reading top to bottom) that stresses "ongoing communication". Everyone else seems to think estimate-communication is a one-off event. That's bad advice, and a poor approach to these things. *This answer* is good advice.
Answer: Estimates for what? Small tasks or complete solutions.
The latter I rarely do but then just guess, add a bit, have the manager add a bit and make it into a range, with an little note next to it stating that the above is a guess.
Small tasks - Planning poker I've found to work really well (not perfect, some 1pt tasks have taken much longer and some 5pt tasks took minutes, but it all evens out in the end).
Answer: Confidently. I can't tell you how many times I botched up an initial meeting with a client by not putting on professionalism when giving an estimate. Even if you're blowing numbers out of thin air - make sure you always keep some estimate around. That said, be careful not to estimate yourself into a hole. Different things take different amount amounts of time, effort and resources to put together. Here's a good way to do it:

Them: How much will it cost?
Me: It depends on what you want me to do. Generally, I start this sort of project at around $X.
Answer: Present a range based on what you know today. Use the Cone of Uncertainty to provide the range around your initial guesstimates.
Every week calculate how much is left to do, re-estimate based on what you know. Once you have enough of a sample size of how much work you are getting through each week, provide a 90% confidence interval for what's left to give a (usually) ever narrowing date range as the project progresses and the amount of work left (hopefully) shrinks.
Answer: Sometimes estimating becomes an enormous challenge for you and your team, especially when we are talking about software project estimation.
Once we had decided to share our experience and our knowledge about software estimation process and defined four distinct types of estimations:

ballpark figure
service estimate
feature estimate
componential estimate

Of course, those types are distinct. Ballpark is what is often called a "guesstimate". So it's an approximate number or range that gives a general idea of cost and that may help a prospect decide whether they would like to take the discussion further.
As a rule, clients need a ballpark figure at the beginning of the project. And our advise is: discussion of the project and providing ballpark figures should just be steps well towards receiving componential estimate (which is flexible, one can make use of componential type estimate for the whole development process. No need to re-estimate from scratch when you want to add, remove or replace features, services etc).
Everyone should keep in mind the risks that come with software development estimating: underestimating, overestimating, total epic fail scenario etc.
You can read more on our blog!
http://blog.lemberg.co.uk/project-management/software-estimation-process/
Hope this information will help you!
Answer:
I always end up giving estimates that I later realize I cannot fulfill. It has happened countless of times, and I always promise it won't happen again.

It sounds like you're being asked for a commitment, not an estimate. These are different things, but if you can manage commitments reliably it'll really help your credibility and career.
Some advice based on my ~10 years of experience:

Always provide a range (i.e. lower and upper bound). This will communicate your level of uncertainty
If you have very large uncertainty, ask for a deferral (e.g. 1 day to do analysis, and then provide a tighter range)
If the task it too large, break it up and provide a range for each piece
Answer: First, if some task was assigned to me I would break it down into subtasks.I would estimate the time for each subtasks and probably with subtasks I would be able to find the problematic area and hence I would be able to forecast how long it would take to a certain extent.
But still all the planning would help only to a certain extent. Only when you start coding you can find the exact issues
Answer: If you do many projects for the same boss or client, you can try to estimate in broad strokes of complexity instead of weeks or months, possibly in t-shirt sizes. Identify a few past projects, and assign them the sizes S, M, L, XL.
And then ask yourself: which project does that sound similar to in scope? And then instead of answering with "2 Months", you can answer with "sounds like an L to me" (or whatever your calibration for project turns out to be).
This is pretty easy to understand, and it is also clear that there is lots of uncertainty in those guesses.
Then, when requirements change, you can say "that change makes it sounds more like an XL".
Comment: this is quite smart (if you are allowed to use it): I prefer going with a similar approach but just generalising with time values, so I will answer "this will take a week or so" or "it's going to be a matter of days" for something small and avoid answering when the project is going to be bigger than a month and need a proper estimate
Answer: A bit late but when I was in the military we were instructed to use PERT to determine estimates.  It does require some experience in your field and the task at hand.  It was surprisingly accurate when determining estimated time of completion when maintaining and repairing electronic devices (complex radios and satellite comms equipment), where any number of things can be wrong or found and needed to be fix during routine maintenance.  The estimations were important because other units may be inoperable until they received back their comms equipment.  One that I've used is this Free Online PERT Calculator


How does $-(-1)^n$ become $(-1)^{n+1}$

Question: I am currently studying how to prove the Fibonacci Identity by Simple Induction, shown here, however I do not understand how $-(-1)^n$ becomes $(-1)^{n+1}$.  Can anybody explain to me the logic behind this?
Answer: $-(-1)^n=(-1)^1(-1)^n=(-1)^{n+1}$
Answer: $$-x=(-1)x$$
Now substitute $x=(-1)^n$
$$-(-1)^n=(-1)(-1)^n=(-1)^{n+1}$$
Answer: The negative sign outside the parentheses can be re-written as $-1$:
$$-(-1)^n = (-1)(-1)^n$$
That first factor of $(-1)$ can be written as $(-1)^1$, so we have
$$(-1)^1(-1)^n$$
and finally the two factors can be combined by adding the exponents:
$$(-1)^{n+1}$$
Answer: The powers of $-1$ are $$-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, \ldots$$ If $n$ is odd, then $(-1)^n = -1$, but if $n$ is even then $(-1)^n = 1$. So if you multiply $(-1)^n$ once by $-1$, it is the same as incrementing $n$. (Technically you can also decrement, but you can't generalize that to other negative numbers).
Answer: Simple there is a $-$ sign in front so you can write $-(-1)^n=(-1)(-1)^n=(-1)^{n+1}$.

How does $-(-1)^n$ become $(-1)^{n+1}$