Why is Average Treatment Effect different from Average Treatment effect on the Treated?

Question: In RCTs, randomisation balances unmeasured confounders and, I'm told, ATE and ATT would be the same. In observational studies, this is not possible and Propensity Scores are used in various ways to estimate ATT and/or ATE. The analyses that I've performed and examples that I've seen (eg this helpful text) shows different ATT and ATE (albeit slightly).
Please can anyone help me understand why they are different and, more importantly, what the differences mean (eg. if ATE>ATT or ATT>ATE), if anything?
Answer: The Average Treatment Effect (ATE) and the Average Treatment Effect on Treated (ATT) are commonly defined across the different groups of individuals. In addition, ATE and ATT are often different because they might measure outcomes ($Y$) that are not affected from the treatment $D$ in the same manner.
First, some additional notation:

$Y^0$: population-level random variable for outcome $Y$ in control state.
$Y^1$: population-level random variable for outcome $Y$ in treatment state.
$\delta$: individual-level causal effect of the treatment.
$\pi$: proportion of population that takes treatment.

Given the above, the ATT is defined as: $\mathrm{E}[\delta|D=1]$ ie. what is the expected causal effect of the treatment for individuals in the treatment group. This can be decomposed more meaningfully as:
\begin{align}
\mathrm{E}[\delta|D=1] = & \mathrm{E}[Y^1 - Y^0|D=1] \\ &  \mathrm{E}[Y^1|D=1] - \mathrm{E}[Y^0|D=1]
\end{align}
(Notice that $\mathrm{E}[Y^0|D=1]$ is unobserved so it refers to a counterfactual variable which is not realised in our observed sample.)
Similarly the ATE is defined as: $\mathrm{E}[\delta]$, ie. what is the expected causal effect of the treatment across all individuals in the population. Again we can decompose this more meaningfully as:
\begin{align}
\mathrm{E}[\delta] =& \{ \pi \mathrm{E}[Y^1|D=1] + (1-\pi) \mathrm{E}[Y^1|D=0] \} \\ -& \{ \pi \mathrm{E}[Y^0|D=1] + (1-\pi) \mathrm{E}[Y^0|D=0] \}
\end{align}
As you see the ATT and the more general ATE are referring by definition to different portions of the population of interest. More importantly, in the ideal scenario of a randomised control trial (RCT) ATE equals ATT because we assume that:

$\mathrm{E}[Y^0|D=1] = \mathrm{E}[Y^0|D=0]$ and
$\mathrm{E}[Y^1|D=1] = \mathrm{E}[Y^1|D=0]$,

ie. we have believe respectively that:

the baseline of the treatment group equals the baseline of the control group (layman terms: people in the treatment group would do as bad as the control group if they were not treated) and
the treatment effect on the treated group equals the treatment effect on the control group (layman terms: people in the control group would do as good as the treatment group if they were treated).

These are very strong assumptions which are commonly violated in observational studies and therefore the ATT and the ATE are not expected to be equal. (Notice that if only the baselines are equal, you can still get an ATT through simple differences: $\mathrm{E}[Y^1|D=1] - \mathrm{E}[Y^0|D=0]$.)
Especially in the cases where the individuals self-select to enter the treatment group or not (eg. an e-shop providing cash bonus where a customer can redeem a bonus coupon for $X$ amount given she shops items worth at least $Y$ amount) the baselines as well as the treatment effects can be different (eg. repeat buyers are more likely to redeem such a bonus, low-value customers might find the threshold $Y$ unrealistically high or high-value customers might be indifferent to the bonus amount $X$ - this also relates to SUTVA). In scenarios like this even talking about ATE is probably ill-defined (eg. it is unrealistic to expect that all the customers of an e-shop will ever shop items worth $Y$).
ATT being unequal to ATE is not unexpected. If ATT is smaller or greater than ATE is application specific. The inequality of the two suggests that the treatment assignment mechanism was potentially not random.
In general, in an observational study because the above-mentioned assumptions do not generally hold, we either partition our sample accordingly or we control for difference through "regression-like" techniques.
For a more detailed but easy to follow exposition of the matter I recommend looking into Morgan & Winship's Counterfactuals and Causal Inference.
Comment: Thank you very much for this incredibly detailed and helpful answer. I'm not a statistician and struggle at times with formulae, but this is very clear. Will Morga & Winship's book be digestible by a layman, or can you suggest a "dummy's guide" to causal inference? Thanks again
Comment: In a *hypothetical* situation, yes. I think it would be meaningful in the context of a simulation study. That said, actual using it to quantify "poorness/goodness" of balance achieved by PS is probably a methodical exercise on its own right. (Happy reading!)
Comment: I am glad I could help. I have educated myself mostly from papers so I have a limited view of what causal inference books are out there. That said, I have found M&W's book to be clear and easy to comprehend; I think an inclined layman will have little problems to follow through. The book is part of the "*Analytical Methods for Social Research*" series from Cambridge Univ. Press so it uses mostly Sociology-based examples. @DimitriyV.Masterov might have a more educated suggestion.
Comment: @bobmcpop I'm a statistician, and I never have understood why someone would want to measure the ATT instead of the ATE. It's important to have a control group to account for regression to the mean effects & other factors - you're missing this when you use the ATT.
Comment: Thanks, I'll get myself a copy. "The inequality of the two suggests that the treatment assignment mechanism was potentially not random." I assume in a hypothetical situation where literally every baseline confounder was measured in an observational study, and there was a perfect match for each PS, we would get very close to those assumptions. Therefore would the extent to which ATT/ATE are discordant provide any meaningful information about how poorly the PS balanced for unmeasured confounders?
Comment: This answer would be even better if you could spell out the steps & formulas that are used for calculating the ATT. Say you've matched the treatments with the controls on propensity scores. What's the next step?
Comment: @RobertF: ATT can be relevant especially in cases where we have an inherit selection bias in our sample. For example, we might want to measure the effect on those who would "typically"/"be likely to" take up a treatment (think the bonus conditional on some expenditure example I mention) instead of across all people who could potentially take up the treatment.
Comment: @RobertF: You are welcome to open a new question regarding the use of propensity scores for the calculation of ATE and ATT.
Comment: I asked a very similar question on this site: https://stats.stackexchange.com/questions/238431/is-the-average-treatment-effect-on-the-treated-att-a-meaningful-comparison-in. I didn't get an answer, but in the comments was told that the ATT is estimated as the average difference between trmt and controls with a 1:1 match.
Comment: I think that ATE, ATT, ATC, etc. are all defined in terms of our research question; please see my comment from about 60' ago. As you correctly mention, this is a potential estimation method and not the actual meaning of estimator.
Comment: @usεr11852 I asked my colleagues in my workplace (a health insurance company) about their choice of estimating ATT over ATE for a case vs. control propensity score matching study. They have more of an operational rather than mathematical definition of ATT - out of a pool of candidates eligible to receive a treatment, only a small percentage received the treatment during a given time period. The rest of the eligible population are considered to be an ad hoc "control group" of sorts even though they're scheduled to receive the treatment. Hence ATT rather than ATE, but the difference is semantic.
Comment: @RobertF: The idea of "ad hoc control" seems dangerous to me because of selection bias. (I work in industry too.)
Answer: ATE is the average treatment effect, and ATT is the average treatment effect on the treated.
The ATT is the effect of the treatment actually applied. Medical studies typically use the ATT as the designated quantity of interest because they often only care about the causal effect of drugs for patients that receive or would receive the drugs.
For another example, ATT tells us how much the typical soldier gained or lost as a consequence of military service, while ATE tells us how much the typical applicant to the military gained or lost.
Comment: This is one of the clearest explanations I have seen of ATE vs ATT
Comment: I don't confuse. I refer to this paper: Ho, D. E., Imai, K., King, G., & Stuart, E. A. (2007). Matching as nonparametric preprocessing for reducing model dependence in parametric causal inference. Political analysis, 15(3), 199-236.
Comment: You're right, I misunderstood.
Comment: You're confusing the ATT with the ITT, intent-to-treat effect.
Answer: There seems to be something obvious not discussed above. If the treatment effect is constant over individuals $Y_i^1-Y_i^0=c$ for every $i$ then ATT and ATE as defined above should be equal.
This may be seen as there being no "effect modifiers". My intuition is that balancing effect modifiers between groups would also be sufficient for equality of ATT and ATE. The distribution of treatment effects would then be independent of treatment. Maybe someone already has this formalized?


Why Math.Atan(Math.Tan(x)) != x?

Question: If tan(x) = y and atan(y) = x why Math.Atan(Math.Tan(x)) != x?
I´m trying to calculate x in something like:
tan(2/x +3) = 5

