text stringlengths 1 1.11k | source dict |
|---|---|
special-relativity
rotated in space."
I understand that this is looking at a special case where we are physically observing an object as opposed to talking about mathematically what is happening but why would we observe the rod to be "rotated in space"? And along which axis would it appear rotated? The apparent length contraction resulting from relative motion, which is given by the Lorenz transformations, is the effect that would seen by two stationary observers, one at each end of the interval being measured. The Terrell–Penrose rotation is a change to the perceived orientation of a moving object as seen by a single observer, and is a consequence of the different amount of time light takes to arrive at the observer's eye from the various parts of the moving body. The rotation is about an axis normal to the direction of motion. I suspect that the shape may appear distorted too, depending upon the angles which its various facets subtend to the eye. | {
"domain": "physics.stackexchange",
"id": 62918,
"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": "special-relativity",
"url": null
} |
javascript, beginner
function isAuthorized(url, lv) {
var mapping = mappings.find(m => m.names.includes(url.trim('/'));
return mapping !== undefined
&& lv > mapping.level;
}
To explain:
.find() gives us the first item which conforms to the selection logic (or undefined if no such item exists).
The selection logic (.includes()) checks if a mapping contains a name that matches the url parameter.
By using url.trim('/'), you omit the first and last character (the /) from the URL when it is a / (but will leave any other characters). This just makes it easier for use to not have to constantly put the / in the mapping names.
The !== undefined check ensures that we return false if no mapping exists for the current URL. Your intended behavior may be different here - adjust it as you see fit. | {
"domain": "codereview.stackexchange",
"id": 36565,
"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, beginner",
"url": null
} |
(or onto), or a surjection, if for every element y in the codomain Y of f there is at least one element xf from a set X to a set Y is surjective (or onto), or a surjection, if for every element y in the codomain Y of f there is at least one element x An onto function is also called surjective function. In other words, the function F maps X onto Y (Kubrusly, 2001). A function f (from set A to B) is surjective if and only if for every y in B, there is at least one x in A such that f(x) = y. Bijective. (if f is injective, called 1-1 into,), The main idea of injective is that f:A-->f(A) be bijective (that is, have an inverse (also a function) f, If three different people did not understand your post then possibly it was NOT as "concise, clear, correct, and comprehensive" as you think! To say that a function f: A → B is a surjection means that every b ∈ B is in the range of f, that is, the range is the same as the codomain, as we indicated above. Surjective is also called "onto", it is | {
"domain": "fasngo.org",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9840936073551713,
"lm_q1q2_score": 0.8022650834883827,
"lm_q2_score": 0.8152324915965392,
"openwebmath_perplexity": 563.2614000795674,
"openwebmath_score": 0.7634180784225464,
"tags": null,
"url": "https://fasngo.org/assassin-s-pfdyhnu/9e60c3-surjective-function-is-also-called"
} |
I'm particularly working with $$a_n = 2a_{n-1} + 5^{n-1}$$, but the sequence expands extremely fast. The base case, $$a_{0} = 1$$.
Any help would be appreciated!
• In the two examples you mention, it is often done in two parts. First the general soluion to the homogeneous equation. Second, a particular solution ( either by undetermined coefficients or variation of parameters or some other ad-hoc method ). Nov 10, 2020 at 1:22
• @GEdgar The way I've solved the Fibonacci sequence was by declaring $a_n$ as $F(x)$ and then subtracting $xF(x)$ and subtracting $x^2F(x)$, setting the entire difference equal to 1, and getting the generator function of $1/(1-x+x^2)$. No clue how to proceed here, though. Nov 10, 2020 at 1:25
Because the one with which you’re now working is first-order, you can simply ‘unwind’ it: | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9915543715614326,
"lm_q1q2_score": 0.8012425781137079,
"lm_q2_score": 0.8080672135527631,
"openwebmath_perplexity": 692.0785834965465,
"openwebmath_score": 0.9929620623588562,
"tags": null,
"url": "https://math.stackexchange.com/questions/3901080/recurring-sequence-with-exponent"
} |
algorithms, algorithm-analysis, asymptotics, runtime-analysis
But on the other hand inputs to an algorithm which are neither the best case input nor the worst case input is supposed to be somewhere in between both the extremes and the performance of our algorithm is measured on them by none other than the average case time complexity as the average case time complexity of the algorithm is in between the worst and best case complexities just as our input between the two extremes.
Is it correct or incorrect to say that an input say $C$ causes an average run-time of an algorithm?
The excerpt from the text which made me ask such a question is as follows: | {
"domain": "cs.stackexchange",
"id": 16445,
"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, algorithm-analysis, asymptotics, runtime-analysis",
"url": null
} |
string-theory, mathematical-physics, gauge-theory, topological-field-theory, branes
I think this factor of two, that is currently beyond my understanding, is really important and not a typo. In my previous PSE question D-branes as the atoms of Calabi-Yau crystals I requested help to understand why in the quantum foam description of topological string theory apparently a D2/anti-D2-brane bound state is equivalent to having a single $0$-brane. That seems to point out that $0$-branes are composite objects in this quantum foam story. Is that right? | {
"domain": "physics.stackexchange",
"id": 75787,
"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": "string-theory, mathematical-physics, gauge-theory, topological-field-theory, branes",
"url": null
} |
c, opengl, c11
Assigning a value in a condition block may sometimes be the best approach, such as in a while loop, but use it carefully.
Specialisation
Your main is too big, you should split your code into smaller functions, each doing it's own thing, not only it makes your code more readable but it also makes your code more maintainable and easier to debug.
Vertices & TexCoords
Both your vertices and texture coordinates can be declared as global constants as they are never changed and a brief description on what they are for could be added for further clarification of their usage and purpose (vertex data for a quad).
OpenGL Vertex Data
Since you're drawing a 2D surface to the screen, you do not need vertices with 3 coordinates, you need only two, thus your vertex data would become:
const GLshort vertices[] = {
-1, 1,
1, 1,
-1, -1,
1, -1,
};
Then you need to change your vertex attributes to two values:
glVertexAttribPointer(0, 2, GL_SHORT, GL_FALSE, 0, NULL); | {
"domain": "codereview.stackexchange",
"id": 21150,
"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, opengl, c11",
"url": null
} |
python, beginner, numpy, machine-learning
Of course profiling is also key in that process and has been mentioned in the comments. Python's built-in cProfile module is very useful for that purpose. timeit can also be used to robustly measure the execution time of smaller pieces of code. | {
"domain": "codereview.stackexchange",
"id": 37271,
"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, numpy, machine-learning",
"url": null
} |
frequency-spectrum, frequency, estimation, estimators, amplitude
Title: Estimation of the amplitude of a frequency component in a signal I'm working on a device that produces a signal with sampling rate of 100 kHz. Every 40 ms, I receive 16000 points, from which I have to extract a frequency close to 3.55 kHz. I have developed a method that extracts the frequency of the signal very close to the Cramér-Rao lower bound, but I need to extract the amplitude of the signal at that frequency very precisely.
The first idea that occured to me was using a digital implementation of a lock-in amplifier, but the problem is that a lock-in amplifier needs a low-pass filter. And I'm trying to avoid using filters as much as I could, because filters introduce a systematic shift in my readings, while I need extremely high precission and accuracy.
What's the best amplitude estimation algorithm I should use? Generally, the frequency estimation problem decouples from the amplitude + phase estimation problem.
As I said in the comments, you could just do:
$$ | {
"domain": "dsp.stackexchange",
"id": 1208,
"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": "frequency-spectrum, frequency, estimation, estimators, amplitude",
"url": null
} |
planet, solar-system, mars, newtonian-telescope
I have made sure that the laser is straight by 1. spinning it in the
eyepiece holder and the laser stayed in the same spot 2. zooming in
and out and again the laser stayed in the same place. the laser seems
to be centered so I put it in the middle of the doughnut on the mirror
and the laser bounces back into the middle of the colimating lens | {
"domain": "astronomy.stackexchange",
"id": 3434,
"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": "planet, solar-system, mars, newtonian-telescope",
"url": null
} |
javascript, html5, authentication
// localStorage equiv of cookie
bic.isLoggedIn = function() {
var a = localStorage.loggedIn;
var storedUser = localStorage.Username;
var storedUser2 = storedUser.replace(/"/g,''); // removing " as above
// does a exactly equal "yes"?
if(a === "yes") {
bic.notify("loginForm", "Logged in as: " + storedUser2 + "<br /><br /><a id='logout' href=''>Log out?</a>");
document.getElementById("logout").onclick = function(e){e.preventDefault();bic.logout();};
console.log("Logged in as: " + localStorage.Username);
}
} | {
"domain": "codereview.stackexchange",
"id": 7286,
"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, html5, authentication",
"url": null
} |
general-relativity, black-holes, kerr-metric
note that although the causal pathologies [closed timelike curves] in the Kerr spacetime have their genesis in the maximally extended $r < 0$ region, the effects of these causal pathologies can
reach out into part of the $r > 0$ region, in fact out to the inner horizon at
$r = r_−$ [31] — so the inner horizon is also a chronology horizon for the maximally extended Kerr spacetime. Just what does go on deep inside a classical
or semiclassical black hole formed in real astrophysical collapse is still being
debated — see for instance the literature regarding “mass inflation” for some
ideas [42]. For astrophysical purposes it is certainly safe to discard the $ r < 0$ region, and almost all relativists would agree that it is safe to discard the
entire region inside the inner horizon $r < r_-$ | {
"domain": "physics.stackexchange",
"id": 22558,
"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": "general-relativity, black-holes, kerr-metric",
"url": null
} |
mechanical-engineering, electrical-engineering, mechanical-failure
If a process needs to maintain some minimum capacity, and a critical component is likely to fail at some point, make the component redundant (e.g., more engines than needed for basic flight) or provide a fallback (e.g., the ability to perform an unpowered landing).
Always use tested products and components, even if it means you have to do the testing yourself.
Provide a mechanism for your customers/clients/users to give feedback about failures as they occur. You'll hardly ever anticipate every possibility and being able to retrofit or adapt an existing design is important.
* Stripping too much insulation during installation; pests chewing on wires; running wires through studs without a nail plate; cutting flex conduit improperly/not deburring; etc.
** You could also argue for expanding the system to include users as internal components—especially children and pets—but that's another discussion altogether. | {
"domain": "engineering.stackexchange",
"id": 223,
"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, electrical-engineering, mechanical-failure",
"url": null
} |
soft-question, time, terminology, covariance
Title: Is time a Scalar or a Vector? In Wikipedia
it's said that time is a scalar quantity. But its hard to understand that how? As stated that we consider only the magnitude of time then its a scalar. But on basis of time we define yesterday, today and tomorrow then what it will be? To pick up on twistor59's point, time is not a vector but a time interval is.
The confusion arises because you have to define carefully what you mean by the word time. In special relativity we label spacetime points by their co-ordinates $(t, x, y, z)$, where $t$ is the time co-ordinate. The numbers $t$, $x$, etc are not themselves vectors because they just label positions in spacetime. So in this sense the time co-ordinate, $t$, is not a vector any more than the spatial co-ordinates are. | {
"domain": "physics.stackexchange",
"id": 22819,
"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": "soft-question, time, terminology, covariance",
"url": null
} |
rna-seq, normalization, edger
No; you divide, but if you poke around, you can probably find a way to get edgeR to return the normalized counts.
I think since normalization uses per person library size, each
person's normalization is independent of the others.
Not true for the default normalization used in edgeR, TMM. CPM normalization is independently determined for each sample.
In general, normalize everything together, unless you think that the algorithm assumptions might be violated by including all of them together. | {
"domain": "bioinformatics.stackexchange",
"id": 1087,
"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": "rna-seq, normalization, edger",
"url": null
} |
arithmetic
As a consequence, for operations where $0 \odot 0 \ne 0$, such as NAND and NOR, the identity $(x \odot y)_k = x_{k} \odot y_k$ may not hold when $k$ is out of range. Thus, for such operations, the distributive properties given above may not hold for the lowest $n$ bits (for $\ll n$) and the highest $n$ bits (for $\gg n$, where $\gg$ is a logical shift). However, arithmetic right shifts with sign extension (as well as right shifts on arbitrary-length numbers with implicit sign extension) do fully distribute over all bitwise logical operations. | {
"domain": "cs.stackexchange",
"id": 6836,
"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",
"url": null
} |
quantum-mechanics, quantum-information, polarization, tensor-calculus
Title: Spatial and polarizing beam splitters in a graphical calculus Suppose I have four wires, and I tensor product them together
$A \otimes B \otimes C \otimes D$
I pass $A \otimes B$ through a spatial beam splitter
$Spl: A \otimes B \rightarrow A^\prime \otimes B^\prime$
and I pass $C \otimes D$ through a polarizing beam splitter
$Pspl : C \otimes D \rightarrow C^\prime \otimes D^\prime $.
What kind of product do I use to combine $Pspl$ and $Spl$? For instance, can I just tensor them and get
$Spl \otimes Pspl : A \otimes B \otimes C \otimes D \rightarrow A^\prime \otimes B^\prime \otimes C^\prime \otimes D^\prime $? | {
"domain": "physics.stackexchange",
"id": 3276,
"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, quantum-information, polarization, tensor-calculus",
"url": null
} |
newtonian-gravity, education, home-experiment
Measurement
Measuring this won't be easy. A seconds pendulum nominally has a period of two seconds. The length of such a pendulum is a bit shy of one meter. (Aside: This was the definition of a meter recommended by French scientists. There was one problem: It was a "placist" definition because gravitational acceleration varies somewhat over the face of the Earth.) Assuming a seconds pendulum with a nominal, non-tidal period of two seconds, a seconds pendulum will have a period of 2.000000167 seconds at noon at the sub-moon point during a solar eclipse and a period of 1.999999917 seconds at sunset of the same day. An hour as measured by the clock will be 0.45 milliseconds shorter at sunset than at noon. | {
"domain": "physics.stackexchange",
"id": 15189,
"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-gravity, education, home-experiment",
"url": null
} |
machine-learning, comparison, features, random-variable
It also helps to think that given a set of different examples (say the image of cats). What the ML algorithm really learns is the invariant features between all the examples, i.e. the cats. So the ML algorithm learns to discriminate all the variability (backgrounds, occluding objects) and learn what is invariant: the representation of a cat.
This representation, since images are pixels, can be described as a probability density function of values that would represent a cat. It would be like the ML algorithm said: "If those pixels values behave close to the probability density function I learned, then those pixels must represent a cat!" | {
"domain": "ai.stackexchange",
"id": 2984,
"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": "machine-learning, comparison, features, random-variable",
"url": null
} |
heaps
Title: 3-heap max heap I have this 3 heap max heap that I need to write the array for it, but I'm not sure how. Would it just be
20,18,13,15,11,12,16,10,9,11,13,2,9? Yes, it would be Just the Level Order Traversal of the tree, In this case, it is 20,18,13,15,11,12,16,10,9,11,13,2,9,10,1.
More generally for a generalized d-heap, the items may be viewed as the nodes in a complete d-ary tree, listed in breadth-first traversal order: the item at position $0$ of the array (using zero-based numbering) forms the root of the tree, the items at positions 1 through d are its children, the next $d^2$ items are its grandchildren, etc. Thus, the parent of the item at position $i$ (for any $i > 0$) is the item at position $⌊(i − 1)/d⌋$ and its children are the items at positions $d\cdot i + 1$ through $d\cdot i + d$. | {
"domain": "cs.stackexchange",
"id": 14738,
"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": "heaps",
"url": null
} |
quantum-mechanics, operators, notation, conventions, second-quantization
And here the order of creation operators is the reverse of the order spin-orbitals in Slater determinant (although Slater determinant is not written explicitly, I think we can safely assume that it is $| \begin{matrix} \psi_{1} & \psi_{2} & \cdots & \psi_{n} \end{matrix} |$, i.e. that orbitals follow in natural order). But with this convention $\Phi(1,2)$ mentioned above should be equivalent to $a_{k}^{+} a_{i}^{+} \lvert \text{vac} \rangle$ rather than $a_{i}^{+} a_{k}^{+} \lvert \text{vac} \rangle$.
Am I right or totally confused? Since the states $|\psi\rangle$ and $-|\psi\rangle$ differ only by a phase factor, they really describe the same electron configuration. So, while it is a bit sloppy to have inconsistent sign conventions in different places in a text, it's not surprising to see it, and it's not really a big deal. (Unless you have inconsistent sign conventions within a single equation of course!)
In other words, I agree with what you wrote in your question. | {
"domain": "physics.stackexchange",
"id": 18192,
"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, operators, notation, conventions, second-quantization",
"url": null
} |
vba, excel, web-scraping
With CreateObject("VBScript.RegExp")
.Global = True
.MultiLine = True
.IgnoreCase = False
.Pattern = "<span class=""avgRate"">(.*?)</span>"
Set intMatches = .Execute(sContent)
If intMatches.Count <> 0 Then
With intMatches
For mtchCnt = 0 To .Count - 1
For subMtchCnt = 0 To .Item(subMtchCnt).SubMatches.Count - 1
GetRateYear = .Item(mtchCnt).SubMatches(0)
Cells(RowNum, ColNum).Value = GetRateYear
Cells(RowNum, 1).Value = sYear
Cells(RowNum, 2).Value = sFromCrcy
RowNum = RowNum + 1
Next
Next
End With
End If
End With
End Function
GetSingleMonth Function:
Private Function GetSingleMonth(ByVal sFromCrcy As String, ByVal sToCrcy As String, ByVal sYear As String, ByVal RowNumB As Long, ByVal ColNumB As Long) | {
"domain": "codereview.stackexchange",
"id": 20007,
"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": "vba, excel, web-scraping",
"url": null
} |
java, linked-list, unit-testing
for (int i = 0; i < list.size(); i++) {
assertEquals(Integer.valueOf(i + 1), list.get(i));
}
}
@Test
public void testAddCollectionAtIndex() {
list.addAll(0, Arrays.asList(2, 3)); // setAll
list.addAll(0, Arrays.asList(0, 1)); // prependAll
list.addAll(4, Arrays.asList(6, 7)); // appendAll
list.addAll(4, Arrays.asList(4, 5)); // insertAll
for (int i = 0; i < list.size(); i++) {
assertEquals(Integer.valueOf(i), list.get(i));
}
}
@Test
public void testRemoveInt() {
list.addAll(Arrays.asList(0, 1, 2, 3, 4));
assertEquals(Integer.valueOf(0), list.remove(0));
assertEquals(Integer.valueOf(4), list.remove(3));
assertEquals(Integer.valueOf(2), list.remove(1));
assertEquals(Integer.valueOf(1), list.remove(0));
assertEquals(Integer.valueOf(3), list.remove(0));
} | {
"domain": "codereview.stackexchange",
"id": 42089,
"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, linked-list, unit-testing",
"url": null
} |
everyday-chemistry, aqueous-solution
Source: https://www.onlinechemistrytutor.net/oxidation-state-examples/
What it probably is not
Chlorite, as stated by the OP, can be used to synthesize chlorine dioxide gas by adding chlorine or hypochlorite. It is unlikely that there is chlorine or hypochlorite in the product.
Chlorite in an acidified form is used as desinfection agent to kill bacteria on chicken and cows during meat processing. In this application, chlorine dioxide is produced:
$$\ce{4 HClO2 -> 2 ClO2 + ClO3- + Cl- + 2H+ + H2O}$$
$$\ce{5 HClO2 -> 4ClO2 + Cl- + H+ + 2 H2O}$$
A strongly acidic solution (very low pH) would probably kill the fish, so that formulation is also unlikely.
What it might be
There is a product for cleaning contact lenses where chlorite is combined with sodium chloride and trace amounts of hydrogen peroxide. | {
"domain": "chemistry.stackexchange",
"id": 17032,
"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": "everyday-chemistry, aqueous-solution",
"url": null
} |
python, beginner, strings, python-3.x
If the last part is unfamiliar, see What does if __name__ == "__main__": do?
Note that including examples in the docstring in the form of an interactive Python session not only gives the reader a good idea of exactly how to use the function, but also allows doctest to validate the code and examples for you. If you save the above into a file initial.py:
$ python -m doctest initial.py --verbose
Trying:
initial_of_name('Ram Chandra Giri')
Expecting:
'R.C.Giri'
ok
Trying:
initial_of_name('Ram chandra Giri')
Expecting:
'R.C.Giri'
ok
1 items had no tests:
initial
1 items passed all tests:
2 tests in initial.initial_of_name
2 tests in 2 items.
2 passed and 0 failed.
Test passed. | {
"domain": "codereview.stackexchange",
"id": 27719,
"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, strings, python-3.x",
"url": null
} |
The units digit of the sum of the first $$10$$ terms
$$=(1+4+3+6+5+6+7+6+9+0)$$ $$($$mod $$10)=47$$ $$($$mod $$10)=7$$
Therefore, the units digit of the given expression is $$(7 \times 101)$$ $$($$mod $$10)=707$$ $$($$mod $$10)=7$$.
I am not sure if I am right or wrong. Please let me know.
Also, I do not know anyway to find the first digit (on the left).
Any help would be appreciated. THANKS!
• I am sceptical that the first digit can be found out by hand. We would not only need logarithms, but also it would be difficult to find out the largest summand and whether it is large enough compared to the rest of the sum to determine the first digit. Sep 5, 2019 at 7:53
• Where id the question come from? You think about it or it shows in books or contests? Sep 5, 2019 at 8:56
• @IsaacYIUMathStudio I was reading a book in number theory, in a chapter about modular arithmetic. This question just pop-up in my mind. Sep 5, 2019 at 9:00
Your computation for the last digit looks correct. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9777138157595305,
"lm_q1q2_score": 0.8038656784683663,
"lm_q2_score": 0.8221891370573388,
"openwebmath_perplexity": 121.3881099094361,
"openwebmath_score": 0.7783242464065552,
"tags": null,
"url": "https://math.stackexchange.com/questions/3344958/the-first-digit-on-the-left-and-the-last-digit-on-the-right-of-sum-k-1"
} |
c++, array, c++20
My first approach was only templated on the datatype, but not the dimensions. This allowed for dynamic resizing and reshaping of the view, but it didn't allow for the multiple subscript operators returning different types, either new views, or values if the span is one-dimensional.
After that I restructured my code to be templated on the dimensions as well, which got rid of the previously mentioned subscript problem and additionally got compile time constant evaluation possibilities.
#pragma once
#include <concepts>
#include <utility>
#include <array>
template <template<typename, auto...> typename U, typename V, auto first, auto... others>
struct DropFirstPackValue {
using type = U<V, others...>;
};
template <template<typename, auto...> typename U, typename V, auto first, auto... others>
using DropFirstPackValue_t = DropFirstPackValue<U, V, first, others...>::type; | {
"domain": "codereview.stackexchange",
"id": 45394,
"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++, array, c++20",
"url": null
} |
microbiology, metabolism
LDH: the reaction pyruvate + NADH/H+ = lactate + NAD+ + 25 kJ/mol is highly exergonic, i.e. produces heat
PDC: the reaction pyruvate = acetaldehyde + CO2 (and with ALD present) acetaldehyde + NADH/H+ = ethanol + NAD+ where ethanol is poisonous to other species
Add to it that there are organisms like Sch. pombe that have both enzymes, so can do both reactions, your questions should be rather:
How has the enzyme LDH evolved?
The enzyme is similar to malate dehydrogenase, both form a family. They belong to a group of enzymes that all have a NAD(P) binding domain, so it's not too far-fetched to state that LDH and MDH evolved from another enzyme with NAD(P) binding domain.
http://www.ebi.ac.uk/interpro/IEntry?ac=IPR016040
How has the enzyme PDC evolved? | {
"domain": "biology.stackexchange",
"id": 675,
"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": "microbiology, metabolism",
"url": null
} |
#### Rido12
##### Well-known member
MHB Math Helper
So Step 1 is to see to determine its continuity, if the function is continuous, we can proceed to find the derivative.
Step 2, we find the limit of both sides of the derivative at the point we want to prove, say x = 0 , and we find that the limit doesn't exist
Step 3, we can make a conclusion that because the limit doesn't exist, g'(x) is discontious at the point and impossible to differentiate. for a function to be differentiable, it must be continuous, but the converse is not true.
Is there anythign wrong with the procedure above?
#### Bacterius
##### Well-known member
MHB Math Helper
Thanks! So I guess the last question is how would I prove that g(x) is not differentiable at x = 0. Say you prove that g(x) is continuous at 0. How would I prove that it is not differentiable at x = 0 .
You take the definition of "differentiable": | {
"domain": "mathhelpboards.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9465966732132748,
"lm_q1q2_score": 0.8613149540995223,
"lm_q2_score": 0.9099070158103778,
"openwebmath_perplexity": 249.94956744422095,
"openwebmath_score": 0.9249218106269836,
"tags": null,
"url": "https://mathhelpboards.com/threads/understanding-limits.6134/"
} |
python, pygame
if event.type == E2:
B_SPAWN = random.uniform(1000, 6000)
pygame.time.set_timer(E2, 1 * int(B_SPAWN))
bullet = pygame.Rect(0, 70, BULLET_WIDTH, BULLET_HEIGHT)
BULLETS_L.append(bullet)
if event.type == E3:
B_SPAWN = random.uniform(1000, 6000)
pygame.time.set_timer(E3, 1 * int(B_SPAWN))
bullet = pygame.Rect(0, 620, BULLET_WIDTH, BULLET_HEIGHT)
BULLETS_L.append(bullet)
if event.type == E4:
B_SPAWN = random.uniform(1000, 6000)
pygame.time.set_timer(E4, 1 * int(B_SPAWN))
bullet = pygame.Rect(0, 430, BULLET_WIDTH, BULLET_HEIGHT)
BULLETS_L.append(bullet) | {
"domain": "codereview.stackexchange",
"id": 44446,
"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, pygame",
"url": null
} |
electric-circuits, electric-current, voltage, batteries, short-circuits
The current source is connected in parallel with the zero-ohm wire. Therefore the resistance that applies here is the parallel combination of the source's internal resistance and the wire. Since 0 ohms in parallel with any other resistance is 0 ohms, in this equation we should have $R=0\ \Omega$.
Then there is no infinity involved and your question is moot.
It may make it easier to understand this circuit if instead of a short-circuit wire, you place a resistor across the source. Then you can use the mathematical tools of limits to find out what happens if the resistor value approaches zero or increases toward infinity.
For example, the short circuit case can be studied as
$$V=\lim_{R\to 0}IR$$
Since $I$ is a finite constant value, this limit is very easy to evaluate. | {
"domain": "physics.stackexchange",
"id": 68605,
"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": "electric-circuits, electric-current, voltage, batteries, short-circuits",
"url": null
} |
organic-chemistry, polymers, terminology, reference-request
Fig. 4 Polymerisation of styrene and divinylbenzene to form an infinite polymer network.
Further, the paper lists several reasons as to why the real level of crosslinking is always accompanied with a level of uncertainty:
The effective crosslink ratio significantly decreases with greater quantity of DVB being fed due to growing number of unreacted vinyl groups.
Entanglement crosslinking occurs at higher rates of polymerization in slowly-agitated systems and results in additional mobile crosslinking.
Fig. 5 Permanent entanglement crosslink
Additional crosslinks can also be created as the result of intramolecular side-reactions.
These factors are tricky to estimate quantitatively; a method allowing to do so would be a single pulse excitation (SPE) 13C solid state NMR.
References | {
"domain": "chemistry.stackexchange",
"id": 14865,
"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, polymers, terminology, reference-request",
"url": null
} |
According to Wolfram, the integral formula is
1/2[tan theta sec theta {: - ln (cos {:theta/2:} - sin {:theta /2:}) {: + ln (sin {:theta/2:} + cos {:theta/2:})]
Therefore, 1/2 [tan .7853\ sec .7853 {:- ln (cos .7853/2 - sin .7853/2) {: + ln (sin .7853/2 + cos .7853/2)] - 1/2 [0 - ln (1-0) + ln (0+1) ]
= 1/2[tan .7853\ sec .7853 {: - ln (cos .7853/2 - sin .7853/2) {: + ln (sin .7853/2 + cos .7853/2)] - [0]
=1.15
which is the web site's answer using the Trapezoidal Rule!
Thank you for the guidance.
Note: concerning how theta is written above, I wrote it out in Word.
## Re: Find integral sqrt (x^2 + 1) using trigonometric substitution
OK - looks good.
BTW, the "theta" symbols didn't show because Word uses a different set of fonts. It's always best to type the math directly in the text box, for best results. I edited your answer so the thetas showed properly and also so the answer worked OK on a phone.
X
OK - looks good. | {
"domain": "intmath.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9653811651448431,
"lm_q1q2_score": 0.8438177012933787,
"lm_q2_score": 0.8740772368049823,
"openwebmath_perplexity": 4474.827558513489,
"openwebmath_score": 0.9217457175254822,
"tags": null,
"url": "https://www.intmath.com/forum/methods-integration-31/find-integral-sqrt-x-2-1-using-trigonometric:155"
} |
human-biology, development, embryology
Title: What is the mechanism of folic acid deficiency and neural tube defects? I am having difficulty finding the mechanism by which folic acid reduces the risk of neural tube defects. I know that it does so, but what in particular actually occurs with folic acid deficiency to cause the neural tube defect? Is that completely unknown and merely a strong association, or is there a putative mechanism? You are having difficulties finding the mechanism because it is as of yet unknown.
Now of course comes the hard part where I need to prove that statement. Often, it's just apparent by papers not saying anything about the mechanism, even though you'd expect then to include a brief section if it was known, for example Folic acid supplementation for pregnant women and those planning pregnancy: 2015 update or the various Cochrane reviews on the topic of how much folic acid supplementation is optimal, or the WHO and CDC documents on the topic | {
"domain": "biology.stackexchange",
"id": 4943,
"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": "human-biology, development, embryology",
"url": null
} |
java, performance
Analysis
Say we have M products, N discounts, and k discount names for each product.
Populating HashMap: O(N)
Going through each product: O(M)
Going through each discount (for each product) O(M * k)
Time complexity: O(max(N, M * k))
Space Complexity: O(N) for Hashmap.
Are the time and space complexities correct?
Can I optimize this code? The mess you are in
Below are the initial comments. Mostly naming, but I also added code explanation comments for the purpose of the next part of refactoring. You seem to mix different levels of abstraction in a single line. For example when you iterate over the list of products, each item in the list is a product, not a "list" just because a product is represented as a list.
Also notice, that your method has multiple levels of indentation. This is a sign, that the method does more than it says it does. Each explanation comment is basically saying what the method does.
...
// Minor naming: Seems like Discount would be more appropriate | {
"domain": "codereview.stackexchange",
"id": 42144,
"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, performance",
"url": null
} |
rust
Q1: How do I make sure in such situation what trait bounds are necessary?
It is a combination of reading the documentation and intuition. If we Google something like "hashmap rust", we get to the documentation page, which tells us what we need to know: | {
"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
} |
zoology, entomology, statistics, research-design
and there are wealth of information out there and once you do that you can get the communities help in websites such as stack overflow to help you refine your codes or any problems you may have with it, so long as you show evidence of your work. This is a great option since you can add variety of data (or different data aspects) to your project such as what is the average speed/velocity which your bees travel at in different times when entering/exiting the hive, is there a pattern to their travelling (e.g. straight line, zig-zag etc) and much more. I'm aware that this is beginning to sound like a PhD project and not a high school project but these are some things to consider. If programming is totally out of the question then you can look on internet to see what free programs are out there to aid you with your data collection. I briefly looked and saw this (http://www.youtube.com/watch?v=jWD8CHW06Ks) and this | {
"domain": "biology.stackexchange",
"id": 2268,
"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": "zoology, entomology, statistics, research-design",
"url": null
} |
time-complexity, trees, recurrence-relation
Title: Solving $T(n) = T(n/2) + T (n/3) + n $ with recurrence tree I am trying to solve the following recurrence relation:
$$T(n) = T(n/2) + T (n/3) + n $$ $$T(1) = Θ(1) $$
I guess that the time complexity is $T(n)=Θ(n)$ since $\frac{n}{2} + \frac{n}{3} < n$
I am trying to prove it using a recurrence tree.
The tree is not balanced. Particularly, the longest path from the root to a leaf is the leftmost one with a length of $\log_2n$ when the shortest path is the rightmost one with a length of $\log_3n$.
We get that at each level,except the first one, the cost is $< n$. In more detail,the first level has a cost of $n$. The nodes on the second level add to a $\frac{5}{6}\cdot n$ cost, the third level has a cost equal to $\left (\frac{5}{6} \right )^2\cdot n$ and so on...
So, untill the height of $\log_3n$ we have a cost of $$n\sum_{i=0}^{\log_3n-1}\left (\frac{5}{6} \right )^i = n\cdot \frac{\left (\frac{5}{6}\right)^{\log_3n}-1}{\left (\frac{5}{6}\right)-1}$$ | {
"domain": "cs.stackexchange",
"id": 14930,
"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, trees, recurrence-relation",
"url": null
} |
javascript, game, stackexchange, userscript
Is my game design okay? I'm not that familiar with game programming, and although this is hardly a game, I am still curious about code design. Is the idea of having this single play function good? Is there anything else?
Is my "play" button initialization okay? I've always done it this way for UserScripts that need edit the existing webpage with new, flowing content, but I don't know if this is good practice. Did I split up the functions that accomplish this well?
I have quite a few global variables, and even one that is constantly used (questions). Is this sort of practice okay for UserScripts/games in JavaScript? Even if this may suffice for a simple game such as this, would it suffice for other, large games but in a similar context?
Are there any inefficiencies in my code, specifically around the DOM traversing and element creation? | {
"domain": "codereview.stackexchange",
"id": 17457,
"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, game, stackexchange, userscript",
"url": null
} |
quantum-field-theory, causality, greens-functions, correlation-functions, propagator
where $\mathcal{T}$ is the time-ordering symbol, $s$ the spacetime interval $x \cdot x$, $H^{(2)}$ the Hankel function, and $K_1$ the modified Bessel function.
Looking at the operator expectation values, it's clear that the Feynman propagator is the right one to use for calculating probabilities of past-to-future propagation. But looking at the actual functional expressions, $G_\text{ret}$ naively "looks" more causally correct, because it vanishes outside the light cone, as we'd naively expect for a particle propagator. (I know, I know, the spacelike correlations decay exponentially and don't actually violate causality because they can't transmit causal influence, etc. etc.) | {
"domain": "physics.stackexchange",
"id": 30829,
"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, causality, greens-functions, correlation-functions, propagator",
"url": null
} |
randomness, pr.probability, randomized-algorithms
One is that, you can't merely say "wlog $\operatorname{E}(X) = 0$" by shifting the distribution, because you are changing the relationship between $f$ and $\mu$.
Next is that the bound must depend on the distribution in some way. To see this, imagine that $X \sim \textrm{Gaussian}(0, \sigma^2)$ and $f(x) = x^2$. Whatever the value of $\sigma$, you still get $f(\operatorname{E}(X)) = f(0) = 0$. On the other hand, $\operatorname{E}(f(X)) = \operatorname{E}(X^2) = \sigma^2$. Thus, by changing $\sigma$, you can make the gap between the two quantities arbitrary! Intuitively, more mass is pushed away from the mean, and thus, for any strictly convex function, $\operatorname{E} (f(X))$ will increase.
Lastly, I don't see how to get a multiplicative bound like you suggest. Everything I have used in this post is standard: Taylor's theorem and derivative bounds are bread&butter in statistics bounds, and they automatically give additive, not multiplicative errors. | {
"domain": "cstheory.stackexchange",
"id": 56,
"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": "randomness, pr.probability, randomized-algorithms",
"url": null
} |
This worry can be obfuscated by flattening $$ℝ^3$$ into a contour plot where the constraint and maximized function do intersect, but only by discarding a dimension of information from the original picture; being aware of the 3D graph the contour plot represents, I still find the matter conceptually troublesome. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9653811621568289,
"lm_q1q2_score": 0.8186121074724282,
"lm_q2_score": 0.8479677660619633,
"openwebmath_perplexity": 332.03784112662504,
"openwebmath_score": 0.5942949056625366,
"tags": null,
"url": "https://math.stackexchange.com/questions/3044697/constrained-optimization-geometry-confusion"
} |
python, numerical-methods, scipy, sympy
def main(name, var_list, abl_height, infunc_list_dict, thresh_list_dict,
weight_list_dict, wefact_list_dict, teston, saveon, printon):
"""Start routines, print output (if printon), save Fortran functions in a
file and start testing (if teston)
"""
func_dict, deri_dict = {}, {}
# file_str stores everything that is written to file in one string
file_str = '!' + 78*'=' + '\n' + '! ' + name + '\n!' + 78*'=' + '\n'
if printon:
print(' ' + 78*'_' + ' ')
print('|' + 78*' ' + '|')
print('|' + 30*' ' + name + (48-len(name))*' ' + '|')
print('|' + 78*' ' + '|')
data = read_scm_data(name)
for var in var_list:
verify_input(name, infunc_list_dict[var], thresh_list_dict[var],
weight_list_dict[var], wefact_list_dict[var])
if printon:
print('! ----- ' + var)
file_str += '! ----- ' + var + '\n'
# use data.z.values to get rid of the pandas-overhead and because | {
"domain": "codereview.stackexchange",
"id": 25090,
"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, numerical-methods, scipy, sympy",
"url": null
} |
ros, tutorial, beginner
Now, if you don't want to create a robot of your own and use a ready model, for example Husky, you need to find the description of Husky, which can be found here. In the file husky_custom_description you can find a urdf file which contains the robot structural code - the team that created the robot used a program like meshlab and generated the code from meshes ( the .dae files represent that) to implement difficult shapes - you can add your own elements (other sensors for example) in this structure with joints to the base platform. In the husky_gazebo folder you will find a code written using <gazebo> tags. These tags must always be included in your description because they define some gazebo elements (elements necessary for the gazebo world like a controller for example). As you can see the husky_gazebo is based on the structural code from the husky_description. They seperated the directories for better organization of the project.
Gazebo | {
"domain": "robotics.stackexchange",
"id": 25532,
"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, tutorial, beginner",
"url": null
} |
matlab, fft, dft, amplitude
$$ \omega_0 = \frac{ 2\pi }{M}k_0 \tag{12}$$ ,in that special case $|X_L^M[k_0]| = 0.5 A L$ will happen. Otherwise, you will have two complex numbers added and their magnitude is computed.
Note that by selecting $M = L$ when $\omega_0$ meets the criterion (i.e, $ \frac{M \omega_0}{2\pi}$ is an integer), then one can get what is an illusion of lollipop plot indicating only two nonzero samples at the frequencies of $\pm \omega_0$ with magnitude 0.5 $A \cdot L $ and all zeros. But this is a conseqeunce of frequency sampling and not to be taken unnecessarily into too far conclusions.
Here is a MATLAB / OCTAVE code to produce the results
clc; clear all; close all | {
"domain": "dsp.stackexchange",
"id": 7666,
"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": "matlab, fft, dft, amplitude",
"url": null
} |
c++, algorithm, c++11
I keep going back and forth with putting a flipped bool in the result instead of the size. The only reason I'm not doing it is that size == {0,0} is my packing failure signal. maybe returning an optional<Result> might be better? Throwing an exception is out of the question as I have code paths that are written in a way to expect an eventual failure as part of the main flow (pack until full). The first thing I would like to mention is that I was unable to compile given code. And compilation fails not because of some fancy problem, but because RectSize declaration or something else is clearly missing from the code. | {
"domain": "codereview.stackexchange",
"id": 28058,
"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++, algorithm, c++11",
"url": null
} |
c#, unity3d, snake-game
protected override void SetPosition(IVector2 pos)
{
base.SetPosition(pos);
instance.transform.position = new Vector3(pos.x, pos.y, 0);
}
public void InstallVisual(GameObject instance, Color color)
{
this.instance = instance;
//Just setting the color of the visual object
instance.GetComponent<MeshRenderer>().material.color = color;
}
public override void DestroyThis(DataBase<IVector2, Obj> objects)
{
GameObject.Destroy(instance);
base.DestroyThis(objects);
}
}
}
AppleObj.cs
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Misc;
namespace SnakeGameSOLID
{
public class AppleObj : VisualObj
{
public AppleObj() : base()
{
}
public override void Next(DataBase<IVector2, Obj> objects)
{ | {
"domain": "codereview.stackexchange",
"id": 23761,
"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#, unity3d, snake-game",
"url": null
} |
java, performance, linked-list, deque, heuristic
// Write out all elements in the proper order.
for (Node<E> x = first; x != null; x = x.next)
s.writeObject(x.item);
}
/***************************************************************************
Implements the doubly-linked list node.
***************************************************************************/
private static class Node<E> {
E item;
Node<E> prev;
Node<E> next;
@Override
public String toString() {
return "[Node; item = " + item + "]";
}
}
/***************************************************************************
Implements the list node finger.
***************************************************************************/
private static final class Finger<E> {
Node<E> node;
int index; // Index at which 'node' is located. | {
"domain": "codereview.stackexchange",
"id": 42034,
"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, performance, linked-list, deque, heuristic",
"url": null
} |
ros-melodic, rosparam, roscpp
Title: roscpp: set / get vector containing infinity from parameter server
Hello everyone,
I would to read a vector containing some infinity components from the ROS parameter server. I have included the following line in the roslaunch:
<rosparam param="my_vector">[0.0, inf, 0.0]</rosparam>
Using the command line rosparam get tool, the vector seems to be loaded correctly in the parameter server, but trying to read it from my node with the following lines:
std::vector<double> v;
ros::param::get("my_vector", v);
returns false.
Is there any built-in way to set / get an infinity value from the parameter server?
Thank you in advance
Originally posted by d.fenucci on ROS Answers with karma: 114 on 2020-10-20
Post score: 0
Shouldn't it be .inf instead? Your v is a vector<double>.
Related: #q275681.
Originally posted by gvdhoorn with karma: 86574 on 2020-10-20
This answer was ACCEPTED on the original site
Post score: 0 | {
"domain": "robotics.stackexchange",
"id": 35657,
"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-melodic, rosparam, roscpp",
"url": null
} |
homework-and-exercises, newtonian-mechanics, potential-energy, conventions, celestial-mechanics
I'm having trouble understanding the question. What does the zero of potential mean? What they are basically telling is that the gravitational potential at an infinite distance from the fixed mass is zero. The total energy of the satellite would be K.E. + P.E.
Since, $$V(r)=-\int{E(r)}$$
$$V(r)=\frac{-GM}{r}$$ With M being the mass of the fixed object. As r tends to infinity, it is clear that the potential of the system rapidly decreases, so it is assumed to be zero. (extremely negligible.)
The orbital velocity of the object is $v_o$. and therefore its kinetic energy is $\frac{mv_o^2}{2}$. In this type of simple orbit scenario, it is always true that $P.E=-2(K.E)$.
Therefore the total energy is $K.E-2(K.E)=-K.E.$ which is $\frac {-mv_o^2}{2}$
In a general satellite planet system, the satellite travels with an orbital velocity. Since the orbital velocity in this case makes the object travel in a circular orbit, it must have centripetal acceleration. | {
"domain": "physics.stackexchange",
"id": 17985,
"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, potential-energy, conventions, celestial-mechanics",
"url": null
} |
$$X_k = \sum_{i=1}^{M_k} Y_i, \quad k = 1, 2.$$
We want to compute $\operatorname{Cov}(X_1, X_2)$. To this end, we first compute $\Bbb{E}[X_1 X_2]$:
\begin{align*} \Bbb{E}[X_1 X_2] &= \Bbb{E}\bigg[\sum_{i=1}^{M_1}\sum_{j=1}^{M_2}Y_i Y_j\bigg] = \Bbb{E}\bigg[\Bbb{E}\bigg[\sum_{i=1}^{M_1}\sum_{j=1}^{M_2}Y_i Y_j \, \bigg| \, \sigma(M_1, M_2)\bigg]\bigg] \\ &= \Bbb{E}\bigg[\sum_{i=1}^{M_1}\sum_{j=1}^{M_2} \Bbb{E}[Y_i Y_j]\bigg] \\ &= \Bbb{E}\bigg[ (M_1 \wedge M_2)\Bbb{E}[Y^2] + (M_1 M_2 - (M_1 \wedge M_2)) \Bbb{E}[Y]^2 \bigg] \\ &= \Bbb{E}[M_1 \wedge M_2]\operatorname{Var}(Y) + \Bbb{E}[M_1 M_2]\Bbb{E}[Y]^2. \end{align*}
(Technically you have to check integrability in order to work with conditional expectation. The 2nd moment condition for $Y$ is enough in this case.) Similar but easier computation shows that $\Bbb{E}[X_k] = \Bbb{E}[M_k]\Bbb{E}[Y]$. Thus it follows that | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9833429619433693,
"lm_q1q2_score": 0.8194438798848196,
"lm_q2_score": 0.8333245994514082,
"openwebmath_perplexity": 292.70066204107104,
"openwebmath_score": 0.9999097585678101,
"tags": null,
"url": "https://math.stackexchange.com/questions/2042109/finding-the-covariance-of-a-poisson-process"
} |
java, web-scraping
// A POJO that encapsulates a ranking week and the name of the corresponding No.1 player
public class WeeklyResult {
private final String week;
private final String playerName;
public WeeklyResult(final String week, final String playerName) {
this.week = week;
this.playerName = playerName;
}
public String getWeek() {
return week;
}
public String getPlayerName() {
return playerName;
}
}
ScraperException class:
package scraper;
public class ScraperException extends Exception {
final String message;
public ScraperException (String message) {
this.message = message;
}
@Override
public String toString() {
return this.message;
}
}
I had some follow up questions to ensure I've truly understood Marv's feedback from my previous question: | {
"domain": "codereview.stackexchange",
"id": 38598,
"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, web-scraping",
"url": null
} |
quantum-mechanics, photons, wavefunction, scattering
$$\Psi(x) \sim \sum_k c_k\psi_k(x)$$
which resembles the Fourier transform. The picture one has in mind is that of a localized bump whose shape is given by the particular coefficients $c_k$ packaging the individual modes (the fixed $k$ wave functions).
I hope that clears up the difference. About the spherical wave, it is just a particular set of coordinates for the problem, but it doesn't change anything of what I have described. To finish I would like to point you perhaps towards the topic of quantum field theory in particular to QED (quantum electrodynamics) which is the theory that properly explains the propagation and interaction of photons with matter. | {
"domain": "physics.stackexchange",
"id": 48597,
"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, photons, wavefunction, scattering",
"url": null
} |
photons, electrons, electric-current, vacuum, lightning
Title: Can lightning happen in a vacuum? Can lightning occur in space artificially?
Can lightning channel along a laser or proton beam in space? Depends on what you mean by "lightning". Yes, because charge can flow across vacuum, but no, because you won't see anything. The visual effect that you see in the sky is actually a luminescent plasma that is left in the wake of the charge moving through the atmosphere. No atmosphere, no plasma, no light.
I suppose you might see some light from Brehmstrahlung, but this would probably be very dim in the visible range. | {
"domain": "physics.stackexchange",
"id": 99072,
"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": "photons, electrons, electric-current, vacuum, lightning",
"url": null
} |
c++, functional-programming, c++14, template-meta-programming
template<typename T>
void printLine()
{
print<T>();
std::cout << '\n';
}
template<int n>
struct Fib_
{
static constexpr int value = Fib_<n - 1>::value + Fib_<n - 2>::value;
};
template<>
struct Fib_<0>
{
static constexpr int value = 0;
};
template<>
struct Fib_<1>
{
static constexpr int value = 1;
};
template<int n>
constexpr int fib = Fib_<n>::value;
template<int n>
struct FibList_
{
typedef Cons<Box<fib<n>>, typename FibList_<n - 1>::Type> Type;
};
template<>
struct FibList_<0>
{
typedef List<> Type;
};
template<int n>
using FibList = Reverse<typename FibList_<n>::Type>;
template<int n, int n2>
struct IsPrime_2
{
typedef If<Box<n % n2 == 0>, Box<false>, typename IsPrime_2<n, n2 + 1>::Type> Type;
};
template<int n>
struct IsPrime_2<n, n>
{
typedef Box<true> Type;
};
template<typename T>
struct IsPrime_
{
typedef typename IsPrime_2<unbox<T>, 2>::Type Type;
};
template<>
struct IsPrime_<Box<1>>
{
typedef Box<false> Type;
}; | {
"domain": "codereview.stackexchange",
"id": 15614,
"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++, functional-programming, c++14, template-meta-programming",
"url": null
} |
machine-learning
So, which is it? Does a DNF being not PAC learnable mean the algorithm's runtime is $O(2^N)$ or $O(2^{2^N})$? There's a misconception here. PAC learning doesn't require the learning to find the shortest formula. It merely requires the learner to find any formula that has sufficiently low generalization error. If there are multiple formulas that meet that criteria, the learner is allowed to output any of them -- not necessarily the shortest.
Take a closer look at the formal definition, and hopefully you'll see how that follows from the definition. | {
"domain": "cs.stackexchange",
"id": 9170,
"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": "machine-learning",
"url": null
} |
ros, rviz, visualization, ros-indigo
#47 0x00007ffff2c820af in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#48 0x00007ffff2c823a5 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#49 0x00007ffff2c87b79 in QCoreApplication::exec() () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#50 0x0000000000401113 in main (argc=1, argv=0x7fffffffda98) at /home/likewise-open/FARADAYFUTURE/c-naman.kumar/catkin_ws/src/rviz/src/rviz/main.cpp:42
(gdb) | {
"domain": "robotics.stackexchange",
"id": 26228,
"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, rviz, visualization, ros-indigo",
"url": null
} |
general-relativity, differential-geometry, notation, conventions, tensor-calculus
or does it simply not matter that much?
Of course, the second way can be done more elegantly with a \newcommand
\newcommand{\christoffel}[2]{\Gamma^{#1}_{\hphantom{#1}#2}}
I know this is more of a LaTeX question, but I guess physicists know more about the core of the question than TeX-perts. Horizontal position of indices matters in principle because one might want to raise and lower indices on the Christoffel symbols. If the horizontal position of indices are not observed in a consistent manner, it becomes ambiguous which index was raised or lowered, and so forth, in particular if the connection is not torsionfree. Also note that different authors use different notations and horizontal orderings, e.g. $\Gamma^{\mu}{}_{\alpha\beta}$ vs. $\Gamma_{\alpha\beta}{}^{\mu}$.
TeX note:
You should write $\Gamma^{\mu}{}_{\beta\alpha}$ as
\Gamma^{\mu}{}_{\beta\alpha}
instead of using phantoms for spacing. | {
"domain": "physics.stackexchange",
"id": 27642,
"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": "general-relativity, differential-geometry, notation, conventions, tensor-calculus",
"url": null
} |
python, gnuradio
What is the best way of doing this?
Is this possible to accomplish using a custom embedded python block that has one input and one output that only allows a predetermined number of samples through to the output after the threshold has been reached and never allows any more samples through? For a signal that you expect to stay above the threshold once reached, you can use the "Power Squelch" block, with the "Gate" parameter set to "True", followed by a "Head" Block, set to 10,000 samples. | {
"domain": "dsp.stackexchange",
"id": 8855,
"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, gnuradio",
"url": null
} |
c++, array
Title: K largest elements in an array I solve problems to prepare for interviews. Now I have written the algorithm of finding K largest numbers in array. Various solutions are described here: https://www.geeksforgeeks.org/k-largestor-smallest-elements-in-an-array/. Initially, I came up with the solution myself and looks my solution corresponds to that described as Method 2 on the site, with the difference that I additionally use the "old minimum" to cut off unnecessary steps along the nested loop.
What could be written better in my code? What could be used instead of pmin?
Here is my implementation:
using namespace std;
vector<int> largest_part_of_vector(const vector<int>& vec, int K_PartSize)
{
assert(K_PartSize < vec.size());
vector<int> ret(K_PartSize);
// Initial filling of temporary vector
int ind = 0; // main end-to-end index
int* pmin = const_cast<int*>(&vec[0]); // current minimum
// How `pmin` could be declared and used better? | {
"domain": "codereview.stackexchange",
"id": 42272,
"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++, array",
"url": null
} |
performance, php, algorithm
How I might write it
I have used terrible variable names, because I don't have the time do work out the complete logic of your script, so this should be unit tested if your going to use it
function getColor($value, $values_range, $opacity = '0.7')
{
$deltaS = ($values_range['max'] - $values_range['min']) / 2;
$ds = ($value - $values_range['min']) / $deltaS;
$nearest_color_index = floor($ds);
$alpha = $ds - $nearest_color_index; | {
"domain": "codereview.stackexchange",
"id": 31493,
"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": "performance, php, algorithm",
"url": null
} |
javascript, dom
document.getElementById("slideM5").className="";
document.getElementById("slideC1").style.display="none";
document.getElementById("slideC2").style.display="none";
document.getElementById("slideC3").style.display="block";
document.getElementById("slideC4").style.display="none";
document.getElementById("slideC5").style.display="none";
break;
case 4:
document.getElementById("slideM4").style.backgroundColor="#009CFF";
document.getElementById("slideM4").className="show";
document.getElementById("slideM1").style.backgroundColor="silver";
document.getElementById("slideM2").style.backgroundColor="silver";
document.getElementById("slideM3").style.backgroundColor="silver";
document.getElementById("slideM5").style.backgroundColor="silver";
document.getElementById("slideM1").className=""; | {
"domain": "codereview.stackexchange",
"id": 3824,
"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, dom",
"url": null
} |
general-relativity, gravity, mass-energy
Title: What is the real world interpretation of $E = mc^2$? Why I am asking this question:
There appears to be a logical contradiction in the notion that gravity is "one thing"
mass moves in gravity much differently than light (a massless particle)
allowing light to be truly massless, light follows the space-time curve
mass follows the space time curve + some additional direct mass-mass component
The geodesic path for massive objects:
$$\frac{d p^\mu}{d\lambda} + \Gamma^\mu_{\beta\sigma}p^\beta p^\sigma = 0$$
And the geodesic path for massless objects:
$$\frac{d p^0}{d\lambda} + \Gamma^0_{00}p^0p^0= 0$$ | {
"domain": "physics.stackexchange",
"id": 88078,
"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": "general-relativity, gravity, mass-energy",
"url": null
} |
applications of this, so I'll walk you through several different types. For example: suppose the radius of a circle is increasing at the constant rate of 2 inches per second. He goes 288 upstream and downstream. 9 per 100,000 in 2008, according to the latest figures from the U. It will be directly tested | Quiz 6, Exam 1, and the Final Exam. A pebble is thrown into water and causes a circular ripple to spread outwards at a rate of 2 ft/s. At the instant the the depth of the water is 0. Visual Calculus - Derivatives. A trough is being filled up with swill. Water is poured into the cup at a constant rate of 2cm /sec. 0 Slideshow. Is the area of the slick increasing or decreasing? To solve this problem you have to identify what the problem is giving you in terms of information and find out what it is asking of you. Video transcript. AP Calc related rates question: a stone dropped into a still pond? a stone dropped into a still pond sends out a circular ripple whose radius increases at a | {
"domain": "studiotamarapani.it",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.983342959990771,
"lm_q1q2_score": 0.815131143503781,
"lm_q2_score": 0.8289388104343893,
"openwebmath_perplexity": 639.9930241551878,
"openwebmath_score": 0.5510013699531555,
"tags": null,
"url": "http://grhr.studiotamarapani.it/related-rates-ripple-problem.html"
} |
python, performance, sorting, mergesort
The slice creates a new list and copies the elements in L into it. That works fine when you are dealing with small lists, but in the lists you are playing with here, thats gonna be a significant speed drain. For the most efficiency in cases like this you need to avoid creating new lists altogether and just move stuff between elements in the same list.
All in all, it isn't really much slower then I'd expect the algorithm you are implementing to be in Python. Nothing you are doing should produce pathologically bad performance. However, there is a reason why we use a sort implementation in C. If you are just interested in implementing algorithms for the learning experience, I suggest you use smaller lists. Thats a lot of data to sort with a bad algorithm. | {
"domain": "codereview.stackexchange",
"id": 307,
"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, performance, sorting, mergesort",
"url": null
} |
python, beginner, file, serialization, pyqt
gridLayout.addWidget(self.separator, 3, 1, 1, 2)
gridLayout.addWidget(self.exportLbl, 4, 1, 1, 2)
gridLayout.addWidget(self.exportTxt, 5, 1, 1, 1)
gridLayout.addWidget(self.setAnimBtn, 5, 2, 1, 1)
gridLayout.addWidget(self.exportCombo, 6, 1)
gridLayout.addWidget(self.exportAnimBtn, 7, 1, 1, 2)
self.setLayout(gridLayout)
self.setWindowTitle("IMPORT / EXPORT ANIMATION KEYFRAMES")
def createConnections(self):
# Connections for Import
self.connect(self.openAnimBtn, SIGNAL('clicked()'), self.openFile)
self.connect(self.importAnimBtn, SIGNAL('clicked()'), self.importAnim)
# Connections for Export
self.connect(self.setAnimBtn, SIGNAL('clicked()'), self.setDirectory)
self.connect(self.exportAnimBtn, SIGNAL('clicked()'), self.exportFunc)
def openFile(self):
""" Module for importing in .txt anim files """ | {
"domain": "codereview.stackexchange",
"id": 10531,
"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, file, serialization, pyqt",
"url": null
} |
• Your answer very helpful. Can $C^2$ with $C$ as the field have such a basis vector that contains $i$ as a possible component in place of the 1's, 0's Or not.. Aug 2 '20 at 19:42
• @Shashaank Indeed, one can "rotate" the standard basis of $\mathbb{C}^2$ viewed as a v.s. over $\mathbb{C}$ to obtain the basis $\{ (i,0), (0,i) \}$ just as one could rotate any basis of $\mathbb{R}^2$ over $\mathbb{R}$. Feb 17 at 18:21
• @CharalambosKioulos Thanks for your comment. I also wanted to know that when the basis vectors are written like this -(i,0) etc, then what is exactly “i” or “0” here. Is it a component or what? Because my understanding is that in a term like 2(i,0), 2 is the component along that specific basis vector. But what exactly is “i” or “0” in that term? Feb 17 at 18:28 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9632305328688783,
"lm_q1q2_score": 0.8005823608788303,
"lm_q2_score": 0.8311430478583169,
"openwebmath_perplexity": 266.5135486962735,
"openwebmath_score": 0.785631000995636,
"tags": null,
"url": "https://math.stackexchange.com/questions/123448/what-is-the-standard-basis-for-fields-of-complex-numbers/123450"
} |
rosinstall, osx
Originally posted by William with karma: 17335 on 2011-08-08
This answer was ACCEPTED on the original site
Post score: 4
Original comments
Comment by William on 2011-08-12:
I don't know exactly, it looks like there are three print statements and they are only using one, and there fore you can safely comment the one in my patch out. I didn't look very hard though, and that function might be needed, but I haven't run into problems yet.
Comment by LucaGhera on 2011-08-11:
@William Fine! It works, now I can finally compile the base stacks. Does this patch exclude some important feature? | {
"domain": "robotics.stackexchange",
"id": 6226,
"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": "rosinstall, osx",
"url": null
} |
c#, performance, game, state-machine
Title: Increase difficulty based on score What I'm trying to do is very straightforward and easy, but I am wondering whether there is a more elegant solution.
Basically I have a game and I want the difficulty to increase the moment the score gets between 100 - 500, then increase once again when the score is between 500 - 1500, then again when the score is between 1500 - 3000. In total, the difficulty should increase 3 times.
I need to check:
Whether I am in one of those ranges.
Whether I already increased the score when I got in that range.
Here's what I've got.
bool Increased100500 = false;
bool Increased5001500 = false;
bool Increased15003000 = false; | {
"domain": "codereview.stackexchange",
"id": 41612,
"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, game, state-machine",
"url": null
} |
stability
Title: Energy lost due to stability We used to say that when an atom is stable it is in its minimum energy state.Every shell has its fixed energy. So from where does the energy come which is lost by an atom to achieve stability.
Do electrons lose energy? If yes then will there be any effect of the lose of energy on the speed of electron revolving around the nucleus.
Thank you
Sorry for the English. Let call it rather the atom ground state and the atom excited state.
Same excited states can be kinetically quite stable, like atomized hydrogen in interstellar space with mutual parallel (excited state) and antiparallel ( ground state) proton and electron spin. This spin flipping is the source of the famous 21 cm hydrogen spectral line, used as the scale for the Pioneer cosmic sons plaquette.
Excited atom states have higher energy of electrons than ground states. This energy consists of kinetic and potential energy. | {
"domain": "chemistry.stackexchange",
"id": 13848,
"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": "stability",
"url": null
} |
Funny thing is, there is no need to "solve for x". One can answer the question directly.
#### Jomo
##### Elite Member
Hello,
i found this question over the internet from an aptitude practice exam.
cant solve this problem..
below are the Question and Answer.
Q > if 2/5 of 3x=120, what is 1/5 of x?
A > First we find what 2/5 of 1x is by dividing 120 by 3=40.
if 2/5 of x=40, then 1/5 of x must be 40/2=20.
may i know what topic should i study so i can understand this problem?
Thanks
3x=120, is the same as x = 40
Now that you know x, they are saying that 2/5 of x = 40
Now 1/5 is half of 2/5.
So to find 1/5 of x, 1/5 of 40 just compute half of 40 = 20.
Which step in any solution you viewed do you not understand?
#### JeffM
##### Elite Member
Hello,
i found this question over the internet from an aptitude practice exam.
cant solve this problem..
below are the Question and Answer. | {
"domain": "freemathhelp.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9744347890464283,
"lm_q1q2_score": 0.8243157423364732,
"lm_q2_score": 0.845942439250491,
"openwebmath_perplexity": 1802.6299850743274,
"openwebmath_score": 0.780571460723877,
"tags": null,
"url": "https://www.freemathhelp.com/forum/threads/help-on-this-problem.121051/"
} |
ros, turtlebot, create-robot, turtlebot-bringup
NODES
/
appmaster (app_manager/appmaster)
app_manager (app_manager/app_manager)
turtlebot_node (turtlebot_node/turtlebot_node.py)
turtlebot_laptop_battery (turtlebot_node/laptop_battery.py)
robot_state_publisher (robot_state_publisher/state_publisher)
diagnostic_aggregator (diagnostic_aggregator/aggregator_node)
robot_pose_ekf (robot_pose_ekf/robot_pose_ekf)
ROS_MASTER_URI=http://192.168.1.15:11311 | {
"domain": "robotics.stackexchange",
"id": 7447,
"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, turtlebot, create-robot, turtlebot-bringup",
"url": null
} |
and I have tried proving its convexity via definition of a convex function with above inequalities. But that didn't work.
EDIT2: I have posted my answers below.
• Composition rules for preserving convexity. But it didn't work – Finley Sep 6 '17 at 4:18
• What about using induction? – Sergio Enrique Yarza Acuña Sep 6 '17 at 4:53
• A possible duplicate of math.stackexchange.com/questions/2416837/… – Math Lover Sep 6 '17 at 4:58
• @MathLover : It seems that I need to compute the Hessian of $f(x)$ that I tried to avoid before. – Finley Sep 6 '17 at 5:10
• @Finley At this moment, I can't think of any other way to prove that the function is convex. The individual entries of the Hessian matrix are given in math.stackexchange.com/questions/2416837/…. A proof is also given based on the C-S inequality. – Math Lover Sep 6 '17 at 5:13
Proof: | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9728307653134903,
"lm_q1q2_score": 0.846943795473698,
"lm_q2_score": 0.8705972566572503,
"openwebmath_perplexity": 472.21297594119017,
"openwebmath_score": 0.919211208820343,
"tags": null,
"url": "https://math.stackexchange.com/questions/2418554/why-log-of-sum-of-exponentials-fx-log-left-sum-limits-i-1n-e-x-i-righ"
} |
c++, multithreading, locking
The thread doesn't make things more efficient. Either the interval it sleeps for is too large for the rate at which put() is called, in which case put() will do all the eviction work anyway, or it is too short and wastes CPU cycles for nothing, and even if the interval is perfectly balanced with regards to the frequency of put() and get() calls, the latter two functions still can't rely on the thread to have kicked in at the right time.
Without a thread you also don't have to deal with thread cleanup, and avoid having to wait 0.75 seconds on average when destroying an instance of LRUCache.
Use std::size_t for count, capacity and indices
An int might not be large enough to represent the maximum size a container can be. Furthermore, specifying a negative capacity leads to disaster. The right type for storing counts, sizes and indices is std::size_t.
Don't use a special value to indicate that an item was not in the cache | {
"domain": "codereview.stackexchange",
"id": 44581,
"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++, multithreading, locking",
"url": null
} |
exoplanet
Measurments of this type rely on very precise astrometry, which is the determinaton of an object's position. This may sound easier to do than it actually is. In the above figure the error bars of each measurment used are also given, and to suppress them to small values and at the same time make them accurate is the challenge here. One can see that the errors are of the order of 10 milliarcseconds. From the ground this precision is at the moment at the limit of what we can do, better will only Gaia be with errors down to 10-100 microarcseconds.
But Gaia doesn't have the angular resolution for such systems which has slightly worse than 0.1 arcseconds angular resolution . | {
"domain": "astronomy.stackexchange",
"id": 1958,
"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": "exoplanet",
"url": null
} |
ros
Note that I created the file via Rhino.
I'm not sure I understand what this implies.
Meshes generated by modelling tools tend to be overly detailed.
How big is the .stl (as in: in bytes)?
Comment by JCatania on 2022-04-03:
The file is 2.9 kB. It must have both visual and collision meshes, as when I loaded the end effector on Gazebo, it loaded correctly.
Comment by gvdhoorn on 2022-04-03:\
It must have both visual and collision meshes, as when I loaded the end effector on Gazebo, it loaded correctly.
No, that's not how it works.
Your .stl file contains a single shape. If you don't specify a different file, your "high quality" model will just be used for both purposes.
The file is 2.9 kB.
Then it's likely OK to reuse the same file for both purposes. | {
"domain": "robotics.stackexchange",
"id": 37548,
"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
} |
lambda-calculus, denotational-semantics, scheme, operational-semantics
With this definition, the answer is no: delimited control is not macro-expressible in the lambda-calculus + call/cc. To express delimited control operators using call/cc. In order to implement the control delimiters (the reset part of shift/reset), you need some state to simulate the continuation marks, essentially to encode a stack to simulate the dynamic lifetimes of the continuation marks.
However, delimited control is a universal effect, in the following sense. In his PhD thesis, Andrzej Filinski showed that any expressible side effect is encodable using either delimited continuations, or call/cc and a single cell of state. Roughly, an "expressible side effect" is any effect whose monadic type can be defined in terms of the types of the programming language. | {
"domain": "cstheory.stackexchange",
"id": 1890,
"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": "lambda-calculus, denotational-semantics, scheme, operational-semantics",
"url": null
} |
quantum-mechanics, hilbert-space, operators, angular-momentum, commutator
the case of $\ell=0$, where there is a single state involved; and
the case of $j=1/2$, where every eigenstate of $J^2$ is an eigenstate of a component $\hat{\mathbf n}\cdot\mathbf J$ of $\mathbf J$ along some direction $\hat{\mathbf n}$ (but not necessarily the restricted set of Cartesian coordinates along some pre-chosen set of axes);
but for anything bigger than that, the sets in question are just different enough that you cannot really compare them. | {
"domain": "physics.stackexchange",
"id": 83661,
"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, operators, angular-momentum, commutator",
"url": null
} |
general-relativity, notation, volume, diffeomorphism-invariance
Now expand, using the distributive law, but you must preserve the order since dx $\otimes$ dy is noncommutative multiplication, it is not equal to dy $\otimes dx$.
Then there is quite a lot of cancellation and some like terms to collect, and you will see that you do indeed get the determinant (in this case, the 2x2 determinant) of the transformation, i.e., the Jacobian. | {
"domain": "physics.stackexchange",
"id": 73786,
"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": "general-relativity, notation, volume, diffeomorphism-invariance",
"url": null
} |
# Indefinite integral of $\int x\sqrt{x-1} \, \mathrm dx$
How can I evaluate the indefinite integral $$\int x\sqrt{x-1} \, \mathrm dx?$$
I tried to calculate it using integration by parts, I get $$\int x\sqrt{x-1} \, \mathrm dx = \frac{2}{3}x(x-1)^{3/2} - \frac{2}{3}\cdot\frac{2}{5}\cdot(x-1)^{5/2}$$
But this is not the correct solution, and I don't understand why.
In the integration by parts formula I used $$f(x)=x$$ and $$g'(x)=(x-1)^{1/2}$$ so $$f'(x)=1$$ and $$g(x)=(x-1)^{3/2}\cdot\frac{2}{3}$$.
What did I do wrong? I know I should use substitutional integral, but why does my solution not work? Thank you | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9752018398044143,
"lm_q1q2_score": 0.8040167811418721,
"lm_q2_score": 0.8244619199068831,
"openwebmath_perplexity": 707.6069490054255,
"openwebmath_score": 0.7362444400787354,
"tags": null,
"url": "https://math.stackexchange.com/questions/3224308/indefinite-integral-of-int-x-sqrtx-1-mathrm-dx"
} |
light applications, it is very useful to be able to receive a wide range of frequencies and be able to pinpoint which frequencies are the loudest/brightest. Google Scholar. Description of the method. Module 22 - Power Series; Lesson 22. 2 - Maclaurin Series; Lesson 24. THE METHOD OF FROBENIUS We have studied how to solve many differential equations via series solutions. Video tutorial on Power Series Solutions of Differential Equations - In this video, I show how to use power series to find a solution of a differential equation. So, the convergence of power series is fairly important. 1126 CHAPTER 15 Differential Equations In Example 1, the differential equation could be solved easily without using a series. The general Airy differential equation is given by :$D^2y \pm m^2 x y = 0$or equivalently$y’’ \pm m^2 x y = 0$The differential equation in the question is a form of the Airy differential equation with the minus sign preceding $m^2$. 1 - Power Series; Lesson 24. 2 Series | {
"domain": "sicituradastra.it",
"id": null,
"lm_label": "1. Yes\n2. Yes",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9902915223724212,
"lm_q1q2_score": 0.8738608306621545,
"lm_q2_score": 0.8824278618165526,
"openwebmath_perplexity": 599.5197649938564,
"openwebmath_score": 0.7561150193214417,
"tags": null,
"url": "http://jtbv.sicituradastra.it/power-series-calculator-differential-equations.html"
} |
sas
I have added the informat line. The problem with the original code is that you have not told SAS what is the format that DOB will come in. In this case: 22jan1996 is of date9. format, so I added the informat telling SAS that the data will come in this way.
The format DOB line tells SAS to display the data as mmddyy10. which makes 22jan1996 look like 01/22/1996.
Lastly, the . before the ; in the format/informat lines specifies that it is a format type. There are character formats: $8. or numeric formats Best12. etc... | {
"domain": "datascience.stackexchange",
"id": 7979,
"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": "sas",
"url": null
} |
ros, environment-server
The amount of boiler plate code to do the same thing has grown since electric.
I'd rather not get/set the same planning scene multiple times from many (possibly remote) nodes, if they will all operate on the same scene.
TIA | {
"domain": "robotics.stackexchange",
"id": 9748,
"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, environment-server",
"url": null
} |
forces, electrostatics, rotational-dynamics, integration
A possible culprit is the conducting part of the electroscope which may also have electrons and thus repel both the gold leaves. But assuming that all three have the same no: of electrons then shouldn't the angle always be $120$. It definitely may not be the effect of gravity as the force of gravity is weak compared to the electrostatic forces
Then there's the elephant in the room, how do you integrate this knowing every point on the is effected by every other point on the leaves
TIA It's not possible to find the magnitude of the charge of an object placed on the type of electroscope in the picture.
To see this imagine the charged object was the same size and material as the conducting part of the electroscope and has charge $2Q$. Then half the charge would go onto the electroscope and half would stay on the charged object. | {
"domain": "physics.stackexchange",
"id": 80617,
"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, electrostatics, rotational-dynamics, integration",
"url": null
} |
quantum-field-theory, operators, differentiation, dirac-equation, dirac-matrices
Title: Hermitian adjoint of 4-gradient in Dirac equation I'm having issues deriving the Dirac adjoint equation, $$\overline{\psi}(i\gamma^{\mu}\partial_{\mu}+m)=0.\tag{1}$$
I started by taking the Hermitian adjoint of all components of the original Dirac equation, giving me | {
"domain": "physics.stackexchange",
"id": 72196,
"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, operators, differentiation, dirac-equation, dirac-matrices",
"url": null
} |
ros, cmake, rosbuild
rosbuild_init()
#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
#uncomment if you have defined messages
#rosbuild_genmsg()
#uncomment if you have defined services
#rosbuild_gensrv() | {
"domain": "robotics.stackexchange",
"id": 20551,
"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, cmake, rosbuild",
"url": null
} |
scikit-learn, clustering
Title: Spectral clustering result interpretation I cluster a toy data set into three groups with spectral clustering. Please see the code below. affinity='rbf' by default.
from sklearn.cluster import SpectralClustering
import numpy as np
points = np.array([[5,6], [3,3], [2,2], [7,3], [8,3], [5,4], [5,5], [9,3], [7,1]])
spectral = SpectralClustering(n_clusters=3)
labels = spectral.fit(points).labels_
The output is three clusters with labels [1 2 2 0 0 1 1 0 2] shown on the image. Why point 8 happens to be in the same cluster with 1 and 2, not with points 3,4, and 7?
UPDATE:
Affinity matrix: | {
"domain": "datascience.stackexchange",
"id": 4219,
"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": "scikit-learn, clustering",
"url": null
} |
r
Should you be interested in the custom system route, this discussion might be worth reading, as it contains some interesting pricing numbers (just to get an idea of potential savings) and also sheds some light on multiprocessor vs. multi-core alternatives (obviously, the context is different, but nevertheless could be useful). As I said, I would go the COTS route, mainly due to reliability and compatibility issues. In terms of single-processor multi-core systems, your budget is more than enough. However, when we go to multiprocessor workstations (I'm not even talking about servers), even two-processor configurations can go over your budget easily. Some, not far away, such as HP Z820 Workstation. It starts from 2439 USD, but in minimal configuration. When you upgrade it to match your desired specs (if it's even possible), I'm sure that we'll be talking about 5K USD price range (extrapolating from the series' higher-level models). What I like about HP Z820, though, is the fact that this | {
"domain": "datascience.stackexchange",
"id": 189,
"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": "r",
"url": null
} |
c#, k-sum
first_i and second_i are also rather useless,
and would have been to use their values directly inside the loop statements.
Also keep in mind that declaring variables at the top of their scope,
when they are not used until much later,
is not a recommended practice.
It's best to declare a variable right before you need it.
Correctness
As @RiskyMartin hinted, given an input list 1, 6, 9, the output will be incorrectly (6, 6). In other words, you need to make sure that i and j indexes are not equal.
Performance
Of course, none of the above help with the performance.
The algorithm is \$O(n^2)\$: you try all permutation of pairs.
To make this faster, you can sort the input list, and then form pairs using two pointers, one going from the start and one going from the end.
Move the pointers closer when the sum of the pointed values is above the target sum.
The performance of this algorithm will be \$O(n\log(n))\$:
the sorting step is \$O(n\log(n))\$, | {
"domain": "codereview.stackexchange",
"id": 19893,
"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#, k-sum",
"url": null
} |
javascript, node.js, express.js
event.update({
'active': event['active']
}, defaultError(function() {
res.end('Success!');
}));
}));
};
Now obviously the defaultError can also customize the rendered error,
so as long as error is in a fixed position in the call, this pattern
can be used to build a small control flow abstraction.
The cost here is a possible speed penalty due to the manipulation of arguments and the apply call.
If you had promises a generic error handler would be equally
viable, but it looks like that is not an option. | {
"domain": "codereview.stackexchange",
"id": 12038,
"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, node.js, express.js",
"url": null
} |
qiskit, programming, ibm-q-experience
Title: How to execute many circuits on an IBMQ backend? I attempted to execute a list of $3200$ QuantumCircuits in Qiskit, each with the max_shots of $8096$ as follows:
ibmq_manhattan = provider.get_backend('ibmq_manhattan')
job = execute(all_qc, backend=ibmq_manhattan, shots=8096)
job_monitor(job)
and got the following response:
Job Status: job has been cancelled
Furthermore, I successfully performed the exact same execution locally using the Aer qasm_simulator. Presumably this is because there is a runtime timeout on the IBMQ backend device which is triggered as one might expect for such a large list. Is this correct? and if so how can I bypass this limitation?
This is a summary of the job on IBMQ: If you have more circuits than what the backend allows, consider using IBMQJobManager, which will divide the circuits and collect results for you. | {
"domain": "quantumcomputing.stackexchange",
"id": 1910,
"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": "qiskit, programming, ibm-q-experience",
"url": null
} |
php
protected function PostExecute(){
// handle $_POST data
}
}
I am very satisfied with the ease of use of this approach. However, I can't think of a way to extend this approach to more than 2 url params. Currently it only handles urls of format /api/v1/param1 and /api/v1/param1/param2. I'd like to extend it to also handle /api/v1/param1/param2/param3 and /api/v1/param1/param2/param3/param4. The Express way is the following:
app.get('/users/:userId/books/:bookId', function (req, res) {
res.send(req.params)
}) | {
"domain": "codereview.stackexchange",
"id": 37250,
"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": "php",
"url": null
} |
photons, electric-current, wave-particle-duality, photoelectric-effect, solar-cells
Title: How current is produced in photoelectric cell?
In photoelectric cells, a current is detected when photoelectrons reach the electrode on the opposite side of the tube after being emitted. But shouldn't current be detected when photoelectrons leave the first electrode and not just when they reach the second electrode? Because this would create a positive charge on the first electrode which they are emitted from, so a redistribution of electrons in the external wire and therefore a current.
I don't know if I've explained it well enough, so here is a diagram to show what I mean...
Also, I don't understand how a current is detected when electrons reach the electrode on the opposite side. Is it because of an excess negative charge it gains? | {
"domain": "physics.stackexchange",
"id": 68316,
"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": "photons, electric-current, wave-particle-duality, photoelectric-effect, solar-cells",
"url": null
} |
November 5th, 2019, 07:31 AM #3 Math Team Joined: Jul 2011 From: Texas Posts: 3,093 Thanks: 1675 One final note ... the author of this problem used the equation $a = -ks$, which was a bit misleading at first. The actual equation should be $F = -ks \implies ma = -ks \implies a = -\dfrac{k}{m} \cdot s$ $F$ is the restoring force when an object is displaced from equilibrium, acting opposite in direction to the object's displacement. ... he/she just replaced the constant $\dfrac{k}{m}$ with a $k$ Thanks from topsquark and Chemist116
November 7th, 2019, 12:53 AM #4
Senior Member | {
"domain": "mymathforum.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9688561676667173,
"lm_q1q2_score": 0.8156079762068269,
"lm_q2_score": 0.8418256532040707,
"openwebmath_perplexity": 954.4220339483282,
"openwebmath_score": 0.7868483066558838,
"tags": null,
"url": "http://mymathforum.com/physics/347393-how-do-i-find-constant-oscillation-given-sphere-motion.html"
} |
python, game-of-life, pygame
for i in range(THE_SIZE-1):
ip1 = i + 1
for j in range(THE_SIZE-1):
jp1 = j + 1
if board[ip1][jp1]: counts[i][j] += 1
if board[i][jp1]: counts[ip1][j] += 1
if board[ip1][j]: counts[i][jp1] += 1
if board[i][j]: counts[ip1][jp1] += 1
return counts | {
"domain": "codereview.stackexchange",
"id": 12795,
"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, game-of-life, pygame",
"url": null
} |
ros, navigation, differential-drive, dwa-local-planner, move-base
dwa_local_planner params:
DWAPlannerROS:
#Robot Config Params
acc_lim_theta: 0.35
acc_lim_x: 0.3
acc_lim_y: 0.0
acc_limit_trans: 0.35
max_vel_x: 0.25
min_vel_x: -0.1
max_vel_y: 0.0
min_vel_y: 0.0
max_trans_vel: 0.25
min_trans_vel: 0.01
max_rot_vel: 0.25
min_rot_vel: 0.01
#Forward Simulation Parameters
sim_time: 10
sim_granularity: 0.025
vx_samples: 30
vy_samples: 0
vtheta_samples: 40
penalize_negative_x: false
#Trajectory Scoring Parameters
goal_distance_bias: 32.0
path_distance_bias: 24
occdist_scale: 0.01
stop_time_buffer: 0.2
forward_point_distance: 0.325
scaling_speed: 0.1
max_scaling_factor: 0.2
#Goal Tolerance Parameters
xy_goal_tolerance: 0.2
yaw_goal_tolerance: 0.17
latch_xy_goal_tolerance: true
rot_stopped_vel: 0.001
trans_stopped_vel: 0.001
#Oscillation Prevention Param
oscillation_reset_dist: 0.05
#Global Plan PArameters
prune_plan: true | {
"domain": "robotics.stackexchange",
"id": 20656,
"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, navigation, differential-drive, dwa-local-planner, move-base",
"url": null
} |
homework-and-exercises, newtonian-mechanics, forces, energy-conservation, spring
Title: Max extension of spring mass system While attempting problems of simple harmonic motion I came across this problem, which has gotten me confused.
A fixed horizontal spring is stretched by a constant force $F$. I am required to obtain the maximum elongation of that spring. But the problem is which method is correct, the energy method or the force method? Do let me know the misconception in the wrong path.
Method 1:
$$\text{For Equilibrium}\\ \; F= kx_\text{max}\\ \implies x_\text{max}= \frac{F}{k}\;.$$
Method 2: | {
"domain": "physics.stackexchange",
"id": 26356,
"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, forces, energy-conservation, spring",
"url": null
} |
php, object-oriented, wordpress
4 query variables are set to the URL according to archive page, ie, one query variable for taxonomy pages, one query variable set for the author pages and so one. No page can ever have more than one custom query variable. This 4 variables is retrieved by my first class and checked against a given global variable, in this case $_GET. I have not hardcoded the 4 variables in my class, and this goes for $_GET as well to keep the class testable. If the value exists in the URL, the key/value pair is returned through the has* methods. These methods return null if no match is found. (this is raw data which will be sanitized/escaped by the classes that will use this data)
Here is the full class:
<?php
namespace PG\Single\Post\Navigation; | {
"domain": "codereview.stackexchange",
"id": 12353,
"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": "php, object-oriented, wordpress",
"url": null
} |
ros, python, rosbuild
Originally posted by Nathan Wong on ROS Answers with karma: 3 on 2013-04-05
Post score: 0
This [tutorial](http://www.ros.org/wiki/roscpp_tutorials/Tutorials/Publisher and Subscriber with Parameters and Dynamic Reconfigure) shows how to do that. In particular, you could look at the Python node which prints out multiple variables from a custom message.
Originally posted by Thomas D with karma: 4347 on 2013-04-05
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by Nathan Wong on 2013-04-07:
Thank you this was very useful! :) | {
"domain": "robotics.stackexchange",
"id": 13700,
"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, python, rosbuild",
"url": null
} |
error-handling, f#
Please let me know how I would achieve what I want in an idiomatic style.
Here's my code. All above bind2 is taken broadly from Scott's code, the remainder is my bind2 function and a simple demo.
type Result<'S, 'F> =
| Success of 'S
| Failure of message : 'F list | {
"domain": "codereview.stackexchange",
"id": 22075,
"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": "error-handling, f#",
"url": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.