bIII upon bII5, bII7#11omit3, how to name that chord in this context?

Question: Note : I had trouble to name this question properly. I would've gone with "What's that chord name" but it doesn't seem to help anyone that would stumble across a similar problem to find my question. Anyway, my question seem to be very specific.
Context : I'm pretty new to music theory I'm trying to analyse the music "Rude Buster" from Deltarune OST (link), and so far I'm slowly making progress in understanding the piece, which is nice :) Though, there's a part where I struggle to find the adequate way to analyse it.

The piece is in F#minor. In the first half of bar 1 & 3, the crazy bass highlights an F#5, which goes well with the chord part that does an A major, creating a F#m7. Then, in the second half of the measures, it goes to highlighting a weird G5  chord when the chord section stay on A major (except for the last one of the bar which is an inversion of F#m).
The result is creating some kind of polychord, A upon G5, or bIII upon bII5, in relative, assuming that I got the key right.
My problem : The thing is, I can't really make a link between what I hear and what I can analyze out of it, because I've never encountered such a weird combination of notes. Since I can't really put a name on it, I guessed that it should sound dissonant, but it doesn't really to me.
My guesses :

My first guess was just saying that the bass is crazy anyway and "has the right to" (=can without sounding too dissonant) spend half of a measure playing some crazy notes. But it doesn't match it's behavior for the rest of the piece. For the rest, I've figured it did quite a good job playing the chord tones (while often supplementing the fondamental) and while using some passing tones here and there.
Another guess would be that a B is implicit, making this chord G7#11 (with the 9, A). This make more sense to why this chord doesn't sound that dissonant to me. So I would be tempted to treat it as a G7#11omit3, in relative a bII7#11omit3, borrowed from the parallel phrygian I guess ?

I like the second one, but I'll gladly hear what you have to say on it.
EDIT : Actually my second guess can't be totally accurate, as I did not include the E of the A major chord, also the 13 of G. And there's no 7 in that chord either. So it would be a glorious G13(#11)omit3omit7, in relative a bII13(#11)omit3omit7 ? Pretty crazy chord right here !
Comment: My mistake--turns out that the OP's excerpt is from the very beginning of the piece, but the bassline is isolated as its own very prominent entity later. I'm a fan of treating the chords and bassline as separate entities in this case.
Comment: Interesting ! The bass does stand out a lot in this piece, though could you call the A an ostinato, when it's only been played two times before, half a measure at a fast tempo ? I get the idea though, it's kinda related to what I was trying to say in my first guess :)
Comment: @Dekkadeci I understand. Though I got some interesting insights from analysing it as a whole, since together they were forming some 7 chords that I thought fitted better to what I hear in the piece. Except here, where they form this massive weird chord :D
But yeah, I see the point in analysing it separately. EDIT : Ok I've misread your comment as well, so in this part you don't necessarly think it's a good thing to treat them separately ? Right.
Answer: The chord, from your description, highlights G and D in the bass, and has A, C♯, and E in the upper structure. I have not listened to the song, but from these notes, to me there are at least two distinct possibilities.
Your polychord analysis was my first instinct, seeing the upper structure and the lower component. A/G5 would be equivalent to the tertian quality G(9♯11), omitting the third (which seems reasonable enough, since B is much more likely than Bb here). If we truly are in the key of F♯ minor (A major was my first instinct - mixolydian is a pretty common choice for modal mixture, but then again this is VGM, so phrygian's not out of the picture by any means), then this chord is built on the ♭II scale degree. This could very well be a tritone substitution for the dominant chord C♯ in a jazz-based context, or modal mixture (hence your phrygian explanation) or a Neapolitan 6th, depending heavily on context and style.
However, there's another explanation that may have merit. You mention some earlier examples of the A chord appearing in the upper structure with a bass structure outside of that chord. It is very possible to me that this G power chord idea is simply a move upwards from F♯ to G along the phrygian scale, while the A chord is somewhat dronelike in that it holds over in seeming defiance of the bassline for effect. This would make a lot of sense if the bass outlined, say, F♯5, then G5, then A5. I think that it's probably a good idea to view the bass and chords as being separate entities in this case, and it may be the case in your example as well.
And of course, it's always possible that neither A nor G are the root of the chord and this is some nasty inversion, but that's unlikely, and I think you probably would have picked up on that.
Comment: Very interesting insights ! And a lot of vocabulary, some terms I need to go look for them since I don't know them yet, which is a very good occasion to learn new terms. Give me time to look these terms and I'll come back with an answer :)
Have you seen my edit ? It seems you were redacting your answer while I did my edit. I think you did a mistake when saying that we have the maj7 in the chord, since we don't have any F# in this chord. So, in tertian, it would actually be a `G13(#11)omit3omit7`... that's a lot of omissions there !
Comment: @021 Good catch - no major seventh. Let me fix that...
Comment: Either I'm mistaken myself, but I believe there are still some mistakes in the second paragraph : `G(9♯11), omitting the third (which seems reasonable enough, since we have the major seventh)` still says we have the major seventh, and doesn't include the 13 (or 6) (E)
Comment: @021 Thanks. In the future, you can just propose an edit if you see something like that.
Answer: As you say your pretty new to music theory ...

you shouldn't start analyzing chords like these crazy chords
don't choose a notation with errors
don't try to transfer or adapt the RN. to a harmony        that isn't written in this music language and doesn't fit in this system.