so
atan(tan(2/x + 3) = atan(5)

and so on... but I´ve tried this:
double d = Math.Atan(Math.Tan(10));

and d != 10. Why?
Comment: Math.Tan(10) return the tangent of an angle of 10 *radians*, not 10 *degrees*, as I suspect you were thinking.
Answer:
The tangent function is periodic with period pi, and is invertible only if you restrict it to a subset of its domain over which it is injective. Usually the choice of such set is the open interval ]-pi/2, pi/2[, hence the arctan function will always return a point in that interval. In your case, 10 = 3*pi + 0.57522... Thus, the arctan of the tangent of 10 will return 0.57522...
Note that the arctan function, defined as above, is injective and defined over all the real numbers, hence the converse of your problem math.tan(math.atan(x)) == x
indeed holds for each x (except for numerical errors).
In order to deal with numerical errors, you should never perform comparisons between the results of floating point computations using == or !=. Use abs(number1 - number2) <  epsilon   // ==
abs(number1 - number2) >= epsilon   // !=
 instead, where epsilon is a small positive constant.
Comment: Yeah, the choice of epsilon is application specific. The framework cannot have some epsilon that works everywhere.
Comment: Note that the Double.Epsilon constant represents the smallest positive Double value greater than zero. It does not work in any other domain.
Comment: Peter Ritchie/Thomas Lee: This value is not defined as smallest positive number x, such that x + 1.0 is not equal to 1.0, so Double.Epsilon cannot be used for "almost equality". There exists no constant in the framework whose value is smallest positive number x, such that x + 1.0 is not equal to 1.0
Comment: Just note: In C# there is Double.Epsilon constant that represents epsilon value for the double datatype.
Comment: AFAIK (but correct me if I'm wrong) in C# Math.Abs(n1 - n2) < Double.Epsilon is the same as n1 == n2 since by definition anything that has a smaller absolute value than Double.Epsilon is zero. Math.Abs(n1 - n2) <= Double.Epsilon would be better IMHO
Answer: A graph might help explain why you are not getting the result you expected.

(source: wolfram.com)
http://mathworld.wolfram.com/Tangent.html
That shows the graph of Tan, but if you imagine reading off a value of x for a given y, (e.g. y = 0) then depending on which "strand" of Tan you read, you will get a different answer (-pi, 0, pi...). That's the point about Arctan(x) having more than one solution.
If arctan was restricted to only one of those strands, e.g. -pi/2 < x < pi/2 then Arctan(tan(x)) will return x providing you have accounted for floating point errors.
EDIT: However, according to http://msdn.microsoft.com/en-us/library/system.math.atan.aspx, the atan method already returns -pi/2 < x < pi/2 or NaN if your input is undefined. So the problem must soley be down to floating point rounding.
EDIT (F.R.): Added figure
Comment: "the problem must soley be down to floating point rounding" is the wrong conclusion, because atan just return from the intervall, does not solve the mathmatical background - just take your pocket calc and (which behaves same) and calc the original example
Answer: I dont know any C#, but maths says that tan is not invertable, only in a small intervall.
e.g. tan(pi) = 0 and tan(0) = 0. When asking for atan(0) it could be 0 or pi (or every multiple of pi), so the result is in the range from -pi/2 .. pi/2.
Even if you start with an x in the invertable range i doesnt has to work, because of rounding errors with the floating points (it has not unlimmited precision).
Answer: tan-1(tan(x)) == x for all x in (-PI/2, PI/2).
Answer:
Because the tangent function is periodic we need to normalize input angle. Math.Atan returns an angle, θ, measured in radians, such that -π/2 ≤ θ ≤ π/2, so it makes sense to normalize to that range (since it obviously won't anything within that range anyway):
double normalizedAngle = (angle + Math.PI / 2) % Math.PI - Math.PI / 2;

Doubles should be compared with some error margin. But in fact for this case Double.Epsilon is too small and "If you create a custom algorithm that determines whether two floating-point numbers can be considered equal, you must use a value that is greater than the Epsilon constant to establish the acceptable absolute margin of difference for the two values to be considered equal. (Typically, that margin of difference is many times greater than Epsilon.)" For instance, Math.Atan(Math.Tan(-0.49999632679501449)) + 0.49999632679501449 will be greater than Double.Epsilon for 1.1235582092889474E+307 times.
Answer: In general, when you are dealing with floating point numbers, you are dealing with approximations. There are numbers that cannot be represented exactly, and the tan and arctan operations are themselves only approximate.
If you want to compare floating point numbers, you need to ask if they are nearly equal, or equivalently, if the difference is less than some small value, and think carefully what you are doing.
Here is are some FAQS (for c++, but the idea is the same), that talk a bit about some of the oddities of floating point numbers:
FAQ 29.16
FAQ 29.17
FAQ 29.18
Edit: Looking at the other answers, I realise that the main problem is probably that tan isn't invertible, but the approximation issue is worth considering too, whenever you test floating point numbers for equality.
Looking at the .net documentation for Math.Atan, atan produces a value between -π/2 and ≤ π/2, which doesn't include 10. That I think is the usual range for arctan.
Answer: It might be helpful if you posted what you are trying to accomplish.  I have recollections of discovering trig functions that handled the issue if what quadrant the inputs were in for me when I tried playing with angles, for example.
Answer: double d = Math.Atan(1) * (180 / Math.PI);
so d will be 45 in degrees
Comment: here Tan-1 return in degree to d

Why Math.Atan(Math.Tan(x)) != x?


How to get through the form with scrape

Question: I am trying to submit the form with scrapy spider to retrieve more results in a page. I have tried to see if the problem has been already researched and I found only this post.
I think that I am doing things right (based on explanation there) but the log looks like this (it seems that attempts to submit the form are not successful and spider stops) :
2016-02-01 00:43:40 [scrapy] INFO: Scrapy 1.0.4 started (bot: scrapybot)
2016-02-01 00:43:40 [scrapy] INFO: Optional features available: ssl, http11
2016-02-01 00:43:40 [scrapy] INFO: Overridden settings: {'FEED_FORMAT': 'json', 'FEED_URI': 'stack.json'}
2016-02-01 00:43:40 [scrapy] INFO: Enabled extensions: CloseSpider, FeedExporter, TelnetConsole, LogStats, CoreStats, SpiderState
2016-02-01 00:43:40 [scrapy] INFO: Enabled downloader middlewares: HttpAuthMiddleware, DownloadTimeoutMiddleware, UserAgentMiddleware, RetryMiddleware, DefaultHeadersMiddleware, MetaRefreshMiddleware, HttpCompressionMiddleware, RedirectMiddleware, CookiesMiddleware, ChunkedTransferMiddleware, DownloaderStats
2016-02-01 00:43:40 [scrapy] INFO: Enabled spider middlewares: HttpErrorMiddleware, OffsiteMiddleware, RefererMiddleware, UrlLengthMiddleware, DepthMiddleware
2016-02-01 00:43:40 [scrapy] INFO: Enabled item pipelines:
2016-02-01 00:43:40 [scrapy] INFO: Spider opened
2016-02-01 00:43:40 [scrapy] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2016-02-01 00:43:40 [scrapy] DEBUG: Telnet console listening on 127.0.0.1:6023
2016-02-01 00:43:41 [scrapy] DEBUG: Redirecting (302) to <GET http://www.experienceproject.com/dologin.php?err=t> from <GET http://www.experienceproject.com/dologinhandler.php>
2016-02-01 00:43:41 [scrapy] DEBUG: Crawled (200) <GET http://www.experienceproject.com/dologin.php?err=t> (referer: None)
2016-02-01 00:43:42 [scrapy] DEBUG: Redirecting (303) to <GET http://www.experienceproject.com/dologin.php?err=t&usernameAttempt=linguisttoo> from <POST https://www.experienceproject.com/ajax/ep/login.php>
2016-02-01 00:43:43 [scrapy] DEBUG: Crawled (200) <GET http://www.experienceproject.com/dologin.php?err=t&usernameAttempt=linguisttoo> (referer: http://www.experienceproject.com/dologin.php?err=t)
Login success
2016-02-01 00:43:43 [scrapy] DEBUG: Crawled (200) <GET http://www.experienceproject.com/about/rain0069/stories> (referer: http://www.experienceproject.com/dologin.php?err=t&usernameAttempt=linguisttoo)
2016-02-01 00:43:43 [scrapy] DEBUG: Redirecting (303) to <GET http://www.experienceproject.com/ajax/member-profile-subpage/groups?nextStartId=20&filter=&loadContentOnly=1&mid=9547778&showAdult=&=See+More+Groups> from <GET http://www.experienceproject.com/ajax/member-profile-subpage/groups?nextStartId=20&filter=&loadContentOnly=1&mid=9547778&showAdult=&=See+More+Groups>
2016-02-01 00:43:43 [scrapy] DEBUG: Filtered duplicate request: <GET http://www.experienceproject.com/ajax/member-profile-subpage/groups?nextStartId=20&filter=&loadContentOnly=1&mid=9547778&showAdult=&=See+More+Groups> - no more duplicates will be shown (see DUPEFILTER_DEBUG to show all duplicates)
2016-02-01 00:43:43 [scrapy] INFO: Closing spider (finished)
2016-02-01 00:43:43 [scrapy] INFO: Dumping Scrapy stats:
{'downloader/request_bytes': 4091,
 'downloader/request_count': 6,
 'downloader/request_method_count/GET': 5,
 'downloader/request_method_count/POST': 1,
 'downloader/response_bytes': 32318,
 'downloader/response_count': 6,
 'downloader/response_status_count/200': 3,
 'downloader/response_status_count/302': 1,
 'downloader/response_status_count/303': 2,
 'dupefilter/filtered': 1,
 'finish_reason': 'finished',
 'finish_time': datetime.datetime(2016, 1, 31, 23, 43, 43, 949049),
 'log_count/DEBUG': 8,
 'log_count/INFO': 7,
 'request_depth_max': 3,
 'response_received_count': 3,
 'scheduler/dequeued': 6,
 'scheduler/dequeued/memory': 6,
 'scheduler/enqueued': 6,
 'scheduler/enqueued/memory': 6,
 'start_time': datetime.datetime(2016, 1, 31, 23, 43, 40, 995588)}
2016-02-01 00:43:43 [scrapy] INFO: Spider closed (finished)

My code is here :
import scrapy
from scrapy.http import FormRequest
from loginform import fill_login_form
from scrapy.selector import HtmlXPathSelector
from scrapy.http import Request
from scrapy.shell import inspect_response

class LoginSpider(scrapy.Spider):
    name = 'experienceproject.com'
    start_urls = ['http://www.experienceproject.com/dologinhandler.php']
    login_user = "xxx" # Login is required but I do not provide it .... I attach the page source instead to the question
    login_pass = "xxx"

    def parse(self, response):
        args, url, method = fill_login_form(response.url, response.body, self.login_user, self.login_pass)
        return FormRequest(url, method=method, formdata=args, callback=self.after_login)

    def after_login(self, response):
        # check login succeed before going on
        if "authentication failed" in response.body:
            self.logger.error("Login failed")
            return
        print "Login success"
        return Request(url="http://www.experienceproject.com/about/rain0069/stories",
               callback=self.parse_stories)

    def parse_stories(self,response):
#        TRY TO CLICK ON "SEE MORE STORIES"
         return scrapy.FormRequest.from_response(
         response,
         formxpath='//form[@class="pagination-form indicate-loading"]',
         clickdata={'class': 'ep-button page-btn -input'},
         callback=self.go_out)

    def go_out(self, response):
#        SEE IF SUCCESS
        inspect_response(response, self)
        return

The page is behind a login so I rather provide page source here
Is there anything I am doing wrong?
Answer: You request got filtered out by the built-in duplicate filter. Use dont_filter=True:
return scrapy.FormRequest.from_response(
     response,
     formxpath='//form[@class="pagination-form indicate-loading"]',
     clickdata={'class': 'ep-button page-btn -input'},
     callback=self.go_out,
     dont_filter=True
)

Comment: I have tried but it only shows more line and the last one is : 2016-02-01 01:09:11 [scrapy] DEBUG: Discarding : max redirections reached
Comment: @linguisttoo well, that's the next different problem. I'm not registered on this site and cannot reproduce it.
Comment: Thanks @alexce for your help. Here is the temporary logindata to test it on the live website to be used in the script : login_user = stacktest , login_pass = stacktest. Can you try pls?
Comment: @linguisttoo okay, what is `fill_login_form`?
Comment: Oh, yes, this is the code that automatically identifies login form items from the supplied page. I installed it through pip ….. "pip install loginform".

How to get through the form with scrape


Clarification of Equation for Variational Inference in Pattern Recognition and Machine Learning

Question: I am looking at the derivation of variational inference and specifically the approach taken by Bishop in his book on page 465 as illustrated in the Figure below. The key step is the statement below Equation 10.8 in which he says "... Thus maximizing (10.6) is equivalent to minimising the KL Divergence, ..."

However in the Errata document for the book that was created by Yousuke Takada the relevant clip is shown below in the Figure:

We see the statement "However, there is no point in taking the Kullback-Leibler
divergence between two probability distributions over different sets of random variables;
such a quantity is undefined."
So my questions are, is the statement made by Takada correct, and if so what is the correct derivation of the variational inference algorithm. Secondly, if the statement is incorrect, what is the expression for the KL-divergence of the form presented in Equation (10.6) and how does that form relate to the derivation of the variational inference algorithm?
Answer: Having spent a few days exploring various derivations of variational inference, I thought I could answer my own question, at least to provide an historical record and closure.
I think the answer comes down to notation differences which in itself raises a question. Anyway, to the answer, I believe that both representations are the same, and by that I mean the following.
First equation (10.7) in Bishop is the same as equation (171) in Takada to put this explicitly we have:
\begin{equation}
\begin{aligned}
\ln \tilde{p}(\boldsymbol X, \boldsymbol Z_j) &= \mathbb{E}_{i \neq j} [ \ln p(\boldsymbol X, \boldsymbol Z)] + \operatorname{const} \text{ - (10.7)} \\
\ln q^*_j(\boldsymbol Z_j) &= \mathbb{E}_{\boldsymbol Z \backslash \boldsymbol Z_j} [ \ln p(\boldsymbol X, \boldsymbol Z)] + \operatorname{const} \text{ - (171)}
\end{aligned}
\end{equation}
The definition for the expectations is the same but a different notation, basically both exclude the $j^{th}$ component.
With that equivalence stated, then equation (10.6) is the same as (168) which can be seen if we inserted (10.7) into (10.6). And finally, (10.8) is the same as (170).
So the summary is that both formulations are saying the same thing, and the main point of contention is the use of $\tilde{p}(\boldsymbol X, \boldsymbol Z_j)$ over $q^*_j(\boldsymbol Z_j)$.
This I guess is where notation seems to fall down. In the spirit of the derivations, in the expectation, it is implicitly assumed that the observed data $\boldsymbol X$ is held constant. This is recognized in (171) but left "hanging" in (10.7). The observed data is variable but held constant, so it is not clear (to me) what the correct way of representing this should be, and whether this truly invalidates the definition of the KL-divergence?


Merging several text files line by line in python

Question: I'm a network engineer by trade, new to python, and this question will be applied to access lists on routers but for simplicity I am going to use States and Cities.
I have several text files (two below) that contains lines of States and Cities as shown:
File1
Texas
Austin
Dallas
Houston
San Antonio

File2
Texas
Amarillo
Austin
Dallas
San Antonio
Waco

I need to merge these two files and spit out a new text file that looks like the one below:
Texas
Amarillo
Austin
Dallas
Houston
San Antonio
Waco

The positioning has to be precise in such a way that since file1 is missing Amarillo compared to file2, and file2 has Amarillo on top of Austin, then merged file will have Amarillo on top of Austin or below Texas in the resulting file. The same thing applies if it was the other way around where file2 is missing some cities compared to file1.
I'm not too sure how to start this script. A guiding hand would be appreciated!
thanks!
Comment: Welcome to Stack Overflow! What have you tried to do?
Comment: You could start by reading the contents of the two files into two lists. It's not relevant to the problem that this data is stored in a file. It takes minimal effort and reduces the scope of your question. We really don't want to have to teach you how to read and write files.
Comment: I've been using PyCharm to create some of the simpler scripts and there is a tool on there that lets you compare two files and then merge. I'm able to get my goal done through it but I have several files to merge so it's not scalable.
Comment: @Aran-Fey I understand that you don't want to teach how to read and write files. And that's ok. I do have simpler scripts that parse through router configs and write out to a file with anything I want. Now my next goal is to compare them and merge. I just started with Python so a bit of help would be nice. But if it's a bother, that's ok too.
Comment: Would you mind if I went ahead and edited your question so that the data is provided as two lists rather than two files?
Comment: I'm not too sure if presenting the question as two lists would give it context. But I guess that would make it clear. Go ahead. The data, before I write them out to files, are already on dictionaries with key as the "state" and values as cities (list). Just wasn't sure how to move forward with actual merging.
Answer: Here's one simple way to do it:
#! /usr/bin/python3
from sys import exit

def w(data, title):
    with open('f3.txt', 'w') as file_out:
        file_out.write(title + '\n')
        for line in data:
            file_out.write(line + '\n')

def r(path):
    with open(path) as file_in:
        lines = file_in.read().split('\n')
    return [l for l in lines if l]

def combine(path1, path2):
    f1 = r(path1)
    f2 = r(path2)
    title1 = f1.pop(0)
    title2 = f2.pop(0)
    # ensure Texas is the first line in each file
    if title1 != title2:
        print("Titles do not match")
        exit()
    w(sorted(set(f1 + f2)), title1)

if __name__ == "__main__":
    combine('f1.txt', 'f2.txt')

Here's the directory/file content before and after running:
james@rootVIII:~/Desktop$ ls
delete  f1.txt  f2.txt  test.py  utils
james@rootVIII:~/Desktop$
james@rootVIII:~/Desktop$ cat f1.txt
Texas
Austin
Dallas
Houston
San Antonio
james@rootVIII:~/Desktop$
james@rootVIII:~/Desktop$ cat f2.txt
Texas
Amarillo
Austin
Dallas
San Antonio
Waco
james@rootVIII:~/Desktop$
james@rootVIII:~/Desktop$ ./test.py
james@rootVIII:~/Desktop$
james@rootVIII:~/Desktop$
james@rootVIII:~/Desktop$ cat f3.txt
Texas
Amarillo
Austin
Dallas
Houston
San Antonio
Waco

Some things to note:

This expects "Texas" or the state name to be the first entry in each text file (f1.txt and f2.txt)
Turning a list into a set removes duplicates
The combine() method can accept a relative or absolute paths
The list comprehension [l for l in lines if l] returns a list without empty elements (because the string was split with a newline)... If split on whitespace you'll get San instead of San Antonio
Comment: I'll play with this one. Thank you!
Comment: Okay if it works just remember to mark answer as correct please and thank you :)
Comment: I can build upon this one. Thanks!


What is the mistake in this approach to find the average

Question: The captain of a Football team of 11 members is 26 years old and the GoalKeeper is 3 years older. If the ages of these two are excluded, the average age of the remaining players is one year less than the average age of the whole team. What is the average age of the team?
Answer : 23 years.

my (wrong) solution :

<code>Let the total Age of the Team be "x" . ---> equation (1)

Average of the team = x / 11

According to the question :

The average age of the team (Excluding Captain and GoalKeeper)

Total age of the team - (captain's age - GoalKeeper's age) / 9 .

Captain age = 26 , Goal Keeper age = 29 . Total age to be removed = 55

x - 55 / 9

Given in the question is that this average is one year less than the
the average of the whole team .

[x-55/9] - 1 = x / 11

solving this equation . x = 352 .

according to equation(1) 352 / 11 = 32 (average age of the team)
</code>

This however is the wrong answer . Where have i gone wrong ?
Comment: $x-55/9\neq (x-55)/9$.
Comment: a little more detail ? . is the approach itself wrong or is there a calculation error ?
Answer: When you compute the average age of the team without the captain and goalkeeper it should be (total age of team-captain's age-goalkeeper's age)/9.  You put the opening parenthesis before the captain's age so the total age of the team would not be divided by $9$.  You also subtracted the $1$ year from the wrong side as we are told that removing them lowers the age.  You then would get
$$\frac {x-55}9=\frac x{11}-1\\ \frac {2x}{99}=\frac {46}9\\ x=253$$
and the average age is $$\frac {253}{11}=23$$
Answer: Plus 1 instead of minus 1. $$\frac{x-55}9+1=\frac x{11}.$$ Leads to $x=253$.
Answer: Let $N$ be the sum of the ages of the other players.
So the total sum of all the players' ages is $N + 55$
We know that
$N/9 = (N+55) / 11 + 1$
Which gives
$N = 198$
So the total age of the players is $198 + 55 = 253$
So the average age of all the players is
$253 / 11 = 23$
Answer: Firstly, the age of captain is 26 and goal keeper is 29.
let x be the average of the team including captain and goal keeper.
Let y be the average of team excluding captain and goalkeeper.
y=x-1
Compute x (Average of team including captain and goalkeeper)
= (Sum of ages of nine players+age of captain + age of goal keeper)/11
Computer y (Average of team including captain and goalkeeper)
= (Sum of ages of nine players)/9
As y=x-1
(Sum of ages of nine players)/9 = (Sum of ages of nine players+age of captain + age of goal keeper)/11 )-1
Solve this equation:
(Sum of ages of nine players)/9 =(Sum of ages of nine players+age of captain + age of goal keeper -11)/11.
Use cross multiplication technique
11(Sum of ages of nine players)= 9(Sum of ages of nine players)+9(age of captain)+9(age of goalkeeper)-99
2(Sum of ages of nine players) = 9(age of captain)+9(age of goalkeeper)-99
2(Sum of ages of nine players) = 9(26)+9(29)-99
2(Sum of ages of nine players) = 234+261-99
2(Sum of ages of nine players) = 495-99
2(Sum of ages of nine players) = 396
Sum of ages of nine players = 396/2 =198
Now compute x
x = (Sum of ages of nine players+age of captain + age of goal keeper)/11
x = (198+26+29)/11
x = 253/11
x= 23
to check whether your answer is correct computer y and check whether y =x-1.


definite integration of a function in terms of a composite function over a log-transformed domain

Question: Let $f(x) = g(w)$, where $w=\log(x)$.  Can the definite integral $F(b) - F(a) = \int_a^b f(x) \,dx$ be expressed as an integral involving $g(w)$ over the corresponding log-transformed interval (that is, from $\log(a)$ to $\log(b)$)?
Answer: Yes. $\frac {dx} {dw }=e^{w}$ so   the integral becomes $\int\limits_{\log a }^{\log b} g(w)e^{w}dw$.


C#: Exception "Input string was not in a correct format." after Row.Delete in DataSet

Question: I am getting a strange exception when trying to update a DataTable after flagging a row for deletion. It looks like it's validating the data in the row I'm trying to delete. I was able to save the same row successfully, why won't it let me delete it?
Using C# in VS 2008 and SQL Server CE.
The essential bits (I hope) of my code:
<code>var listDataTable = new booksDataSet.ListDataTable();
this.tableAdapterManager1.ListTableAdapter.Fill(listDataTable);
listDataTable.Rows[0].Delete();
this.tableAdapterManager1.ListTableAdapter.Update(listDataTable);
booksDataSet1.List.AcceptChanges(); // exception here
</code>
The exception is:
System.FormatException was unhandled
  Message="@p2 : foo - Input string was not in a correct format."
  Source="System.Data"
I've reduced this to a very simple table:
Id (PK, int, not null)
Name (nvarchar(100), not null)
Notes (nvarchar(4000), null)
The data in the row I'm trying to delete (first row) is Name = "foo", so it is the correct row, but why does it care what the data is before deleting the row?
Comment: What does the AcceptChanges method do? Are you using an ORM?
Answer: You need to do a trace on the app (try running it on your local copy of SQL Server and run the 'Profiler'); my guess is when the SQL query is hitting your SQL Server, part of it isn't in the correct format.  I bet you'll see the problem when you run a trace.
Comment: Thanks. I will try, since that sounds like a debugging technique I should know.

Your answer did point me in the right direction. I opened the DataSet in the designer and checked out the Update statement for the adapter. It was wrong; I regenerated it and now it works.
Answer: I get the same response.  If I bind with {0:c} it will fail on delete every time.  Thinking it was the $ I tried {0:N2} same response.  Remove it, deletes just fine.


Sketches of proofs written in English that show that first-order logic is complete?

Question: I came across the following in a textbook:

$\mathcal{L}$ is a language.  $\alpha \in \mathcal{L}$ is a formula. $\alpha \frac{c}{x}$ means: replace every instance of $c$ in $\alpha$ by $x$.
I am not sure I understand the sketch of this proof. Part of the issue I am finding, as I go through logic texts, is that the notation isn't the most illuminating.
Thus, I am wondering, may I have a sketch of proofs that show that boolean algebra is complete, using as much English as possible? (A sketch of a proof is something that is not a proof, but merely outlines how one would start the proof, or what strategy one would employ.)
Comment: It seems to be about *predicate logic*. The sentence 'Boolean algebra is complete' adds a little confusion..
Comment: @user89 I'm afraid the notation could hardly be made any easier, and the terminology used is just the standard terminology of FOL. Abstract concepts and involved proofs requie a minimum of notation and terminology; that's not a fault of the textbook, that's just how math works.
Comment: @user89 While this is not my favorite notation by any means, it's not too dissimilar to many other popular notations. Either way, learning to deal with potentially bad and certainly a variety of notations *is also something you'll need to learn*. Yes, it is annoying that there is a variety of notations, but given how bad old notations used to be, I'm glad people didn't feel too tied to them.
Comment: The notation isn't going to go away or reduce as you proceed, so avoiding it doesn't seem like a good strategy. Also, with a few minor exceptions, most of the "notation" is just the things themselves. Formulas like $\neg\alpha$ are pieces of syntax, just symbols, they don't have meaning. $\equiv$ is a relation between formulas, so it's saying something that could arguably be written out in English, but I doubt that would be too helpful (except by making it more clear that it doesn't mean equality and that it's acting on these formulas). At any rate, there appears to be a typo in (1).
Comment: $\alpha\frac{x}{c}$ means "replace every instance of $x$ in $\alpha$ by $c$", not the other way round.
Comment: @Derek Elkin I don't think there's a typo in (1): The equivalence of  $\neg \alpha^x$ to $\exists x \neg \alpha \to \neg \alpha \frac{c}{x}$ works out, and this is just the negative variant of a Henkin formula for positive $\alpha$, $\exists x \alpha \to \alpha \frac{c}{x}$. The problem is that this positive formulation of $\alpha^x$ for positive $\alpha$ (let's call it (2)) is not equivalent to (1): (1) implies (2), but not the other way round. So (1) is a weaker statement. But apperently this is sufficient to construct a (complete) Henkin theory.
Comment: Corr.: In that case (1) is actual a stronger formulation, not weaker.
Comment: @DerekElkins The issue is that the choice of notation is frankly just awful, and the choice of terms is even more awful. Even worse, different textbooks have just the right "variation" in notation that it becomes a terrible exercise in trying to figure out what everyone means.
Comment: The second part of [this old answer of mine](https://math.stackexchange.com/a/2099585/28111) (from "Having acknowledged that GCT is counterintuitive" to "See e.g. these two questions, respectively") gives a very quick introduction to the proof. If you find that style useful, I can write a more detailed summary in that spirit. Your comments to the answer below, however, suggest that aren't comfortable yet with structures/models/$\models$; those are really prerequisites to understanding the completeness theorem, so - if that's the case - I'd focus on them separately first.
Comment: @lemontree Sorry, but I disagree. [Then again, I am from an unorthodox school of thought, given my education.](http://www.cs.toronto.edu/~hehner/FMSD/) Too enamoured by Leibniz's dream?
Comment: @lemontree I think I found something which is much more along the lines of notation I am used to: http://www.cs.cornell.edu/home/gries/Logic/Equationalhistory.html (see the note on soundness and completeness for equational logic)
Comment: @lemontree I might have misparsed (1).
Comment: @user89 If you don't like notation like "$\vDash$" but want something 'descpritive', then everytime instead of writing "$\phi \vDash \psi$" you could write "$\phi$ semantically entails $\psi$", but if you don't like that either, you'd have two write "For all pairs of structures $\mathfrak{A}$ and assignment functions $v$, if $\mathfrak{A} \vDash_{v} \phi$, then $\mathfrak{A} \vDash_{v} \psi$, and if this is yet too much notation and terminology, then you'd have to write...
Comment: ... "For all pairs of a domain of objects and a a function which interprets the non-logical symbols and a function which maps the variables of the language to objects in the domain, if $\phi$ evaluates to true under that pair of domain and interpretation function and and function which maps the variables to objects of the domain, then $\psi$ evalutes to true under the same pair of domain and interpretation function and function which maps the variables to objects of the domain", but that certainly won't make the proof *easier* to read.
Comment: There's a point to using terminology and symbols. If you don't understand a term or symbol, then look up its definition (you can't get any more precise than the definition), and if you don't understand the definition, then look up the definition of the first word or symbol you don't understand about the definition. Eventually you will reach basic mathematical concepts like "function" or "if ... then ..." which you just have to take as primitive.That being said, the proof of completeness for FOL is a step or two more involved than the logic you'll need for a course on software design.
Answer: In order to prove completeness of a calculus, we need to show that any consistent theory $T$ has a model, that is, we need to find an $\mathcal{L}$ structure $\mathfrak{A}$ such that $\mathfrak{A} \vDash T$. This is achieved by constructing so-called Henkin theories. It is possible to show that any complete Henkin theory has a model. So the goal is to "henkinize" a given theory, i.e. extending the theory $T$ to a Henkin theory $T_H$, which is then extended to a complete Henkin theory in a next step.
The first step towards the construction of such a Henkin theory is what is done here: Your textbook snippet defines the "Henkin formulas" which will be added to the theory $T$ to arrive at a Henkin theory $T_H$.
In a Henkin theory $T_H$, any existential statement $\exists x \alpha \in \mathcal{L}$ (note: any existential statement of the language $\mathcal{L}$, not just those in $T_H$!) is "witnessed" by an individual constant $c$. This means that if we claim that $\alpha$ is true for some $x$, then we need to be able to provide a concrete term $t$ that provides evidence for this claim, hence the name "witness". For example, in the language of Peano arithmetic with a symbol for $>$, if we claim that $\exists x(x > 0)$, then we want to find a concrete instance of $x$ that satisfies this property (in this acse, this could be $s(0)$). This concrete instance is denoted by an individual constant $c$. (We later need to extend the alphabet of our language to include all of these witnesses $c$; this will result in the Henkin language $\mathcal{L}_H$, in which the Henkin theory $T_H$ of a theory $T$ can be axiomatized.)
In our example, $\alpha = x > 0$ (note that $\alpha$ contains a free variable $x$), and $\alpha\frac{c}{x}$ just means that $x$ is substituted by $c$, so here $\alpha\frac{c}{x} = c > 0$.
Note that this is an implicative statement, so the individual denoted by $c$ does not necessarily need to have the property $\alpha$: We only have $T_H \vDash \alpha\frac{c}{x}$ in case $T_H \vDash \exists x \alpha$.
So in a Henkin theory $T_H$, we want that the formula $\exists x \alpha \to \alpha\frac{c}{x}$ is $\in T_H$ for any $\alpha$. To define this "Henkin formula" for any $\alpha$, we can introduce the notation $\alpha^x$, and write it as
$$(1') \quad \alpha^x := \exists x \alpha \to \alpha\frac{c}{x}$$
Now suppose that a formula has the form of a negated statement, for example $\alpha' := \neg \alpha = \neg (x > 0)$. Then the Henkin formula becomes
$$(2) \quad (\neg \alpha)^x = \exists x \neg \alpha \to \neg \alpha \frac{c}{x}$$
This means that under the assumption $\exists \neg \alpha$, there is a witness $c$ that provides evidence for $\neg \alpha$, and therefore a counterexample to the validity of $\alpha$.
This is precisely what your textbook snippet says. It is easy to see that this is equivalent to the negation of (1):
$(\neg \alpha)^x\\
\equiv \exists x \neg \alpha \to \neg \alpha \frac{c}{x}\\
\equiv \neg(\exists x \neg \alpha \land \neg \neg \alpha \frac{c}{x})\\
\equiv \neg(\neg \forall x \alpha \land \neg \neg \alpha \frac{c}{x})\\
\equiv \neg(\neg \forall x \alpha \land \alpha \frac{c}{x})\\
\equiv \neg(\alpha^x)$
So we can deduce the unintuitive formula (1) by starting with the more intuitive implicative formulation (1') and inserting a negative formula $\neg \alpha$ as in (2).
However, for positive formulas $\alpha$, (1) = $\alpha^x$ is not equivalent to the implicational formulation (1') of the Henkin formula:
We have
$$(1) = \neg \forall x \alpha \land \alpha \frac{c}{x} \vDash \exists x \alpha \to \alpha \frac{c}{x} = (1')$$
(since $\neg \forall x \alpha \land \alpha \frac{c}{x} \vDash \alpha \frac{c}{x} \vDash \exists x \alpha \to \alpha \frac{c}{x}$)
but
$$(1') = \exists x \alpha \to \alpha \frac{c}{x} \not \vDash \neg \forall x \alpha \land \alpha \frac{c}{x} = (1)$$
(since if $\mathfrak{A}, v \not \vDash \exists x \alpha$ and $\mathfrak{A}, v \not \vDash \alpha \frac{c}{x}$, then $\mathfrak{A}, v \not \vDash \exists x \alpha \to \alpha \frac{c}{x}$ but $\mathfrak{A}, v \not \vDash \neg \forall x \alpha \land \alpha \frac{c}{x}$).
So (1) $\vDash$ (1') but (1') $\not \vDash$ (1), hence (1) is a stronger statement than (1'): All situations (here: combinations of structures $\mathfrak{A}$ and assignments $v$) where (1) is true are also situations where (1') is true, but not the other way round, so there are fewer cases where (1) holds than where (1') holds, i.o.w. fewer structures which will manage to satisfy (1) than (1'), so (1) manages to exclude more possibilities (if you imagine a structure as a "possibility of what the universe could look like", you managed to exclude more such possibilities), hence it is a stronger, more informative claim than the more intuitive (and I think more common) Henkin formula (1').
Your textbook will show how the construction of a Henkin theory - and its extension to a complete Henkin theory for which we can prove the existence of models - will work for this more unintuitive, stronger formulation of Henkin formulas, but the idea is the same: For any existential statement, we want to have a witness in the form of an individual constant denoting a concrete object that provides evidence for this existential claim, and likewise, in the case of an existential negated statement, we want a witness that proves the invalidity of the unnegated statement. This is exactly what is done here.
Comment: Thank you for this answer. However, can I ask some fairly "stupid" questions, and ask you to update your answer with their answers? (I'll also be very happy to give a large bounty.)
Comment: 1) A model is simply a choice of instantiation for each free variable in each formula. Yes? If so, can you replace the word model with something more appropriate?
Comment: 2) What does $\mathfrak{A} \vDash T$? Let $\alpha$ be a formula, then $\vDash \alpha$ means that every choice of instantiation for all the free variables in $\alpha$ causes $\alpha$ to be evaluated to $\top$. Is this correct? In this context, what does $\mathfrak{A} \vDash T$ mean? That every formula in $T$, when instantiated with constants in $...$ evaluates to $\top$? What should fill $...$?
Comment: 3) Can we avoid the use of honorifics in this answer? For instance, instead of saying "Henkin theory", can we say "$...$ theory", where $...$ is something descriptive?
Comment: 4) What does "positive formula" mean? Does if $\alpha$ is positive, does it mean that $\alpha = \top$?
Comment: 5) I'm sorry, but you will really have to clarify the definition of $\vDash$ for me. Please don't say "semantic entailment" :(
Comment: 6) I really like this explanation of yours: *For any existential statement, we want to have a witness in the form of an individual constant denoting a concrete object that provides evidence for this existential claim, and likewise, in the case of an existential negated statement, we want a witness that proves the invalidity of the unnegated statement. This is exactly what is done here.*

I would love something more along those terms. For instance, once I have constructed such an extended language, where every existential quantifier statement has a "witness", what then?
Comment: At this point I really think it makes more sense for you to first get more familiar with basic concepts of FOL before trying to understand the completeness theorem. If you're still struggling with things such as $\vDash$ or "model", then any further explanation of Henkin stuff will likely confuse you just as well, and explaining the meaning of $\vDash$ is definitely outside the scope of this question.
Comment: So my suggestion is: Have another thorough reading through the chapter on first-order logic in your textbook, especially on the definitions of $\vDash$ and "structure"/"model"; if that leaves questions open, search MathSE for respective questions or ask a new one. Once your questions 1), 2), 5) (which are questions about the basics of FOL) have resolved themelves, then come back here and I will gladly answer your questions 3), 4), 6) (which are about the completeness proof; though 6) is a bit unspecific).
Comment: You only can start a bounty after the question has been online for 48 hours anyway, so use that time (or longer) to familiarize yourself again with the basic notation and terminology, that will make it much easier for you to understand my (or other people's) answer.
Comment: Okay, no problem. I'll write up an answer for myself which is closer to what I am looking for. The issue really hasn't been how much time I have spent trying to parse at least 3 different texts on logic, as much as my own limited intellect.


How can i make a Unity App run in the new Xcode?

Question: Hi i am having a problem with the new Xcode 4.2. I am working with Unity and everytime i try to run my apps on a  device it give me a message like that:
<code>Nov 18 11:34:57 unknown multiplayertester[3670] <Warning>: -> registered mono modules 0xcbafb8
Nov 18 11:34:58 unknown kernel[0] <Debug>: launchd[3670] Builtin profile: container (sandbox)
Nov 18 11:34:58 unknown kernel[0] <Debug>: launchd[3670] Container: /private/var/mobile/Applications/D691EFA3-1EC8-4F8A-A4FB-90329945C4B4 [69] (sandbox)
Nov 18 11:34:58 unknown UIKitApplication:com.XXXXXXXXX.multiplayertester[0x1d92][3670] <Notice>: -> applicationDidFinishLaunching()
Nov 18 11:34:58 unknown com.apple.launchd[1] <Warning>: (UIKitApplication:com.XXXXXXX.multiplayertester[0x1d92]) Exited with code: 1
Nov 18 11:34:58 unknown SpringBoard[15] <Warning>: Application 'realtest' exited abnormally with exit status 1
</code>
I have been searching everywhere and nobody could answer me. Thank You
Answer:
You should use Unity 3.4.2 if your device is iPhone or use Unity 3.4.1 with iPad.
"Exited with code: 1" means you that should reset Xcode or your Mac.
Multiple Xcode 4.2 compilation errors.

At the moment for Xcode 4.0 and later you need manually select proper build target (scheme) and proper target device. That's described on manual page:  http://unity3d.com/support/documenta...roubleShooting


Keyword 'Selenium2Library.Click Element' expected 1 to 3 arguments, got 0

Question: I'm trying to select the first item from the list below using robotframework:
<select id="organization_saml_enabled" name="organization[saml_enabled]">
   <option value="true">SAML SSO enabled</option>
   <option value="false" selected="selected">SAML SSO disabled</option>
</select>

With this snippet:
Click Element  //select[@id="organization_saml_enabled"]/option[@value="true"]

I get the error Keyword 'Selenium2Library.Click Element' expected 1 to 3 arguments, got 0.
I dont get it because from the way i understand the documentation the Click Element needs the locator and optional offsets.
Can anyone help me check what I'm missing here.
Comment: I honestly don't think it's possible to get that exact error with that exact line of code. Are you absolutely certain that it's this specific line of code which causes this exact error?
Answer: Add locator strategy (xpath:) before the actual locator and remember to have at least two spaces between keyword and argument:
Click Element    xpath://select[@id="organization_saml_enabled"]/option[@value="true"]

Comment: I also noticed that if i used the `Run Keywords` and chain that key word with another one the keyword failed. That is what maybe was causing the issue so i decided to split the keywords and execute them separately instead on chaining them based on a certain condition.
Comment: In `Run Keywords` case, you'll have to use `AND` between keywords.

E.g.: `Run Keywords    Keyword1   argument    AND    Keyword2    argument2    argument3`
Answer: dont use Selenium2Library, use SeleniumLibrary latest version.
Comment: [so] is not a forum. This is not an answer to the question.
Comment: The issue could of also been to this to, as the keywords differ in these versions. This was intended as a 'partial answer'///


A book that contains a proof on the infinity case of L' Hospitals Rule

Question: I own three calculus books and all of them prove the $\displaystyle\frac{0}{0}$ case but none even give a rough idea for the $\displaystyle\frac{\infty}{\infty}$ case. Any books I can see pdf's of that do prove it? I would prefer to see a proof that does not use the epsilon delta proof for now. Don't get me wrong, I do not hate epsilon delta proofs. I just want to see the proof without it for now. Thanks!
Comment: If my memory serves me well Tom Apostol's calculus book contains a geometric proof of the $\infty/\infty $ case.
Comment: The best reference in this case is the proof given in wikipedia https://en.wikipedia.org/wiki/L'H%C3%B4pital's_rule
Answer: The $\frac{\infty}{\infty}$ case is not very different and if you have proved the $\frac{0}{0}$ case you can use that to prove the former one.
Consider
$$\lim_{x\to h}\frac{f(x)}{g(x)}$$
where $\lim_{x\to h}f(x)=\lim_{x\to h}g(x)=\infty$
Let $f_2(x)=\frac{1}{f(x)}$ and $g_2(x)=\frac{1}{g(x)}$ so $\lim_{x\to h}f_2(x)=\lim_{x\to h}g_2(x)=0$ and:
$$\lim_{x\to h}\frac{f(x)}{g(x)}=\lim_{x\to h}\frac{g_2(x)}{f_2(x)}$$
You can then use the $\frac{0}{0}$ prove to then prove this.
Comment: We have $f/g$ in the $\infty/\infty$ case. We want $f'/g'\to L \implies f/g \to L.$ The suggestion is to look at $(1/g)/(1/f),$ which puts us in the $0/0$ case. So if we can show $(1/g)'/(1/f)' \to L,$ we'll be done. How does $f'/g'\to L \implies (1/g)'/(1/f)' \to L?$
Comment: @imranfat: put $x = 1/y$ and let $y$ tend to $0$.
Comment: This answer shows intuitively why LHR applies in the $\infty/\infty$ case, but it is not a valid proof, petitio principii.  As hinted by @zhw $(1/g)'/(1/f)' = (f/g)^2(f'/g')^{-1}$.  Given only that $f'/g' \to L$ we cannot conclude that $(1/g)'/(1/f)' \to L$ because that assumes $f/g$ converges - which is what must be proved.
Comment: And how would the proof go if you get an infinity over infinity situation for $x$ going to infinity?
Comment: ok thanks. makes sense


Microsoft Azure SQL Server with Single Database

Question: I have created a Single SQL Database and a SQL Server on Microsoft Azure with a Basic Plant of MAX 2GB. Now I want to create another SQL Database of MAX Size 2GB. Can I create another SQL Database under same SQL Server created earlier? OR I have to create another SQL Server for another SQL Database?
I asked this question because MS Azure Single SQL Database word is making confusion.
Answer: Yes, You can create another Azure SQL DB. When creating DB you can use the existing server or new server


Contar inputs de tipo radio que estão :checked

Question: Estou com dois inputs em cada grupo com name iguais, aonde cada um tem values diferentes, inteiro e metade
Usando o if e else ou outra maneira, gostaria de contar os inputs que estarão checked.

Quando falo do if e else eu imagino que seria um jeito de " Se o botão estiver checked adicione++; Caso contrário --subtraia;

Como meu conhecimento é bem raso, adoraria comentários sobre a lógica de uma função assim.
https://jsfiddle.net/he0fch08/
Deixei para vocês verem mais ou menos a ideia. Comentei o último else no javascript pois esse já está fugindo muito.
Exemplo da situação seria a seguinte,

Começou o programa
Dê check no 1º input do grupo[0].
Veja o resultado - Vai aparecer 1 e 0.
Seleciona o 2º grupo[0] - Vai aparecer 0 e 1.
Quando voltasse a escolher o grupo[0], era pra ficar 1 e 0 novamente, mas ai já acontece o primeiro desencontro - Aparecendo 1 e 1.
E assim, em diante ir somando com as escolhas dos demais inputs.
Comment: O objetivo é contar quantos inputs de metade estão `checked` e quantos inputs de `inteiro` estão `checked` ?
Comment: Cara não entendi o que você quer fazer.
Comment: Isso mesmo @Isac, eu estou arrumando a pergunta e o exemplo, eu estava muito cansado quando fiz ela, realmente ficou confuso!
Comment: @CaiqueRomero, vou arrumar ela, mas é o que o Isac comentou, realmente a pergunta que fiz está bem confusa.
Answer: Se apenas pretende contar quantos inputs para metade e inteiros estão selecionados pode fazer tudo à custa do seletor.
Para isso irá necessitar de incluir no seu seletor:

[type=radio] para incluir apenas os radio buttons
[value=inteiro] ou [value=metade] para apanhar apenas os que tem o value que lhe interessa
:checked para serem so os selecionados

Depois é so saber a quantidade de elementos obtidos consultando o length.
Exemplo:

function resultado(){
  let metades = $("input[type=radio][value=metade]:checked").length;
  let inteiros = $("input[type=radio][value=inteiro]:checked").length;
  console.log("Inteiro(s) " + inteiros, "Metade(s) " + metades );
}

<input type="radio" name="nome[]" value="inteiro"/>inteiro[]
<input type="radio" name="nome[]" value="metade"/>metade[]

<input type="radio" name="nome[1]" value="inteiro"/>inteiro[1]
<input type="radio" name="nome[1]" value="metade"/>metade[1]

<input type="radio" name="nome[2]" value="inteiro"/>inteiro[2]
<input type="radio" name="nome[2]" value="metade"/>metade[2]

resultado - clique.

Comment: Gostei da forma como usou os seletores em conjunto com o length, muito prático +1
Comment: @Yemoja Para este caso não faz diferença, foi mesmo força de habito. A ideia base é como disse limitar escopo, que acaba por apenas lhe trazer vantagens.
Comment: @isac, o motivo de declarar a variável com `let` tem algo em especial pra esse caso ? - Vi que `let` está relacionado com limitar a variável para um escopo de bloco.
Answer: Basicamente mudei o seletor, para buscar os <input> por name e trazer somente os checkados.
Depois verifico os valores marcados e a incremento as variaveis inteiro e metade.

function resultado(){
  var opcoes  = [];
  var inteiro = 0;
  var metade  = 0;
  opcoes[0] =document.querySelector("input[name='nome[]']:checked");
  opcoes[1] =document.querySelector("input[name='nome[1]']:checked");
  opcoes[2] =document.querySelector("input[name='nome[2]']:checked");

  for(i=0;i<opcoes.length;i++){
    if(opcoes[i]){ //Verifico se uma opção foir marcada
      if(opcoes[i].value == 'inteiro')//se foi marcada verifico o valor
        inteiro++;
      else
        metade++
    }
  }

  console.log('A quantidade de "inteiro" marcados é:' + inteiro);
  console.log('A quantidade de "metade" marcados é:' + metade);
}

      <input type="radio" name="nome[]" value="inteiro" id="i"/>
      inteiro[ ]

      <input type="radio" name="nome[]" value="metade" id="m"/>
      metade[ ]

      <input type="radio" name="nome[1]" value="inteiro" id="i1"/>
      inteiro[1]

      <input type="radio" name="nome[1]" value="metade" id="m1"/>
      metade[1]

      <input type="radio" name="nome[2]" value="inteiro" id="i2"/>
      inteiro[2]

      <input type="radio" name="nome[2]" value="metade" id="m2"/>
      metade[2]

    Clique para visulizar a quantidade de opções 'inteiro' e a quantidade de opções 'metade' marcadas:


Where can I find online/live and accurate and multi versioned Jersey documentation?

Question: Since java.net has been shut down where can I find an online documentation for Jersey 2.0? Github repo contains docbook only. Docs.oracle.com is a nightmare and does not contains the info I need.
Comment: Possible duplicate of [java.net site closed, not able to access jersey documentation](http://stackoverflow.com/questions/43976613/java-net-site-closed-not-able-to-access-jersey-documentation)
Answer: Jersey 2.23 User Guide is available on the github site: https://jersey.github.io/documentation/latest/index.html


Why should we use the uniform boundedness principle here?

Question: Here is the question:
Let $A = [a_{ij}]_{i,j = 1}^{\infty}$ be an infinite matrix of real numbers and suppose that, for any $x \in \ell^2,$ the sequence $Ax$ belongs to $\ell^2.$ Prove that the operator $T,$ defined by $T(x) = Ax,$ is a bounded operator on $\ell^2.$
My question is:
I got a hint to use the uniform boundedness principle here but I do not know why, could anyone explain this to me, please? what makes me when I look at a problem to decide that it should be solved by UBP?
EDIT:
1-I have taken this proposition: "The series $\sum_{n =1}^{\infty} a_{n} b_{n}$ converges absolutely for every convergent sequence $\{b_{n}\}$ iff $\sum_{n =1}^{\infty} |a_{n}|$ converges." will it be helpful here in our case? the problem is that here in our case we are in $l^2.$
2-Also, Should it be better to use the uniform boundedness principle or the following theorem to solve the problem given above?
Theorem:
Let $X,Y$ be Banach spaces and let $\{T_{n}\}_{n=1}^{\infty}$ and $T$ be operators in $\mathcal{L}(X,Y).$ then $\lim_{n} T_{n}x = Tx,$ for all $x \in X,$ iff
(a)the sequence $\{T_{n}\}$ is bounded;
(b)lim_{n} T_{n}x exists on a dense subset of $X.$
Comment: Let $A_n$ be the top-left $n\times n$ matrix (zeroing out everything else), then for each $x$, $\sup_n \|A_n x\|_2 < \infty$ and by the uniform boundedness principle, $\sup_n \|A_n\| < \infty$. Finally note that $Ax$ is the pointwise limit of $A_nx$.
Comment: Such questions are usually hard to answer. There is really no protocol. So, you want to show that $\|Ax\|$ is uniformly upper bounded for all unit vectors $x$. Now you are dealing with infinite sums and you need to use the fact that $Ax\in \ell^2$ for all $x$. Thus you may need to use special $x$'s to get something. It is a typical idea to approximate $A$ by finite-rank matrices (if you are taking a functional analysis course, you will see more examples like this when you're studying compact operators)...
Comment: You can use Cauchy-Schwarz to show that $T_N$ is bounded.
Comment: @user58955 could you provide more details, please? Also, what about my question above? How do I know that I should apply UBP?
Comment: and here the easiest thing to do is to take $n\times n$ submatrix, corresponding to taking $x$ with only finitely many nonzero coordinates. Then you will see that UBP helps.
Comment: why I should use special $x'$s and to get what? @user58955
Comment: This is what is ad hoc. You plug in special values of $x$ to obtain something for the purpose of the problem. Here, since you have a $\ell_2$ sequence, it is again a typical attempt to approximate $x$ (which may consist of infinitely many nonzero coordinates) by its finite truncations: $(x_1,0,0,0,\dots), (x_1,x_2,0,0,\dots), (x_1,x_2,x_3,0,\dots)$. It may work and it may not work. But you can try that and see what you get afterwards.
Comment: I got a hint to define $$T_{N}x = (\sum_{k=1}^{N}a_{ij}x_{j})$$ is this the same idea you are trying to convey to me? @user58955
Comment: Yes, it's exactly the same as what I said.
Comment: where is the truncation here? I can not see it. where is taking $x$ with finitely many nonzero terms?I can not see this in this hint.@user58955
Comment: How can I verify that this $T_N$ is bounded?@user58955
Comment: Oh, there is a slight difference between $T_N x$ and I said at the beginning. I were doing $n\times n$ truncation of the infinite matrix and the hint says it's $\infty\times n$. Anyway let's stick to your hint. Originally with infinitely many terms, it should be $\sum_{k=1}^\infty a_{ij}x_j$ and if you truncate $x$ to the first $N$ terms, the sum becomes $\sum_{k=1}^N a_{ij}x_j$ as in your hint
Comment: I have taken this proposition: "The series $\sum_{n =1}^{\infty} a_{n} b_{n}$ converges absolutely for every convergent sequence $\{b_{n}\}$ iff $\sum_{n =1}^{\infty} |a_{n}|$ converges." will it be helpful here in our case? the problem is that here in our case we are in $l^2.$@user58955
Answer: First let's show a simpler version (1-dimensional): If $\sum_i a_i x_i < \infty$ all for $x\in\ell^2$, then $a\in \ell^2$.
You can prove this claim using uniform boundedness principle, or you can just use Riesz Representation Theorem. See this post.
Now, let's go back to your problem. It follows from the claim above that each row of $A$ is in $\ell_2$. Define $T_N$ to be the restriction of $A$ onto the first $N$ rows, that is,
$$
T_N x = \left(\sum_j a_{1j}x_j,\sum_j a_{2j}x_j,\dots,\sum_j a_{Nj}x_j,0,0,\dots,\right).
$$
We claim that $\|T_N\| < \infty$. Note that
$$
\|T_Nx\|_2^2 = \sum_{i=1}^N \left|\sum_j a_{ij}x_j\right|^2 \leq \sum_{i=1}^N\left(\sum_j |a_{ij}|^2 \right)\left(\sum_j |x_j|^2 \right) \leq \|x\|_2^2\cdot \sum_{i=1}^N\sum_{j=1}^\infty |a_{ij}|^2,
$$
thus
$$
\|T_N\| \leq \left(\sum_{i=1}^N\sum_{j=1}^\infty |a_{ij}|^2\right)^{1/2}.
$$
(Note that the infinite sum over $j$ is finite because of the claim at the beginning.)
Now, for each fixed $x$, observe that $\|T_Nx\|_2$ is uniformly bounded by $\|Ax\|_2$ (since $\|T_Nx\|_2$ is just part of the sum for $\|Ax\|_2<\infty$). It follows from the uniform boundedness principle that $\sup_N \|T_N\|<\infty$. Note that $\|Ax\|_2 = \lim_{N\to\infty} \|T_Nx\|_2 \leq (\sup_N \|T_N\|)\|x\|$, which implies that $A$ is bounded and $\|A\| \leq \sup_N \|T_N\|$.
Comment: @Happy So it's slightly different from your hint. I am taking $T_N$ to be the first $n$ rows of $A$ while in your hint it is the first $n$ columns of $A$.

No, I am not taking a special $x$ to say $\sum_j |a_{ij}|^2$ is finite. This is from the 1-dimensional version stated at the beginning of the proof. Since $Ax\in \ell^2$, every coordinate of $Ax$ must be finite. The $i$-th coordinate of $Ax$ is $\sum_j a_{ij}x_j$, and this is finite for any $x\in \ell^2$. The 1-dimensional version implies that the $i$-th row of $A$ is in $\ell^2$, that is, $\sum_j |a_{ij}|^2 < \infty$.
Comment: In this sentence "(Note that the infinite sum over $j$ is finite because of the claim at the beginning.)" do you mean over $j$ or over $i$?
Comment: I mean over $j$. It's $\sum_{j=1}^\infty$, this is an infinite sum
Comment: I think in the 8th line, in your middle term , the $i$ should be until $N.$
Comment: Oh, you're right. Let me fix the typo
Comment: which claim makes the infinite sum over $j$ finite ?I do not understand this.
Comment: I understood now, is this upon taking $x_{i} = 1$ for all $i$?
Comment: and because we have $Ax \in l^2$ for all $x \in l^2$ by assumption ..... am I correct?
Comment: I also have the same question about the infinite sum over $j$ being finite … could you clarify this please?


SpringBootApplication with log4j2 throws error on start

Question: I configured my log4j2.yml with properties from springboot:
Properties:
    property:
      - name: LOGSTASH_HOST
        value: ${spring:logstash.server.host}
      - name: LOGSTASH_PORT
        value: ${spring:logstash.server.port}
      - name: APPLICATION_NAME
        value: ${lower:${spring:spring.application.name:-spring}}

If I start my application I get a bunch of error messages saying:
ERROR StatusConsoleListener Resolver failed to lookup spring:logstash.server.host
java.lang.IllegalStateException: Unable to obtain Spring Environment from LoggerContext
and
ERROR StatusConsoleListener Unable to write to stream TCP:localhost:9800 for appender LOGSTASH
org.apache.logging.log4j.core.appender.AppenderLoggingException: Error writing to TCP:localhost:9800: socket not available at org.apache.logging.log4j.core.net.TcpSocketManager.write(TcpSocketManager.java:214)
It can not find the serverhost until springboot starts which takes a few seconds, after that the logging works fine and no more error messages.
How could I configure my log4J2 to start after or when springboot starts and don't spam error messages.
I've tried excluding the springr boot starter logging in pom:
<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j2</artifactId>
        </dependency>

or I've tried fallback hosts and ports:
Properties:
  property:
    - name: LOGSTASH_HOST
      value: "${sys:LOGSTASH_HOST:-${env:LOGSTASH_HOST:-localhost}}" # Prefer system property, then env variable, fallback to 'localhost'
    - name: LOGSTASH_PORT
      value: "${sys:LOGSTASH_PORT:-${env:LOGSTASH_PORT:-5044}}" # Prefer system property, then env variable, fallback to '5044'
    - name: APPLICATION_NAME
      value: "${sys:spring.application.name:-${env:spring_application_name:-default-application}}" # System property, env variable, fallback

Answer: Try renaming your log4j2.yml file to log4j2-spring.yml
This is one possibility described in the documentation since 3.0.0: https://docs.spring.io/spring-boot/docs/3.2.4/reference/html/features.html#features.logging.log4j2-extensions

Because the standard log4j2.xml configuration file is loaded too early, you cannot use extensions in it. You need to either use log4j2-spring.xml or define a logging.config property.


Uniform convergence on the interval $[0,a].$

Question: Let
$$f_n(x) = 4^{n}(x^{2^{n}}-x^{2^{n+1}}).$$
Then I wan to show that $f_n(x)$ is uniformly convergent in on the interval $[0,a]$ where $a\in [0,1).$
I looked at the solution and the author says that for large enough $n$ we have that
$$\sup_{0\leq x\leq a}|f_n(x)| = f_{n}(a).$$
I do not understand why this is true. Perhaps someone could explain?
I know that that $f_{n}(x)$ takes its maximum value at $x = \frac{1}{2^{1/2^n}}\to 1 $ (as $n\to \infty$) on the interval $[0,1].$ And so I guess if $n$ is large enough then $\frac{1}{2^{1/2^n}}$ will miss the interval $[0,a]$ and so all values of $x\in[0,a]$ the function will be increasing and thus their supremum equals the $f_n(a).$ Is this the reasoning behind this claim?
Comment: Yes. Just observe the derivative of $f_n'$ on $[0,a]$, from which I think you would have got the maximum value. Check that if $n$ is small enough then the derivative will be positive on that interval. Write down the derivative first, though, for context.
Answer: It is not necessary to find $\max_{x\in [0,a]}|f_n(x)|.$
If $0\le a <1$ then $\lim_{n\to \infty}a^n=0$ so there exists $k_a\in \Bbb N $ such that $a^{k_a}\le 1/8.$
And $\lim_{n\to \infty}n/2^n= 0$ so there exists $n_a\in \Bbb N$ such that $\forall n\ge n_a\,(2^n\ge k_an).$
So for $n\ge n_a$ and $x\in [0,a]$ we have $$0\le f_n(x)=4^n(x^{2^n})(1-x^{2^n}) \le$$ $$\le 4^n(x^{2^n})\le$$ $$\le 4^n(a^{2^n})\le$$ $$\le 4^n(a^{k_an})=$$ $$=4^n (a^{k_a})^n\le$$ $$\le  4^n (1/8)^n=2^{-n}.$$ Therefore $\forall n\ge n_a \;(\; \sup_{x\in [0,a]}|f_n(x)|\le 2^{-n}\;).$
Answer: A more precise statement is : $\sup_{0\leq x \leq a} |f_n(x)|=f_n(a)$ if $a^{2^{n}} <\frac 1 2$. For this write $f_n(x)$ as $4^{n}x^{2^{n}}(1-x^{2^{n}})$. The function $t \to t(1-t)$ is increasing in $[0,\frac 1 2]$. Hence $f_n$ is increasing on $[0,a]$ provided $a^{2^{n}} <\frac 1 2$. This inequality holds for $n$ sufficiently large.


LCD of 2x+1, x^2 and x

Question: I am given the following sum:
$$\frac{x}{2x+1} + \frac{3}{x^2} + \frac{1}{x}$$
In order to add these fractions, I must find a common denominator. I have been taught to factor each denominator and then multiply each factor the greatest number of times that they occur.
$$
    (2x+1), x(x), x\\
    LCD = (2x+1) \cdot x = 2x^2 + x
$$
I have also been taught that you do not include anything that has been factored out (in this case, the second $x$ in $x(x)$). Thus, the greatest number of times $x$ occurs is once; similarly with $2x+1$, so the $LCD$ is the product of these two expressions.
But apparently this is not correct, and somehow, I have encountered multiple different solutions, including:
$$
    2x^2 + x^3 \\
    2x^3 + x
$$
What is correct? And please explain (simply) how I can calculate the $LCD$ for future problems like this.
Comment: Welcome to MSE.  The LCD is $x^2(2x+1)=2x^3+x^2$
Comment: How do you calculate the LCD of 2 and 9?
Comment: or of $2, 9, $ and $3$ (to be more analogous)?
Comment: "But apparently this is not correct, and somehow, I have encountered multiple different solutions, "   Where did you encounter these?
Comment: " I have encountered multiple different solutions, including: "  And I've encountered people saying the earth is flat and Donald Trump isn't scum. The LCD of $2x+1, x\cdot x, x$ is $x\cdot x \cdot(2x+1) = x^2(2x+1)$ exactly as you thought for exactly the reason you said it was.  Don't listen to idiots.
Comment: @fleablood One was in my textbook, and another was from a different forum.
Answer: Factoring each denominator and then multiplying each factor the greatest number of times that it occurs works.  In this case, the factor $x$ occurs twice in the middle term, so the answer for least common denominator is $(2x+1)x^2=2x^3+x^2.$
The LCD has to be a multiple of all of the denominators, so it has to include all of the factors in the denominators for the greatest numbers of times they occur.
Comment: @Gerard Way:  To get all the fractions to have the LCD, you multiply the numerators and denominators by whatever it takes to make each denominator into the LCD.  When doing that, you multiply each numerator and denominator by all of the other denominators, leaving out factors of those that are already included.  I wonder if that's where you got the idea "you do not include anything that has been factored out"

LCD of 2x+1, x^2 and x


Number of Arithmetic Operations in Gaussian-elimination/Gauss-Jordan Hybrid Method for Solving Linear Systems

Question: I am stucked at this problem from the book Numerical Analysis 8-th Edition (Burden) (Exercise 6.1.16) :

Consider the following Gaussian-elimination/Gauss-Jordan hybrid method for solving linear systems:
First apply the Gaussian-elimination technique to reduce the system to triangular form. Then use the $n$-th equation to eliminate the coefficients of $x_{n}$ in each of the first $n-1$ rows. After this is completed use the $(n-1)$-st equation to eliminate the coefficients of $x_{n-1}$ in the first $n-2$ rows, ans so on. The system will eventually appear as the reduced system we get by applying Gauss-Jordan method to the original system.
Show that this method requires $\frac{n^3}{3}+\frac{3}{2}n^2-\frac{5}{6}n$ multiplication/divisions and $\frac{n^3}{3}+\frac{n^2}{2}-\frac{5}{6}n$ additions/subtractions.

But when I tried to calculate the total number of multiplication/divisions I got $\frac{n^3}{3}+\frac{3}{2}n^2-\frac{11}{6}n$, Here's what I've done (Sorry for being a bit long):
The augmented matrix for the system has the form
$$ \left[
    \begin{array}{cccc|c}
        a_{1,1} & a_{1,2} & \cdots & a_{1,n} & a_{1,n+1} \\
        a_{2,1} & a_{2,2} & \cdots & a_{2,n} & a_{2,n+1} \\
        \vdots  & \vdots  & \ddots & \vdots & \vdots  \\
        a_{n,1} & a_{n,2} & \cdots & a_{n,n} & a_{n,n+1}
    \end{array}
\right] $$
after applying Gaussian-elimination (without backward substitution) to this system we get
$$ \left[
    \begin{array}{cccc|c}
        \hat{a}_{1,1} & \hat{a}_{1,2} & \cdots & \hat{a}_{1,n} & \hat{a}_{1,n+1} \\
        0 & \hat{a}_{2,2} & \cdots & \hat{a}_{2,n} & \hat{a}_{2,n+1} \\
        \vdots  & \ddots  & \ddots & \vdots & \vdots  \\
        0 & \cdots & 0 & \hat{a}_{n,n} & \hat{a}_{n,n+1}
    \end{array}
\right] $$
We know that the total number of multiplications/divisions and additions/subtractions of the Gaussian-elimination technique is $\frac{n^3}{3}+\frac{1}{2}n^2-\frac{5}{6}n$ and $\frac{1}{3}n^3-\frac{1}{3}n$ respectively.
Now we will use the $i$-th row to eliminate the coefficients of $x_i$ in each of the first $i-1$ rows for each $i=n,n-1,...,2$ ($i$ starts at $n$ and goes down to $2$), and we will get:
$$ \left[
    \begin{array}{cccc|c}
        \hat{\hat{a}}_{1,1} & 0 & \cdots & 0 & \hat{\hat{a}}_{1,n+1} \\
        0 & \hat{\hat{a}}_{2,2} & \cdots & 0 & \hat{\hat{a}}_{2,n+1} \\
        \vdots  & \ddots  & \ddots & \vdots & \vdots  \\
        0 & \cdots & 0 & \hat{\hat{a}}_{n,n} & \hat{\hat{a}}_{n,n+1}
    \end{array}
\right] $$
Since for each $i$ we do $i - 1$ divisions (inorder to calculate $\frac{\hat{a}_1,i}{\hat{a}_{i,i}}$ , $\frac{\hat{a}_2,i}{\hat{a}_{i,i}}$ , ... , $\frac{\hat{a}_{i-1},i}{\hat{a}_{i,i}}$), After that we subtract each of the elements in the row $j=1,2,...,i-1$, $\frac{\hat{a}_j,i}{\hat{a}_{i,i}}$ times the $i$-th row, and so additional $i-1$ multiplications are carried out, and we get that the total number of multiplications/divisions in this step is $\Sigma_{i=2}^n2(i-1)=n^2-n$.
And so we get that the total number of multiplications/divisions required to apply the hybrid method is $\frac{n^3}{3}+\frac{1}{2}n^2-\frac{5}{6}n + \frac{1}{2}n^2-\frac{1}{2}n = \frac{1}{3}n^3+\frac{3}{2}n^2-\frac{11}{6}n$ which is different from $\frac{n^3}{3}+\frac{3}{2}n^2-\frac{5}{6}n$.
Thanks for any help.
Comment: You should add the final step: $n$ divisions required to compute the final solution of the diagonal system (or, equivalently, "normalizing" the diagonal matrix to the identity). That will give you the desired term $-\frac{5}{6}n$.
Comment: @AlgebraicPavel Thanks a lot, I've simply missed it.
Answer: To provide an answer to the question from Algebraic Pavel's comment:

You should add the final step: $n$  divisions required to compute the final solution of the diagonal system (or, equivalently, "normalizing" the diagonal matrix to the identity). That will give you the desired term $-\frac56n$.

That is to say, your entries need to be $1$ at the end to actually get the solution.
Answer:
Gaussian elimination :
(n+1)(n-1)+(n)(n-2)+...+(3)(1)=sigma(k=1 to n-1)(k+2)(k)=n^3/3+n^2/2-5n/6

2.Backward gaussian method :
2(n-1)+2(n-2)+...+2(1)=2*sigma(k=1 to n-1)(k)=n^2-n
3.Find the solution :
n
Sum of multi./div. = sum of 1,2,3 = n^3/3+3n^2/2-5n/6
I tried to upload my picture to explain it in detail but i dont know how to do it...
Comment: Use LaTeX please. https://math.meta.stackexchange.com/questions/5020/


Confusion about the Kronecker $\delta$

Question: Something disturbs me, concerning the Kronecker $\delta$.
Assuming these hold: $$\delta_{ij}\delta_{jk}=\delta_{ik}$$ $$\delta_{ij}=\delta_{ji}$$ $$\delta_{ii}=1$$ does it follow that for every  $\delta_{ij}$ we have $(\delta_{ij})^2=\delta_{ij}\delta_{ji}=\delta_{ii}=1$?
This makes no sense, as $\delta_{ij}$ can also be equal $0$.
Can anyone clear the confusion?

Edit: I am using Einstein notation. Do Kronecker deltas in Einstein notation always equal something different then zero? For example, if $\delta_{ii}=n$, does it imply $\delta_{ij}=n^{0.5}$ for all $\delta_{ij}$?
Comment: Are you using the Einstein summation convention?  The first equation you list is only true if you are using it.  The third equation is only true if you're not (or if your index set only has one element).
Comment: Given two matrices $A$ and $B$, $A_{ij}$ is one entry of $A$ and $B_{jk}$ is another entry of $B$.  Matrix multiplication is defined entrywise as $$[AB]_{ik} = \sum_j A_{ij}B_{jk}$$  But using the Einstein summation convention, the RHS can just be written $A_{ij}B_{jk}$ where we see that we're supposed to sum over $j$ because there are two of them.  If you see an expression like $A_{ii}$ then you need to realize that this is NOT one entry of $A$ -- this has an implied summation as well (over $i$).  $A_{ii}= A_{11} + A_{22} + \cdots + A_{nn} = \operatorname{trace}(A)$.
Comment: Well if you put repeated indices anywhere in a term -- for instance $\delta_{ij}v_i$ has a repeated $i$ -- then readers will assume that you mean to imply summation over the $i$ UNLESS you write something like "summation not implied" afterward.
Comment: @Whyka: One thing I will say as a warning is that whether or not people assume S.C. is being used can depend on context. As a rule of thumb, applied mathematicians and physicists will assume it's being used; but pure mathematicians will commonly state clearly if it is being used, and otherwise will not use it.
Comment: It seems that the author is using Einstein notation
Comment: @Bye_World Thank you for a good comment. So, how do I know which meaning does the notation have when I see it?
Comment: If there are any repeated indices then a summation is implied.  Otherwise there is no summation implied.  So $A_{ij}$ is one entry of $A$ because there are no repeated indices but $A_{ii} = \sum_i A_{ii}$ because $i$ is a repeated index.
Comment: @Bye_World But if I do want to refer to the regular form of the Kronecker delta ($\delta_{ij}=1$ if $i=j$, $0$ else), how do I make sure it won't be understood as in the summation?
Comment: @Bye_World I see. So the Einstein notation is the "defualt", unless said otherwise. Thanks!
Answer: You're confused about this notation, most likely because of what I suspect is the inconsistent use of summation convention.
The first statement is only correct if implicitly summed over $j$:
$$\sum_j \delta_{ij}\delta_{jk} = \delta_{ik}$$
The last statement however is only true if there is no summation over $i$, since generically if $i=1,2,\ldots,n$ then
$$\sum_i \delta_{ii} = n$$
This inconsistency is what is causing you problems.
(Notice for example that if $n=1$ then there is no such ambiguity but indeed it is not possible for $\delta_{ij}$ to be anything other than 1!)

Edit in response to comment: To respond to your comment, no. $\delta_{ij}$ takes different values depending on what $i,j$ are. For example in 3D,
$$\delta_{ij} = \pmatrix{1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1}_{ij}$$
Hence using summation convention, e.g. $\delta_{ii} \equiv \delta_{11} + \delta_{22} + \delta_{33} = 3$
Generally, $\delta_{ij}$ is just a thing that tells you whether or not $i = j$. If yes, then it is 1, if no, then it is 0. You can also think of these as the components of the identity matrix as suggested in the comments by Bye_World.
Comment: Maybe it would help you to understand the $\delta_{ij}$ just means the entry in the $i$th row and $j$th column of the **identity matrix**.  So of course $\delta_{ij}\ne 3^{1/2}$.
Comment: @Whyka: I've responded in the question because it's much easier that way.
Comment: Because we are looking at an 1*1 matrix?
Comment: @Whyka Exactly! Another way to look at it is that if $i,j\in \{1\}$ then $i=j$ always!
Comment: So, if I use Einstein notation, then $\delta_{ij}$ always equals $3^{0.5}$ in 3-D?
Comment: Thanks a lot. So why does it make sense that if n=1 $\delta_{ij}=1$ always?
Comment: @Sharkos it is all clearer now. Thanks a lot!

Confusion about the Kronecker $\delta$


TFS Build agen failing to find .certifcate file

Question: <code> 1. 2020-09-18T19:03:37.9661852Z ##[debug]Evaluating condition for step:
    'Get Sources'
 2. 2020-09-18T19:03:37.9783485Z ##[debug]Evaluating: SucceededNode()
 3. 2020-09-18T19:03:37.9798521Z ##[debug]Evaluating SucceededNode:
 4. 2020-09-18T19:03:37.9848754Z ##[debug]=> True
 5. 2020-09-18T19:03:37.9888404Z ##[debug]Result:
True
 6. 2020-09-18T19:03:37.9971561Z ##[section]Starting: Get Sources
 7. 2020-09-18T19:03:38.0033628Z ##[debug]Sync source for endpoint: DIAMONDS
 8. 2020-09-18T19:03:38.0470845Z Syncing repository: DIAMONDS (TfsGit)
 9. 2020-09-18T19:03:38.0560347Z Prepending Path environment variable
    with directory containing 'git.exe'.
 10. 2020-09-18T19:03:38.0571574Z ##[debug]Path:
     'C:\Agent\vsts-agent-win-x64-2.136.1\externals\git\cmd;C:\Program
     Files\Common Files\Oracle\Java\javapath;C:\Program Files
     (x86)\Common
     Files\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program
     Files (x86)\HID Global\ActivClient\;C:\Program Files\HID
     Global\ActivClient\;C:\Program Files\dotnet\;C:\Program
     Files\Microsoft SQL
     Server\130\Tools\Binn\;C:\Users\svc.dsms.vissvc.sa\AppData\Local\Microsoft\WindowsApps'
 11. 2020-09-18T19:03:38.0618801Z ##[debug]Get git version.
 12. 2020-09-18T19:03:38.0659586Z ##[command]git version
 13. 2020-09-18T19:03:38.4081255Z git version 2.17.1.windows.2
 14. 2020-09-18T19:03:38.4111608Z ##[debug]Detect git version: 2.17.1.
 15. 2020-09-18T19:03:38.4204178Z ##[debug]Set git useragent to:
     git/2.17.1 (vsts-agent-git/2.136.1).
 16. 2020-09-18T19:03:38.4267175Z
     ##[debug]Checking if the repo on C:\Agent\vsts-agent-win-x64-2.136.1\_work\2\s matches the expected
     repository origin URL. expected Url: https://XXX
 17. 2020-09-18T19:03:38.4320839Z ##[debug]Inspect remote.origin.url for
     repository under C:\Agent\vsts-agent-win-x64-2.136.1\_work\2\s
 18. 020-09-18T19:03:38.4321081Z ##[command]git config --get
     remote.origin.url
 19. 2020-09-18T19:03:38.7395942Z ##[debug]Get remote origin fetch url
     from git config: https:XXX
 20. 2020-09-18T19:03:38.7396356Z ##[debug]Repository remote origin
     fetch url is https://XXX
 21. 2020-09-18T19:03:38.7396743Z ##[debug]URLs match.
 22. 2020-09-18T19:03:38.7431528Z ##[debug]Delete untracked
     files/folders for repository at
     C:\Agent\vsts-agent-win-x64-2.136.1\_work\2\s.
 23. 2020-09-18T19:03:38.7467645Z ##[command]git clean -fdx
 24. 2020-09-18T19:03:39.0583899Z ##[debug]Undo any changes to tracked
     files in the working tree for repository at
     C:\Agent\vsts-agent-win-x64-2.136.1\_work\2\s.
 25. 2020-09-18T19:03:39.0585957Z ##[command]git reset --hard HEAD
 26. 2020-09-18T19:03:39.2995536Z fatal: ambiguous argument 'HEAD':
     unknown revision or path not in the working tree.
 27. 2020-09-18T19:03:39.3000326Z Use '--' to separate paths from
     revisions, like this:
 28. 2020-09-18T19:03:39.3022533Z 'git <command> [<revision>...] --
     [<file>...]'
 29. 2020-09-18T19:03:39.3195495Z
     ##[debug]'git reset --hard HEAD' failed with exit code 128 For
 30. futher investigation, manually run 'git reset --hard HEAD' on repo
root: C:\Agent\vsts-agent-win-x64-2.136.1\_work\2\s after each
     build.
 31. 2020-09-18T19:03:39.3226184Z ##[warning]Unable to run "git clean
     -fdx" and "git reset --hard HEAD" successfully, delete source folder instead.
 32. 2020-09-18T19:03:39.3415125Z ##[debug]Init git repository at:
     C:\Agent\vsts-agent-win-x64-2.136.1\_work\2\s.
 33. 2020-09-18T19:03:39.3415414Z ##[command]git init
     "C:\Agent\vsts-agent-win-x64-2.136.1\_work\2\s"
 34. 2020-09-18T19:03:39.8849476Z Initialized empty Git repository in
     C:/Agent/vsts-agent-win-x64-2.136.1/_work/2/s/.git/
 35. 2020-09-18T19:03:39.9152342Z ##[debug]Add git remote: origin to
     url: https://XXXfor repository under:
     C:\Agent\vsts-agent-win-x64-2.136.1\_work\2\s.
 36. 2020-09-18T19:03:39.9152668Z ##[command]git remote add origin
     https://XXX
 37. 2020-09-18T19:03:40.2769659Z ##[debug]Disable git auto garbage
     collection.
 38. 2020-09-18T19:03:40.2769869Z ##[command]git config gc.auto 0
 39. 2020-09-18T19:03:40.5400860Z ##[debug]Checking git config
     http.https://XXX.extraheader exist or not
 40. 2020-09-18T19:03:40.5401139Z ##[command]git config --get-all
     http.https://XXX.extraheader
 41. 2020-09-18T19:03:40.7805892Z
     ##[debug]Checking git config http.proxy exist or not
 42. 2020-09-18T19:03:40.7806064Z ##[command]git config --get-all
     http.proxy
 43. 2020-09-18T19:03:41.0134148Z ##[debug]Fetch git
          repository at: C:\Agent\vsts-agent-win-x64-2.136.1\_work\2\s
          remote: origin.
 44. 2020-09-18T19:03:41.0174569Z ##[command]git -c
     http.extraheader="AUTHORIZATION: bearer ***" fetch --tags --prune
     --progress --no-recurse-submodules origin
 45. 2020-09-18T19:03:41.5941543Z fatal: unable to access 'https://XXX':
     error setting certificate verify locations:
 46. 2020-09-18T19:03:41.5958389Z   CAfile: C:/Program
     Files/Git/mingw64/ssl/certs/ca-bundle.crt
 47. 2020-09-18T19:03:41.5958752Z   CApath: none
 48. 2020-09-18T19:03:41.6419509Z ##[error]Git fetch failed with exit
     code: 128
 49. 2020-09-18T19:03:41.6467215Z
 50. ##[debug]System.InvalidOperationException: Git fetch failed with exit code: 128

at Microsoft.VisualStudio.Services.Agent.Worker.Build.GitSourceProvider.<GetSourceAsync>d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)    at Microsoft.VisualStudio.Services.Agent.Worker.Build.BuildJobExtension.<GetSourceAsync>d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)    at Microsoft.VisualStudio.Services.Agent.Worker.JobExtensionRunner.<RunAsync>d__21.MoveNext()
--- End of stack trace from previous location where exception was thrown ---    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)    at Microsoft.VisualStudio.Services.Agent.Worker.StepsRunner.<RunStepAsync>d__1.MoveNext() 2020-09-18T19:03:41.6475180Z ##[section]Finishing: Get Sources
</code>
Comment: Hi friend, is there any update for this issue? Feel free to let me know if you're still blocked, I'll try my best to help :)
Comment: thx still having issue will try to resolve today and tomorrow
Answer: Please try the following ways:

Look for ca-bundle.crt in the "C:/Program Files/Git" folder. If you find this file, copy it and paste it to "C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt".

Fix the path to "C:\Program Files\Git\mingw64\ssl\certs\ca-bundle.crt"
git config --system http.sslcainfo " C:\Program Files\Git\mingw64\ssl\certs\ca-bundle.crt "

Switch off ALL SSL checks completely by executing:
git config --system http.sslverify false

Since you have this issue in the checkout step, you can use
<code>steps:
- checkout: none
</code>
to disable the checkout step first.
After the above command is completed, use the git checkout command in your tasks to checkout your repository.
Please refer to this ticket for more details: Github: error cloning my private repository.
Comment: will try today or tomorrow


Align item to right in Tablecellview using Autolayout or springs and struts

Question: Im having this problem where I simply want to align a UILabel to right of a table viewcell. I have tried both approaches of Autolayout and Springs and struts but neither of them is working. When I run the app on a larger screen size, the cell does resize properly but the UIlabel doesn't align to the right of the tableview cell. What is the proper way to handle this?
For knowledge, I will like to know solution of both approaches.
Note : Its a tableViewController not a custom view controller
Comment: i think the problem is you doesn't set any constraints to your tableview.....pin all edges of tableview..
Comment: Im using tableview controller. I have tested and confirmed - the table does resize properly.
Comment: ok...if tableview controller is there then its fine...and i check your constraints and its working properly on my view....is there any view inside cell?
Answer: You have to set first tableview's constraint with all side.


