checking definition of bounded linear function involves operator maps between different spaces

Question: Let $H$ and $K$ be two Hilbert spaces. Let $T:K\to H$ be a bounded linear operator. Denote the inner products on $H$ and $K$ by $\langle\cdot,\cdot\rangle_H$, $\langle\cdot,\cdot\rangle_K$. Fix any $y\in H$; then the linear mapping
$$ \Phi: K\to\mathbb{C},\quad\Phi x :=\langle Tx,y\rangle_H$$
defines a bounded functional on the Hilbert space $K$.
Could anyone help with the proof of above claim?
Recall, a functional simply a linear operator $\Phi:H\to \mathbb{C}$.
$\Phi$ is bounded if there exists $K$ such that $|\Phi x|\le K\|x\|,\,\,\forall\,\,x\in H$. So I have
$$|\Phi x|=|\langle Tx,y\rangle_H|\le\cdots$$
Please help.
Comment: Hint: Cauchy Schwarz and then the definition of operator norm
Comment: Still, your choice of symbols is rather sloppy here. Both $K$ and $H$ have two quite distinct meanings here. It doesn't matter much if you do keep control over it (and this being a small piece of math, it is not that hard), but be careful.
Answer: Hint: How do you prove that $y^*\colon H\to {\bf C}$ defined by $y^*(y'):=\langle y',y\rangle$ is bounded? Or, if you know what an adjoint operator is, just notice that $\Phi$ is just $T^*(y^*)$.
Comment: Im sorry I do not understand what you mean. I have not got to the point to understand adjoint operator yet...need a more precise answer.
Comment: Which part do you not understand? What $y^*$ is?
Comment: It would help if you provide a detail answer to my question to get me started. I do not know how to prove your first sentence.
Comment: @math101: Well, that's what you should do first. I will not give any more detailed answer, especially while you're not even showing any effort of your own.
Comment: i deleted my comment for privacy. But I am sorry I do not feel the hint helpful.


The derived $\mathscr{der}(Y)$ of some set $Y$ is empty iff $Y$ is a set of isolated point.

Question: Let be $X$ a topological space and let be $Y\subseteq X$ such that $\mathscr{der}(Y)=\varnothing$: so for any neighborhood $I_y$ of $y\in Y $ it result that $I_y\cap Y={y}$ and so Y is a set of isolated point. Now of $Y$ is a set of isolated point clearly none of its point could be a accumulation point: anyway if $x\notin Y$ how prove that for any its neighborhood $I_x$ it result that $I_x\cap Y=\varnothing$?
Could someone help me, please?
Comment: what is $der(Y)$ ? the set of limits points ?
Comment: @Surb Yes, see [here](https://en.wikipedia.org/wiki/Derived_set_(mathematics)).
Answer: Not true in general.
Let  $a\neq b$ and $\tau=\{\varnothing,\{a\},\{a,b\}\}$.
Then $\tau$ is topology on $X=\{a,b\}$.
$Y=\{a\}$ is a set of isolated points but evidently $b$ is a limit point of $Y$ so that $\mathsf{der}(Y)\neq\varnothing$.
Answer: It is not possible. Let us consider $\mathbb{N}$ endowed with the discrete topology and let $X=\mathbb{N}\cup \{\infty\}$ as the one point compactification of such a space ($X$ is homeomorphic to a convergent sequence). Let $Y=\mathbb{N}\subset X$. Since the subspace topology on $Y$ is equivalent to the discrete topology, all the points of $Y$ are isolated points. On the other hand  the limit point $\{\infty\}$ is an accumulation point for $Y$, therefore each neighborhood of $\{\infty\}$ intersects $Y$.
Answer: der($Y$) is empty iff $Y$ is a closed discrete subspace of $X$.
(1). If der($Y$) is empty: (i). Any   $p\in \overline Y$ \ $Y$ would belong to der($Y$). So $\overline Y=Y.$ (ii). Any $y\in Y$ has an open nbhd $U_y$ (in the space $X$) such that $U_y\cap Y=\{y\},$ so $\{y\}$ is open in the subpace topology on $Y$.
(2).If $Y$ is a closed discrete subspace of $X$:  (iii). If $y\in Y$ then $\{y\}$  is open in the subspace $Y$ so there exists some open subset $U_y$ of the space $X$ such that $U_y\cap Y=\{y\},$ so $y\not\in$ der($Y$). (iv). If $x\in X$ \ $Y$ then $X\setminus Y=X$ \ $\overline Y$ is a nbhd of $x$ which is disjoint from $Y,$ so $x\not \in$ der($Y$).
Example. Let $X=\Bbb R$ with the usual topology, and let $Y=\Bbb N.$
Note that if der($Y$) is empty then members of $Y$ are isolated points in the space $Y$ but  not necessarily isolated points of  $X$.


Finding $6$ pairwise non-isomorphic semi-direct products of order $42$

Question: I'm stuck on an old algebra prelim question concerning semi-direct products. I am to find $6$ pairwise non-isomorphic groups of order $42$ that are semi-direct products. I think my main issue is how to determine appropriate maps $\phi: K \rightarrow \text{Aut}(H)$ with $H \unlhd G$, $H \cap K= 1$, $G=HK$ so that $G \cong H \rtimes_{\phi} K$.
My attempt: A group $G$ of order $42= 2 \cdot 3 \cdot 7$ has a normal Sylow $7$-subgroup. So a possible choice of one of these groups is given by the presentation $$\langle x,y: x^6= y^7= 1, xyx^{-1}= y^3 \rangle,$$ where we have a normal Sylow $7$-subgroup $\langle y \rangle$ inverted by $x$, an element of order $6$. This describes the semi-direct product $\mathbb{Z}_7 \rtimes \mathbb{Z}_6$. Another possibility, I think is that since we know that a group of order $42$ has a subgroup of order $21$ (index $2$), then that subgroup is normal. So in this case, we could have $H= \mathbb{Z}_{21}$. Then we can let $K= \mathbb{Z}_2$, and think about $\phi: \mathbb{Z}_2 \rightarrow \text{Aut}(\mathbb{Z}_{21})$. Clearly, $H \cap K=1$ by Lagrange's Theorem but what should I use for $\phi$? From this, I think that my second possibility would probably have to be $\mathbb{Z}_{21} \rtimes_{\phi} \mathbb{Z}_2$. Still not sure what the other four semi-direct products are or how to find them.
Comment: Oh, and don't forget that the action can be trivial, so ${\Bbb Z}_{42}$ and other abelian groups should probably be on your list.
Comment: Just to point out the (perhaps) obvious: You also need to prove that these groups are not isomorphic. A simple example would be $C_{21}\times C_2\cong C_{14}\times C_3$. Non-trivial examples also exist.
Comment: The second one you're looking for seems to be the [dihedral group](https://en.wikipedia.org/wiki/Dihedral_group) of size 42, which you get by letting ${\Bbb Z}_2$ act on ${\Bbb Z}_{21}$ by inverting it.
Comment: There are just 6 groups of order 42 up to isomorphism.
Comment: @HewWolff: I think I see your point now as when $\phi$ acts non-trivially, we obtain precisely $D_{42}$ but when $\phi$ acts trivially, then $\mathbb{Z}_{21} \rtimes \mathbb{Z}_2 = \mathbb{Z}_{21} \times \mathbb{Z}_2 \cong \mathbb{Z}_{42}$. Well, at least that covers three of the six groups!
Comment: $S_3\times Z_7$, $Z_3\times D_{14}$.
Comment: I think the missing one is $(C_7 \rtimes C_3) \times C_2$.
Comment: Derek Holt, you are right. I was in the middle of an edit.
Comment: I also want to say that these are the groups of order $42$. So I don't know why to write semi-direct product here..
Comment: Somehow I think $\mathbb{Z}_7 \rtimes \mathbb{Z}_6$ might not be correct as it isn't even mentioned on this list on page $7$ of $36$ in http://www.mimuw.edu.pl/~zbimar/small_groups.pdf.
Answer: Let us recall the list given by the comments above:
$1)$ $\mathbb{Z}_{21}\times \mathbb{Z}_{2}=\mathbb{Z}_{42}$
$2)$ $\mathbb{Z}_{21}\rtimes \mathbb{Z}_2=D_{42}$ (Diedral group, action on $\mathbb{Z}_{21}$ sends $x$ to $-x$)
$3)$ $\mathbb{Z}_{21}\rtimes \mathbb{Z}/2=\mathbb{Z}_7\times D_{6}$ (the action of $\mathbb{Z}_2$ on $\mathbb{Z}_{21}=\mathbb{Z}_7\times \mathbb{Z}_3$ is trivial on $\mathbb{Z}_7$ but sends $x$ to $-x$ on $\mathbb{Z}_3$ )
$4)$ $\mathbb{Z}_{21}\rtimes \mathbb{Z}/2=\mathbb{Z}_3\times D_{14}$ (the action of $\mathbb{Z}_2$ on $\mathbb{Z}_{21}=\mathbb{Z}_7\times \mathbb{Z}_3$ is trivial on $\mathbb{Z}_3$ but sends $x$ to $-x$ on $\mathbb{Z}_7$ )
$5)$ $\mathbb{Z}_{2}\times (\mathbb{Z}_7\rtimes \mathbb{Z}_3)$ (the action of $\mathbb{Z}_3$ on $\mathbb{Z}_7$ sends $x$ onto $2x$ and is of order $3$ since $2^3=8=1$ in $\mathbb{Z}_7$)
It remains to show that these give really five non-isomorphic examples of groups. In each case, the group $G$ contains a unique subgroup $H$ of order $21$, which is moreover normal. The group $H$ is not abelian only in the last case, so we can forget $5)$. You then look at the action of $G$ on $H$ and consider the subgroup of fixed points. This gives a subgroup of order $21$, $1$, $7$, $3$ respectively. This achieves the proof.


Confusing parts about React and Angular serving

Question: I have started to learn React and now I am a bit confused about different parts of development and deployment.
Does all webpages are bild with frameworks like React or Anguler? Or they are used only for one page web applications? Can I serve React with nodejs server?
Does the method when you build static webpage with js, html, css and serving them with Apache web server is still used in modern world?
Answer: I would highly suggest using the React-Create-App utility.  And yes, you can use Node.js.  In fact, React doesn't force you to use any backend framework.  I could pick ASP.NET MVC, Node, Spring MVC, Rails, etc.
https://github.com/facebook/create-react-app
But this tutorial will guide you through creating react apps in development and creating production builds.
When you build in production, you'll end up with a public folder with html files.  But in React, you don't create html files, you create .jsx, which is a combination of html-like React tags with JavaScript.  They will get transpiled to html, etc during the production build phase.  You can then take the build folder and deploy it on an HTTP server, such as Apache.


Families of orthogonal curves to parabola.

Question: In a typical ODE course, we learn that families of orthogonal curves to parabola $y=Ax^2$ are given by families of ellipses, given by $x^2/2+y^2=c^2$. However, there is this thing called parabolic coordinates which are families of parabolas orthogonal to each other. It seems like either family of ellipses and another family of parabola can be orthogonal to families of parabolas. Can there exist more than one families of orthogonal curves?
Comment: What is "parabolic coordinates" ?
Comment: Of course. The orthogonality condition yields the tangent to a family of curves on the points of the single parabola only. Take a pencil and draw one yourself. Parabolic ccordinates $x=1/2 (\xi^2 -\eta^2), \  y= \xi \  \eta )$ are two families of mirrored parabolas with a common focal point intersecting family-wise eachother everywhere and form a conformal map (angle and area preserving locally)
Answer: (see figure below).
No, (setting apart pathological cases) there is unicity of the family of orthogonal curves to a given family of curves depending on a parameter (in a differentiable way).
Indeed, in your case :

the family of parabolas with equations $y=ax^2$ have the origin as a common vertex  whereas,

the family of parabolas you mention (self orthogonal) with equations $y=-\frac{1}{2k}x^2+\frac{k}{2}$ have the origin as a common focus (blue for the initial family with $k>0$, red for the orthogonal family with $k<0$).