the simple analysis is:
A/f#m, A/G ... etc. we can be pleased understanding this construction. More interpretation isn't appropriate to this chords or this progression.
G isn't N6 of F#m. A isn't bIII,  while the bass note F (natural) should be E#.
of course we can say A/G is G7911 ... but what have we won?
Comment: Uh... OP does say they're new to music theory, but to me, anyone who can handle extended chord naming and polychords can handle roman numeral analysis. I completely missed OP even saying that in the first place, because their post was written quite intelligently.
Comment: Some questions :
- What are the errors on the notation ? The way the natural symbols are handled ? Because of the natural F instead of E# ? - What is RN ? - Why A isn't bIII ?
Comment: I prefer to avoid using polychords for my analysis because they're not very meaningful for me for right now. I can't really put a sound on `A upon G5` but I kinda can on `G13(#11)omit3omit7`, since in this notation it highlights the link between this chord and a G13(#11), even though some notes are missing, it induces that they might be implicitly heard by a listener. Then again, maybe I just lack the knowledge to put a sound on `A upon G5`, and if you and other person say that it's more meaningful this way, I'll take it ! Thanks.
Answer: Why make it complicated? This is just the third inversion of a plain A7 chord (A7/G). The D is melodic in the context of the root/fifth bass line and not harmonically relevant here, and even if it was, you could interpret it as the bass of a Dmaj9 chord (missing the 3rd).


Trying to approximate Riemann sum with $\sin(\frac{x}{5})$

Question: Let $P= 0, \frac{1}{2},1,2$
Find the upper, lower, and exact area and whether the lower or upper sum is more accurate
Starting with the left:
LH: $$\sin(0)(\frac{1}{2}-0)+\sin(\frac{.5}{5})(1-\frac{1}{2})+\sin(\frac{1}{5})(2-1)$$
$$0+.0499+.19=.248$$
RH:
$$\sin(\frac{.5}{5})(\frac{1}{2}-0)+\sin(\frac{1}{5})(1-\frac{1}{2})+\sin(\frac{2}{5})(2-1)$$
$$=.0499+.19+.389=.61$$
Neither of these is close to the book which says that the sum approximately equal to $.5386$ is closest. What is wrong with my calculation?
Comment: You indicated $\sin(\frac15)\frac12=.19$, but I get $.099$
Comment: You should also use $P=1.5$
Answer: It looks like you forgot $\color{red}{\left(1-\dfrac12\right)}$:
$$\sin\left(\frac{.5}{5}\right)\left(\frac{1}{2}-0\right)+\sin\left(\frac{1}{5}\right)\color{red}{\left(1-\frac{1}{2}\right)}+\sin\left(\frac{2}{5}\right)(2-1)$$
$$\approx.0499+.1987\times\color{red}{\frac12}+.3894$$
$$\approx.5386$$
Comment: Note:  for small $x, $ $\sin x \approx x$


Where to specify preprocessor directives in visual studio?

Question: Trying to define a preprocessor directives in the Visual studio 2012.
#define FLAG
....
#endif

But not sure, where to include this FLAG in visual studio - C#. I remember specifying something like this in C++ projects.
Any thoughts ?
Comment: They're called "preprocessor directives" anyway, even though the compiler doesn't have a preprocessor.  https://msdn.microsoft.com/en-us/library/ed8yd1ha.aspx
Answer: You have two options as to where to define it:

Code file level - In the beginning of the file write #define FLAG. You cannot place anything else (other than comments and blank lines) before define directives. As Ron Beyer points out, a directive defined in a file exists only for that file.

Project level - Right click in the project in Solution Explorer, select Properties, then the Build tab, then look at Conditional compilation symbols. Then one can define several comma-separated symbols there such as: FLAG,FOO,BAR. Note that this symbols list is project configuration dependent (there is a configuration selector in the same tab).

Note as mentioned in the comments, define does not work in C# the same way that it does in C. In C# you just declare that the symbol exists, but you can't assign a value to it. Hence the only use for these symbols is for #if FLAG directives and for the Conditional attribute.
Comment: Also note, you cannot specify *values* for these definitions. You can only specify *the definition itself.*
Comment: You should note that defining it at the code file level only defines the flag for that code file, it doesn't do it project wide. Its a departure from how C++ works.
Comment: if you define it at the project level, where does VS store that info? I can't find it in the .csproj or .sln files, and I don't seem to be able to remove it
Comment: @mcmillab it's in the .csproj under \Project\PropertyGroup\DefineConstants
Comment: In my version of VS 2022 Pro v 17.7.5 there is no "Build" tab under "Solution Explorer" / Properties.  There are no ".csproj" files anywhere in the project directory structure.
Answer: For some reason, when properties clicked, nothing happened for me. So I did the following. And it worked.
Open your csproj project file using text editor and  add your preprocessor compiler directives in between these.
<DefineConstants>
HERE!!!
</DefineConstants>


updating OpenLDAP with SSL certificates

Question: I am using the following command and script to get OpenLDAP (running on ubuntu v16) to use SSL certificates (locations of the certificates is correct).
ssl.ldif
dn: cn=config
changetype: modify
add: olcTLSCACertificateFile
olcTLSCACertificateFile: /etc/ssl/certs/fullchain-xxxxxx.pem
-
add: olcTLSCertificateFile
olcTLSCertificateFile: /etc/ssl/certs/cert-xxxxxx.pem
-
add: olcTLSCertificateKeyFile
olcTLSCertificateKeyFile: /etc/ssl/private/privkey-xxxxxx.pem

command:
sudo ldapmodify -H ldapi:// -Y EXTERNAL -f ssl.ldif

output:
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry "cn=config"
ldap_modify: Other (e.g., implementation specific) error (80)

Is there any other log file entry that I can check to troubleshoot this further?
Answer: I had to ensure that all certificate files were readable by the openldap user and that the openldap user was part of the ssl-cert group.  Once the read access was in place, the command worked correctly.

updating OpenLDAP with SSL certificates


Four chords in chord progression. How to choose the fourth chord?

Question: I've been taking a fairly beginner music expression course and I've recently learned about chord progressions using chords in I, IV, V.
However, I'm aware that most popular music that you would hear on the radio is generally a four-chord song. How is the fourth chord generally determined?
Comment: Note that the first three chords are not always I, IV, and V. *Smells Like Teen Spirit* is i - iv - III - VI (major/minor flavors implied as the actual chords have no thirds).
Answer: Adding a fourth chord to a three chord progression consisting of the I - IV and V chords in a major key can serve many purposes.
For one, it can create a more dynamic and more interesting chord progression.  A ii (two minor) or iii (three minor) or vi (sixth minor) chord can add tension to the progression which will beg for resolution back to the root or tonic chord - thereby creating a push pull effect of tension and resolution. A minor chord in a major key progression can serve to lead you to one of the other major chords or serve as a pivot point to switch the order of the progression.  These are just some examples of how one of the minor chords can be used in a four chord progression in a major key.
Many possible 4th chords are available including the ii, iii, or vi.  You can also use a diminished 7th degree chord or even a flattened 7th degree major chord. Extensions can also be used (7th, 9th, augmented, suspended).
One very commonly used fourth chord in a four chord progression is the vi chord and a popular progression is the I-V-vi-IV progression.  Some of the reasons the iv chord is often used as the fourth chord can be found in the answers to this question Why is the I-V-vi-IV chord progression so popular
Ultimately the fourth chord you use depends on what purpose you want it to serve in your song and what you want to accomplish by using it.
A comprehensive online search may yield some helpful guides such as the charts pictured below. As a disclaimer, these charts are merely examples of devices that have been invented to simplify the process of choosing chords and don't purport to offer every possible solution and should not be treated as rules that cannot be broken.  Ultimately your goal should be to develop the ability to effectively use your own creativity (guided by music and chord theory) to compose chord progressions that help you express your own personal musical ideas.
Comment: @RockinCowboy - With due respect, your pictures / graphs are quite silly; the tension -> resolution ladder is quite incorrect: there is *no way* a "iii" chord is to be considered a "tense" chord. In your chord progression graph, it illustrates that IV cannot go to "vi", which is insane, since that movement offers incredibly smooth voice-leading and is actually very common to hear in music. It doesn't show how "ii" can substitute IV or how "vi" can substitute I, and omits the seven-diminished chord entirely. Apart from showing some major scales, the matrix you provide seems to be incoherent.
Comment: @jjmusicnotes  I did not create the charts, I found them & although the ideas suggested are not cast in stone, I personally find them useful.  I agree that a IV can go to a vi so the word "rules" in the instructions should be "suggestions".  If you follow the "suggestions", you will have a chord progression that works.  But you could certainly deviate from the suggestions and still have a chord progression that works.  The OP is a beginner so just offering some cheat sheets.  The charts are designed to be simple & not cover every possibility. I personally feel a iii chord creates tension.
Comment: If a song begins on an upbeat it is likely that the progression will start on the dominant.
Comment: Arguably the most used 4 chord sequence is I- vi- IV- V. There must be hundreds if not thousands.
Comment: @NeilMeyer - if the song begins on the upbeat, it's an anacrucis, and the actual progression starts on the tonic, which is the norm.
Comment: @Tim or some variation of the I-vi-IV-V.  The progression in the popular Axis of Awesome routine is the I-V-vi-IV variation (which is what I meant to say in my answer so I edited to correct the typo).  But regardless of the variation, it is true that the vi seems to be one of the most common fourth chords used - and yes its thousands of songs to be sure.
Comment: @jjmusicnotes My impression is that none of the charts are meant to represent all the possibilities or be restrictive. Instead, they seem to be showing some basic concepts. There's no way the "Chord Progression Map" could be completed in the sense of having all the possibilities. Perhaps Rockin Cowboy could have disclaimed the completeness of the images to be totally clear, but they are presented "to help with some ideas" and not to be a complete picture of any aspect of music theory. +1
Comment: @ToddWilcox I understand. My issue is not with whether or not the charts are comprehensive, but that they are omitting some basic, coherent, factually accurate information. I made my comment because I felt the charts took away from Rockin's answer. I'm all for visuals, but we need to make sure we use / show the best information available, not merely what may be convenient.
Comment: @jjmusicnotes Based on your comments I edited my answer (changed the paragraph preceding the charts).  I do appreciate your suggestions.  My goal whenever I provide an answer on this site, is to provide valuable and useful and accurate content for the benefit of future readers (as well as the OP).    I respect your comprehensive knowledge on music theory in general.  Your assistance in helping with the accuracy of any of my answers is always welcome!
Comment: @ToddWilcox I followed your advice to add the disclaimer and edited my answer accordingly.   Sometimes I think we write answers without considering all the possible ways they might be interpreted. And I think if we made our answers long enough to cover every conceivable interpretation, we would lose the reader.
Answer: Not necessarily so. There is an awful lot of 3 chord songs (and a lot of awful 3 chord songs, but that's just a joke) that work very well. If a fourth chord is deemed needed, it will usually be one of the following. A minor belonging to the same key, as in ii, iii or vi. The vi is probably the most prevalent of these. Followed by ii then iii. But it will depend on the song. Any extra chord will have to match the notes in the melody. That's just what any chord does. The next option is the dominant chord which leads to the dominant of the key - II. Thus, in C, the missing chord , apart from C, F and G, would be either Am, Dm, or Em, or D(7).
Other options in general use could include I7, to move to IV, and iv (minor F in C) to get back to I. There's maybe a list of probable chords, in usage order, to consult. In fact, it may be an interesting exercise to compile such a list from popular song chord make ups that does this. It'd probably go I, V, IV, vi...
Comment: To clean up some of your points concerning music theory - the dominant of a key is the V chord, not a II, which would be a V/V a.k.a a secondary dominant. You would never label a "I" chord as a "I7", but rather a V7/IV - you need to show functional relationship when present. You're correct on both counts about three-chord songs, but you miss the mark in answering the OP's question. In a four-chord progression, the last chord is very, very typically going to be a IV, V, or secondary dominant. Use of a "vi" or "ii" typically serve as substitutions of I, IV, and V to prolong the *middle*.
Comment: @jjmusicnotes - thank you for the guidance, much appreciated.What I tried to portray was the dominant chord leading to the dominant of the key. Thus, in C maj., (dominant G), it would be D (or D7). If I call a chord V7/IV, then yes, it's the dominant 7th leading to the subdominant, which is where most dominants go - up a fourth. My glitch is if I see V7/IV, and I'm reading it live, I see the V7 first, and automatically go to D7 in C. II may not be technically correct, but it helps me play the right thing! The 'fourth chord' (O.P.) I took to mean the next most used chord after I, IV and V.
Comment: @jjmusicnotes - where does that leave Sweet Georgia Brown? In G, goes E - A - D - G chordally. So given G=I, that could make E technically V/V/V - rather unwieldy. And the B7 in there would be V/V/V/V. Help!
Comment: Thanks for explaining how you interpreted the OP's question about the "fourth chord", I obviously took it to mean the fourth chord of a sequence. Regarding Sweet Georgia Brown, if the chords are functioning as secondary dominants, then yes, V/V/V or V/V/V/V would be absolutely right, even if it seems silly / stupid. I've analyzed Beethoven string quartets that had a similar train of secondary leading-tone chords, as well as non-functional secondary dominants (such a rebel!). Yes, you'll feel stupid writing that many "V's", but it's correct. :)
Comment: @jjmusicnotes - thanks again. Some of these rules were made by non-musos, I guess! Incidentally, in my first comment, I should have said 'In C, if I see V7/IV, I automatically go to G7, not D7. A sort of N.N.S. I prefer and have adapted.
Comment: No problem.  For what it's worth, in your defense, people typically don't read roman numeral analysis "live" unless they are sight-reading figured bass realizations in a Baroque ensemble. If you're playing in a rock band, I'd suggest just putting pop chord symbols in and not worrying about showing the functional harmony.
Comment: @jjmusicnotes - yes, it's pretty well like reading Nashville number system, except with Roman numerals instead of Arabic numbers. I find the latter not so clear, so my way works for me. It's not analysis per se, but an easy way to be able to play a song in any key, rather than reading iin Eb, say, and changing it on the fly to F#. So in these cases, in C, D7 would be written as II7, as it's not contravening any rules. Whilst playing a song, I don't need to know whether it's a secondary dominant, etc., only what I need to play.


Android virtual device cannot start on Windows 7

Question: Whenever I try to create a virtual device in Android Studio it always returns this error:
Intel HAXM is required to run this AVD.Enable VT-x in your BIOS security settings.

I have installed haxm 6.1.2 and it's not working. My computer is with Intel Core i5-2450m CPU.  From Intel's website, it shows that it supports virtualization. But I have not been able to figure out how to enable the virtualization.
Answer: I think the virtualization isn't enabled in your BIOS settings.
Open boot menu by pressing F2 just before your system starts. Go to System Security. Make sure that VIRTUAL TECHNOLOGY VTX is checked, then hit F10 to save.
I hope this will work.


How to find cartesian coordinate of velocity of particle on the trajectory, $Ax^2 +2Bxy +Cy^2=1, A,B,C >0.$

Question: Consider a particle with constant speed $|w|=w_o$ moving on trajectory $Ax^2 +2Bxy +Cy^2=1, A,B,C >0.$ Could anyone advise me how to express cartesian coordinates of $v$ in terms of $x$ and $y \ ?$
Here is my attempt: Let $x=u\text{cos}\theta-v\text{sin}\theta, \ y=u\text{sin}\theta+v\text{cos}\theta,$ where $\text{tan}(2\theta) = \dfrac{B}{A-C}.$ Then the equation is reduced to one in terms of only $u^2$ and $v^2.$ So the space curve $r(u)=(u,g(u))$, for some function $g.$ And $w=\dfrac{dr(u)}{dt}= (\dfrac{du}{dt}, \dfrac{dg}{du} \dfrac{du}{dt}) \ ?$
Answer: $$Ax^2 + 2Bxy + Cy^2 = 1$$
$$2Axdx + 2Bydx+2Bxdy + 2Cydy = 0$$
$$2(Ax+By)dx + 2(Bx+Cy)dy = 0$$
$$\Rightarrow (Ax+By)\frac{dx}{dt} + (Bx+Cy)\frac{dy}{dt}= 0$$
$$v_x= - \frac{Bx+Cy}{Ax+By}v_y $$
And we know that
$$v_x^2+v_y^2=w_0^2$$
Using these two equations you can solve for $v_x$ and $v_y$
Answer: Let's rewrite equation
$$
Ax^2 + 2Bxy + Cy^2 = 1
$$
as
$$
(Ax + By)^2 + (CA - B^2)y^2 = A.
$$
We have three cases.
I. $CA - B^2 = D^2 > 0$. Equation is
$$
(Ax + By)^2 + (Dy)^2 = A.
$$
It's ellipse. Let's use standard parametrization:
$$
\left\{\begin{aligned}
Ax + By &= \sqrt A\cos\phi,\\
Dy &= \sqrt A\sin\phi
\end{aligned}\right.
\Longrightarrow
\left\{\begin{aligned}
x &= \frac{1}{\sqrt A}\left(\cos\phi - \frac{B}{D}\sin\phi\right),\\
y &= \frac{\sqrt A}{D}\sin\phi
\end{aligned}\right.
$$
So, tangent vector ("speed") is
$$
\vec p = \left(\frac{\partial x}{\partial\phi},\, \frac{\partial y}{\partial\phi}\right) = \left(-\frac{1}{\sqrt A}\left(\sin\phi + \frac{B}{D}\cos\phi\right),\,
\frac{\sqrt A}{D}\cos\phi\right)
$$
But length of $\vec p$ doesn't equal to one. Ok, let's use $\vec n = \vec p/|\vec p|$! And velocity vector became $\vec u = w_0\vec n$. Let's find them. First of all,
$$
\vec p = \left(-\frac{1}{\sqrt A}\left(\sin\phi + \frac{B}{D}\cos\phi\right),\,
\frac{\sqrt A}{D}\cos\phi\right) = \\=
\left(-\frac{1}{A}\left(Dy + \frac{B}{D}(Ax + By)\right),\,
\frac{Ax + By}{D}\right)=\\=
\frac1D \left(-\frac{1}{A}\left(D^2y + B(Ax + By)\right),\,
Ax + By\right)=\\=
\frac1D \left(-(Bx + Cy),\, Ax + By\right)
$$
and
$$
|\vec p|^2 = \frac{1}{D^2} \big((Bx + Cy)^2 + (Ax + By)^2\big) \Longrightarrow
|\vec p| = \frac{1}{D^2} \sqrt{(Bx + Cy)^2 + (Ax + By)^2}.
$$
So,
$$
\vec u = w_0 \vec n = w_0 \frac{\left(-(Bx + Cy),\, Ax + By\right)}{\sqrt{(Bx + Cy)^2 + (Ax + By)^2}}
$$
I suppose, you can now consider cases $CA - B^2 < 0$ (with $\cosh$ and $\sinh$; it's hyperbola) and $CA - B^2 = 0$ (it's pair of lines).


Question regarding Limits and the use of L'hopital

Question: I am having trouble with this limit, and wondered if this step on line $5$ was allowed, where I used L'Hopital agian but in the numerator of the limit. Thanks in advance.

I have attatched a picture of my calculations.
Comment: Welcome to Mathematics Stack Exchange. It's unclear exactly which line you are referring to. If you typeset the equation in [Mathjax](https://math.meta.stackexchange.com/questions/33179/short-and-helpful-advice-on-using-mathjax-on-the-site), then people will be more willing to help you. In addition, please provide more information about what part of the calculation is troubling you.
Comment: I'm sure that you have not done any calculations. It is important the sincerity. The font is very closer to Cambria Math.
Comment: It is a screenshot from my Microsoft word document. I'm terribly sorry for the format, however, I am not very experienced with Latex and other text editors.
Comment: @BreeZeriNoo: If you read the tutorial, including the section on calculus notation, then I think you will know enough to be able to typeset it. I'm only recommending this because some people object to people using pictures quite strongly, and you might receive downvotes otherwise.
Comment: Which one is line 5? Do you count lines of text? Even if you don't use Mathjax/Latex, please mark it somehow: red line, or star, or put a rectangle around the step which is unclear
Comment: @Andrei Yes I am terribly sorry. I have tried to mark it out now.
Answer: By a single application of L'Hospital,
$$\frac{\sqrt x\sin\sqrt x}{1-e^{-x}}\to\frac{\dfrac{\sin\sqrt x}{2\sqrt x}+\dfrac{\cos\sqrt x}2}{e^{-x}}\to\frac{\dfrac12+\dfrac12}1.$$
Note that a second application of L'Hospital is not allowed (nor necessary), as the conditions for application are not fulfilled.

Without l'Hospital:
Let $x=t^2$ and $u=t^2$. Then
$$\lim_{x\to 0^+}\frac{\sqrt x\sin\sqrt x}{1-e^{-x}}=\lim_{t\to 0}\frac{t\sin t}{1-e^{-t^2}}=\lim_{t\to 0}\frac{t^2}{1-e^{-t^2}}\frac{\sin t}t=\frac{\lim_{t\to 0}\dfrac{\sin t}t}{\lim_{u\to 0}\dfrac{1-e^{-u}}u}=1$$
using well-known limits.


How many four-vertex graphs are there up to isomorphism;

Question: Let us call graphs $G = (V,E)$ and $G' = (V', E')$ fundamentally different if they are not isomorphic. How many fundamentally different graphs are there on four vertices?
This is a question on my homework. I'm thinking that I need to exhaust all the possible variations of a graph with four vertices:
Each vertices could have a degree of 0, 1, 2 or 3.
Four possibilities times 4 vertices = 16 possibilities.
And also, maybe, since the graphs are fundamentally different (not isomorphic), you need to minus 1 possible variation since it would match the other graph.
Comment: There are more possibilities than that. When the degree is 2, you have several choices about which 2 nodes your node is connected to. I assume you're working with simple graphs (i.e., you cannot have an edge from a node to itself).
Comment: Omnomnomnom (below) says otherwise. Can you expand on your answer please?
Answer: There are $11$ fundamentally different graphs on $4$ vertices.
Comment: This looks like a cool reference page but I don't quite understand how/why you think 11 is the answer. Elaborate please?
Comment: @DiscreteGenius, Omnomnomnom counted the eleven four-vertex graphs listed on that page and came up with the number eleven. Are you asking how that list was constructed, or how to count to eleven?
Comment: Excuse my confusion yesterday. I understand the answer now.
Answer: As Omnomnomnom posted, there are only 11. One way to approach this solution is to break it down by the number of edges on each graph. A (simple) graph on 4 vertices can have at most ${4\choose 2}=6$ edges.
0 edges: 1 unique graph.
1 edge: 1 unique graph.
2 edges: 2 unique graphs: one where the two edges are incident and the other where they are not incident.
3 edges: 3 unique graphs. One is a 3 cycle with an isolated vertex, and the other two are trees: one has a vertex with degree 3 and the other has 2 vertices with degree 2.
4 edges: 2 unique graphs: a 4 cycle and one containing a 3 cycle.
5 edges: 1 unique graph.
6 edges: 1 unique graph.


Subdifferential of a finite dimensional function.

Question: I want to compute the subgradients of the absolute value function in $\mathbb{R}^n$. How do I do this?
Comment: By absolute value, you mean $|x|= \left( \sum_i x_i^2 \right)^{1/2}$?
Answer: $\phi=||\cdot||$ is differentiable on $\mathbb{R}^n \backslash \{0\}$, so $\partial \phi(x)=\{\phi'(x) \}$ (you can show that $\phi'(x)= \frac{1}{|x|} \langle x, \cdot \rangle$). Then, $\partial \phi(0)= \{ \zeta \in (\mathbb{R}^n)^* \ | \ \forall y \in \mathbb{R}^n, |y| \geq \langle \zeta, y \rangle \}$ is the unit closed ball in $(\mathbb{R}^n)^*$.
Comment: Yes. I know how Tor do this for n=1 but not for arbitrary n.


Enter Mutex error for Launch4J

Question: What is the following error I get in Launch4J while converting my Jar file to an Exe:
Enter Mutex Name?

I am using Version 3.8 of Launch4J. Comment if you want me to elaborate.
Answer: If you chose a Mutex, you allow only one instance of your application.
You can chose a random Mutex name, example: abcMutex0
Without Mutex:

With Mutex:

If you get the error Enter Mutex Name?, you may have tick "Allow only a single instance of the application" but you haven't enter a Mutex name.

Enter Mutex error for Launch4J


Is it possible to do a half-range sine expansion on the sine function?

Question: Suppose $f(x)=sinx,\quad 0<x<π$.
Can you do a half-range sine expansion on f(x)? I tried, but I got $a_0=a_n=b_n=0$.
If you requrie me to show my steps (i.e. I should have not gotten $a_0=a_n=b_n=0$), please leave a comment. I am not very good with tex so I'd rather avoid it if I can.
Answer: If you do an odd expansion, then the extension is $\sin x$ itself. And, indeed, you have
$$
b_1=\frac2\pi\int_0^\pi\sin^2x\,dx=\frac2\pi\,\frac\pi2=1.
$$
If you do an even expansion, then your function is $|\sin x|$ on $(-\pi,\pi)$ and its coefficients are
$$
a_0=\frac2\pi\int_0^\pi\sin x\,dx=\frac4\pi,
$$
$$
a_n=\frac2\pi\int_0^\pi\sin x\,\cos nx\,dx=\frac2\pi\,\frac{1+(-1)^k}{1-k^2}.
$$
so the Fourier series is
$$
\frac4\pi-\frac4\pi\,\sum_{k=1}^\infty\frac{\cos 2kx}{4k^2-1}
$$


create a df of mean ± std by column values

Question: I have seen some solutions in the internet but no one seems comprehensive enough for this seemingly simple task.
Suppuse I have a df:
data = {'group': ['A', 'A', 'B', 'B', 'B', 'A'],
        'value1': [10, 20, 30, 40, 50, 60],
        'value2': [1, 2, 3, 4, 5, 6],
        'value3': [0.1, 0.2, 0.3, 0.4, 0.5, 0.6]}
df = pd.DataFrame(data)

I want to create a new df: the columns would be the values of the "group" coulmn, and the values would be the mean ± std for each column from the original df.
Desired output:
     variable     A            B
     value1   30.00±26.46  40.00±15.59
     value2     3.00±2.16    4.33±1.25
     value3     0.15±0.19    0.40±0.12

Comment: Can you explain how do you compute the *mean/std* ? e.g, why the pair `value3/A` has `0.15±0.19` ?
Answer: Here is one way :
out = (df.groupby("group").agg(["mean", "std"]).stack(0).round(2).astype(str)
             .agg("±".join, axis=1).unstack(0).rename_axis(columns="variable"))

Output :
print(out)

variable           A          B
value1    30.0±26.46  40.0±10.0
value2      3.0±2.65    4.0±1.0
value3      0.3±0.26    0.4±0.1

Answer: Another possible solution:
df.pivot_table(
    index='group', values=['value1', 'value2', 'value3'],
    aggfunc=lambda x: f'{x.mean().round(2)}±{x.std().round(2)}').T

Output:
group            A          B
value1  30.0±26.46  40.0±10.0
value2    3.0±2.65    4.0±1.0
value3    0.3±0.26    0.4±0.1

Comment: You should make it a string directly in your lambda
Comment: Done, @mozway. Thanks for having commented my solution!


How do I implement the login, register and "Forgotten password" forms?

Question: I'm trying to implement the three Drupal 8 user forms : login, register account and forgotten password forms.
I'm creating custom pages in my module for each one of them because I want to display content around those forms, change titles, hook the forms.
I'm having a hard time to do it, especially to get those forms in order to send them to the template and render them.
Answer: Here is what I ended up doing in my controllers :
<code># Login form
public function content() {
  $formBuilder = $this->formBuilder();
  $form = $formBuilder->getForm("Drupal\user\Form\UserLoginForm");
  return [
  '#theme' => 'weber_login_form',
  '#login_form' => $form,
  ];
}

# Forgotten password form
public function content() {
  $formBuilder = $this->formBuilder();
  $form = $formBuilder->getForm("Drupal\user\Form\UserPasswordForm");
  return [
    '#theme' => 'weber_password_form',
    '#password_form' => $form,
  ];
}

# Register form
public function content() {
  $entity = \Drupal::entityManager()
  ->getStorage('user')
  ->create(array());

  $formObject = \Drupal::entityManager()
  ->getFormObject('user', 'register')
  ->setEntity($entity);

  $form = \Drupal::formBuilder()->getForm($formObject);
  return [
    '#theme' => 'weber_register_form',
    '#register_form' => $form,
    '#link' => NULL,
  ];
}
</code>
Answer: I would always prefer to customise the built-in pages rather than use the approach OP followed because those pages still exist and can be visited (unless OP is overriding the routing as well, which they did not mention).
There's a lot that can be done by simpler means:

Using the block system to inject extra content into the pages. Blocks can be programmatic or content managed, whichever best suits your needs.
Using hook_form_ID_alter() to alter the individual forms as required.
Using theme overrides to adjust the HTML for theming purposes.

Without knowing the specific changes required it's difficult to advise in more detail. Certain contributed modules might be useful but again without further information I can't really say.


Doubt in differentiation

Question: This question may look like a homework like question but I am only giving a example to express my problem :
Suppose we have an equation
$$ x^2=\cos\theta.$$
Taking the derivative to both sides I get
$$\frac{dx^2}{d\theta} = \sin\theta.$$
Now what $d(x^2)$ essentially means is that when I change $\theta$ to $\theta + d\theta$ what is the change in $x^2$. Now I know that
$$d(x^2)=2xdx$$
by as $\frac{dx^2}{dx}=2x$ and I can replace $d(x^2)$ from here. But my doubt Is how do we know that they both bring the same change $d(x^2)$ when $\theta$ changes to $\theta + d\theta$ and $x$ changes to $x +dx$. How do we know $d(x^2)$ is the same in both cases?
Comment: You may think of this way: $df$ is an instrument that measures how the value of a function $f(x)$ changes as $x$ changes. So, even if the variable $x$ is restricted to a constraint, the relation $$df=f'(x)\,dx$$ continues to hold but the only difference is that now the variable $x$ can change only along that constraint. In your case, $x^2=\cos\theta$ induces $$2x\,dx=-\sin\theta\,d\theta,$$ and its interpretation is that two infinitesimal changes $2x\,dx$ and $-\sin\theta\,d\theta$ are coupled by the above equality. This ideal also aligns with the famous Chain Rule.
Comment: I don't understand your question, but maybe this helps: we have $$\dfrac {d x^2}{d \theta} = 2x \dfrac {d x}{d \theta}.$$ So we do take into account the change in $\theta$.
Answer: Good question. One way to think about differentiation which I think will clear some things up is to assume that there is a "standard candle" against which all differentiation is done.
That is, in your case you were noting that for the equation:
$$
x^2 = \cos(\theta)
$$
If you take the derivative with respect to $\theta$ you get
$$
\frac{d(x^2)}{d\theta} = -\sin(\theta)
$$
You noted that if you do the differentiation in the numerator you will get $d(x^2) = 2x\,dx$.  But how do you know that these incremental changes "match up" so to speak?
The way to think about it is to assume that the differential operator is always in terms of some non-present standard candle.  So, imagine a new variable, say $q$, which everything is ultimately dependent upon, but for which we do not have a formula.  Therefore, we will say that $dq$ is some infinitely small difference (I usually use $\epsilon$ as the standard infinitesimal if I want to get concrete about it).  You can think about the differential operator as always generating differentials which are relative to this standard candle.  In fact, you can think about $dx$ and $d\theta$ as literally being relative values to our standard candle $dq$.  Since $dq$ is a fixed value for our differential operator, then the relationships between $dx$ and $d\theta$ will hold true.
Comment: I understand what you are saying but I am not sure I understand what you have written in the last paragraph.Could you explain it in layman terms?
Comment: I don't understand what is a differential operator
Comment: Please answer my question

Doubt in differentiation


How does jslint work?

Question: How does jslint check for problems in javascript?  Does it have an actual javascript parser?
Answer: JSLint is written in JavaScript and uses a Pratt Parser. It "works" by parsing the source provided and looks for "problems". These problems are defined by the author, and are not necessarily syntax-related.
It should be noted that "JSLint defines a professional subset of JavaScript". This means that not all pure ECMAScript would appear valid in JSLint.
Comment: @fridojet I can't answer that question definitively. The author claims that **"JSLint defines a professional subset of JavaScript, a stricter language than that defined by _[Third Edition of the ECMAScript Programming Language Standard](http://www.ecma-international.org/publications/standards/Ecma-262.htm)_."**. I understand that to mean it is possible that not all valid ECMAScript programs will be valid from a JSLint perspective. I suppose it would have to be able to parse correctly in order to determine if a given piece of JavaScript is "good" or not, though. You can always ask Crockford :)
Comment: Do you that mean by that, that JSLint's parser doesn't parse every valid ECMA-/JavaScript correctly?
Answer: Yes, it parses and analyses the code.
It does not only check for definite problems in the code like syntax errors, but also any potential problems. If you write code that looks strange, there is a big probability that it doesn't do what you intended.

How does jslint work?


Should it be A|B or B|A?

Question: I came across a question in condition probability which left me wondering.
A departmental store reports that 30% of sales are transacted via cash, 60% are credit card and 10% with a debit card.
20% of the above cash purchases, 90% of the above credit card purchases and 80% of the above debit card purchases are made for purchases more than $200.
<code>So Let $C = {cash}$, D = {credit card}, E = {debit card} and M = {purchases > $200}

P(C) = 0.3
P(D) = 0.6
P(E) = 0.1
</code>
What I am not really sure is if it should be $P(M|C) = 0.2$ or is it $P(C|M) = 0.2$. Was wondering if I may get some advice on this please.
Comment: It looks like [the Wikipedia article on conditional probability](http://en.wikipedia.org/wiki/Conditional_probability#Conditioning_on_an_event) is clear about this.
Comment: Self-study tag maybe?
Answer: $P(M|C)$ denotes probability of the purchase being above $200 when you have observed that the purchase is through cash.
You say 20% of the cash purchases are made for above $200$. So $P(M|C) = 0.2$
$P(C|M)$ is slightly more complicated. You observe that the purchase is above $200 and then you need the conditional probability that it is done by paying cash. You need to apply Bayes rule.
$$
P(C|M) = \frac{P(C ) P(M|C)}{P(M)}
= \frac{0.3 \times 0.2}{0.68} \approx 0.088
$$
P.S: I must add, I am a newbie myself. So please get this verified by someone!
P.P.S: Sorry, as pointed out below, I made a small error with my normaliser. Fixed now.
Comment: I think you may want to check the probablity of $M$, which IMAO should be $P(M)=P(M \cap C)+P(M \cap D)+P(M \cap E)$, from which follows that $P(M)=P(M|C)P(C)+P(M|D)P(D)+P(M|E)P(E)=.68$ so that $P(C|M)=.0882$.

Should it be A|B or B|A?


What is proper way to handle custom validation in flask?

Question: Following is the method where I am handling multiple custom validation with custom messages.
def social_login_validation(data):
    """Login validation schema."""
    schema = Schema({
        Required('first_name'):All(str, Length(min=1, max=30)),
        Required('last_name'):All(str, Length(min=1, max=30)),
        Optional('phone_number'):All(str, Length(min=10, max=10), validate_phone_number),
        Optional('profile_picture'):Any(str, Length(min=1, max=255)),
        Optional('email'):All(str, Length(min=10, max=255), validate_email),
        Optional('auth_token'):Any(str, Length(min=10, max=255)),
        Optional('auth_token_expiry_date'):Any(str, Length(min=10, max=255)),
        Required('social_media_login_type'):All(str, Length(min=1, max=255),\
                validate_social_media_login_type),
        Required('social_id'):All(str, Length(min=10, max=255))
    })
    try:
        schema(data)
    except MultipleInvalid as error:
        if "length" in str(error) and "['first_name']" in str(error) and "at most" in str(error):
            message = RESPONSES['LENGTH_FIRST_NAME']
            code = RESPONSES_CODE['BAD_REQUEST']
        elif "length" in str(error) and "['last_name']" in str(error) and "at most" in str(error):
            message = RESPONSES['LENGTH_LAST_NAME']
            code = RESPONSES_CODE['BAD_REQUEST']
        elif "length" in str(error) and "['social_media_login_type']"\
            in str(error) and "at most" in str(error):
            message = RESPONSES['LENGTH_LOGIN_TYPE']
            code = RESPONSES_CODE['BAD_REQUEST']
        elif "length" in str(error) and "['social_id']" in str(error) and "at most" in str(error):
            message = RESPONSES['LENGTH_SOCIAL_ID']
            code = RESPONSES_CODE['BAD_REQUEST']
        elif "length" in str(error) and "['phone_number']" in str(error):
            message = RESPONSES['LENGTH_PHONE_NUMBER']
            code = RESPONSES_CODE['BAD_REQUEST']
        elif "expected str" in str(error) and "['email']" in str(error):
            message = RESPONSES['TYPE_EMAIL']
            code = RESPONSES_CODE['BAD_REQUEST']
        elif "data['first_name']" in str(error):
            message = RESPONSES['EMPTY_FIRST_NAME']
            code = RESPONSES_CODE['BAD_REQUEST']
        elif "data['last_name']" in str(error):
            message = RESPONSES['EMPTY_LAST_NAME']
            code = RESPONSES_CODE['BAD_REQUEST']
        elif "data['social_media_login_type']" in str(error):
            message = RESPONSES['EMPTY_LOGIN_TYPE']
            code = RESPONSES_CODE['BAD_REQUEST']
        elif "data['social_id']" in str(error):
            message = RESPONSES['EMPTY_SOCIAL_ID']
            code = RESPONSES_CODE['BAD_REQUEST']
        else:
            return jsonify({'message':str(error.error_message)}), 400
        return jsonify({'message':message}), code

What is the better way to handle these many custom messages?
Comment: This may help http://flask.pocoo.org/docs/1.0/patterns/errorpages/ . Also, if this is sqlalchemy there are custom errors for `required` columns.
Answer: It appears you're using voluptuous package?
Instead of writing each error message yourself, you might want to use the humanize functionality of the package.
If you look in the source code a bit, you can see that you can access the errors by error.errors. I'd look a bit into that and see if you can access the errors in a way less hacky than making turning the errors into strings.
I've never used this package, but please add it to the question tags so people know what they're looking at.


Moderated moderation (3-way interaction) with latent variables

Question: I would appreciate some help in deciding the analysis method for my research.
I have 7 variables: one DV, one IV, two moderators, one moderator/moderating moderator plus 2 controls. My overall sample size is 100 which is divided by the levels of Z (two countries) into 46 and 54. The DV, IV and one of the moderators are Likert-scale data (7 points), the other moderator and moderator/moderating moderator are binary.
My main purpose is to investigate the differences between the two countries regarding the relationships among the other variables.

I tried two analysis methods which I find okay but not sure which one is the best. The first one is regression analysis using R and the second is PLS-SEM using SmartPLS.
For the regression analysis, I ran the following models (ignore model 2):
Note: W3 = Z
m1 <- lm (Y ~ C1 + C2, data = DataR100C)
m3 <- lm (Y ~ C1 + C2 + X + W1 + W2 + Z, data = DataR100C)
m4 <- lm (Y ~ C1 + C2 + X*W1*Z, data = DataR100C)
m5 <- lm (Y ~ C1 + C2 + X*W2*Z, data = DataR100C)
m6 <- lm (Y ~ C1 + C2 + X*W1*Z + X*W2*Z, data = DataR100C)
The results are as follows:

First, I would like some help with the interpretation. I see that both 3-way interactions are significant when combined but not separately. what does this mean?!
For the second method; PLS-SEM, I added the two interaction terms to the model then ran bootstrapping analysis, then I ran MGA between the two countries (Z) to detect multigroup differences.
Which method is better to best present my main focus, having in mind the small sample size? are there other methods I should try?
Thanks.
Comment: Just a short comment. You are testing a fairly complex model for your sample size of n=100. You may run a risk of not having enough power to detect statistically significant effects, especially for the moderated parts of your model
Comment: Thank you for the comment @PsychometStats. Do you have any suggestions?
Answer: @Sara, I will add some suggestions here, as I thought that it might be a bit too long for a comment. I apologise in advance that I will not be able to tackle all issues raised in your post. So hopefully, whatever is not covered will be covered by others.
First, given a complex model for your relatively small sample size of n = 100, you may lack statistical power to detect (especially) moderated effects. Hence, I would probably start by running the simplest X -> Y model. Once you have an idea of the relationship between these two variables, I would do the following.
You may start by adding moderators incrementally. The first choice is between W1 (binary), Z1 (binary) and W2(continuous). Again given your sample size, my recommendation would be to start by trying either of the binary moderators W1 or Z1. From a statistical point of view it's more convenient and generally easier to start with binary moderators. When guiding your choice as to which of the two binary moderators to start with, you may ask yourself which of the two makes theoretically more sense. If adding W1 or Z1 individually and then simultaneously does NOT work, and it is not unreasonable to expect that, I would then try adding W2 (continuous) moderator individually instead.
Next, try adding all 3 moderators simultaneously: W1, Z1 W2, and then assess the results. If everything happens to be significant, then your interpretation of the conditional effects would usually be complex as you need to go into details of various conditions under which X affects Y. For example, suppose W1 is gender, Z1 is disability, and W2 is age. Then you may say that, for example, that for middle age females without disability, X has a significant effect of Y (insert effect size and level of statistical significance). Again, you do not need to interpret the effects of X on Y for every possible condition, but rather for the conditions you may most be interested in.
Finally, I would add two remaining relationships: each where Z1 moderates the moderated effects of W1 and W2. Please note that in practice, relatively large sample sizes are needed to test hypotheses involving moderated moderation.
Again, my guess is that you would struggle to achieve statistically significant results for the moderated relationships, but it is not to say that you should NOT try. After all, this situation is not uncommon in social research. In such situations, if your moderated relationships are not significant, you may acknowledge a possibility in your write up that this might have been a result of low power (i.e. low sample size). And that this possibility may be tested in future research with larger sample sizes to get more conclusive results.


How to get ListView data from one activity to another using setOnClickListener

Question: In my listview there are to feilds,ward number and the date.i want to get these data to new activity when i'am clicking a listview.but in this there is a runtime error and i have no idea to how to fix it.
this is my dashboardActivity.java file,
public class DashboardActivity extends ListActivity implements FetchDataListener{

    UserFunctions userFunctions;
    Button btnLogout;
    TextView resultView;
    private ProgressDialog dialog;
    //private String email;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    /**
     * Dashboard Screen for the application
     * */
    // Check login status in database
    userFunctions = new UserFunctions();
    if(userFunctions.isUserLoggedIn(getApplicationContext())){
        setContentView(R.layout.dashboard);

        initView();

         ListView lv = getListView();

          // listening to single list item on click
          lv.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {

                // selected item
              TextView txtviewWard= (TextView) view.findViewById(R.id.ward_number);
              String ward = txtviewWard.getText().toString();

              TextView txtviewDate= (TextView) view.findViewById(R.id.date_time);
              String dateTime = txtviewDate.getText().toString();

                // Launching new Activity on selecting single List Item
                Intent i = new Intent(getApplicationContext(), SingleListItem.class);
                // sending data to new activity
                i.putExtra("ward", ward);
                i.putExtra("dateTime", dateTime);
                startActivity(i);

            }
          });

        btnLogout = (Button) findViewById(R.id.btnLogout);

        btnLogout.setOnClickListener(new View.OnClickListener() {

            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                userFunctions.logoutUser(getApplicationContext());
                Intent login = new Intent(getApplicationContext(), LoginActivity.class);
                login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(login);
                // Closing dashboard screen
                finish();
            }
        });

    }else{
        // user is not logged in show login screen
        Intent login = new Intent(getApplicationContext(), LoginActivity.class);
        login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(login);
        // Closing dashboard screen
        finish();
        }
    }

private void initView() {
    // show progress dialog
    dialog = ProgressDialog.show(this, "", "Loading...");

    Intent intent = getIntent();
    String email = intent.getStringExtra(LoginActivity.EMAIL);

    String url = "http://pubbapp.comze.com/pubapp1.php?email=" + email;
    FetchDataTask task = new FetchDataTask(this);
    task.execute(url);

}

public void onFetchComplete(List<Application> data) {
    // dismiss the progress dialog
    if(dialog != null)  dialog.dismiss();
    // create new adapter
    ApplicationAdapter adapter = new ApplicationAdapter(this, data);
    // set the adapter to list
    setListAdapter(adapter);
}

public void onFetchFailure(String msg) {
    // dismiss the progress dialog
    if(dialog != null)  dialog.dismiss();
    // show failure message
    Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
}

}

this is my SingleListItem.java file,
public class SingleListItem extends Activity{
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.single_list_item_view);

    TextView txtWard = (TextView) findViewById(R.id.ward_number);
    TextView txtDate = (TextView) findViewById(R.id.date_time);

    Intent i = getIntent();
    // getting attached intent data
    String wardNumber = i.getStringExtra("ward");
    String dateTime = i.getStringExtra("dateTime");
    // displaying selected product name
    txtWard.setText(wardNumber);
    txtDate.setText(dateTime);

}