If $M$ is a 4-dimensional, compact, simply connected manifold with boundary, what is the topology of $\partial M$?

Question: I know if we have a compact simply connected 3-manifold with boundary, then the boundary will be $S^2$. The argument is as following
1) $H_1(M)\simeq 0$;
2) Poincare duality $H_2(M,\partial M)\simeq H^1(M)\simeq 0$;
3) Long exact sequence we have
$$\to H_2(M,\partial M)\to H_1(\partial M)\to H_1(M)\to$$
Thus $H_1(\partial M)\simeq 0$ and $\partial M\cong S^2$. Now if we do same argument for 4-dimensional compact simply connected manifold with boundary we cannot say anything about 1st and 2nd homology groups, like we could above. I think $\partial M\cong S^3, S^1\times S^2, L(p,q)$, but the argument doesn't work. How can I show this?
Comment: As a note, the boundary can be a disjoint union of copies of $S^2$; it doesn't have to be connected. (Just take $S^3$ and delete a bunch of balls.)
Answer: There are many more 3-manifolds that arise as the boundary of compact contractible 4-manifolds than just those, including some Brieskorn spheres like $\Sigma(2,3,13)$. The keyword you want is Mazur manifold. It is my impression that, and I would be surprised if it weren't true, there is not much known about what 3-manifolds arise as the boundary of a Mazur manifold.
Now if you just want simply connected, every orientable 3-manifold bounds a simply connected 4-manifold. First recall the Lickorish-Wallace theorem that every oriented 3-manifold $M$ arises from surgery on a link in $S^3$. This defines a cobordism $W: S^3 \to M$ that's obtained by attaching 2-handles to $S^3 \times I$; this remains simply connected. Now simply cap off the copy of $S^3$ with a ball. This gives a simply connected 4-manifold that bounds $M$.
(Of course, a non-orientable 3-manifold cannot bound a simply connected 4-manifold. For simple connectedness implies the 4-manifold is orientable; and the boundary of an orientable manifold is orientable.)
Comment: $\Sigma (2,3,5)$ does not arise as the boundary of a smooth contractible 4-manifold as it has nonvanishing Rohklin invariant. The $E_8$-plumbing glued to this contractible 4-manifold on $\Sigma (2,3,5)$ would violate Rohklin's theorem.
Comment: What about if I add symmetry to my manifold with boundary, like $U(1)^2$ symmetry?
Then I know the compact manifold without boundary (By Ramond,OrliK,1972) is $\cong n(S^2\times S^2)\# n(\pm \mathbb{CP}^2)$. Then can I say since any $3D$ closed manifold with $U(1)^2$ action (without discrete isotropy subgroup) is $\cong S^3,S^1\times S^2,L(p,q)$, $\partial M$ is one of these cases.
Comment: If I believe your statement that those are the only 3-manifolds with effective torus action, then yes, that (or the disjoint union of some of those) must be the boundary of a manifold with effective torus action, because we can just restrict our action to the boundary.
Comment: @PVAL: Fixed. ${}$