Explanation for the second family :
The directrix has equation $y=k$ ; expressing that the generic point $M=(x,y)$ must be at the same distance from the origin and from the directrix gives condition $x^2+y^2=(y-k)^2$. Expanding it, one obtains the given equation.
Comment: Thanks! A parabola has the general form $y=ax^2+bx+c$, which has three parameters. The family of ellipsis are orthogonal to the case when $b=0, c=0$, whereas the the family of parabola are orthogonal to the case when $a=-\frac{1}{4c}$. Can we say that once we specified one the parameters, either $a, b$ or $ c$, there to exist an orthogonal families of curves to parabola corresponding to that parameter?
Comment: You have to fix $two$ parameters in order there is only one remaining. It is in the framework of a family of curves depending on a *single* parameter that the concept of orthogonal family makes sense.
Comment: For the complex interpretation, see for example [here](https://mathcurve.com/courbes2d.gb/orthogonale/orthogonale.shtml)
Comment: Thanks for the information! Another question that came to my mind is that in $\mathbf{R}^2$, given a family of orthogonal trajectories, do they always form a coordinate system? If not, what are the conditions that they have to satisfy?
Comment: Good question. I am going to think about it before saying "yes" too quickly.


Calculation of Euler's Criterion

Question: In order to solve Quadratic Congruences, we need Euler's Criterion to determine whether the congruence is solvable. My question is, for those huge numbers, how can we determine whether it is congruent to 1 or -1 mod p?
Here is how we define Euler's Criterion

For example, how can we know whether $2^{30} \equiv 1 (mod 61)$ or  $2^{30} \equiv -1 (mod 61)$
Answer: These numbers are  small compared to those actually used e.g. in
(RSA) cryptography. They are computed with
Modular_exponentiation.
  An alternative is to use fast algorithms for the
Jacobi/Legendre symbol.
You are right in your second comment: to test whether $2$ is a quadratic residue mod $61$ you just have to look at  property (8) in the Wiki reference and get $\left(\frac{2}{61}\right) = -1\;$ because  $\;61 \equiv 5 \pmod 8.$  Thus computing Jacobi symbols for $a=2$ is trivial.
Here is the modular computation using the right-to-left binary method, all steps are $\bmod 61$
$$2^{30} \equiv 2^{16} \times 2^8 \times 2^4 \times 2^2$$
$$2^2\equiv 4, \quad 2^4\equiv16, \quad  2^4 \times 2^2 \equiv 64 \equiv 3$$
$$2^8\equiv16^2\equiv12, \quad2^8 \times 2^4 \times 2^2 \equiv 12\times 3 \equiv 36$$
$$2^{16} \equiv 12^2 \equiv 22, \quad 2^{16} \times 2^8 \times 2^4 \times 2^2 \equiv 22\times 36 \equiv 60 \equiv -1$$
Comment: What I'm thinking is, here a=2, n=61, $61 \equiv 5 (mod 8)$, thus (2/61) = -1
Comment: Can you try to explain $2^{30}≡−1(mod61)$ by using Jacobi symbol?
Answer: I would only use Euler for being able to say something about these large numbers, not prove that $(\frac{2}{61})=-1$ from solving these large numbers.
So, $(\frac{2}{61})=-1$ because (see Using gauss's lemma to find $(\frac{n}{p})$ (Legendre Symbol)) $61 \equiv -3 \mod 8$. From Euler it follows then that $2^{30} \equiv -1 \mod 61$. No complications whatsoever.
Moral: use Gauss' lemma to determine the value of $(\frac{a}{p})$, then use that value and Euler to derive which of $a^{\frac{p-1}{2}} \equiv \pm 1 \mod p$ holds.

Calculation of Euler’s Criterion


Time complexity of Metropolis-Hastings and potential speed-up?

Question: The MH algorithm essentially involves generating a sample destination state from a proposal distribution, computing the acceptance probability as a function of that sample, and checking whether a uniform random variable is above the acceptance probability to determine whether to move to the new state or not.

What is the time complexity of each step? Is it the case that each step in this algorithm is really fast, and so MH is time-bottlenecked by the mixing time it takes for the distribution to converge?
How does the time complexity depend on the dimension of the data in the underlying joint distribution being approximated in the first place (recall MH seeks to provide samples drawn from a PDF approximating some target distribution/PDF)?
For the exponential family, the acceptance probability of a proposed state $x_{m+1}$ is given by $$p(x_{m+1}=x' \mid x_m)=\min \left[1, \frac{\exp \left\{\eta \cdot T(x')\right\} Q(x_m \mid x')}{\exp \{\eta \cdot T(x_m)\} Q(x' \mid x_m)}\right]$$

where both exponentials contain a dot product involving the sufficient statistic. Since approximate isometries are guaranteed to exist for data sets (by JL Lemma), why can't we always project data down into a much lower dimension such that all data points have the same pairwise dot products, then compute the acceptance probability/run M-H with the lower dimensional data points, if the only thing we use about the data points are their dot products with other data points?
Answer: The time-complexity of a Metropolis-Hastings algorithm depends on the complexity of the target distribution. In Bayesian statistics where the target is a function of a sample of $n$ observations, computing the target distribution at a new value [proposed state] is generally of order $\text{O}(n)$ if there is no sufficient statistic (i.e., outside exponential families). The dimension $d$ of the state space also impacts the computation time at each step.
Dimension also matters in the number of steps needed to achieve
stationarity, whose order $\text{O}(d^\alpha)$ will increase with $d$.


making a string samefrom both ends by shifting characters

Question: I am given a string S and I have to make it a palindrome by re-arranging the characters of the given string.
If the given string can not be converted into a palindrome by re-arranging characters, print false and if it is possible to make it a palindrome, print true
My code:
       String a=new String(br.readLine());      //given string
   int n= a.length();
                    int j=0,k=n-1,count=0;
        boolean flag=false;
        for(int i=0;i<n;i++)
        {
            if(a.charAt(i)=='*')
                continue;        //for skipping already shifted  chars
            int ix = a.indexOf(a.charAt(i), i+1);
            if(ix >= 0)
            {                   a=a.substring(0,i+1)+a.substring(i+1, ix) + "*" + a.substring(ix+1);
            }
            else
            {
                count++;        //number of unique chars which can only be 1 or 0
                if(count<=1 && n%2==1)
                {

                    a=a.replaceFirst(a.substring(i,i+1),"*");                  //giving middle position to the only unique char at center and replacing it with *
                }
                else
                {
                    System.out.println("false");    //if more than one unique char, palindrome not possible
                    flag=true; // shows not possible
                    break;
                }
            }

        }
        if(!flag) // if possible
        {
            System.out.println("true");
        }