this is my xml file,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
    android:id="@+id/ward_number"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:padding="10dip"
    android:text="wardNumber"
    android:textColor="#ffffff"
    android:textSize="25dip"
    android:textStyle="bold" />

<TextView
    android:id="@+id/date_time"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Date"
    android:padding="10dip"
    android:textColor="#ffffff"
    android:textSize="20dip"
    android:textStyle="bold" />

</LinearLayout>

and this is the error in the LogCat,
12-02 19:10:01.100: E/AndroidRuntime(22705): FATAL EXCEPTION: main
12-02 19:10:01.100: E/AndroidRuntime(22705): java.lang.NullPointerException
12-02 19:10:01.100: E/AndroidRuntime(22705):    at com.example.androidhive.DashboardActivity$1.onItemClick(DashboardActivity.java:59)
12-02 19:10:01.100: E/AndroidRuntime(22705):    at android.widget.AdapterView.performItemClick(AdapterView.java:284)
12-02 19:10:01.100: E/AndroidRuntime(22705):    at android.widget.ListView.performItemClick(ListView.java:3745)
12-02 19:10:01.100: E/AndroidRuntime(22705):    at android.widget.AbsListView$PerformClick.run(AbsListView.java:1980)
12-02 19:10:01.100: E/AndroidRuntime(22705):    at android.os.Handler.handleCallback(Handler.java:587)
12-02 19:10:01.100: E/AndroidRuntime(22705):    at android.os.Handler.dispatchMessage(Handler.java:92)
12-02 19:10:01.100: E/AndroidRuntime(22705):    at android.os.Looper.loop(Looper.java:130)
12-02 19:10:01.100: E/AndroidRuntime(22705):    at android.app.ActivityThread.main(ActivityThread.java:3691)
12-02 19:10:01.100: E/AndroidRuntime(22705):    at java.lang.reflect.Method.invokeNative(Native Method)
12-02 19:10:01.100: E/AndroidRuntime(22705):    at java.lang.reflect.Method.invoke(Method.java:507)
12-02 19:10:01.100: E/AndroidRuntime(22705):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
12-02 19:10:01.100: E/AndroidRuntime(22705):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
12-02 19:10:01.100: E/AndroidRuntime(22705):    at dalvik.system.NativeStart.main(Native Method)

