text stringlengths 1 1.11k | source dict |
|---|---|
• You have to express $T(e_1)$ and $T(e_2)$ in the basis $\{e_1,e_2\}$. – Guest Mar 6 '15 at 20:46
If $T(i)=(1,1)$ and $T(j)=(2,-1)$ and $e_1=i-j=(1,-1)$ and $e_2=3i+j=(3,1)$, then $$T(e_1)=T(i-j)=T(i)-T(j)=(-1,2)=a_1e_1+b_1e_2 \,\text{(say)}$$ and $$T(e_2)=T(3i+j)=3(1,1)+(2,-1)=(5,2)=a_2e_1+b_2e_2\,\text{(say)}.$$ Thus the matrix of $T$ w.r.t. the new basis $\{e_1,e_2\}$ is $\begin{pmatrix} a_1 & a_2\\ b_1 & b_2 \end{pmatrix}$ and you need to find the values of $a_1,a_2,b_1$ and $b_2$. The above systems of equations reduces to $$a_1+3b_1=-1\\ -a_1+b_1=2$$ and
$$a_2+3b_2=5\\ -a_2+b_2=2.$$ Solve these equations to obtain $a_1=-\frac{7}{4},b_1=\frac{1}{4},a_2=-\frac{1}{4}$ and $b_2=\frac{7}{4}$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446486833801,
"lm_q1q2_score": 0.8155441969031585,
"lm_q2_score": 0.8376199653600372,
"openwebmath_perplexity": 282.1121045694154,
"openwebmath_score": 0.9236588478088379,
"tags": null,
"url": "https://math.stackexchange.com/questions/1178741/find-matrix-of-linear-transformation"
} |
optics, reflection
The argument is reversible starting from B and traveling to a reflected point of A, call it A'. This line also intersects the mirror at M.
Now consider a line dropped from B to B' and call where it intersects the mirror N. Let P be a point also on the mirror on the opposite of M from N but the same distance. It can be proven triangles MNB and MNB' are congruent by the SAS rule of congruent triangles. Angle AMO and NMB' are vertical angles and vertical angles are congruent. The angle of incidence of ray is measured from the normal to the plane it intersects and congruent angles have congruent angles have congruent complements, so it follows that the angles of incidence are congruent. | {
"domain": "physics.stackexchange",
"id": 83623,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "optics, reflection",
"url": null
} |
the-sun, solar-system, n-body-simulations, orbital-migration
This is clearly after the time when the Sun is becoming a red giant in 4.5 – 5.5 billion years - this is the number given in an article Will Earth survive when the sun becomes a red giant? by
Matt Williams from 2016.
References
The first post is refering to a scientific article On the Dynamical Stability of the Solar System by Konstantin Batygin and Gregory Laughlin. | {
"domain": "astronomy.stackexchange",
"id": 5241,
"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": "the-sun, solar-system, n-body-simulations, orbital-migration",
"url": null
} |
For example, if $y = x + 1$ and $z = y + 1$, then $z = (x + 1) + 1 \implies z = x+2$. So currently, you don't have transitive closure. Both $(x, y), (y, z)\in R$, but $(x,z) \notin R$.
Note that $R = \{(x, y) \mid y = x\}$, by itself, is an equivalence relation (hence reflexive, symmetric, and transitive for all elements on which it is defined), as equality is perhaps the most fundamental of all equivalence relations.
Assuming we are talking about real numbers, we can get transitive closure (with reflexive closure), on the reals using the relation $R = \{(x, y)\mid y\leq x\}$. But this relation fails to by symmetric. "$\leq$" is a paradigmatic partial order relation on the set of reals: reflexive, antisymmetric, and, and transitive. Can you see why it is transitive, reflexive, but not symmetric? | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9715639653084245,
"lm_q1q2_score": 0.8138013729975875,
"lm_q2_score": 0.8376199633332891,
"openwebmath_perplexity": 240.2485354457037,
"openwebmath_score": 0.9318026900291443,
"tags": null,
"url": "http://math.stackexchange.com/questions/289038/reflexive-symmetric-and-transitive-closure-of-a-given-relation"
} |
implies that the sum, difference, differentiability implies continuity and quotient of any function satisfies conclusion... ' … differentiability also implies a certain “ smoothness ”, apart from mere continuity the conclusion of intermediate... The domains *.kastatic.org and *.kasandbox.org are unblocked at a=1 b=\answer [ given ] { -9 } point then. Not differentiable at a, 231 West 18th Avenue, Columbus OH, 43210–1174 from mere continuity — team... Defined and, we conclude that is continuous at a, then f ' ( a ) for! Line to be of class C 1 Differentiable at x = a, b containing. A certain “ smoothness ”, apart from mere continuity on \RR a web filter please... The conclusion of the intermediate Value theorem for derivatives derivative differentiability implies continuity, connecting differentiability continuity... Class C 1 team, 100 Math Tower, 231 West 18th Avenue, Columbus OH, 43210–1174 PRESENTED! Condition of differentiability and continuity, we see that if a function and be | {
"domain": "oscarfalk.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9820137874059599,
"lm_q1q2_score": 0.8423401126384558,
"lm_q2_score": 0.8577681122619883,
"openwebmath_perplexity": 922.7839848678535,
"openwebmath_score": 0.9041855335235596,
"tags": null,
"url": "http://oscarfalk.com/dc95nd/8e3611-differentiability-implies-continuity"
} |
waves, fourier-transform, boundary-conditions, superposition
Any wave on a string of any length (including an infinite string) can be presented by: $$y(x,y)=\Sigma^\infty_0 A_n \sin(k_n)\cos(\omega_nt-\delta_n)$$ The point of restricting the string to length $L$ is that we can then construct a periodic function (with wavelength $L$) by imagining repeated copies of the string connected to each other. In this case we can construct the function as a Fourier series with the lowest frequency sine/cosine having the same wavelength $L$.
If we have an infinite string then the function need not be periodic (though of course it may be). If the function is not periodic we can still use a Fourier description, but in this case it is a Fourier transform not a Fourier series. | {
"domain": "physics.stackexchange",
"id": 21167,
"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": "waves, fourier-transform, boundary-conditions, superposition",
"url": null
} |
inorganic-chemistry, nomenclature
Title: Is NaHCO₃ a carbonate? I know that $\ce{NaHCO3}$ is sodium bicarbonate, but According to Wikipedia:
In chemistry, a carbonate is a salt of carbonic acid, characterized by the presence of the carbonate ion, $\ce{CO3^{2-}}$. | {
"domain": "chemistry.stackexchange",
"id": 1307,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "inorganic-chemistry, nomenclature",
"url": null
} |
performance, comparative-review, swift, combinatorics
mutating func permute() -> Bool {
// Nothing to do for empty or single-element arrays:
if count <= 1 {
return false
}
// L2: Find last j such that self[j] <= self[j+1]. Terminate if no such j
// exists.
var j = count - 2
while j >= 0 && self[j] > self[j+1] {
j -= 1
}
if j == -1 {
return false
}
// L3: Find last l such that self[j] <= self[l], then exchange elements j and l:
var l = count - 1
while self[j] > self[l] {
l -= 1
}
swap(&self[j], &self[l])
// L4: Reverse elements j+1 ... count-1:
var lo = j + 1
var hi = count - 1
while lo < hi {
swap(&self[lo], &self[hi])
lo += 1
hi -= 1
}
return true
}
} | {
"domain": "codereview.stackexchange",
"id": 32763,
"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, comparative-review, swift, combinatorics",
"url": null
} |
# math
solve 2x^2+3x+8=0 and express the solutions in a+bi form.
Let's use the quadratic formula to solve for x and express those solutions in a+bi form.
x = [-b + or - sqrt(b^2 - 4ac)]/2a
Note: sqrt = square root.
a = 2, b = 3, and c = 8 from your problem.
Therefore:
x = [-3 + or - sqrt(3^2 - 4*2*8)]/2*2
x = [-3 + or - sqrt(-55)]4
x = [-3 + or - i sqrt(55)]/4
Solutions:
x = [-3 + i sqrt(55)]/4 = -3/4 + [sqrt(55)/4]i
x = [-3 - i sqrt(55)]/4 = -3/4 - [sqrt(55)/4]i
I hope this will help.
1. 1
## Similar Questions
1. ### Math
Solve the given quadratic equation exactly using the quadratic formula. Write the solutions in its simplest form. Using a calculator, determine all irrational solutions to the nearest thousandth. Separate the solutions with a
2. ### Math | {
"domain": "jiskha.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9886682468025243,
"lm_q1q2_score": 0.8151193315704056,
"lm_q2_score": 0.8244619306896955,
"openwebmath_perplexity": 767.8722245180605,
"openwebmath_score": 0.8167388439178467,
"tags": null,
"url": "https://www.jiskha.com/questions/9591/solve-2x-2-3x-8-0-and-express-the-solutions-in-a-bi-form-Lets-use-the-quadratic"
} |
general-relativity, spacetime, metric-tensor
And here is the given solution:
I managed to derive the correct form of $\epsilon$ myself but am confused as to why implies the space-time is therefore Minkowski. My current thought is that it's something to do with being a gauge transformation but I'm not certain why this might be the case.
Any help is much appreciated! If the coordinate transformation removes h terms to first order then the metric is just left as
$$
ds^2 = -c^2dt^2+dx^2+dy^2+dz^2 \tag{1}
$$
which is clearly just the Minkowski metric in Cartesian coordinates.
i.e. Its the choice of coordinates used initially that caused it to look 'non-flat' and so with a simple coordinate transformation, you recover flat space.
You could say its the 'y' coordinate initially that's stealthily a non-Cartesian coordinate, but they're just variables after all, so its acceptable. The true Cartesian 'y' coordinate is in the RHS of the coordinate transformation: $`\mathbf{y}+h\varepsilon'$. | {
"domain": "physics.stackexchange",
"id": 66019,
"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, spacetime, metric-tensor",
"url": null
} |
artificial-intelligence, neural-networks, big-data, perceptron
Title: Learning a perceptron from stream data I want to train a Perceptron using stochastic gradient rulefrom the stream data. I have very limited amount of memory and i can store only $N$ examples.
Suppose my population consist of point as show in the following picture:
Now suppose my first $N$ examples come in following fashion and i can classify them correctly as show in the next picture: | {
"domain": "cs.stackexchange",
"id": 14321,
"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": "artificial-intelligence, neural-networks, big-data, perceptron",
"url": null
} |
doğrusal (lineer) analog devre elemanı vardır: direnç (R), kapasitör (C) ve bobin (L). It is sometimes desirable to compute the inverse Laplace transform of the product of two. The step function is one of most useful functions in MATLAB for control design. Laplace’s Equation In the vector calculus course, this appears as where ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ ∂ ∂ ∂ ∂ ∇= y x Note that the equation has no dependence on time, just on the spatial variables x,y. Laplace transformation is a technique for solving differential equations. Without Laplace transforms it would be much more difficult to solve differential equations that involve this function in $$g(t)$$. since my function is continuous I would like to use one as heaviside (0) - KratosMath Feb 11 '16 at 14:08 Even still, just make your own - excaza Feb 11 '16 at 14:11. Heavyside \Cover-up" Method for Partial Fractions April 3, 2003; Revised February 12, 2004, December 14, 2009, March 30, 2011 What follows is a very terse description of an | {
"domain": "comefaretradingonlinebft.it",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9817357227168957,
"lm_q1q2_score": 0.809403727261041,
"lm_q2_score": 0.8244619285331332,
"openwebmath_perplexity": 838.3805772550382,
"openwebmath_score": 0.7996795177459717,
"tags": null,
"url": "http://comefaretradingonlinebft.it/rqmx/laplace-heaviside-calculator.html"
} |
memory-management, memory-access, stacks
In a language with dynamic scoping, if a function f calls a function g, the code of g can access the variables of f by name. This is an example of a stack with extra operations: the code of g can read and modify the variables of f. The code of g can't create new variables of f or destroy variables of f, so this is still a stack. In a language with [lexical scoping]9https://en.wikipedia.org/wiki/Scope_(computer_science)#Lexical_scoping), the code of g can't access the variables of f by name, but it may nonetheless be able to access and modify their value if it can see a pointer or reference to a variable of f. | {
"domain": "cs.stackexchange",
"id": 15777,
"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": "memory-management, memory-access, stacks",
"url": null
} |
(18)
\begin{align} (AB)_{i,j}=row_i(A)\cdot col_j(B) \end{align}
Linear Transformation: A function $\mathit{T}$: $\mathbb{R}^n$ to $\mathbb{R}^m$ is called a $\mathit{linear}$ $\mathit{transformation}$ (or $\mathit{linear}$ $\mathit{map}$) if it satisfies the following $\mathit{linearity}$ $\mathit{properties}$:
(i) T(x + y) = T(x) + T(y) for all $\mathbf{x}, \mathbf{y} \in \mathbb{R}^n$.
(ii) T(cx) = cT(x) for all $\mathbf{x} \in \mathbb{R}^n$ and all scalars $\mathit{c}$.
Rotation Matrix: The matrix $A_\theta$ that rotates a vector through the angle $\theta$, given by:
(25)
\begin{align} A_\theta = \begin{bmatrix} \cos(\theta) & -\sin(\theta) \\ \sin(\theta) & \cos \theta \end{bmatrix} \end{align}
Left and Right Inverses: Given an $m \times n$ matrix $A$, an $n \times m$ matrix $B$ is called a right inverse of $A$ if
(26)
$$AB = I_{m}.$$
Similarly, an $n \times m$ matrix $C$ is called a left inverse of $A$ if
(27)
$$CA = I_{n}.$$ | {
"domain": "wikidot.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9920620070720564,
"lm_q1q2_score": 0.8087611707100054,
"lm_q2_score": 0.8152324803738429,
"openwebmath_perplexity": 6638.88111323154,
"openwebmath_score": 1.0000100135803223,
"tags": null,
"url": "http://plufa12m331.wikidot.com/definitions"
} |
c, console, io
{
printf("%lf / %lf = %f\n", num1, num2, r);
}
else
{
if (num1 * num2 > 500000000)
{
printf("Number is Big\n");
}
if (num1 * num2 < -500000000)
{
printf("Number is Small\n");
}
if (num1 > 0 & num2 == 0 | num1 == 0 & num2 == 0)
{
printf("Undefined\n");
}
}
break;
case 'e':
r = pow(num1, num2);
if (pow(num1, num2) < 500000001 & pow(num1, num2) > -500000001)
{ | {
"domain": "codereview.stackexchange",
"id": 40138,
"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, console, io",
"url": null
} |
inorganic-chemistry, acid-base
That's said, the very first reaction you probably want to write is dissociation of $\ce{H2S}$ in water and demonstrating that it is a weak acid by showing the corresponding acid dissociation constants $K_\mathrm{a}$ (the larger the $\mathrm{p}K_\mathrm{a},$ the weaker the acid; data from [1, p. 5-87]):
$$
\begin{align}
\ce{H2S + H2O &<=> HS- + H3O+} &\quad \mathrm{p}K_\mathrm{a1} &= 7.05\\
\ce{HS- + H2O &<=> S^2- + H3O+} &\quad \mathrm{p}K_\mathrm{a2} &= 19
\end{align}
$$
Some reactions illustrating acidic properties of $\ce{H2S}$:
Reaction with sodium hydroxide
Note that the reaction
$$\ce{H2S(aq) + 2 NaOH(aq) -> Na2S(aq) + 2 H2O(l)}$$
is for complete neutralization (concentrated $\ce{NaOH}$ solution).
If the reactants are taken in 1:1 ratio (diluted $\ce{NaOH}$ solution), sodium hydrosulfide is formed:
$$\ce{H2S(aq) + NaOH(aq) -> NaHS(aq) + H2O(l)}$$
Reaction with sodium carbonate
Sodium hydrosulfide is also formed when saturated $\ce{H2S}$ solution reacts with $\ce{Na2CO3}$: | {
"domain": "chemistry.stackexchange",
"id": 12759,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "inorganic-chemistry, acid-base",
"url": null
} |
evolution, reproduction
Every single locus is subject to genetic drift whether it is under selection or not. However, if a locus is under strong selection, then genetic drift with have little power to explain what allele will get fixed in comparison to when the locus is neutral.
Genetic drift and loss of alleles
It is clear from the graph above that genetic drift also wipe variant out of the population. We just don't know for sure which variant will be wiped out. To be more accurate, the expected heterozygosity due to genetic drift is reduced by a factor $\frac{1}{2N}$ each generation. One can make plenty of calculations from basic models of genetic drift. For example the expected time to being wiped out is $\bar t(p_0)=-4N\left(\frac{p_0}{1-p_0}\right)\ln(p_0)$, where $p_0$ is the starting frequency of the allele of interest. | {
"domain": "biology.stackexchange",
"id": 5650,
"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": "evolution, reproduction",
"url": null
} |
genetics, molecular-biology, dna, methods, restriction-enzymes
The change reflects a change in the ultraviolet absorbance properties of different structural forms of DNA. | {
"domain": "biology.stackexchange",
"id": 12442,
"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": "genetics, molecular-biology, dna, methods, restriction-enzymes",
"url": null
} |
java, enum
And so the enum made its way to production.
Time has passed, and now I've got the chance to change that enum so its usage is not tied to the ordering of its elements.
However, since this has been in production for quite some time, I have to make it so the current DB values (0, 1, 2...) are kept and still interpreted correctly (as changing the DB values or column type would be too costly now).
This is the first version I came up with:
public enum STATUS {
NEW (0),
SENT (1),
FAILED (2),
OK (3),
; | {
"domain": "codereview.stackexchange",
"id": 32940,
"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, enum",
"url": null
} |
javascript, regex
Title: Refactor 2 regular expressions in Javascript into 1 statement I have the following code, which replaces " " <-- Spaces with "-" <-- Dash.
Because some of the title text will be returned with more spaces, it converts it into 3 dashes.
Examples of Possible Titles:
"Hello World From Jquery" <--- Notice 2 Spaces between the words, not 1
"Main Title - Sub-Title or description here"
I would like the above titles to be turned into:
"Hello-World-From-Jquery" <---- (Not "Hello--World--From--Jquery")
"Main-Title-Sub-Title-or-description-here" <--- (Not "Main-Title---Sub-Title-or-desc...")
This is what I got so far, but its not ideal as you can see.
Example:
var dirty_url = ui.item.label;
var url = dirty_url.replace(/\s+/g,"-");
var url = url.replace(/---/g,"-"); | {
"domain": "codereview.stackexchange",
"id": 671,
"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, regex",
"url": null
} |
# Double branch $\sqrt x$ or square function turned 90°?
I have this idea for a graph but don't know what function could describe it better.
The idea is something like the "squared" function turned $90$ degrees to the right, so that possible values for $x$ are always positive and $y$ may be both positive and negative.
The graphs of $\sqrt x$ and $-\sqrt x$ combined look good too, but I don't know how to write that as a single function (eh, I'm so bad with these things).
Basically, anything that may look like this will do.
Looking forward to some solution.
What you're looking for can be described as a parabola opening towards the positive $x$ axis. I'm going to refer to it as a "sideways parabola," since the "standard" parabola that people learn opens towards the positive $y$ axis.
The bad news: You cannot express a sideways parabola as a function of $x$. Why? Let's go back and look at a restriction on functions: | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9711290913825541,
"lm_q1q2_score": 0.8553676690677837,
"lm_q2_score": 0.8807970811069351,
"openwebmath_perplexity": 190.7451724422293,
"openwebmath_score": 0.8127148747444153,
"tags": null,
"url": "https://math.stackexchange.com/questions/1103580/double-branch-sqrt-x-or-square-function-turned-90"
} |
python, python-3.x, hash-map, constructor, role-playing-game
In this example I'm using strings, like "unholy", to represent what will become method calls (with a given name) at some point.
The number of items (that will share most of this Weapon example's design, once I'm done with it), eventually, should reach the hundreds (the PRD rules I'm adapting to this game already provide a few hundred "basic items"), and allow the player to build new ones, both at runtime based on existing models (crafting) and pre-runtime (modding).
One weapon, for example, should change its stats and associated functions (spell-like effects) when equipped according to the wielder's class. But many more different conditions should be needed/used as I add fancy magic weapons, armors and items. | {
"domain": "codereview.stackexchange",
"id": 22526,
"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, python-3.x, hash-map, constructor, role-playing-game",
"url": null
} |
ros, serial, communication
In addition, the xbee package is not included with any of these, so:
sudo apt-get install ros-hydro-rosserial-xbee
Originally posted by fergs with karma: 13902 on 2014-02-04
This answer was ACCEPTED on the original site
Post score: 2
Original comments
Comment by yading on 2014-02-05:
Thank you Fergs! I run the two commands above and the problem was solved.
Comment by fergs on 2014-02-05:
Great! If you click on the checkmark next to my answer it will mark this as answered. | {
"domain": "robotics.stackexchange",
"id": 16880,
"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, serial, communication",
"url": null
} |
organic-chemistry, molecular-structure, carbon-allotropes
One can indeed see that there is 9-fold symmetry (technically, $D_\mathrm{9h}$). This implies that $\ce{C18}$ has a 'polyyne' structure in which there are two different types of bonds $\ce{-C#C-C#C-\phantom{}}$, rather than a 'cumulene' structure in which every bond is equivalent $\ce{=C=C=C=C=}$ (prior to this, computational studies had been equivocal as to which form was more stable).
The bright spots within the ring do not correspond to carbon atoms, but rather to carbon–carbon triple bonds. This is consistent with the AFM images obtained for other similar intermediates in the synthesis of cyclo[18]carbon. In the authors' own words: | {
"domain": "chemistry.stackexchange",
"id": 12421,
"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, molecular-structure, carbon-allotropes",
"url": null
} |
java, algorithm, programming-challenge
}
}
If you observe the flow, we can notice ways[k] only needs the most recent 2 values this ways[k-1] and ways[k-2]. Should I use a Hashmap or there is a better approach?
1 : 1
2 : 2
3 : 3
4 : 5
5 : 8
6 : 13
34 Houston, you have some bugs
The algorithm counts incorrectly in some cases involving zeros.
For example, there's only one way to make "10" or "20", not 2.
A different problem is the overly strict condition <26,
which excludes "26" even it can be decoded to z.
Beware of string slicing
String.substring creates a new string.
This could become expensive when repeated often.
If you change the logic to work with a char[] instead of a String,
then you can check if the first digit is '1',
or the first digit is '2' and the second digit is <= '6'.
Unnecessary code
This condition will never be true:
if((int)message.charAt(n-k)==0) | {
"domain": "codereview.stackexchange",
"id": 33603,
"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, algorithm, programming-challenge",
"url": null
} |
computer-architecture, virtual-memory, memory-access
A non-faulting prefetch is purely speculative. (Some ISAs provide support for speculative, non-faulting loads. In such an ISA, non-faulting prefetches could be implemented using such a load. Since the speculative load value may be used, hardware will typically treat such as an actual access and merely suppress any exceptions.) | {
"domain": "cs.stackexchange",
"id": 7124,
"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": "computer-architecture, virtual-memory, memory-access",
"url": null
} |
c#, multithreading, simulation
static void Main(string[] args)
{
// Initializes a new thread for each customer.
Thread bankCustomer1 = new Thread(new ThreadStart(new BankCustomer("Joe").runCustomer));
Thread bankCustomer2 = new Thread(new ThreadStart(new BankCustomer("Bob").runCustomer));
Thread bankCustomer3 = new Thread(new ThreadStart(new BankCustomer("Steve").runCustomer));
Thread bankCustomer4 = new Thread(new ThreadStart(new BankCustomer("Frank").runCustomer));
Thread bankCustomer5 = new Thread(new ThreadStart(new BankCustomer("Jess").runCustomer));
// Starts the treads.
bankCustomer1.Start();
bankCustomer2.Start();
bankCustomer3.Start();
bankCustomer4.Start();
bankCustomer5.Start();
// Prevents program from closing so that user may read output.
if (transactions == 100)
{ | {
"domain": "codereview.stackexchange",
"id": 12849,
"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, simulation",
"url": null
} |
c#, design-patterns, inheritance, xna
My current solution is to do something like the following to have more control over the manipulation:
public class Mesh<T> : Grid<T>, IMesh<T>
{
public Mesh(int x, int y)
: base(x, y)
{
} | {
"domain": "codereview.stackexchange",
"id": 7727,
"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#, design-patterns, inheritance, xna",
"url": null
} |
Thank you very much.
• Yes to your first question. It is not possible to say without more information (about the group, about $\Omega$, and about the action) what the orbits of the second action will be like. In general we can say say $(x_1, y_1) \sim (x_2, y_2)$ if there is a $g \in G$ such that $x_2 = x_1^g$ and $y_2 = x_2^g$. – Abhiram Natarajan Feb 12 '18 at 15:30
• If G is transitive on $\Omega$ then there will be only one orbit. Not sure in the latter case, more information is needed. – Osama Ghani Feb 12 '18 at 15:30
• Has the expression "doubly-transitive action" been mentioned where you are reading/hearing this stuff? – Clément Guérin Feb 12 '18 at 15:31
• @AbhiramNatarajan Then, in that case, will $(x_1, y_1)$ and $(x_2, y_2)$ be in the same orbit? – sugoi_overload Feb 13 '18 at 2:38
• @ClémentGuérin $G$ is doubly-transitive if $\Omega$ has 2 orbits, if I'm not mistaken? – sugoi_overload Feb 13 '18 at 2:42
1 Answer | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9511422241476943,
"lm_q1q2_score": 0.8158594597249419,
"lm_q2_score": 0.8577681013541613,
"openwebmath_perplexity": 119.34791559644233,
"openwebmath_score": 0.9509938955307007,
"tags": null,
"url": "https://math.stackexchange.com/questions/2647532/orbits-of-the-action-of-g-on-omega-%C3%97-omega"
} |
ros
Originally posted by rnunziata on ROS Answers with karma: 713 on 2014-06-22
Post score: 0
Original comments
Comment by Enrico Villagrossi on 2014-07-04:
The problem seems to be in trasmission_info.h where the member hardware_interfaces_ in the struct ActuatorInfo has been changed from (in Hydro):
std::string> hardware_interface_;
to (in Indigo):
std::vectorstd::string hardware_interfaces_;
but the change was not receipt in default_robot_hw_sim.cpp
Enrico
From the looks of it, you are using hydro's ros_control, but are building gazebo_ros_control from source using the indigo-devel branch.
If you are working in hydro, but need ros_control features that are only released into indigo, you should be able to build the indigo-devel versions of ros_control and gazebo_ros_control in an otherwise Hydro environment. Otherwise just stick to hydro-only code.
Originally posted by Adolfo Rodriguez T with karma: 3907 on 2014-07-04
This answer was ACCEPTED on the original site
Post score: 1 | {
"domain": "robotics.stackexchange",
"id": 18347,
"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
} |
laser
Title: How can the repetition rate of mode-locked lasers be tuned? In my job there is a femtosecond mode locked laser. It is able to operate at a range of repetition rates. I understand the principle behind mode locking of a laser, but I do not know how it would be possible to change the repetition rate of the laser without changing the cavity length. How is that achieved in real applications? The cavity length (and therefore the mode-locked pulse repetition rate) of a laser can be changed in any of several different ways. The easiest is to move one of the cavity mirrors using a piezoelectric stack. Another is to insert a pair of optical wedges into the cavity and move them to vary the thickness of glass the beam must traverse. The piezo stack is, of course, faster but has a shorter range. | {
"domain": "physics.stackexchange",
"id": 52728,
"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": "laser",
"url": null
} |
python, c++, c++11
factor_code = string.Template('''
template <>
const double basic_convert<$unit>::factor = $value;
''')
non_cannon = (unit for unit in self._units if unit != self._canonical)
for unit in non_cannon:
if unit not in self._factors:
raise NameError('No conversion factor exists for {}'.format(unit))
yield textwrap.dedent(
factor_code.substitute(unit=unit, value=self._factors[unit])
)
def _ostream_operator(self):
'''Returns a string impelementing the ostream<< operator.'''
ostream_code = string.Template('''
template <typename T>
std::ostream& operator<<(std::ostream& os, $unit_name<T> unit)
{
return os << unit.value() << T::to_string();
}
''')
return textwrap.dedent(ostream_code.substitute(unit_name=self._unit_type)) | {
"domain": "codereview.stackexchange",
"id": 16195,
"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, c++, c++11",
"url": null
} |
c#, object-oriented, game, .net, playing-cards
private IEnumerable<Type> GetTypesOfBaseType(Type baseType)
=> Assembly.GetExecutingAssembly().GetTypes().Where(t => baseType.IsAssignableFrom(t) && t != baseType);
private IEnumerable<T> GetCombinationAnalyzerInstances<T>(object[] parameters)
where T : class => combinationAnalyzerTypes.Select(type => (T) Activator.CreateInstance(type, parameters));
} I don't like the required length in the ctor for Hand. Allowing the user to provide an array signals that you don't care about the number of cards provided. If there must be a specific number of cards, you should make the user provide them explicitly, and if you need to, concatenate them into an array in the constructor. If this was a public library, this would probably be quite the pain point for your users, and when it comes down to it, you are basically just a user 6 weeks/months after you write this. | {
"domain": "codereview.stackexchange",
"id": 25642,
"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#, object-oriented, game, .net, playing-cards",
"url": null
} |
algorithms, complexity-theory, time-complexity, turing-machines
For instance, a Turing machine that halts and accepts for all $x \in A$, but fails to halt for some (or all) $x \notin A$, would not qualify as a valid decider for $A$. | {
"domain": "cs.stackexchange",
"id": 20792,
"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, complexity-theory, time-complexity, turing-machines",
"url": null
} |
structural-engineering
Title: Double-bagging problem: which bag on the inside? If you're double-bagging some groceries, and one of the bags has tears in it while the other is intact, which bag should go on the inside? Put the torn bag inside, just to let it absorb the possible moisture of veggies and other freshly washed fruits.
It is interesting to note that some tears at critical locations where they could concentrate stress to outer bag can lead to tearing of the outer bag, while left alone by itself it could safely contain it's load. Same idea as the shallow scorelines the glazing guys put on a plane of glass to cut it. | {
"domain": "engineering.stackexchange",
"id": 2948,
"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": "structural-engineering",
"url": null
} |
quantum-mechanics, energy, momentum, ground-state
By symmetry $\langle x\rangle=0$ for your problem, and so does $\langle p\rangle=0$. Thus, for instance,
\begin{align}
(\Delta p)^2=\langle p^2\rangle -\langle p\rangle^2=\langle p^2\rangle \propto \langle T\rangle
\end{align}
in this case. | {
"domain": "physics.stackexchange",
"id": 71294,
"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, energy, momentum, ground-state",
"url": null
} |
one_res = False
two_res = False
if one_idx < len(one) and one[one_idx] == three[three_idx]:
one_res = interweavingStringsHelperMEMO(
one, two, three, cache, one_idx+1, two_idx)
if two_idx < len(two) and two[two_idx] == three[three_idx]:
two_res = interweavingStringsHelperMEMO(
one, two, three, cache, one_idx, two_idx+1)
cache[one_idx][two_idx] = one_res or two_res
return cache[one_idx][two_idx]
"""
------------------------------------------------------------------------------------------------------------------------------------------------------
Bottom up:
- for each char(in one or two) check if it matches what is in three:
- if it does: if we had built the prev string up to that point == True (
one idx behind the curr idx in three (up or left depending on if the row or column matches) )
- then True
# can be optimised to 1D array
"""
def interweavingStrings(one, two, three):
if len(three) != len(one) + len(two):
return False | {
"domain": "paulonteri.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9559813501370535,
"lm_q1q2_score": 0.8218225111577803,
"lm_q2_score": 0.8596637487122111,
"openwebmath_perplexity": 6090.381773024074,
"openwebmath_score": 0.30743175745010376,
"tags": null,
"url": "https://dsa.paulonteri.com/Data%20Structures%20and%20Algorithms%2016913c6fbd244de481b6b1705cbfa6be/Recursion%2C%20DP%20%26%20Backtracking%20525dddcdd0874ed98372518724fc8753.html"
} |
spacetime, metric-tensor
Title: Does a spacetime manifold have the structure of a metric space? My first introduction to spacetime physics was Wheeler and Taylor's book Spacetime Physics. This book gave me an appreciation for how important the spacetime interval was for giving the distortions to space and time meaning. You know, the classical examples with the light beams and the trains, etc. So I have always associated the "spacetime interval" with the idea of distance.
However, I recently learned that, because a pseudo-Riemannian manifold can have zero length curves, it therefore is not a metric space by the specific definition mathematicians use. Now I am very confused. Is the concept of distance still useful to spacetime? Obviously it is in some sense, but now I'm not sure what sense I mean. Before I thought I might mean the metric space definition. But it would seem that metric spaces are not the right way to think about spacetime distance if a pseudo-Riemannian manifold isn't a metric space. | {
"domain": "physics.stackexchange",
"id": 18984,
"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": "spacetime, metric-tensor",
"url": null
} |
homework-and-exercises, electromagnetism, lagrangian-formalism, stress-energy-momentum-tensor, noethers-theorem
In vacuum, i.e. for $J^\alpha=0$, the conservation equation reduces to: $\partial_\alpha F^{\alpha}_{\beta} = 0$ .
For more references, you may have a look at the famous as well as the legendary book by Thanu Padmanabhan, "Gravitation: Foundations and Frontiers". The entire proof, alongwith the related concepts are well described there. | {
"domain": "physics.stackexchange",
"id": 97108,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "homework-and-exercises, electromagnetism, lagrangian-formalism, stress-energy-momentum-tensor, noethers-theorem",
"url": null
} |
vectors, tensor-calculus, coordinate-systems, vector-fields, covariance
If one writes the expression in the new coordinates, and it is not the same, what went wrong? Yes!
A vector is the same in every coordinate system, only the way the vector is written out varies.
For example, consider this expression: $$\nabla \cdot \vec E=\frac{\rho}{\epsilon_o}$$
This is true in any Euclidean space, and holds the form.
The only thing that changes is the form of the $\nabla$ operator. (and the resulting $\rho$, that undergoes a variable transformation)
For example, in rectangular coordinates, it is: $$\nabla=\hat{\pmb e}_{x}\frac{\partial}{\partial x}+\hat{\pmb e}_{y}\frac{\partial}{\partial y}+\hat{\pmb e}_{z}\frac{\partial}{\partial z}$$
Whereas in spherical polar coordinates, it is: $$
\nabla =\hat{\pmb e}_{r}\frac{\partial }{\partial r}+\hat{\pmb e}_{\theta}\frac{1}{r}\frac{\partial }{\partial \theta}+\hat{\pmb e}_{\phi}\frac{1}{r\sin\theta}\frac{\partial }{\partial \phi}.
$$ | {
"domain": "physics.stackexchange",
"id": 41271,
"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": "vectors, tensor-calculus, coordinate-systems, vector-fields, covariance",
"url": null
} |
moveit
Comment by benedikt on 2022-05-05:
Thanks, this works for me. I just had to change the message namespace to get it running with Moveit2 (Galactic binary).
moveit_msgs::msg::RobotTrajectory trajectory;
moveit_msgs::msg::RobotTrajectory trajectory_slow; | {
"domain": "robotics.stackexchange",
"id": 27452,
"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": "moveit",
"url": null
} |
bash, shell, sed
Title: Bash Shell Script uses Sed to create and insert multiple lines after a particular line in an existing file This code seems to work, but I'd like someone with shell-fu to review it.
Is the temp file a good idea? How would I do without?
Is sed the right tool?
Any other general advice for improving my shell script
Script/Code to Review:
# Grab max field lengths from each .hbm.xml file and
# put them into the corresponding .java file
for myFile in $(find generatedSchema/myApp/db/ -name *.hbm.xml)
do
# Calculate the java file name
javaFile=${myFile/%\.hbm\.xml/.java}
echo $javaFile
# Find each field name and length and format it for the java file.
# Save result lines to temp.txt
sed -n '/<property name="[^"]\+" type="string">/{
N
s/ \+<property name="\([^"]\+\)" type="string">\n \+<column name="[^"]\+" length="\([0-9]\+\)".*/ @SuppressWarnings({"UnusedDeclaration"}) public static final int MAX_\1 = \2;/p}' $myFile >temp.txt | {
"domain": "codereview.stackexchange",
"id": 3559,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "bash, shell, sed",
"url": null
} |
python, python-3.x, calculator, math-expression-eval
elif choice_sub == "sum_to_nth_with_L_exceed":
count_list = [input("enter a1: "), L]
count_list = [float(eval(count)) for count in count_list if isinstance(count, str)]
return count_list
elif choice_main == 'geometric':
if choice_sub == 'a_nth':
return three_variables_looper_geometric()
elif choice_sub == 'sum_to_nth':
return three_variables_looper_geometric()
elif choice_sub == 'sum_to_infinity':
count_list = [input("enter a1: "), input("enter r: ")]
count_list = [float(eval(count)) for count in count_list if isinstance(count, str)]
return count_list
elif choice_sub == "a_nth_exceed":
count_list = [input("enter a1: "), input("enter r/d: ")]
count_list = [float(eval(count)) for count in count_list if isinstance(count, str)]
return count_list | {
"domain": "codereview.stackexchange",
"id": 37626,
"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, python-3.x, calculator, math-expression-eval",
"url": null
} |
electromagnetism, polarization
Title: Why does it seem like a broken magnet's poles flip? I just took a rare earth magnet out of an old hard drive. Lacking an appropriate screwdriver, force was used, and the magnet broke into two pieces; one about a quarter of the original size and one about 3/4 the original size.
Let's say this is the magnet:
>>>>>>>>
and the arrows are pointing north, in the original magnet.
It broke into two pieces:
>>>>>} }>
(where } represents the rough edge of the break).
I'd expect that the two magnets would keep their relative directions, so that the magnets would fit back together at the break, like this:
>>>>>}}>
But instead, the broken edges repel, and the magnet wants to come together so that formerly "north-facing" sides are now connected, like so:
>>>>>}<{ | {
"domain": "physics.stackexchange",
"id": 1857,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "electromagnetism, polarization",
"url": null
} |
solid-state-physics, material-science, elasticity, metals
"More elastic" is ambiguous, and the insistence that the meaning is always "stiffer" does not reflect any consensus in the field.
Nobody refers to aortic tissue as an elastomer, as a look at the literature reveals. Elastomer generally refers to a synthetic substance; tissue is a biological substance.
Stress can certainly be assigned an orientation, as in the components of the rank-two stress tensor. Perhaps the authors mean "pressure," but this doesn't match the context of axial stress that's being discussed.
The language is generally poor, with missing articles and other grammatical and formatting problems; this suggests that the content hasn't received careful review.
Again, I wouldn't consider this resource to be a reliable one. | {
"domain": "physics.stackexchange",
"id": 78648,
"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": "solid-state-physics, material-science, elasticity, metals",
"url": null
} |
python, beginner, strings, search
def r(self):
return self.uModP
def update_ax(self, up_down):
if up_down == "up":
self.size_x += 1
elif up_down == "down":
self.size_x -= 1
self.ax = self.h(self.a**(self.size_x - 1))
def append(self, char):
self.uModP = self.h((self.uModP*self.a) + ord(char))
self.update_ax("up")
def skip(self, char):
self.uModP = self.h(self.uModP - (ord(char) * self.h(self.ax)))
self.update_ax("down")
def search_file(fileStr, term):
size = find_prime_above(len(fileStr))
rs = rolling_hash(256, size)
rt = rolling_hash(256, size)
for c in term:
rs.append(c)
for c in fileStr[:len(term)]:
rt.append(c) | {
"domain": "codereview.stackexchange",
"id": 22983,
"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, search",
"url": null
} |
python, time-limit-exceeded, csv
p = cols[0].strip()+"\t"+cols[1].strip()+"\n"
q += p
D2.write(q)
D2.close()
with open(vcf_File_name+".vcf","r") as f, open(vcf_File_name+".redp.vcf","w+") as f1 :
D2=open(vcf_File_name+"dup_posID_re.txt", "r")
lines2=D2.readlines()
for v_line in f:
if v_line[0] != '#':
v_cols = re.split('[ ]+|[ ]+',v_line.strip())
st = v_cols[2]+"\t"+v_cols[1]+"\n"
if st in lines2:
lines2.remove(st)
s = "\t".join(v_cols)
s += "\n"
#req += s
f1.write(s)
#f1.write("\n")
else:
s = v_line
f1.write(s)
f1.close() | {
"domain": "codereview.stackexchange",
"id": 30304,
"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, time-limit-exceeded, csv",
"url": null
} |
of steps that the records in the array must move to reach their "correct" location. Insertion sort is a comparison-based sorting algorithm that we will use all operations involve a fixed number of bits. Test Yourself #1. we can reduce it to O(logi) by using binary search. Insertion Sort is often used as the recursive base case for higher overhead divide and conquer sorting algorithms, such as merge sort or quick sort, when the problem size is small. A sorting algorithm is easier to implement if its number of passes and the number of comparisons along with the actual number of swaps required to be performed can be easily predicted. Is there an ideal comparison sort? Every computer science student should have studied or at least encountered sorting algorithms early in their career. We can modify the mergesort algorithm to count the number of inversions while sorting. Insertion Sort algorithm in python. sort() method, while the sorting itself uses Insertion Sort for arrays shorter than 47, | {
"domain": "candelaeventi.it",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.965899575269305,
"lm_q1q2_score": 0.8006716367591382,
"lm_q2_score": 0.8289388019824947,
"openwebmath_perplexity": 998.2573675633466,
"openwebmath_score": 0.3076539933681488,
"tags": null,
"url": "http://scmo.candelaeventi.it/insertion-sort-number-of-comparisons.html"
} |
c#, .net, winforms, dependency-injection, mvp
if (modelValue != null)
{
object valueToAssign = Convert.ChangeType(modelValue, viewProperty.PropertyType);
if (valueToAssign != null)
{
viewProperty.SetValue(this._view, valueToAssign, null);
}
}
}
}
}
}
//======================================================================================
private void _view_DataChanged(object sender, EventArgs e)
{
this.SetModelPropertiesFromView(); // Updating the model properties when data in the view properties changed…
}
private void _view_Save(object sender, EventArgs e)
{
this.Save();
}
private bool Save()
{
return _ds.InsertClient(_model);
} | {
"domain": "codereview.stackexchange",
"id": 7304,
"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#, .net, winforms, dependency-injection, mvp",
"url": null
} |
strings, ruby, bioinformatics, rspec, edit-distance
TACTCAATCCTCGTTACAACTAGGTGCCCGAAGTCAAGTAGCTCTGCCGCACGTCCGTGGTCATCGAGGGATGTGGATGCGGCAGCGGGGTCAGCTCGTCTCGTGCCAGTGTATATACGACTAAATACTGTCATCGCTCGCGGGCTGACCCTTTGCGTGGCACAGTGTTCCCCAAGCCTATCCATGCTCTCAGGGAGCAGCGTCTACCCGACCGCCGCTTATGGTGTGTAAGACTGCTTATGGTTCAAGACGGATCAAATGCACATTAATTTCGCAGCGTGATGATATTACACTACCTTCTGCATTGACGTTCAACTACACAAGTCGGAGCGGTCTATCCCATAGTGCAGTGCGCTTAGGTTGAAGCGTGAACGTTTATCAGTTATACCCTTCATTGTCCTCGAGGTGGTGTCATAAGGCTATGCTGCATGCCTCTCCGACCCTGCGAGATATTCTCCGTTTGTGCTTATGTATTCCCTGGTTCTCCTTAGTATAACCCTTTTTTCTGTGCTCCCCGACCTCGCAGTTCCGGCCAGTGCTTGCGTAACATGAGCAGTTACCTTAGTCATTACGCTTGGTAGTTCCCATTAGGAAGGCATGTATTTCGAGTTGCGGGATGGTTTGGGATGTGTGGCAAGATGTAAGGACCGCGTTGGTTACTCGATGAGACAAGCCAGGCACCGAACATCCTCGGGTCATCCGAATCATCCGAATGGTCGGCCACCGATCTGACGTGTGCCAACCCGTGGATGCCAGGCATCGTTAGAGGTATTTACCCTTGACTGTTATCTCGGAACGAGAACAACGTCAAATCCTTGCCCTTTTGATAACGGAGGACTACTATACTACCTAGTCATACCTATATCCGTCGCAAGGAATCTGAAATACCCGGACATAGAGAGAAAACAATAACACTGTGTCCGAAGAGGACTGTCTGGCCTTTCATTATTGATAACCGCGCAATGGCAGTTGGAC | {
"domain": "codereview.stackexchange",
"id": 20346,
"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": "strings, ruby, bioinformatics, rspec, edit-distance",
"url": null
} |
quantum-mechanics, heisenberg-uncertainty-principle
Title: Uncertainty relation and Energy-Position interference How would you prove that the simultaneous measurements of position and energy are not subject to interference?
I was thinking in calculate the commutation relation between $x$ and $H$ (Because $\Delta E=\Delta H$), but I realized that $[H,x]\neq0$, so I tried to use a more general expression for the Uncertainty Principle that says that if $H_1$ and $H_2$ are Hermitian operators then $\Delta H_1 \Delta H_2\geq\frac{1}{2}|\langle [H_1,H_2]\rangle|$, but again, $[H,x]\neq0$. Can you suggest me a way to do this? Thanks. You're right to use the general form of the Uncertainty Principle, namely:
$$ \Delta H_1 \Delta H_2\geq\frac{1}{2}|\langle [H_1,H_2]\rangle|. $$
However, note that in the right hand side you have the expectation value of the commutator, so even if $[H,x] \neq 0$ it can still be that $\langle [H,x] \rangle = 0$. If this is the case then you can simultaneously measure position and energy. | {
"domain": "physics.stackexchange",
"id": 6146,
"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, heisenberg-uncertainty-principle",
"url": null
} |
quantum-mechanics, quantum-information, quantum-optics, unitarity
\begin{equation}
\hat{B}^{(N)} = \frac{1}{\sqrt{N}}\begin{bmatrix}
1 & 1 & 1 & ⋯ & 1\\
1 & \alpha_N^? & \alpha_N^? & ⋯ & \alpha_N^? \\
⋮ & ⋮ & ⋮ & ⋱ & ⋮ \\
1 & \alpha_N^? & \alpha_N^? & ⋯ & \alpha_N^?
\end{bmatrix}.
\end{equation} It seems the matrix you want is just the Fourier matrix. Thus, if $\alpha=e^{2\pi i/N}$ so that $\alpha^N=1$, then
\begin{align}
\frac{1}{\sqrt{N}}\left(
\begin{array}{ccccc}
1&1&1&\ldots&1\\
1&\alpha&\alpha^2&\ldots &\alpha^{N-1}\\
1&\alpha^2&\alpha^4&\ldots&\alpha^{2(N-1)}\\
\vdots&\vdots &\vdots &\ddots&\vdots\\
1&\alpha^{N-1}&\alpha^{2(N-1)}&\ldots&\alpha^{(N-1)(N-1)}
\end{array}\right)
\end{align}
BTW this matrix has a number of "nice" properties. See for instance: | {
"domain": "physics.stackexchange",
"id": 98284,
"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, quantum-optics, unitarity",
"url": null
} |
physical-chemistry, molecules, dipole
‡
For a non-electroneutral region of space, by center of charge I mean the charge-weighted centroid of the system: (1) Choose a reference point $\vec r_0$. (2) At each point $\vec r$ in the region of interest, multiply the charge at that point, $\rho\!\left(\vec r\right)$, by the distance from the reference point, $\vec r - \vec r_0$. (3) Integrate the resulting product, $\rho\!\left(\vec r\right)\cdot\left(\vec r - \vec r_0\right)$, over all space. (4) Divide by the net charge of the region of interest. Dipole moment calculations are more complicated for electroneutral systems, but the principle is similar. | {
"domain": "chemistry.stackexchange",
"id": 5342,
"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": "physical-chemistry, molecules, dipole",
"url": null
} |
period was −1.64%. De R.O.I. NL:rate of return. The latter is also called the holding period return. Identify variable rate of return, if applicable, for CIC categories 5 (Structured notes) and 6 (Collateralised securities). These after-tax returns would apply of course only to taxable accounts and not to tax-deferred or retirement accounts such as IRAs. V The result of the conversion is called the rate of return. We highlight what each term means and why they represent similar but distinctively different concepts in asset valuation. For a return of +20%, followed by −20%, this again has an average return of 0%, but an overall return of −4%. {\displaystyle t} unesdoc.unesco.org. In such a case, where there are multiple contiguous sub-periods, the return or the holding period return over the overall period can be calculated, by combining together the returns within each of the sub-periods. Let us stop there and say the Internal Rate of Return is 12.4%. i g to a compound rate of return | {
"domain": "abo-sommerhuse.dk",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.975576912786245,
"lm_q1q2_score": 0.8021087273052373,
"lm_q2_score": 0.8221891239865619,
"openwebmath_perplexity": 2160.510007665216,
"openwebmath_score": 0.49565374851226807,
"tags": null,
"url": "http://abo-sommerhuse.dk/f1wc7/archive.php?id=453a80-rate-of-return"
} |
discrete-signals, autocorrelation, proof
For $n<0$:
$$u[m]u[m-n]=\begin{cases}0,& \forall m<0\\
1,& \forall m\ge 0\end{cases}$$
$$\begin{align}
\phi_{xx}[n]&=\sum_{\color{red}{m=0}}^{\infty}x[m]x[m-n]\\
&=\sum_{m=0}^{\infty}a^ma^{m-n}\\
&=a^{-n}(1 + a^2 + a^4 +\cdots )\\
&=\frac{a^{-n}}{1-a^2}\end{align}$$
and since $\phi_{xx}[n]=\phi_{xx}[-n]$, we can write it for all $n$ as
$$\phi_{xx}[n]=\frac{a^{|n|}}{1-a^2},\ |a|<1$$ | {
"domain": "dsp.stackexchange",
"id": 5368,
"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": "discrete-signals, autocorrelation, proof",
"url": null
} |
a temporal part, and the symmetry between space and time can be exploited. A solution of a partial differential equation in some region R of the space of the independent variables is a function that possesses all of the partial derivatives that By separation of variables, we assume a solution in the form of a product and Euler derived and solved a linear wave equation for the motion of vibrating strings in the. When using the separation of variable for partial differential equations, we assume the solution takes the form u(x,t) = v(x)*g(t). EE 439 time-independent Schroedinger equation - 2 With U independent of time, it becomes possible to use the technique of "separation of variables", in which the wave function is written as the product of two functions, each of which is a function of only one variable. In the following, the radius r;the mass mand the velocity vare func-tions of the time t:By de nition of the density ;we have. The wave equation written can be written with the aid of | {
"domain": "chicweek.it",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9923043544146899,
"lm_q1q2_score": 0.8434301006175603,
"lm_q2_score": 0.8499711775577736,
"openwebmath_perplexity": 556.7745988916529,
"openwebmath_score": 0.808579683303833,
"tags": null,
"url": "http://zgrk.chicweek.it/solution-of-wave-equation-by-separation-of-variables-pdf.html"
} |
context-free, automata
Title: How to make a Post Machine for $a^nb^n$? I have tried to make a Post machine for that all words of the form $a^nb^n$ by the following steps.
add a marker '#'
read first 'a'
read next 'a's and add them
read first 'b'
read next 'b's and add them
read '#' (that we added in the first step)
repeat steps while input tape is not empty
but this algorithm also accepts words of the form $(ab)^n$ e.g abab, ababab
I want to make a Post machine that only accepts words of the form $a^nb^n$
How to do that? Hint.
One possible solution is checking the format of the input in the beginning of the procedure to get sure the user input is in form of $a^nb^n$. If it is in correct format then go to next step otherwise reject. In next step using the instructions that you've written can accept the language. But one thing which is important in post-turing machines is it's model (eg. Davis), which you didn't mention. | {
"domain": "cs.stackexchange",
"id": 8772,
"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": "context-free, automata",
"url": null
} |
newtonian-gravity, earth, estimation, tidal-effect
Title: What is the difference of gravity between lowest tides and highest tides? I know tides are due to gravitional gradients so the difference of gravity between places does not need to be big in order to generate tides.
Regardless, what difference are we talking about, numerically?
This is depending on the location, OF COURSE, so no need to get obsessed about how you could never answer such a question given so little details, etc. Just pick an interesting example or a textbook one, as I want a ballpark figure. Thank you for keeping things simple as possible.
I looked for possible possible duplicates but did not find a question about the numbers. According to Wikipedia - Tidal force - Formulation highest tide is at lowest total acceleration ($g_\text{total,high}= g-a_\text{tide,max}$),
and lowest tide is at highest total acceleration ($g_\text{total,low}= g+\frac{1}{2}a_\text{tide,max}$). | {
"domain": "physics.stackexchange",
"id": 80450,
"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, earth, estimation, tidal-effect",
"url": null
} |
reinforcement-learning, q-learning, value-functions, notation, random-variable
What I didn't understand is what is here. i.e., what is the random variable on which we are calculating long-run rewards?
The random variable is $R_t$, the reward at each time step. The distribution of $R_t$ in turn depends on the distribution of $S_{t-1}$ and $A_{t-1}$ plus the policy and state progression rules. There is no need to include the process that causes the distribution of each $R_t$ in every equation. Although sometimes it is useful to do so, for example when deriving the Bellman equations for value functions.
My guess is policy function. It is averaging long-run rewards over all possible policy functions. Is it true? | {
"domain": "ai.stackexchange",
"id": 2366,
"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": "reinforcement-learning, q-learning, value-functions, notation, random-variable",
"url": null
} |
python, python-3.x, game, console, minesweeper
do three things: (1) segregate the input() call to the simplest possible
function (so simple that it's hardly worth testing); (2) extract as much of the
algorithmic detail to an easily-tested, data-oriented function; and (3) leave
the surviving remainder in read_action(). The main point is to push
complexity out of the functions that are bothersome to test. Here's a sketch:
def read_action(minefield: Minefield) -> Action:
# This isn't algorithm-free, but it's close.
prompt = 'Please enter: (visit|mark) <x> <y> '
while True:
text = get_input(prompt)
result = parse_action(minefield, text)
if isinstance(result, Action):
return result
else:
print(result, file=stderr) | {
"domain": "codereview.stackexchange",
"id": 42610,
"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, python-3.x, game, console, minesweeper",
"url": null
} |
javascript, jquery, html, angular.js, twitter-bootstrap
// next step
$scope.nextStep = function() {
setStep($scope.currentStep + 1);
};
// prev step
$scope.prevStep = function() {
setStep($scope.currentStep - 1);
};
// jump to @step
function setStep(step) {
if (step < 0 || step > $scope.steps.length) {
// throw error, trying to step out of scope
throw {
name: "Step by step wizard",
message: "Trying to step out of the scope"
};
} else {
$scope.currentStep = step;
}
};
// get current status ('completed' / 'active' / 'incompleted') of @index in $scope.steps
$scope.getStatus = function(index) {
var status = '';
if (index < $scope.currentStep) {
// completed step
status = 'completed';
} else if (index == $scope.currentStep) {
// current step
status = 'active';
} else {
// incompleted step
status = 'incompleted';
}
return status;
}; | {
"domain": "codereview.stackexchange",
"id": 26393,
"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, jquery, html, angular.js, twitter-bootstrap",
"url": null
} |
newtonian-mechanics, work, power
In this case the velocity of the contact patch is the same as the velocity of the motorcycle, but consider a drum being angularly accelerated by a spinning tire, in this case the contact patch is not moving, but the surface of the drum is. The drum could be replaced with a cable that loops between two spools, so that the acceleration of the cable at the contact point is linear. In this case, the contact patch is not moving, and power = force exerted on cable · velocity of cable.
The fact that the tire surface is not moving with respect to the road at the contact patch is the reason that a non-moving road can apply a force to a moving motorcycle.
So what I refer to as an abstract object is just a way of referring to something that moves at the same speed as the object the force is being applied to, and was my attempt to deal with rolling motion of the rear tire in the case of the motorcycle. | {
"domain": "physics.stackexchange",
"id": 64280,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "newtonian-mechanics, work, power",
"url": null
} |
orbit, stellar-dynamics
# Update positions
for i,xi,vi in zip(range(n),x,v):
xi += vi * dt
xHist[i].append(list(xi))
# Update time and end simulation if past tEnd
t += dt
if dt > 0 and t > tEnd: break
if dt < 0 and t < tEnd: break
end = time()
print('Simulation finished in {:.4f} seconds.'.format(end-start))
# Convert xHist and vHist to np arrays
xHist = np.array(xHist)
vHist = np.array(vHist)
# Plot everything up
figure()
for i,c in enumerate(['or','ob','oc']):
# Plot starting positions
plot(xHist[i,0,0], xHist[i,0,1], c)
for i,c in enumerate(['-r','-b','-c']):
# Plot path of star
plot(xHist[i,:,0], xHist[i,:,1], c)
gca().set_aspect(1)
gca().set_xticks([])
gca().set_yticks([])
show(block = False)
Note, the plots show the initial positions of the stars as the points and then trace out their paths over time.
Path of three masses for $t<t_0$ | {
"domain": "astronomy.stackexchange",
"id": 2551,
"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": "orbit, stellar-dynamics",
"url": null
} |
c++, template, optional
Title: C++ Nullable template class Today I implemented a C++11 template class which allows for Nullable types. The reason for this is that std::optional is not yet available, (I use C++11/14) and I wanted to practice a bit, so I decided to make one myself. Also for portability reasons. (The code has to compile on multiple platforms, namely Linux and Windows. GCC/MSVC)
Can you guys take a look at it and point me to some improvements/changes that might be needed?
Here is the code:
Class Definition:
#include <algorithm>
template<typename T>
class Nullable final
{
private:
union Data
{
Data(){};
~Data(){};
Data(const Data&) = delete;
Data(Data&&) = delete;
Data& operator=(const Data&) = delete;
Data& operator=(Data&&) = delete;
T m_Data;
} m_Data;
bool m_IsUsed = false;
public:
Nullable() = default;
~Nullable();
Nullable(T object); | {
"domain": "codereview.stackexchange",
"id": 26073,
"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++, template, optional",
"url": null
} |
proteins, nomenclature, receptor
Ericsson et al. 2003: Identification of receptors for pig endogenous retrovirus
Next, Ericsson et al come along looking for receptors for the pig endogenous retrovirus and find this gene. They used cDNA to make a bunch of transduced cell lines that had difference human cDNAs expressed. They found two related proteins that could serve as receptors to the pig endogenous retrovirus. They named the first one HuPAR-1, which is 445aa long and has 11 transmembrane helices. This is the length of one of the proper splice variants of this gene.
Andriamampandry et al. 2007: Cloning and functional characterization of a gammahydroxybutyrate receptor identified in the human brain | {
"domain": "biology.stackexchange",
"id": 1243,
"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": "proteins, nomenclature, receptor",
"url": null
} |
particle-physics, mass, higgs, electroweak
\Phi\\
\Theta
\end{array}\right),
\end{equation}
where $\mathcal{L_{\text{kin}}}$ is the kinetic part of the Lagrangian. Can you read of the mass of the fields from these terms?
To answer your question, there is relation between the properties of the potential under transformations and the physical properties of your model. Can you see which from the previous argument? What happens to the derivatives when the potential is invariant under changes in one of the fields? | {
"domain": "physics.stackexchange",
"id": 86347,
"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": "particle-physics, mass, higgs, electroweak",
"url": null
} |
python, python-3.x, homework, reinventing-the-wheel
I prefer short-circuiting, hence the returns. If you prefer if...else, here is an equivalent implementation:
def cartesian_product_recursive_2(tup_1, tup_2):
res = ((tup_1[0], tup_2[0]), (tup_2[0], tup_1[0]))
if len(tup_2) > 1:
res += cartesian_product_recursive_2(tup_1[:1], tup_2[1:])
if len(tup_1) > 1:
res += cartesian_product_recursive_2(tup_1[1:], tup_2)
return res | {
"domain": "codereview.stackexchange",
"id": 30595,
"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, python-3.x, homework, reinventing-the-wheel",
"url": null
} |
python, programming-challenge, python-3.x, time-limit-exceeded
Title: Google Code Jam Google String problem: a sequence resulting from bit flips and reversals I'm currently having a go at some past Google Code Jam problems to help me practice my programming skills.
One of these problems is Problem A ("Googol String") from Round A APAC Test 2016. Here is the problem for reference (you can find the details via the link):
Problem
A "0/1 string" is a string in which every character is either 0 or 1. There are two operations that can be performed on a 0/1 string:
switch: Every 0 becomes 1 and every 1 becomes 0. For example, "100" becomes "011".
reverse: The string is reversed. For example, "100" becomes "001". | {
"domain": "codereview.stackexchange",
"id": 32948,
"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, programming-challenge, python-3.x, time-limit-exceeded",
"url": null
} |
classification, dataset, sampling, class-imbalance
Title: Why do we need to handle data imbalance? I would like to know why we need to deal with data imbalance. I know how to deal with it and different methods to solve the issue - by up sampling or down sampling or by using SMOTE.
For example, if I have a rare disease 1 percent out of 100, and lets say I decided to have a balanced data set for my training set which is: 50/50 sample
won't that make the machine think 50% of patients will have disease? even though the ratio is 1 of 100.
So | {
"domain": "datascience.stackexchange",
"id": 2177,
"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": "classification, dataset, sampling, class-imbalance",
"url": null
} |
newtonian-mechanics, newtonian-gravity, orbital-motion, rocket-science, satellites
Title: Change of orbit with radial impulse This probably is dumb question, but it has been giving me issues for days.
I was thinking about a point of mass $m$ in a circular orbit around a planet. The question is: giving a radial impulse, what is the change in the shape of the orbit? Will it change in another circular orbit? Or maybe will undergo a spiral motion? Suppose you are in a circular orbit around the Earth. You are always at the same altitude, your path's curvature exactly follows that of the Earth's surface. You are basically Newton's cannonball.
All of a sudden, you get a huge kick in the outward radial direction.
You will experience an instantaneous change of velocity, both in magnitude (greater speed) and direction (pointed not just forward, but also outward). | {
"domain": "physics.stackexchange",
"id": 8536,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "newtonian-mechanics, newtonian-gravity, orbital-motion, rocket-science, satellites",
"url": null
} |
identities below and then try the examples that follow. Simplifying Problems Step-by-Step Lesson- These problems require you to combine trigonometric identities that many people find difficult. Volume. Trigonometric identities Problems on trigonometric identities Trigonometry heights and distances. I like to give students problems that include old topics along with the new material. 4 about trigonometric identities. These are called Pythagorean identities, because, as we will see in their proof, they are the trigonometric version of the Pythagorean theorem. In these problems, you are commonly asked to "prove" that one side of an equation is equal to the other side of an equation, and you will need to simplify expressions using quotient and reciprocal identities to do so. Chapter 6 Trigonometric Identities Sec 6. Formula for the Pythagorean Identities sin^2 \theta ; + cos^2 \theta = 1 tan^2 \theta + 1 = sec^2 \theta 1 + cot ^2 \theta = csc^2 \theta 5. 3 Problem Solving with the | {
"domain": "hhdy87.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9901401441145626,
"lm_q1q2_score": 0.837601566789277,
"lm_q2_score": 0.8459424373085146,
"openwebmath_perplexity": 945.3422094831918,
"openwebmath_score": 0.7557592391967773,
"tags": null,
"url": "http://www.hhdy87.com/ore2/pythagorean-identities-proof-problems.html"
} |
quantum-mechanics, angular-momentum, quantum-spin, eigenvalue
For a given set of states with angular momentum $j$, only the state with $m=j$ is killed by $\hat L_+$. This follows from the usual
\begin{align}
\hat L_+\vert \ell,m\rangle &=\sqrt{(\ell-m)(\ell+m+1)}\vert \ell,m+1
\rangle\, ,\\
\hat L_+\vert \ell,\ell\rangle&=0\, .
\end{align}
State counting: in your full Hilbert space spanned by states of the form $\vert j_1m_1\rangle \vert j_2m_2\rangle$, there is only one state with eigenvalue $m=\frac{1}{2}+\ell$, and it is the state
$$
\vert s=\textstyle\frac{1}{2},\ell;m_s=\frac{1}{2},m_\ell=\ell\rangle = \vert \frac{1}{2},\frac{1}{2}\rangle\vert \ell,\ell\rangle\, .
\tag{1}
$$
All other states of the form $\vert s,m_s\rangle\vert \ell,m_\ell\rangle$ have a lower eigenvalue $m_s+m_\ell$ of $\hat L_x$ since by assumption $m_s+m_\ell<\ell+\textstyle\frac{1}{2}$. | {
"domain": "physics.stackexchange",
"id": 40273,
"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, angular-momentum, quantum-spin, eigenvalue",
"url": null
} |
dynamic-reconfigure
Title: dynamic_reconfigure and catkin
Dear all,
I would like to know if there is a way, even a workaround, of generating dynamic_reconfigure files from a catkin package. AFAIK, there is no way currently to use dynamic_reconfigure in a catkin package as the CMake macro is not compatible (rely on rosbuild macros).
Is there a workaround?
Is it planned for dynamic_reconfigure to switch to catkin?
Thanks!
Originally posted by Thomas on ROS Answers with karma: 4478 on 2013-01-07
Post score: 2
I believe there is a way do generate the files using catkin:
In your CMakeLists.txt
#add dynamic reconfigure api
find_package(catkin REQUIRED dynamic_reconfigure)
generate_dynamic_reconfigure_options(relative_path_to_file1 relative_path_to_file2 ...)
From the dynamic reconfigure tutorial: http://ros.org/wiki/dynamic_reconfigure/Tutorials/HowToWriteYourFirstCfgFile
Originally posted by adobke with karma: 71 on 2013-01-07
This answer was ACCEPTED on the original site
Post score: 2 | {
"domain": "robotics.stackexchange",
"id": 12299,
"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": "dynamic-reconfigure",
"url": null
} |
php, design-patterns
class CarFactory extends VehicleFactory
{
public static function build($car) : Car
{
switch ($car)
{
case 'BMW': return new BMW();
case 'Audi': return new Audi();
// ...
}
}
}
$aircraft = AircraftFactory::build($choice);
$aircraft->drive();
$car = CarFactory::build($choice);
$car->drive();
Hopefully this gives you an idea of why the factory pattern is useful. The upshot is that your base factory class defines the interface by which users will request an object be created, and the factory subclasses take care of the actual definition for how it happens. In addition, defining each factory's return type in terms of a base object (i.e..., the CarFactory returns a Car) allows us to choose the actual subclass of that object that actually gets created at runtime (users can pick a BMW or an Audi, both of which are Cars, all of which are Vehicles, all of which are Drivable). | {
"domain": "codereview.stackexchange",
"id": 39568,
"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, design-patterns",
"url": null
} |
hydrology, water, wind, fluid-dynamics
Title: Can air be slowed down by Fricton? Can wind/air that is moving at average speeds be slowed down by the cause of Friction? Also, Can Air bubbles in water be slowed down because of Friction? Please cite your sources. Air is affected by friction. A brief search of AMS journals shows over 14,000 times friction is mentioned. How it is manifested in the equations that describe the atmosphere is complicated.
Let's think of wind as 'air moving' or perhaps space moving which air occupies. At some point, called the roughness length, the wind is 0 m/s (or knots or mph). If such a thing does not exist, then the earth would move with the wind (which is legitimate thing with blowing dust/snow). Concerning this, the atmosphere produces a frictional torque on the earth, and vice-versa. A metric to gauge the influence of friction is the friction velocity. Perhaps, most notably, friction is a major cause on why the surface wind and geostrophic wind are not the same. | {
"domain": "earthscience.stackexchange",
"id": 2209,
"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": "hydrology, water, wind, fluid-dynamics",
"url": null
} |
ros, catkin-make, catkin-package, anaconda
ImportError: "from catkin_pkg.package import parse_package" failed: No module named 'catkin_pkg'
Make sure that you have installed "catkin_pkg", it is up to date and on the PYTHONPATH.
CMake Error at /opt/ros/kinetic/share/catkin/cmake/safe_execute_process.cmake:11 (message):
execute_process(/home/daniel/anaconda3/bin/python
"/opt/ros/kinetic/share/catkin/cmake/parse_package_xml.py"
"/opt/ros/kinetic/share/catkin/cmake/../package.xml"
"/home/daniel/catkin_ws2/build_isolated/cartographer_ros_msgs/catkin/catkin_generated/version/package.cmake")
returned error code 1
Call Stack (most recent call first):
/opt/ros/kinetic/share/catkin/cmake/catkin_package_xml.cmake:63 (safe_execute_process)
/opt/ros/kinetic/share/catkin/cmake/all.cmake:151 (_catkin_package_xml)
/opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:20 (include)
CMakeLists.txt:27 (find_package) | {
"domain": "robotics.stackexchange",
"id": 27300,
"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, catkin-make, catkin-package, anaconda",
"url": null
} |
java
Title: Add numbers in array without adding adjacent number This is first time I code reviewing and would like feedback on coding in industry standards and optimum code.
This program adds number in array in two formats:
Adds adjacent numbers in a serial manner as proof for the actual sum to refer to the required output.
Adds the last and first variables in the array.
import java.util.stream.IntStream;
class twoadj1
{
public int a;
public int b[];
public int sum=0;
public int sum1=0;
public int k=0;
public int m=0;
twoadj1(int size)
{
b = new int[size];
k = size-1;
m = size;
}
void valueadd()
{
{
for(int z = 0; z < b.length; z++) {
b[z] = (int)(Math.random()*9);
System.out.print(b[z]+ " ");
int sum = IntStream.of(b).sum();
System.out.println("real sum"+sum);
}
for (int j=0;j<b.length/2;j++)
{ | {
"domain": "codereview.stackexchange",
"id": 21243,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "java",
"url": null
} |
coordination-compounds, hybridization
Now you may decide to argue using square planar complexes. However, the complex in question cannot be square planar since there are six ligands.
Therefore, a magnetic moment of zero is not an option in the case presented; $\ce{[Ni(H2O)2(NH3)4]^2+}$ cannot reasonably adopt a low-spin configuration. The high-spin complex is paramagnetic and in a triplet state ($2S+1 = 3$). | {
"domain": "chemistry.stackexchange",
"id": 6995,
"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": "coordination-compounds, hybridization",
"url": null
} |
quantum-field-theory, operators, wick-theorem
This may be generalized to the situation in which the normal product also contains a contraction within the set $\{\hat{F}_i\}_{i=\overline{1,k}}$
$$\color{navy}{\overset{\huge\frown}{\hat{F}_m\hat{F}_{n}}:\prod_{i\neq m,n}^{1,k}\hat{F}_i:}\hat{F}_{k+1}=\color{green}{\overset{\huge\frown}{\hat{F}_m\hat{F}_{n}}:\prod_{i\neq m,n}^{1,k}\hat{F}_i\,\hat{F}_{k+1}:}+\color{purple}{\sum_{j\neq m,n}^{1,k}\overset{\huge\frown}{\hat{F}_j\hat{F}_{k+1}}\overset{\huge\frown}{\hat{F}_m\hat{F}_{n}}:\prod_{i\neq j,m,n}^{1,k}\hat{F}_i:}\tag{5}\label{generalizedwick1}$$
and the same for two contractions | {
"domain": "physics.stackexchange",
"id": 75838,
"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, wick-theorem",
"url": null
} |
special-relativity, time-dilation
Therefore, if $M_2$ is in the positive $x$ direction from $M_1$, and $v \gt 0$, then it turns out that $E_2$ happens instantaneously after $E_1$, but it takes an infinite time for $E_1$ to occur again. This obviously changes (i.e. $E_1$ and $E_2$ may be exchanged) with the 'signs' of the mirror separation and observer velocity. This is one of the reasons that, for simple thought experiments with 'light clocks', the mirror separation is chosen in a direction perpendicular to the relative motion: so that arguments about 'time elapsed' are uniform.
As an additional remark, note that there is no problem with the overall idea that some things may be infinite when you approach the speed of light; that is built into special relativity almost by design. | {
"domain": "physics.stackexchange",
"id": 21387,
"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, time-dilation",
"url": null
} |
algorithms, graphs, shortest-path
Title: extending bellman ford to find shortest weight paths with no repeating vertices Is it possible to extend the Bellman Ford algorithm to output all shortest simple paths without repeating vertices?
The issue is that the Bellman Ford algorithm doesn't make any checks for whether the shortest "paths" it counts have repeating vertices. Also, if one were to keep track of all of these paths, I think it would be very inefficient. Breadth first search doesn't even come close to solving the issue, as it can't be used if edge weights are not all equal to a positive number. Dijkstra's algorithm doesn't work for negative weight edges. | {
"domain": "cs.stackexchange",
"id": 19726,
"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, graphs, shortest-path",
"url": null
} |
c#, strings, .net, converting, formatting
byte[] workingSet = new byte[newLength];
for (int i = 0; i < originalLength; i++)
{
workingSet[i] = input[i];
}
for (int g = 0; g < newLength / 3; g++)
{
workingResult += alphabet[((workingSet[(g * 3)] & 0xFC) >> 2)];
workingResult += alphabet[((workingSet[(g * 3)] & 0x03) << 4) | ((workingSet[(g * 3) + 1] & 0xF0) >> 4)];
workingResult += alphabet[((workingSet[(g * 3) + 1] & 0x0F) << 2) | ((workingSet[(g * 3) + 2] & 0xC0) >> 6)];
workingResult += alphabet[((workingSet[(g * 3) + 2] & 0x3F))];
}
if ((options & Base64FormattingOptions.RequirePaddingCharacter) == Base64FormattingOptions.RequirePaddingCharacter)
{
if (originalLength != newLength)
{
for (int p = 0; p < newLength - originalLength; p++)
workingResult += alphabet[64];
}
}
int lineBreaks = 0; | {
"domain": "codereview.stackexchange",
"id": 15723,
"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#, strings, .net, converting, formatting",
"url": null
} |
water, ph, buffer
$$\ce{2H2O + H2CO3 <=> 2H3O+ + CO3^2-}$$
$$K1K2 = \frac{\ce{[H3O+]^2[CO3^2-]}}{\ce{[H2CO3]}}$$
Analysing our system, to give a full treatment, if we know the solution pH, we can calculate $\ce{[H3O+]}$. So we are left with three unknown variables, $\ce{[H2CO3]}$, $\ce{[HCO3-]}$ and $\ce{[CO3^2+]}$. But so far we have only two independent mathematical equations, for K1 and K2 (the overrall equation does't count as independent, as it's only the merging together of the other two). To solve it, we need at least one more independent equation, to match the number of unknows. What we need is the equation for the material balance of the system. As we assumed all carbonate came from calcium carbonate, we can write:
$$Cs = \ce{[CaCO3]} = \ce{[H2CO3] + [HCO3-] + [CO3^2-]}$$ | {
"domain": "chemistry.stackexchange",
"id": 13651,
"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": "water, ph, buffer",
"url": null
} |
turing-machines, strings, string-metrics
We observe that $t_{M'}(x) - t_{M'}(y) \geq T > 0$ since $x \neq y$. Condition (**) is satisfied by increasing the running-time on all inputs that begin with $xy$ as well; hence, $M' \in X^L_*$ and thus $d(x,y) > 0$.
This constructions works for all pairs of distinct $x$ and $y$, proving the claim. Your claim follows since trivially $d(x,x) = 0$ for all $x$.
I think the problem is that $d(x,y)$ is not well-defined. With a similar construction as above, we can increase the difference between $t_M(x)$ and $t_M(y)$ by an additional $i$ for all $i \in \mathbb{N}$. Since the sum of $t_M(xy)$ and $t_M(yx)$ grows with $i$ as well (unless either is $\varepsilon$), $d(x,y)$ approaches a constant for $i \to \infty$ and the maxium does not exist. | {
"domain": "cs.stackexchange",
"id": 7140,
"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": "turing-machines, strings, string-metrics",
"url": null
} |
beginner, rust
Links to the code on Godbolt,, and the OLIS sequence.
You might prefer the use of a helper function to a chain of map calls:
/* Finds all pairs (a,b) such that a**3 + b**3 = sum.
*/
fn taxicab_pairs(sum: usize) -> Vec<(usize, usize)> {
/* Given a and sum, finds b such that a**3 + b**3 == sum, if b exists.
* Returns either Some((a,b)) or None.
*/
fn find_dual(sum: usize, a: usize) -> Option<(usize, usize)> {
let b_cubed = sum - a*a*a;
let b = f64::round(f64::powf(b_cubed as f64, 1.0 / 3.0)) as usize;
if b*b*b == b_cubed {
Some((a, b))
} else {
None
}
}
/* If positive integers a**3 + b**3 = i, and WLOG a <= b,
* a <= pivot and b >= pivot.
*/
let pivot: usize = f64::floor(f64::powf(sum as f64 / 2.0, 1.0 / 3.0) + f64::EPSILON) as usize;
(1..=pivot)
.filter_map(move|a| find_dual(sum, a))
.collect()
} | {
"domain": "codereview.stackexchange",
"id": 44840,
"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": "beginner, rust",
"url": null
} |
tools. A converse in geometry is when you take an conditional statement and reverse the premise “if p” and the conclusion “then q”. Maybe it was cake, pie, brownies or some other tasty, fatty food. In Mathematical Geometry, a Converse is defined as the inverse of a conditional statement. Condition: Sides BC and AC of triangle ABC are equal. A converse is when you switch the hypothesis and the conclusion. Similarly, if two alternate interior or alternate exterior angles are congruent, the lines are parallel. How To Write A Converse In Geometry Description. These unique features make Virtual Nerd a viable alternative to private tutoring. Is the COVID-19 Crisis Increasing America's Drug Overdoses. The converse in geometry applies to a conditional statement. Learn what is converse. If you find product , Deals.If at the time will discount more Savings So you already decide you want have How To Write A Converse In Geometry for your, but you don't know where to get the best price for this How | {
"domain": "gridserver.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9518632343454895,
"lm_q1q2_score": 0.8336294307528215,
"lm_q2_score": 0.8757869835428965,
"openwebmath_perplexity": 875.0929390351697,
"openwebmath_score": 0.35917341709136963,
"tags": null,
"url": "https://s116323.gridserver.com/the-twin-fmm/the-converse-in-geometry-2f0cf9"
} |
quantum-field-theory, field-theory, scattering, scattering-cross-section, s-matrix-theory
If we have a local, massless theory, the denominator is always quadratic in momenta. This is a totally nontrivial point since naively, we could think of interactions of the form $\mathcal{L}_{int} \sim g_n \phi \partial ^n \phi$. But of course, massless theories do not admit such terms bilinear in fields since generic values of the $\{g_i\}$ introduces new poles in the two point function, that is to be interpreted as a new massive particle. Therefore all propagators are of the form $\frac{i}{(k_{i_1}+k_{i_2}+k_{i_3}...+k_{i_m})^2}$. No two propagators of a tree diagram carry the same momenta(for generic values of the external momenta), and hence when this propagator goes on shell, we find a simple pole in the Mandelstam variable $s_{{i_1 i_2....i_m}}=(k_{i_1}+k_{i_2}+k_{i_3}...+k_{i_m})^2$. | {
"domain": "physics.stackexchange",
"id": 71943,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-field-theory, field-theory, scattering, scattering-cross-section, s-matrix-theory",
"url": null
} |
reinforcement-learning, policies, value-functions
Title: Why does the value of state change depending on the policy used to get to that state? From what I understand, the value function estimates how 'good' it is for an agent to be in a state, and a policy is a mapping of actions to state.
If I have understood these concepts correctly, why does the value of a state change with the policy with which an agent gets there?
I guess I'm having difficulty grasping the concept that the goodness of a state changes depending on how an agent got there (different policies may have different ways, and hence different values, for getting to a particular state).
If there can be a concrete example (perhaps on a grid world or on a chessboard), that might make it clear why that might be the case.
I guess I'm having difficulty grasping the concept that the goodness of a state changes depending on how an agent got there | {
"domain": "ai.stackexchange",
"id": 737,
"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": "reinforcement-learning, policies, value-functions",
"url": null
} |
electromagnetism, general-relativity, gravity, stress-energy-momentum-tensor
Q2. There is no factor $8\pi$ in the Wu-Sachs version of the field equation. Why is it missing? I do not suppose this has to do with the systematic use of geometric units? Or maybe Wu and Sachs are just considering all the basic objects such as $\mathbf E$ and $\mathbf T$ scaled by $8\pi$ in comparison to the standard conventions? But that does not seem to be the case either, because I have seen the very same definition of the electromagnetic stress-energy tensor in sources which include $8\pi$ in the field equation ...
Any help in clearing up this matter will be deeply appreciated! | {
"domain": "physics.stackexchange",
"id": 19835,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "electromagnetism, general-relativity, gravity, stress-energy-momentum-tensor",
"url": null
} |
php, security, pdo
if(!empty($where))
{
$sql .= " WHERE " . implode(' AND ', $this->removeVowelsWhere($where, $table));
}
if(!empty($group))
{
$sql .= " GROUP BY (" . implode(', ', $this->removeVowels($group)) . ')';
}
return $this->action($sql);
}
public function delete($table, $where) {
$sql = 'DELETE FROM `' . $table . '`';
if(!empty($where))
{
foreach($where as $key => $value)
{
foreach($value as $operator => $attribute)
{
$sql .= "WHERE " .$key . " " . $operator . " '" . $attribute . "'";
}
}
}
return $this->action($sql);
}
public function update($table, $id, $column, $fields) {
$set = '';
$x = 1; | {
"domain": "codereview.stackexchange",
"id": 7889,
"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, security, pdo",
"url": null
} |
The feasible paths we find are:
---- 106 PARAMETER result negative numbers indicate prime cells
INDEX 1 = solution1
j1 j2 j3 j4 j5 j6 j7 j8 | {
"domain": "blogspot.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9833429580381723,
"lm_q1q2_score": 0.8129412126298076,
"lm_q2_score": 0.8267117855317474,
"openwebmath_perplexity": 1246.608280550852,
"openwebmath_score": 0.5432333946228027,
"tags": null,
"url": "https://yetanothermathprogrammingconsultant.blogspot.com/2021/09/another-rooks-tour-of-chessboard.html"
} |
algorithms, algorithm-analysis, knapsack-problems
Some of the tested permutations may include unpaired original items A + B that could benefit from a synergy, but the synthetic combination AB will also be tried and yield the proper total weight.
Using the above transformation of the problem , you can use dynamic programming (DP) and benefit from its speed-optimality tradeoff.
NOTE: If the up-front assumption does not hold, you need to augment the list of synthetic items with more combinations, like triples, quadruples, etc, possibly making the problem incapable of being solved in a reasonable time. In that case, this transformation will not be useful. | {
"domain": "cs.stackexchange",
"id": 21164,
"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, knapsack-problems",
"url": null
} |
java, beginner, array, parsing
public char[][] getChars() {
return charlist.toArray(new char[charlist.size()][]);
}
public double[] getDoubles() {
double[] ret = new double[doublelist.size()];
int cnt = 0;
for (Double d : doublelist) {
ret[cnt++] = d;
}
return ret;
}
public static void main(String[] args) throws IOException {
Path inputpath = Paths.get("hello.txt");
List<String> inputlines = Files.readAllLines(inputpath, StandardCharsets.UTF_8);
DataParser parser = new DataParser();
// set up a loop over the input data
for (String line : inputlines) {
parser.parseLine(line);
}
char[][] chars = parser.getChars();
double[] doubles = parser.getDoubles();
System.out.println(Arrays.deepToString(chars));
System.out.println(Arrays.toString(doubles));
}
}
Output: | {
"domain": "codereview.stackexchange",
"id": 6056,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "java, beginner, array, parsing",
"url": null
} |
python, web-scraping, beautifulsoup
def getAmmount(Selid, PropertyID, Viewstate, Eventvalidation):
return requests.post('website',
data="__LASTFOCUS=&__EVENTTARGET=ctl00%24cpMain%24ctl01%24grdResults&__EVENTARGUMENT=Select%24"+urllib.quote(Selid, '')+"&__VIEWSTATE="+urllib.quote(Viewstate, '')+"&__EVENTVALIDATION="+urllib.quote(Eventvalidation, '')+"&ctl00%24txtsearch=&ctl00%24rdoSearch=rdoSite&ctl00%24cpMain%24ctl01%24rblSearchType=PropertyID&ctl00%24cpMain%24ctl01%24txtPropertyID="+urllib.quote(PropertyID, ''),
verify=False,
headers={"User-Agent" : "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36", "Referer" : "https://nevadatreasurer.gov/UPSearch/", "Content-Type" : "application/x-www-form-urlencoded"})
def GetData(Html):
Soup = BeautifulSoup(Html)
return Soup.find('span', {"id" : "cpMain_ctl01_lblAmountValue"}).text | {
"domain": "codereview.stackexchange",
"id": 9414,
"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, web-scraping, beautifulsoup",
"url": null
} |
discrete-signals, fourier-transform, fourier, downsampling
Title: Understanding index transformation in derivation of Fourier transform for sampling rate reduction Was going over some notes regarding deriving fourier transform equation for Sampling Rate Reduction. Reference to Notes from below link https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-341-discrete-time-signal-processing-fall-2005/lecture-notes/lec05.pdf or from Book Discrete-Time Signal Processing by Alan V. Oppenheim (2nd Edition), equation 4.75.
$$r = i + kM$$
I am lost as to how this is obtained. I understand that every $M-1$ samples are dropped from original sampling results; but still cannot understand how this expression for $r$ is derived.
Could someone help me understand this? It's not derived, it's just chosen in a smart way such that the relationship between the decimated and the original sequences becomes obvious.
It's just a rearrangement of the terms of the sum. As a simple example, take an infinite sum of numbers $a_r$: | {
"domain": "dsp.stackexchange",
"id": 8991,
"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": "discrete-signals, fourier-transform, fourier, downsampling",
"url": null
} |
quantum-mechanics, density-operator, greens-functions
Can these definitions be generalized to many particle states? The standard definition of density matrix defines the probability distribution over the Hilbert space regardless of whether the states under discussion are single or many particle states. However I'm not sure how to generalize the Green function definition of probability to learn something about the occupation many particle states, it only teaches me about the occupation of a specific site? Can it be done, and if so how? | {
"domain": "physics.stackexchange",
"id": 69828,
"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, density-operator, greens-functions",
"url": null
} |
java, file, compression
Naming
The convention for constant values is all-caps. So instead of:
private static final int UndefinedNumberOfLines = -1;
Name like this:
private static final int UNDEFINED_NUMBER_OF_LINES = -1;
Wasted operations
The FileMessageReader checks if the string path passed in is a file,
by creating a File object from it.
So far so good, but then it throws away the File and keeps only the path.
It would be better to keep the File and forget about the path.
Later when you use the path to create a FileReader,
it will convert the path to a File. Again.
Besides, it's called a FileReader for a reason.
If you already have a File, it's better to use it.
Consider this code:
if (isInteger(line)) {
numberLinesInMessage = Integer.parseInt(line);
} else {
throw new IllegalMessageFormatException("line is not a number");
}
// ... | {
"domain": "codereview.stackexchange",
"id": 12270,
"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, file, compression",
"url": null
} |
using approxi-mation techniques. Therefore, k 2 corresponds to the slope of the solution one would get by. It is a quantity with the dimensions of (Energy)£(Time). Now Euler repeats it for natural logarithms. Euler's Method We have seen how to use a direction field to obtain qualitative information about the solutions to a differential equation. However, the accuracyfactor persuades scholar to use another complex method to replace Euler method [4], [5]. This paper, called 'Solutio problematis ad geometriam situs pertinentis,' was later published in 1741 [Hopkins, 2. Euler's Method, Taylor Series Method, Runge Kutta Methods, Multi-Step Methods and Stability. Runge-Kutta methods d. Our approach is to focus on a small number of methods and treat them in depth. Use the trapezoidal method with 100 steps to solve the same problem. The simple Euler method: yn = yn 1 +hf(yn 1); h = xn xn 1 can be made more accurate by using either the mid-point or the trapezoidal rule quadrature formula: yn = | {
"domain": "clandiw.it",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9929882058635181,
"lm_q1q2_score": 0.8359229450249943,
"lm_q2_score": 0.8418256532040707,
"openwebmath_perplexity": 860.9143158530364,
"openwebmath_score": 0.724964439868927,
"tags": null,
"url": "http://pdcv.clandiw.it/euler-method-pdf.html"
} |
java, validation, io, integer
public static int getInt(BufferedReader in) {
String errorMessage = "Please enter a valid integer: ";
boolean invalid = true;
int output = 0;
do {
try {
output = Integer.parseInt(in.readLine());
invalid = false;
} catch(NumberFormatException e) {
System.out.print(errorMessage);
} catch(IOException e) {
e.printStackTrace();
}
} while(invalid);
return output;
}//End of validateInt method.
public static int getInt(int value) {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String errorMessage = "Please enter the integer value " + value + ": ";
boolean invalid = true;
int output = 0; | {
"domain": "codereview.stackexchange",
"id": 27184,
"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, validation, io, integer",
"url": null
} |
From this perspective, the relational structure of a ring is a set $R$, two binary operations called $+$ and $\cdot$ and two "nullary functions" -- i.e., constants $0$ and $1$. There is more to the definition of a ring, namely the axioms that these relations must satisfy. In this sense, model theory is being overlayed on top of universal algebra. However, the definition of a homomorphism of relational structures doesn't depend on the axioms: a homomorphism of relational structures is just a map of the underlying sets which preserves, in a rather straightforward sense which I won't completely write out here (one can easily look it up online) all the relations. In the case of rings, this means that a homomorphism $f: R \rightarrow S$ is a map of the underlying sets such that
$\bullet$ For all $x,y \in R$, $f(x+y) = f(x) + f(y)$,
$\bullet$ For all $x,y \in R$, $f(x \cdot y) = f(x) \cdot f(y)$,
$\bullet$ $f(0) =0$, and
$\bullet$ $f(1) = 1$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9817357243200244,
"lm_q1q2_score": 0.8725262477508697,
"lm_q2_score": 0.8887587831798665,
"openwebmath_perplexity": 199.63215356552917,
"openwebmath_score": 0.959018349647522,
"tags": null,
"url": "http://math.stackexchange.com/questions/141770/does-varphi1-1-if-varphi-is-a-field-homomorphism"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.