Comment: I think this question would be a better fit for the Stack Exchange site [Code Review](https://codereview.stackexchange.com/). The problem seems a little too broad for Stack Overflow.
Comment: It is hard to understand whats going on with the code, explain your algorithm from a high level point of view. To me the approach would be : if the two ends do not match, first check for a matching char from right if it is there swap their positions, if a matching char not found, try the left. Then remove them , and keep working on the remaining string. Base case is either you have one character or two characters ( check for equality there ). If you couldn't find a character to swap return false.
Comment: Do you mean you have to find a combination of the characters that is a palindrome?
Comment: At first glance, you rely to much on string operations. Couldn't you work with individual characters instead?
Comment: @Mauriceperry yes, I want to find the combination of chars of the given string which will make make it a palindrome and return their new positions
Comment: updated my code after reducing string methods
Answer: One obvious optimization would replace:
        if(a.substring(i+1).contains(a.substring(i,i+1)))
        {
            ans[j++]=i;                           //storing new positions in ans array
            ans[k--]=a.substring(i+1).indexOf(a.charAt(i))+1+i;
            a=a.substring(0,i+1)+a.substring(i+1).replaceFirst(a.substring(i,i+1),"*");                 //replacing the shifted char with *
        }

with:
        int ix = a.indexOf(a.charAt(i), i+1);
        if(ix >= 0)
        {
            ans[j++]=i;                           //storing new positions in ans array
            ans[k--]=ix;
            a=a.substring(0,i+1)+a.substring(i+1, ix) + "*" + a.substring(ix+1);
        }

UPDATE
I wonder if the following code would be faster. There is no indexOf on arrays, so I had to do a loop, but there is no string manipulation:
    char[] c = a.toCharArray();
    int n= c.length;
    int ans[]=new int[n];  // for storing new positions after shifting
    int j=0,k=n-1,count=0;
    boolean flag=false;
    for(int i=0; i < n; i++)
    {
        char ch = c[i];
        if(ch=='*')
            continue;        //for skipping already shifted  chars
        int ix = i;
        do {
            ++ix;
        } while (ix < n && c[ix] != ch);
        if(ix < n)
        {
            ans[j++]=i;
            ans[k--]=ix;
            c[ix] = '*';
        }
        else
        {
            count++;        //number of unique chars which can only be 1 or 0
            if(count<=1 && n%2==1)
            {
                ans[(int)n/2]=i;
                c[i] = '*';
            }
            else
            {
                System.out.println("-1");   //if more than one unique char, palindrome not possible
                flag=true; // shows not possible
                break;
            }
        }

    }

UPDATE 2
You can also stop when j has reached n/2:
    char[] c = a.toCharArray();
    int n= c.length;
    int ans[]=new int[n];  // for storing new positions after shifting
    int j=0,k=n-1,count=0,half=n/2;
    boolean flag=false;
    for(int i=0; i < n; i++)
    {
        char ch = c[i];
        if(ch=='*')
            continue;        //for skipping already shifted  chars
        int ix = i;
        do {
            ++ix;
        } while (ix < n && c[ix] != ch);
        if(ix < n)
        {
            ans[j++]=i;
            ans[k--]=ix;
            c[ix] = '*';
            if (j > half) {
                break;
            }
        }
        else
        {
            count++;        //number of unique chars which can only be 1 or 0
            if(count<=1 && n%2==1)
            {
                ans[half]=i;
                c[i] = '*';
            }
            else
            {
                System.out.println("-1");   //if more than one unique char, palindrome not possible
                flag=true; // shows not possible
                break;
            }
        }

    }

Comment: will it reduce the time complexity that much ?will it work  for n=10^5?
Comment: @sahilmehta It reduces the number of string operations, and it will definitely be faster, that said, You'd be better of with a `char[]`instead of a String.
Comment: @sahilmehta or in addition to a String
Comment: you mean I should operate the code on char[] instead of string?
Comment: your suggested code was helpful it reduced the time complexity a bit but still code is exceeding time limit for a test case in n=10^5
Comment: @sahilmehta the complexity doesn't change: it's still O(n^2), but from what I have measured, the last version is like 100 times faster than the original one.
Comment: thanks. your code works fine with the constraints and within time limit.


Help identifying something in guitar tablature?

Question:
Hey, I'm having trouble identifying what those two arcs are. The dotted one going over and the solid one going under.
I'm trying to re-create this tab in Guitar Pro 6, so that I can listen to it as it helps me play better.
This is the tab for the song Layover by Michael Hedges from Andy McKee's Joyland tablature book.
Comment: The octave sign seems to me to indicate that you should play the artificial harmonic an octave higher.
Comment: @NeilMeyer - that's the only way it'll sound - an octave higher than written.
Answer: They are both just ties to indicate that you sustain the note for 4+2+1.5 beats (or an eight note less than two bars).  The dashed one is dashed because it applies to the harmonic notes.  Note that you hold the F on the 6th string against the fretboard, but induce a harmonic at the 7th fret.
The wavy vertical line indicates that the "chord" should be rapidly arpeggiated -- in this case it means that the harmonic note should be played ever so slightly after the fretted note.
Comment: Any ideas how the arpeggiation wavy lines should be played?
Comment: F normally? It's normally on 1st fret, but this is tuned to open D. The harmonic will work on 7th OR 19th fret without the jiggery pokery. Use l.h. above fret 7, or, easier, use r.h. above fret 19. OR - 5th fret harm. on B string - less stretch!
Comment: @NeilMeyer - just play the lower note slightly before the upper.
Comment: Hey, thanks. I'm not sure if you use Guitar Pro 6, or any version at all, but do you have any idea on how to mimic that tie in the program? I was playing around with it, but can't seem to get it right. Like I said, I'm putting the tab into GP6, so I can listen to while I play it.


Does use of ReLU activation in hidden layers a neural network for regression make it expensive (stacked) linear regression?

Question: Neural Networks (NNs) are tricky to play with when it comes to regression problems. Often the output unit of a neural network contains linear activation. However, many posts suggest using ReLU activation for the hidden layers (for instance, look at this question).
Now let's consider a problem $(X,y)$, where $X=(x_1,x_2)$ and $y \in \mathbb{R}$. Consider a NN with a single hidden layer with two neurons, each with ReLU activation. Let the weights be denoted as:
Inputs - Hidden unit$_1$: $w_{11}, w_{12}$
Inputs - Hidden unit$_2$: $w_{21}, w_{22}$
Hidden layer - Output: $v_1, v_2$.
(no bias is involved anywhere.)
The following computations are straightforward. $ReLU(z) = max(0,z)$ (in case you don't know)
$a_1 = ReLU(z_1) = ReLU(w_{11}x_1 + w_{12}x_2) = either~0~or~w_{11}x_1 + w_{12}x_2$
$a_2 = ReLU(z_2) = ReLU(w_{21}x_1 + w_{22}x_2) = either~0~or~w_{21}x_1 + w_{22}x_2$
In the end, the output from the network will be one of the following four:

$\hat{y} = 0$; when both $a_{1,2} = 0$
$\hat{y} = v_2(w_{21}x_1 + w_{22}x_2)$; when $a_1=0~and~a_2 \neq 0$
$\hat{y} = v_1(w_{11}x_1 + w_{12}x_2)$; when $a_1 \neq 0~and~a_2=0$
$\hat{y} = v_1(w_{11}x_1 + w_{12}x_2) + v_2(w_{21}x_1 + w_{22}x_2)$; when $a_{1,2} \neq 0$

In all the cases above, $\hat{y}$ can be written as $\hat{y} = U_1x_1 + U_2x_2$, where $U = vw$.
So, does this mean that using ReLU activation in the hidden layers of a deep network, the network would become a linear perception (or linear regression)?
Answer: No. Because there is no almost linear, there's only linear or nonlinear. Otherwise, I'd be saying that ReLU is a linear function "because it is always linear with a slope 0 or 1."
ReLU is a nonlinear function with non zero convexity. If you step back you'll see a world of difference between a line and ReLU. ReLU is cousin of a highly convex function.

Yes, its convexity is concentrated in a small region but that's also what makes it so useful too: your weights "locate" convexities in the domain, helping the NN approximate the shapes so well.
I'd also say that having a protractor is not the same as having only a ruler. You can draw complex surface much faster with a protractor than with only a ruler, because to make a simple angle with only a ruler would require quite a bit of trigonometry while with a protractor it's just a quick single operation.
Comment: you are dealing with a piece wise linear function, and looking at each linear piece in isolation - that's what wrong. you can take any continuous function and approximate it with a piece wise linear function, using small pieces. so in your framework of thought what NN accomplishes is that it finds the appropriate knot points and picks the right slopes for each piece. that's quite a bit and that's what a simple linear regression can't do out of the box.
Comment: Great answer. But, what is wrong with my mathematical reasoning in my question?


How to loop through text files in R?

Question: I have three text files . I want to do some calculations as shown below and plot the results.
All text files contain 14 columns X1 to X14 and 601 rows.
This code basically read X3 from all three files and do some computations and then return the result.
   ref= read.table("D:\\ref.txt", sep="",header=TRUE)# read first file
   sour1 = read.table("D:\\sour1.txt", sep="",header=TRUE)# read second file
   sour2= read.table("D:\\sour2.txt", sep="",header=TRUE,na.rm=TRUE)# read third file
  result1 = (mean(ref$X3) - ((sd(ref$X3)/sd(sour1$X3))*mean(sour1$X3))+ ((sd(ref$X3)/sd(sour1$X3)*sour1$X3))) # calculate using ref and sour1
result2 = ((mean(ref$X3) - ((sd(ref$X3)/sd(sour2$X3,na.rm=TRUE))*mean(sour2$X3,na.rm=TRUE))+((sd(ref$X3)/sd(sour2$X3,na.rm=TRUE)*sour2$X3))))  # calculate using ref and sour2
plot(ref$X3,result1,ylab="Weight in pounds",xlab="Weight in pounds",col=2)
points(ref$X3,ref$X3, col = 'green')
points(ref$X3,result2, col = 'blue') # from this I get one plot showing 3 variables on y axis against one on x axis.

This is only plot using  X3 from all data, but still I have the other columns X1  to X14
My question is how can I do the same thing with all other columns, and finally will get 14 plots.
Comment: You should give some sample of your data not all the files, and simplify the question to include only the part on interest ( applying the function to others columns), otherwise this question is too localized.
Comment: Cuurently your code relies on 2 columns (`X3` and `X1`).  Did you mean that?  (Looping over 2 columns implies different bahviour to looping over 1 column.)
Comment: Sorry I typed wrongly.My  code relies on 1 column: X3
Answer: To get Xi for i from 1 to 14, you've got to use paste function and the alternative way of getting elements in a list : ref[["X3"]] instead of ref$X3
It gives on your example :
for (i in 1:14){
        name <- paste('X',i,sep='')
        result1 = (mean(ref[[name]]) - ((sd(ref[[name]])/sd(sour1[[name]]))*mean(sour1[[name]]))+ ((sd(ref[[name]])/sd(sour1[[name]])*sour1[[name]]))) # calculate using ref and sour1
        result2 = ((mean(ref[[name]]) - ((sd(ref[[name]])/sd(sour2[[name]],na.rm=TRUE))*mean(sour2[[name]],na.rm=TRUE))+((sd(ref[[name]])/sd(sour2[[name]],na.rm=TRUE)*sour2[[name]]))))  # calculate using ref and sour2
        plot(ref[[name]],result1,ylab="Weight in pounds",xlab="Weight in pounds",col=2)
        points(ref[[name]],ref$X1, col = 'green')
        points(ref[[name]],result2, col = 'blue')
}

Answer: As Pop mentioned, you need to create a list of column names and loop over those.
lapply provides a lightly more elegant alternative to a for loop.
By laying out your code more clearly, you can see that you have some odd double brackets in the lines assigning result1 and result2.  Consider breaking these lines into smaller calculations for clarity.
columns <- paste0("X", 1:14)
lapply(
  columns,
  function(column)
  {
    result1 <- (
      mean(ref[[column]]) -
      ((sd(ref[[column]]) / sd(sour1[[column]])) * mean(sour1[[column]])) +
      ((sd(ref[[column]]) / sd(sour1[[column]]) * sour1[[column]]))
    )   # calculate using ref and sour1
    result2 <- ((
      mean(ref[[column]]) -
      ((sd(ref[[column]]) / sd(sour2[[column]], na.rm=TRUE)) * mean(sour2[[column]], na.rm=TRUE)) +
      ((sd(ref[[column]]) / sd(sour2[[column]], na.rm=TRUE) * sour2[[column]]))
    ))  # calculate using ref and sour2
    plot(
      ref[[column]],
      result1,
      ylab = "Weight in pounds",
      xlab = "Weight in pounds",
      col  = 2
    )
    points(ref[[column]], ref[[column]], col = 'green')
    points(ref[[column]], result2, col = 'blue')
  }
)

Comment: It may mean that there are `NA` or `Inf` in what you plot, therefore you have errors in your calculus or these `NA` values were already in your files.
Comment: If your column is all missing and you do `na.rm = TRUE` then you are left with no data. If you pass no data to `max` then it returns `-Inf`.  Try looking at your data with `str`, `summary`, `head`, `View`, etc.
Comment: Thanks for your help.But I got this error:`Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf`
Comment: Oh yes there are NAs in my data. but I treated them `na.rm=TRUE`.should not be a problem!
Comment: any idea on how to deal with this problems.To get rid of NAs when plotting.
Comment: @Richie Cotton Thanks.I will take care of the NAs. But then the 13 plots will be one over the others so I have to close one to see the others. Is there away to plot them all side by side?
Comment: Combining multiple plots is a separate question.  Take a look at the `ggplot2` package.  If you get stuck try the `lattice` package.  If you are still stuck look at the `layout` function.  If you are still stuck then ask a new question.

How to loop through text files in R?


Numark Mixtrack Pro as a midi controller?

Question: Can I use a Numark Mixtrack Pro as a midi controller in Ableton or other DAW? For example map fader/knob to cutoff synth or other parameters?
Answer: Yep!
As stated on their website (https://www.numark.com/product/mixtrackpro):

Mixtrack Pro is also a MIDI-over-USB controller

To map to parameters in Ableton, under Preferences -> Midi Link make sure the "remote" option is on, then click the midi button in the top right corner, anything highlighted is mappable, just click what you want to map to set it.


Resize & Crop Image Style Lowers Resolution

Question: Whenever I try to implement a "resize & crop" image style on the display of a node in Drupal 7, the image also comes out with a lower resolution than the original file. Any idea why this might be happening or how I can get it to stop?
Thank you.
Answer: The jpeg quality is defined at 75%, this can be changed at /admin/config/media/image-toolkit


Eigenvector and orthogonal matrix

Question: If $D$ is a diagonal matrix and $P$ is an orthogonal matrix where $P^{-1} = P^T$.
If $y= PDP^T$ , why is $y^{100} = P D^{100} P^T$ and not $P^{100} D^{100} {(P^T)}^{100}$ ?
Comment: Hi and welcome to the site, please consider learning mathjax / latex typesetting as it is used much on this site. I can help show you this first time how you can do it. You can hit "edit" button to see how the code is written, and there is also some tutorial here on the site you can probably find.
Comment: [Here](https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference) it is!
Answer: Well, let's take a look at $y^2 = PDP^T \cdot PDP^T$. The $P^T$ and $P$ in the middle cancel out because $P^T$ is the inverse of $P$. That means this can be simplified to $y^2 = PD^2P^T$. Do you see the pattern?

Eigenvector and orthogonal matrix


Error Probability: Can anyone share a detailed solution to the problem?

Question: Seventy data clerks at the Department of Motor Vehicles make an average of 18 errors per day, normally distributed with a standard deviation of 4. A field auditor can check the work of 15 clerks per day. What is the probability that the average number of errors in a group of 15 clerks checked on one day is
(a) Fewer than 15.5?
(b) Greater than 20?
Comment: Does each clerk make an average of 18 errors per day or all seventy of them combined?
Answer: Let $X \sim N(18, 16)$ be the random variable representing how many errors 70 clerks make in a day.
Then $Y=\frac{15}{70}X\sim N(\frac{15}{70} (18), (\frac{15}{70})^2 (16))$
So $Y\sim N(\frac{27}{7}, \frac{36}{49}$)
and $P(Y\le 15.5)$=$P\left(\frac{Y-E[Y]}{\sqrt{Var(Y)}}\le \frac{15.5-E[Y]}{\sqrt{Var(Y)}}\right)$,
where the expectation and variance are given above and where you'd just use your standard normal distribution tables to compute an answer.


Tick box doesnt show in internet explorer

Question: Sorry I've never come across this problem before.
My check boxes dont appear in IE but do in FF. Why? I dont know a second way to do tick boxes.
    <%if termandcon = "" and not error="" then warningman = "You Must Tick This Box"%>

      <input   type="checkbox"       name="termandcon" <%if termandcon = "on"then%> checked <%end if%> style="height:1px; width:1px;"/>

         I accept the terms & conditions

    *
    <%warning(termandcon)%>

Comment: You seem to be missing a tag. Your code is definitely no pure HTML. Which templating language are you using? Also it might be useful to paste the resulting HTML source code.
Comment:
Comment: What's the point to the 1px/1px size ?
Comment: Right.

style="height:1px; width:1px;"

gives me a small checkbox in FF but doesnt show at all in IE.
Comment: The behavior should be undefined when applying appearance attributes to check-boxes/radio-buttons
Answer:  <input
     type="checkbox" name="termandcon"
     <%if termandcon = "on"then%> checked <%end if%>
     style="height:1px; width:1px;"/>

don't you see anything strange here?
height:1px; width:1px;
Answer: If you remove the style portion then it should work fine.
<input type="checkbox" name="termandcon"
    <%if termandcon = "on"then%> checked="checked" <%end if%>/>


Como limitar casas decimais em C#

Question: Fiz uma aplicação para calcular a média aritmética de 3 notas. Meu formulário tem 3 TextBox que recebe a nota e um botão que calcula a média. O resultado é imprimido em um Label, como faço para limitar a quantidade de números após a ","?
<code> private void btnCalcular_Click(object sender, EventArgs e)
    {
        //DECLARAÇÃO DE VARIÁVEIS
        double num1, num2, num3, resultado;

        //CONVERSÃO DE STRING PARA DOUBLE
        num1 = Convert.ToDouble(txtN1.Text);
        num2 = Convert.ToDouble(txtN2.Text);
        num3 = Convert.ToDouble(txtN3.Text);

        //OPERAÇÃO DE CÁLCULO
        resultado = (num1 + num2 + num3) / 3;

        lblResult.Text = resultado.ToString();

        lblResult.Text = resultado.ToString();

        if (resultado >= 6)
        {
            MessageBox.Show("Aluno aprovado!", "Status do aluno", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        else
        {
            MessageBox.Show("Aluno reprovado", "Status do aluno", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }
    }
</code>
Comment: https://pt.stackoverflow.com/questions/290894/casas-decimais-c
Comment: A resposta resolveu sua dúvida? Acha que pode aceitá-la? Veja o [tour] se não souber como faz. Isso ajudaria muito indicar que a solução foi útil para você. Também pode votar em qualquer pergunta ou resposta que achar útil no site todo.
Answer: Você precisa formatar o texto a ser usado, não pode usar de forma direta, assim para duas casas:
<code>$"{resultado:0.##}"
</code>
Mas se quiser mudar o valor e não só aprender, o que não é o que o código faz agora, aí teria que manipulá-lo (e pode dar um valor diferente do que deu na formatação, então tem que decidir qual é a melhor estratégia para seu cenário). Seria algo como:
<code>Round(resultado, 2)
</code>
Veja funcionando no ideone. E no .NET Fiddle. Também coloquei no GitHub para referência futura.
Tem outros problemas no código, ainda que funcione.

Como limitar casas decimais em C#


How to understand point functions

Question: I am having trouble understanding the meaning of point functions. I know the mathematical definition but i don't think that i truly understand there true meaning.
Point functions:
Suppose $(X,d)$ is a metric space and $z∈X$. Then a nonnegative real function
$x \rightarrow d(x,z)$ defined on $X$ is a point function at $z$.
I have tried looking for examples w/ no luck.
Comment: I never heard of point functions but the function you defined there, gives the distance between x and z in the metric of X. How are those point functions used in your text?
Comment: From your link, they're just saying that if you know the point function at $0$ you can recover the entire metric using the fact that subtraction is defined in $\mathbb{R}^n$. Was that part clear? What kind of examples are you looking for? The author is just using this as an interesting example.
Answer: By your description, it seems that given a point $z \in X$, the point function $\delta_z(x)$ returns the distance between $x$ and $z$.
For example, in $\mathbb{R}$, let $\delta_0$ be a point function at $0$. Then $\delta_0(3)$ would be equivalent to $d(3,0)$, or the distance between $3$ and $0$, which is $3$. Similarly, let $\delta_8$ be a point function at $8$. Then $\delta_8(3) = d(3,8) = 5$.
Please elaborate on what you mean by "I don't think that I truly understand there [sic; should be 'their'] true meaning."

How to understand point functions


Asymptotics of an integral involving the exponential integral

Question: Consider the integral:
$$
I(a)=\int_a^\infty e^x E_1(x)\dfrac{dx}{x},
$$
where $a>0$ and $E_1(x)$ is the exponential integral function.
I would like to better understand the behavior of $I(a)$ for $a\to 0+$.
For example, from the double inequality
$$
\dfrac{1}{x+1}<e^{x}E_1(x)<\dfrac{1}{x},\ \ x>0,
$$
we readily get
$$
\log(1+1/a)<I(a)<\dfrac{1}{a}.
$$
The (more fine) double inequality
$$
\dfrac{1}{2}\log(1+2/x)<e^{x}E_1(x)<\log(1+1/x),\ \ x>0,
$$
yields
$$
1/12 (\pi^2 + 3 \log^2(2) + 3 \log(a/4)\log(a) + 6 Li_2(-a/2))<I(a)<-Li_2(-1/a),
$$
where $Li_2(x)$ is the poly-log function.
Can these bounds be refined? For example, are there tight bounds for the poly-log function?
Answer: $$I(a)=\int_a^\infty e^x E_1(x)\dfrac{dx}{x}=\int_a^\infty \frac{e^x}xdx\left(\int_x^\infty\frac{e^{-t}}tdt\right)\overset{t=xs}{=}\int_a^\infty \frac{e^x}xdx\left(\int_1^\infty\frac{e^{-xs}}sds\right)$$
$$\overset{x=at}{=}\int_1^\infty \frac{e^{at}}tdt\left(\int_1^\infty\frac{e^{-ats}}sds\right)=\int_1^\infty\frac{dt}t\int_0^\infty\frac{e^{-ats}}{1+s}ds$$
Integrating by part
$$=\int_1^\infty\frac{dt}t\left(\ln(1+s)e^{-ats}\,\bigg|_0^\infty+at\int_0^\infty\ln(1+s)e^{-ats}ds\right)=\int_0^\infty\frac{\ln(1+s)}se^{-as}ds\tag{1}$$
Making the substitution $as=t$ and integrating by part
$$=\ln s\ln\frac{s+a}ae^{-s}\,\bigg|_0^\infty-\int_0^\infty\frac{\ln s}{a+s}e^{-s}ds+\int_0^\infty\ln s\ln\frac{a+s}ae^{-s}ds$$
$$=\int_0^\infty\ln s\ln(a+s)e^{-s}ds+\gamma\ln a-\int_0^\infty\frac{\ln s}{a+s}e^{-s}ds$$
The first integral converges at $a=0$; therefore
$$I(a)=\gamma\ln a+\int_0^\infty\ln^2s\,e^{-s}ds-\int_0^\infty\frac{\ln s}{a+s}e^{-s}ds+o(1)\tag{2}$$
Using $\displaystyle \frac1{s+a}=\int_0^\infty e^{-t(s+a)}dt$, the last integral in (2) can be evaluated. Changing the order of integration,
$$-\int_0^\infty\frac{\ln s}{a+s}e^{-s}ds=-\int_0^\infty e^{-ta}dt\int_0^\infty\ln s\,e^{-s(t+1)}ds$$
$$=-\int_0^\infty\frac{dt}{1+t}e^{-at}\left(-\gamma-\ln(1+t)\right)=e^a\int_1^\infty\frac{\ln x}xe^{-ax}dx+\gamma e^a\int_1^\infty\frac{e^{-ax}}xdx$$
Integrating by part and keeping only non-vanishing at $a\to 0$ terms, we get
$$-\int_0^\infty\frac{\ln s}{a+s}e^{-s}ds=\frac{e^a}2\int_a^\infty(\ln x-\ln a)^2e^{-x}dx-\gamma\ln a+\gamma e^a\int_a^\infty\ln xe^{-x}dx$$
$$=\frac{\ln^2a}2+\frac12\int_0^\infty\ln^2xe^{-x}dx-\gamma^2+o(1)=\frac{\ln^2a}2+\frac{\pi^2}{12}-\frac{\gamma^2}2+o(1)\tag{3}$$
Putting (3) into (2)
$$\boxed{\,\,I(a)=\frac{\ln^2a}2+\gamma\ln a+\frac{\gamma^2}2+\frac{\pi^2}4+o(1)\,\,}$$
Answer: $$I(a)=\int_a^\infty\frac{ e^x} x E_1(x)\,dx$$ As usual, the result is given in terms of hypergeometric functions and some of their derivatives
$$I(a)=  \text{Ei}(a) \,(\log (a)+\gamma )-\frac 12 \log (a)
  \, (\log (a)+2 \gamma )+\frac{(\pi ^2-2 \gamma ^2)}4-$$
$$2 a \, _3F_3(1,1,1;2,2,2;a)-\frac{1}{2}\, _1F_1^{(2,0,0)}(0;1;a)$$
Expanded as series around $a=0^+$
$$\color{blue}{I(a)=\left(\gamma +a+\frac{a^2}{4}+\frac{a^3}{18} \right)\,\log(a)+\frac{1}{2}\log ^2(a)+}$$
$$\color{blue}{\frac{2 \gamma ^2+\pi ^2}{4}+(\gamma -2)
   a+\frac{\gamma -2}{4}  a^2+\frac{6 \gamma -13}{108} a^3}$$ which is a very good approximation up to $a=1$.
Just to give an idea
$$\int_0^{\frac 12} \Big(I(a)-\text{approximation}\Big)^2\,da=1.81 \times 10^{-7}$$
$$\int_0^1 \Big(I(a)-\text{approximation}\Big)^2\,da=5.84 \times 10^{-5}$$


Escaping Variables in View?

Question: I'm wondering how to escape variables in my view, in my Node.js project.
For example #{name} in my .jade view file seems vulnerable to SQL Injection or XSS. Is there a standard way to resolve this? I know in ruby I would do <%= h name %> for example...
Comment: IIRC, Jade escapes by default.
Comment: Yes jade escapes by default, use !{} if you don't want escaping.
Answer: Actually want #{} for some reason? escape it!

p \#{something}
now we have
#{something}

We can also utilize the unescaped variant !{html}, so the following will result in a literal script tag:

- var html = ""
| !{html}

from https://github.com/visionmedia/jade#readme
Comment: I see. So is there any difference between (message is a variable):
p= message
p #{message}
Comment: The variables message and #{message} are the same, it just depends on where/how you use them.  The following article helped me http://stackoverflow.com/questions/14709560/in-jade-why-can-i-sometimes-use-variables-as-is-and-on-other-times-have-to-encl

Escaping Variables in View?


Best way to use 4 ordinal variables in regression analysis?

Question: I have 4 likert scale questions (coded 1= never through 5=always) that are to be dependent variables. I have 125 observations and 3 predictors. My initial thought was to just use ordinal regression on each question/dependent variable. However, given that there are 5 outcome levels, this is a lot to report. I am curious if there could be a meaningful way to combine the likert scale questions into one dependent variable.
Thanks for any advice.
Comment: If the questions are related, I've seen people create an aggregated variable and then treat it like a single continuous predictor. I'm not clear on the theoretical motivation for that, so I'm not comfortable giving this an answer.
Comment: Duplicate of http://stats.stackexchange.com/questions/10382/general-advice-on-forming-an-index-of-attitude-to-the-environment-from-a-set-of/10522#10522
Answer: This will depend on the questions themselves. One approach would be to use a factor analysis approach to determine how well the items "load" on to the construct of interest. Are they all questions intended to measure the same underlying construct?
If you find that the four items are reasonably similar in their capture of the target construct, you might use a dimensionality reduction technique (PCA, median score across questions) to simplify. Note that this approach makes some assumptions about your items/data so you should think carefully about those assumptions.
The approach with the fewest assumptions is to proceed as you have described---one ordinal regression (e.g., cumulative link model) per item.
One tweak to simplify though (again assuming your questions target the same underlying construct) is that you could use a cumulative link mixed model (CLMM) where you predict the ratings for each of your four items based on your IVs and a random effect of participant (or whatever source generated your ratings).
<code>library(ordinal)
model <- clmm(rating ~ IVs + (1|participant_id), data = your_data)
summary(model)
</code>
The value of creating an aggregated variable will vary depending on the number of items you have and 4 is on the low end of where that approach would be acceptable. I would not suggest this route but see this question for resources on this approach.


Combinando o valor de colunas com MySQL

Question: Estou trabalhando em um relatório em MySQL onde preciso mostrar um percentual de diversos eventos que ocorreram com um grupo de entidades.
A estrutura da minha tabela é a seguinte:
| id | eventoA | eventoB | eventoC | eventoD |
|----|---------|---------|---------|---------|
| 1  | 0       | 0       | 0       | 0       |
| 2  | 1       | 0       | 0       | 0       |
| 3  | 1       | 0       | 0       | 0       |
| 4  | 0       | 0       | 1       | 0       |
| 5  | 0       | 1       | 0       | 0       |
| 6  | 1       | 1       | 0       | 0       |
| 7  | 1       | 1       | 0       | 0       |
| 8  | 1       | 0       | 1       | 0       |
| 9  | 0       | 0       | 1       | 0       |
| 10 | 0       | 0       | 0       | 0       |

As colunas EventoA, EventoB e assim por diante são do tipo BIT e são atualizadas pela aplicação quando determinado evento é disparado para aquela entidade. Hoje consigo gerar esse relatório com a seguinte query:
SELECT COUNT(`id`) AS `Total`,
  SUM(`eventoA`) AS `eventoDisparado`,
  COUNT(`id`) - SUM(`eventoA`) AS `eventoNaoDisparado`
FROM tabela;

Resultado da query:

Total: 10 , eventoDisparado: 5, eventoNaoDisparado: 5

Porém dessa forma não consigo combinar múltiplos eventos pois o número de eventos acaba não batendo:
SELECT COUNT(`id`) AS `Total`,
  SUM(`eventoA`) + SUM(`eventoB`) AS `eventoDisparado`,
  COUNT(`id`) - SUM(`eventoA`) + SUM(`eventoB`) AS `eventoNaoDisparado`
FROM tabela;

Resultado esperado:

Total: 10 , eventoDisparado: 6, eventoNaoDisparado: 4

Resultado obtido

Total: 10 , eventoDisparado: 8, eventoNaoDisparado: 2

Gostaria de certa forma combinar as colunas eventoA e eventoB dessa forma:
| id | eventoA | eventoB | eventoA + eventoB |
|----|---------|---------|-------------------|
| 1  | 0       | 0       | 0                 |
| 2  | 1       | 0       | 1                 |
| 3  | 1       | 0       | 1                 |
| 4  | 0       | 0       | 0                 |
| 5  | 0       | 1       | 1                 |
| 6  | 1       | 1       | 1                 |
| 7  | 1       | 1       | 1                 |
| 8  | 1       | 0       | 1                 |
| 9  | 0       | 0       | 0                 |
| 10 | 0       | 0       | 0                 |

Talvez consiga o resultado esperado utilizando um OR bitwise.
É possível utilizar esse tipo de operadores diretamente numa query? Quais outras alternativas eu tenho para conseguir o resultado esperado?
Comment: Não sei se entendi o que você precisa mas no mínima dá para fazer uma função que facilite o que deseja.
Comment: Baseado na tabela que você exibiu, qual é o resultado esperado? Teria como atualizar a pergunta com essa informação? Se possível em estrutura tabular, como você mostrou a tabela acima.
Comment: @cantoni ficou mais claro ?
Comment: Sim, ficou mais claro @gmsantos, obrigado. Uma dúvida, quantos campos de eventos são?
Comment: @gmsantos, no SQL Server funcionou a operação bit a bit, precisamos ver agora no MySQL. Vou dar uma checada aqui.
Comment: São 7 tipos de eventos
Comment: Ok, vou postar uma resposta aqui e veja se ela te atende.
Answer: Fiz um teste no SQL Server (para o MySQL ver o final da resposta) com duas versões, uma com os campos do tipo int e outra com o tipo bit. A versão do tipo int funcionou normalmente. Vou deixá-la aqui enquanto verifico a versão do tipo bit
Versão com os campos do tipo int:
create table teste (
  id int,
  eventoA int,
  eventoB int,
  eventoC int
);

insert into teste (id,eventoA,eventoB,eventoC) values (1,0,0,0);
insert into teste (id,eventoA,eventoB,eventoC) values (2,1,0,1);
insert into teste (id,eventoA,eventoB,eventoC) values (3,1,0,1);
insert into teste (id,eventoA,eventoB,eventoC) values (4,0,0,0);
insert into teste (id,eventoA,eventoB,eventoC) values (5,0,1,1);
insert into teste (id,eventoA,eventoB,eventoC) values (6,1,1,1);
insert into teste (id,eventoA,eventoB,eventoC) values (7,1,1,1);
insert into teste (id,eventoA,eventoB,eventoC) values (8,1,0,1);
insert into teste (id,eventoA,eventoB,eventoC) values (9,0,0,0);
insert into teste (id,eventoA,eventoB,eventoC) values (10,0,0,0);

SELECT
  COUNT(*) TOTAL,
  SUM(CASE WHEN EVENTO = 0 THEN 1 ELSE 0 END) EVENTO_NAO_DISPARADO,
  SUM(CASE WHEN EVENTO = 1 THEN 1 ELSE 0 END) EVENTO_DISPARADO
FROM
(
    SELECT
        ID,
        CASE WHEN SUM(eventoA + eventoB + eventoC) >= 1 THEN 1 ELSE 0 END EVENTO
    FROM TESTE
    GROUP BY ID
) A

ATUALIZAÇÃO - Versão com o tipo bit:
create table teste (
  id int,
  eventoA bit,
  eventoB bit,
  eventoC bit
)

insert into teste (id,eventoA,eventoB,eventoC) values (1,0,0,0)
insert into teste (id,eventoA,eventoB,eventoC) values (2,1,0,1)
insert into teste (id,eventoA,eventoB,eventoC) values (3,1,0,1)
insert into teste (id,eventoA,eventoB,eventoC) values (4,0,0,0)
insert into teste (id,eventoA,eventoB,eventoC) values (5,0,1,1)
insert into teste (id,eventoA,eventoB,eventoC) values (6,1,1,1)
insert into teste (id,eventoA,eventoB,eventoC) values (7,1,1,1)
insert into teste (id,eventoA,eventoB,eventoC) values (8,1,0,1)
insert into teste (id,eventoA,eventoB,eventoC) values (9,0,0,0)
insert into teste (id,eventoA,eventoB,eventoC) values (10,0,0,0)

SELECT
  COUNT(*) TOTAL,
  SUM(CASE WHEN EVENTO = 0 THEN 1 ELSE 0 END) EVENTO_NAO_DISPARADO,
  SUM(CASE WHEN EVENTO = 1 THEN 1 ELSE 0 END) EVENTO_DISPARADO
FROM
(
    SELECT
        ID,
        eventoA | eventoB | eventoC EVENTO
    FROM TESTE
) A

ATUALIZAÇAO 2 - Fiddle MySQL: http://sqlfiddle.com/#!9/20011/1/0
Nota: Não houve mudança para a versão com o tipo bit do SQL Server. A única coisa necessária foi incluir ";" ao final do Create Table e de cada Insert.
Comment: estou utilizando MySQL, poderia montar uma resposta para ele?
Comment: Vou utilizar o fiddle. Daqui a pouco chega aqui.
Answer: Fiquei curioso, tentei usar operadores Binários e deu certo.
select count(entidade) as Total,
SUM(evento_a | evento_b) as EventoDisparado
from evento;

Retorno: Total: 10, EventoDisparado: 6

Referência: Documentação do MySQL
Comment: Isso mesmo que estava procurando

Combinando o valor de colunas com MySQL


Good math books to discover stuff by programming

Question: I am asking for books/any other online sources with the following philosphy$^{[1]}$:

This is a mathematics, not a programming book. It's intended for students, mathematics teachers and mathematicians who are just starting to explore mathematics on their own computers. In studying it, and especially working through the problems, readers will get to know many new elementary topics and learn as much from the extensive exercises as from the examples

Which basically means you have some problems, and with your computers you find and discover new patterns, which are tedious to do by hand, and then you prove them without computer.
 Notes : $^{[1]}$ The only book I know is Arthur Engel's "Exploring mathematics with your computer" , but it's not available at a reasonable price. The text is copied from it's preface, from the preview at Amazon. I forgot to mention, but I know Project Euler too, and it moderately fits to my criterion.
$[2]$ Related to my this question .
$[3]$ Books like "A=B" doesn't quite fits to my criterion, because you don't prove stuff with hypergeometric series there,
the computer proves it for you. But "Computational recreations in mathematica" (by Illan Vardi) fits to my criterion, because you prove the stuff yourself.
Comment: While not being a book, Project Euler is good for number theoretical stuff.
Comment: @lovsovs PE doesn't really teach until you've already solved the problem and look at the posts
Comment: Some of these might be of interest: http://www.experimentalmath.info/books/
Comment: "A = B" deals with hypergeometric identities and computer use
Comment: @qwr I'd still classify that as educational.
Answer: The following quote is the starting point of chapter I in

Mathematics by Experiment, Plausible Reasoning in the 21st Century by J. Borwein and D. Bailey
''The computer has in turn changed the very nature of mathematical experience, suggesting for the first time that mathematics, like physics, may yet become an empirical discipline, a place where things are discovered because they are seen.''
From:  David Berlinski, ''Ground Zero: A Review of the The Pleasures of Counting, by T.W. Koerner,'' 1997

Both authors are well known for their highly creative usage of computational power in mathematical problems.

From the preface of the book:
Our goal in these books is to pesent a variety of accessible examples of modern mathematics where intelligent computing plays a significant role (along with a few examples showing the limitations of computing). We have concentrated primarily on examples from analysis and number theory, as this is where we have the most experience but there are numerous excursions into other areas of mathematics as well.

Here the authors also address the follow-up book: Experimentation in Mathematics - Computational Paths to Discovery.
Hint: You might also want to take a look at experimentalmath.info.
Comment: *Hint*: Did you check the comment section of the question, especially the comment by Hans ? :P
Comment: @ArbitraryKangaroo: No, but I've checked the link in your note section. Considering the stated preface in my answer I think these books might fit your needs.
Comment: Yeah, sure, definitely it fits, thanks, but its a bit high level for me. :(
Answer: Ilan Vardi, Computational Recreations in Mathematica.
Answer: A = B by Marko Petkovsek, Herbert S Wilf, & Doron Zeilberger
Comment: Check the updated question.
Answer: You might like Coding the Matrix, Linear Algebra
through Applications to Computer Science. There is also a MOOC for the course on Coursera.
The following excerpt is from the website:

The aim of this course is to provide students interested in computer science an introduction to vectors and matrices and their use in CS applications.
The course is driven by applications from areas chosen from among: computer vision, cryptography, game theory, graphics, information retrieval and web search, and machine learning.
Answer: http://www.math.tamu.edu/~harold.boas/courses/math696/Maple.html
See the lecture on "slicing bread". It uses Maple to explore some concepts in higher-dimensional Euclidean geometry. (The other lectures provide the necessary Maple background).


Understanding Rudin Theorem 3.3(c)

Question: Rudin's Theorem 3.3 states:

Suppose $\{s_n\}$, $\{t_n\}$ are complex sequences, and $\lim\limits_{n \to \infty} s_n = s$, $\lim\limits_{n \to \infty} t_n = t$. Then

(a) $\lim\limits_{n \to \infty} \left(s_n + t_n\right) = s + t$;

(b) $\lim\limits_{n \to \infty} cs_n = cs$,  $\lim\limits_{n \to \infty} \left(c + s_n\right) = c + s$, for any number $c$;

(c) $\lim\limits_{n \to \infty} s_n t_n = st$;

(d) $\lim\limits_{n \to \infty} \frac{1}{s_n} = \frac{1}{s}$, provided $s_n \neq 0$ ($n = 1, 2, 3, \ldots$), and $s \neq 0$.

I proved (a) and (b) without trouble. I'm trying to understand his proof of (c). He notes that for any $s$ we have:
$$
s_n t_n - st = (s_n - s)(t_n - t) + s(t_n - t) + t(s_n - s).
$$
My first question is: where does this come from? By brute-forcing the right-side, I can tell that this amounts to adding and subtracting $st$, $ts_n$, and $st_n$. But is there another reason why this holds? Rudin calls it an "identity,' but I've never seen it before.
Then, given $\epsilon > 0$, he takes $N_1, N_2$, so that $n \geq N_1$ implies $|s_n - s| < \sqrt{\epsilon}$ and $n \geq N_2$ implies $|t_n - t| < \sqrt{\epsilon}$. So for $n \geq \max(N_1, N_2)$, we have
\begin{align*}
|(s_n - s)(t_n - t) - 0| = |s_n - s||t_n - t| < \sqrt{\epsilon} \cdot \sqrt{\epsilon} = \epsilon,
\end{align*}
so $\lim\limits_{n \to \infty} (s_n - s)(t_n - t) = 0$.
Rudin then claims that the remaining terms in the first identity converge to $0$ by using $(a)$ and $b$. The first term converges, as we just proved, and the second and third are scaled versions of $t_n$ and $s_n$, so they converge. (I'm not sure how to word this exactly, since I need to have convergence first to use this identity, but I'm using the identity to prove they converge, so this is a very circular argument. I'm trying to figure out how best to word it.)
With that aside, we have:
\begin{align*}
\lim\limits_{n \to \infty} [(s_n t_n - st) & = \lim\limits_{n \to \infty}  (s_n - s)(t_n - t) + s(t_n - t) + t(s_n - s)] \\
& = \lim\limits_{n \to \infty} (s_n - s)(t_n - t) + \lim\limits_{n \to \infty} s (t_n - t) + \lim\limits_{n \to \infty} t(s_n - s) \\
& = 0 + \lim\limits_{n \to \infty} (st_n - st) + \lim\limits_{n \to \infty} (ts_n - ts) \\
& = s \lim\limits_{n \to \infty}t_n - st + t \lim\limits_{n \to \infty} s_n - ts \\
& = st - st + ts - ts \\
& = 0
\end{align*}
So $\lim\limits_{n \to \infty} (s_n t_n - st) = 0$. I'm trying to figure out exactly how this implies the result, because I can't just invoke part (a)/b to break the limit apart, as that requires convergence of $s_n t_n$, which is what I need. I think, however, it can be used to prove the fact directly.
Given $\epsilon > 0$, we use this limit to find $N$ so that for $n \geq N$, we have $|s_n t_n - st| < \epsilon$ for all $n \geq N$, so $(s_n t_n) \to st$.
As a general principle, am I allowed to just "break it apart," or was that just a coincidence?
I would appreciate any help and any feedback on what I've written above.
Comment: "Breaking $\lim_{n \to \infty} (s_n t_n - st) = 0$ apart" is justified because $s_n t_n = (s_n t_n - st) + (st)$ is the sum of two convergent sequences, so you can apply (a) directly.
Comment: The identity is justified by adding and subtracting the same terms as you pointed out. That is a pretty common strategy for proving facts in analysis. You _can_ actually deduce that $s_n t_n$ converges in a different, but equivalent, way than how you did it. This is because $st$ converges (constant), $s_n t_n - st$ converges (to $0$ as you've shown), and $s_n t_n$ is the sum of these two convergent sequences.
Comment: Your method was not a coincidence, in any case. Using the $\varepsilon$-definition for the limit of a sequence, you can prove more generally that $\lim_{n\to\infty} (a_n - a) = 0$ if and only if $\lim_{n\to\infty} a_n = a$. The absolute value inequality for $\varepsilon$ is actually the _same_ for both limits!
Answer: To state that
$$\lim_{n \to \infty}(a_nb_n-ab)=0 $$
Is equivalent to stating that for arbitrary $\varepsilon >0$
$$\exists N\in \mathbb{N}:\forall n \geq N, \,|(a_nb_n-ab)-0|<\varepsilon$$
but this also coincides with
$$\exists N\in \mathbb{N}:\forall n \geq N, \,|a_nb_n-ab|<\varepsilon$$
which means, by using the definition of limit,
$$\lim_{n \to \infty}a_nb_n = ab$$
Answer: Let $s_n=s+d_n$ and $t_n=t+e_n .$ Then Rudin's equality is $$s_nt_n-st=(s+d_n)(t+e_n)-st=d_ne_n+se_n+td_n.$$ The idea is that if $d_n\to 0$ and $e_n\to 0$ then $d_ne_n$ and $se_n$ and $td_n$ all $\to 0.$
For $d_ne_n$ it is simpler to observe that $|d_n|\le 1$ for all but finitely many $n$ (because $d_n\to 0$). So for all but finitely many $n$ we have $|d_ne_n|\le |e_n|,$ which, combined with $e_n\to 0,$ implies $d_ne_n\to 0.$

Understanding Rudin Theorem 3.3(c)


The Number Of Possible Four Digit Numbers With Ordered Digits

Question: I got the answer to the question: The number of possible $4$ digit numbers with ordered digits
But I wasn't sure if I could use the same principle outlined there to solve this:
How many possible 4 digit numbers are there where each digit is lower than or equal to the one before it?
This question would allow numbers such as 5332 which the previous question wouldn't.
How do I account for the extra solutions, past 210?
Answer: Use stars-and-bars and relate your original problem to the problem of having ten labeled buckets (labeled 0,1,2,...9) and four identical balls.
For example, an outcome of two balls in the bucket labeled 5, one ball in the bucket labeled 7 and one ball in the bucket labeled 2 would correspond to the four digit number $7552$.
Recognize now that all of the balls-and-buckets outcomes make sense as your four digit numbers in decreasing order with a small exception.

 The outcome of all balls in the bucket labeled 0 would correspond to the number "$0000$" which is not traditionally considered a four-digit number.
Comment: Ok, using your method it seems to give me the right answer... Thank You


If $4^x + 4^{-x} = 5$, what is $8^x + 8^{-x}$?

Question: I found this competition math problem that I haven't been able to solve.

If $4^x + 4^{-x} = 5$, find $8^x + 8^{-x}$.

Setting $a = 4^x$, we see the problem is equivalent to saying:

If $a + a^{-1} = 5$, find $a^{3/2} + a^{-3/2}$.

So $a$ is the solution to the quadratic equation $a^2 - 5a+ 1 = 0$.  Explicitly, $a = \frac{5 + \sqrt{21}}{2}$, which is a unit in the ring integers of $\mathbb Q(\sqrt{21})$.  The expression $a+a^{-1}$ is then equal to the trace of $a$.  Then $a^{3/2} + a^{-3/2}$ should be another trace.
I would love to see if there is a nice solution to this problem using algebraic number theory.  But it should also be possible to solve using elementary methods, since it is a high school competition math problem.
Comment: $~y^2 + \dfrac{1}{y^2} = \left(y + \dfrac{1}{y}\right)^2 - 2,~$ which implies that (without solving for $~2^x),~$ you can infer the value of $~\displaystyle \left(2^x + 2^{-x}\right).~$  From this, you can infer the value of $\displaystyle 2^{3x} + 2^{-3x} = \left(2^x + 2^{-x}\right)^3 - 3\left(2^x + 2^{-x}\right).$  The point of the question is that it is unnecessary to solve for either $~4^x~$ or $~2^x.$
Comment: Hint: use symmetric polynomial identities as [here](https://math.stackexchange.com/a/16337/242) or [here](https://math.stackexchange.com/a/1901150/242) (this is implicitly done in the answers below).
Answer: With $a=2^x$ we have $a^2+a^{-2}=5$ which means $a+\frac 1a=\sqrt 7$ or $a-\frac 1a=\sqrt 3$.  Then $a^3+a^{-3}=4\sqrt 7$.
Comment: To @Bryce: $(a + \tfrac{1}{a})^2 = a^2 + 2 + \frac{1}{a^2}$
Comment: Where does the fact that $a + \frac{1}{a} = \sqrt{7}$ or $a - \frac{1}{a} = \sqrt{3}$ come from?
Comment: @Bryce: use $a^2\pm 2+a^{-2}=(a\pm \frac 1a)^2$.
Comment: Thanks for this solution, very simple
Answer: A trigonometric solution.  Note
$$
4^x+4^{-x} = e^{x\ln 4}+e^{-x\ln 4} = 2 \cosh(x\ln 4) = 2 \cosh(2x\ln 2),
$$
and similarly
$$
8^x+8^{-x} = 2 \cosh(3x\log 2)
$$
Writing $t=x\log 2$ we have
$$
4^x+4^{-x} = 2\cosh(2t) = 4\cosh^2(t)-2
\\
8^x+8^{-x} = 2\cosh(3t) = 8\cosh^3(t)-6\cosh(t)
$$
Now we are given $4^x+4^{-x} = 5$, so
$$
5=4\cosh^2(t)-2
\\
\frac{7}{4}=\cosh^2(t)
\\
\frac{\sqrt{7}}{2} = \cosh(t)
$$
where we assumed $x$ is real so that $\cosh(t) > 0$.
Finally,
$$
8^x+8^{-x} = 8\cosh^3(t)-6\cosh(t) =
 8\left(\frac{\sqrt{7}}{2}\right)^3 - 6\left(\frac{\sqrt{7}}{2}\right)
=4\sqrt{7} .
$$
Answer: $(2^x+2^{-x})^2=4^x+4^{-x}+2=7$
$\therefore 8^x+8^{-x}=(2^x+2^{-x})^3-3(2^x+2^{-x})=4\sqrt7$


What is the median of an equally weighted mixture of two Normal Distributions?

Question: Suppose men's heights follow a normal distribution $X \sim \mathcal{N}(\mu_1,\sigma_1^2)$ and women's heights follow a normal distribution $Y \sim \mathcal{N}(\mu_2,\sigma_2^2)$. How can I find the median height of the entire population of adults, supposing an equal number of men and women?
I think the solution is a height $h$ such that $P(X<h) + P(Y<h) = 1$ but I don't know how to find that $h$.
Comment: Welcome to the site, @Jose. Do you know how to format formulae using $\LaTeX$? It looks like you started some formula, but did nit finish it.
Answer: Your expression in the bottom is correct and can be proved using the law of total probability. Let's define two random variables $H$ and $G$ such that $H|G=1 \sim \mathcal{N}(\mu_1, \sigma_1^2)$ and likewise for $H|G=0$.
So, $Pr(H<h) = 0.5$ = $Pr(H<h|G=0)\cdot Pr(G=0) + Pr(H<h|G=1)\cdot Pr(G=1) = 0.5$. The important thing is that with a perfect 0.5 mixture, the solution to the median is quite easy, just calculate the $h$ that is symmetrically in the middle of the densities, with equal and opposite $\mathcal{Z}$-scores.. i.e. solve
$$\left( \frac{h - \mu_1}{ \sigma_1^2} \right) = -\left( \frac{h - \mu_2}{ \sigma_2^2} \right) $$


Commutator subgroup of Heisenberg group.

Question: Dears,
Let $H$ be Heisenberg group, a group of $3\times 3$ matrices with $1$ on the main diagonal, zeros below, and elements of $\Bbb R$ above the main diagonal.
Its center is the subgroup of all matrices with $0$ on the first diagonal above the main diagonal.
My question is - is it also a commutator subgroup of that group?
The quotient group $H/Z(H)$ is abelian (this group is nilpotent of class two), so commutator subgroup must be inside the center. I can't imagine other subgroups being CS, but I want someone smarter to let me know.
Have a nice day.
Answer: $$\begin{pmatrix}1&x&y\\ 0&1&z\\ 0&0&1\end{pmatrix}^{-1}=\begin{pmatrix}1&-x&xz-y\\ 0&1&-z\\ 0&0&1\end{pmatrix}$$
Therefore \begin{align}ABA^{-1}B^{-1}&=\begin{pmatrix}1&x&y\\ 0&1&z\\ 0&0&1\end{pmatrix}\begin{pmatrix}1&s&t\\ 0&1&u\\ 0&0&1\end{pmatrix}\begin{pmatrix}1&-x&xz-y\\ 0&1&-z\\ 0&0&1\end{pmatrix}\begin{pmatrix}1&-s&su-t\\ 0&1&-u\\ 0&0&1\end{pmatrix}=\\&=\begin{pmatrix}1&s+x&t+ux+y\\ 0&1&u+z\\ 0&0&1\end{pmatrix}\begin{pmatrix}1&-x-s&ux+xz-y+su-t\\ 0&1&-z-u\\ 0&0&1\end{pmatrix}=\\&=\begin{pmatrix}1&0&t+ux+y+ux+xz-y+su-t-(z+u)(s+x)\\ 0&1&0\\ 0&0&1\end{pmatrix}=\\&=\begin{pmatrix}1&0&ux-zs\\ 0&1&0\\ 0&0&1\end{pmatrix}\end{align}
It is therefore apparent that commutators are exactly the elements in the form $\begin{pmatrix}1&0&\alpha\\0&1&0\\ 0&0&1\end{pmatrix}$, which incidentally form a subgroup.
Answer: Since$$\begin{bmatrix}0&a&c\\0&1&b\\0&0&1\end{bmatrix}.\begin{bmatrix}1&d&f\\0&1&e\\0&0&1\end{bmatrix}\begin{bmatrix}0&a&c\\0&1&b\\0&0&1\end{bmatrix}^{-1}\begin{bmatrix}1&d&f\\0&1&e\\0&0&1\end{bmatrix}^{-1}=\begin{bmatrix}0 & 0 & a e-b d \\ 0 & 0 & 0 \\ 0 & 0 & 0\end{bmatrix},$$yes, the commutator group is the center.


Prefill content type form field with alter hook

Question: I've created a content type with a link type field.
When an user add this content type I want to prefill the link field with the user email.
I've a create a new module named prefilllink with an alter hook :
function prefilllink_alter(&$form, &$form_state, $form_id) {
  dsm($form);
  switch($form_id) {
    case "job_node_form":
      $form["field_apply"]["und"][0]["value"]["#default_value"] = $user->mail;
      break;
  }
}

But it doesn't work... Any idea?
Comment: hook_form_alter().Instead of prefilllink_alter maybe try prefilllink_form_alter()
Answer: You need to implement either hook_form_alter() or hook_form_FORM_ID_alter() (there's no hook_alter() which is what your code is implementing at the moment).
The second is probably preferable as it targets the form you're interested in:
function prefilllink_form_job_node_form_alter(&$form, &$form_state, $form_id) {
  global $user;
  $form["field_apply"][LANGUAGE_NONE][0]["value"]["#default_value"] = $user->mail;
}

Comment: Thanks!!
that wasn't the right hook name.
i've added a email type field and now the correct syntax is :
    global $user;
    $form["field_email"][LANGUAGE_NONE][0]["email"]["#default_value"] = $user->mail;


Deletar apenas checkbox selecionados PHP

Question: Estou com um sistema que fiz (não entendo muito de PHP) funcionava perfeitamente porém após trocar de servidor parou de funcionar a função de deletar apenas os checkbox selecionados, ele simplesmente deleta tudo.
Eu busco todos eles de banco de dados e mando exibir apenas os 4 primeiros ID (normalmente são gravados com erro no Banco - XML com problema que não vem de mim).
Segue parte do código.
<form method="post" action="limpar_selecionados.php">
<?php
$query = sprintf("SELECT * FROM loja WHERE categoria = 'NOTEBOOK' ORDER  BY nome ASC  LIMIT 4");
$dados = mysql_query($query, $con) or die(mysql_error());
$linha = mysql_fetch_assoc($dados);
$total = mysql_num_rows($dados);
if($total > 0) {
do {
?>

 <input type="checkbox" name="chk[]" value="<?=$linha['id']?>"   style="display:block;"/>

<?php
    }while($linha = mysql_fetch_assoc($dados));
}
?>

<?php
$query = sprintf("SELECT * FROM loja WHERE categoria = 'Smartphone' ORDER  BY nome ASC  LIMIT 4");
$dados = mysql_query($query, $con) or die(mysql_error());
$linha = mysql_fetch_assoc($dados);
$total = mysql_num_rows($dados);
if($total > 0) {
do {
?>

 <input type="checkbox" name="chk[]" value="<?=$linha['id']?>"   style="display:block;"/>

<?php
    }while($linha = mysql_fetch_assoc($dados));
}
?>

<input type="submit" name="submit" value="Excluir Selecionados">

</form>

Limpar_selecionados.php
<?php
print_r($_POST);
    if(isset($_POST['chk'])){
            $excluir = $_POST['chk'];

            foreach ($_POST['chk'] as $item) {
            $sql_deleta = "DELETE FROM `loja` WHERE `id` = '$item'";
            mysql_query($sql_deleta);
}
}
?>

Comment: Só com esse código não tem como explicar esse comportamento.
Mesmo que *short_tags* esteja desativado ele não apagaria todos os registros. Deve ser outra coisa.
Tente adicionar no inicio dos scripts o código `error_reporting(E_ALL);`
Answer: Porque não organizas as id numa única variável, e depois executas como uma única consulta ?
Outra coisa, é o facto de estares a passar o indentificador na atributo value, é desnecessário quando já tens esse mesmo valor na atributoname.
Para ser sincero, não lembro exatamente, e não sei se, é esta a linha de pensamento correta, mas, posso afirmar que é incorreto assinar valores que não sejam true ou false ou equivalente às checkboxes. Alguém para me corrigir se eu estiver errado.
De:
<input type="checkbox" name="chk[]" value="<?=$linha['id']?>"/>

Para:
<input type="checkbox" name="chk[<?=$linha['id']?>]"/>

Nesta parte do script, poderias simplesmente fazer:
if(isset($_POST['chk'])){
  $excluir = $_POST['chk'];

  foreach ($excluir as $item) {
          $sql_deleta = "DELETE FROM `loja` WHERE `id` = $item";
          mysql_query($sql_deleta);
}
}

Não sei se isto é uma função personalizada, criada por ti mesmo, ou se é apenas a velha extensão de conexão MySQL, porque se for, recomendo que comeces a usar MySQLi ou PDO.
mysql_query($sql_deleta);

Abaixo um exemplo de como executar as consultas, como uma única, usando a  cláusula IN:
DELETE FROM tabela_ WHERE id IN (id1, id2, id3, idn...)

Exemplo:
<?php
/* CREATE DATABASE IF NOT EXISTS exemplo;
 * CREATE TABLE IF NOT EXISTS exemplo (
 * id INT(11) NOT NULL AUTO_INCREMENT,
 * titulo VARCHAR(20) NOT NULL,
 * PRIMARY KEY(id),
 * UNIQUE KEY(titulo));
 * INSERT INTO exemplo (titulo) VALUES ('primeiro'),('segundo'),
 * ('terceiro'),('quarto'),('quinto'),('sexto'),('setimo'),('oitavo')
 * ,('nono'),('decimo');
 */
$mysqli = new mysqli("localhost", "root", "", "exemplo");

if(!$mysqli) die ("Erro: " . $mysqli->connect_errno());
$consulta = $mysqli->query("SELECT * FROM exemplo ORDER BY id ASC");

if($consulta){
 echo "<form method=\"POST\" action=\"\">";
 while($linha = $consulta->fetch_object()){
  echo "
" . $linha->titulo . "<input type=\"checkbox\" name=\"item[{$linha->id}]\">
";
 }
 echo "<input type=\"submit\" name=\"apagar\" value=\"apagar\">";
 echo "</form>";
} else {
 die("Erro");
}

if(isset($_POST["apagar"])){
  $ids = "";
 foreach($_POST['item'] as $id=>$val){
  $ids .= $id . ',';
 }
 $ids = substr($ids, 0, -1);
 $apagar = "DELETE FROM exemplo WHERE id IN({$ids})";
 if($mysqli->query($apagar)){
  header("Location: exemplo.php");
  exit();
 } else {
  die("Erro: ". $mysqli->error);
 }
}

?>

Answer: Você já verificou se a variável $item está com os valores corretos? e se o SQL de DELETE está correto?
Eu também percebi que você cria a variável $linha = mysql_fetch_assoc($dados); e depois cria ela novamente no do {} while {}, não sei se isso atrapalha em algo, não fiz testes, mas não sei se ajuda.
Answer: Por ter ocorrido após troca de servidor, provavelmente está relacionado ao PHP do seu novo servidor.

Se outros erros se apresentam, pode ser que a versão do PHP do novo servidor seja mais recente e funções utilizadas em seu código estejam depreciadas.
Em seu atual código, você utiliza short tag <?=$linha['id']?> short tag está habilitado em seu atual servidor? Caso não, será que seu value="<?=$linha['id']?>" não está retornando vazio por este motivo?

Não fiz testes, sugiro que faça estes testes para eliminar estas possibilidades.
Answer: Use esse e com certeza irá funcionar:
<form method="post" action="limpar_selecionados.php">

<?php

$query = mysql_query("SELECT * FROM loja WHERE categoria = 'NOTEBOOK' ORDER BY nome ASC LIMIT 4");

if(mysql_num_rows($query) > 0){

    while($linha = mysql_fetch_array($query)){

        echo '
<input type="checkbox" name="chk[]" value="'.$linha['id'].'" style="display:block">
';
    }
}

$query = mysql_query("SELECT * FROM loja WHERE categoria = 'Smartphone' ORDER BY nome ASC LIMIT 4");

if(mysql_num_rows($query) > 0){

    while($linha = mysql_fetch_array($query)){

        echo '
<input type="checkbox" name="chk[]" value="'.$linha['id'].'" style="display:block">
';
    }
}

?>

<input type="submit" name="submit" value="Excluir Selecionados">

</form>

Depois para deletar
<?php
if(!empty($_POST['chk'])){

    $chk = $_POST['chk'];

    foreach($chk as $item){

        mysql_query("DELETE FROM loja WHERE id = '".$item."'")
    }
}
?>

Algumas observações
A Função mysql_ foi descontinuada, então recomendo que use mysqli.
Nunca usei a função do while, mas recomendo fazer sempre da maneira que eu fiz no código: Use somente a função while()
Não sei o seu conhecimento com PHP, mas você iria poupar código e processamento utilizando funções (function) no PHP, assim o código iria ficar mais limpo e mais rápido.
Utilize sempre a tag <?php . Quando você faz a migração para outro servidor, talvez a short tag não esteja ativa, para não ter dor de cabeça use sempre <?php :)


Is the alternating group $A_1$ empty?

Question: I'm proving that $A_n$ is a subset of $S_n$. By definition, $A_n$ is the set of permutations in $S_n$ that can be decomposed into an even number of 2-cycles. Since $S_1$ has no 2-cycles, it seems that $A_1$ would have to empty.
If I'm right, then that would mean that $A_n$ is subgroup of $S_n$ only when $n\geq 2$. Since my textbook just asked to show that $A_n$ is a subgroup of $S_n$ without specifying that $n\geq 2$, I think that I'm wrong that $A_1 = \emptyset$. Some clarification would help me.
Comment: The identity is the product of $0$ transpotions, hence it is even.
Comment: A subgroup is never empty.
Answer: $A_1$ consists of the identity permutation, hence is equal to $S_1$. In fact, the identity permutation is contained in $A_n$ for all $n$ (this is important for the fact that $A_n$ is a subgroup of $S_n$) because it is an empty product of transpositions.
Comment: Yes, that's right. There are also other equivalent definitions of even permutations which handle this case better. E.g. defining the sign of a permutation as $-1$ raised to the number of inversions.
Comment: Ok, so by transpositon, you mean that $e$ can be expressed as the product of 0 2-cycles?

Is the alternating group $A_1$ empty?


Elastic Search with Symfony2 + Aggregation [Complex]

Question: Facet Filter Demo
I'm creating a search page with Elastic search + Symfony2 using FOSElastica. I have setup repository and model transform and pagination perfectly fine.
I have geo-location search with couple of aggregation which are following
Distance Range

< 5 miles
25 miles
50 miles
100 miles

Duration between two points

30 minutes
1 hour
2 hour
3 hour

Categories

Car
Truck
Bike
Hover board

location: geo point (default is set by country)
Question
There will be multiple aggregation click by user to filter their data to narrow the data. What would be the best way to track which aggregation is active by the user?
And how can I show send and receive filter aggregation between controller and service methods?
Would it be best to just track everything by session?
Comment: Please clarify the scope of your question.  You've used the word *track* twice.  Is this about logging/counting the which filter is used most relative to the others?  Or are you trying to determine the best way to understand the current selection-state of your filters given an Elasticsearch response document?
Comment: best way to understand the current selection-state of your filters given an Elasticsearch response document? (while displaying it to user on refresh page)
Answer: Since the default Elasticsearch response doc does not contain the query that was submitted, you'll need to keep track of the filter selection state in a MVC application in order to properly render your filter controls.
Some options:

filters encoded into form elements (possibly hidden) on the page.  Form could post via Ajax.
filters encoded into url (added benefit of bookmarkable/shareable searches)
filters stored in session (not sure why you'd want this, but it would be possible)

Once you've submitted a search request, your controller which calls Elasticsearch, is now responsible for passing the user's filter selection state to Elastica (and also back to the view along with search results)

This sort of echoing filter state back from the search controller is useful especially when you need to redraw the section of the page housing search filters.


How to attach SSD to Azure VM and check its type?

Question: I created one VM with 100G SSD, but it's only D rive, which is the temporary disk. I want to attach another SSD drive to the VM, but I'm not sure its type. Is is possible to do this?
Thank You
Answer: The Azure D-series VMs have an SSD as the resource disk. Once Premium Storage is available you will be able to attach additional SSD disks to a VM of the DS-series (a new instance type that is essentially the D-series usable with Premium Storage). Premium storage is currently in limited preview.


Lower bound for $|\cos z|$ for $|z|=1$

Question: I have to show these inequalities:
For $|z|=1$
 $$\frac{1}{3} \lt |\cos z| \lt \frac{5}{3}$$
Here is what I have so far:
Let $z = x + i y$
$\cos z=\frac{1}{2}\left(e^{ix}e^{-y}+e^{-ix}e^y\right)\implies|\cos z|\le\frac{1}{2}\left(e^{-y}+e^y\right)\le e$
And for the left side I have $\frac{e-\frac{1}{e}}{2}$.
I cannot seem to find a way to show these tighter bounds.
Comment: $|a+b|\neq|a|+|b|$.
Comment: I would suggest substituting $z=e^{i\theta}$
Answer: $|\cos z|^2=(e^{2y}+e^{-2y}+2\cos(2x))/4$ and we want to prove it is less than $\frac{25}{9}$, or equivalently $e^{2y}+e^{-2y}+2\cos(2x)<100/9$. Since $x^2+y^2=1$ both $x$ and $y$ are forced in the range $[-1,1]$. The maximum of $e^{2y}+e^{-2y}$ is achieved when $y=1$ and the maximum of $\cos(2x)$ is achieved in $x=0$, hence LHS$\leq e^2+1/e^2+2<(2.8)^2+1/4+2=10.09<11<100/9$. So $|\cos z|<5/3$ for $|z|=1$.
For the other inequality we have to prove $e^{2y}+e^{-2y}+2\cos(2x)>4/9$. The minimum of $e^{2y}+e^{-2y}$ is achieved for $y=0$ and the minimum of $2\cos(2x)$ is achieved when $x=1$, so we have to prove $2+2cos(2)>4/9$. $cos(\alpha+\pi/2)=-sin(\alpha)$ and in our case $0<\alpha<\pi/4$ since $\pi/2+\pi/4>2>\pi/2$, so we have to prove $2(1-sin(\alpha))>4/9$ or $sin(\alpha)<7/9$, but in that range sin is increasing so $sin(\alpha)<sin(\pi/4)=\frac{\sqrt2}{2}<7/9$, hence we are done.
Comment: What about the other side of the inequality?

Lower bound for $|\cos z|$ for $|z|=1$


Linear surjective operator's property proof

Question: Let $X,Y$ be normed spaces and $T\in \mathcal{L}(X,Y)$. I want to prove that if $T$ is surjective and for all $y\in Y$
$$\|y\|=\inf\{\|x\|\ \colon x\in X, \ Tx=y\},$$
then
$$\{Tx \ \colon \|x\|<1\}=\{y\ \colon \|y\|<1\}.$$
Any ideas on how to approach this proof?
Answer: You know that $\|Tx\| \leq \|x\|$ (set $y = Tx$ in the given identity). This implies the inclusion $\{Tx \ \colon \|x\|<1\} \subseteq \{y\ \colon \|y\|<1\}$. For the other direction, take $y \in Y$ with $\|y\| < 1$. You find $\varepsilon > 0$ such that $\|y\| < 1 - \varepsilon$. Now the given identity shows there exists $x \in X$ with $\|y\| \leq \|x\| < \|y\| + \varepsilon$ and $T x = y$. It follows that $\|x\| < 1$ and so you obtain the other inclusion.


Conditions for using The Rational Zeros Theorem

Question: Barron's SAT Math 2 and SparkNotes state that if p/q is a rational zero of P(x) with integral coefficients, then p is a factor of the constant term of P(x) and q is a factor of the leading coefficient of P(x) .
Then they show an example in which p/q isn't even a zero of the polynomial and continue to solve it as is (solving for 9/2 does not get you to 0):

$P(x) = 2x^4 + x^3 -19x^2 - 9x + 9$
Factors of constant term: $±1 , ±3 , ±9 $.
Factors of leading coefficient: $±1 , ±2 $.
Possible values of : $±1/1 , ±1/2 , ±3/1 , ±3/2 , ±9/1 , ±9/2 $. These can be simplified to: $±1 , ±1/2 , ±3 , ±3/2 , ±9 , ±9/2 $.

My questions are:

Does p/q (where p is a factor of the constant term of P(x) and q is a factor of the leading coefficient of P(x)) need to be a zero of the polynomial in order to use this theorem? (since this obviously isn't the case in the above mentioned example and several others that I came across).
What are the conditions for one to be able to use it?
If anyone could provide an intuitive explanation/proof of why this theorem works in general that would be awesome.

http://www.sparknotes.com/math/algebra2/polynomials/section4.rhtml
Answer: The theorem says if $p/q$ is a rational zero of $P(x)$, then ....  The way you usually use this is to narrow down the possibilities for rational zeros.  In this case $9/2$ does not happen to be a zero, but the theorem doesn't rule it out.
Once you identify the possible rational zeros using the theorem, you can test each of them by substituting in to the polynomial and see which (if any) are actually zeros.
See e.g. Wikipedia for a proof.


Openstack Pike fails after Ubuntu 18.04 upgrade

Question: First off, I am an amateur to Openstack upgrading and made a big mistake in upgrading the controller and compute nodes OS from Ubuntu 16.04 to 18.04. I know now that was a mistake. My Openstack Pike fails now.
Is there a step by step procedure to undo what I did in reference to the 16.04 to 18.04 upgrade?
Don
Answer: In practice downgrading Ubuntu from major release is not possible [1], however in theory, you could re-tweak apt source files to point to the previous release [2], some packages have deb-postinst scripts which might migrate the config files, so downgrading might cause service to fail, etc.., thus requiring more manual work to fix the config.
IMO, your best option at moment is to try and fix the issues with Openstack, for that, more details are needed, like: which Openstack distro (Mirantis, Red Hat, Ubuntu, etc..) and the errors you are seeing (logs, etc...)
[1] https://askubuntu.com/questions/49869/how-to-roll-back-ubuntu-to-a-previous-version
[2] https://askubuntu.com/a/3675


RegEx - Exclude Matched Patterns

Question: I have the below patterns to be excluded.
make it cheaper
make it cheapere
makeitcheaper.com.au
makeitcheaper
making it cheaper
www.make it cheaper
ww.make it cheaper.com

I've created a regex to match any of these. However, I want to get everything else other than these. I am not sure how to inverse this regex I've created.
mak(e|ing) ?it ?cheaper

Above pattern matches all the strings listed. Now I want it to match everything else. How do I do it?
From the search, it seems I need something like negative lookahead / look back. But, I don't really get it. Can some one point me in the right direction?
Answer: You can just put it in a negative look-ahead like so:
(?!mak(e|ing) ?it ?cheaper)

Just like that isn't going to work though since, if you do a matches1, it won't match since you're just looking ahead, you aren't actually matching anything, and, if you do a find1, it will match many times, since you can start from lots of places in the string where the next characters doesn't match the above.
To fix this, depending on what you wish to do, we have 2 choices:

If you want to exclude all strings that are exactly one of those (i.e. "make it cheaperblahblah" is not excluded), check for start (^) and end ($) of string:
^(?!mak(e|ing) ?it ?cheaper$).*

The .* (zero or more wild-cards) is the actual matching taking place. The negative look-ahead checks from the first character.
If you want to exclude all strings containing one of those, you can make sure the look-ahead isn't matched before every character we match:
^((?!mak(e|ing) ?it ?cheaper).)*$

An alternative is to add wild-cards to the beginning of your look-ahead (i.e. exclude all strings that, from the start of the string, contain anything, then your pattern), but I don't currently see any advantage to this (arbitrary length look-ahead is also less likely to be supported by any given tool):
^(?!.*mak(e|ing) ?it ?cheaper).*

Because of the ^ and $, either doing a find or a matches will work for either of the above (though, in the case of matches, the ^ is optional and, in the case of find, the .* outside the look-ahead is optional).

1: Although they may not be called that, many languages have functions equivalent to matches and find with regex.

The above is the strictly-regex answer to this question.
A better approach might be to stick to the original regex (mak(e|ing) ?it ?cheaper) and see if you can negate the matches directly with the tool or language you're using.
In Java, for example, this would involve doing if (!string.matches(originalRegex)) (note the !, which negates the returned boolean) instead of if (string.matches(negLookRegex)).
Answer: The negative lookahead, I believe is what you're looking for. Maybe try:
(?!.*mak(e|ing) ?it ?cheaper)

And maybe a bit more flexible:
(?!.*mak(e|ing) *it *cheaper)

Just in case there are more than one space.

RegEx - Exclude Matched Patterns


Install an Oracle DB in a linux VM

Question: I am trying to set up an Oracle database server (at the moment just for testing purposes) in a virtual machine.
The setup I'm using:

VirtualBox
Network adapter in NAT mode (redirecting ports 22->22, 80->80, 1521->1521, 8080->8080)

I'd rather avoid bridged networking, if possible
It would be good if the database could be accessed by the outside world, and not just the host OS

CentOS 6.4 64-bit
Oracle XE, version 22.214.171.124.0 "Production", installed and configured using the default ports (1521 and 8080)
Firewall disabled in both the guest OS and the host OS
The host OS is behind a proxy

The problem
I cannot access the database (over port 1521, using sqlplus or SQL developer) from the host. I can access it from the VM itself though (using sqlplus).
I can also SSH from the host into the VM and I can access the web interface from the host when I navigate to:
http://127.0.0.1:8080/apex

Therefore, the NAT setup of VirtualBox seems to work to some extent.
It seems the listener is up when I execute lsnctrl status. The listener.ora file looks like this:
# listener.ora Network Configuration File:

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/xe)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
    )
  )

DEFAULT_SERVICE_LISTENER = (XE)

When I try to connect from the host, I get the following error (the same command works when executed within CentOS):
PS C:\Users\winuser> sqlplus firstname.lastname@example.com

SQL*Plus: Release 220.127.116.11.0 Production on Fr Jul 12 16:56:25 2013

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified

Port 1521 also seems to be active in the VM, and port forwarding is set up appropriately in VirtualBox:
[root@localhost admin]# nmap 127.0.0.1

Starting Nmap 5.51 ( http://nmap.org ) at 2013-07-12 17:02 CEST
Nmap scan report for localhost.localdomain (127.0.0.1)
Host is up (0.0000050s latency).
Not shown: 994 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
25/tcp   open  smtp
111/tcp  open  rpcbind
631/tcp  open  ipp
1521/tcp open  oracle
8080/tcp open  http-proxy

Nmap done: 1 IP address (1 host up) scanned in 0.06 seconds

Thank you for any tips or suggestions.
Comment: Why do you want to avoid bridged networking?
Comment: Because I would like the database to be accessible when clients connect to my machine. With bridged networking, the virtual machine appears as a separate machine on the network. I'd use bridged if there is no other solution though.
Answer: You cannot connect to database using only IP address.
Run
lsnrctl status

on guest machine to find out service name and instance name (ORCL for example). Then edit tnsnames.ora on host machine similar to this:
ORCL=
(DESCRIPTION=
 (ADDRESS=
   (PROTOCOL=TCP)
   (HOST=127.0.0.1)
   (PORT=1521)
 )
 (CONNECT_DATA=
   (SERVER=dedicated)
   (SERVICE_NAME=your_service_name_here)
 )
)

and try TNSPINGing it:
tnsping ORCL

It sould say something like "Ok (20 msec.)"
At last run sqlplus:
sqlplus user/password@ORCL

For more information read Oracle Documentation:
http://www.oracle.com/pls/db112/portal.portal_db?selected=4&frame=#network_management
Answer: This sounds like a problem with your Oracle network configuration. Either use network manager or hand-edit sqlnet.ora and tnsnames.ora in $ORACLE_HOME/network/admin.
Comment: Thanks for the info. I assume the network manager is a graphical application (the CentOS server does not have a graphical server installed)? I noticed I don't have an sqlnet.ora file, is this a mandatory file?

Install an Oracle DB in a linux VM


How to redefine / override the default breakpoints in a Bootstrap sub-theme

Question: I have a Drupal 7 subtheme based on the Drupal Bootstrap theme CDN starterkit. I'm trying to change the default breakpoints, which I thought would be a simple, routine task, but I can't find anything that works.
I've read this issue which shows that the theme supports the Breakpoints module. I've installed the Breakpoints module, followed the steps given, got confirmation in Drush and the Breakpoints module UI that my new breakpoints have been read from my .info file - but the columns in my Bootstrap subtheme ignore these and carry on using the built-in ones. I've cleared all browser and Drupal caches.
I can only assume that the "Breakpoints module support" means that it allows other modules (like Navbar etc) to listen to the custom breakpoints, whereas Bootstrap itself continues getting Bootstrap CSS files according to its built-in defaults.
I've also been through the Drupal Bootstrap documentation and can't find anything about breakpoints at all. I only confirmed what the default Bootstrap breakpoints were through a comment in the above linked issue.
All I can think of is, to compile a version of the Bootstrap CSS with the breakpoints I want, upload it and use it instead of CDN as per "Using own Bootstrap 3 files in Bootstrap Drupal 7 theme". I'm wary of this however because it seems like the theme PHP would expect different breakpoints to those defined in the theme CSS which sounds like a recipe for strange bugs further down the line. I'd prefer to override some setting or, failing that, function in the theme so that it gets the configuration I want from the CDN and isn't expecting a different configuation.
[UPDATE] I've tried this and it does seem to work, although at first I thought it hadn't because I'd misread how the Bootstrap compiler used minimum and maximum values. It feels like a very "against the grain" bodge though, and I won't be surprised if it causes problems later, which is why I'm not posting it as an answer.

How can I customise the pixel values for the xs, sm, md and lg Bootstrap breakpoints in a Drupal 7 Breakpoints based subtheme in a clean way that is consistent between front end and back end?
Answer: There doesn't currently seem to be anything in the Bootstrap theme that supports this directly, and the theme doesn't appear to listen to anything in the Breakpoints module. The bootstrap breakpoints are hard-baked into the JS and CSS.
If you're not using LESS, this means the only realistic option is to override the CSS and JS with custom local files. I had a bit of trouble with this at first but it seems to be fine and doesn't seem to conflict with anything in the server-side theme code.

Create a customised version of Bootstrap with your breakpoints and other preferences, from http://getbootstrap.com/customize/
Install the module Bootstrap Library
Upload the custom bootstrap files to sites/all/libraries/bootstrap
Disable everything to do with CDN in your theme settings page


Local epxansion of a holomorphic function into taylor series

Question: I am currently taking a beginners course in complex analysis and there it was mentioned that every holomorphic function can be locally expanded into a taylor series.
From real analysis I know that a smooth function can be expanded into its corresponding taylor series, which does not need to converge to the function. It does not even need to converge at all.
What is the big difference to real analysis then? In the complex case it does not need to converge, too, right? Is it just the taylor coefficients that are granted to exist in a given expansion point, because the function is holomorphic and therefore smooth?
Could someone elaborate the exact differences between the real and complex case? I have a feeling, that I am missing something important, because the seemingly important differences seem trivial to me.
Answer: This is one of the amazing things  about complex analysis: If $f$ is complex-differentiable in $D(0,r)$ then there exist $a_n$ so $$f(z)=\sum_{n=0}^\infty a_nz^n\quad(|z|<r).$$Amazing because as you note it's far from true in real analysis.
Comment: So it does converge on an open disk around the point about which the series was expanded?
Comment: @EpsilonDelta Indeed it converges on any open disc centred at this point and contained in the set on which $f$ is holomorphic. If only Professor Ullrich could recommend a convenient textbook to read up on such things...
Comment: You should mention the word analytic and https://en.wikipedia.org/wiki/Analyticity_of_holomorphic_functions
Answer: There are several stages that the complex analysis course typically goes through to arrive at this result:

) the special form of complex differentiability as a case of 2D real differentiability,
) the Cauchy-Riemann differential equations as defining property of analytic/holomorphic functions
) The Goursat theorem about integrals over the sides of a triangle,
) the existence of anti-derivatives
) the Cauchy integral theorem and Cauchy integral formula, and
) with the help of those one finally arrives at the Taylor expansion via geometric series,
$$ \frac1{ζ−z}=\frac1ζ\,\frac{1}{1-\frac{z}{ζ}}=\sum_{k\ge 0}\frac{z^k}{ζ^{k+1}}$$ as follows.
For any $R>r>0$ so that $f$ is holomorphic on $B(0,R)$ and any $|z|<r$
$$
f(z)=\frac1{2\pi i}\oint_{|\zeta|=r}\frac{f(\zeta)}{\zeta - z}d\zeta
=\sum_{k=0}^\infty \left[\frac1{2\pi i}\oint_{|\zeta|=r}\frac{f(\zeta)}{\zeta^{k+1}}d\zeta\right]\;z^k
$$
and the integral in the coefficients is $$\frac1{2\pi r^k}\int_0^{2\pi}f(re^{it})e^{-ikt}dt$$ thus well-defined.
Comment: It is also [there](https://en.wikipedia.org/wiki/Analyticity_of_holomorphic_functions)
Answer: With functions of a real variable $z$, in the expression
$$
f'(z) = \lim_{\Delta z \to 0} \frac{f(z+\Delta z) - f(x)}{\Delta z}
$$
the bound variable $\Delta z$ can approach $0$ from either of two directions.
But if $z$ is a complex variable, it can approach from any of many directions. That means far fewer functions will qualify as differentiable: only those for which the limit exists and is the same number regardless of how $\Delta z$ approaches $0.$
And "holomorphic at $z$" must be construed not simply as "differentiable at $z$" but rather as "differentiable everywhere in some open neighborhood of $z$." By that definition, the function $z\mapsto |z|^2$ is differentiable at $0$ but is not holomorphic.