please help me to fix this error.
thank you.
Comment: I didnt't read through the code but what about simply usign an `Intent`?
Comment: `how to fix it` : read the stacktrace. check the indicated line. wonder why this exception happens at this specific line.
Answer: try this....
   ListView lv = getListView();

  // listening to single list item on click
  lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, View view,
        int position, long id) {

       //your code

    }
  });

Comment: you used new OnItemClickListener() and mine is new AdapterView.OnItemClickListener()..try this..it will work for sure
Comment: @user2881604 can you able to fetch data inside AdapterView.OnItemClickListener()..? make log and check first you getting value from adapter before starting activity. Then you can able find out issue
Answer: In first activity, pass the data as a bundle using putExtras:
// sending data to new activity
Bundle b = new Bundle();
b.putString("ward", ward);
b.putString("dateTime", dateTime);
i.putExtras(b);

In second activity, retrieve the bundle and parse the data as follows:
Bundle b = getIntent().getExtras();
if (b != null)
{
    String wardNumber = b.getString("ward");
    String dateTime = b.getString("dateTime");
}

Comment: thank you for your reply.i changed that as you mentioned.but still there is same error.
Answer: get data like this in ur second activity:
Bundle b = savedInstanceState.getExtras();
    if(b!=null)
    {
        String ward =b.getString("ward");
        String dateTime =b.getString("datetime");

    }

