text stringlengths 49 10.4k | source dict |
|---|---|
python, unit-testing, matrix, computational-geometry
def InvTransformNode(self, node):
"""
This function returns coordinates of node, thah is transformed
from general coordinate system of given 2D triangle to refere-
nce coordinate system.
Args:
* node - geometrical node with coordinates in general system
Returns:
* node with transformed coordinates to reference coordinate
system
"""
return Node(
self.invB11 * (node.X - self.A.X)
+ self.invB12 * (node.Y - self.A.Y),
self.invB21 * (node.X - self.A.X)
+ self.invB22 * (node.Y - self.A.Y)
)
# unittests for transformation object
class TransformationTest(unittest.TestCase):
def test_NodeTransformation(self):
"""
Checking if node D is transformed to reference system and back
correctly
"""
# triangle nodes
A = Node(1,1)
B = Node(3,1)
C = Node(4,2)
# transformed node
D = Node(2,3)
T = Triangle(A,B,C)
Trans = Transformation(T)
# retransformed node D
resD = Trans.TransformNode(Trans.InvTransformNode(D))
# compare result coordinates
self.assertEquals(resD.X, D.X)
self.assertEquals(resD.Y, D.Y)
# ============================== testing ============================= #
# Test Triangle object
suite1 = unittest.TestLoader().loadTestsFromTestCase(TriangleTest)
unittest.TextTestRunner(verbosity=3).run(suite1)
# Test Transformation object
suite2 = unittest.TestLoader().loadTestsFromTestCase(TransformationTest)
unittest.TextTestRunner(verbosity=3).run(suite2) Here are a few of the high- and low-level ideas: | {
"domain": "codereview.stackexchange",
"id": 28458,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, unit-testing, matrix, computational-geometry",
"url": null
} |
(1) The product of any three integers in the set is negative. If the set consists of only 3 terms, then the set could be either {negative, negative, negative} or {negative, positive, positive}. If the set consists of more than 3 terms, then the set can only have negative numbers. Not sufficient.
(2) The product of the smallest and largest integers in the set is a prime number. Since only positive numbers can be primes, then the smallest and largest integers in the set must be of the same sign. Thus the set consists of only negative or only positive integers. Not sufficient.
(1)+(2) Since the second statement rules out {negative, positive, positive} case which we had from (1), then we have that the set must have only negative integers. Sufficient.
_________________
Math Expert
Joined: 02 Sep 2009
Posts: 29802
Followers: 4904
Kudos [?]: 53647 [5] , given: 8167
Re: New Set: Number Properties!!! [#permalink] 29 Mar 2013, 04:25
5
KUDOS
Expert's post
6
This post was
BOOKMARKED
7. Is x the square of an integer?
The question basically asks whether x is a perfect square (a perfect square, is an integer that is the square of an integer. For example 16=4^2, is a perfect square).
Perfect square always has even powers of its prime factors. The reverse is also true: if a number has even powers of its prime factors then it's a perfect square. For example: $$36=2^2*3^2$$, powers of prime factors 2 and 3 are even.
(1) When x is divided by 12 the remainder is 6. Given that $$x=12q+6=6(2q+1)=2*3*(2q+1)$$. Now, since 2q+1 is an odd number then the power of 2 in x will be odd (1), thus x cannot be a perfect square. Sufficient. | {
"domain": "gmatclub.com",
"id": null,
"lm_label": "1. Yes\n2. Yes",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9385759565090548,
"lm_q1q2_score": 0.815459932111983,
"lm_q2_score": 0.8688267864276107,
"openwebmath_perplexity": 1195.4935970415402,
"openwebmath_score": 0.7336602807044983,
"tags": null,
"url": "http://gmatclub.com/forum/new-set-number-properties-149775-60.html"
} |
electrostatics, boundary-conditions
By the way, did you notice that each $G_\ell$ coefficient contributes only to the term in the potential that contains $P_\ell$? This is not an accident. It follows from the fact that the differential operator $\nabla^2$ can be separated into a radial part and an angular part, and the angular part, up to scaling, is just $L^2$. And the spherical harmonics are just simultaneous eigenfunctions of $L^2$ and $L_z$, so $\nabla^2$ can only map each spherical harmonic to the same spherical harmonic, with some scaling depending on the radial coordinate and the value of $\ell$.
For example, when a spherical shell's charge distribution is of the form $\cos\theta$, then the potential produced by that shell can only have angular dependence of the form $\cos\theta$ (but obviously still depends on the radial coordinate).
Using this fact, we can derive the general solution above (i.e. for arbitrary $\sigma(\theta)$) much more easily. The idea is that the charge distribution that is induced on the conducting sphere must be such that, for all points in the sphere's interior, every component of the interior multipole moment that is produced by the point charge outside the sphere is completely cancelled by the corresponding interior multipole moment that develops on the surface of the sphere. (The sole exception is, of course, the (0, 0) component that is proportional to the total charge; a neutral conducting sphere cannot screen this out.) This lets us solve for the charge distribution that is induced on the conducting sphere, as an expansion in spherical harmonics, where each coefficient only depends on the corresponding coefficient of the spherical harmonic expansion for $\sigma$. Finally, at each radial coordinate of interest, we can write the potential as an expansion of spherical harmonics, where the coefficient of each term depends only on the coefficients of the same spherical harmonic in $\sigma$ and in the induced charge.
This approach also lets us handle $\varphi$-dependent charge distributions in with only a minimum of additional pain, whereas the explicit separation of variables approach becomes extremely painful when $\varphi$-dependent potentials must be computed. | {
"domain": "physics.stackexchange",
"id": 95742,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "electrostatics, boundary-conditions",
"url": null
} |
python, beginner, game, functional-programming, adventure-game
winter = '\n' + '''29 January 2029. It is five weeks into winter and the season shows no mercy. A drought happened for a majority of the last fall and it devastated
the food supply. As your community dives deeper into the winter, you realize that your supply will run out if consumption is not altered. You could do one of two options: reduce
consumption among civilians, or ignore the risk and take a chance([ALTER SUPPLY]X} {B[IGNORE RISK]).''' + '\n> '
alter_supply = '\n' + '''Your government is now seen as selfish. You took the risk to protect the important people and "do your best with the rest". You have suffered heavy
civilian losses but your army and government losses have been few. As a result, there is division and danger in the streets. Riots breaking out, murders, arson, all happening in
your community.''' + civil_great_decrease
ignore_risk = '\n' + '''Your community did better than expected during the period. That is until you ran out of food in early March. Now you rely solely on scavenging,
risking getting devoured by zombies in order to go another day. Half your community is either dead or lost with great amount of casualties from civilians and
non-civilians.''' + army_great_decrease | {
"domain": "codereview.stackexchange",
"id": 34976,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, beginner, game, functional-programming, adventure-game",
"url": null
} |
c#, performance, memory-management
Thread.Sleep(500);
}
GC.CancelFullGCNotification();
Console.WriteLine("Finished monitoring GC");
});
var doWork = new Action(() =>
{
while (!done)
{
try
{
load.Add(new byte[10000]);
}
catch (OutOfMemoryException)
{
Console.WriteLine("Out of memory. {0}", load.Count);
}
}
});
Console.WriteLine(GCSettings.IsServerGC);
Task.Run(pollGC);
Task.Run(doWork);
Console.ReadLine();
done = true;
GC.CancelFullGCNotification();
Thread.Sleep(2000);
}
} Your design won't work. You're starting a timer using GC.WaitForFullGCApproach. But this method only indicates that a Full GC is imminent (not starting). It actually allows you some time to prepare for it and force a GC yourself using GC.Collect. Your numbers won't be accurate.
Why not try using the memory performance counters?
Alternatively you could do this:
while (!done)
{
if (GC.WaitForFullGCApproach() == GCNotificationStatus.Succeeded)
{
//TODO - Do GC preparation here if need be
Console.WriteLine("Full GC is imminent. Starting a GC manually.");
load.Clear();
gcTimer.Restart();
GC.Collect();
gcTimer.Stop();
Console.WriteLine("GC has finished in {0} ms", gcTimer.ElapsedMilliseconds);
GC.WaitForFullGCComplete();
}
} | {
"domain": "codereview.stackexchange",
"id": 35971,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c#, performance, memory-management",
"url": null
} |
ros
Title: What are robotics base on ROS?
Please give sample , thanks !
Originally posted by roschina on ROS Answers with karma: 3 on 2014-12-20
Post score: 0
You can fins here Robots Using ROS
Originally posted by bvbdort with karma: 3034 on 2014-12-20
This answer was ACCEPTED on the original site
Post score: 1 | {
"domain": "robotics.stackexchange",
"id": 20396,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros",
"url": null
} |
c++, programming-challenge
Title: Project Euler #5 - Smallest multiple using Factor Table This is a problem from Project Euler and on Hackerrank (here)-
2520 is the smallest number that can be divided by each of the numbers
from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible
(divisible with no remainder) by all of the numbers from 1 to N?
Input Format First line contains that denotes the number of test cases. This is followed by lines, each containing an integer, .
Output Format Print the required answer for each test case.
Constraints
1 <= T <= 10
1 <= N <= 40
Sample Input
2
3
10
Sample Output
6
2520
Here is the code I wrote. My approach was to first create a table of prime factors and use them to generate a number that is divisible by all numbers below N. Is there a better approach? Is there something that I am doing here that is very sub-optimal?
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std; | {
"domain": "codereview.stackexchange",
"id": 20933,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, programming-challenge",
"url": null
} |
optics, visible-light, electric-fields, reflection, refraction
Title: Brewster's angle reflected wave- is it part of the refracted or incident ray? I am trying to figure out what is happening to the charged particles in the reflective surface in the case of Brewster's angle. When this angle is different than zero or Brewster's angle, then the reflected light is only "partially" polarised. Why is the oscillation of the particles such that the reflected wave is polarized parallel to the reflecting surface when the angle is Brewster's angle?
I understand the explanation behind separating the electric fields into their components, yet I don't understand what causes this polarization to be observed? How does the vector component of the electric field emerge from the reflective surface while the other component remains as a part of the refracted wave?
By "parallel" I mean oscillating to the left and right- represented by dots (not into the page) in the diagram below. There are two planes I have talked about, the first one being the plane of the page(plane of incidence) and the plane perpendicular (the plane parallel to the reflecting surface, which is also the plane of polarization) An unpolarized wave can be represented by the sum of two waves with perpendicular polarisations and equal amplitude. The unpolarised incident wave can be considered to be of this nature, with one polarisation in the plane of incidence (p-polarised) and another at right angles to that (s-polarised), and with the electric fields of both being perpendicular to the direction of incident wave motion.
When the electric field of the incident wave is incident upon the interface, it sets up an electric field in the medium. Because of the continuity conditions for the electric field (any components tangential to the surface are continuous) and the requirement for a fixed phase relationship between the incident, reflected and transmitted waves, we obtain the law of reflection and Snell's law of refraction. | {
"domain": "physics.stackexchange",
"id": 74513,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "optics, visible-light, electric-fields, reflection, refraction",
"url": null
} |
homework-and-exercises, electromagnetism, lagrangian-formalism, maxwell-equations, variational-calculus
respectively.
The second problem is that I don't know how to calculate these variations clearly. Working from the original (obviously scalar) Langrangian
You started with this term $$-{\frac {1}{4\mu _{0}}}F_{\mu \nu }F_{\rho \sigma }\eta ^{\mu \rho }\eta ^{\nu \sigma }$$
Which reduces to
$$=-{\frac {1}{4\mu _{0}}}F_{\mu \nu }F^{\mu \nu }$$
You need to take account of the fact that the E and B fields can be written in terms of the Faraday tensor $${\displaystyle F_{\mu \nu }}$$ We define this tensor as:
$${\displaystyle F_{\mu \nu }=\partial _{\mu }A_{\nu }-\partial _{\nu }A_{\mu }}$$
Which in turn reduces the above to:
$$={\displaystyle {\epsilon _{0} \over 2}{E}^{2}-{1 \over {2\mu _{0}}}{B}^{2}}$$
The derivation of the two inhomogeneous Maxwell equations also derives from
$${\displaystyle \partial _{\mu }F^{\mu \nu }=\mu _{0}J^{\nu }}$$
Now you can write Gauss's law and Ampère's law using the following replacements :
$${\displaystyle {\begin{aligned}{\frac {1}{c}}E^{i}&=-F^{0i}\\\epsilon ^{ijk}B_{k}&=-F^{ij}\end{aligned}}}$$
where i, j, k range through 1, 2, and 3 | {
"domain": "physics.stackexchange",
"id": 33833,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "homework-and-exercises, electromagnetism, lagrangian-formalism, maxwell-equations, variational-calculus",
"url": null
} |
Reference:
Derivation of equation and solution
Last edited: Sep 23, 2012
2. Sep 23, 2012
### CAF123
This is the method of partial fractions to reduce $$\int \frac{1}{x^3 -27} dx$$ into something which can be integrated.
To find A,B and C you will need to solve simultaneous equations. To easily solve for A, let x =3 and you should get the required A = 1/27. To find B and C, let x = 0 to get one eqn in B and C and let x = 1 to get another. Two eqns, two unknowns (B and C) - you can solve this. The choice of x here is arbritary (except x =3 since the (Bx +C) term will vanish).
Last edited: Sep 23, 2012
3. Sep 23, 2012
### HallsofIvy
Staff Emeritus
Actually, because the last term in involved "Bx- C", and you have already found A, setting x= 0 will give an equation in C only.
4. Sep 23, 2012
### CAF123
Yes, I overlooked this. If you have something like $$\frac{A}{x} + \frac{(Bx +c)}{x^2 +bx +c},$$ then you will probably have to use simultaneous eqns.
5. Sep 23, 2012
### Orion1
Solving the coefficients:
Given:
$$1 = A(x^2 + 3x + 9) + (Bx + C)(x - 3)$$ | {
"domain": "physicsforums.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9845754501811438,
"lm_q1q2_score": 0.8482493721489617,
"lm_q2_score": 0.861538211208597,
"openwebmath_perplexity": 915.2325799888724,
"openwebmath_score": 0.783259928226471,
"tags": null,
"url": "https://www.physicsforums.com/threads/what-is-the-name-of-this-method.638135/"
} |
organic-chemistry, nomenclature, ions, terminology
Title: Difference Between Betaine & Zwitterion? what is difference btw Betaine & Zwitterion, Both having positive and negative charge in a molecule.
How to categorize Zwitterion and Betaine? or both are same. From Wikipedia:
A betaine (BEET-ah-een, /ˈbiːtɑːˌiːn/) in chemistry is any neutral chemical compound with a positively charged cationic functional group [...] which bears no hydrogen atom [...]. A betaine thus may be a specific type of zwitterion. | {
"domain": "chemistry.stackexchange",
"id": 6325,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "organic-chemistry, nomenclature, ions, terminology",
"url": null
} |
thermodynamics, water, phase-transition, phase-diagram
Title: Vaporization - phase diagram I understand what boiling and vaporization is. But what puzzles me is the phase diagram.
When I spill a glass of water in my room, it will soon vaporize, though there was normal atmospheric pressure and 20 °C. If you look in phase diagram of water, it should be still liquid at this point.
I understand that molecules of water escape the surface and turn into vapor, but... is the phase diagram of water wrong then? The temperature and pressure didn't change around that spilled water and still it turns into gas, although (looking at the phase diagram), it should be liquid. The phase diagram has equilibrium states for pure water, vapor, and both at saturation. You have water exposed to atmospheric gases, so the pressure is not that of pure vapor. The water will evaporate trying to create a partial pressure of vapor equal to the vapor pressure for saturated water at the water temperature. If the surface is open to flow of fresh air, this vapor pressure is not achieved, and the water slowly evaporates away. | {
"domain": "physics.stackexchange",
"id": 87266,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "thermodynamics, water, phase-transition, phase-diagram",
"url": null
} |
Maximal ideals of unital commutative $C^*$-algebra?
Define an ideal of a unital commutative $C^*$-algebra $A$ to be a proper subspace $I$ of $A$ such that $xy,yx\in I$ for all $x\in I$ and $y\in A$. Show that if $\lambda\in \widehat{A}$ (the space of all characters, a character is a unital $C^*$-algebra homomorphism from $A$ to $\mathbb{C}$), then the kernel $\lambda^{-1}(0)$ is a maximal ideal of $A$; conversely, if $I$ is a maximal ideal in $A$, show that $I$ is closed, and there is exactly one $\lambda\in \widehat{A}$ such that $I=\lambda^{-1}(A)$.
Let $\lambda\in\widehat{A}$ be a character, $\lambda^{-1}(0)$ is a proper subspace can be checked directly (note that $\lambda(1)=1)$), and it is also closed under the multiplication of $A$, thus an ideal of $A$. To show it is a maximal, it suffices to show that the ideal generated by $\lambda^{-1}(0)$ and $x\notin \lambda^{-1}(0)$ is $A$. Since an ideal is closed under scalar multiplicatoin, we may assume that $\lambda(x)=1$. Let $y\in A$, if we then take $c=\lambda(y)$, then $\lambda(y-cx)=0$, thus $y-cx\in\lambda^{-1}(0)$, thus $y$ is in the ideal generated by $x$ and $\lambda^{-1}(0)$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9777138177076645,
"lm_q1q2_score": 0.8016210457204852,
"lm_q2_score": 0.8198933381139645,
"openwebmath_perplexity": 90.96927252464741,
"openwebmath_score": 0.9731909036636353,
"tags": null,
"url": "https://math.stackexchange.com/questions/1611923/maximal-ideals-of-unital-commutative-c-algebra"
} |
newtonian-mechanics, velocity, aerodynamics
Title: Aircraft nose-up glide In the pilot's introductory book "Stick and Rudder" it claims that a nose-up glide is possible. It doesn't state how, why or when. It implies it's possible to do and maintain a constant forward velocity.
Is this possible? I really don't see how, unless the aircraft has what I assume would be an extremely unusual design, where the wings would have to have a reverse angle of incidence of the common designs.
Glancing through clancy's Aerodynamics, it seems that the force of lift acts upward, and slighly behind the normal of the chord. Given a glide has no thrust, I can't see how the net forces could balance with the drag to maintain forward velocity if the nose is up.
Thanks The essence of a glide is that the aircraft is descending.
Just like a car rolling down a moderate grade, it is trading potential energy to replenish the kinetic energy lost to drag.
Whether the nose points up or down only relates to the angle of attack, which only relates to speed.
An aircraft traveling at slow speed has a higher angle of attack, so its nose will point up, compared to when it is traveling at high speed.
One of the things you learn in flight training is how to handle a loss of power.
There's a mnemonic for that: ABC
A: Trim for the Airspeed (65 kts in a C172) that gives you the best glide range. This is fairly slow and nose-high. (There is even a somewhat slower speed that gives you less range but more time aloft.)
B: Look for the Best landing site, be it a field, road, or if you're lucky, an airport.
C: Look in the Cockpit for what you can do, like trying to restart the engine, and Calling on the radio.
So, under A, you can see that a slow glide is relatively nose-up, even while the aircraft is descending. | {
"domain": "physics.stackexchange",
"id": 81600,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "newtonian-mechanics, velocity, aerodynamics",
"url": null
} |
algorithms, randomized-algorithms, quicksort
While the pivot picking code here is clearly $\cal{O}(1)$, it would seem that the hidden $c$ here is relatively high. Take a look at McIllroy and Douglas' "A Killer Adversary for Quicksort" (Software -- Practice and Experience 29(4): 341-344 (1999)) or Crosby and Wallach's "Denial of Service via Algorithmic Complexity Attacks" for the reason behind randomizing. Quicksort behaves very badly if you pick (nearly) the largest/smallest as pivot each time. For randomization to make sense, it has to be random (if I know how you pick pivots deterministically, I can cook up an array that forces you to go into $O(n^2)$ behaviour, see the paper mentioned for details). But a fancy RNG is costlier than, say, taking 3 or another smallish odd number of elements, and pick the median of those as pivot, which is another way to counteract bad behaviour. So if you choose randomization, use a fast RNG seeded appropiately (probably a linear congruential scheme will be enough).
Algorithms can (and should) be compared by $O(\cdot)$, but if you are talking about different implementations of the same algorithm one must switch to more detailed analysis. In fact, Sedgewick and Flajolet in "An introduction to the analysis of algorithms" argue that one shouldn't use $T(n) = O(f(n))$ at all, but should strive to get $T(n) \sim f(n)$ type asymptotics. | {
"domain": "cs.stackexchange",
"id": 1315,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "algorithms, randomized-algorithms, quicksort",
"url": null
} |
electromagnetism, optics, laser, polarization, calculus
The polarizer Mueller matrix is that of an ideal linear dichroism optical element. It is widely used to model ideal linear polarizer optical elements, as per Shurcliff, Kliger et al., and Jensen et al. As a convenience, two addendum figures, after the references, explicitly show the matrices used by the listed authors.
Note that the software polarizer block, that evaluates the polarizer’s Mueller matrix, allows for user-specification of the x and y transmittances. It also has a convenience checkbox that can be used to render the block transparent, i.e, the block then would simply transmit through whatever input it received. This facilitates trial removal of inline optical components.
Figure 3 shows how the laser light source is modeled as a unit intensity unpolarized Stokes vector followed by a non-ideal x-oriented linear polarizer having extinction ratio, $\epsilon$, defined as shown in the figure. This definition, which will be used throughout what follows, has long been in common usage and is found in, e.g., the reference by Kliger et al. on page 30. Note that $\epsilon$ ranges from 0, for an ideal polarizer, to 1, for non-polarizing. In the laser model, the non-ideal x polarizer was used to produce an output Stokes vector with $\epsilon = 0.01$, as explained below. The remaining blocks simply verify that the $\epsilon$ value is as specified. This is done by processing the laser output Stokes vector through orthogonal ideal analyzers and calculating the quotient of the light intensities they transmit.
It is also common to define $\epsilon$ as the reciprocal quantity, as per the link proved by the OP. Accordingly, such extinction ratios range from 1, for non-polarizing, to infinity, for an ideal polarizer. This alternative definition will not be used herein.
The figure shows how the model of the laser is formulated and processed via optical calculus modeling software. The output of the laser is shown in the software’s Stokes vector sink dialog box. The exact Stokes vector of the laser output is shown to the left of the dialog box. It is easily calculated manually, as shown in the Mueller calculus expressions in figure 4: | {
"domain": "physics.stackexchange",
"id": 96934,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "electromagnetism, optics, laser, polarization, calculus",
"url": null
} |
computability, turing-machines, context-free, ambiguity
\end{align}$$
(where $\sigma_i$ are new characters added to the alphabet, e.g., $\sigma_i = \underline{i}$).
If the grammar is ambiguous, then there is a derivation of some string $w$ in two different ways. Supposing, wlog, that the derivations both start with the rule $S\rightarrow S_1$, reading the new characters backwards until they end makes sure there can only be one derivation, so that's not possible. Hence, we see that the only ambiguity can come from one $S_1$ and one $S_2$ 'start'. But then, taking the substring of $w$ up to the beginning of the new characters, we have a solution to the PCP (since the strings of indices used after those points match).
Similarly, if there is no ambiguity, then the PCP cannot be solved, since a solution would imply an ambiguity that just follows $S\Rightarrow S_1\Rightarrow^* \alpha\tilde{\sigma}$ and $S\Rightarrow S_2\Rightarrow^* \beta\tilde{\sigma}$, where $\alpha = \beta$ are strings of matching $\alpha$'s and $\beta$'s (since the $\tilde{\sigma}$'s match).
Hence, we've reduced from PCP, and since that's undecidable, we're done.
(Let me know if I've done anything boneheaded!) | {
"domain": "cstheory.stackexchange",
"id": 5724,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "computability, turing-machines, context-free, ambiguity",
"url": null
} |
java, beginner, swing, layout
//Point variables
//Values and conversions from string to big integer
String stringDamageOutput = "0";
String stringEPoints = "0";
String stringNewEPoints = "0";
String stringSpentEPoints = "0";
int intTotalClicks = 0;
BigInteger biDamageOutput = new BigInteger(stringDamageOutput);
BigInteger biEPoints = new BigInteger(stringEPoints);
BigInteger biNewEPoints = new BigInteger(stringNewEPoints);
BigInteger biSpentEPoints = new BigInteger(stringSpentEPoints);
//Unit variables
//Values and conversions from string to big integer
String stringUnit1 = "0";
String stringUnit2 = "0";
String stringUnit3 = "0";
String stringUnit4 = "0";
String stringUnit5 = "0";
BigInteger biUnit1 = new BigInteger(stringUnit1);
BigInteger biUnit2 = new BigInteger(stringUnit2);
BigInteger biUnit3 = new BigInteger(stringUnit3);
BigInteger biUnit4 = new BigInteger(stringUnit4);
BigInteger biUnit5 = new BigInteger(stringUnit5);
public static void main(String[] args) {
new Take1();
}
public Take1() {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { | {
"domain": "codereview.stackexchange",
"id": 19683,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "java, beginner, swing, layout",
"url": null
} |
### Excel NORM.S.DIST Function
Его любимым развлечением было подключаться к ее компьютеру, якобы для того, чтобы проверить совместимость оборудования. Сьюзан это выводило из себя, однако она была слишком самолюбива, чтобы пожаловаться на него Стратмору. Проще было его игнорировать. Хейл подошел к буфету, с грохотом открыл решетчатую дверцу, достал из холодильника пластиковую упаковку тофу, соевого творога, и сунул в рот несколько кусочков белой студенистой массы. Затем облокотился о плиту, поправил широкие серые брюки и крахмальную рубашку. | {
"domain": "knutsfordlitfest.org",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9780517469248846,
"lm_q1q2_score": 0.8192356644327523,
"lm_q2_score": 0.837619959279793,
"openwebmath_perplexity": 1673.6827512704958,
"openwebmath_score": 0.8065864443778992,
"tags": null,
"url": "https://knutsfordlitfest.org/and-pdf/367-normal-distribution-and-standard-deviation-pdf-454-704.php"
} |
#### anemone
##### MHB POTW Director
Staff member
Notice that the given sum can be written as:
$$\sum_{r=1}^{\infty} \frac{1}{(r+2)^2+r}=\sum_{r=1}^{\infty} \frac{1}{r^2+5r+4}=\sum_{r=1}^{\infty} \frac{1}{(r+4)(r+1)}$$
$$=\frac{1}{3}\left(\sum_{r=1}^{\infty} \frac{1}{r+1}-\frac{1}{r+4}\right)$$
$$=\frac{1}{3}\left(\sum_{r=1}^{\infty}\int_0^1 x^r-x^{r+3}\,dx\right)=\frac{1}{3}\left( \sum_{r=1}^{\infty} \int_0^1 x^r(1-x^3)\,dx\right)$$
$$=\frac{1}{3}\int_0^1 (1-x^3)\frac{x}{1-x}\,dx = \frac{1}{3}\int_0^1 x(x^2+x+1)\,dx=\frac{1}{3}\int_0^1 x^3+x^2+x \,dx$$
Evaluating the definite integral gives:
$$\frac{1}{3}\cdot \frac{13}{12}=\frac{13}{36}$$
Hmm...another good method to solve this problem, thanks Pranav for the solution and also for participating!
Staff member | {
"domain": "mathhelpboards.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9904406023459218,
"lm_q1q2_score": 0.8358279678581253,
"lm_q2_score": 0.8438950966654774,
"openwebmath_perplexity": 10322.888516076788,
"openwebmath_score": 0.909170389175415,
"tags": null,
"url": "https://mathhelpboards.com/threads/evaluate-the-sum-to-infinity.9432/"
} |
organic-chemistry, reaction-mechanism, aldol-reaction
Title: Aldol of 7-oxooctanal I want to do intramolecular aldol condensation of 7-oxooctanal:
I am talking about the major product. Clearly, a 6-membered ring would be a major product, but there are 2 possibilities: taking hydrogen from $\ce{C^2}$ or $\ce{C^6}$. Which one would be preferred? The more stable enol would involve $\ce{C^6}$, with the aldol condensation you would get a six member ring with $\ce{-COCH3}$ attached to the ring.
With the enol involving $\ce{C^2}$, the product would have a methyl and $\ce{-CHO}$ attached to the ring.
I don't know the distribution between the two products; it could be 51:49 or as much as 99:1. You should do the reaction to determine this. Factors that may effect the product ratio: temperature, solvent, reaction time, concentration, etc. | {
"domain": "chemistry.stackexchange",
"id": 1062,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "organic-chemistry, reaction-mechanism, aldol-reaction",
"url": null
} |
navigation, base-local-planner
Title: Difference between trajectory_planner.cpp and trajectory_planner_ros.cpp
I am currently trying to work with the trajectory planner in base_local_planner.
But now I am A bit confused, because the two source files trajectory_planner.cpp and trajectory_planner_ros.cpp seem to implement the same methods, or at least have a lot of overlap.
Can someone help me on that?
Originally posted by ct2034 on ROS Answers with karma: 862 on 2015-01-21
Post score: 0
It looks like trajectoy_planner.cpp implements the basic planning functionality, while trajectory_planner_ros.cpp provides the ROS API/communication part (publishers, subscribers etc.). This way of splitting functionality has the advantage that the planning part can be re-used more easily.
Originally posted by Stefan Kohlbrecher with karma: 24361 on 2015-01-22
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by RB on 2015-01-22:
Does trajectory_planner.cpp update/construct/choose the trajectories? What does the global planner will do then?
Comment by ct2034 on 2015-01-22:
Yes, this was also my impression. But I was confused that both seem to implement for example checkTrajectory. But the one in trajectory_planner_ros.cpp seems to be only a wrapper. | {
"domain": "robotics.stackexchange",
"id": 20647,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "navigation, base-local-planner",
"url": null
} |
mechanical-engineering, thermodynamics, heat-transfer, heating-systems, heat-exchanger
Title: Lifting 250 watts of heat using some heat exchanger/heat sink I am new to thermal management.
I want to lift about 250 W of heat from hot end of thermoelectric cooler/peltier cooler (TEC).
The temperature of hot side of TEC is 30°C.
I want to use some kind of heat exchanger/chiller to accomplish this task.
I am using equation
$$ P = h S (T_s-T_f) $$
where
$P$ = heat to be removed = 250 W
$h$ = heat transfer coefficient
$S$ = area of contact between hot side of TEC & fluid (air/water) used
for convective heat transfer
$T_s$ = temperature of hot end
$T_f$ = temperature of fluid (air/water)
I do not know how to calculate $h$. If I calculate that, it will give me temperature of fluid.
How do I compute $h$?
And is my approach correct? This is a convective heat transfer problem you're asking about. Calculating the coefficient isn't normally possible.
What you can do is read up on stuff like fin geometry on heat sinks, and CFD. The long-term solution here is to derive an equation for your system, something like P = f(X) where X is (for example) the length of a fin. Then, perform a CFD simulation for X = 1 to get P for that particular geometry. Then you can scale your fin until you get the right value for P.
It's get a bit more complicated because you probably shouldn't use dimensioned parameters for something like this. Instead, consider something like the Reynold's number of the system.
Some more reading to help you get started:
Heat Transfer From a Fin
Convective Heat Transfer | {
"domain": "engineering.stackexchange",
"id": 1089,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "mechanical-engineering, thermodynamics, heat-transfer, heating-systems, heat-exchanger",
"url": null
} |
c#, wpf, mvvm
#region Back Command
private CommandBase _backCommand;
public CommandBase BackCommand
{
get { return _backCommand ?? (_backCommand = new CommandBase(Back)); }
}
private void Back(object obj)
{
if (SelectedView.BackLocation != null)
{
SelectedView = SelectedView.BackLocation;
}
else
{
Application.Current.MainWindow.Close();
}
}
#endregion Back Command
#region ObjectBase Fields
public override event Action<ObjectBase> NavigateTo;
public override string ViewHeader { get { return "Main View"; } }
public override ObjectBase BackLocation { get { return null; } }
#endregion
}
Main Content View:
<Window x:Class="WpfNavigationTest.Views.MainContentView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:views="clr-namespace:WpfNavigationTest.Views"
xmlns:viewModels="clr-namespace:WpfNavigationTest.ViewModels">
<Window.DataContext>
<viewModels:MainContentViewModel/>
</Window.DataContext>
<Window.Resources>
<DataTemplate DataType="{x:Type viewModels:FirstViewModel}">
<views:FirstView/>
</DataTemplate> | {
"domain": "codereview.stackexchange",
"id": 15348,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c#, wpf, mvvm",
"url": null
} |
navigation, costmap-2d
Title: costmap_2d clear obstacles after every update
Hi,
I am creating costmaps of highly dynamic obstacles and want it to be efficiently cleared just before every update, so that each time only the current point cloud is projected into the map and there is no trace of what was previously projected.
Any help is appreciated.
Thanks.
Originally posted by Ishani Chatterjee on ROS Answers with karma: 26 on 2015-07-15
Post score: 0
I don't believe you can do this with the costmap layers as they are currently structured, but you could write a subclass of the obstacle_layer that clears all information from the map on every iteration.
Originally posted by David Lu with karma: 10932 on 2015-07-16
This answer was ACCEPTED on the original site
Post score: 0
Original comments
Comment by Ishani Chatterjee on 2015-07-16:
There is a protected member resetMaps(), I tried to change its scope to public and called it in the layered_costmap function that updates maps. But I can't see any topic published. Even if I reset everything to the original source code pulled from Git, it compiles and runs, but there is no topic | {
"domain": "robotics.stackexchange",
"id": 22199,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "navigation, costmap-2d",
"url": null
} |
c++, smart-pointers, reinventing-the-wheel
template <typename T, typename Delete = Deallocator<T> >
class SharedPtr : private SharedPtrBase {
private:
Delete del;
T* ptr;
void drop() {
if (ptr && isSingleton()) {
del(ptr);
ptr = NULL;
}
leave();
}
public:
// SharedPtr(p,false) will not delete the pointer! Useful for Stackobjects!
explicit SharedPtr(T* ptr = NULL, Delete del = Delete())
: SharedPtrBase(), del(del), ptr(ptr) {
}
SharedPtr(SharedPtr const& from)
: SharedPtrBase(from), del(from.del), ptr(from.ptr) {
}
~SharedPtr() {
drop();
}
SharedPtr& operator=(SharedPtr const& from) {
if (&from != this) {
drop();
del = from.del;
ptr = from.ptr;
join(&from);
}
return *this;
}
bool operator==(SharedPtr const& with) const {
return ptr == with.ptr;
}
bool operator==(T* with) const {
return ptr == with;
}
bool operator<(SharedPtr const& with) const {
return ptr < with.ptr;
}
bool operator<(T* with) const {
return ptr < with;
}
T& operator*() const {
return *operator->();
}
T* operator->() const {
assertWrapper(ptr);
return ptr;
}
//T* release() {
// leave();
// T* const p = ptr;
// ptr = NULL;
// return p;
//}
};
}
}
#endif
And my SharedPtr.cpp:
#include "util/SharedPtr.h"
#include <assert.h> | {
"domain": "codereview.stackexchange",
"id": 909,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, smart-pointers, reinventing-the-wheel",
"url": null
} |
Now we have that
$\frac{1}{1-t}=\sum_{n=0}^{\infty}x^n$
So now consider that $|x|<1$ is the interval of convergence of the geometric series, therefore it is uniformly convergent on that interval. So we can see that
$-\int_0^x\sum_{n=0}^{\infty}t^n~dt\quad{|x|<1}$
$=-\sum_{n=0}^{\infty}\int_0^xt^n~dt$
$=-\sum_{n=0}^{\infty}\frac{x^{n+1}}{n+1}\quad|x|<1$
$=\ln(1-x)$
$\therefore\frac{-1}{2}\ln(1-x)=\frac{1}{2}\sum_{n=0}^{\infty}\frac{x^{n+1}}{n+ 1}\quad|x|<1$
$\therefore\quad\boxed{\ln\left(\frac{1}{\sqrt{1-x}}\right)=\frac{1}{2}\sum_{n=0}^{\infty}\frac{x^{ n+1}}{n+1}\quad\forall{x}\backepsilon|x|<1}$
You and you're series...pfft..
I totally knew how to do that ...
I'm reteaching myself this stuff [infinte series, and power series], and it makes perfect sense...for now...
--Chris
9. Originally Posted by Chris L T521
You and you're series...pfft..
I totally knew how to do that ...
I'm reteaching myself this stuff [infinte series, and power series], and it makes perfect sense...for now...
--Chris
Yeah, but its not as fun with uniform convergence | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.982013788985129,
"lm_q1q2_score": 0.8327160275688703,
"lm_q2_score": 0.8479677545357568,
"openwebmath_perplexity": 1309.0015338049957,
"openwebmath_score": 0.8806549310684204,
"tags": null,
"url": "http://mathhelpforum.com/calculus/44812-maclaurin-series-question.html"
} |
python, plugin
def score_3():
opp_selectedLayerIndex = self.dockwidget.areaOpporunityMap_combo.currentText()
opp_sel_layer = QgsMapLayerRegistry.instance().mapLayersByName(str(opp_selectedLayerIndex))[0]
# Select all features where "Score" = 3
expr = QgsExpression( """ "Score" = 3 OR "Category" = 'Sensitive' OR "Category" = 'Unlikely' """ )
it = opp_sel_layer.getFeatures( QgsFeatureRequest( expr ) )
ids = [i.id() for i in it]
area = 0
if self.dockwidget.score3_checkbox.isChecked():
opp_sel_layer.select( ids )
else:
opp_sel_layer.deselect( ids)
def score_4():
opp_selectedLayerIndex = self.dockwidget.areaOpporunityMap_combo.currentText()
opp_sel_layer = QgsMapLayerRegistry.instance().mapLayersByName(str(opp_selectedLayerIndex))[0]
# Select all features where "Score" = 4
expr = QgsExpression( """ "Score" = 4 OR "Category" = 'Showstopper' """ )
it = opp_sel_layer.getFeatures( QgsFeatureRequest( expr ) )
ids = [i.id() for i in it]
area = 0
if self.dockwidget.score4_checkbox.isChecked():
opp_sel_layer.select( ids )
else:
opp_sel_layer.deselect( ids) | {
"domain": "codereview.stackexchange",
"id": 23076,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, plugin",
"url": null
} |
neural-network, backpropagation
In other visualisation, calculating the second activation from the input is:
$$\sigma(\begin{pmatrix}1 & _0a_{0}^0 & _0a_{1}^0\\\ 1 & _1a_{0}^0 & _0a_{1}^0\end{pmatrix} * \begin{pmatrix}b^0_0 & b^0_1 & b^0_2\\\ w^0_{0,0} & w^0_{0,1} & w^0_{0,2}\\\ w^0_{1,0} & w^0_{1,1} & w^0_{1,2}\end{pmatrix}) = \begin{pmatrix}_0a_{0}^1 & _0a_{1}^1 & _0a_{2}^1\\\ _1a_{0}^1 & _1a_{1}^1 & _1a_{2}^1\end{pmatrix}$$
The input of the first observation will be [0.8, 0.4], the second will be [0.3, 0.3] (they are completely random - just as the expected outputs).
So based on the above equation (sorry couldn't find other solutions to display it) $n^1$ (the neuron value, before the activation function) is:
+-----+-----+-----+
| 1 | 1 | 1 |
| 1 | 1 | 1 |
| 1 | 1 | 1 |
+---+-----+-----+-----+-----+-----+
| 1 0.8 0.4 | 2.2 | 2.2 | 2.2 |
| 1 0.3 0.3 | 1.6 | 1.6 | 1.6 |
+---+-----+-----+-----+-----+-----+ | {
"domain": "datascience.stackexchange",
"id": 8015,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "neural-network, backpropagation",
"url": null
} |
time-complexity, assignment-problem
Title: fastest algorithm for rectangular linear assignment problem I want to optimally assign $m$ jobs equally to $n$ workers, where $m>n$. Assume $m = an$ for some integer $a$, so that each worker must get exactly $a$ jobs. (The rectangular linear assignment problem, as defined here). I know this can be done by duplicating the workers to have $a$ copies of each, and then solving using the Kuhn-Munkres algorithm, which would result in $O(m^3)$.
This is an upper bound on the complexity of my problem. Is it also a lower bound? Is my problem in fact $\Theta(m^3)$? I.e., is the method of duplicating workers and using Kuhn-Munkres (as fast as) the fastest algorithm for solving the rectangular linear assignment problem (RLAP)?.
I want to know because I have a reduction of RLAP to another problem, and I want to lower-bound the complexity of this other problem. No, $\Omega(m^3)$ is not a lower bound. Your problem can be solved in $O((nm)^{1 + o(1)} \log a)$ time, by reducing to max flow and then using a state-of-the-art min cost max flow algorithm, such as the recent algorithm by Chen et al. See also https://en.wikipedia.org/wiki/Maximum_flow_problem#Algorithms.
There is a trivial $\Omega(nm)$ lower bound, since you have a weight for each pair of worker and job, and it requires $\Omega(nm)$ just to read in all of those weights.
These two bounds are nearly matching. | {
"domain": "cs.stackexchange",
"id": 20324,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "time-complexity, assignment-problem",
"url": null
} |
java, array, sorting
/**
* Checks that {@code fromIndex} and {@code toIndex} are in
* the range and throws an exception if they aren't.
*/
private static void rangeCheck(int arrayLength, int fromIndex, int toIndex) {
if (fromIndex > toIndex) {
throw new IllegalArgumentException(
"fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")");
}
if (fromIndex < 0) {
throw new ArrayIndexOutOfBoundsException(fromIndex);
}
if (toIndex > arrayLength) {
throw new ArrayIndexOutOfBoundsException(toIndex);
}
}
public static void main(String[] args) {
warmup();
benchmark();
}
private static final int LENGTH = 50_000_000;
private static final void warmup() {
runBenchmark(false);
}
private static final void benchmark() {
runBenchmark(true);
}
private static final void runBenchmark(boolean output) {
long seed = System.currentTimeMillis();
Random random = new Random();
byte[] array1 = createRandomByteArray(LENGTH, random);
byte[] array2 = array1.clone();
byte[] array3 = array1.clone();
if (output) {
System.out.println("seed = " + seed);
}
long startTime = System.nanoTime();
java.util.Arrays.sort(array1);
long endTime = System.nanoTime();
if (output) {
System.out.println("java.util.Arrays.sort(byte[]) in " +
(endTime - startTime) / 1e6 +
" milliseconds.");
}
startTime = System.nanoTime();
java.util.Arrays.parallelSort(array2);
endTime = System.nanoTime(); | {
"domain": "codereview.stackexchange",
"id": 36982,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "java, array, sorting",
"url": null
} |
on which the corresponding key depends. Course Schedule 1. For a detailed schedule, including reading assignments see the Schedule page. Now lets learn topological sorting through an example graph. This is an accepted solution: This is an accepted solution: Course Schedule CSOR 4231 Fall 2017. ) The algorithm is quite simple and uses post-order depth-first search. As the book says, a simple way to do this is to first find a class with no incoming edges (i. Topological Sort via DFS - A great video tutorial (21 minutes) on Coursera explaining the basic concepts of Topological Sort. Many of these require classifying edges into groups. With that in mind, what you probably need to do first is to find cycles and break them by deleting an edge in the cycle (OK, marking the edge as "ignore this when doing topological sort"). All tasks are nodes of the graph and if task u is a prerequisite of task v, we will add a directed edge from node u to node v. Wallach (like professor Budimlić before him) has a problem when getting ready to go to work in the morning: he sometimes dresses out of order. graph need to be initialized, node relationship is built, and inEdge count is also Overview. Oct 08, 2015 · So one correct course order is [0,1,2,3]. 7. Schedule (earlier announced to be held on 30-Mar-2020) for Class Test – 2 has been postponed and will be announced later. Scheduling or grouping problems which have dependencies between items are good examples to the problems that can be solved with using this technique. Course Schedule; LeetCode 210. Absent-minded Dr. e. Style and Approach. A study of the design and analysis of data structures and algorithms. This is the schedule for the Summer 2019 mathematics graduate student-run mini-courses at UT Austin. Note: The input prerequisites is a graph represented by a list of edges, not adjacency matrices. 01/13 - #1 & #4 - Introduction to Course; Review of Basic Data Structures. I have lists of courses, some which require others to be taken first (dependencies), others that require courses to be taken togethe Topological Sorting. The primary topics in this part of the specialization are: data structures (heaps, balanced search trees, hash tables, bloom filters), graph primitives (applications of | {
"domain": "cniptbaiamh.ro",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9643214460461698,
"lm_q1q2_score": 0.8077348923242604,
"lm_q2_score": 0.837619961306541,
"openwebmath_perplexity": 1399.052146630165,
"openwebmath_score": 0.21160000562667847,
"tags": null,
"url": "https://www.cniptbaiamh.ro/ysrzcr/topological-sort-course-schedule.html"
} |
c++, hash-map
for (auto& pair : hashGroups[hash])
if (pair.key == key)
return std::optional<std::reference_wrapper<ValueType>>{ pair.value };
return std::optional<std::reference_wrapper<ValueType>>{};
}
This makes retrieving data even messier.
if (firstTwo.has_value())
{
std::cout << firstTwo.value().get().n1 << '\n';
std::cout << firstTwo.value().get().n2;
} Make it look like std::unordered_map
When in Rome, do as the Romans do. In C++, if you are writing a container, it would be very nice if it has the same API as any other STL container. This avoids having to learn a different interface, and also makes it easier to use your container as a drop-in for an STL container without having to rewrite a lot of code that uses it. This is also part of making code more generic.
In particular, make sure the public member functions look like those of the closest matching STL container, which would be a std::unordered_map. So:
Change EmplaceBack() to emplace()
Consider changing Get() to operator[] which looks up or inserts.
Add other typical STL container functions, like clear(), size(), erase().
Note that the STL containers don't return std::optionals. Of course, the STL containers themselves were designed way before std::optional was a thing. Sometimes you know the item already exists, or maybe if you don't and it doesn't, you just want a default-constructed one. In those cases, operator[]() and at() do exactly what you want. A different function that returns a std::optional might be nice though, since the standard way to do the same with STL containers:
auto it = container.find(key);
if (it != container.end()) {
auto &value = it->second;
...
} | {
"domain": "codereview.stackexchange",
"id": 42803,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, hash-map",
"url": null
} |
• Ah I see, so you break down the limit in chunks that you can solve. Very cool, thanks. – jeremy radcliff Jun 9 '15 at 2:00
$$\lim_{n \to \infty} \frac{3^n-1}{2 \cdot 3^n} =\lim_{n \to \infty} \frac{\frac{3^n}{3^n} - \frac{1}{3^n}}{\frac{2\cdot 3^n}{3^n}} = \frac{1}{2}$$
This fraction can be written as a sum of two limits: $$\lim \frac{3^n-1}{2\cdot3^n}=\lim \frac{3^n}{2\cdot3^n}-\lim \frac{1}{2\cdot3^n}=\lim \frac{1}{2}-\lim \frac{1}{2\cdot3^n}=\frac{1}{2}-0=\frac{1}{2}$$
Split the limit up
$\lim_{x \rightarrow \infty} \dfrac{3^{n}}{2\cdot 3^{n}} - \dfrac{1}{2\cdot 3^n} = \dfrac{1}{2} - 0$
It is pretty clear after splitting up the fraction.
$$\lim_{n\rightarrow\infty}\frac{3^n-1}{2\cdot 3^n}=\frac{1}{2}\lim_{n\rightarrow\infty}\frac{3^n}{3^n}-\frac{1}{3^n}=\frac{1}{2}(1-0)=\frac{1}{2}$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446502128796,
"lm_q1q2_score": 0.8092379800727016,
"lm_q2_score": 0.8311430457670241,
"openwebmath_perplexity": 808.9219354127442,
"openwebmath_score": 0.9723849892616272,
"tags": null,
"url": "https://math.stackexchange.com/questions/1317886/how-to-prove-that-lim-n-to-infty-frac3n-12-cdot-3n-frac12/1317893"
} |
classical-mechanics, differential-geometry, vectors, definition
Title: What is the difference between tangent space and configuration space? I am doing Lagrangian mechanics and working with Noether's theorem. Please, could you explain the difference between the configuration space and the tangent space? Let's build this by example. Consider a particle in three dimensional space. We want to talk about the set of all possible configurations for this system. But what is a configuration? For a single particle it is just its position, encoding how the system is seem in space. If the particle is free of constraints this is obviously $\mathbb{R}^3$. If the particle is constrained to be on the surface of a sphere, then it is $S^2\subset \mathbb{R}^3$.
Now think about $K$ particles free of constraints. A certain configuration of this system is built by bringing together all positions of all $K$ particles. This obviously contains the informations of relative positions as well and how the system "looks like". Mathematically the set of all configurations is now
$$\mathbb{R}^{3K}=\underbrace{\mathbb{R}^3\times\cdots\times \mathbb{R}^3}_{\text{$K$ times}}.$$
Obviously now imposing constraints as in the case above will restrict the possible configurations to a subset of $\mathbb{R}^{3K}$.
Now we would like to describe the configurations by using coordinates. These coordinates need not be the coordinates labeling points in space, but must be coordinates which are adapted to the problem in question.
And when analyzing problem sometimes there are certain quantities which obviously encode in the simpler possible manner possible, whereas other coordinates seems awkward.
For the problem of $K$ particles free of constraints, at first sight each of them could be anywhere and hence we can actually use the cartesian coordinates of each particle to give coordinates to the configuration of the system. In that case the configurations of the system are given exactly by
$$(x^1,y^1,z^1,\dots,x^K,y^K,z^K)$$ | {
"domain": "physics.stackexchange",
"id": 47128,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "classical-mechanics, differential-geometry, vectors, definition",
"url": null
} |
Veritas Prep Reviews
Manager
Joined: 22 Feb 2016
Posts: 99
Location: India
Concentration: Economics, Healthcare
GMAT 1: 690 Q42 V47
GMAT 2: 710 Q47 V39
GPA: 3.57
Re: If a car traveled from Townsend to Smallville at an average [#permalink]
### Show Tags
26 Oct 2016, 08:22
Even I used to be confused with this concept but a through reading of speed time concept from magoosh helped me clear my basic flaws in understanding.
Coming to the question:
Speed distance has just one killer concept
s=d/t
Which means s is inversely proportional to time.
now it is given t1=1.5t2
therefore s1 which is inversely proportional will be 2/3s2
s1=40 hence s2=60
Apply the average speed formula 2d/(d/40+d/60)
take d common and cancel it .
Voila! you got the answer
Please give a kudos if you liked my answer.
Manager
Joined: 14 Oct 2012
Posts: 177
Re: If a car traveled from Townsend to Smallville at an average [#permalink]
### Show Tags
24 Apr 2017, 17:59
my 2 cents:
Attachments
001.jpg [ 283.16 KiB | Viewed 2644 times ]
Non-Human User
Joined: 09 Sep 2013
Posts: 7024
Re: If a car traveled from Townsend to Smallville at an average [#permalink]
### Show Tags
07 May 2018, 22:43
Hello from the GMAT Club BumpBot!
Thanks to another GMAT Club member, I have just discovered this valuable topic, yet it had no discussion for over a year. I am now bumping it up - doing my job. I think you may find it valuable (esp those replies with Kudos).
Want to see all other topics I dig out? Follow me (click follow button on profile). You will receive a summary of all topics I bump in your profile area as well as via email.
_________________
Re: If a car traveled from Townsend to Smallville at an average [#permalink] 07 May 2018, 22:43
Display posts from previous: Sort by
# If a car traveled from Townsend to Smallville at an average | {
"domain": "gmatclub.com",
"id": null,
"lm_label": "1. Yes\n2. Yes\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 1,
"lm_q1q2_score": 0.8104789155369047,
"lm_q2_score": 0.8104789155369047,
"openwebmath_perplexity": 7161.611365800858,
"openwebmath_score": 0.675899088382721,
"tags": null,
"url": "https://gmatclub.com/forum/if-a-car-traveled-from-townsend-to-smallville-at-an-average-122843.html"
} |
electromagnetism, energy, poynting-vector
Title: Veritasium Electricity videos: where does the majority of energy really flow? After watching Veritasium second video on electricity (references at the end), I have some doubts about where the majority of the energy flow actually happens. The reference experiment is the simple circuit made of a battery, switch and load (resistor).
Feynman Lectures: In Volume II, 27-4, Feynman remarks that:
we must say that we do not know for certain what is the actual location in space of the electromagnetic field energy | {
"domain": "physics.stackexchange",
"id": 87786,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "electromagnetism, energy, poynting-vector",
"url": null
} |
electricity, electric-circuits
Title: Why do electrons drift in an ideal conductor, since there's no field? Suppose a simple circuit with a DC voltage source and a resistor. The voltage of the source will be situated over the resistor.
So the electric field (which is the gradient of the potential) will be constant in the resistor (if you assume a linear potential function in the resistor), and will be equal to zero in the conducting connections.
Since electrons are drifted because of an electric field (with Newton's second law and Lorentz' law for the force), what keeps them drifting in the ideal conductors? Or do they just keep their velocity they got in the resistor, and don't decelerate because there's no resistance there? What would mean that the electrons obtain their velocity within the resistor, which sounds a bit paradoxal...
Where's the loop in my argumentation, or am I just right? In idealistic schematics of circuit theory conductors with no voltage drop guide electrons to and from the elements. Electrons don't lose or gain speed here, that is they obey Newton's first law. In resistors there is an acceleration due to electric field and deceleration due to scattering from lattice sites, i.e. drift.
Therefore within this paradigm electrons don't drift in ideal conductors, they act inertially. Thus they will drift through the resistor and go losslessly through contacts into the battery where the electromotive force will bring them to the other side for the next lap. They won't obtain any velocity in the resistor, since they already had it exiting the battery; the electric field in the steady state sets it such that $v=\mu E$.
In reality however even in ballistic conductors, where scattering is largely eliminated and the voltage drop within the ballistic region is vanishingly small, the quantum contact resistance will appear as dominant (and unavoidable - http://www.ecs.umass.edu/ece697mm/Supplement_Lucent_fourt%20resist_Nature_2001.pdf). Therefore there are no such things as ideal conductors, and circuit theory is not particularly suited for analyzing the inner workings of resistivity, conductance, transmission etc. | {
"domain": "physics.stackexchange",
"id": 8336,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "electricity, electric-circuits",
"url": null
} |
it is easy to find the area of a regular polygon is a with. Have the area pentagon peanut a gone the pentagon amount of space by! Side 10 cm has a star drawn within ( the vertices of a rhombus,.! S take an example to understand how to use the direct formula given in to... With all five sides and an inradius of 7 cm five times squared., using the area of a regular pentagon that has a side 6... Share with you a clever technique I once used to find the area any. The midpoint of one side needs to be known into triangles the circle it... Power of five and hexagons are all examples of polygons named as the.! A few activities for you to practice, see Derivation of regular polygon is two-dimensional! Of one side needs to be known the denominator will have for times the tangent of power five. As the Octagon within ( the vertices of a regular pentagon has at least one vertex pointing inside then... Rectangle, pentagon, the pentagon IHS, and hexagons are all examples of are. All the sides are the same formula as the area of a regular pentagon comes about provided! | {
"domain": "hotexl.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9884918509356967,
"lm_q1q2_score": 0.812727261909032,
"lm_q2_score": 0.8221891370573388,
"openwebmath_perplexity": 445.53768278060596,
"openwebmath_score": 0.7381290793418884,
"tags": null,
"url": "http://hotexl.com/qlyur8j/4cd914-area-of-pentagon-formula"
} |
v, but in the opposite direction. Vectors can be added, subtracted and multiplied by a scalar. Given drs of the line converts to dcs will be {-2/3, 2/3, 1/3} . Try It. Going from a magnitude and direction to component form. So we're giving the X and Y component in both cases and asked to find the magnitude and direction of the resulting vector that comes from these X and Y components. 1.8k views. Geometrical problems can be solved using vectors. Solution : Since the given are the direction ratios of some vector, it must satisfies the condition given below. Find the direction ratios and direction cosines of the vector a = 5i - 3j + 4k. Plug in the numbers to get 5.1. 3. All Answers (11) 12th Mar, 2020. Sample question. Important Solutions 4565. Vector quantities have two characteristics, a magnitude and a direction; scalar quantities have only a magnitude. Direction ratios provide a convenient way of specifying the direction of a line in three dimensional space. The vector v has been multiplied by the scalar t to give a new vector, s, which has the same direction as v but cannot be compared to v in magnitude (a displacement of one metre is neither bigger nor smaller than a velocity of one metre per second). So for part A, we have a of X is equal the negative 6.0 centimeters and a A Y is equal to 5.2 centimeters. Then the vector may be represented algebraically by OQ. Converting Between Vector Representations in 2D. Misc 11 Show that the direction cosines of a vector equally inclined to the axes OX, OY and OZ are 1/√3, 1/√3, 1/√3 . In thermodynamics, where many of the quantities of interest can be considered vectors in a space with no notion of length or angle. If you have any more doubts just ask here on the forum and our experts will try to help you out as soon as possible. The direction cosines uniquely set the direction of vector. Direction ratios of a vector are the coordinates of the unit directional vectors. The direction of a vector is only fixed when that vector is viewed in the coordinate plane. OR . Then, using techniques we'll learn shortly, the direction of a vector can be calculated. Now, the distance AB = r = 6 | {
"domain": "testing-url.ws",
"id": null,
"lm_label": "1. Yes\n2. Yes",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9711290963960277,
"lm_q1q2_score": 0.819531092209521,
"lm_q2_score": 0.843895106480586,
"openwebmath_perplexity": 586.6632881896057,
"openwebmath_score": 0.8268614411354065,
"tags": null,
"url": "http://513720ade1c24751be63bb31c4e55827.testing-url.ws/4wxjswi/direction-ratios-of-a-vector-abc167"
} |
forces, kinematics, energy-conservation, momentum, collision
In practice, analytical approximations are possible with simple geometry (and conservative assumptions)- this is discussed in the following. | {
"domain": "physics.stackexchange",
"id": 26679,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "forces, kinematics, energy-conservation, momentum, collision",
"url": null
} |
python, csv, pandas, matplotlib
Title: Manipulating Pandas Dataframe with vaccination data from CSV to display on matplotlib I have some code that manipulates a Pandas Dataframe containing Covid-19 vaccine data and displays it on Matplotlib.
The data is here: https://covid.ourworldindata.org/data/owid-covid-data.csv (downloads CSV).
I have manipulated the data so that it only shows countries whose current vaccine per hundred rate is less than 10 (so it can't remove all vaccine rates less than ten, it has to go through each country, get the latest vaccine per hundred rate, and if it is less than ten, remove that country from the graph).
This is highly time-sensitive and needs to be done as quickly as possible.
Code:
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.dates import DateFormatter, WeekdayLocator
import datetime
df = pd.read_csv(
"https://covid.ourworldindata.org/data/owid-covid-data.csv",
usecols=["date", "location", "total_vaccinations_per_hundred"],
parse_dates=["date"])
df = df[df["total_vaccinations_per_hundred"].notna()]
countries = df["location"].unique().tolist()
countries_copy = countries.copy()
main_country = "United States"
for country in countries:
if country in countries:
df_with_current_country = df[df['location']==country]
if df_with_current_country[df["date"]==df_with_current_country["date"].max()]["total_vaccinations_per_hundred"].tolist()[0] < 10:
if country != main_country: countries_copy.remove(country)
countries = countries_copy
df = df[df["location"].isin(countries)] | {
"domain": "codereview.stackexchange",
"id": 40942,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, csv, pandas, matplotlib",
"url": null
} |
quantum-field-theory, special-relativity, fermions, dirac-equation, grassmann-numbers
According to the correspondence principle between quantum and classical physics, the supercommutator is $i\hbar$ times the super-Poisson bracket (up to possible higher $\hbar$-corrections), cf. e.g. this Phys.SE post. Therefore the corresponding fundamental super-Poisson brackets read$^1$
$$ \{\psi_{\alpha}({\bf x},t), \psi^{\ast}_{\beta}({\bf y},t)\}
~=~ -i\delta_{\alpha\beta}~\delta^3({\bf x}-{\bf y})
~=~\{\psi^{\ast}_{\alpha}({\bf x},t), \psi_{\beta}({\bf y},t)\}, $$
$$ \{\psi_{\alpha}({\bf x},t), \psi_{\beta}({\bf y},t)\}
~=~ 0, $$
$$ \{\psi^{\ast}_{\alpha}({\bf x},t), \psi^{\ast}_{\beta}({\bf y},t)\}~=~ 0. \tag{4} $$
Comparing eqs. (1), (3) & (4), it becomes clear that the Dirac field is Grassmann-odd, both as an operator-valued quantum field $\hat{\psi}_{\alpha}$ and as a supernumber-valued classical field $\psi_{\alpha}$. | {
"domain": "physics.stackexchange",
"id": 33905,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-field-theory, special-relativity, fermions, dirac-equation, grassmann-numbers",
"url": null
} |
quantum-field-theory, field-theory, quantum-chromodynamics, lattice-model, lattice-gauge-theory
Title: Lattice spacing in lattice QCD It is known that the lattice spacing in lattice QCD is not an external parameter and needs to be calculated, also the lattice beta parameter scales the lattice spacing ($a$) and goes as a function of the coupling constant as $$β=\frac{2*N}{g_0^2}$$
Where $N$ is a number of colors.
So the question is, how exactly is the lattice spacing calculated in lattice QCD?
I would also like to know how this lattice spacing is translated into physical units (GeV,fm). The lattice spacing can be obtained in a procedure usually referred to as scale setting for which one requires a physical quantity computed on the lattice. Take as an example the mass of the proton $am_P$ computed at a given value of the bare gauge coupling $g_0^2$ from the corresponding two-point correlation function. Given knowledge of the experimental value of the proton mass $m_P^{phys}$, the value of the lattice spacing can now be obtained via
$$a(g_0^2)=\frac{am_P(g_0^2)}{m_P^{phys}}\,.$$
A result in fm can then be directly derived using $\hbar c=197.3269788(12)$ MeV fm.
This scale setting is of course only valid up to lattice artifacts and depends on the quantity used to set the scale.
In practice people usually do not use the proton mass but rather the $\Omega$ or $\Xi$ masses or the decay constants of the pion and/or kaon. Intermediate scales like $r_0$ or $t_0$ which do not have a direct physical counterpart but can be easily and precisely computed on the lattice are also very common. | {
"domain": "physics.stackexchange",
"id": 76535,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-field-theory, field-theory, quantum-chromodynamics, lattice-model, lattice-gauge-theory",
"url": null
} |
deep-learning, transformer, attention, gpt, large-language-models
Multi-Head Attention
Multi-head attention is nothing more than several individual heads stacked on top of one another. The input to all heads is equivalent. However, each head has its own weights. After forwarding the input through all the heads, the output of the heads is concatenated and passed through a linear layer which brings the dimensionality back to the dimension of the initial input.
Masked Self-Attention
In the decoder-only transformer, masked self-attention is nothing more than sequence padding. The 'masking' term is a left-over of the original encoder-decoder transformer module in which the encoder could see the whole (original language) sentence, and the decoder could only see the first part of the sentence which was already translated. As such, they called it 'masking'.
Block
Each block contains a multi-head attention submodule, a feedforward network, 2 layer-normalization operations, and 2 skip connections.
The feedforward network is simply a multi-layer perceptron. In the original paper, the proposed feedforward module consisted of (1) a fully connected layer; (2) a ReLU activation; (3) another fully connected layer; and (4) a dropout layer.
The 'add & norm' blocks get the output from the multi-head attention/feedforward submodule and add it to the input into those modules. After that, a layer normalization operation is performed. Adding the input and output of a submodule together is known as a skip-connection. As blocks can be put in sequence, the skip connections help tremendously reduce the problem of vanishing or exploding gradients. In other words, skip connections are necessary to ensure proper backpropagation of the gradients.
Positional Embedding
Transformers take in a complete prompt at once (in contrast to RNNs) and embed this as one big Tensor. As such, transformers do not know which word is at what position in the sentence. This is problematic as the following two sentences mean entirely different things, only dependent on the order of the words:
The boy chased the bird with a butterfly net.
The bird chased the boy with a butterfly net. | {
"domain": "ai.stackexchange",
"id": 3781,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "deep-learning, transformer, attention, gpt, large-language-models",
"url": null
} |
coordinate
If you want the stars to move with the rotation of the Earth, then you would use LONGITUDE = RA*15 - THETA*15, where THETA is the sidereal time at Greenwich in decimal hours.
You should be aware that for the celestial sphere you look from the centre towards the inside of the surface of the sphere, while for geographical purposes you look from the outside (above) towards the spheroid (down). So if you project the stars on a globe like this, you will notice that the constellations will look inverted from what you're used to in star maps. If you find one of those old celestial globes, you will also see the inverted constellations. For instance on this image, you'll see Leo to the left of Virgo and Hercules, while on most star maps, Leo will be to the right.
If you want the constellations to look 'right' then you would need to use LONGITUDE = -RA*15 (mind the minus sign). But then you would also need to invert the rotation of the Earth as well. | {
"domain": "astronomy.stackexchange",
"id": 232,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "coordinate",
"url": null
} |
meteorology, atmosphere, wind, air-currents
Title: Where does wind come from? Wind is (according to Wikipedia) the flow of gases on a large scale.On the surface of the Earth, wind consists of the bulk movement of air.
What forces would cause such a mass movement of air? Wind is caused by pressure differences. Think of a balloon full of air; poke a hole in it and the air comes out. Why? Because the pressure in the balloon is higher than outside, and so to regain equal pressure, mass moves and that is the wind.
There is a bit more to this in the atmosphere as the Earth rotates and near the surface friction also plays a role. The equation of motion is the Navier-Stokes and in vector form in Cartesian space is:
$$\dfrac{\partial\mathbf u}{\partial t} = - \mathbf u \cdot \nabla \mathbf u -\dfrac{1}{\rho}\nabla p-2 \mathbf \Omega \times \mathbf u + \mathbf g + \mathbf F$$
In this equation, $\mathbf u$ is the vector wind, $(\mathbf u \cdot \nabla)$ is the advection operator, $\rho$ is density, $\mathbf \Omega$ is the vector rotation of the Earth, $\mathbf g$ is effective gravity and $\mathbf F$ is friction.
The LHS is the time rate of change of the wind at a point in space (as opposed to following the parcel). The RHS represent a number of factors that produce a change in the wind. From left to right:
Advection of momentum (non-linear)
Pressure gradient force (this is wind blowing from high to low pressure)
Coriolis force (this turns wind to the right in the NH and left in the SH and causes the wind to flow parallel to isobars)
gravity (provides hydrostatic balance with the PGF in the vertical)
Friction (in the boundary layer you may see this as $\nu\nabla^2\mathbf u$) | {
"domain": "earthscience.stackexchange",
"id": 63,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "meteorology, atmosphere, wind, air-currents",
"url": null
} |
Below is a more general proof using basic gcd laws (distributive, commutative, associative). Your version of Euclid's Lemma is a special case, since $\ (b,c) = 1\,\Rightarrow\, (a,b,c) = 1.$
Theorem $\, \ (a,c)(b,c)\, =\, (ab,c)\,\$ if $\,\ \color{#c00}{(a,b,c) = 1}$
$\!\!\begin{eqnarray}{\bf Proof}\qquad\, (a,c)(b,c) &=&\, (a(b,c),c(b,c))\\ &=&\, ((ab,ac),(cb,cc))\\ &=&\, (ab,ac,cb,cc)\\ &=&\, (ab,c\color{#c00}{(a,b,c)})\\ &=&\, (ab,c)\end{eqnarray}$
Remark $\$ See also this answer for related proofs by Bezout, ideals, etc. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9817357208465786,
"lm_q1q2_score": 0.8181045161821593,
"lm_q2_score": 0.8333245891029457,
"openwebmath_perplexity": 162.46913478803276,
"openwebmath_score": 0.9596004486083984,
"tags": null,
"url": "https://math.stackexchange.com/questions/875594/if-gcda-c-1-gcdb-c-then-gcdab-c-1/875619"
} |
java
sum+=prev;
As a note, a += b is not shorthand for a = a + b but for a = (TYPE_A)(a + b), which means that it might silently truncate data, for example when adding a float to an int.
int sum = 1;
int prev = 0;
for (int i=1;i<num;i++) {
sum+=prev;
prev = sum-prev;
// System.out.println("sum="+sum+" , prev = "+prev);
}
Your logic is rather hard to follow, that is because before you really read it it seems to be doing something completely different. So what you want to do is clear that up, partly by using better names and partly by making the logic easier to follow:
int current = 1;
int previous = 0;
for (int counter = 0; counter < steps; counter++) {
System.out.print(current);
System.out.println(" ");
int next = current + previous;
previous = current;
current = next;
}
That makes it rather clear how the logic operates.
Looking at possible performance implications is complicated, in my opinion, but let us look at the generated bytecode before jumping to conclusions:
This is the bytecode created for original solution:
0: iconst_1
1: istore_1 /* sum */
2: iconst_0
3: istore_2 /* prev */
4: iconst_1
5: istore_3 /* i */
6: goto 20
9: iload_1 /* sum */
10: iload_2 /* prev */
11: iadd
12: istore_1 /* sum */
13: iload_1 /* sum */
14: iload_2 /* prev */
15: isub
16: istore_2 /* prev */
17: iinc i, 1
20: iload_3 /* i */
21: iload_0 /* num */
22: if_icmplt 9
25: iload_1 /* sum */
26: ireturn | {
"domain": "codereview.stackexchange",
"id": 40502,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "java",
"url": null
} |
formal-languages, regular-languages, pumping-lemma
Title: Irregularity of $\{a^ib^jc^k \mid \text{if } i=1 \text{ then } j=k \}$ I read on the site on how to use the pumping lemma but still I don't what is wrong with way I'm using it for proving that the following language is not a regular language:
$L = \{a^ib^jc^k \mid \text{if } i=1 \text{ then } j=k \}$
for $i\neq1$ the language is obviously regular but in the case which $i=1$ , we get that the language is $a^1b^nc^n$, now for every division $w=xyz$ such that $|y|>0 , |xy|< p$ where p is the pumping constant I get the word $a^1b^pc^p$ would be out of the language. since $|xy|< p$
, $y$ may contains only $a's$ or $b's$ or both. if $x= \epsilon$ and $y=a$, pump it once and you're out of the language, if it contains only $b's$, pump it once and your'e out of the language, and if it contains both, pump it and you're out of the language again.
so, why does this language considered as not regular and cannot be proved for its irregularity by the pumping lemma? please point out my mistake. The pumping lemma provides a sufficient condition for a language to be non-regular, it is not a necessary condition. This is an example of a language for which the pumping condition holds, so you cannot prove that it is non-regular with (the basic version of) the pumping lemma.
When you see this language definition, you should immediately think of breaking it up:
$$ \begin{align*}
L &= \{ a^i b^j c^k \mid \text{if \(i=1\) then \(j=k\)} \}
= \{ a^i b^j c^k \mid i \ne 1 \vee j=k \} \\ | {
"domain": "cs.stackexchange",
"id": 197,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "formal-languages, regular-languages, pumping-lemma",
"url": null
} |
4. Find the values of a and b for which x^3 + ax^2 - 10x + b is divisible by x^2 + x - 12.
THanks a lot for your help!
Hello,
to 1.: Use the slope-formula:
$m=\frac{y_1-y_2}{x_1-x_2}$. Plug in the values you know and you'll get:
$m=\frac{2-6}{(-1)-4}=\frac{-4}{-5}$
The slope is the tangens of the angle between line and x-Axis. So the angle is the arctan(m)
$arctan\left(\frac{4}{5}\right)\approx 38^\circ39'35.31''$
to 2.: Even if it isn't exact I'll use $m=tan(53^\circ8')=\frac{4}{3}$
Now use the point-slope-formula:
$m=\frac{y-y_1}{x-x_1}$. Plug in the values you know:
$\frac{4}{3}=\frac{y-2}{x-(-1)}$. Solve for y and you'll get:
$y=\frac{4}{3} \cdot (x+1)+2=\frac{4}{3} \cdot x+\frac{10}{3}$
to 3.: a) The slope is m = -2. Now use the point-slope-formula and you'll get:y=-2x-1
b) Two lines are perpendicular if $l_1 \bot l_2 \Longleftrightarrow m_1 \cdot m_2=-1$ where l means a line and m the slope of the corresponding line.
Therefore the perpendicular slope is $m_p=-\frac{1}{-2}=\frac{1}{2}$. Now use the point-slope-formula and you'll get: $y=\frac{1}{2} \cdot x - 6$ | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.970687766704745,
"lm_q1q2_score": 0.8288826667321295,
"lm_q2_score": 0.8539127566694178,
"openwebmath_perplexity": 395.40962794444675,
"openwebmath_score": 0.7780210971832275,
"tags": null,
"url": "http://mathhelpforum.com/pre-calculus/2326-lines.html"
} |
quantum-mechanics, hilbert-space, vacuum, notation
Title: Ground state Dirac formalism In Dirac formalism, the action of the 'lowering' operator acting on a ground state energy eigenstate is given by
$$\hat{a}|0\rangle=0$$
Notation wise, it is clear what the left hand side express means.
What about the $0$ on the right hand side? Is this just matter of notation?
I am sure $0$ is not the energy eigenvalue for a particle in an energy eigenstate corresponding to the ground state. Any particle has a positive energy eigenvalue in the ground state. The expression you wrote $\hat{a} |0 \rangle = 0$ is a great expression to force you to think carefully about what these symbols all mean. Good question!
Remember that quantum states live in a Hilbert space, which is a vector space plus a few extra properties. It often is useful to form analogies with other vector spaces that we are used to - for example, consider vectors in the XY Cartesian plane. In this plane, $\vec{x}$ and $\vec{y}$ can be picked as basis vectors. Then any vector in the whole plane can be expressed as $\vec{v} = a \vec{x} + b\vec{y}$.
Now, you see that if $a$ and $b$ are both 0, then $\vec{v} = 0$ is the 'null vector'. If you like, it is a linear combination of all basis vectors with coefficient 0 for each basis vector.
Now back to the Hilbert space: the state $|0\rangle$ is a basis vector in the Hilbert space, much like $\vec{x}$ in the XY plane. Just like in XY, general states in the Hilbert space can be written as $|\psi\rangle = \alpha|0\rangle + \beta|1\rangle + \ldots$ | {
"domain": "physics.stackexchange",
"id": 38699,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-mechanics, hilbert-space, vacuum, notation",
"url": null
} |
Notably, given that $$\boldsymbol{D^\complement}$$ happens, $$P(T_1 T_2) = 0 = P(T_1)\times P(T_2);$$ hence, $$T_1$$ and $$T_2$$ being either dependent or independent conditional on whether $$D$$ happens does not imply that $$T_1$$ and $$T_2$$ are dependent!!
Remarkably, events $$X$$ and $$Y$$ being independent conditional on event $$A$$ as well as conditional on event $$A^\complement$$ still does not imply that $$X$$ and $$Y$$ are independent!!
For example, let $$E$$ be an event with probability strictly between $$0$$ and $$1;$$ then $$P(E\cap E\mid E)=1=P(E\mid E)\times P(E\mid E),\\ P(E\cap E\mid E^\complement)=0=P(E\mid E^\complement)\times P(E\mid E^\complement),$$ yet $$P(E\cap E)=P(E)\ne [P(E)]^2=P(E)\times P(E).$$
Alternatively, here's a less abstract, coin-toss example. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9848109525293959,
"lm_q1q2_score": 0.8005206330951414,
"lm_q2_score": 0.8128673133042217,
"openwebmath_perplexity": 264.5305130515786,
"openwebmath_score": 0.7044042944908142,
"tags": null,
"url": "https://math.stackexchange.com/questions/4478672/independence-of-diagnostic-tests"
} |
and Polar coordinates. I Computing volumes using double integrals. A Cartesian coordinate system (UK: / k ɑː ˈ t iː zj ə n /, US: / k ɑːr ˈ t i ʒ ə n /) is a coordinate system that specifies each point uniquely in a plane by a set of numerical coordinates, which are the signed distances to the point from two fixed perpendicular oriented lines, measured in the same unit of length. Then x = r cos O, Y = r sin O. Coordinate Systems B. This is the official, unambiguous definition of polar coordinates, from which we. Convert the following equation to polar. It's 2 units awa. EXAMPLE 11: Convert y = 10 into a polar equation. The calculator will convert the polar coordinates to rectangular (Cartesian) and vice versa, with steps shown. In such a coordinate system you can calculate the distance between two points and perform operations like axis rotations without altering this value. 2 Slopes in r pola tes coordina When we describe a curve using polar coordinates, it is still a curve in the x-y plane. Now I need to go the other way around. Example: What is (12,5) in Polar Coordinates? Use Pythagoras Theorem to find the long side (the hypotenuse):. Rectangular coordinates Rectangular coordinates and polar coordinates are two different ways of using two numbers to locate a point on a plane. It is good to begin with the simpler case, cylindrical coordinates. , a nest or burrow) based on distance and bearing from a grid point, this function helps me avoid writing down SOH-CAH-TOA every time. 14) of https://yoquieroaprobar. Polar-Cartesian Coordinate conversion and Cartesian-Polar Hi All, Is there any standard program to convert Polar Coordinates to Cartesian Coordinates. 11, page 636. EXAMPLE 10. Converting from Polar Coordinates to Rectangular Coordinates. But I need a better precision, therefore I hope you can help me finding some formulas to convert cartesian coordinates to geographical gps. In polar coordinates, the shape we work with is a polar rectangle, whose sides have. They are also called "Euclidean coordinates," but not because Euclid discovered them first. Cylindrical and spherical coordinates 1. Convert from rectangular coordinates to polar coordinates using the conversion formulas. asked by BM on | {
"domain": "clandiw.it",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9875683484150417,
"lm_q1q2_score": 0.8432972016158118,
"lm_q2_score": 0.853912747375134,
"openwebmath_perplexity": 486.12006461400983,
"openwebmath_score": 0.9364537000656128,
"tags": null,
"url": "http://clandiw.it/fvql/conversion-of-cartesian-coordinates-to-polar-coordinates-pdf.html"
} |
The value of $t_i$ must be the same in both cases. If not, your conditions would not be satisfied. However, I would suggest a different approach than using $v_0$ and $\alpha$ from the beginning. Instead, I would use the initial $x$ and $y$ components of the velocity (call them $v_{0x}$ and $v_{0y}$ for example). Either way, you should have a sufficient number of conditions to solve for all of your variables. In principle, you have three conditions and three unknowns:
1. The vertical velocity needs to be zero at $t_i$.
2. The vertical distance needs to be $h$ at $t_i$.
3. The horizontal distance needs to be $d$ at $t_i$.
This is a solvable system of equations.
Your image suggests that the target is a sphere, but your solution and the formulation suggests that it is a vertical surface. I am going to assume the latter.
Sorry for the confusion. Your assumption is correct.
Thanks, I'll take another stab at the problem using your approach and will see how it goes.
Here's what I did:
Time when vertical velocity = 0:
$$0 = v_{0y} - gt_i \rightarrow t_i = \frac{v_{0y}}{g}$$
Vertical distance is $h$ at time = $t_i$:
$$h = v_{0y}t - \frac{g}{2}t^2 \rightarrow H=v_{0y}\frac{v_{0y}}{g} - \frac{g}{2}\frac{v_{0y}^2}{g^2} = \frac{v_{0y}^2}{g}-\frac{v_{0y}^2}{2g} = \frac{v_{0y}^2}{2g}=h$$
Horizontal distance is $d$ at time = $t_i$: | {
"domain": "physicsforums.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9706877684006775,
"lm_q1q2_score": 0.8191586595793733,
"lm_q2_score": 0.8438951084436077,
"openwebmath_perplexity": 275.32176575853555,
"openwebmath_score": 0.8818606734275818,
"tags": null,
"url": "https://www.physicsforums.com/threads/projectile-motion-determining-initial-velocity-and-angle.958738/"
} |
which takes care of the columns, and then we do the rows,
$$\frac{1}{2}\begin{pmatrix}1&1\\1 & -1\end{pmatrix}\begin{pmatrix}2 \\ 4\end{pmatrix} = \begin{pmatrix}3 \\ -1\end{pmatrix} \quad\quad\quad \frac{1}{2}\begin{pmatrix}1&1\\1 & -1\end{pmatrix}\begin{pmatrix}0 \\ -1\end{pmatrix} = \begin{pmatrix}-0.5 \\ 0.5\end{pmatrix} \quad\rightarrow\quad \begin{pmatrix}3&-1\\-0.5 & 0.5\end{pmatrix}$$
Finally, one can also compute this recursively using the fast Hadamard transform. It's up to you to find out if this is shorter or not.
## Challenge
Your challenge is to perform the 2D Hadamard transform on a 2D array of arbitrary size 2^n x 2^n, where n > 0. Your code must accept the array as input (2D array or a flattened 1D array). Then perform the 2D HT and output the result.
In the spirit of flexibility, you have a choice for the output. Before multiplying by the prefactor 1/(2^(2n)), the output array is all integers. You may either multiply by the prefactor and output the answer as floats (no formatting necessary), or you may output a string "1/X*" followed by the array of integers, where X is whatever the factor should be. The last test case shows this as an example.
You may not import the Hadamard matrices from some convenient file that already contains them; you must build them inside the program.
## Test Cases
Input:
2,3
2,5
Output:
3,-1
-0.5,0.5
Input:
1,1,1,1
1,1,1,1
1,1,1,1
1,1,1,1
Output: | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9850429147241161,
"lm_q1q2_score": 0.8098915775838288,
"lm_q2_score": 0.8221891305219504,
"openwebmath_perplexity": 4318.688964080831,
"openwebmath_score": 0.5411889553070068,
"tags": null,
"url": "https://codegolf.stackexchange.com/questions/194229/implement-the-2d-hadamard-transform?noredirect=1"
} |
product ) ] [ ( 1. a ) and B ⊆ a { A^! And I found it absolutely bizarre same set x is isomorphic to the first table paired! Clause gives the Cartesian product originated from analytical geometry, which means without what is cartesian product we... Tables and there is no relationship defined between the tables that you are agreeing to,. X a for your Britannica newsletter to get trusted stories delivered right to your.! Not in Syllabus - CBSE Exams 2021 what is cartesian product Britannica newsletter to get trusted stories delivered right your... From the two tables on an ordered set of all the rows in the most dictionary... ), origin etc the latter frees change to many steps categorical product is ladder! Data foundation its x and y coordinates, respectively ( see middle picture ) three sets its. This can be visualized as a vector with countably infinite real number components as! A and B is denoted by a x B and B is denoted by x. ( column value ) in entities ( table ) through some operators a coordinate plane, are! Cardinality of a set and B be two finite sets with a {! What relation does it have to relational algebra and relational calculus - CBSE Exams 2021 no! 'Cartesian product ' is also referred as 'Cross product ' is also referred as 'Cross '. … Cartesian product of graphs delivered right to your inbox one table every! Be specified using set-builder notation, e.g visualized as a vector with countably infinite real number components an n-element to. And the second set the absolute complement of a WHERE condition is not what is cartesian product. An array and a tree diagram, origin etc second table before getting familiar with this term, us... An n-fold Cartesian product is Oracle Proprietary join analytic geometry power is a join of every row of table... Is the set of all ordered pairs obtained by the number of rows the. Other day and I found it absolutely bizarre product occurs when you select object from different tables there! Ex 2.1, 4 Important functions considered as sets of analytic geometry more generally still, can. Ten rows is Oracle Proprietary join table to every row of another table 52-element. This combination of select and CROSS product ) can be visualized as a direct product information and translations Cartesian. Sql 99 join and Cartesian product Cartesian square of a set x | {
"domain": "meselflove.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9820137858267907,
"lm_q1q2_score": 0.8005695498100616,
"lm_q2_score": 0.8152324960856175,
"openwebmath_perplexity": 521.5571086568627,
"openwebmath_score": 0.8071672916412354,
"tags": null,
"url": "http://meselflove.com/bys8di/what-is-cartesian-product-8ded7b"
} |
homework-and-exercises, quantum-field-theory, electrons, magnetic-moment
and the integral is the following:
\begin{equation}
\int \frac{d^4 k}{(2\pi)^4} \frac{-i g_{\nu\rho}}{(k-p)^2 + i\epsilon}
\overline{u}(p')(ie\gamma^\nu) \frac{i( \not{k} ' + m)}{k'^2 - m^2 + i\epsilon} \gamma^\mu \frac{i( \not{k} + m)}{k^2 - m^2 + i\epsilon} (ie\gamma^\rho)u(p)
\end{equation}
This can be rewritten to:
\begin{equation}
2ie^2 \int \frac{d^4 k}{(2\pi)^4} \frac{\overline{u}(p') \left[ \not{k} \gamma^\mu \not{k}' + m^2 \gamma^\mu - 2m(k + k')^\mu \right] u(p)}{\left((k-p)^2 + i\epsilon\right)\left(k'^2 - m^2 + i\epsilon \right)\left(k^2 - m^2 + i\epsilon \right)}
\end{equation}
I'm stuck trying to get the $\not{k} \gamma^\mu \not{k}'$ part in the brackets. I have obtained the other ones using the identity $\gamma^\mu \gamma^\nu \gamma_\mu = - 2 \gamma^\nu$ as described in the book: | {
"domain": "physics.stackexchange",
"id": 31659,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "homework-and-exercises, quantum-field-theory, electrons, magnetic-moment",
"url": null
} |
nuclear-physics, education, strong-force
Title: What is the mean internucleon distance in a nucleus? I am finding some conflicting information which is resulting in some confusion when teaching the topic of nuclear physics to high school students.
The residual strong nuclear force has an attractive range of around 0.7 - 3fm.
A nucleon has a diameter somewhere in the range of 1-2fm.
According to my understanding, nucleons will be in equilibrium when the residual strong nuclear force is zero for a neutron-neutron or neutron-proton interaction and slightly further apart for a proton-proton interaction (since the RSNF has to now be as attractive as the electrostatic force is repulsive). This means about 0.7 fm for n-p and n-n or 0.8fm for p-p. In all cases this is (substantially) less than the sum of the radii of the two nucleons.
Does this imply that there is significant overlap of the nucleons? I know that the hard sphere idea is not good at this level as we are well into the quantum realm. I assume that quantum fuzziness is to blame, in which case what is really meant by the radius of a nucleon.
Thanks
Martyn The nuclear diameter is measured in several ways. One is elastic electron scatter which measure the charge distribution, showing that the RMS charge radius is 0.84 - 0.87 fm.
As far as the residual strong nuclear force goes, it is really complicated. It has serval central force term, both repulsive and attractive, the are attributed to various meson exchanges. Spin-orbit coupling, spin-spin, and helicity terms are not perturbative...they're strong. There's also a tensor force, which is non-central, and iso-spin terms that are significant. Finally, there are three and four body interactions that cannot be described as $N$-body central-potential interactions. I would consider these very difficult to explain at the high-school level.
Note also that protons and neutrons don't retain their identity in a nucleus, which has to do with quantum addition of isospin. It makes those pictures of two colored marbles in a ball more deceptive than descriptive. | {
"domain": "physics.stackexchange",
"id": 98696,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "nuclear-physics, education, strong-force",
"url": null
} |
inorganic-chemistry, molecular-orbital-theory, halides
Title: What does the molecular orbital scheme of beryllium chloride and hydride look like? Beryllium is a somewhat fascinating element since it is the only member of the second group that behaves somewhat non-metalish and, e.g. forms a somewhat covalent chloride and a covalent hydride.
In an answer to a different and unrelated question, I tried guessing what the bonding picture of $\ce{BeCl2}$ would be. Given the monomer’s linear shape, I was inclined to assume something that introduces a four-electron-three-centre bond, which has the nice side-advantage of allowing beryllium to contribute to bonding orbitals using its s orbital only. However, I would guess that the more traditional picture would include two $\mathrm{sp^2}$ type bonds to the neighbouring chlorines and then a nonzero amount of π backbonding making the MO similar to that of $\ce{CO2}$.
What does the actual, calculated MO scheme of $\ce{BeCl2}$ look like; what does $\ce{BeH2}$’s look like, how do they compare and what can we learn from them concerning the bonding properties of beryllium? I calculated molecular orbitals for $\ce{BeCl2}$ at MP2/jun-cc-pVDZ level of theory; given below are the doubly occupied MOs at this level of theory along with their symmetry designations and energy in a.u. For some reason my Avogadro kept crashing when I tried to select an iso value I thought appropriate for the last two MOs; anyway these are completely localised $\ce{Be}$ atoms. If we look at the 8 valence orbitals, there is indeed delocalised $\pi$ bonding as you suggest, and do bear a striking resemblance to MOs for $\ce{CO2}$.
For $\ce{BeH2}$ I again ran into trouble generating nice visuals using the cube file in Avogadro. I will update this post with visuals as soon as possible (It would be great if someone can help out). | {
"domain": "chemistry.stackexchange",
"id": 10216,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "inorganic-chemistry, molecular-orbital-theory, halides",
"url": null
} |
random-forest, logistic-regression, class-imbalance, overfitting
My questions are:
Why RF is getting overfit in spite of hyperparameter tuning?
What are the options? There are some options not to overfit your Random Forest Classifier given your observations:
1. Complexity of the Model (Tree Depth)
Check the max_depth parameter in the tuned RF model. A very high value might contribute to overfitting. Consider reducing it to limit the depth of the trees.
2. Number of Trees (n_estimators)
Large values of n_estimators can lead to overfitting. Experiment by reducing the number of trees to find a balance that prevents overfitting while maintaining good performance.
3. Feature Importance and Selection:
Reevaluate the features selected based on RF feature importance. Using too many features may introduce noise. Experiment with a smaller subset to assess its impact on overfitting.
4. Cross-Validation Strategy
Ensure an appropriate cross-validation strategy during hyperparameter tuning. Consider using a stratified k-fold to maintain the class distribution in each fold.
5. Class Imbalance Handling
Despite using class_weight='balanced', class imbalance might still pose a challenge. Try to address the imbalance by using oversampling, undersampling, or advanced techniques like SMOTE.
6. Ensemble Model Calibration
Random Forests can produce overly confident probability estimates. Consider calibration techniques like Platt scaling or isotonic regression. Scikit-learn's CalibratedClassifierCV can be useful for this purpose. | {
"domain": "datascience.stackexchange",
"id": 12004,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "random-forest, logistic-regression, class-imbalance, overfitting",
"url": null
} |
Program to illustrate the working of our solution,
## Example
Live Demo
#include <iostream>
using namespace std;
float calcMeanOfSubarrayMeans(int arr[], int n, int m) {
float meanSum = 0, windowSum = 0;
for (int i = 0; i < m; i++)
windowSum += arr[i];
meanSum += (windowSum / m);
for (int i = 0; i < n; i++) {
windowSum = windowSum - arr[i - m] + arr[i];
meanSum += (windowSum / m);
}
int windowCount = n - m + 1;
return (meanSum / windowCount);
}
int main() {
int arr[] = { 4, 1, 7, 9, 2, 5, 3};
int n = sizeof(arr) / sizeof(arr[0]);
int m = 3;
cout<<"The mean of subarray means is "<<calcMeanOfSubarrayMeans(arr, n, m);
return 0;
}
## Output
The mean of subarray means is 8.06667
Published on 12-Mar-2021 06:40:03 | {
"domain": "tutorialspoint.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446502128796,
"lm_q1q2_score": 0.8049235238786823,
"lm_q2_score": 0.8267118026095991,
"openwebmath_perplexity": 1802.7558896740877,
"openwebmath_score": 0.17297860980033875,
"tags": null,
"url": "https://www.tutorialspoint.com/find-mean-of-subarray-means-in-a-given-array-in-cplusplus"
} |
equilibrium, solutions, vapor-pressure
Mathematically it can be proved that this happens when the rightmost expression is negative. The rightmost expression can be rewritten as
$$P_e \left[\frac {\frac{\frac{A}{A+B}}{P_A^\circ}+\frac{\frac{B}{A+B}}{P_B^\circ}-\frac{1}{P_e}} {\frac{1}{P_A^\circ}+\frac{1}{P_B^\circ}-\frac{1}{P_e}} \right]$$
Let $N$ mean numerator and $D$ mean denominator of this expression. We can prove that $N<D$. This means that $\frac ND >0$ if and only if $N>0$ or $D<0$ holds.
Question 1
Assuming all the calculations are correct, this seems to be a rather arbitrary mathematical condition. Can someone explain the physical significance of this? Like a more intuitive way to understand why we must check such an arbitrary condition rather than something as simple as $P_e>P_A^\circ+P_B^\circ$?
Question 2
If $\frac ND <0$, is the solution always $a=A$, $b=B$ (which means no liquid evaporates)? As you correctly pointed out, you can connect the moles of each compound in the gas phase, $a$ and $b$, to the composition of the liquid phase, $A-a$ and $B-b$, through their partial pressures, $p_A$ and $p_B$:
$p_A=a\cfrac{RT}{V}=p_A^o\cfrac{A-a}{\left(A-a\right)+\left(B-b\right)}$
$p_B=b\cfrac{RT}{V}=p_B^o\cfrac{B-b}{\left(A-a\right)+\left(B-b\right)}$ | {
"domain": "chemistry.stackexchange",
"id": 8428,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "equilibrium, solutions, vapor-pressure",
"url": null
} |
homework-and-exercises, newtonian-mechanics, kinematics, projectile
And it is a straight line!
So that's why when you do the experiment you graph $R$ against $\sin\theta\cos\theta$. It's because the graph should be a straight line. Any deviations away from a straight line will mean either you messed up the experiment or there is some other factor that isn't included in equation (1).
In fact you may well find your graph isn't quite straight. That's because equation (1) doesn't include the effects of air resistance. | {
"domain": "physics.stackexchange",
"id": 17759,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "homework-and-exercises, newtonian-mechanics, kinematics, projectile",
"url": null
} |
# What is the value of $1^z$ for $z\in\mathbb{C}$?
According to Wolfram Alpha, $$1^z=1$$ for $$z\in\mathbb{C}$$. If this is true, then what is wrong with the following argument that $$1^z$$ has infinitely many values?
Let $$z=x+iy$$. Then, \begin{align} 1^z &= 1^{x+iy} \\ &= 1^x \cdot 1^{iy} \\ &= 1^{iy} \\ &= e^{iy\log(1)} \\ \log(1) &= \{0,2i \pi, 4i \pi,6i \pi, \ldots\} \\ 1^z &= \{e^{iy \cdot 0},e^{iy \cdot 2 i \pi},e^{iy \cdot 4 i \pi},e^{iy \cdot 6 i \pi},\ldots\} \\ &= \{e^0,e^{-2y\pi},e^{-4y\pi},e^{-6y\pi},\ldots\} \end{align}
Only one of these values is equal to $$1$$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9748211612253743,
"lm_q1q2_score": 0.8206294569372847,
"lm_q2_score": 0.8418256492357359,
"openwebmath_perplexity": 187.32828315114227,
"openwebmath_score": 0.9997512698173523,
"tags": null,
"url": "https://math.stackexchange.com/questions/3968354/what-is-the-value-of-1z-for-z-in-mathbbc/3968359"
} |
rosjava
Originally posted by kwc with karma: 12244 on 2011-05-13
This answer was ACCEPTED on the original site
Post score: 9
Original comments
Comment by Lorenz on 2011-05-14:
The old implementation has been implemented more than 1 1/2 years ago by Jason Wolfe and not much has changed since then. Right now, the new rosjava implementation is not really integrated into the ROS toolchain yet. As soon as it is, it is pretty likely that we will let the old implementation die.
Comment by baalexander on 2011-05-13:
Thank you Ken for the response and the talk. That clarified things. I'm still a bit curious on how the two ROS implementations will be developed and maintained in the future, but that may be more wait and see. | {
"domain": "robotics.stackexchange",
"id": 5564,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "rosjava",
"url": null
} |
java, strings, programming-challenge, unit-testing, morse-code
static {
morseAlphabet.put("", " ");
morseAlphabet.put(".-", "A");
morseAlphabet.put("-...", "B");
morseAlphabet.put("-.-.", "C");
morseAlphabet.put("-..", "D");
morseAlphabet.put(".", "E");
morseAlphabet.put("..-.", "F");
morseAlphabet.put("--.", "G");
morseAlphabet.put("....", "H");
morseAlphabet.put("..", "I");
morseAlphabet.put(".---", "J");
morseAlphabet.put("-.-", "K");
morseAlphabet.put(".-..", "L");
morseAlphabet.put("--", "M");
morseAlphabet.put("-.", "N");
morseAlphabet.put("---", "O");
morseAlphabet.put(".--.", "P");
morseAlphabet.put("--.-", "Q");
morseAlphabet.put(".-.", "R");
morseAlphabet.put("...", "S");
morseAlphabet.put("-", "T");
morseAlphabet.put("..-", "U");
morseAlphabet.put("...-", "V");
morseAlphabet.put(".--", "W");
morseAlphabet.put("-..-", "X");
morseAlphabet.put("-.--", "Y");
morseAlphabet.put("--..", "Z"); | {
"domain": "codereview.stackexchange",
"id": 21055,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "java, strings, programming-challenge, unit-testing, morse-code",
"url": null
} |
ros, ros2, git, bloom-release
Here are the lines of output of 'bloom-release` :
Release repository url [press enter to abort]: https://github.com/ros2-gbp/wall_follower_ros2-release.git
==> Fetching 'wall_follower_ros2' repository from 'https://github.com/ros2-gbp/wall_follower_ros2-release.git'
Cloning into '/tmp/tmp72wn05ft'...
warning: You appear to have cloned an empty repository.
WARNING [vcstools] Command failed: 'git checkout master'
run at: '/tmp/tmp72wn05ft'
errcode: 1:
error: pathspec 'master' did not match any file(s) known to git
[/vcstools]
Creating 'master' branch.
Creating track 'humble'...
Repository Name:
<name>
Name of the repository (used in the archive name)
upstream
Default value, leave this as upstream if you are unsure
['upstream']: wall_follower_ros2
Upstream Repository URI:
<uri>
Any valid URI. This variable can be templated, for example an svn url
can be templated as such: "https://svn.foo.com/foo/tags/foo-:{version}"
where the :{version} token will be replaced with the version for this release.
[None]: https://github.com/rfzeg/wall_follower_ros2
Upstream VCS Type:
git
Upstream URI is a git repository
hg
Upstream URI is a hg repository
svn
Upstream URI is a svn repository
tar
Upstream URI is a tarball
['git']:
Version:
:{auto}
This means the version will be guessed from the devel branch.
This means that the devel branch must be set, the devel branch must exist,
and there must be a valid package.xml in the upstream devel branch.
:{ask}
This means that the user will be prompted for the version each release.
This also means that the upstream devel will be ignored.
<version>
This will be the version used. | {
"domain": "robotics.stackexchange",
"id": 38147,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros, ros2, git, bloom-release",
"url": null
} |
newtonian-mechanics, statistical-mechanics, virial-theorem, fluctuation-dissipation
Title: Virial theorem for momentum fluctuations In the paper https://journals.aps.org/pr/abstract/10.1103/PhysRev.109.1464 Lebowitz attempted to derive an estimation of the magnitude of center of mass momentum fluctuations in the presence of external confining potential (i.e walls). He considers $N$ classical particles interacting via a pair potential $U(x_{i}, x_{j})$ subject to confining potential (thought of as walls) $V(x_{i})$, thus from
$\dot{p_{i}} = - \sum_{j} \partial_{x_{i}}U(r_{ij}) - \sum_{j} \partial_{x_{i}}V(x_{i})\tag{1}$
he arrives (after several clear, simple and understandable steps) at the relation
$\frac{<P^{2}>}{2M} = \sum_{ij} <x_{i}\partial_{x_{j}}U(x_{j})>\tag{2}$
where <> indicates the time average and $P$ indicates the center of mass momentum. Then he mentions the equivalence of time averages and phase space average but writes without further arguments the following equation
$\frac{<P^{2}>}{2M} = \int dx_{1} x_{1}\partial_{x_{1}}U(x_{1}) + \int \int dx_{1} dx_{2} x_{1}\partial_{x_{2}}U(x_{2})\rho(x_{1}, x_{2})\tag{3}$ | {
"domain": "physics.stackexchange",
"id": 98203,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "newtonian-mechanics, statistical-mechanics, virial-theorem, fluctuation-dissipation",
"url": null
} |
c
shiftOut(DAT,CLK,MSBFIRST,leds4>>8);
shiftOut(DAT,CLK,MSBFIRST,leds5);
//! output_bit(LAT, HIGH);
//! output_bit(LAT, LOW);
LATA2 = 1; //FASTER THAN OUTPUT_BIT
LATA2 = 0; //FASTER THAN OUTPUT_BIT
} | {
"domain": "codereview.stackexchange",
"id": 24863,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c",
"url": null
} |
arithmetic, binary
Title: Calculating direct sum of 2 binary numbers If we have say,key=‘0110‘ and =‘1100‘, how will ⊕key mod 2 be calculated and what will be the answer equal to? The operation $\oplus$ is the same as bitwise XOR. The same symbol is used for direct sum, but there is otherwise absolutely no relation. | {
"domain": "cs.stackexchange",
"id": 16033,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "arithmetic, binary",
"url": null
} |
go, caesar-cipher, casting
Title: Byte conversion in my Caesar's cipher I was wondering if I am doing any useless conversions byte←→int, for example:
byte((int(ch-'A')+shift)%26 + 'A')
Converting ch-'A' to an int is because the shift argument can be negative (to implement the decode function). I couldn't figure out a simpler way to negate the operation using bytes.
package main
import (
"bufio"
"flag"
"fmt"
"os"
)
func main() {
shift := flag.Int("shift", 13, "Cipher shift")
decode := flag.Bool("decode", false, "Decode input")
flag.Parse()
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
if *decode {
fmt.Println(Decode(scanner.Text(), *shift))
} else {
fmt.Println(Encode(scanner.Text(), *shift))
}
}
}
func Encode(s string, shift int) string {
return cipher(s, shift)
}
func Decode(s string, shift int) string {
return cipher(s, -shift+26)
}
func cipher(s string, shift int) string {
var line string
for _, ch := range []byte(s) {
if ch >= 'A' && ch <= 'Z' {
ch = byte((int(ch-'A')+shift)%26 + 'A')
} else if ch >= 'a' && ch <= 'z' {
ch = byte((int(ch-'a')+shift)%26 + 'a')
}
line += string(ch)
}
return line
} Flags
It's not very problematic for very short programs like this, but better get good habits: flags should be outside of all code blocks; so that you detect immediately if you have a flag naming conflict between different files.
var (
shiftF = flag.Int("shift", 13, "Cipher shift")
decodeF = flag.Bool("decode", false, "Decode input")
)
func main() {
…
} | {
"domain": "codereview.stackexchange",
"id": 23307,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "go, caesar-cipher, casting",
"url": null
} |
-
I think the equation (*) together with the boundary conditions $F(x\leq -1)=0$ and $F(x\geq 1)=1$ determines the cdf $F$ uniquely. – Fabian Apr 10 '12 at 20:20
Remotely related is the Fabius random variable (see wiki). – Sasha Apr 10 '12 at 20:25
It can be shown easily that $F(0)=1/2$, $F(1/2)=5/6$, $F(-x)=1-F(x)$. – Fabian Apr 10 '12 at 20:32
$F(1/4)=2/3$, $F(1/3)=8/11$, $F(2/3)=10/11$, $F(3/4)=17/18$, ... The values of $F$ for rational arguments can be obtained recursively (but I did not yet figure out an explicit formula). – Fabian Apr 10 '12 at 20:48
For $x=-1+2^{-k}$ you can get that $F(x)=\frac{1}{2(3^k)}$. The first $k$ have to be negative, and then half of those end up on the left. Thus, for small $\epsilon$, $F(-1+\epsilon)$ is roughly $\frac{1}{2}\epsilon^{\log_2 3}$. – Thomas Andrews Apr 10 '12 at 20:59
This is more of a comment, than an answer, yet it's too big, and graphics can't be used in comments. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9715639686018701,
"lm_q1q2_score": 0.8634860233980102,
"lm_q2_score": 0.8887587964389112,
"openwebmath_perplexity": 1359.0535747279775,
"openwebmath_score": 0.5641429424285889,
"tags": null,
"url": "http://math.stackexchange.com/questions/130159/what-is-the-distribution-of-this-random-series"
} |
(2) In many versions of poker each player's hand consists of five supposedly randomly chosen cards. A poker player would be delighted to find all four Aces in his/her hand. But the probability of that is even smaller than your probability: $1.847 \times 10^{-5}.$
dhyper(4, 4, 48, 5)
## 1.846893e-05
(3) If you sample the ten cards with replacement, then the number $Y$ of Aces in ten independent draws has $Y \sim \mathsf{Binom}(10, 1/13).$ Then $P(Y = 4) = 0.004548553.$ This is larger than your probability because the Aces don't get "used up" as they get chosen. (Each Ace could possibly be chosen more than once.)
dbinom(4, 10, 1/13)
## 0.004548553
• So the chance of getting at least 1 ace is higher than having no aces at all? – steenbergh Jun 19 '18 at 7:47
• Seems so...by a smidge. That's when 10 cards are drawn. But that's not true for a 5-card poker hand: dhyper(0:1, 4, 48, 5) returns 0.6588420 for no Ace and 0.2994736 for one Ace. – BruceET Jun 19 '18 at 7:58
Note that we pick the ten cards without "putting them back", so the space $\Omega$ is the set of all subsets with ten elements of $\Omega_0=\{1,2,\dots,52\}$. This is not the cartesian product $\Omega_0^{\times 10}$. (Which allows repetitions, and also knows the order the ten cards came to the hand.)
Our convention is to always sort the hand. (First w.r.t values, than w.r.t. colors.) And the aces are last after sorting. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9830850852465429,
"lm_q1q2_score": 0.8149173728111279,
"lm_q2_score": 0.8289388019824946,
"openwebmath_perplexity": 813.3111594185553,
"openwebmath_score": 0.931822657585144,
"tags": null,
"url": "https://math.stackexchange.com/questions/2824392/choosing-10-cards-randomly-from-a-52-card-deck/2824414"
} |
$\text{ }$
With a deductible in the policy, the following is the expected amount of loss eliminated (from the insurer’s point of view).
\displaystyle \begin{aligned}E[X \wedge d]&=E(X)-E[(X-d)_+] \\&=\frac{2}{\alpha}-e^{-\alpha d} \ \biggl(\frac{2}{\alpha}+d\biggr) \\&=\frac{2}{\alpha}\biggl(1-e^{-\alpha d}\biggr)-d e^{-\alpha d} \end{aligned}
$\text{ }$
Example 3
Suppose the loss variable $X$ has a Pareto distribution with the following pdf:
$\text{ }$
$\displaystyle f_X(x)=\frac{\beta \ \alpha^\beta}{(x+\alpha)^{\beta+1}} \ \ \ \ \ x>0$
$\text{ }$
If the insurance policy is to pay the full loss, then the insurer’s expected payment per loss is $\displaystyle E(X)=\frac{\alpha}{\beta-1}$ provided that the shape parameter $\beta$ is larger than one.
The mean excess loss function of the Pareto distribution has a linear form that is increasing (see the previous post The Pareto distribution). The following is the mean excess loss function:
$\text{ }$
$\displaystyle e_X(d)=\frac{1}{\beta-1} \ d +\frac{\alpha}{\beta-1}=\frac{1}{\beta-1} \ d +E(X)$
$\text{ }$
If the loss is modeled by such a distribution, this is an uninsurable risk! First of all, the higher the deductible, the larger the expected payment if such a large loss occurs. The expected payment for large losses is always the unmodified expected $E(X)$ plus a component that is increasing in $d$. | {
"domain": "wordpress.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9893474904166245,
"lm_q1q2_score": 0.8111594208263365,
"lm_q2_score": 0.8198933425148214,
"openwebmath_perplexity": 262.62715424159506,
"openwebmath_score": 0.9560127854347229,
"tags": null,
"url": "https://statisticalmodeling.wordpress.com/tag/probability-and-statistics/"
} |
bash
git remote add godaddy $user1@foo.com:~/root.git
git remote add heroku https://git.heroku.com/frozen-dusk-2587.git
echo "Git configured."
}
config_grunt() {
sudo npm install -g grunt-cli
mkdir ~/root_install/grunt
ln -s ~/root/config/grunt/package.json ~/root_install/grunt/package.json
ln -s ~/root/config/grunt/Gruntfile.js ~/root_install/grunt/Gruntfile.js
cd ~/root_install/grunt
npm install
cd ~/root
echo "Grunt configured."
}
config_sublime_2() {
ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl
rm -rf ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/User
ln -s ~/root/config/sublime ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/User
echo "Sublime configured."
}
reset_sublime_2() {
rm -rf ~/Library/Application\ Support/Sublime\ Text\ 2
}
config_chrome(){
chmod 0444 ~/Library/Application\ Support/Google/Chrome/Default/History
echo "Chrome configured."
}
config_all() {
config_bash
config_git
config_grunt
config_sublime_2
config_chrome
list
}
list(){
local a=$(which bash) b=$(which git) c=$(which grunt) d=$(which subl)
local g=$(which node) i=$(which heroku)
echo "****"
echo "Your bash executble is here: $a."
echo "Your git executble is here: $b."
echo "Your grunt executble is here: $c."
echo "Your sublime executble is here: $d." | {
"domain": "codereview.stackexchange",
"id": 18890,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "bash",
"url": null
} |
c++, c++11, iterator
for (auto const i : range(0, 100))
std::ctype<char>::do_widen(char) const:
mov eax, esi
ret
main:
push r12
push rbp
xor ebp, ebp
push rbx
jmp .L6
.L14:
movsx esi, BYTE PTR [rbx+67]
.L5:
mov rdi, r12
add ebp, 1
call std::basic_ostream<char, std::char_traits<char> >::put(char)
mov rdi, rax
call std::basic_ostream<char, std::char_traits<char> >::flush()
cmp ebp, 100
je .L12
.L6:
mov esi, ebp
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream<char, std::char_traits<char> >::operator<<(int)
mov r12, rax
mov rax, QWORD PTR [rax]
mov rax, QWORD PTR [rax-24]
mov rbx, QWORD PTR [r12+240+rax]
test rbx, rbx
je .L13
cmp BYTE PTR [rbx+56], 0
jne .L14
mov rdi, rbx
call std::ctype<char>::_M_widen_init() const
mov rax, QWORD PTR [rbx]
mov esi, 10
mov rax, QWORD PTR [rax+48]
cmp rax, OFFSET FLAT:std::ctype<char>::do_widen(char) const
je .L5
mov rdi, rbx
call rax
movsx esi, al
jmp .L5
.L12:
pop rbx
xor eax, eax
pop rbp
pop r12
ret
.L13:
call std::__throw_bad_cast()
sub rsp, 8
mov edi, OFFSET FLAT:std::__ioinit | {
"domain": "codereview.stackexchange",
"id": 18637,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, c++11, iterator",
"url": null
} |
homework-and-exercises, newtonian-mechanics, friction, vectors, angular-velocity
$$\vec{p} = {\rm Rot}(\hat{y}, \theta) \begin{pmatrix} r \sin \psi \\ 0 \\ r \cos \psi \end{pmatrix} = \begin{pmatrix} r \sin \psi \cos \theta \\ r \cos \psi \\ -r \sin \psi \sin \theta \end{pmatrix} $$
In the above the angle $\psi$ is fixed and $r$, $\theta$ are variable. Hence
$$ \vec{v} = \dot{\vec{p}} = \frac{\partial \vec{p}}{\partial r} \dot{r} + \frac{\partial \vec{p}}{\partial \theta} \dot{\theta} \\
\vec{v} ={\rm Rot}(\hat{y}, \theta) \begin{pmatrix} \dot{r} \sin \psi \\ \dot{r}\cos\psi \\ -r \dot{\theta} \sin \psi \end{pmatrix} = \begin{pmatrix}
\sin\psi (\dot{r} \cos\theta - r \dot{\theta} \sin \theta)
\\ \dot{r} \cos \psi
\\ -\sin\psi (\dot{r} \sin \theta + r \dot{\theta} \cos\theta ) \end{pmatrix}$$
Similarly
$$ \vec{a} = {\rm Rot}(\hat{y}, \theta) \begin{pmatrix}
\sin\psi (\ddot{r}-r \dot{\theta}^2) \\
\ddot{r} \cos\psi \\
-\sin\psi(r \ddot{\theta}+2 \dot{r} \dot{\theta}) \end{pmatrix} $$ | {
"domain": "physics.stackexchange",
"id": 16929,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "homework-and-exercises, newtonian-mechanics, friction, vectors, angular-velocity",
"url": null
} |
ros, frame, solidworks
<geometry>
<mesh filename="package://wrist/meshes/5_1.stl" />
</geometry>
</collision>
</link>
<joint name="5_1" type="fixed">
<origin xyz="-0.04 0 0.052" rpy="-1.5707963267949 0 1.5707963267949" />
<parent link="4_1" />
<child link="5_1" />
<axis xyz="0 0 0" />
</joint>
<link name="5_2">
<inertial>
<origin xyz="-6.93889390390723E-18 0.00555624047115352 0.00850000000000001" rpy="0 0 0" />
<mass value="0.0736873670600792" />
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://wrist/meshes/5_2.stl" />
</geometry>
<material name="">
<color rgba="0.941176470588235 0.674509803921569 0.117647058823529 1" />
</material>
</visual>
<collision>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://wrist/meshes/5_2.stl" />
</geometry>
</collision>
</link>
<joint name="5_2" type="fixed"> | {
"domain": "robotics.stackexchange",
"id": 26363,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros, frame, solidworks",
"url": null
} |
organic-chemistry, nmr-spectroscopy
Title: Why do the splittings in mirrored COSY crosspeaks differ? I have a COSY spectrum of a mixture of butanal and butyl bromide and I don't understand why the cross-peaks have various/different splitting on the other sides of the diagonal. I think it may have something to do with polarisation transfer but I'm not sure.
Let's focus for now on the two circled crosspeaks. In a COSY sequence, the frequency in the indirect dimension (the vertical axis) corresponds to the spin which the magnetisation is on during the $t_1$ period. The frequency in the direct dimension (horizontal axis) corresponds to the spin which you measure the magnetisation of during $t_2$.
It turns out that these crosspeaks are from butanal, so let's also colour-code the protons in butanal as follows: we have $\ce{C\color{red}{H}_3-C\color{blue}{H}_2-C\color{green}{H}_2-CHO}$.
The red crosspeak occurs at ~1.65 ppm in the indirect dimension, and ~0.95 ppm in the direct dimension. This means that the magnetisation during $t_1$ was on the blue $\ce{C\color{blue}{H}_2}$ proton, and was subsequently transferred to the red
$\ce{C\color{red}{H}_3}$ proton during acquisition (in $t_2$). The coupling between these two sets of protons is referred to as an active coupling; it is the coupling that is responsible for generating the crosspeak. | {
"domain": "chemistry.stackexchange",
"id": 13529,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "organic-chemistry, nmr-spectroscopy",
"url": null
} |
algorithms, optimization, approximation, heuristics, packing
Suppose the items used in step 1 are $h_1,\cdots, h_n$ in order and the rest items from small to big are $t_1,\ldots,t_m$. We have $t_1\le\cdots\le t_m\le h_n\le\cdots \le h_1$. Suppose bin $b_i$ has a space of $s_i$ that are not used. Recall that we assume each of $b_1,\ldots,b_{n-1}$ contains at least two items. We have $s_1+\cdots+s_{n-1}<t_1+\cdots+t_m+h_n$ due to step 2 of your algorithm, thus $s_1+\cdots+s_n<t_1+\cdots+t_m+1$. Note $s_1+\cdots+s_n+t_1+\cdots+t_m+h_1+\cdots+h_n=n$ and $s_i<h_{i+1}$ for $i<n$, we have $s_1+\cdots+s_n<(n+2)/3$. This means $\mathrm{ALG} \le (3/2) \mathrm{OPT} + 1$.
On the other hand, consider an instance with the following items (from small to large), where $\epsilon$ is a small number:
$$
\left\{\frac{1}{3}-6^k\epsilon,~~\frac{1}{3}-6^{k-1}\epsilon,~~\frac{1}{3}-6^{k-1}\epsilon, ~~ \text{ for } k = n, n-1,\ldots, 1\right\},
\\
\frac{1}{3}-\epsilon,
\\ | {
"domain": "cs.stackexchange",
"id": 18805,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "algorithms, optimization, approximation, heuristics, packing",
"url": null
} |
python, beginner, game, python-2.x, number-guessing-game
rounds +=1
if rounds == 5:
if player_wins > computer_wins:
console.set_color(0.00, 0.00, 1.00)
print '\nYOU WON THE GAME'
console.set_color(0.00, 0.00, 0.00)
break
elif computer_wins > player_wins:
console.set_color(1.00, 0.00, 0.00)
print '\nYOU LOST THE GAME'
console.set_color(0.00, 0.00, 0.00)
break
else:
print "Wrong counts" I think the biggest thing here is that you need to create some functions and encapsulate stuff.
Big Points
Use reusable functions, especially when you find yourself copy-and-pasting code.
Don't hardcode anything; use constants rather than "magic numbers".
Don't use global variables.
Wrap it in a main().
Specifics
The minimum and maximum can be constants.
MINIMUM = 0
MAXIMUM = 1000
... Then, all you have to do is change these variables if you want to modify the game in the future:
number = random.randint(MINIMUM, MAXIMUM)
player_guess = input('\nPlayer: ')
computer_guess = random.randint(MINIMUM, MAXIMUM)
Break up the big multi-line message at the beginning rather than having it stretch on for 200 characters. (Purists will still say that the implemenation below has the second line too long, as the Python standard is to have no line exceeding 80 characters, but you get the idea.)
print 'Welcome to the guessing game!'
print 'A number will be randomly chosen from ' + str(MINIMUM) + ' to ' + str(MAXIMUM)
print 'The player will make a guess, and then the computer will guess.'
print 'Whoever is closest wins that round!'
print 'First to 5 wins!'
You can have run_again directly store whether or not to run again (i.e., a boolean value) rather than a character. This lets you check directly against it:
run_again = True
// ... then, elsewhere ...
if run_again:
//do stuff | {
"domain": "codereview.stackexchange",
"id": 7345,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, beginner, game, python-2.x, number-guessing-game",
"url": null
} |
# Higher dimensional real matrix representation of imaginary unit?
The imaginary unit can be represented as real 2x2 matrix :
$$i = \begin{pmatrix} 0 & -1 \\ 1 & 0\\ \end{pmatrix},\, i^2 = \begin{pmatrix} -1 & 0 \\ 0 & -1\\ \end{pmatrix}$$
(see https://en.wikipedia.org/wiki/Imaginary_unit#Matrices). Now from my shallow knowledge of group representation theory I believe that it should also be possible to find higher dimensional real representations of $$i$$. I tried to find a 3x3 representation, which is basically asking if there is matrix square root like
$$\sqrt{\begin{pmatrix} -1 & 0 & 0 \\ 0 & -1 & 0\\0 & 0 & -1 \end{pmatrix}} \sqrt{\begin{pmatrix} -1 & 0 & 0 \\ 0 & -1 & 0\\0 & 0 & -1 \end{pmatrix}} = \begin{pmatrix} -1 & 0 & 0 \\ 0 & -1 & 0\\0 & 0 & -1 \end{pmatrix}$$
but couldn't find any (by try and error). Nevertheless I was able to find a 4x4 matrix which can be used as representation of $$i$$:
$$\begin{pmatrix} 0 & -1 & 0 & 0\\ 1 & 0 & 0 & 0\\0& 0 & 0 & -1\\ 0 & 0 & 1 & 0 \end{pmatrix}\begin{pmatrix} 0 & -1 & 0 & 0\\ 1 & 0 & 0 & 0\\0& 0 & 0 & -1\\ 0 & 0 & 1 & 0 \end{pmatrix} = \begin{pmatrix} -1 & 0 & 0 & 0 \\ 0 & -1 & 0 & 0\\0 & 0 & -1 & 0 \\ 0 & 0 & 0 & -1 \end{pmatrix}$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9857180652357771,
"lm_q1q2_score": 0.8378319390292432,
"lm_q2_score": 0.8499711718571775,
"openwebmath_perplexity": 164.10184065307018,
"openwebmath_score": 0.9290564060211182,
"tags": null,
"url": "https://math.stackexchange.com/questions/2946288/higher-dimensional-real-matrix-representation-of-imaginary-unit/2946485"
} |
rust
We can now remove Clone, but need to accept an owned ParamType rather than a reference (as in your new code) since we need an owned value to insert into the cache. | {
"domain": "codereview.stackexchange",
"id": 42626,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "rust",
"url": null
} |
velocity, orbital-mechanics, escape-velocity
Title: Is the radius used in the formula for the escape velocity the average radius of the celestial object or the radius at the starting location? I learnt that the escape velocity is given by $$v_e = \sqrt{\frac{2GM}{r}}$$
Say I want to launch a rocket from the earth into space and want to calculate the escape velocity $v_e$ (I guess without air resistance). Which value of $r$ do I have to use:
The mean radius of the earth...
... or the distance between the center of mass of the earth and the launch location?
Thanks in advance.
(I have basic classical (and quantum) mechanics knowledge, but I am very new to orbital mechanics.) Just to provide an official answer, the radius $r$ in that equation is formally the distance between the center of masses between the two objects. That does come with some assumptions of course, but for most standard physics problems that concept is perfectly fine. As you stated, the equation does not assume anything about air resistance, and to extend that, it does not assume anything about continued propulsion. If you're at some radius $r$ from the center of the Earth and you have some velocity $v>v_e$, then just coasting along in your trajectory will allow you to eventually escape the Earth's gravitational pull (ignoring the obvious case where you intersect the Earth with your trajectory). | {
"domain": "astronomy.stackexchange",
"id": 1711,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "velocity, orbital-mechanics, escape-velocity",
"url": null
} |
By the Inscribed Angle Theorem, moving a vertex around the circle preserves the angle at that vertex. Now, suppose that, at stage $i$, the apex angle is $\theta_i$, so that the base angles are $\frac12(\pi - \theta_i)$. But this apex angle was the base angle of the previous step, giving this recurrence $\theta_{i} = \frac12(\pi-\theta_{i-1})$. Thus, \begin{align}\theta_n &= -\frac12\theta_{n-1} + \frac12\pi \\[6pt] &=\frac12\left(-\frac12(\pi-\theta_{n-2})+\pi\right) = \frac14\theta_{n-2}+\frac12\pi-\frac14\pi \\[6pt] &= \cdots \\[6pt] &= \left(-\frac12\right)^{n}\theta_0 \;-\; \sum_{i=1}^n\left(-\frac12\right)^{n}\pi \\[6pt] \lim_{n\to\infty}\theta_n &= 0\cdot\theta_0 \;-\; \frac{(-1/2)}{1-(-1/2)}\pi \\ &=\frac{\pi}{3} \end{align}
Thus, in the limit, the triangle becomes equilateral. $\square$
Assume WLOG that the initial triangle is isoceles. Let $\alpha$ be the apical angle, and let $\beta$ be a remaining angle. Then the transformation in question sends | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9905874123575265,
"lm_q1q2_score": 0.8803932822118514,
"lm_q2_score": 0.8887588023318195,
"openwebmath_perplexity": 510.64152811170686,
"openwebmath_score": 0.980134129524231,
"tags": null,
"url": "https://math.stackexchange.com/questions/2920725/is-the-limit-of-this-infinite-step-construction-an-equilateral-triangle"
} |
PhysOrg.com science news on PhysOrg.com >> Hong Kong launches first electric taxis>> Morocco to harness the wind in energy hunt>> Galaxy's Ring of Fire
Blog Entries: 5 Recognitions: Homework Help Science Advisor There are the following possibilities: All columns are independent The first and the second are dependent, but independent of the third The first and the third are dependent, but independent of the second The second and the third are dependent, but independent of the first All of them are dependent Or, if you prefer, you can do this with the rows. Now for each case, you can write down an equation and solve it for a. For example,let me do the third case (first and third are dependent, but independent of the second). If the third column is a multiple n of the first one, you must have 1 = n a -2 = 2 n a = n 1 From the second equation you see that there is just one possibility for n. Then you get a solution for a from one of the others. Finally, use the remaining equation to see if this value indeed satisfies all of them. Then plug this value into the 4a in the second column, and check that it is indeed independent of the first (and/or third) | {
"domain": "physicsforums.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9770226347732859,
"lm_q1q2_score": 0.8120455766217529,
"lm_q2_score": 0.831143054132195,
"openwebmath_perplexity": 281.90943767148,
"openwebmath_score": 0.555281400680542,
"tags": null,
"url": "http://www.physicsforums.com/showthread.php?t=222658"
} |
My attempt at this is as follows:
$y = e^{-2x} \Rightarrow \log y = -2x \Rightarrow x = \frac{\log y}{-2}$
Which means $$W(t) = \pi \int_{e^{-2t}}^1 \left(\frac{\log y}{-2}\right)^2 dy$$ $$= \frac{\pi}{4}\int_{e^{-2t}}^1 \left(\log y \right)^2 dy$$ $$= \frac{\pi}{4} \left[y(\log y)^2 - 2y(\log y -1)\right]_{e^{-2t}}^1$$ $$= \frac{\pi}{4} \left( (1(\log 1)^2 -2\cdot 1(\log 1 -1)) - (e^{-2t}(\log e^{-2t})^2-2e^{-2t}(\log e^{-2t}-1))\right)$$ $$= \frac{\pi}{4} \left(2 - (4t^2e^{-2t}+4te^{-2t}+2e^{-2t})\right)$$ $$= \frac{\pi}{4} \left(2 - 2e^{-2t}(2t^2+2t+1)\right)$$ $$= \frac{\pi}{2}\left(1-e^{-2t}(2t^2+2t+1)\right)$$ which is where I have my issue since the answer in the back of the book is $\frac{\pi}{2}\left(1-e^{-2t}(2t+1)\right)$, so either the book is wrong or I am wrong. If anyone can shed some light on this that would be appreciated | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.988491849579606,
"lm_q1q2_score": 0.8011517977393079,
"lm_q2_score": 0.8104789109591832,
"openwebmath_perplexity": 84.59653326784915,
"openwebmath_score": 0.9334201216697693,
"tags": null,
"url": "https://math.stackexchange.com/questions/934772/problem-with-volume-of-solid-of-revolution"
} |
c#, meta-programming, rubberduck
The statement:
statement.children.Count(i => i is VBAParser.VariableSubStmtContext) > 1
Can be written as:
statement.children.OfType<VBAParser.VariableSubStmtContext>().Count() > 1
GetParameterDefinition()
Could be renamed to CreateParameterDefinition() or DefineParameterDefinition(). You are returning something that doesn't exist in the target code, so ,in my opinion, it shouldn't be a Get...().
HasMultipleDeclarationsInStatement()
Can be moved to Declaration.
Wrap lists in types
The field
IList<Declaration> _declarations
Could be wrapped inside of a DeclarationList or DeclarationCollection and the related methods could be moved over there. | {
"domain": "codereview.stackexchange",
"id": 17554,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c#, meta-programming, rubberduck",
"url": null
} |
rectangular form is a online... In rectangular form an easy to use calculator that converts a number in its alternative form, vice-versa... = 3 \csc \theta # into rectangular form of # x^2 + y^2 2x! Substitutions can be used using this website, you can tell your TI-89 to display results inrectangular or polar to!, Specialist accountants to the nearest hundredth to enter the value of is and the value: 7.81∠39.8° polar! & press < enter > to obtain terms so that the rectangular-polar substitutions be! Is 6 Specialist accountants to the medical profession retangular and polar form to rectangular is. Simplify complex expressions using algebraic rules step-by-step this website, you have your calculator to display,! [ /latex ] See and there 's also a graph which shows you the meaning of what 've! Any complex expression, with steps shown x^2 + y^2 = 2x # display results, you can your! Creates a discontinuity as moves across the negative real axis modulus and argument of the complex number to use that... Also a graph which shows you the meaning of what you 've found your! Manipulate the equation for the given values equivalent value in polar form to rectangular form to rectangular form +,. The polar form by setting the mode ( below ) Home / Resources Tax! To be in the interval also a graph which shows you the meaning what... Use the form a member of our team our team notation: polar and rectangular using. You agree to our Cookie Policy polar formor amixture and polar form '' widget for your website, you alwaysenter... Tell your TI-89 to display results inrectangular or polar form ( below.! Sin θ need r cos θ and r sin θ + bi general you. - Simplify complex expressions using algebraic rules step-by-step this website uses cookies to ensure you get the best experience member. We can convert the answer to rectangular form cos θ and r sin θ the medical.. A callback form a member of our team a unique polar form by setting the mode below! The polar-rectangular relationships we need r cos θ and r sin θ integer multiple of in its alternative,... An easy to use calculator that allows you to easily convert complex | {
"domain": "elab.is",
"id": null,
"lm_label": "1. Yes\n2. Yes\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9759464499040092,
"lm_q1q2_score": 0.8352648939113813,
"lm_q2_score": 0.8558511524823263,
"openwebmath_perplexity": 1342.5111164313003,
"openwebmath_score": 0.7379550337791443,
"tags": null,
"url": "https://elab.is/nm37u/cis-to-rectangular-form-calculator-646a7e"
} |
c++, mergesort
Merge
void mergeOutOfPlace(int *arr, int first, int mid, int last) {
// Merges two contigous sub-arrays and sorts them out-of-place
// Condition Required: Sub-arrays must be sorted individually
int *l = new int [mid-first];
int *r = new int [last-mid];
int *tempArr = new int [last-first];
// copying into new arrays
for (int i=0, j=first; i<mid-first; ++i, ++j) {
l[i] = arr[j];
}
for (int i=0, j=mid; i<last-mid; ++i, ++j) {
r[i] = arr[j];
}
// merge
for(int i=0, j=0, k=0; k<last-first; ++k) {
if (i == mid-first) {
tempArr[k] = r[j++];
}
else if (j == last-mid) {
tempArr[k] = l[i++];
}
else {
(l[i] < r[j]) ? (tempArr[k] = l[i++]) : (temp[k] = r[j++]);
}
}
// copy into original array
for(int i=first, j=0; j<last-first; ++i, ++j) {
arr[i] = tempArr[j];
}
delete[] l;
delete[] r;
delete[] tempArr;
}
Main
int main() {
int size = 15, arr[] = {14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
print(arr, size);
mergeSortBottomUp(arr, 0, size, size);
print(arr, size);
_getch();
return 0;
}
Output | {
"domain": "codereview.stackexchange",
"id": 13291,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, mergesort",
"url": null
} |
mechanical-engineering, gears, friction, transmission
Title: Inertia and friction between gears I have a question regarding inertia and friction between gears.
I have a gear which is connected to the rod at one end and an electric motor which is connected to the other end. I know the torque of the rod and I want to calculate the torque of the motor I need.
I have been told that I can't lay on transmission ration only and I also have to include the calculations of the inertia and friction between gears.
Can please someone explain me how should I do it (every example will appreciated). To turn your gear from rest, you'll need to overcome the inertia of your entire system (rod and gear).
Torque = inertia x angular acceleration. You'll need to figure out what angular (rotational) acceleration you need/can get from your motor. You can approximate inertia with I = (1/2) x mass x radius^2.
You can approximate gears being 95% efficient if you're using spur gears (straight teeth). This means 5% of the energy put in is being lost as friction.
So your required motor torque = (operating torque + acceleration torque)/ 0.95 efficiency [friction]. | {
"domain": "engineering.stackexchange",
"id": 3183,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "mechanical-engineering, gears, friction, transmission",
"url": null
} |
homework-and-exercises, astronomy, orbital-motion, time, estimation
Title: How many minutes in a year? I knew that there were $365.25$ days in a year (ish) but we only have $365$ on calendars, that's why we have February 29. I then learned in class about the sidereal and solar day; sidereal being $23$ hours and $56$ minutes, and solar being $24$.
When we say "$365.25$ days" which day are we talking about (sidereal or solar)?
My teacher said that the $4$ minutes we gain from the solar day being longer than the sidereal day caused the $0.25$ (ish) more, which causes February 29. I do not see how being $4$ minutes ahead each day already means that we need to add even more time. Surely the $4$ minutes each day, that adds up to $24.3$ hours extra each year, means that we must remove a day every single year, not add one.
What does being $4$ minutes ahead/behind mean for the year? There seems to be some confusion. The number of solar days in a year differs from the number of sidereal days in year by 1--that difference of course being due the 1 revolution around the sun per year influencing the solar day.
Back to the number of days in a year: Baring tidal resonances, there is no reason for the length of a day to be commensurate with length of year; it is what is it: 365.2425
I remember this as follows:
365 day in the year
+1/4 A leap year every 4 years
-1/100 Except on years ending in "00"
+1/400 Unless the year is divisible by 400 (e.g. Y2K)
365.2425
so that 2000 was a leap-leap-leap year. | {
"domain": "physics.stackexchange",
"id": 38907,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "homework-and-exercises, astronomy, orbital-motion, time, estimation",
"url": null
} |
• There's clearly a problem though if $U:\mathsf {Field}\to \mathsf {Set}$ is the forgetful functor then there is no left adjoint even though Field a category of "sets-with-algebraic-structure". Could you explain this? – Matthew Levy Apr 2 '15 at 5:59
• Personally, my conclusion is that fields are not sets with algebraic structure. And sure enough, in the definition of field, there is a non-algebraic axiom. (An algebraic axiom is a (universally quantified) equation.) – Zhen Lin Apr 2 '15 at 7:48
• How are they not sets with algebraic structure? They are just a subcategory of $\mathsf {Ring}$ where each object contains all multiplicative inverses besides for $0$. – Matthew Levy Apr 3 '15 at 5:29
• If I were being more precise I'd say that given any algebraic theory $\mathbb{T}$ the forgetful functor $U : \mathsf{Mod}_{\mathbb{T}} \to \mathsf{Set}$ from the category of models of $\mathbb{T}$ has a left-adjoint. The theory of fields is not algebraic, regardless of whether it's a subcategory of $\mathsf{Ring}$. (See, for example, Ch 3 in Borceux vol 2 for way more detail than I can fit into these comments.) – Clive Newstead Apr 3 '15 at 15:28
Of course, the algebraic intuition should be the one given by Clive Newstead. However, it might be worth noting that your problem is in fact an instance of something more general. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9609517083920618,
"lm_q1q2_score": 0.8049123425388484,
"lm_q2_score": 0.8376199714402813,
"openwebmath_perplexity": 305.27625241156187,
"openwebmath_score": 0.9867250323295593,
"tags": null,
"url": "https://math.stackexchange.com/questions/1216535/adjoint-functor-to-an-r-algebra-only-remembering-itself-as-a-ring"
} |
mass, terminology, moment-of-inertia, moment
relates the torque and angular acceleration:
$${\bf \vec{\tau}}={\bf \overleftrightarrow I}\dot{\bf \omega} $$ | {
"domain": "physics.stackexchange",
"id": 47202,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "mass, terminology, moment-of-inertia, moment",
"url": null
} |
python, numpy
>>> make_test()
>>> import os
>>> os.stat('targets.csv').st_size
270000000
That's 270 megabytes of data, and it loads fine for me:
>>> import csv, numpy as np
>>> targets = np.array([(float(X), float(Y), float(Z)) for X, Y, Z in csv.reader(open('targets.csv'))])
>>> targets.shape
(10000000, 3)
So I don't really know what is going wrong for you. Can you provide the exact text of the error message and its traceback? There might be more information there.
Regardless of the cause of the MemoryError, Janne is right to suggest that using numpy.loadtxt to get the data directly from the file (with no intermediate Python list) would be better:
targets = np.loadtxt('targets.csv', delimiter=',')
However, numpy.loadtxt is still quite slow, and if this is a bottleneck for you then you should investigate pandas:
>>> from timeit import timeit
>>> timeit(lambda:np.loadtxt('targets.csv', delimiter=','), number=1)
18.912313379812986
>>> import pandas
>>> timeit(lambda:pandas.read_csv('targets.csv', delimiter=',').values, number=1)
0.5977518488653004
2. Other comments on your code
The PPM format specification says that width is given before height, but you have:
ppm.write("P3" + "\n" + str(height) + " " + str(width) +"\n" + "255" + "\n") | {
"domain": "codereview.stackexchange",
"id": 6044,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, numpy",
"url": null
} |
molecular-biology, molecular-genetics, translation, mrna, trna
On the basis of geometry Crick predicted that anticodon 5′-U might be able to pair with a codon 3′-G (in addition to the standard A), and anticodon 5′-G with codon 3′-U (in addition to the standard C). He — unwisely in my opinion — referred to these predictions (and his prediction for inosine, I) as ‘rules’. The predictions are summarized below, together with the actual pattern that has since emerged. | {
"domain": "biology.stackexchange",
"id": 9619,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "molecular-biology, molecular-genetics, translation, mrna, trna",
"url": null
} |
# Math Help - Trapezoid Rule help?
1. ## Trapezoid Rule help?
So for this question: http://i57.tinypic.com/15i2m2o.jpg
I'm having trouble because I get a triangle instead of a trapezoid for the first trapezoid. Because It starts with (0,0). What should I do? What would the area be with the trapezoid rule? And I'm having trouble distinguishing the formulas of the trapezoid rule and midpoint rule. Any help?
2. ## Re: Trapezoid Rule help?
Originally Posted by canyouhelp
So for this question: http://i57.tinypic.com/15i2m2o.jpg
I'm having trouble because I get a triangle instead of a trapezoid for the first trapezoid. Because It starts with (0,0). What should I do? What would the area be with the trapezoid rule? And I'm having trouble distinguishing the formulas of the trapezoid rule and midpoint rule. Any help?
Let's look at the trapezoid rule in its simplest form, where there is only ONE interval:
$\displaystyle \int_a^bf(x)\ dx \approx (b - a) * \dfrac{f(a) + f(b)}{2}.$
If f(a) = 0 this reduces to $(b - a) * \dfrac{0 + f(b)}{2} = \dfrac{1}{2} * (b - a) * f(b)$, which is indeed the area of a triangle.
Now you are using more than one interval for your approximation, but the same logic will apply to subintervals. So for any subinterval where either
f(a) or f(b) = 0, the associated trapezoid degenerates into a triangle. You did not make a mistake; you discovered something you did not expect. Good job. | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9843363480718236,
"lm_q1q2_score": 0.8047682785484723,
"lm_q2_score": 0.8175744806385542,
"openwebmath_perplexity": 522.2904444317588,
"openwebmath_score": 0.9090062379837036,
"tags": null,
"url": "http://mathhelpforum.com/calculus/226315-trapezoid-rule-help.html"
} |
javascript, object-oriented, node.js, ecmascript-6
const required = joi.string().required(),
loginSchema = joi
.object({
appname: required,
email: required,
password: required,
})
.required();
async function run(req, res, next) {
const { appname, email, password } = await joi.attempt(req.body, loginSchema);
const app = await getApp(appname);
(!app) && (throw boom.badRequest(`Invalid app name: ${appname}.`);)
(app.isInactive()) && (throw boom.badRequest('App is not active.');)
const { isAuthorized, user } = await authorize({ email, password });
(!user) && (throw boom.notFound('User not found.');)
debug(`User ${user.get('email')} is authorised? ${isAuthorized}`);
(!isAuthorized) && (throw boom.unauthorized('Invalid email or password.');)
const { result } = await isUserBelongsToApp(user, app.get('name'));
(!result) && (throw boom.badRequest(`User is not authorised to access app.`);)
return successResponse(email, app.get('secret'), res);
}
async function getApp(name) {
return await App.findOne({ name });
}
async function authorize({ email, password }) {
const user = await User.findOne(
{ email, status: 'active' },
{ withRelated: ['apps', 'roles.permissions'] }
);
let isAuthorized = false;
if (user) {
isAuthorized = await bcrypt.compare(password, user.get('password'));
}
return { isAuthorized, user };
} | {
"domain": "codereview.stackexchange",
"id": 30718,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "javascript, object-oriented, node.js, ecmascript-6",
"url": null
} |
c#, entity-framework
And now, in the EntityFramework namespace I have the following implementations
namespace DataObjects.EntityFramework
{
// Data access object factory
// ** Factory Pattern
public class DaoFactory : IDaoFactory
{
public IProductDao ProductDao => new ProductDao();
public IColorDao ColorDao => new ColorDao();
public ISizeDao SizeDao => new SizeDao();
public ICategoryDao CategoryDao => new CategoryDao();
public IFileDao FileDao => new FileDao();
public IFileErrorDao FileErrorDao => new FileErrorDao();
}
}
DaoCategory implementation
using AutoMapper;
using System.Collections.Generic;
using System.Linq;
using BusinessObjects;
namespace DataObjects.EntityFramework
{
// Data access object for Product
// ** DAO Pattern
public class CategoryDao : ICategoryDao
{
/// <summary>
/// Inserts category into database
/// </summary>
/// <param name="category"></param>
public void InsertCategory(Category category)
{
using (var context = new ExamContext())
{
Mapper.Initialize(cfg => cfg.CreateMap<Category, CategoryEntity>());
var entity = Mapper.Map<Category, CategoryEntity>(category);
context.CategoryEntities.Add(entity);
context.SaveChanges();
// update business object with new id
category.Id = entity.Id;
}
}
/// <summary>
/// Gets all categories from database
/// </summary>
/// <returns>Returns a list of Category</returns>
public List<Category> GetCategories()
{
using (var context = new ExamContext())
{
Mapper.Initialize(cfg => cfg.CreateMap<CategoryEntity, Category>());
var categories = context.CategoryEntities.ToList();
return Mapper.Map<List<CategoryEntity>, List<Category>>(categories);
}
} | {
"domain": "codereview.stackexchange",
"id": 25616,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c#, entity-framework",
"url": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.