Clarification needed regarding Supremums and Limit points

Question: While reading about limit points, I came upon a theorem that states that the supremum of a bounded non-empty set $S$ in $\mathbb{R}$ is a limit point of that set. In the proof, it is used that $\forall \epsilon > 0$, $\exists x_0 \in S$ such that $M-\epsilon < x_0 < M$, where $M = \sup S$. Now, I have a problem in this part. I think it should be $M-\epsilon < x_0 \leq M$ and then, the proof would not hold anymore. (Consider the set $(4,5) \cup \{6\}$ for example). Since I am using a pretty famous book, baby Rudin, it is likely that I am making a mistake. It'd be great if anyone can clarify. Here is a picture of the theorem:
Sorry for the confusion. I misunderstood the statement. It doesn't say that the supremum is a limit point. Instead, that it's in the closure of the set. Thanks @Bungo for clarification.
Comment: Which theorem in Rudin?
Comment: @SayantanSantra If you read his proof again, you will see that after the first sentence, he is assuming that $\sup(E) \not\in E$, so in fact there must be a point $x \in E$ satisfying $\sup(E) - h < x < \sup(E)$. Otherwise, as he indicates, $\sup(E)-h$ would be an upper bound for $E$. (+1 for recognizing that the mistake was probably yours, not Rudin's :-)
Comment: @SayantanSantra By the way, your paraphrasing of what the theorem says is not correct. The supremum of a bounded nonempty set is in the **closure** of the set. The closure of a set consists of the limit points of the set as well as the isolated points. Isolated points are always elements of the set, whereas limit points may or may not be. In the first sentence of his proof, he handles the possibility that $\sup(E)$ is an isolated point or a limit point that is contained in $E$. The rest of the proof deals with the possibility that $\sup(E)$ is a limit point which is not contained in $E$.
Comment: Your example seems to break not just the proof, but the statement itself...!
Comment: @GregMartin I'm new to these. It'd be really helpful you could explain a bit. Am I making a mistake? If yes, it'd be great if you pointed out.
Comment: @Cat Chapter 2. Basic topology. Theorem 2.28
Comment: It seems to me that $6$ is not a limit point of the set $(4,5)\cup\{6\}$. Are you sure you're quoting the result correctly? Perhaps there's an additional assumption that the supremum is not an element of the set?
Comment: @GregMartin I've added a picture from the book. Please check out if I'm missing something.
Comment: @Bungo Oh yes. Thank you. I missed that part. Thanks for the clarification.
Answer: Theorem 2.28 and its proof do not state nor imply that $\sup E$ is a limit point of $E.$ It states that if $E$ is closed and if $\sup E$ exists then $\sup E \in E.$ This is done by contradiction: Suppose instead that $E=\bar E,$ and $y=\sup E$ exists but $y\not \in E.$ Then,by def'n of $\sup,$ we have $(y-h,y]\cap E\ne \emptyset$ for all $h>0.$ But (because $y\not \in E$) this implies $(y-h,y)\cap E\ne \emptyset$ for all $h>0,$ implying that $y$ is a limit point of $E,$ and hence $y\in \bar E.$
In summary, $\sup E=y\not \in E=\bar E\implies (y$ is a limit point of $E)\implies y\in \bar E=E\implies y\in E,$ a contradiction.
We can also prove this directly by noting that  for any $F\subset \mathbb R,$ we have (1) if $y=\sup F=\max F$ then by  def'n of $\max$ we have $y\in F\subset \bar F,$ and (2) if $y=\sup F\ne \max F$ then $F\subset (-\infty, \sup F)\implies y\in \bar F$ because $F\cap (y-r,y)\ne \emptyset$ for all $r>0.$