bundle is responsible to getexras(),so use this.it worked for me and my other friends.


The significance of partial derivative notation

Question: If some function like $f$ depends on just one variable like $x$, we denote its derivative with respect to the variable by:
$$\frac{\mathrm{d} }{\mathrm{d} x}f(x)$$
Now if the function happens to depend on $n$ variables we denote its derivative with respect to the $i$th variable by:
$$\frac{\partial }{\partial x_i}f(x_1,\cdots ,x_i,\cdots ,x_n)$$

Now my question is what is the significance of this notation? I mean what will be wrong if we show "Partial derivative" of $f$ with respect to $x_i$ like this?  :
$$\frac{\mathrm{d} }{\mathrm{d} x_i}f(x_1,\cdots ,x_i,\cdots ,x_n)$$
Does the symbol $\partial$ have a significant meaning?
Comment: I guess [this](http://math.stackexchange.com/questions/320228/the-notation-for-partial-derivatives?rq=1) is a similar question.
Answer: Or from a mathematical point of view:
$$
\frac{d}{dx_i}f(x_1,…,x_i,…,x_n)=\sum_{j=1}^n\frac{∂}{∂x_j}f(x_1,…,x_n)·\frac{dx_j}{dx_i}
$$
that is, the partial derivative "binds closer" to $f$ than the total derivative.
Comment: Thank you. But keep in mind I just know about elementary calculus :).So my knowledge is not much. What do you mean by "Total derivative"? I mean can you firstly define all of the terms "Ordinary derivative", "Partial derivative" and "Total derivative" in your answer?
Comment: The partial derivative treats all variables as independent. When differentiating for $x_i$, all other $x_j$ are held constant. -- In the total derivative, all variables are considered to be functions of $x_i$, even if they turn out as constant functions. Thus $\frac{d}{dx}f(x,y(x))=f_x+f_y·y'(x)$ is different from $f_x=\frac{∂}{∂x}f(x,y(x))$.
Comment: So for univariate functions "Ordinary derivative" and "Partial derivative" have the same values. But multivariate functions has no such thing as "Ordinary derivative"(and the notation is used instead for "Total derivative" which means the dependency of variables is not determined). And plus for multivariate functions we have "Partial derivative" which means the other variables are taken as independent. Correct?
Comment: Yes. The boundaries of what is what may be a little fluid from place to place, but essentially this is correct. -- I would not say "have the same values" but "are the same concept".
Answer: Mainly historical; see Earliest Uses of Symbols of Calculus : Partial Derivative :

