text stringlengths 1 1.11k | source dict |
|---|---|
organic-chemistry, boiling-point, melting-point, cyclohexane
Title: Boiling/melting points of cyclohexane and cycloheptane I’m looking at a chart in my book, and while cycloheptane has a higher boiling point than cyclohexane like I’d expect, cycloheptane has a melting point of −12 °C, while cyclohexane has a melting point of 6.6 °C. Why does it have a lower melting point only? There are not many reputable sources on the matter (as I could find) since it seems that cycloheptane isn't the most popular chemical around (poor guy) but I will present you with the best explanation/argument/insight into the situation as I can.
Note that it would be solely my own interpretation, and a case of explaining results that we see, rather than formulating an explanation to encompass natural phenomena without observing the results prior.
The key ingredient that I noticed while looking through charts and whatnot was bonding which is connected to sterics. More on that later.
Melting and Boiling Points of Cycloalkanes | {
"domain": "chemistry.stackexchange",
"id": 3773,
"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, boiling-point, melting-point, cyclohexane",
"url": null
} |
quantum-mechanics
Title: Expansion Coefficient - Why Does Sigma Disappear?
How is the second equation derived with the orthonormality property?
The orthonormality property is
< a"|a'> = kronecker delta_a",a'
I ask because I don't know why the summation in the first equation disappears in the second equation, especially since I could imagine a' and a" being the same while varying. The second equation $c_{a'} = <a'|\alpha>$ says "the coefficient of $|\alpha>$ corresponding to eigenstate $|a'>$ is computed by projecting $|\alpha>$ onto $|a'>$". Think of it in the scope of linear algebra, where a vector in n-dimentional space is decomposed over a given orthonormal basis. The orthonormality of the basis is required to make this formula valid: for any given basis element $|a>$,
$$ <a|\alpha> = <a|\sum_{a'} c_{a'}|a'> = \sum_{a'} <a|a'><a'|\alpha> = \sum_{a'}\delta_a^{a'} <a'|\alpha> = <a|\alpha>$$. | {
"domain": "physics.stackexchange",
"id": 40042,
"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",
"url": null
} |
javascript, jquery, game, html, css
_.extend(Game.prototype, {
play: function (player, move) {
var g = this.data,
p = g.players[g.currentPlayer];
g.winningMoves = { horizontal: [], vertical: [], diagonalDown: [], diagonalUp: [] };
g.status.wrongPlayer = g.currentPlayer !== player;
g.status.isDuplicate = Utils.isDuplicate(g.allMoves, move);
if (g.status.wrongPlayer) { return g; }
if (g.status.isDuplicate) { return g; }
g.allMoves.push(move);
p.moves.push(move);
if (p.moves.length >= g.size) {
_.each(p.moves, function (pmove) {
this.checkRules(pmove, move);
}, this);
g.winCondition = this.findWinner(g.winningMoves, g.size);
p.isWinner = true;
}
if (g.allMoves.length === (g.size * g.size) && !g.winCondition) {
_.each(g.players, function (pl) {
pl.isWinner = null;
});
g.winCondition = [];
} | {
"domain": "codereview.stackexchange",
"id": 4889,
"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, game, html, css",
"url": null
} |
clustering, graphs, social-network-analysis
Title: Clustering Multiple Networks I'm looking for methods of Community Detection in networks. For example if I have a network of 100 people (each node is a person), how can I cluster nodes? What would be the best approach for grouping these People? I know this question is rather open, but I'm just looking for a nudge in the right direction. Your question is not clear in a way there are two different Graph Clustering problems. One is having a dataset of different graphs and you would like to cluster similar graphs (in this case each object is a graph), and the other when you have a graph (e.g. a social network) and you would like to group similar nodes inside that graph (here each object is a node).
The first problem needs Graph Embedding which is to transfer graphs into a n-dimensional manifold and from there on, you have a classical clustering problem. For this case have a look at what Horst Bunke has done. | {
"domain": "datascience.stackexchange",
"id": 1616,
"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": "clustering, graphs, social-network-analysis",
"url": null
} |
quantum-operation, noise, quantum-process-tomography
Thanks! The 2-norm difference typically isn't particularly physical. So no, this is most likely not the right distance. What you want from a physical point of view is a distance measure which measures the maximal distance between the two channels on any possible input (possibly on a larger system), such as the diamond norm.
Note that the fact that "norms are equivalent" just means that they are bounded with respect to each other, but this does by no means imply that the minimum distance is obtained at the same point, or takes the same value! (Just consider the 1- and $\infty$-norm in $\mathbb R^2$, where one is a square, where the lines of constant distance are a square and a diamond, respectively.)
One reason why people might be using the 2-norm distance, though, is that this is a quadratic problem, so it is easy to minimize by solving an eigenvalue problem. But this is a purely pragmatic reason. | {
"domain": "quantumcomputing.stackexchange",
"id": 2330,
"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-operation, noise, quantum-process-tomography",
"url": null
} |
c, game
#include <stdlib.h>
#include <SDL_main.h>
#define FPS 25
#define NUM_ANTS 400
#define NUM_ROCKS 800
#define COL_GRAY1 0xb0b0b0
#define COL_GRAY2 0x808080
struct ant ANTS[NUM_ANTS];
void Draw_Ground(void);
void Initialize_Ants(void);
void Erase_Ants(void);
void Move_Ants(void);
void Behind_Ants(void);
void Draw_Ants(void);
int main (int argc, char* argv[])
{
set_video_mode();
Draw_Ground();
Initialize_Ants();
while (!kbhit())
{
unsigned int then = now();
Erase_Ants();
Move_Ants();
Behind_Ants();
Draw_Ants();
delay_fps(FPS, then);
}
return 0;
}
void Draw_Ground(void)
{
int i, x, y;
for (i = 0; i < NUM_ROCKS; i++)
{
x = (rand() % 320) * 2;
y = (rand() % 240) * 2;
put_pixel(x, y, (rand() % 2 ? COL_GRAY1 : COL_GRAY2));
}
}
void Initialize_Ants(void)
{
int i; | {
"domain": "codereview.stackexchange",
"id": 25508,
"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, game",
"url": null
} |
c#, .net, wpf
Title: Rounded borders for different controls (Button, TextBox, ComboBox) via Attached Property Suppose you just want to set border radius for different controls:
Button
TextBox
ComboBox
The most frequent approach I usually find is totally override default template like in answers
https://stackoverflow.com/a/4779905/1548895
https://stackoverflow.com/a/6746271/1548895
https://stackoverflow.com/a/17681374/1548895
I find overriding default styles for every CornerRadius value of Button, TextBox, ComboBox very bad idea for the following reasons:
You'll have to carry a lot of styles in your resources and they will be polluted with a lot of default properties.
You create duplicate code for every property value if you need different values
You don't have clean, elegant code for setting border radius itself | {
"domain": "codereview.stackexchange",
"id": 31021,
"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, wpf",
"url": null
} |
newtonian-mechanics, angular-momentum, momentum, rotational-dynamics
Also, the amount of work required to increase the velocity to 50 times is unreasonably high. There's something missing here. What is it exactly? You're not missing much. First of all, if we do this experiment under ideal conditions (massless string, no aerodynamic drag, no torque), then the increase in $\omega$ will indeed follow angular momentum conservation, and, yes, the centrifugal force will become very large, so that work against it can indeed provide the needed kinetic energy. Back in the real world, meanwhile, that mass of yours will experience some very substantial aerodynamic drag at those kinds of velocities. In addition, you'll probably see other kinds of friction losses from the string (aerodynamic and mechanical), so in the end your velocities should be significantly lower. | {
"domain": "physics.stackexchange",
"id": 45495,
"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, angular-momentum, momentum, rotational-dynamics",
"url": null
} |
ros, executive-smach, smach
Original comments
Comment by 130s on 2014-11-18:
+1 I believe some or many researchers using PR2 use smach (I've seen some within the last 1 year) but haven't seen it applied for other robots, although it should be very useful.
Comment by arennuit on 2014-11-18:
Thanks for your helpful input ;)
Comment by 130s on 2014-11-18:
Also I just randomly hit an email where @Pi Robot used it.
Comment by Adolfo Rodriguez T on 2014-11-21:
FWIW, SMACH has been used in many non-PR2 robots.
Comment by arennuit on 2014-11-21:
okey dok, I take note. Thanks ;)
Given that smach is released into Indigo, that's a good sign that it's still maintained.
There are a few open issues, but nothing major. I suspect you could get the maintainer's attention and get a bug fix accepted and released if you found a major bug. That said, smach has been around for many years, and I suspect most of the bugs have been worked out by now; don't confuse a lack of changes for lack of maintenance. | {
"domain": "robotics.stackexchange",
"id": 20080,
"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, executive-smach, smach",
"url": null
} |
• If the maps happen to go into a field, "pairing" has the minor misfortune of being a term one might also use to describe an inner product of $f_1$ and $f_2$. To make matters worse, come to think of it, an inner product is often denoted $(f_1, f_2)$. Fortunately, there's an easy fix: just refer to $(f_1, f_2) \colon X \to Y_1 \times Y_2$ as the tupling even when you're only tupling two things (and hope nobody adopts this terminology for multilinear functionals, I guess). – Vectornaut Oct 6 '15 at 18:47
• @Vectornaut I'd think if you referred to the pairing $(f_1, f_2): X \to Y_1 \times Y_2$ or $\langle f_1, f_2 \rangle: X \to Y_1 \times Y_2$, then context should usually be sufficient to disambiguate this sense of pairing from bilinear pairing, since a product $Y_1 \times Y_2$ of two rings is never a field. :-) – Todd Trimble Oct 6 '15 at 19:27 | {
"domain": "mathoverflow.net",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9669140244715406,
"lm_q1q2_score": 0.8218490574891876,
"lm_q2_score": 0.8499711832583696,
"openwebmath_perplexity": 527.87374565866,
"openwebmath_score": 0.8335656523704529,
"tags": null,
"url": "https://mathoverflow.net/questions/220106/what-is-the-term-for-combining-functions-f-1-f-2-dots-f-n-into-a-tuple-f-1"
} |
thermodynamics
If you want an example of a non-spontaneous process that's common, consider cloud formation. For clouds to spontaneously form, the temperature profile in the atmosphere has to be such that air that starts rising will, even though it cools as it rises since it's expanding, remain warmer than its new surrounding air. Then, since it's warmer, it will continue to rise until it cools enough to condense into a cloud (and probably past that). But what if the temperature profile is different, so a rising air parcel is cooler than its surrounding air? Then it would go back to where it started. So, this is a non-spontaneous process because energy has to be put into the system to make the air rise. This happens when, for example, the whole region of air moves over a mountain range. Then, the mountain forces the air to rise, creating clouds, and the energy came from the large-scale flow. | {
"domain": "physics.stackexchange",
"id": 81466,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "thermodynamics",
"url": null
} |
ros, joint, rviz, urdf, transform
When I launch it by "roslaunch sp1s display.launch model:=urdf/sp1s.urdf", the Rviz keep saying "No transform from [front_left] to [base_link]".
I double checked my urdf content, I believe it caused by using joint type "continuous".
I strongly believe its a bug. When I follow the urdf_tutorial by 'roslaunch urdf_tutorial display.launch model:=urdf/06-flexible.urdf gui:=True', it was showing fine. But I changed the 06-flexible.urdf simply by add one space at the last empty line, launch it again it would say same thing on RViz
Why its happening, how to work around it?
Originally posted by Dragon Qu on ROS Answers with karma: 73 on 2015-01-20
Post score: 0
I got it! It took me a whole day to figure out why.
joint_state_publisher failed to parse the urdf xml file. It dumped error message:
UnicodeEncodeError: 'ascii' codec
can't encode character | {
"domain": "robotics.stackexchange",
"id": 20627,
"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, joint, rviz, urdf, transform",
"url": null
} |
forces, momentum, acceleration, inertia
So what I'm trying to do is calculate the weight of an item in the event of an emergency stop. So I want to have a spreadsheet where I can simply enter in the weight of a product, initial speed, resultant speed, and time delay between the two. The spreadsheet should then give me the resultant weight of the item as it decelerates.
Can someone help me simplify the equation so that it can be put in a series Excel compatible formulae? What my answer in the linked question is attempting to do is determine the apparent weight of an object that is rapidly decelerating. The relation,
$$\frac{\Delta p}{\Delta t}=\frac{p(t_2)-p(t_1)}{t_2-t_1}\simeq F\tag{1}$$
tells you that the rate of change momentum is equal to the force. So what I do in my answer is take this force and set it equal to the gravitational force,
$$
F = mg,\tag{2}
$$
to determine what the effective mass of this object is, to try verifying the claim in the question. $g$ here is the acceleration due to gravity (9.81 m/s$^2$). | {
"domain": "physics.stackexchange",
"id": 56517,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "forces, momentum, acceleration, inertia",
"url": null
} |
c++, multithreading, asynchronous, producer-consumer, multiprocessing
int main() {
std::cout << "Hello, World!" << std::endl;
Pipeline p;
p.buildAndRun();
std::cout << "Goodbye, World!" << std::endl;
return 0;
}
Is there a way to simplify the Code for Nodes by somehow adding condition_variable to the Queue and using that to synchronize and signal all output nodes to stop wait? (I have some ideas for this in the comments of the Queue class.. but need to be sure about race conditions and blocking stuff...)
Finally, a bit more open ended for the future.. I have to make the ``Queue` bounded at some point. What would be the most optimal way to handle this? The processing times of different nodes could be different and large queues could form at 'some' places but not others. Is it possible to have a global bound on total number of queued items rather than local bound on each queue? General | {
"domain": "codereview.stackexchange",
"id": 44637,
"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, asynchronous, producer-consumer, multiprocessing",
"url": null
} |
electricity, electric-current, voltage, power, batteries
In reality there are many batteries that have the same voltage but
different supply different currents.
When different batteries having the same open circuit (no load) voltage, referred to as the battery emf, supply different currents to the same resistance it is because the batteries have different internal resistance which is in series with the resistor connected to its terminals. That is why a 1.5 v alkaline C battery delivers more current than a 1.5 v alkaline AAA battery. The internal resistance of the C cell is less than the AAA cell.
Speaking of power. I still don't understand what exactly is it. A
battery have a specific power but how does it control the voltage and
the current? P = U1 x I1 = U2 x I2 = ... So if we rise the voltage,
what causes the current to decrease? | {
"domain": "physics.stackexchange",
"id": 73290,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "electricity, electric-current, voltage, power, batteries",
"url": null
} |
Lecture 16 (Introduction to Fourier Transforms) Lecture 17 (Fourier Transforms and the Wave Equation). This lecture note covers the following topics: Cesaro summability and Abel summability of Fourier series, Mean square convergence of Fourier series, Af continuous function with divergent Fourier series, Applications of Fourier series Fourier transform on the real line and basic properties, Solution of heat equation Fourier transform for functions in Lp, Fourier. 1 Fourier analysis was originallyconcerned with representing and analyzing periodic phenomena, via Fourier series, and later with extending those insights to nonperiodic phenomena, via the Fourier transform. Last modified by: kadiam Created Date: 7/7/2009 7:20:00 PM Category: General Engineering Manager: Autar Kaw Company. Maximal functions and Calderon--Zygmund decompositions are treated in R^d, so that. Find the Fourier series of the functionf defined by f(x)= −1if−π0 by Fourier's law and the boundary conditions (2). | {
"domain": "wwfmartesana.it",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9918120913084073,
"lm_q1q2_score": 0.8449770939444133,
"lm_q2_score": 0.8519528057272543,
"openwebmath_perplexity": 849.0646823502694,
"openwebmath_score": 0.8424391746520996,
"tags": null,
"url": "http://tcpb.wwfmartesana.it/"
} |
special-relativity, fluid-dynamics
The equations he specifies are continuity
$$ \frac{\partial}{\partial t}\left(\gamma n\right)+\nabla\cdot \left(\gamma n \mathbf{v}\right) =0,$$
Euler
$$ \frac{\partial \mathbf{v}}{\partial t} + \mathbf{v}\cdot \nabla \mathbf{v}=-\left(\frac{1-\mathbf{v}^2}{\rho+P}\right)\left(\mathbf{v}\frac{\partial P}{\partial t}+\nabla P\right), $$
entropy conservation
$$ \frac{\partial s}{\partial t}+\mathbf{v}\cdot \nabla s=0,
$$
and the equation of state
$$ P = P(\rho).$$
I count 6 equations and 7 unknowns $\{n,\mathbf{v},\rho,P,s \}$. How can we completely specify the fluid given just these equations? I am not familiar with Zee's text, since it seems relatively new on the G.R. front, but, for relativistic hydrodynamics and thus, relativistic thermodynamics, you have 8 quantities that characterize the fluid flow, and thus need 8 equations that govern the fluid's motion. The 8 quantities are: | {
"domain": "physics.stackexchange",
"id": 97889,
"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, fluid-dynamics",
"url": null
} |
beginner, console, go
return true, ""
}
func IsUnchanged(s State) bool {
return s == InitState()
}
colour.go
package libprojectstart
var (
HEADER = "\033[95m"
OKBLUE = "\033[94m"
OKGREEN = "\033[92m"
WARNING = "\033[93m"
FAIL = "\033[91m"
BOLD = "\033[1m"
UNDERLINE = "\033[4m"
RESET = "\033[0m"
) | {
"domain": "codereview.stackexchange",
"id": 30640,
"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, console, go",
"url": null
} |
c#, algorithm, .net
Complexity
You're doing a lot of things with a lot of lists of ports (better naming would have come in handy here!).
This is what you do:
Create list (A) of input ports
Parse A into another list (B)
Create new list that holds unique values from B
Clear B
Add all ports that adhere to a boundary check to list B
Sort B
That's a lot of stuff that we can refactor.
First of all: put that boundary check earlier in your code. Once a port is added to our result list of ports, it is a valid port. We don't want to copy everything to a new list just to add that boundary check (and you need more than that!).
In fact, now it's already a lot easier: by using the SortedSet<T> you will already do the sorting and duplicate removal so that's not needed either.
Best part: SortedSet<T> implements IEnumberable<T> so you can simply return your set as-is. | {
"domain": "codereview.stackexchange",
"id": 7159,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c#, algorithm, .net",
"url": null
} |
When asked the question, what is the probability of a coin toss coming up heads, most people answer without hesitation that it is 50%, 1/2, or 0. George flips an unfair coin 7 times. You chose one at random one of the coins, tossed it twice and the outcomes were both Heads. 984 Originally posted by lagomez on Mon Nov 02, 2009 5:05 am. The coin is flipped 50 times. What is the probability that the sum of the numbers on two dice is even when they are rolled? Ans: 18/36. Express the result in the form (a √ b+c)/d, where a,b,c,d are integers. Examples with unfair coins and dies Unfair coin A coin is biased with the probability of heads 2 3. Days of a week. There are 2 coins, one fair (heads/tails) and one unfair (head/head) A person chooses randomly between the two coins, and throws it. An unfair coin has a probability of coming up heads of 0. When I flip the coin and get tails, I lose a dollar. If a tail turns up, you lose $1. In this case, the coin landing on its side would depend on the | {
"domain": "rciretedimpresa.it",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9838471613889295,
"lm_q1q2_score": 0.8066497311802325,
"lm_q2_score": 0.8198933359135361,
"openwebmath_perplexity": 454.996892519576,
"openwebmath_score": 0.7294924855232239,
"tags": null,
"url": "http://lvme.rciretedimpresa.it/unfair-coin-probability.html"
} |
6. Jan 24, 2014
### Xiuh
7. Jan 25, 2014
### pwsnafu
8. Jan 29, 2014
### FactChecker
It is good to know that properties proven for a space will still hold for their limits. That is not true a lot of times. A property proved for every member of a complete space will still hold for limits of those members.
9. Jan 30, 2014
### mathwonk
In analysis we usually solve problems by finding a sequence of approximate solutions whose limit is an actual solution. Hence we need the limit to exist in our space. This is why we do calculus in the real numbers, a Banach space, rather than the rational numbers. Otherwise problems like: find x with x^2 = 2 would have no solution. | {
"domain": "physicsforums.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9572777975782054,
"lm_q1q2_score": 0.815555496511275,
"lm_q2_score": 0.8519527963298947,
"openwebmath_perplexity": 323.1467838469467,
"openwebmath_score": 0.8602431416511536,
"tags": null,
"url": "https://www.physicsforums.com/threads/why-banach-spaces.733882/"
} |
c#, rational-numbers
return string.Format("{0}/{1}", rational.numerator.ToString(innerFormat, formatProvider), rational.Denominator.ToString(innerFormat, formatProvider));
}
private string handleOtherFormats(string format, object arg, IFormatProvider formatProvider)
{
if (arg is IFormattable)
return ((IFormattable)arg).ToString(format, formatProvider);
if (arg != null)
return arg.ToString();
return String.Empty;
}
}
}
Tools class:
public static class Tools
{
public static BigInteger LeastCommonMultiple(this BigInteger number1, BigInteger number2)
{
if (number1 == 0) return number2;
if (number2 == 0) return number1;
var positiveNumber2 = number2 < 0 ? BigInteger.Abs(number2) : number2;
var positiveNumber1 = number1 < 0 ? BigInteger.Abs(number1) : number1; | {
"domain": "codereview.stackexchange",
"id": 14521,
"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#, rational-numbers",
"url": null
} |
javascript, html, css, ecmascript-6, event-handling
},
{
// Month 4
month: "May",
first_day: starting_day(date_object.getFullYear(), 4),
days: Array(total_month_days(date_object.getFullYear(), 4)),
},
{
// Month 5
month: "June",
first_day: starting_day(date_object.getFullYear(), 5),
days: Array(total_month_days(date_object.getFullYear(), 5)),
},
{
// Month 6
month: "July",
first_day: starting_day(date_object.getFullYear(), 6),
days: Array(total_month_days(date_object.getFullYear(), 6)),
},
{
// Month 7
month: "August",
first_day: starting_day(date_object.getFullYear(), 7),
days: Array(total_month_days(date_object.getFullYear(), 7)),
},
{
// Month 8
month: "September",
first_day: starting_day(date_object.getFullYear(), 8),
days: Array(total_month_days(date_object.getFullYear(), 8)),
},
{
// Month 9
month: "October", | {
"domain": "codereview.stackexchange",
"id": 39624,
"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, html, css, ecmascript-6, event-handling",
"url": null
} |
transform
Originally posted by BrettHemes with karma: 525 on 2017-05-18
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by TristanTrim on 2017-05-18:
Ahh, yes, this makes sense. I'm guessing then that what you're publishing as a message will vary enough that it makes sense to always include some kind of conversion utility, rather than just having a built in conversion utility. | {
"domain": "robotics.stackexchange",
"id": 27932,
"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": "transform",
"url": null
} |
Concentrating on just the first octant, we can see that a rotation by $\frac{2\pi}{3}$ (counterclockwise of course, with respect to the plane through the tips of $i,j,k$ (this is normal to $(1,1,1)$) sends $i$ to $j$, $j$ to $k$ and $k$ to $i$, where $i,j,k$ are my names for the standard basis. This plane cuts the first octant at an equilateral triangle, and the rotation is just permuting the vertices.
Writing this as a matrix on the left of column vectors, we would have then
$$T=\begin{bmatrix}0&0&1 \\1&0&0\\0&1&0\end{bmatrix}$$
As you can see:
$$T\begin{bmatrix}1\\0\\0\end{bmatrix}=\begin{bmatrix}0\\1\\0\end{bmatrix}$$
$$T\begin{bmatrix}0\\1\\0\end{bmatrix}=\begin{bmatrix}0\\0\\1\end{bmatrix}$$
$$T\begin{bmatrix}0\\0\\1\end{bmatrix}=\begin{bmatrix}1\\0\\0\end{bmatrix}$$
So it is indeed the transformation that permutes $i,j,k$ cyclically.
• the plane $x+y+z = 0$ cuts the unit cube in a regular hexagon of length $\sqrt 2$ called the petri polygon. – abel Jan 9 '15 at 15:24 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9830850852465429,
"lm_q1q2_score": 0.8060249143560477,
"lm_q2_score": 0.8198933403143929,
"openwebmath_perplexity": 285.2226525374186,
"openwebmath_score": 0.8217423558235168,
"tags": null,
"url": "https://math.stackexchange.com/questions/1097681/standard-matrix-of-rotation-of-unit-cube"
} |
python, git
Title: Counting the number of days worked for all commiters to a git repo I wrote this script to collect evidence of the number of days worked for the purpose of claiming some government tax credits.
I'm looking for some ways to clean it up. I'm especially wondering if there is a cleaner way to uniqueify a list than list(set(my_list) and maybe a better way to do:
d = dict(zip(commiters, [0 for x in xrange(len(commiters))]))
import os
from pprint import pprint
lines = os.popen('git log --all').read().split('\n')
author_lines = filter(lambda str: str.startswith('Author'), lines)
date_lines = filter(lambda str: str.startswith('Date'), lines)
author_lines = map(lambda str: str[8:], author_lines)
date_lines = map(lambda str: str[8:18].strip(), date_lines)
lines = zip(author_lines, date_lines)
lines = sorted(list(set(lines)), key = lambda tup: tup[0])
commiters = list(set(map(lambda tup: tup[0], lines)))
d = dict(zip(commiters, [0 for x in xrange(len(commiters))])) | {
"domain": "codereview.stackexchange",
"id": 1998,
"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, git",
"url": null
} |
algorithms, dynamic-programming, algorithm-design
If the input is a pair $(x,y)$, then recursively look at the type of $x$ and the type of $y$ to identify a way to choose a subproblem for each. In other words, one candidate way to define a subproblem is to replace $(x,y)$ by $(x',y')$ where $x'$ is a subproblem for $x$ and $y'$ is a subproblem for $y$. (You can also consider subproblems of the form $(x,y')$ or $(x',y)$.) | {
"domain": "cs.stackexchange",
"id": 5556,
"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, dynamic-programming, algorithm-design",
"url": null
} |
c++, algorithm, recursion, template, c++20
template<std::size_t unwrap_level, class...Ts1, template<class...>class Container1, typename... Ts>
requires ( std::ranges::input_range<Container1<Ts1...>> &&
requires { typename recursive_unwrap_type<
unwrap_level - 1,
std::ranges::range_value_t<Container1<Ts1...>>,
std::ranges::range_value_t<Ts>...>::type; }) // The rest arguments are ranges
struct recursive_unwrap_type<unwrap_level, Container1<Ts1...>, Ts...>
{
using type = typename recursive_unwrap_type<
unwrap_level - 1,
std::ranges::range_value_t<Container1<Ts1...>>
>::type;
};
template<std::size_t unwrap_level, typename T1, typename... Ts>
using recursive_unwrap_type_t = typename recursive_unwrap_type<unwrap_level, T1, Ts...>::type; | {
"domain": "codereview.stackexchange",
"id": 45483,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, algorithm, recursion, template, c++20",
"url": null
} |
ros, ros-hydro, rosdoc-lite
Title: When will rosdoc_lite be released to Hydro?
I do most of my work on Hydro lately. It mostly works fine.
But, it's very annoying having to switch to a Groovy workspace for working on documentation.
Any estimate for when a Hydro version might be released?
Originally posted by joq on ROS Answers with karma: 25443 on 2013-06-15
Post score: 0
I just released it today. It should be built in the next few hours into shadow-fixed and will go into the next hydro sync to public.
PS a better forum is probably ros-release for this sort of request.
Originally posted by tfoote with karma: 58457 on 2013-06-17
This answer was ACCEPTED on the original site
Post score: 1 | {
"domain": "robotics.stackexchange",
"id": 14581,
"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, ros-hydro, rosdoc-lite",
"url": null
} |
c#, game, unity3d
If this method decides whether the player can shoot or not, then what is _playerCanShoot. It turns out that sometimes _playerCanShoot == true (which suggests to the reader that the player can indeed shoot) but CheckIfPlayerCanShoot() will return false. Who should we trust?
If you can shoot if _bulletsLeft > 0, nothing stops you from shooting with one bullet in the magazine even if your _bulletsPerShoot is higher than one which makes your _bulletsLeft negative.
if (Physics.RaycastNonAlloc(transform.position, directionBulletRaycastShouldGo, rayHit, maxDistanceTheBulletCanHit, _bulletLayerMask) > 0)
{
for (int i = 0; i < rayHit.Length; i++)
rayHit.Length is always 4 since you made it that way. What you should check for is the result of Physics.RaycastNonAlloc(...) that you just got.
if (_bulletsLeft > 0)
Invoke(nameof(AllowPlayerShootAgain), _shootDelay);
return;
}
ReloadGun(); | {
"domain": "codereview.stackexchange",
"id": 43973,
"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#, game, unity3d",
"url": null
} |
integration, singularities, complex-numbers, regularization, wick-rotation
$$
I = \int_{\mathbb{R}^3} d^3\mathbf{k}\int_{-\infty}^{\infty} d k^0 \,\frac{1}{(|\mathbf{k}|^2 - (k^0)^2 - i\varepsilon)^2}\,.
$$
The "$+i\varepsilon$" is the so-called $\varepsilon$ prescription which is simply giving you instructions on how to analytically continue this expression.
By this I mean that we now regard the integrand as an analytic function of $k^0$ and the integral as a contour integral on the complex plane. There are many ways of defining such a contour integral, the $i\varepsilon$ tells you which one to pick.
The reason why we choose such a prescription comes from the very definition of the propagator as a time ordered correlator, I'll elaborate on that later. | {
"domain": "physics.stackexchange",
"id": 59208,
"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": "integration, singularities, complex-numbers, regularization, wick-rotation",
"url": null
} |
the formula: , where From the formula above follows, that the length of the vector is the scalar always greater than or equals to zero. Therefore, the magnitude and direction of the net gravitational force on mass A due to masses B and C are and right direction. In physics, speed is a pure scalar, or something with a magnitude but no direction --such as 5 m/s. Find the distance between the points A(1, 2, 3) and B(−1, 2, 0). For math, science, nutrition, history. RSI is an overbought-oversold indicator that compares the magnitude of a stock's recent gains to the magnitude of. Find (a) the magnitude and (b) the direction of the vector. By using this website, you agree to our Cookie Policy. Magnitude of Kinetic Friction Pull a block across the table Forces on the block: P is in the y direction and cannot affect motion in the x direction +y +x The kinetic frictional force increases. Geologists in the field can measure strike and dip with a compass. A magnitude 8 earthquake has the | {
"domain": "openbowlingtrichiana.it",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.98504291340685,
"lm_q1q2_score": 0.8098915722090282,
"lm_q2_score": 0.8221891261650248,
"openwebmath_perplexity": 399.03176281837773,
"openwebmath_score": 0.7278825640678406,
"tags": null,
"url": "http://awgn.openbowlingtrichiana.it/magnitude-and-direction-calculator.html"
} |
electrostatics
Title: Potential of a charge placed in the middle of two other charges Is the potential of two charges adds or subtract when you are going to find the potential at the middle? It adds irrespective of the position of the point at which potential should be found as potential is a scalar quantity
So it should be $$V=\frac{k}{r}.(q_1+q_2)$$
We consider the negative sign when the charge itself is negative, as $-ve$ charges are considered to have an opposite potential to that of positive charges | {
"domain": "physics.stackexchange",
"id": 64759,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "electrostatics",
"url": null
} |
python, api
def __iter__(self):
"""Generates release info for the specified wantlist url."""
for page in self._generate_pages():
for rid in self._generate_releases_on_page(page):
yield rid
Finally, this is how the @verify decorator is implemented:
import requests
import sys
import time | {
"domain": "codereview.stackexchange",
"id": 42717,
"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, api",
"url": null
} |
file, vb.net
And an example for the first option
For Each file As String In files
file_data = IO.File.ReadAllBytes(file)
For each signature in MasterSignatureList
if filedata.Length < signature.Length Then MasterSignatureList.Remove signature ' Obviously wrong
Next signature
For signatureIterator = 0 to file_data.Length ' we should exit the loop before getting to the end of most files!
signatureCheck = false
For each signature in MasterSignatureList
If signatureIterator < signature.Length Then ' retains signatures that have already passed
signatureCheck = true ' still some signatures to check
If file_data(signatureIterator) <> signature(signatureIterator) Then
MasterSignatureList.Remove signature ' signature does not match
End if
End if
Next signature
If MasterSignatureList.Empty or Not signatureCheck then Exit For ' exit if nothing left to check | {
"domain": "codereview.stackexchange",
"id": 32109,
"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": "file, vb.net",
"url": null
} |
quantum-mechanics, photons, atomic-physics
The atom has energy levels, and if the photon energy coincides (within a small $ΔE$, the width of the energy level) with the transition energy of kicking an electron to an empty energy level, then the atom can absorb the photon (not the electron). So the answer to "why", above, is "because the photon has the appropriate energy to transfer the electron to an empty energy level".
If the photon energy does not coincide with transition energy of the atom, the photon may scatter with the spillover electric fields of the atom or molecule either elastically, or transferring energy and a lower energy photon continues on its way.
The relevant thought to keep is that an elementary particle cannot absorb a photon. Composite ones as atoms, molecules and lattices, can. | {
"domain": "physics.stackexchange",
"id": 50765,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-mechanics, photons, atomic-physics",
"url": null
} |
I'm not sure how to start this one. I thought of simply solving for $\theta$, but I'm don't know how to transform the integrand.
First of all, you should always include $dx$ when you integrate. Secondly, here is a plot of the function.
I would assume you want to evaluate $\int_0^{0.5} \dfrac{8x^2}{\sqrt{1-2x^2}}\, dx$
The key is to think of it like a triangle(check triangle.pdf)
Now $\dfrac{1}{\sqrt{1-2x^2}}=\dfrac{1}{\cos{\theta}}$
$8x^2=4\times 2x^2=4\sin^2 \theta$
And lastly you have $\dfrac{d}{dx}(\sin \theta)=\sqrt{2}\dfrac{dx}{dx}$
$\sqrt{2}\, dx=\cos(\theta)\, d\theta$
Now the last part is to change the limits of integration. You have $\sin \theta=\sqrt{2}x$ so $x=0,\theta=0$ and $x=0.5,\theta=\sin^{-1}\left(\sqrt{2}\times 0.5\right)$
Can you finish from here? | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9830850867332734,
"lm_q1q2_score": 0.8082818684070977,
"lm_q2_score": 0.8221891261650248,
"openwebmath_perplexity": 171.44830000302235,
"openwebmath_score": 0.9508614540100098,
"tags": null,
"url": "http://mathhelpforum.com/calculus/151481-changing-limits-integration.html"
} |
discrete-signals, signal-analysis, acoustics
So now I am wondering if the definition of Oppenheim is simplified or which one represents the real physical scenario. Oppenheim's definition is not so much simplified as it is context-specific:
His definition is primarily conceptual and is used to analyze and process signals in terms of their mathematical properties, and as such it accurately represents the energy of a signal within the domain of signal processing mathematics. | {
"domain": "dsp.stackexchange",
"id": 12492,
"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, signal-analysis, acoustics",
"url": null
} |
vba, excel
Finally, just as an aside - I have no idea what ...some code... is doing in GetHighestRowOrCol, but from the If block it appears that ...some code... is calculating both maxRow and maxCol when it only ever returns one of them. I'm guessing this would be a more efficient structure:
If rowOrColumn = rowOrColumnOption.Row Then
'...some code to determine the highest row number.
GetHighestRowOrCol = maxRow
ElseIf rowOrColumn = rowOrColumnOption.Column Then
'...some code to determine the highest column number.
GetHighestRowOrCol = maxCol
Else
GetHighestRowOrCol = 0
End If | {
"domain": "codereview.stackexchange",
"id": 23210,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "vba, excel",
"url": null
} |
gravitational-waves
since GW decay as 1/r, can we assume that the amplitude at emission $h_{em}$ is roughly obtained assuming $r=2GM/c^2$ (i.e. produced near the Schwarzschild radius of the final BH), so that
\begin{align}
h_{em} &\approx \left(\frac{v}{c}\right)^2 \\
&\approx 10^{-2} \;?
\end{align}
GW decay should also depend on time (as hinted, for example, here). But after spending a few hours looking in the literature, I haven't found any derivation showing both time and distance decays of the strain. Does anyone have references on the subject?
the physical process leading to astrophysical GW is much less energetic than, say, inflation. So, when we say primordial GW (PGW) are harder to detect, is it only due to the decay with distance (and/or time) that is much greater?
The period of an astrophysical GW depends on the radius R of the orbit as $T_{GW}=2\pi R/\nu$. This formula does not make sense for PGW. Is there a way to obtain the period of a PGW? | {
"domain": "physics.stackexchange",
"id": 76871,
"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": "gravitational-waves",
"url": null
} |
java, dice
public class Game {
private Player p1;
private Player p2;
private Dice dice;
private int scoreToWin;
void displayGameMenu() {
System.out.println();
System.out.println("(1) Start a new game");
System.out.println("(2) Play one round");
System.out.println("(3) Who is leading now?");
System.out.println("(4) Display game help");
System.out.println("(5) Exit game");
System.out.print("Choose an option: ");
} | {
"domain": "codereview.stackexchange",
"id": 43232,
"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, dice",
"url": null
} |
javascript, beginner, jquery, image, callback
$.fn.galleryThumbSwapper = function(options) {
// Extend our default options with those provided.
// Note that the first argument to extend is an empty
// object – this is to keep from overriding our "defaults" object.
var opts = $extend({},$.fn.galleryThumbSwapper.defaults, options);
// do our DOM selections once
// define wrapper based on element this function was called on
var $wrapper = $(this);
// define main image and gallery image items
// here we only find element within the wrapper such that
// you could use multiple galleries on a page without
// worry about interaction problems between galleries so
// long as each gallery is contained within the wrapper
var $mainImage = $wrapper.find(opts.mainImageSelector);
var $galleryImages = $wrapper.find(opts.galleryImageSelector);
// set click handler
$galleryImages.on('click', swapImages); | {
"domain": "codereview.stackexchange",
"id": 21724,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "javascript, beginner, jquery, image, callback",
"url": null
} |
compilers, interpreters, theory
Compile the program from X to Y, then
Compile the program from Y to Z, then
Interpret the program using your Z interpreter.
Likewise, if you have a program written in X, and you have an interpreter for X written in Y, but no interpreter for Y, but instead you have an interpreter for Y written in Z, you can
Interpret the program using your interpreter for X running on …
your interpreter for Y running on …
your interpreter for Z.
Two ways of implementing programming languages
Fundamentally, there are two ways of implementing a programming language: compilation and interpretation.
tl;dr: An interpreter runs the program, a compiler translates the program to another language.
My question is is these interpreters break down the language into low level code like Assembly and machine code, | {
"domain": "cs.stackexchange",
"id": 19511,
"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": "compilers, interpreters, theory",
"url": null
} |
c#, parsing, csv
public class CsvParser : ICsvParser
{
public IEnumerable<List<string>> Parse(string csv, char separator = ';')
{
if (csv == null) { throw new ArgumentNullException(nameof(csv)); }
if (string.IsNullOrEmpty(csv)) { yield break; }
var doubleQuote = '"';
var carriageReturn = '\r';
var lineFeed = '\n';
var eof = false;
var i = 0;
resume:
var isQuote = false;
var isEscapeSequence = false;
var isLineBreak = false;
var buffer = new StringBuilder();
var line = new List<string>();
for (; i < csv.Length; i++)
{
var current = csv[i];
if (isLineBreak)
{
if (current == lineFeed)
{
i++; // Skip the line-feed.
goto yield;
} | {
"domain": "codereview.stackexchange",
"id": 28897,
"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#, parsing, csv",
"url": null
} |
c++, c++14
/// \brief Compares two numbers.
/// \tparam T Predicate of the checked number.
/// \tparam U Type of another number.
/// \param[in] lhs First number.
/// \param[in] rhs Second number.
/// \return True if first number is less than or equal to second, false
/// otherwise.
template <Predicate T, typename U>
bool operator<=(const CheckedNumber<T>& lhs, const U& rhs);
/// \brief Compares two numbers.
/// \tparam T Predicate of the checked number.
/// \tparam U Type of another number.
/// \param[in] lhs First number.
/// \param[in] rhs Second number.
/// \return True if first number is less than or equal to second, false
/// otherwise.
template <Predicate T, typename U>
bool operator<=(const U& lhs, const CheckedNumber<T>& rhs); | {
"domain": "codereview.stackexchange",
"id": 30098,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, c++14",
"url": null
} |
python, beginner, object-oriented, homework, hash-map
Bugs
The formula for "area" is not twice the sum of width & height.
I don't know what "surrounding" is, but the formula for perimeter is not width times height.
The midpoint (centre?) of a rectangle should be within the bounds of the rectangle. Consider the rectangles with corners (10, 10) and (12, 12). The centre would be (11, 11), not (1, 1) as calculated.
Awkward initialization
This code:
names = list(dct.keys())
coords = list(dct.values())
start = [names[0], coords[0]]
end = [names[1], coords[1]]
self.start = start
self.end = end
relies on the dictionary's ordering of keys. It can break in Python 3.6 and earlier (CPython 3.5 and earlier). It does not enforce the key names p1 and p2; any two keys will work. And self.start[0] and self.end[0] are never used, so storing the key names in these entries is unnecessary.
The code could simply and safely read:
self.start = dct['p1']
self.end = dct['p2'] | {
"domain": "codereview.stackexchange",
"id": 37655,
"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, object-oriented, homework, hash-map",
"url": null
} |
java, swing, text-editor
JLabel sample = new JLabel("AaBbYyZz");
Font prev = textarea.getFont();
JPanel preview = new JPanel();
sample.setPreferredSize(new Dimension(400,100));
sample.setHorizontalAlignment(JLabel.CENTER);
sample.setBorder(BorderFactory.createLineBorder(Color.BLACK , 2));
sample.setFont(textarea.getFont());
preview.add(sample);
GridBagLayout layout = new GridBagLayout();
GridBagConstraints cons = new GridBagConstraints();
JPanel north = new JPanel(layout);
cons.insets = new Insets(0,50,10,50);
JLabel font = new JLabel("Font :");
font.setHorizontalAlignment(JLabel.LEFT);
layout.setConstraints(font, cons);
north.add(font);
JLabel fontstyle = new JLabel("Font Style:");
fontstyle.setHorizontalAlignment(JLabel.LEFT);
layout.setConstraints(fontstyle, cons);
north.add(fontstyle); | {
"domain": "codereview.stackexchange",
"id": 29188,
"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, swing, text-editor",
"url": null
} |
First, we will show that if $|a| \le 1$ and $|b| \le 1$, then $(a,b)$ is good.
Case 1. $(0,0)$: $x^2$ has integer root $0$. It is good.
Case 2. $(1,0)$: $x^2+x$ has integer roots $0, -1$. It is good.
Case 3. $(-1,0)$: $x^2-x$ has integer roots $0, 1$. It is good.
Case 4. $(0,-1$: $x^2-1$ has integer roots $-1, 1$. It is good.
Case 5. $(0,1)$: $x^2+1$. If Peter starts, he must change $b$ or Alex will decrease $b$ to zero and the roots will be integral. But if he decreases $b$, it becomes the same as Case 1, and if he increases it, Alex can decrease by $3$ and it will become the same as Case 4. If Alex starts, he can decrease $b$ by $1$ to get Case 1. So it is good. | {
"domain": "mathematicalfoodforthought.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9935117290585669,
"lm_q1q2_score": 0.8145736523655078,
"lm_q2_score": 0.8198933425148213,
"openwebmath_perplexity": 244.5714741544119,
"openwebmath_score": 0.6436347961425781,
"tags": null,
"url": "http://www.mathematicalfoodforthought.com/2006/03/it-game-time-topic-algebrapolynomials_14.html"
} |
thermodynamics, freezing
The first process I described is melting, the same process in reverse is freezing. And as temperature doesn't change during melting and freezing, they both happen at the same temperature! | {
"domain": "physics.stackexchange",
"id": 9071,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "thermodynamics, freezing",
"url": null
} |
c#, .net, security
private static void PrintHelp(){
Console.WriteLine("=======================================================================");
Console.WriteLine("= Generic PHP Remote Code Execution Exploit");
Console.WriteLine("= \Written by Aleksey (github.com/Alekseyyy)");
Console.WriteLine("= \n= Exploits (windows-based) PHP Remote Code Execution bug to execute");
Console.WriteLine("= a reverse, simple, interactive connect-back shell.\n= ");
Console.WriteLine("= Run like: exploit.exe <SCRIPT> <LHOST> <LPORT>");
Console.WriteLine("= ");
Console.WriteLine("= \t<SCRIPT> is the vulnerable script (with the parameter)");
Console.WriteLine("= \t<LHOST> is the IP address (or DNS address) of the machine");
Console.WriteLine("= \t\trecieving the connect-back shell");
Console.WriteLine("= \t<LPORT> is the listening port for the connect back shell"); | {
"domain": "codereview.stackexchange",
"id": 41655,
"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, security",
"url": null
} |
graphs, clique
Title: Implementing Nesetril and Poljak's clique detection algorithm I want to implement the clique detection algorithm by Nesetril and Poljak described in [1].
However, I can't seem to understand how the auxiliary graph $H$ is to be created and how it can be used to detect a clique. For instance, the paper suggests that to detect a clique of size $3\ell$ in a graph of size $n$, we construct an auxiliary graph $H$ of size $n^\ell$. For the detection of a clique of size $6$ in a graph $G$ of size $8$ for example, then the size of $H$ would be $64$ (i.e. $8^2$) and then checking for the presence of a triangle in $H$ which would indicate the presence of a clique of size $6$ in $G$. | {
"domain": "cs.stackexchange",
"id": 7113,
"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": "graphs, clique",
"url": null
} |
c++, recursion, assembly, fibonacci-sequence, memoization
The executable files for Windows and Linux are available here, and the assembly code that my compiler for AEC generates is available here.
So, what do you think about it? Why would you do such a thing?
I understand that you wrote the Arithmetic Expression Compiler, and perhaps want to show it off. But who would ever want to write a function as simple as a Fibonacci sequence generater using three programming languages (AEC, Intel assembly, and C++) mixed together, and type way more code than it would take in either C++ or even pure Intel assembly itself to implement it?
AEC doesn't provide any benefits here. Looking at the generated assembly, AEC does not perform any kind of optimization.
fibonacci.aec syntax | {
"domain": "codereview.stackexchange",
"id": 38704,
"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++, recursion, assembly, fibonacci-sequence, memoization",
"url": null
} |
c++, beginner, random
Write usages out in declarative form
Write out some candidates
If list is empty, make usages more concrete, go back to 1
Narrow/order list based on "easy to use correctly, hard to use incorrectly"
Order the list based on implementation complexity
Start implementing from first to last, until the first working version
Think if they'll ever need more control, stop if not.
Port/factor out core functionality which has greatest amount of control, and base the interface on top of it. Usually template parameters with default arguments, function with default arguments, using declarations help. I've yet to see the cases where it would be impossible. | {
"domain": "codereview.stackexchange",
"id": 28547,
"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++, beginner, random",
"url": null
} |
beginner, networking, go
The command line interface, main.go:
package main
import (
"flag"
"fmt"
"os"
"strconv"
)
// TODO
// flags: --tcp, --udp; default is tcp
// flag: -W timeout
// flag: -v verbose; default=false
// drop default count, print forever, until cancel with Control-C, and print stats
const defaultCount = 5
func exit() {
flag.Usage()
os.Exit(1)
}
type Params struct {
host string
port int
count int
}
func parseArgs() Params {
flag.Usage = func() {
fmt.Printf("Usage: %s [options] host port\n\n", os.Args[0])
flag.PrintDefaults()
}
countPtr := flag.Int("c", defaultCount, "stop after count connections")
flag.Parse()
if len(flag.Args()) < 2 {
exit()
}
host := flag.Args()[0]
port, parseErr := strconv.Atoi(flag.Args()[1])
if parseErr != nil {
exit()
}
return Params{
host: host,
port: port,
count: *countPtr,
}
}
func main() {
params := parseArgs() | {
"domain": "codereview.stackexchange",
"id": 19232,
"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, networking, go",
"url": null
} |
quantum-gate, quantum-state, circuit-construction, terminology-and-notation
$$
U=\prod_{i=0}^{l-3}C_i.
$$
I remain unclear if that target register is supposed to be the one that starts $|0\rangle^{\otimes q}$, or not. I'm assuming not.
Overall, you would thus be left with
$$
\prod_{i=0}^{l-3}I^{\otimes q}\otimes(I^{\otimes (4l-2)}+P_1\otimes I^{\otimes(l-1)}\otimes P_1\otimes I^{\otimes(l+i-1)}\otimes P_1\otimes I^{\otimes (l-1)}\otimes(X-I)\otimes I^{\otimes(l-3-i)}).
$$
Note, the first two $P_1$s are the controls off $x_0$ and $y_0$. The third is the control off $z_i$, and the $(X-I)$ term should be acting on the target, $i$ of the extra register.
Now you can express each of these operators in Dirac notation if you really want to. | {
"domain": "quantumcomputing.stackexchange",
"id": 764,
"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-gate, quantum-state, circuit-construction, terminology-and-notation",
"url": null
} |
data-mining, classification, clustering
So... if it's classification, then you can use k-NN, that's similar to the idea of assigning a point to a cluster according to distance. But it's not defined as finding the nearest cluster, it's defined as finding the classes of the k nearest points, then applying a vote or something. 1-NN is basically like single-linkage clustering. kNN does require finding the most similar (training) data points to your new data point. Sampling is definitely sub-optimal, but it may be good enough if you classes are well separated. If the cost of calculating distances is high, then one way of reducing the cost of calculation is the idea of skyline clustering: use a cheap distance metric to determine a subset of points that are likely to be among the k nearest neighbours, then compute these neighbours using the more expensive distance metric.
Finally, if you will be classifying many points and not updating your model, it may be worth training a model (e.g. a decision tree) on the existing classes. | {
"domain": "datascience.stackexchange",
"id": 258,
"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": "data-mining, classification, clustering",
"url": null
} |
waves, string-theory, fourier-transform, boundary-conditions
Title: Linear term in string mode expansion From wave equation upon quantising a string:
$$ \partial^2_\tau X-\partial^2_\sigma X^2=0,$$ obtain that the solution looks like this $$X^\mu=X_L(\tau+\sigma)+X_R(\tau-\sigma).$$ Then fourier expansion gives $$X^\mu_{L/R}=x^\mu_{L/R}+\frac{1}{2}\alpha'p^\mu(\tau\pm\sigma)+i\sqrt{\frac{\alpha'}{2}}\sum_{n\neq 0}\frac{a^\mu_{n,L/R}}{n}e^{-in(\tau\pm\sigma)}.$$
I would like to understand where does the linear term in the expression containing $(\tau\pm\sigma)$ come from. I don't think such term appear explicitly in the fourier expansion of any function, although I do see that such a term is necessary so that this expression is compatible with the conserved charge we get from noether's theorem (i.e. string action symmetry is there before we write down such an expression). | {
"domain": "physics.stackexchange",
"id": 93936,
"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, string-theory, fourier-transform, boundary-conditions",
"url": null
} |
• I really don't understand downvotes for such kind of OP and answers!
– user
Sep 29, 2018 at 13:32
• @gimusi Me neither. Sep 29, 2018 at 13:34
• @gimusi: I can understand downvotes for the question. It is a question about a comparatively advanced concept (spans) when the OP appears to be fundamentally confused about a more basic concept (linear spaces). Such questions are difficult to answer - and even if a direct answer is attempted, it doesn't necessarily remove the original confusion. Sep 29, 2018 at 20:35
• @MeniRosenfeld I can't know in advance all the lacking in knowledge by the asker. I usually give the strictly necessary information and then if the OP requires some further explanation I add that or I discuss that by comments. See for example OP there is a line of answer and 3 hours of discussion.
– user
Sep 29, 2018 at 20:39 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9787126488274566,
"lm_q1q2_score": 0.800170476858911,
"lm_q2_score": 0.8175744717487329,
"openwebmath_perplexity": 80.77202244963004,
"openwebmath_score": 1.000001072883606,
"tags": null,
"url": "https://math.stackexchange.com/questions/2935414/span-of-vectors-with-more-entries-in-each-vector-than-the-amount-of-vectors/2935420#2935420"
} |
material-science, stress-strain, metals
In contrast, if look at the "normal design" case at the top of the image, the finite elements are all mostly in tension for the whole length of the part. There's still some shear force. But there's no one place where a large area of tension gets converted to shear forces acting on a single point.
And that's why rounded holes are good. | {
"domain": "physics.stackexchange",
"id": 44564,
"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": "material-science, stress-strain, metals",
"url": null
} |
algorithm, c, image
return tempSad;
}
The arrays are from the wikipedia link above, so I can duplicate the result and see if it works. It seems to work but I want your opinion if you see something wrong or if it doesn't work. A more generic SAD function
Currently, your SAD function is hardcoded to work on a 3x3 area. Also, because it takes 3x3 arrays as inputs, you need to use a temporary array tempImage in order to copy a 3x3 area of the original image so that you can pass it to your function.
If you modified your function a bit, you could pass the original image into the function without making a copy. Here is how I would rewrite your function:
/**
* Calculates sum of absolute differences between a pattern and an image.
* The area of the image to be matched is at (imgX, imgY).
*/
int calSad(const int *pattern, int patWidth, int patHeight,
const int *img, int imgX, int imgY, int imgWidth)
{
int ret = 0;
int x = 0;
int y = 0; | {
"domain": "codereview.stackexchange",
"id": 22600,
"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": "algorithm, c, image",
"url": null
} |
java, unit-testing, collections, null, junit
/**
* Returns the hash code value for this map. The hash code of a map is
* defined to be the sum of the hash codes of each entry in the map's
* entrySet() view. This ensures that m1.equals(m2) implies that
* m1.hashCode()==m2.hashCode() for any two maps m1 and m2, as required by
* the general contract of Object.hashCode().
*/
@Override
public int hashCode() {
int sum = 0;
for (Map.Entry<T, Integer> e : this) {
if (e == null || e.getValue() == 0) {
break;
}
sum += e.hashCode();
}
return sum;
}
public void increment(T key, int delta) {
Integer prev = this.c.put(key, delta);
if (prev != null) {
this.c.put(key, prev + delta);
}
}
/**
* Increments the count of the specified key by 1.
*/
public void increment(T key) {
this.increment(key, 1);
} | {
"domain": "codereview.stackexchange",
"id": 6653,
"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, unit-testing, collections, null, junit",
"url": null
} |
the given series is therefore convergent using the limit comparison test AG
[2 marks]
## Examiners report
Most candidates were able to answer part (a) and many gained a fully correct answer. A number of candidates ignored the factor 2 in the numerator and this led to candidates being penalised. In some cases candidates were not able to identify an appropriate series to compare with. Most candidates used the Comparison test rather than the Limit comparison test.
## Question
Show that the series $$\sum\limits_{n = 2}^\infty {\frac{1}{{{n^2}\ln n}}}$$ converges.
[3]
a.
(i) Show that $$\ln (n) + \ln \left( {1 + \frac{1}{n}} \right) = \ln (n + 1)$$.
(ii) Using this result, show that an application of the ratio test fails to determine whether or not $$\sum\limits_{n = 2}^\infty {\frac{1}{{n\ln n}}}$$ converges.
[6]
b.
(i) State why the integral test can be used to determine the convergence or divergence of $$\sum\limits_{n = 2}^\infty {\frac{1}{{n\ln n}}}$$. | {
"domain": "iitianacademy.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9923043510009422,
"lm_q1q2_score": 0.8203497102801243,
"lm_q2_score": 0.8267117940706735,
"openwebmath_perplexity": 1986.0596788137618,
"openwebmath_score": 0.9119042158126831,
"tags": null,
"url": "https://www.iitianacademy.com/ib-dp-maths-topic-9-2-tests-for-convergence-comparison-test-limit-comparison-test-ratio-test-integral-test-hl-paper-3/"
} |
photons, glass
The answer to your question is on the quantum level elastic scattering. This is the only way the photons: | {
"domain": "physics.stackexchange",
"id": 56031,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "photons, glass",
"url": null
} |
classical-mechanics, hamiltonian-formalism
A great example would be a simple system like the harmonic oscillator or even a free particle! :) This equation reduces to the Hamiltonian-Jacobi equations in certain specific examples.
The Hamiltonian formalism in symplectic geometry, which you've written above, is dependent on the fact that for a symplectic manifold $(M, \omega)$ and a smooth function $H : M \rightarrow \mathbb{R}$, there exists a unique vector field $X_H$ satisfying
$$\iota_{X_H} \omega = d H$$, | {
"domain": "physics.stackexchange",
"id": 24525,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "classical-mechanics, hamiltonian-formalism",
"url": null
} |
mass, theory-of-everything
Title: How did these guys get the masses from Heim Theory? How did these guys get the masses from Heim Theory?
I won't even bother to ask about validity as I read the other post on this. So I know how we all feel about that. I hadn't even heard of it till today when I stumbled across it searching for something else. But I'd like to know: How did they get the subatomic particle masses to come out of their equations? Did they just "coach" them in the right directions- meaning are the equations just so vague that you could get any number out of them? I tried to read the papers but just don't get it.
In discussions concerning it's invalidity I've found a lot of arguing over the true accuracy of the mass values. While I've seen tables to compare theoretical and actual values- the sources for such are all a group working on the theory. Has anyone seen the calculations and can answer? | {
"domain": "physics.stackexchange",
"id": 582,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "mass, theory-of-everything",
"url": null
} |
metal, transition-metals, metallurgy
The units of $C_a$, $C_b$, and $C_o$ are $\% C\ by\ mass$. That means when you calculate $W_a$ initially, you are calculating the fraction of pearlite and not the percent of pearlite. All of the $\% C\ by\ mass$ units cancel:
$$W_a=\frac{0.76\ \%C-0.4\ \%C}{0.76\ \%C - 0.022\ \%C}=\frac{{\%C}(0.76-0.022)}{{\%C}(0.76-0.022)}=0.487805\implies48.7805\%$$ | {
"domain": "chemistry.stackexchange",
"id": 700,
"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": "metal, transition-metals, metallurgy",
"url": null
} |
audio, tone-generation
Knowing these important aspects of many percussive sounds, you can try to modify - e.g. - a sine wave by changing the frequency and amplitude over time, adding (filtered) noise and so on. Some experimenting will yield sounds similar to that of the classic TR-808. This machine may also be a nice source of inspiration on how to approach drum modelling using basic synthesis elements.
Another - somewhat more involved - approach is called physical modelling. This method starts from trying to emulate and - as the name says - physically model the elements that are involved in actually generating a sound. In the case of drum synthesis this comprises, for example:
the drum head
the stick that is used to hit the head
the drum shell. | {
"domain": "dsp.stackexchange",
"id": 3488,
"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": "audio, tone-generation",
"url": null
} |
java
public void setSetOfProductTypes(HashSet<String> setOfProductTypes) {
this.setOfProductTypes = setOfProductTypes;
}
}
import java.util.ArrayList;
import java.util.HashSet;
public class Catalog {
private ArrayList<Product> allFruitsandVegetables;
private HashSet<String> setofPrimaryTypes;
private HashSet<String> setOfProductTypes;
public Catalog() {
this.allFruitsandVegetables = new ArrayList<>();
this.setofPrimaryTypes = new HashSet<>();
this.setOfProductTypes = new HashSet<>();
}
public ArrayList<Product> getAllFruitsandVegetables() {
return allFruitsandVegetables;
}
public void setAllFruitsandVegetables(Product product) {
this.allFruitsandVegetables.add(product);
}
public HashSet<String> getSetofPrimaryTypes() {
return setofPrimaryTypes;
}
public void setSetofPrimaryTypes(HashSet<String> setofPrimaryTypes) {
this.setofPrimaryTypes = setofPrimaryTypes;
} | {
"domain": "codereview.stackexchange",
"id": 45155,
"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
} |
Other cases are left as exercise to OP, the presentation is becoming a bit tedious here.
We do not answer the specific question, but instead look at two related series, $$1+\frac{1}{2}+\frac{1}{2}+\frac{1}{4}+\frac{1}{4}+\frac{1}{4}+\frac{1}{4}+\frac{1}{8}+\frac{1}{8}+\frac{1}{8}+\frac{1}{8}+\frac{1}{8}+\frac{1}{8}+\frac{1}{8}+\frac{1}{8}+\frac{1}{16}+\cdots\tag{1}$$ and $$1-\frac{1}{2}+\frac{1}{2}-\frac{1}{4}+\frac{1}{4}-\frac{1}{4}+\frac{1}{4}-\frac{1}{8}+\frac{1}{8}-\frac{1}{8}+\frac{1}{8}-\frac{1}{8}+\frac{1}{8}-\frac{1}{8}+\frac{1}{8}-\frac{1}{16}+\cdots\tag{2}$$
Series (1) diverges. For the sum of the first $3$ terms is $2$, the sum of the first $7$ is $3$, the sum of the first $15$ is $4$, the sum of the first $31$ is $5$, and so on. The partial sums "blow up," albeit with a great deal of reluctance. It takes an awful lot of terms to get a sum of $100$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9793540704659681,
"lm_q1q2_score": 0.8284771617504657,
"lm_q2_score": 0.8459424295406088,
"openwebmath_perplexity": 258.2424459872029,
"openwebmath_score": 0.8625534176826477,
"tags": null,
"url": "https://math.stackexchange.com/questions/880980/why-these-two-series-are-convergent-or-divergent"
} |
electromagnetism, magnetic-fields, electric-fields, electricity, field-theory
$\mathbf{H}$ plays a role in magnetostatics analogous to $\mathbf{D}$ in electrostatics: Just as $\mathbf{D}$ allowed us to write Gauss's law in terms of the free charge alone, $\mathbf{H}$ permits us to express Ampere's law in terms of the free current alone-and free current is what we control directly. Bound current, like bound charge, comes along for the ride - the material gets magnetized, and this results in bound currents; we cannot turn them on or off independently, as we can free currents. | {
"domain": "physics.stackexchange",
"id": 100097,
"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, magnetic-fields, electric-fields, electricity, field-theory",
"url": null
} |
python, performance, python-3.x, reinventing-the-wheel, serialization
Example
import json
var = {1: {1: {1: {1: {1: {1: 0}, 2: 0}, 2: {1: 0}, 3: 0},
2: {1: {1: 0}, 2: 0},
3: {1: 0}},
2: {1: {1: {1: 0}, 2: 0}, 2: {1: 0}, 3: 0},
3: {1: {1: 0}, 2: 0}},
2: {1: {1: {1: {1: 0}, 2: 0}, 2: {1: 0}, 3: 0},
2: {1: {1: 0}, 2: 0},
3: {1: 0}},
3: {1: {1: {1: 0}, 2: 0}, 2: {1: 0}, 3: 0}}
dumped = json.dumps(var, indent=4)
repred = represent(var)
print('dumped:')
print(dumped)
print('repred:')
print(repred)
print(f'{(eval(dumped) == var)=}')
print(f'{(eval(repred) == var)=}') | {
"domain": "codereview.stackexchange",
"id": 42243,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, performance, python-3.x, reinventing-the-wheel, serialization",
"url": null
} |
ros-kinetic
Originally posted by Eman.m with karma: 65 on 2021-05-01
This answer was ACCEPTED on the original site
Post score: 0 | {
"domain": "robotics.stackexchange",
"id": 36392,
"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-kinetic",
"url": null
} |
r
#DECILE 3 | {
"domain": "codereview.stackexchange",
"id": 33177,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "r",
"url": null
} |
search-algorithms, heuristics
Finally, regarding your question: even if there are only 3 stones, problems can be really difficult to solve (or, at least, to solve optimally if that's what you are aiming for). See Appendix B, page 158, The 61 Kids Problems and you'll see lots of challenging problems. Many of those contain only 3 stones.
Hope this helps, | {
"domain": "cs.stackexchange",
"id": 4037,
"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": "search-algorithms, heuristics",
"url": null
} |
# Find all factorial numbers less than or equal to n in C++
C++Server Side ProgrammingProgramming
Here we will see how to print all factorial numbers less than or equal to n, a number N is said to be factorial number if it is a factorial of a positive number. So some factorial numbers are 1, 2, 6, 24, 120.
To print factorial numbers, we do not need to find the factorial directly. Starting from i = 1, print factorial*i. Initially factorial is 1. Let us see the code for better understanding.
## Example
Live Demo
#include <iostream>
using namespace std;
void getFactorialNumbers(int n) {
int fact = 1;
int i = 2;
while(fact <= n){
cout << fact << " ";
fact = fact * i;
i++;
}
}
int main() {
int n = 150;
getFactorialNumbers(n);
}
## Output
1 2 6 24 120
Published on 24-Oct-2019 13:08:48 | {
"domain": "tutorialspoint.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9787126444811032,
"lm_q1q2_score": 0.806911314348653,
"lm_q2_score": 0.8244619285331332,
"openwebmath_perplexity": 1458.2502388656792,
"openwebmath_score": 0.24268069863319397,
"tags": null,
"url": "https://www.tutorialspoint.com/find-all-factorial-numbers-less-than-or-equal-to-n-in-cplusplus"
} |
# Why is my regression insignificant when I merge data that produced two significant regressions?
Sorry for the confusing title, I think this is a general statistics question, but I'm working in R. I have a combined dataset of two samples from different countries (n=240 and n=1,010), and when I run a linear regression between the same three variables in each dataset, both datasets produce a significant result, with almost identical coefficients. However, when I merge the datasets and run the same regression on the combined dataset, it is no longer significant. Can anyone explain this?
In case it matters, the regression has the form lm(a~b*c). | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9489172659321807,
"lm_q1q2_score": 0.8403909981912566,
"lm_q2_score": 0.8856314753275019,
"openwebmath_perplexity": 755.1924112467557,
"openwebmath_score": 0.4733723998069763,
"tags": null,
"url": "https://stats.stackexchange.com/questions/298717/why-is-my-regression-insignificant-when-i-merge-data-that-produced-two-significa/298718"
} |
c++, algorithm, c++14, math-expression-eval
case token_t::prefix:
case token_t::name:
case token_t::left_brace:
{
operations.push(tok);
break;
}
case token_t::right_brace:
{
while (not operations.empty() &&
not operations.top().is_left_brace())
{
output.push(operations.top());
operations.pop();
}
operations.pop();
while (not operations.empty()
&& (operations.top().is_prefix() || operations.top().is_name()))
{
output.push(operations.top());
operations.pop();
}
break;
} | {
"domain": "codereview.stackexchange",
"id": 13719,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, algorithm, c++14, math-expression-eval",
"url": null
} |
Is there something that I'm doing very wrong here? Any help you can provide would be great! Thanks in advance!
• What do you mean by "proper"? It sure is a Fourier series (the general form is $$a_0/2+\sum_{n=1}^{\infty}\Big(a_n\sin\frac{n\pi x}{L}+b_n\cos\frac{n\pi x}{L}\Big) ~).$$ – Nikolaos Skout Mar 23 '16 at 16:00
• Wait, so we can count ${\frac9 \pi} {\frac 1 {2n - 1}} {\sin\left(\frac{2n - 1} 2 \pi \right)}$ as $a_n$, and $-{\frac9 \pi} {\frac 1 {2n - 1}} {\cos\left(\frac{2n - 1} 2 \pi \right)}$ as $b_n$? Huh...did not know that... Always thought the coefficients weren't supposed to contain functions... – Arjuna Mar 23 '16 at 16:09
• basically, note that the expressions $\sin(\ldots),~ \cos(\ldots)$ you noted above are not functions but ... numbers (there is no $x$)! – Nikolaos Skout Mar 23 '16 at 16:10
• Right. That just kicked me in the head just now. Thanks a lot for your help! – Arjuna Mar 23 '16 at 16:13
• you're welcome ;-) ! – Nikolaos Skout Mar 23 '16 at 16:14 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9833429619433692,
"lm_q1q2_score": 0.8194438798848196,
"lm_q2_score": 0.8333245994514082,
"openwebmath_perplexity": 238.47916035968618,
"openwebmath_score": 0.8470425605773926,
"tags": null,
"url": "https://math.stackexchange.com/questions/1710385/time-shifted-trigonometric-fourier-series-coefficients"
} |
waves, energy-conservation, everyday-life, dissipation, oceanography
A wave with a height of 2 m and a wavelength of 14 m breaking along 2 km of coastline (surface area = 32,000 m2) has approximately 45 kWh of energy.
How it will be dissipated will depend on the approach to the coast.
A wave as seen above will start losing energy by transferring it to kinetic and rotational energy at the shallow bottom including sand transfers, which finally will become heat (extra kinetic energy). As there will be conservation of momentum also, part of it will be absorbed by the impact on the earth, as vibrations which will also end up as heat, and also any dissipation in air as you observe. In the picture above sand will be continually deposited on the shore changing the shore line.
A wave hitting a rocky precipice will be transferring vibrations (finally heat) but also will erode part of the rock.
In the end all energy will end up as a higher temperature in the region and ground than if the ocean were calm. | {
"domain": "physics.stackexchange",
"id": 44931,
"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, energy-conservation, everyday-life, dissipation, oceanography",
"url": null
} |
deep-learning, nlp, sentiment-analysis
Title: "Rare words" on vocabulary I am trying to create a sentiment analysis model and I have a question.
After I preprocessed my tweets and created my vocabulary I've noticed that I have words that appear less than 5 times in my dataset (Also there are many of them that appear 1 time). Many of them are real words and not gibberish. My thinking is that if I keep those words then they will get wrong "sentimental" weights and gonna make my model worse.
Is my thinking right or am I missing something?
My vocab size is around 40000 words and those that are "rare" are around 10k.Should I "sacrifice" them? Instead of dropping rare words or incorporating them risking their scarcity in the training data leads to poor predictions, you can opt for a third alternative: using a subword vocabulary. | {
"domain": "datascience.stackexchange",
"id": 9014,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "deep-learning, nlp, sentiment-analysis",
"url": null
} |
objective-c, ios
The code for the date formatter doesn't belong in here. I'd make a case for an NSDateFormatter extension.
+ (NSDateFormatter *)anniversaryDateFormatter {
static NSDateFormatter *formatter;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
formatter = [[NSDateFormatter alloc] init];
formatter.dateStyle = NSDateFormatterLongStyle;
});
return formatter;
}
And now when we need it, we're just grabbing it via a simple call:
[NSDateFormatter anniversaryDateFormatter];
As for this big if-else block you have, well... it simply shouldn't exist at all.
We should have proper model objects. Something along the lines of this:
@interface Anniversary : NSObject
@property AnniversaryType anniversaryType;
@property NSDate *anniversaryDate;
@property (readonly) NSString *dateOfAnniversaryDescription;
@property (readonly) NSString *daysAgoDescription;
@end | {
"domain": "codereview.stackexchange",
"id": 17832,
"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": "objective-c, ios",
"url": null
} |
ros, topic
Originally posted by NEngelhard with karma: 3519 on 2015-09-21
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by dornhege on 2015-09-21:
Correct information cited, but the first character is only alpha, not alphanumeric. So this is NOT a valid topic name.
Comment by NEngelhard on 2015-09-21:
The first character is a forward slash, which is a valid first character. (And I can create a publisher for this topic without problems or warnings.)
Comment by dornhege on 2015-09-21:
Interesting. It seems that a topic like /_ would be valid.
Comment by tfoote on 2018-06-20:
The intent is that each token must start with an alpha. The ~ is a special replacement and the / is a joiner. I don't know how it's exactly enforced in the different implementations. In the spirit of things starting with a number for a token is not valid. | {
"domain": "robotics.stackexchange",
"id": 22674,
"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, topic",
"url": null
} |
php, object-oriented
Additionally, the getters are arguably unnecessary and could be replaced with a single __get magic method if you're using an advanced enough version of PHP. I am not familiar enough with the language to say if that is the more idiomatic way. | {
"domain": "codereview.stackexchange",
"id": 24367,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "php, object-oriented",
"url": null
} |
java, beginner, performance, fizzbuzz
By the way, opening braces on a separate line can be brutal when it comes to try-catch-finally blocks.
try
{
…
}
catch (Exception e)
{
…
}
finally
{
…
}
Redundancy: The multiple-of-15 case is handled twice; it should need to be handled once.
Repetition of System.out.println(): I suggest using a ternary conditional expression instead.
for (int num = 1; num <= 100; num++) {
System.out.println((num % 15 == 0) ? "FizzBuzz" :
(num % 3 == 0) ? "Fizz" :
(num % 5 == 0) ? "Buzz" :
num);
} | {
"domain": "codereview.stackexchange",
"id": 5240,
"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, performance, fizzbuzz",
"url": null
} |
c, stack, pointers
// pushing
BigStruct* data = malloc(sizeof(BigStruct));
// initialize *data
stack_push(&stack, data);
// popping
BigStruct* data = stack_pop(&stack);
// use *data
free(data);
Some small issues:
It is not common to cast the result of malloc or realloc in C.
If the stack is initialized to capacity 0, then the stack will never grow and elements will be stored at invalid positions. A solution is to adjust the capacity to 1 automatically. | {
"domain": "codereview.stackexchange",
"id": 37554,
"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, stack, pointers",
"url": null
} |
algorithms, descriptive-statistics, genetic-algorithms
I'm not sure if that's exactly what you had in mind or not, because it feels like you might not know the distribution you want to sample from here, but there are enough parallels that it's probably worth some time to dive in a little deeper. | {
"domain": "datascience.stackexchange",
"id": 11351,
"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, descriptive-statistics, genetic-algorithms",
"url": null
} |
experimental-physics, home-experiment
When you inflate a balloon by mouth, the air is warm: this makes the air inside the inflated balloon slightly lighter than the air it displaced
The air inside the balloon has 100% relative humidity at 37C, and condensation will quickly form on the inside of the balloon as the air inside cools down.
The air inside the balloon contains carbon dioxide, which has higher density than room air (molecular mass of 12+16+16 = 44 amu, vs oxygen at 32 amu and nitrogen at 28 amu - ignoring small isotopic effects, and ignoring Argon).
The pressure inside the balloon is larger than outside - this increases the density
So how large are each of these effects? | {
"domain": "physics.stackexchange",
"id": 18559,
"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": "experimental-physics, home-experiment",
"url": null
} |
# Packing of smaller spheres onto a bigger one
I want to estimate the maximum number of smaller spheres (of known constant radius, r) that can closely pack around a bigger sphere (of radius R, providing R >= r). It would be much appreciated if someone shows me how to get the number (and a 3D plot) for few different radii to generalize (i.e. for both r and R values). | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9572777975782054,
"lm_q1q2_score": 0.8282597958639311,
"lm_q2_score": 0.865224073888819,
"openwebmath_perplexity": 1764.3662866110817,
"openwebmath_score": 0.7090698480606079,
"tags": null,
"url": "https://mathematica.stackexchange.com/questions/101350/packing-of-smaller-spheres-onto-a-bigger-one"
} |
Fractional exponents
What about rational powers? If we want to have 2 = 2^1 =
2^(1/2 + 1/2) = (2^1/2)(2^1/2), then (2^1/2) must be a number which gives 2 when multiplied by itself, i.e. we must have (2^1/2) = sqrt(2). Similarly, we must have 2^1/3 = cuberoot(2), and 2^1/n = nth root(2). For 2^m/n we must have 2^m/n = 2^(1/n + 1/n +....+1/n) (m terms) = (2^1/n)(2^1/n)(.........)(2^1/n) (m factors) = [nth root(2)]^m = nth root(2^m).
As before than we must have 2^-n/m = (1/2)^n/m = 1/[m^th root(2^n)]. Thus we are forced in our definition of every rational power of 2, just by the definition for positive integer powers, plus the basic law 2^(x+y) = 2^x 2^y. This completely determines the exponential function on all rational numbers. | {
"domain": "physicsforums.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9822877038891777,
"lm_q1q2_score": 0.8164215919756966,
"lm_q2_score": 0.8311430436757312,
"openwebmath_perplexity": 626.8308290929708,
"openwebmath_score": 0.8821554183959961,
"tags": null,
"url": "https://www.physicsforums.com/threads/logarithm-question.209250/"
} |
ros, ros-kinetic
Originally posted by banseok Kim on ROS Answers with karma: 1 on 2019-03-19
Post score: 0
There's nothing set in stone anywhere where you need to place any particular sensor. You can place it where ever you like. If you're trying to integrate some other stuff into your IMU (i.e. fuse orientation) then creating a IMU link in TF is probably necessary so another node can transform that data with respect to your base.
However you'd need to do that either way to set things up correctly so there's no additional overhead to placing your IMU in any given location. If you use an IMU that produces an orientation vector out, rigid body transformations tell you the orientation of a part is the orientation of the whole, so it actually doesn't matter at all where it is. If you're integrating angular velocities it may depending on the type of algorithm you're using.
tl;dr: no, you can put it anywhere. Just define the appropriate frame. | {
"domain": "robotics.stackexchange",
"id": 32680,
"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, ros-kinetic",
"url": null
} |
quantum-field-theory, field-theory, path-integral, integration, complex-numbers
Title: Complex Gaussian integral with different source terms Do the source terms multiplying a complex field and its conjugate need to be conjugates for the Gaussian integral to be convergent and the identity to hold? E.g. is
$$\int D({\phi,\psi,b}) e^{-b^\dagger A b +f(\phi, \phi^\dagger,\psi, \psi^\dagger )b +b^\dagger g(\phi, \phi^\dagger,\psi, \psi^\dagger )} = \int D(\phi,\psi) \det(A^{-1}) e^{f(...) A^{-1} g(...)} $$
valid when $f \ne g^* $?
If I change to real and imaginary coordinates in the $b$ it seems fine, but I'm worried that I'm screwing up the measure in $D(...)$ without realizing it.
Edit:
Let's say $A$ is a $c$-number. To do the integral I can write $b = x +iy$ etc. Then the integral is
$$\int D(...) e^{- Ax^2 - A y^2 +x(f + g) + i y(f-g)} = \frac{\pi}{A}\int D(...) e^{(4A)^{-1}((f+g)^2 - (f-g)^2)}$$ $$=\frac{\pi}{A}\int D(...) e^{A^{-1} fg}.$$ | {
"domain": "physics.stackexchange",
"id": 84131,
"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, path-integral, integration, complex-numbers",
"url": null
} |
python, sympy, latex
G_alt = Einstein_alt.tensor_zeros()
for i in range(n):
for j in range(n):
for k in range(n):
G_alt[i, j] += g_inv[i, k] * G[k, j]
G_alt[i, j] = simplify(G_alt[i, j])
assign(Einstein_alt, G_alt) | {
"domain": "codereview.stackexchange",
"id": 42004,
"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, sympy, latex",
"url": null
} |
quantum-mechanics, thermodynamics, statistical-mechanics, harmonic-oscillator, phase-space
Title: How to find the probability of finding quantum particles within a certain region How to evaluate the probability of finding a quantum particle within a certain radius $R$ from the origin ? I have not been provided with any radial distribution functions, and I'm not sure how to construct one, especially when statistical mechanics is involved.
I've been given $n$ number particles that obey the hamiltonian of the $2$ dimensional quantum harmonic oscillators and I need to find the probability of finding a particle within a distance $R$ from the nucleus. Moreover, the system is connected to a heat bath at temperature $T$.
The hamiltonian is : $$\frac{\hat{p_x}^2}{2m}+\frac{\hat{p_y}^2}{2m}+\frac{1}{2}m\omega^2(\hat{x}^2+\hat{y}^2)$$
I thought of integrating this over the phase space, between $0$ and $R$, however, I have no idea how to proceed with this. | {
"domain": "physics.stackexchange",
"id": 84504,
"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, thermodynamics, statistical-mechanics, harmonic-oscillator, phase-space",
"url": null
} |
(Refer to second image for better understanding) 3 identical groups of 5P3/3
Going further. For a set $$Z$$ with $$n\{Z\}=N$$, where all numbers are unique, if we want all the subsets $$X$$ with $$n\{X\}=k$$, meaning that ordering of numbers in subsets is not important for us, we'll have $$p = \text{ } ^NP_k \text{} \text{ ,where } p \text{ is the Total permutations }$$ Now these permutations $$p$$ will have $$k!$$ groups, each group representing a way of permutation. Each group contains our desired combinations ordered in the particular way which the given group represents. The differentiating factor between the members of a group with members of another group is the order/permutation which makes no difference for us, meaning $$\frac{p}{k!}=c \text{} \text{ , where } c \text{ is the Total combinations}$$
This is nothing but $$C(n,k)=\frac{N!}{(N-k)!\times(k!)}=\frac{P(n,k)}{k!}$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9820137900379085,
"lm_q1q2_score": 0.8266843944086281,
"lm_q2_score": 0.8418256472515684,
"openwebmath_perplexity": 167.3886790718227,
"openwebmath_score": 0.7704142332077026,
"tags": null,
"url": "https://math.stackexchange.com/questions/3120653/why-do-we-divide-permutations-to-get-to-combinations/3120718"
} |
gravity, earth
The reason is that any body creates a gravitational field around it, so the massive the object, the stronger the gravitational force it exerts. Also since the gravitational force is inversely proportional to the square of the distance, then the closer it is the strongest is the gravitation force. E=MC2 | {
"domain": "physics.stackexchange",
"id": 12486,
"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": "gravity, earth",
"url": null
} |
(1/2):(√3/2):(1) --triangle 1: half of tetrahedral face, angles of 30, 60 & 90 degrees.
( ):( 1/2):( ) --triangle 2: has unknown base & hypotenuse, but is proportionate to triangle 1.
We really only need to compute the hypotenuse of triangle 2, because that is the desired distance from the corner to the center of the tetrahedron's base:
Multiply triangle-1-hypotenuse by triangle-2-perpendicular; divide by triangle-1-perpendicular.
[(1/2)(1)]/(√3/2) = (1/2)(2/√3) = 1/√3, as the 1st answer also computes in a more complicated way.
For the sake of completeness, since in any 30-60-90-degree triangle the base is simply half the length of the hypotenuse, the second unknown is 1/(2√3) or √3/6 (although it could also have been figured by using ratios, as above). The reader is invited to verify that the square of (√3/6) plus the square of 1/2 equals the square of (1/√3).
- | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9790357616286122,
"lm_q1q2_score": 0.8623318411417867,
"lm_q2_score": 0.8807970811069351,
"openwebmath_perplexity": 425.8305622993112,
"openwebmath_score": 0.8091424107551575,
"tags": null,
"url": "http://math.stackexchange.com/questions/11085/height-of-a-tetrahedron"
} |
c, memory-management, posix, gcc
* goto err;
*
* // `buf` has been succesfully allocated here
* free(buf);
* err:
* // No memory leaks
*/ | {
"domain": "codereview.stackexchange",
"id": 36936,
"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, memory-management, posix, gcc",
"url": null
} |
c#, beginner, programming-challenge, chess
var count = 1;
var bishopcoordinateX = ' ';
var bishopcoordinateX1 = ' ';
while (count < 8)
{
count++;
var value = Char.GetNumericValue(bishop2[1]);
if (b2.Item1((bishop2[0] - 0)) && b2.Item2((int)value))
{
bishopcoordinateX = Convert.ToChar(operation2.Item1(bishop2[0]));
value = operation2.Item2((int)value);
bishop2 = bishopcoordinateX + "" + value;
}
var value1 = Char.GetNumericValue(bishop1[1]);
if (b1.Item1((bishop1[0] - 0)) && b1.Item2((int)value1))
{
bishopcoordinateX1 = Convert.ToChar(operation1.Item1(bishop1[0]));
value1 = operation1.Item2((int)value1);
bishop1 = bishopcoordinateX1 + "" + value1;
}
}
return new string[] { bishop1, bishop2 }.OrderBy(c => c).ToArray();
} | {
"domain": "codereview.stackexchange",
"id": 25192,
"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#, beginner, programming-challenge, chess",
"url": null
} |
c#, hash-map
Full list here.
This is how I identify them:
public Dictionary<int, Tuple<string, string, bool, string>> gs1AiDict { get; private set; }
var aiDataOut = new Tuple<string, string, bool, string>("","",false,""); | {
"domain": "codereview.stackexchange",
"id": 10642,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c#, hash-map",
"url": null
} |
c#, entity-framework, lambda
The second part is OK. Getting the most recent item from a collection always requires some ordering that defines "most recent".
Note that using the improved form, EF will translate this into one query, because logList isn't materialized yet. It is an expression tree1 that can be merged with the second expression. If you want, you can create one statement in LINQ as well:
return dbContext.Jobs
.Where(j => j.Guid == jobGuid)
.SelectMany(j => j.Quotes)
.SelectMany(q => dbContext.EmailLogs
.Where(e => q.EmailLogListGuid == e.EmailLogListGuid))
.OrderByDescending(e => e.CreatedDate)
.Select(e => e.CreatedDate)
.FirstOrDefault(); | {
"domain": "codereview.stackexchange",
"id": 18481,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c#, entity-framework, lambda",
"url": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.