The "curly $\mathrm{d}$" was used in 1770 by Antoine-Nicolas Caritat, Marquis de Condorcet (1743-1794) in "Memoire sur les Equations aux différence partielles", which was published in Histoire de L'Academie Royale des Sciences, pp. 151-178, Annee M. DCCLXXIII (1773). On page 152, Condorcet says:

Dans toute la suite de ce Memoire, $\mathrm{d} z$ & $\partial z$ désigneront ou deux differences partielles de $z$, dont une par rapport a $x$, l'autre par rapport a $y$, ou bien $\mathrm{d} z$ sera une différentielle totale, & $\partial z$ une difference partielle. [Throughout this paper, both $\mathrm{d} z$ & $\partial z$ will either denote two partial differences of $z$, where one of them is with respect to $x$, and the other, with respect to $y$, or $\mathrm{d} z$ and  $\partial z$ will be employed as symbols of total differential, and of partial difference, respectively.]

However, the "curly $\mathrm{d}$" was first used in the form $\dfrac{\partial u}{\partial x}$ by Adrien Marie Legendre in 1786 in his "Memoire sur la manière de distinguer les maxima des minima dans le Calcul des Variations", Histoire de l'Academie Royale des Sciences, Annee M. DCCLXXXVI (1786), pp. 7-37, Paris, M. DCCXXXVIII (1788).
On page 8, it reads:

Pour éviter toute ambiguité, je répresentarie par $\dfrac{\partial u}{\partial x}$, le coefficient de $x$ dans la différence de $u$, & par $\dfrac{\mathrm{d} u}{\mathrm{d} x}$ la différence complète de $u$ divisée par $\mathrm{d} x$.

Legendre abandoned the symbol and it was re-introduced by Carl Gustav Jacob Jacobi in 1841.
Comment: Sorry but I confused. Does it mean $\partial x$ and $\mathrm{d} x$ have different meanings? Does even $\partial x$ alone have a meaning?
Comment: $\partial x$ doesn't really have any meaning as far as i know. You shouldn't really take these notations apart. $\partial_x$ ($x$ in subscript) is often used as a shorthand for $\frac{\partial}{\partial x}$


Given a basis, is there a unique inner product such that that basis is orthogonal?

Question: I know there is a unique way to define an inner product such that the basis are orthonormal. Given a basis $(e_1, e_2, e_3,\dots,e_n),$ we can use the Kronecker delta function $(e_j,e_k)=0$ if $j$ is not equal to $k$, and $1$ if $j$ and $k$ are the same. The inner product defined this way is unique. Now if instead of orthonormal, we only required an inner product such that the basis is orthogonal, is the inner product unable to be unique because this requirement isn't strict enough?
Answer: You can just scale a given inner product by any positive real number.


Maximum possible measure and dimension in SAP UI5 Viz Chart (Line, Stacked Bar, etc.)?

Question: Working with SAP UI5 Viz chart (Line, Bar, Stacked-bar, pie, waterfall etc.). I am trying to make Line chart with 4 measure with 2 dimension and Stacked-bar with 5 measure with one dimension. But in Line can see only two lines (but 4 measure title is showing) and three stacked-bar where I need 2 more. In UI5 is there any limit for these or can I work with 'N' number of measure and dimension?
Comment: Please post your code
Comment: I resolved it, its unlimited. I can able to generate 7 measures in a report
Answer: I resolved it, its unlimited. I can able to generate 7 measures in a report. My mistake was column assigning.


Equivalent Definition of Continuity

Question: I am trying to understand a proof in a book. (Willard, General Topology, p. 45)
Theorem: Let $X$ and $Y$ be topological spaces and $f : X \to Y$. If for each $E \subseteq X$, $f(\operatorname{Cl}_X(E)) \subseteq \operatorname{Cl}_Y f(E)$, then $f$ is continuous on $X$.
Proof: Let $x \in X$ and let $V$ be an open neighborhood of $f(x)$. Set $E = X - f^{-1}(V)$ and let $U = X - \operatorname{Cl}_X E$. It is easy to verify that, since $f(\operatorname{Cl}_X E) \subseteq \operatorname{Cl}_Y f(E)$, we have $x \in U$. It is even clearer that $f(U) \subseteq V$. Hence $f$ is continuous at $x$.
I have not been able to show that $x \in U$ and $f(U) \subseteq V$.
Scratch Work:
For the first part, if I suppose by way of contradiction that $x \notin U$, then $x \in \operatorname{Cl}_X E$ and by hypothesis $f(x) \in \operatorname{Cl}_Y f(E) = \bigcap\{K$ closed in $Y : f(E) \subseteq K\}$. But $f(E) \subseteq Y - V$ which is closed. So $f(x) \in Y - V$ which means $x \notin f^{-1}(V)$ which means $x \in E$. But then $x \notin f^{-1}(V)$, a contradiction since $f(x) \in V$. Is this correct? I am unable to get anywhere with the second part ($f(U) \subseteq V$.
Answer: You have shown that $x\in U$. That was the hard part. Now, to show that $f(U)\subseteq V$, consider any point $u\in U$; you have to show that $f(u)\in V$. The fact that $u\in U=X-\operatorname{Cl}_XE$ means that $u\notin\operatorname{Cl}_XE$. Since $E\subseteq\operatorname{Cl}_XE$, that also means that $u\notin E=X-f^{-1}(V)$, so $u\in f^{-1}(V)$, i.e., $f(u)\in V$.

Equivalent Definition of Continuity


how can I put write/read protection on the sd card?

Question: In linux, with Linux built in command, how can I put write/read protection on the sd card ? I will put, with command, protection such as user can not write something on the sd card because I have enabled the only read protection via command.
If you know without command, feel free to share
Answer: Anyway with software, you can do only it in a filesytem level. If some one format the pendrive, they will get the permission what ever they want to do on it. If there is something at hardware level for making a sdcard readonly, you will get what you asked here.


Sorting an array to get the maximum combined sum of the differences between every two adjacent elements

Question: This is related to this question: Stack Overflow
Problem description
We are given a sequence of n positive integers. How to sort the elements to get the maximum combined sum of the differences between every two adjacent elements.
For example, for a sequence {8, 4, 1, 2, 3} the starting difference is (8-4) + (4-1) + (2-1) + (3-2) = 9, but 14 can be reached for {4, 8, 1, 3, 2}.
The best arrangement is {4, 1, 8, 2, 3}, sum 17.
Claim
Optimal solution can always be reached by either starting with the smallest or largest element and then alternately putting currently largest/smallest elements on both sides of the sequence.
That's not all yet: for the starting sequence {1, 2, 3, 4} we would start with 4 $\longrightarrow$ 1 4 2 $\longrightarrow$ 3 1 4 2 or 1 4 2 3. So this approach is not strict enough yet.
However, if we always first put to the left and then to the right (or otherwise), we are guaranteed that the number on the left side will be smaller/bigger than the corresponding number on the right side.
I tested the solution above so I am quite sure it works.
I am interested how would you prove it.
Answer: You are correct:

When $n$ is even, the best arrangement has the highest and lowest in the middle, sandwiched between the second lowest and second highest, sandwiched between the third highest and third lowest, etc.

When $n$ is odd, the optimal arrangement either has the highest in the middle, sandwiched between the two lowest, then two remaining highest, etc, or it is the similar sequence where you start with the lowest in the middle.

The proof is easier when $n$ is even, so let's start there. Let the sequence of positive integers, sorted in increasing order, be $x_1\le x_2\le \dots\le x_n$. Then, for $i=1,\dots,n-1$, let $s_i=x_{i+1}-x_i$ be the sequence of gaps between the numbers. Finally, given a permutation $y_1,y_2,\dots,y_n$ of the given sequence, for $i=1,\dots,n-1$, let
$$
m_i=\#\{j:y_{j}\le x_{i}\text{ and } y_{j+1}\ge x_{i+1}\}+\#\{j:y_j\ge x_{i+1}\text{ and } y_{j+1}\le x_i \}
$$
In words, $m_i$ is the number of times the sequence $(y_1,\dots,y_n)$ crosses the "gap" between $x_i$ and $x_{i+1}$. Each time the sequence does this, it adds $s_i$ to the total of the absolute differences of the consecutive elements. Therefore, it follows that
$$
|y_2-y_1|+|y_3-y_2|+\dots+|y_n-y_{n-1}|=\sum_{i=1}^{n-1}m_is_i
$$
If this is unclear, I encourage you to look at some examples. You can then show two things:

For the proposed optimal sequence, we have$$
\begin{cases}
m_i=2i & \text{when $i<n/2$}\\
m_{n/2}=n-1\\
m_{n-i}=2i & \text{when $i<n/2$}\\
\end{cases}
$$

For any permutation, it is true that $$
\begin{cases}
m_i\le 2i & \text{when $i<n/2$}\\
m_{n/2}\le n-1\\
m_{n-i}\le 2i & \text{when $i<n/2$}\\
\end{cases}
$$

These two points imply that the proposed sequence is optimal.
The first bullet can be verified easily. For the second bullet, note that when $i<n/2$, that a crossing between $x_i$ and $x_{i+1}$ can only occur when one of the $i$ smallest values $x_1,\dots,x_i$ is next to one of the largest $n-i$ values. But this can obviously occur at most $2i$ times, to the left and right of each of the $i$ values $x_1,\dots,x_i$.  The same logic applies to $m_{n-i}$. Finally, $m_{n/2}\le n-1$ since there are only $n-1$ adjacent pairs.
I leave the case when $n$ is odd to you. In this case, you will find three things:

When $i<n/2$, $m_i<2i$ and $m_{n-i}<2i$ (same as before).

Furthermore, letting $k=\lfloor n/2\rfloor$, it is impossible to have both $m_k=2k$ and $m_{k+1}=2k$. At least of these must be smaller than their maximal value in any permutation.

The two proposed optimal arrangements achieve the maximal values implied by the two previous bullet points.
Answer: Let the given integers be $a_1,\dots,a_n$.  You can formulate the problem as a traveling salesman problem on a complete graph with $n+1$ nodes.  Besides one node for each array element, introduce a dummy node with $0$ cost to the other nodes.  Otherwise, the cost of edge $\{i,j\}$ is $-|a_i-a_j|$, and you want to find a tour of minimum cost.
If there is a counterexample to your conjectured optimal algorithm, this formulation could help you find one by solving the corresponding TSP to check optimality.


What is the benefit to reannealing during Simulated Annealing?

Question: I'm reading up on different ways to implement the Simulated Annealing algorithm. MathWorks's implementation for MatLab was the first time I had come across the concept of reannealing during simulated annealing. As I understand it based on that documentation, the simulation runs a number of times until ReannealInterval number of new values have been selected, at which point it triggers another function that determines a new initial temperature (higher than the current temperature) and then restarts the simulation using the new temperature and the current value. The reannealing loop continues until some criteria other than temperature <= 0 is met. I know that the current temperature plays a role in the probability of accepting a worse solution, but what is the benefit to doing this multiple times as opposed to configuring the initial simulation to run longer with a more slowly decaying temperature?
Answer: With a higher temperature, it's easier to make jumps into regions with significantly poorer solutions.  This can help you get out of local minima which are "deep" - you can do it in one or two steps, instead of having to chain together several smaller steps, which relies, writing intuitively, on the proposals being arranged just right as well as more luck required with the sequence of acceptance random number generators (due to having to make several acceptance "rolls" instead of just one or two.)
Reannealing allows the reset of the temperature to a higher level than it would be if you simply slowed down the decay.  Of course, there's little point if you're simply upping the temperature by a few percentage points when performing the reannealing!  But the faster decay rate + reannealing means you tend to get stuck in certain types of local minima less often, and you still have a reasonably good overall convergence rate.
There is no silver bullet, however, and reannealing is neither a dominant nor a dominated strategy.  Your mileage may vary!


C# WPF DataSource property not recognizing

Question: I am trying to build a very simple WPF Application using C# on .Net F/W 4.0. When i click a button, i wanted it to run a sql query(stored in "finalupdatedsql1" variable) against oracle database. I want the results on a Datagrid. For some reason Datagrid.DataSource property is not recognized. Could anyone help me with an alternate approach or correct my code? FYI, I am using ODP.Net and Oracle connection tests fine. Thanks.
private void RunSQL_Click(object sender, RoutedEventArgs e)
    {
        cmd = new OracleCommand(finalupdatedsql1, conn);//finalupdatedsql1 has the sqlquery in string representation.
        cmd.CommandType = CommandType.Text;
        da = new OracleDataAdapter(cmd);
        cb = new OracleCommandBuilder(da);
        ds = new DataSet();
        da.Fill(ds);
        MyDataGrid.DataSource = ds.Tables[0];//DataSource not showing up in intellisense or recognizing

        conn.Close();
        conn.Dispose();
    }

Comment: `MyDataGrid.DataSource` is for winforms `DatagridView` code
Answer: You're looking for ItemsSource:
MyDataGrid.ItemsSource = ds.Tables[0];

The DataSource property would be a Windows Forms application.
Comment: ds.Tables[0] gives an error. Changing it to (System.Collections.IEnumerable)ds.Tables[0] resolves it, but is it suggestable?


Missing a necessary power in this proof - please help.

Question: This question is somewhat related to Gradient Estimate - Question about Inequality vs. Equality sign in one part.
That question was related to part (c) of a problem I am working on, and this question is related to part (b).
Specifically, I need to show the following:

Let $u$ and $v$ be two functions on $\Omega$ related as follows:
  $$ |u(x)| \leq \int_{\Omega}K(x,y)|v(y)|dy, \quad x \in \Omega, $$
  for some kernel $K(x,y)$. Show that for any $1 \leq p \leq q \leq \infty$, we have
  $$ ||u||_{L^{q}(\Omega)}\leq A||v||_{L^{p}(\Omega)} $$
  where $A = \max \left( \sup_{x}||K(x,\cdot)||_{L^{\frac{pq}{pq+p-q}}(\Omega)},\sup_{y}||K(\cdot,y)||_{L^{\frac{pq}{pq+p-q}}(\Omega)} \right)$.

So, starting with $u$, $v$ on $\Omega$ satisfying $$|u(x)| \leq \int_{\Omega}K(x,y)|v(y)|dy \quad (*)$$
I have that $$(*) \leq \int_{\Omega} |K(x,y) |v(y)|| dy \\
= \int_{\Omega}|K(x,y)v(y)| dy \\
= \int_{\Omega}|K(x,y)^{\alpha+1-\alpha}v(y)|dy\\
\leq \int_{\Omega}|K(x,y)|^{\alpha}|K(x,y)|^{1-\alpha}|v(y)|dy \\
= \int_{\Omega} |K(x,y)|^{\alpha} |K(x,y)|^{1-\alpha}|v(y)|^{1-\beta + \beta} dy\\
\leq \int_{\Omega}|K(x,y)|^{\alpha}(|K(x,y)|^{1-\alpha}|v(y)|^{1-\beta})|v(y)|dy \quad (1)$$
Aplying Holder's Inequality to $(1)$, we get that
$$(1) \displaystyle \leq \left[ \int_{\Omega} |K(x,y)|^{\alpha a} dy\right]^{1/a} \cdot \left[ \int_{\Omega} |K(x,y)|^{(1-\alpha)c} |v(y)|^{(1-\beta)c}dy \right]^{1/c} \cdot \left[\int_{\Omega}|v(y)|^{\beta b}dy \right]^{1/b}, $$
where $\displaystyle 1 = \frac{1}{a} + \frac{1}{b} + \frac{1}{c}. \quad (1^{\prime})$
Since we want the $L^{p}$ norm of $v$ to appear in the RHS, choose $\beta b = p$.
Thus, $\displaystyle b = \frac{p}{\beta}. \quad (2)$
Also, let $(1-\beta)c = p$, which implies that $\displaystyle \beta = 1 - \frac{p}{c}$.
Raising (1) to the power of $q$ and taking the integral with respect to x, we obtain that
$$ \int |u(x)|^{q} dx \leq \int \left( \left[ \int|K(x,y)|^{\alpha a}dy \right]^{q/a}\left[ \int|K(x,y)|^{(1-\alpha)c}|v(y)|^{(1-\beta)c}dy\right]^{q/c}||v||_{L^{p}}^{\beta q}\right) dx. $$
Now, in order for us to be able to switch the order of integration, we need $\displaystyle \frac{q}{c} = 1$, so $q = c. \quad (4)$
Therefore, $(3)$ becomes $\displaystyle \beta = 1 - \frac{p}{q} \quad (3^{\prime})$,
and $(2)$ becomes $\displaystyle b = \frac{p}{\displaystyle \left( 1 - \frac{p}{q}\right)} = \frac{pq}{q-p} \quad (2^{\prime})$.
Substituting $(4)$ and $(2^{\prime})$ into $(1^{\prime})$, we obtain an expression for $a$:
$\displaystyle a = \frac{p}{p-1} \quad (5)$
Bounding everything, we obtain
$$||u||_{L^{q}}^{q} \leq \sup_{x}\left( \int|K(x,y)|^{\alpha a}dy\right)^{q/a} \cdot \left[\sup_{y}\int |K(x,y)|^{(1-\alpha)c}dx \right] ||v||_{L^{p}}^{p+\beta q}. \quad (6)$$
Notice also that $\displaystyle \frac{q}{a} = 1$, so
$$ (6) = \left[ \sup_{x}\int|K(x,y)^{\alpha a}dy\right] \cdot \left[ \sup_{y} \int |K(x,y)|^{(1-\alpha)c}dx \right] \cdot ||v||_{L^{p}}^{p+\beta q}. \quad (6^{\prime})$$
Now, we need $\sup_{x}$, $\sup_{y}$, and each of these kernels to be finite, so choose $\alpha$ so that $\alpha a = (1-\alpha)c$, which implies then that $\displaystyle \alpha = \frac{c}{a+c}$.
Then, substituting our values for $a$ and $c$ [$(5)$ and $(4)$], respectively, we obtain that
$\alpha = \frac{q}{\frac{p}{p-1}+q} = \frac{q(p-1)}{p+pq-q} \quad (7)$
and that
$(1-\alpha) = \frac{p}{p+pq-q}. \quad (7^{\prime})$
So, $\alpha a = \frac{pq}{p+pq-q}$, and $(1-\alpha)c = \frac{pq}{p+pq-q}. \quad (7^{\prime\prime})$
Thus, $(6^{\prime})$ becomes
$$ = \left[ \sup_{x}\int |K(x,y)|^{\frac{pq}{p+pq-q}}dy\right] \cdot \left[ \sup_{y} \int |K(x,y)|^{\frac{pq}{p+pq-q}}dx\right]||v||_{L^{p}}^{p+(1-\frac{p}{q})\cdot q}. \quad (8)$$
But, since $\displaystyle p + \left( 1-\frac{p}{q}\right)q = q$, $(8)$ becomes
$$ = \left[\sup_{x}\int|K(x,y)|^{\frac{pq}{p+pq-q}}dy\right]\left[ \sup_{y} \int |K(x,y)|^{\frac{pq}{p+pq-q}} dx \right] ||v||_{L^{p}}^{q}$$.
Which brings me to my question.
Taking $q$th roots, you see that we have the following:
$$ ||u||_{L^{q}(\Omega)} \leq \left[\sup_{x}\int|K(x,y)|^{\frac{pq}{p+pq-q}}dy\right]^{1/q}\left[\sup_{y}\int |K(x,y)|^{\frac{pq}{p+pq-q}}dx\right]^{1/q}||v||_{L^{p}}$$,
but what I need is:
$$ ||u||_{L^{q}(\Omega)} \leq \left[\sup_{x}\int|K(x,y)|^{\frac{pq}{p+pq-q}}dy\right]^{\frac{p+pq-q}{pq}}\left[\sup_{y}\int |K(x,y)|^{\frac{pq}{p+pq-q}}dx\right]^{\frac{p+pq-q}{pq}}||v||_{L^{p}}$$,
so that I will have the $||K(x,y)||_{L^{\frac{pq}{pq+p-q}}}$ norms on the RHS that I need.
So, what I am hoping someone will tell me is, where did I go wrong in "misplacing" these powers? How do I fix this so that I will get the correct norm in my final answer?
Thank you in advance! I really would appreciate your help!!
Comment: If you work it out, assuming that $\frac{1}{p}+\frac{1}{q} = 1$, we obtain that $\frac{p+pq-q}{pq} = \frac{2}{q}$. What I'm thinking is that since we need the kernel to be integrable, its absolute value needs to be <1.  So, if we take the sup of something that is <1, the sup is going to be 1, so then whether you have it raised to $\frac{1}{q}$ or $\frac{2}{q}$ doesn't matter.  But, this doesn't seem right...
Answer: Let's introduce a couple of notations for greater clarity. For any $r\in [1,\infty]$, we define
$$X_r := \sup_{x\in\Omega} \lVert K(x,\cdot)\rVert_r, \quad Y_r := \sup_{y\in\Omega} \lVert K(\cdot,y)\rVert_r, \quad A_r = \max \{ X_r,Y_r\},$$
and for brevity we write $\lVert\cdot\rVert_r$ instead of $\lVert\cdot\rVert_{L^r(\Omega)}$. The assertion is
$$\lVert u\rVert_q \leqslant A_r\lVert v\rVert_p\tag{$\ast$}$$
for all $1\leqslant p \leqslant q$, where
$$r = \begin{cases} \frac{pq}{pq+p-q} &, q < \infty\\ \quad 1 &, p=q=\infty\\ \;\;\frac{p}{p-1} &, 1 < p < q=\infty\\ \quad\infty &, 1 = p < q = \infty.\end{cases}$$
Let's first get the simple cases out of the way:

$p=q=\infty$: Then $r=1$ and we have, for every $x\in \Omega$, $$\lvert u(x)\rvert \leqslant \int \lvert K(x,y)\rvert\cdot\lvert v(y)\rvert\,dy \leqslant \int \lvert K(x,y)\rvert\,dy\cdot \lVert v\rVert_\infty \leqslant X_1\lVert v\rVert_\infty \leqslant A_1\lVert v\rVert_\infty,$$ and $(\ast)$ follows.
$p=1, q=\infty$: Then $r=\infty$ and, for every $x\in \Omega$, $$\lvert u(x)\rvert \leqslant \int \lvert K(x,y)\rvert\cdot\lvert v(y)\rvert\,dy \leqslant \lVert K(x,\cdot)\rVert_\infty \int \lvert v(y)\rvert\,dy \leqslant X_\infty \lVert v\rVert_1 \leqslant A_\infty\lVert v\rVert_1,$$ and again $(\ast)$ follows directly.
$1 < p < q = \infty$: Then $r = \frac{p}{p-1} = p'$ is the conjugate exponent of $p$, and $$\lvert u(x)\rvert \leqslant \int \lvert K(x,y)\rvert\cdot\lvert v(y)\rvert\,dy \leqslant \lVert K(x,\cdot)\rVert_r\cdot\lVert v\rVert_p \leqslant X_r\lVert v\rVert_p \leqslant A_r\lVert v\rVert_p.$$ Once more, $(\ast)$ follows directly.
$1 = p = q$: Then $r = 1$ too, and we can directly change the order of integration: $$\lVert u\rVert_1 \leqslant \int \left(\int \lvert K(x,y)\,dx\right)\lvert v(y)\rvert\,dy = \int \lVert K(\cdot,y)\rVert_1\lvert v(y)\rvert\,dy \leqslant Y_1\int\lvert v(y)\rvert\,dy \leqslant A_1\lVert v\rVert_1.$$
$1 = p < q < \infty$: Then $r = q$, and $$\lvert u(x)\rvert \leqslant \int\left(\lvert K(x,y)\rvert\cdot\lvert v(y)\rvert^{1/q}\right)\lvert v(y)\rvert^{1-1/q}\,dy \leqslant \left(\int \lvert K(x,y)\rvert^q\lvert v(y)\rvert\,dy\right)^{1/q}\lVert v\rVert_1^{1-1/q}.$$ Raising to the $q$-th power and integrating gives $$\lVert u\rVert_q^q \leqslant \int \underbrace{\lVert K(\cdot,y)\rVert_q^q}_{\leqslant Y_q^q}\lvert v(y)\rvert\,dy \leqslant A_q^q\lVert v\rVert_1^q,$$ and taking $q$-th roots yields $(\ast)$.
$1 < p = q < \infty$: Then $r = 1$ and $$\lvert u(x)\rvert \leqslant \int \lvert K(x,y)\rvert^{1-1/p}\left(\lvert K(x,y)\rvert^p\lvert v(y)\rvert\right)\,dy \leqslant \underbrace{\lVert K(x,\cdot)\rVert_1^{1-1/p}}_{\leqslant X_1^{1-1/p}}\left(\int \lvert K(x,y)\rvert\cdot\lvert v(y)\rvert^p\,dy\right)^{1/p}.$$ Raising to the $p$-th power and integrating, switching the order of integration, then gives $$\lVert u\rVert_p^p \leqslant X_1^{p-1}Y_1 \lVert v\rVert_p^p \leqslant A_1^p\lVert v\rVert_p^p,$$ and taking the $p$-th root gives $(\ast)$.

Now comes the harder case, $1 < p < q < \infty$. We start by splitting the integrand in three factors on the right hand side,
$$\begin{align}
\lvert u(x)\rvert &\leqslant \int \lvert K(x,y)\rvert^\alpha \left(\lvert K(x,y)\rvert^{1-\alpha}\lvert v(y)\rvert^{1-\beta}\right)\lvert v(y)\rvert^\beta\,dy\\
&\leqslant \lVert K(x,\cdot)\rVert_r^{\alpha/r}\left(\int \lvert K(x,y)\rvert^r\lvert v(y)\rvert^p\,dy\right)^{(1-\alpha)/r}\lVert v\rVert_p^{\beta}\\
&\leqslant X_r^\alpha \lVert v\rVert_p^\beta \left(\int \lvert K(x,y)\rvert^r\lvert v(y)\rvert^p\,dy\right)^{(1-\alpha)/r} \tag{1}
\end{align}$$
by Hölder's inequality for three factors, provided we have
$$\frac{\alpha}{r} + \frac{1-\alpha}{r} + \frac{\beta}{p} = 1 \quad\text{and}\quad \frac{1-\alpha}{r} = \frac{1-\beta}{p}.$$
The second of these conditions achieves the integrand $\lvert K(x,y)\rvert^r\cdot\lvert v(y)\rvert^p$ in the remaining integral. Determining $\alpha$ and $\beta$ from these conditions yields
$$\alpha = r\left(1-\frac{1}{p}\right),\qquad \beta = p\left(1-\frac{1}{r}\right),$$
and we verify
$$\frac{1-\alpha}{r} = \frac{1}{r} - \left(1-\frac{1}{p}\right) = \frac{1}{r}+\frac{1}{p}-1 = \frac{1}{p}-\left(1-\frac{1}{r}\right) = \frac{1-\beta}{p},$$
and
$$\frac{\alpha}{r} + \frac{1-\alpha}{r} + \frac{\beta}{p} = \frac{1}{r} + \frac{\beta}{p} = \frac{1}{r} + \left(1 - \frac{1}{r}\right) = 1.$$
Also
$$\frac{1-\alpha}{r} = \frac{1}{r} + \frac{1}{p} - 1 = \frac{pq+p-1}{pq} + \frac{q}{pq} - \frac{pq}{pq} = \frac{p}{pq} = \frac{1}{q},$$
so raising $(1)$ to the $q$-th power and integrating gives
$$\begin{align}
\lVert u\rVert_q^q &\leqslant X_r^{q\alpha} \lVert v\rVert_p^{q\beta} \int \underbrace{\left(\int \lvert K(x,y)\rvert^r\,dx\right)}_{\leqslant Y_r^r} \lvert v(y)\rvert^p\,dy\\
&\leqslant X_r^{q\alpha} Y_r^r \lVert v\rVert_p^{q\beta+p}\\
&\leqslant A_r^{q\alpha+r}\lVert v\rVert_p^{q\beta+p}. \tag{2}
\end{align}$$
Now
$$\begin{gather}
q\alpha + r = qr\left(1-\frac{1}{p}\right)+r = r\left(q+1 - \frac{q}{p}\right) = \frac{pq}{pq+p-q}\frac{pq+p-q}{p} = q,\\
q\beta + p = qp\left(1-\frac{1}{r}\right) + p = pq + p - \frac{pq}{r} = pq+p - (pq+p-q) = q,
\end{gather}$$
so taking $q$-th roots in $(2)$ yields $(\ast)$.

So, where was your mistake? The splitting of the integrand into three factors is the same, your conditions are

$\frac{1}{a}+\frac{1}{b}+\frac{1}{c} = 1$,
$b\beta = p$
$a\alpha = r$
$(1-\alpha)c = r$
$(1-\beta)c = p$
$c = q$

and these are exactly correct. Your mistake is

Notice also that $\dfrac{q}{a}=1$,

that is in general not the case. But when it is the case, your
$$||u||_{L^{q}(\Omega)} \leq \underbrace{\left[\sup_{x}\int|K(x,y)|^{\frac{pq}{p+pq-q}}dy\right]^{1/q}}_{X_r^{r/q}}\underbrace{\left[\sup_{y}\int |K(x,y)|^{\frac{pq}{p+pq-q}}dx\right]^{1/q}}_{Y_r^{r/q}}||v||_{L^{p}}$$
happens to give you what you need, since then $pq = p+q$ and hence
$$r = \frac{pq}{pq+p-q} = \frac{pq}{(p+q)+p-q} = \frac{pq}{2p} = \frac{q}{2},$$
so
$$X_r^{r/q} Y_r^{r/q} = X_r^{1/2}Y_r^{1/2} \leqslant A_r^{1/2}A_r^{1/2} = A_r.$$
Comment: In the other cases, you have $\alpha \in \{0,1\}$ or $\beta \in \{0,1\}$, which requires a bit of care to handle. One can do that, but I found it simpler to avoid it first.
Comment: Doesn't the argument you used for the $1<p<q<\infty$ case apply to all the possibilities for r? Once you have the formula in terms of $r=\frac{pq}{pq+p-q}$, can't you then go back and plug in what $p$ and $q$ are in all the different cases to get the desired results in each case? I.e., isn't that case general enough to cover them all?


Como eu posso verificar se a ultima posição do array foi preenchida?

Question: Como eu posso verificar se a ultima posição do array foi preenchida?
Tentei a função array_pop mas parece que ela corta o elemento do array, eu quero apenas verificar se na última posição do array existe alguma coisa...
Comment: Sua dúvida é sobre  Java, php, mysql, asp ou php? Considere editar sua pergunta, pois ela é um chamativo para votos negativos, visto que não está apresentada de forma clara. (observação: não fui eu quem negativei)
Comment: existe alguma coisa? Seria verificar se o valor não null, false ou 0? Porque se for "existir", você teria que saber qual a posição exata, poderia mostrar o que já fez?
Comment: Desculpe, já alterei, é em PHP
Comment: Vou dar um +1, pois essa é uma dúvida que as vezes o pessoal que tá começando costuma ter.
Answer: Pode usar a função end() para pegar o último elemento do array e verificar se ele tem valor ou não.
$arr = [1,2,3, null];

$ultimo = end($arr);

if($ultimo){
    echo 'tem valor: '. $ultimo;
}else{
    echo 'é vazio';
}

Comment: @WallaceMaxters quase um minuto de diferença :P ta comendo poeira.
Comment: aff, foi mais rápido
Comment: era exatamente o que eu queria, muito obrigado galera
Comment: @ViniciusAquino você pode marcar uma das respostas como útil se resolveu o problema. Sugiro marcar essa do rray, já que ele respondeu primeiro :D
Answer: Eu faria assim:
$array = [1, 2, 3];

$end = end($array);

if ($end) {
    echo "A última posição é {$end}";
}

Observação: A função end só funciona com arrays armazenados em variáveis, já que a mesma espera uma parâmetro passado por referência.
Se tiver problemas com isso, a forma que eu costumo resolver isso é criando uma função que serve como um "wrapper" para poder driblar esse "problema" no PHP:
function last(array $array) {
   return end($array);
}

last([1, 2, 3, 4, 5]); // int(5)

Comment: obrigado, era exatamente oq eu queria
Answer: Uma outra alternativa é obter o valor por índice, usando o count para obter o total de elementos e subtrair por 1:
$array = ['foo', 'bar', 'baz'];

if (($indice = count($array)) > 0) { // Se for um índice válido
    $ultimoValor = $array[$indice - 1];

    echo $ultimoValor;
}

Comment: O problema desse código aí é que se o `count` retornar `0`, o `-1` vai gerar um "undefined index". Além do mais, o `array` pode não ser numérico (como uma lista do `Python`), o que vai gerar mais dores de cabeça. É claro, seu exemplo vai dar certo pois o `array` foi declarado como numérico. Mas talvez, por segurança, fosse necessário usar `array_values` para resetar com um `isset`.
Comment: Isso aí funciona :D +1
Comment: @WallaceMaxters Valeu. :) Já arrumei o código, veja se está melhor agora.


want url validation regex

Question: when i put https://gmail.com in url validation it will through below exception
<code>(Exp:Sorry! You cannot include the intended website in Web Tab, as the
intended website restricts its content from loading inside another
website.)
</code>
i want that url validate regex
Comment: Were do you get this exception? what are things you tried?? Is it really javascript..
Comment: i used this regex(regex: ^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/|www\.)[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$) but it will allowed https://gmail.com but i need to don't allow https://gmail.com
Comment: Hold on a second; gmail.com is a perfectly valid URI. You may want to do a separate blacklist check after the URI check (to disallow specific URIs)
Comment: if(/https\:\/\/gmail\.com/.test(url)){throw new Error("\(Exp\:Sorry! You cannot include the intended website in Web Tab, as the intended website restricts its content from loading inside another website.\)");}
Answer: Please see this gist for a pretty strong regex with explainatory comments https://gist.github.com/dperini/729294
EDIT:
You can customize it by removing the strings you don't want.

want url validation regex