text
stringlengths
49
10.4k
source
dict
c++, c++11, binary-search-tree Unit tests For the unit tests, ideally you would only need to use public functions to test the functionality of your class. With the above changes you can already test if the search functionality and traversal work without needing access to private functions. However, if you really want to be able to access private members in the tests, then one way is to make a test class or function and declare that as a friend inside ShelterBST. That way, the test class has access to the private internals of any ShelterBST object. There are lots of unit test libraries for C++. You would typically use one of those that fits your needs. The more powerful libraries make both writing tests and running them easier. What about the move constructor? I see you wrote a copy constructor and copy assignment operator, but what about the move constructor and move assignment operator? It would be nice to implement those as well. Use '\n' instead of std::endl Prefer to use '\n' instead of std::endl; the latter is equivalent to the former, but also forces the output to be flushed, which is usually unnecessary and negatively impacts performance. Avoid obsolete and non-standard functions usleep() is neither C nor C++. It's a POSIX function which has been deprecated in 2001. If you are writing in C, then use the POSIX nanosleep() or clock_nanosleep() functions. However, in C++11 the standard way to sleep is to use std::this_thread::sleep_for().
{ "domain": "codereview.stackexchange", "id": 44746, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c++, c++11, binary-search-tree", "url": null }
\small\begin{align}z(8m)&=(-1)^{c(8m)}+S(m) \\\\z(8m+1)&=(-1)^{c(8m)}-(-1)^{c(8m+1)}+S(m) \\\\z(8m+2)&=(-1)^{c(8m)}-(-1)^{c(8m+1)}+(-1)^{c(8m+2)}+S(m) \\\\z(8m+3)&=(-1)^{c(8m)}-(-1)^{c(8m+1)}+2(-1)^{c(8m+2)}+S(m) \\\\z(8m+4)&=(-1)^{c(8m)}-(-1)^{c(8m+1)}+2(-1)^{c(8m+2)}-(-1)^{c(8m+4)}+S(m) \\\\z(8m+5)&=(-1)^{c(8m)}-(-1)^{c(8m+1)}+2(-1)^{c(8m+2)}-(-1)^{c(8m+4)}+(-1)^{c(8m+5)}+S(m) \\\\z(8m+6)&=(-1)^{c(8m)}-(-1)^{c(8m+1)}+2(-1)^{c(8m+2)}-(-1)^{c(8m+4)}+S(m)
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9840936101542134, "lm_q1q2_score": 0.8532443645209306, "lm_q2_score": 0.8670357735451835, "openwebmath_perplexity": 582.2596203755722, "openwebmath_score": 0.9025372266769409, "tags": null, "url": "https://math.stackexchange.com/questions/3587292/interesting-property-related-to-the-sums-of-the-remainders-of-integers" }
performance, sql, stackexchange But this not only looks abominable, it's SLOW. How can the readability be improved? Any way to boost the performance so that it can be run on larger SE sites? Any suggestion for a version 2? So it seems that dynamic SQL in general and EXECUTE() in particular, as pointed out by Phrancis, is slow. As I also don't want to be dealing with the composition of the query string, I set out to rewrite the query in static SQL, now with CTE as is available on SEDE. DECLARE @Question tinyint = 1 DECLARE @Answer tinyint = 2 DECLARE @UpMod tinyint = 2 DECLARE @DownMod tinyint = 3 DECLARE @z numeric(19, 9) = 1.96 DECLARE @zz numeric(19, 9) = SQUARE(@z) ; WITH TotalUpDownVotesByTags_VIEW AS ( SELECT Tags.TagName , PostTypes.Name AS PostType , COUNT(DISTINCT Posts.Id) AS PostCount , CAST(SUM(CASE WHEN Votes.VoteTypeId = @UpMod THEN 1 ELSE 0 END) AS numeric(19, 9)) AS PostUpvotes , CAST(SUM(CASE WHEN Votes.VoteTypeId = @DownMod THEN 1 ELSE 0 END) AS numeric(19, 9)) AS PostDownvotes FROM Posts INNER JOIN PostTypes ON Posts.PostTypeId = PostTypes.Id INNER JOIN PostTags ON (CASE WHEN Posts.PostTypeId = @Question THEN Posts.Id WHEN Posts.PostTypeId = @Answer THEN Posts.ParentId END) = PostTags.PostId INNER JOIN Tags ON PostTags.TagId = Tags.Id LEFT JOIN Votes ON Posts.Id = Votes.PostId GROUP BY Tags.TagName, PostTypes.Name )
{ "domain": "codereview.stackexchange", "id": 27913, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "performance, sql, stackexchange", "url": null }
Students, teachers, parents, and everyone can find solutions to their math problems instantly. From the definition, the derivative is the limit (already written on the answer sheet on the previous day). 508 Compilations. Limits Math Help. The most common types of derivatives are futures, options, forwards and swaps. The derivative of a power of x is given by d dx xp = pxp−1. It is equal to slope of the line connecting (x,f(x)) and (x+h,f(x+h)) as h Remember that the limit definition of the derivative goes like this: #f'(x)=lim_{h rightarrow0}{f(x+h)-f(x)}/{h}#. Word Originlate Middle English (in the adjective sense 'having the power to draw off', and in the noun sense 'a word derived from another'): from French dérivatif, -ive, from Latin derivativus, from derivare, from de. Limits and Continuity of Functions. Derived words are those composed of one root-morpheme and one more derivational morphemes (consignment, outgoing, publicity). Book by Peter Senge In learning organizations, life is a work of art. Practice Set #2 – Initital Value Problems Practice Set #3 – Integration by Substitution Practice Set #4 – Definite Integrals in Terms of Area Practice Set #5 – Properties of the Definite Integral. Cauchy and Heine Definitions of Limit. There is a precise mathematical definition of continuity that uses limits, and I talk about that at continuous functions page. Get math help in algebra, geometry, trig, calculus, or something else. The attitude of grammarians with regard to parts of speech and the basis of their classification varied a good deal at different times. Write derivatives of functions as limit expressions. An epsilon-delta definition is a mathematical definition in which a statement on a real function of one variable having, for example, the form "for all neighborhoods of there is a neighborhood of such that, whenever , then " is rephrased as "for all there is such that, whenever , then. Simple solutions to hard problems. 1000 What This Chapter Covers. ! Being able to find the derivatives of functions is a critical skill needed for solving real life problems involving tangent lines. To Introduce the Limit Definition of
{ "domain": "fidelylite.it", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9814534311480466, "lm_q1q2_score": 0.8282437458578029, "lm_q2_score": 0.8438951045175643, "openwebmath_perplexity": 822.6688501689522, "openwebmath_score": 0.7664351463317871, "tags": null, "url": "http://jogy.fidelylite.it/limit-definition-of-derivative-practice-problems-pdf.html" }
differential-geometry, tensor-calculus Title: Integral of the parallel transport equation The parallel transport of a vector $v_0^\alpha$ along the curve $\gamma$ is given by a vector field $v^\alpha$ which satisfies the equation $$ \frac{\mathrm d x^\mu}{\mathrm d \lambda}\frac{\partial v^\alpha}{\partial x^\mu} + v^\nu\Gamma^\alpha_{\mu\nu}\frac{\mathrm d x^\mu}{\mathrm d \lambda} = 0 $$ The first term of the LHS is, by chain rule, is $\mathrm d v^\alpha/\mathrm d \lambda$, so the equation becomes $$ \frac{\mathrm d v^\alpha}{\mathrm d \lambda} = - v^\nu\Gamma^\alpha_{\mu\nu}\frac{\mathrm d x^\mu}{\mathrm d \lambda} $$ Simplifying $\mathrm d\lambda$ from both sides, we get $$ \mathrm d v^\alpha = -v^\nu \Gamma_{\mu\nu}^\alpha\mathrm d x^\mu. $$ Now, if $\gamma$ is a closed curve, and we integrate this equation along the curve, we get $$ \oint \mathrm d v^\alpha = \oint -v^\nu\Gamma^\alpha_{\mu\nu} \mathrm d x^\mu $$ What is the result of this integral? I suppose it is zero if the space is flat and the the coordinates are Cartesian. But what in general? Could this integral be connected to the curvature of the space? The integral is known as the Holonomy. And yes, it is a measure the of the curvature. For a infinitesimal loops in the $\mu, \nu$ coordinate plane it is just a rotation matrix (a Lorentz transformation matrix in Minkowski signature) and is the definition of the curvature tensor ${R^a}_{b\mu\nu}$.
{ "domain": "physics.stackexchange", "id": 60525, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "differential-geometry, tensor-calculus", "url": null }
c, array, pointers, heap Title: Read characters from stdin into an resizeable array As first steps in C, I'm trying to write a program that reads from stdin into an array allocated on the free store, until an exclamation mark ! is entered. The array should be extended to prevent overflow. Here is what I've written: #include <stdio.h> #include <stdlib.h> char* increase_buffer_size(char *buff_ptr, size_t multiplier); //================================================================== int main () { // initial buffer size size_t buffer_size = 32; // allocate 32 bytes of heap memory char *buffer_pointer = (char*) malloc(buffer_size); // input loop variables char input_var; size_t counter = 0; char sentinel = '!'; // input loop printf("Type input\n>>"); while (input_var = getchar()) { // check termination condition if (input_var == sentinel) break; // check capacity and double it if maximum is reached if (counter == buffer_size - 1) buffer_pointer = increase_buffer_size(buffer_pointer, buffer_size *= 2); // populate buffer buffer_pointer[counter++] = input_var; } getchar(); // print input values printf("Buffer content: \n"); for (auto i = 0; i < counter; ++i) printf("%c %c", buffer_pointer[i], ' '); getchar(); } //==================================================================
{ "domain": "codereview.stackexchange", "id": 17196, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c, array, pointers, heap", "url": null }
at 21:33. The goal of this code golf is to draw a regular polygon (one with equal side lengths) given the number of sides and radius (distance from center to vertex). Polygons Maths Worksheets. Go to onmaths. Classify the polygon by the number of sides. Find the value of. If the measure of one interior angle of a regular polygon is 144°, find the number of sides. The word “deca” itself means “ten”. Do you really know everything about these 2-D polygons and. These are all polygons that you probably wanna know, and you should know also that if a polygon is a regular polygon, that means that the sides are all the same and the interior angles are the same. Updated: Aug 5, 2019. A clock is constructed using a regular polygon with 60 sides the polygon rotates every minute how has the polygon rotated after 7 minutes. Polygons and Regular Polygons on the GMAT. Created: Dec 2, 2016. For n=3 or n=4 , this means that the only valid input is the polygon folded zero times. If you use different regular polygons, you can tile a flat surface with triangles and 12-sides or with squares and 8-sides for example. While we are given two sides - the base and the height - we do not know the hypotenuse. If you have to deal with the angles of a polygon,. Use your knowledge of the sums of the interior and exterior angles of a polygon to answer the following questions. Polygons - Topic wise seperated questions from one hundred 11+ Papers with detailed answers. How many diagonals does an octagon have?. The problem concerns a polygon with twelve sides, so we will let n = 12. If the answer is a decimal, round to the nearest tenth. Regular Polygons A regular polygon has lines that are all the same length and it also has all the same angles. About this resource. #N#Regular Pentagon. Printable worksheets containing selections of these problems are available here: #N#Stage 3 ★★ #N#Stage 4 ★★ #N#Stage 4 ★★★ Central Distance. A regular three-sided polygon is called an equilateral triangle. Theorems include: opposite sides are congruent, opposite angles
{ "domain": "clandiw.it", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9861513873424044, "lm_q1q2_score": 0.8260200949028581, "lm_q2_score": 0.8376199694135332, "openwebmath_perplexity": 601.3711387596932, "openwebmath_score": 0.2936362624168396, "tags": null, "url": "http://clandiw.it/xpik/regular-polygon-questions.html" }
php, optimization, object-oriented, design-patterns, pdo public function single(){ $this->execute(); return $this->stmt->fetch(PDO::FETCH_ASSOC); } public function rowCount(){ return $this->stmt->rowCount(); } public function lastInsertId(){ return $this->dbh->lastInsertId(); } } I will apologize for the lack of formatting and using your code segments as straight example - but as I re-read your code I see my old self a whole lot and I don't consider myself any level near some of the coders here. However one important aspect to improvement is obviously trial and error and a lot of refactoring. So you asked about OOP going from procedural php within a single require I would assume your going into one right way which is using classes - however there is a lot of pitfalls in your code. The first would be that to effectively do OOP you should use SOLID design pattern. First there are plenty of ORM out there that does your PDO wrapper. One thing starters would like to do is to wrap a low level class (the PDO object) into a higher wrapper functional object - its not wrong to do so - but its been done over. In reality what you should do is not offer the user (ie you in this case) a simpler form of accessing data that you need while using the database. The database of your APP can change...what will you then? You will need to write a wrapper class again because your class is tightly coupled with PDO. Lets take a look at the database class protected $host = DB_HOST; protected $user = DB_USER; protected $pass = DB_PASS; protected $dbname = DB_NAME; protected $dbh; protected $error; protected $stmt;
{ "domain": "codereview.stackexchange", "id": 6964, "lm_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, optimization, object-oriented, design-patterns, pdo", "url": null }
seismology, earthquakes, seismic-hazards, drilling Title: Why aren't seismic stations installed very deep underground so as to pre-warn from earthquakes? The velocity of p-waves emanating from earthquakes is in the range of 5-8 km/s (link)--let's assume it is 5 km/s. The earthquake depth is up to hundreds of kms deep underground (link)--let's assume it is 100 km. That said, if a seismic station is installed at a depth of 50 km, and there are many of them in any given metropolitan area, then we can have a warning that is tens of seconds before the earthquake reaches the surface. While I realize that drilling down to 50 kn is no easy task, I would have imagined that saving human life is well worth the efforts. Why hasn't this been done so far? Is it that such a short notice (10s of seconds) isn't worth it? The simple answer is that you can't drill to 50 km depth. The deepest holes ever drilled were to a little more than 12 km, one is named the Kola Superdeep Borehole in Russia, which was a scientific drilling project. The very few others were oil exploration boreholes. Drilling that deep is extremely expensive and hard. If you go and ask anyone who ever worked on a drill rig, drilling the second 100 metres is always harder than the first 100 metres. And we're talking about kilometres here! There are several problems with drilling that deep. It's extremely hot down there, and the drilling equipment just breaks and stops working. You also need to pump cooling water in and pump out the stuff you're drilling and it gets harder with depth. This is simply not feasible. Now let's say that you did somehow manage to drill a hole to that depth. How would you put monitoring equipment inside? That equipment has to sustain heat and pressure and still keep working, while being able to transmit whatever it's reading back to the surface. This is not going to happen, not at 50 or 10 km depth. Another problem is that not all earthquakes are that deep. Some earthquakes originate near the surface, or just several km deep. Having a monitoring station down there isn't going to help. The 2011 Tohoku earthquake (the one that triggered the tsunami at Fukushima) was only 30 km deep. Same thing for the 2004 Indian Ocean earthquake.
{ "domain": "earthscience.stackexchange", "id": 692, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "seismology, earthquakes, seismic-hazards, drilling", "url": null }
safety Title: What is the meaning of the '2' on some Compressed Gas Hazard signs in the lab? The main chemistry prep room at my institution (and also at the ambulance station) is labelled with the standard green compressed gas sign. However, there is a small '2' included within the diamond. None of the chemistry technicians, tutors or ambulance staff seem to know what it is referring to and I can't find any reference of it on the internet. Would anyone here happen to know? The related products of this online provider show that other hazards have different numbers but some also have two (e.g. flammable). Is there a standard that is being referred to here? The 2 refers to DOT (Department of Transportation) hazard class 2. This reference describes the different DOT hazard classes. As summarized in the comments: Class 2 (compressed gas) is divided into three subclasses (2.1 - flammable, 2.2 - non-flammable, non-toxic and 2.3 - toxic). I imagine the diamonds for Class 2 don't contain the subclass number because there is a different diamond colour/symbology for each subclass (as opposed to for instance 5.1 (oxidising agent) and 5.2 (organic peroxide), which have the same symbol and colours).
{ "domain": "chemistry.stackexchange", "id": 14, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "safety", "url": null }
quantum-field-theory, vacuum, quantum-anomalies, cp-violation Title: How does the global $G^2G'$ anomaly make all the $\theta$-vacua associated to the gauge group $G$ physically equivalent? Consider a gauge group $G$ and suppose that there is a $\theta$-term associated to it. According to this answer, the existence of a global anomalous symmetry $G'$ which rotates the $\theta$-term, ensures that the different $\theta$-vacua are physically indistinguishable. In that regard, it is enough to check for whether the $G^2G'$ anomaly cancels. If it does not, we are saved from $\theta$-worries. I am trying to understand the mechanism.
{ "domain": "physics.stackexchange", "id": 52456, "lm_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, vacuum, quantum-anomalies, cp-violation", "url": null }
general-relativity, vacuum, stress-energy-momentum-tensor, cosmological-constant Note that a constant energy density that did not have the energy density equals to minus pressure would break Lorentz invariance (or, in other words, break special relativity). Answer with math Einstein's equations with a cosmological constant $\Lambda$ (setting $c=1$) are \begin{equation} G^\mu_{\ \ \nu} + \Lambda \delta^\mu_{\ \ \nu}= 8 \pi G_N T^\mu_{\ \ \nu} \end{equation} We can move the cosmological constant term to the right hand side as follows \begin{equation} G^\mu_{\ \ \nu} = 8 \pi G_N \left( T^\mu_{\ \ \nu} + [T_\Lambda]^\mu_{\ \ \nu} \right) \end{equation} where we have defined an effective stress-energy tensor \begin{equation} [T_\Lambda]^\mu_{\ \ \nu} \equiv - \frac{\Lambda}{8 \pi G_N} \delta^\mu_{\ \ \nu} \end{equation} The definition of energy density is $\rho = - T^0_{\ \ 0} = \frac{\Lambda}{8\pi G_N}$, and pressure is $p = T^1_{1} = T^2_2 = T^3_3 = -\frac{\Lambda}{8\pi G_N}$. From this you can see that by definition, a cosmological constant has $\rho = - p$. We were forced to set the cosmological constant energy density proportional to $\delta^\mu_\nu$ by symmetry. There are no other constant two-index tensors around for us to use. Any other constant tensor would break Lorentz invariance. Of course, generic dynamical matter fields will have stress-energy tensors that do not obey the relationship $p=-\rho$.
{ "domain": "physics.stackexchange", "id": 84001, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "general-relativity, vacuum, stress-energy-momentum-tensor, cosmological-constant", "url": null }
quantum-field-theory, operators, quantum-interpretations, observables Your first assertion, interpreting \eqref{3} as an (hermitean) operator associated with an observable field, is essentially correct, apart from the technical complication that $\phi(x)$ is a highly singular object kicking a normalized state vector $|\psi\rangle \in \mathcal{H}$ ($\mathcal{H}$ denotes the Fock space of the theory) out of your Hilbert space, i.e. $\phi(x) | \psi \rangle\notin \mathcal{H}$. This disease can be cured by considering smeared-out operators $$\phi_f= \int \! d^4x \, f(x) \phi(x), \tag{5} \label{5}$$ where $f$ is a a suitable function with compact support on some finite domain of space-time such that $\phi_f|\psi\rangle \in \mathcal{H}$. For this reason, $\phi(x)$ is referred to as an "operator-valued distribution".
{ "domain": "physics.stackexchange", "id": 100212, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "quantum-field-theory, operators, quantum-interpretations, observables", "url": null }
organic-chemistry, nomenclature Title: Use of repeated numerical prefixes for substituents on methane Take trichloromethane for example. Is its preferred IUPAC name: 1,1,1-trichloromethane or simply trichloromethane And which is that rule in IUPAC that governs this naming? Thank you! According to Nomenclature of Organic Chemistry: IUPAC Recommendations and Preferred Names 2013, P-14.3.4.2 The locant '1' is omitted in substituted mononuclear parent hydrides. For the compound $\ce{CHCl3}$ (chloroform), the parent hydride is methane, which is mononuclear. Hence the locant '1' should be omitted in the preferred IUPAC name (PIN); it is simply trichloromethane.
{ "domain": "chemistry.stackexchange", "id": 9410, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "organic-chemistry, nomenclature", "url": null }
machine-learning, classification, svm, optimization \text{s.t.} & \quad \alpha_i\geq 0, 0=1,...,n \\ & \quad \sum_{i=1}^n\alpha_iy^{(i)}=0 \\ & & \text{...equation (2)} \end{align}$$
{ "domain": "datascience.stackexchange", "id": 10065, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "machine-learning, classification, svm, optimization", "url": null }
robotic-arm, ros, ros-jade, catkin-workspace Originally posted by ahendrix with karma: 47576 on 2016-02-19 This answer was ACCEPTED on the original site Post score: 1 Original comments Comment by I.T on 2016-02-20: Thank you, using the --extend option when sourcing the second setup.bash works. Am I alone in cross compiling my packages or in the way I move them to the target board? Comment by ahendrix on 2016-02-20: I don't know of anyone else who has gotten the cross-compilation process to work. If you have time to post instructions on how you're doing it, it would be greatly appreciated.
{ "domain": "robotics.stackexchange", "id": 23529, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "robotic-arm, ros, ros-jade, catkin-workspace", "url": null }
c++, beginner, rock-paper-scissors std::cout << matches << " matches played in total. \n"; // Declare the winner if (score < 0) { std::cout << "YOU LOST THE GAME! \n"; } else if (score == 0) { std::cout << "IT'S A TIE! \n"; } else { std::cout << "YOU WON THE GAME! \n"; } return 0; } // ask for user input char getUserInput() { char userInput{' '}; std::cout << "Rock, paper or scissors? (r-p-s): \n"; std::cin >> userInput; if (userInput != 'r' && userInput != 'p' && userInput != 's') { std::cout << "Please enter a valid character. \n"; std::cout << "Rock, paper or scissors? (r-p-s): \n"; std::cin >> userInput; } return userInput; } // generate computer's choice using a random number generator char getCompInput() { std::mt19937 mt{static_cast<std::mt19937::result_type>(std::chrono::steady_clock::now().time_since_epoch().count())}; std::uniform_int_distribution randDist{1, 3}; int r = randDist(mt); switch (r) { case 1: return 'r'; break; case 2: return 'p'; break; case 3: return 's'; break; } return 0; }
{ "domain": "codereview.stackexchange", "id": 45307, "lm_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, rock-paper-scissors", "url": null }
$\frac{d}{d t} P_t = Q e^{tQ} = e^{tQ} Q$ The first equality can be written as $$P_t' = Q P_t$$ and this is just the Kolmogorov backward equation. The second equality can be written as $P_t' = P_t Q$ and is called the Kolmogorov forward equation. Applying the Kolmogorov forward equation, we obtain $\frac{d}{d t} \psi_t = \frac{d}{d t} \psi_0 P_t = \psi_0 \frac{d}{d t} P_t = \psi_0 P_t Q = \psi_t Q$ This confirms that (5.3) solves (5.2). Here’s an example of three distribution flows with dynamics generated by (5.2), one starting from each vertex. The code uses (5.3) with matrix $$Q$$ given by Q = ((-3, 2, 1), (3, -5, 2), (4, 6, -10)) Q = np.array(Q) ψ_00 = np.array((0.01, 0.01, 0.99)) ψ_01 = np.array((0.01, 0.99, 0.01)) ψ_02 = np.array((0.99, 0.01, 0.01)) ax = unit_simplex(angle=50) def flow_plot(ψ, h=0.001, n=400, angle=50): colors = cm.jet_r(np.linspace(0.0, 1, n)) x_vals, y_vals, z_vals = [], [], [] for t in range(n): x_vals.append(ψ[0]) y_vals.append(ψ[1]) z_vals.append(ψ[2]) ψ = ψ @ expm(h * Q)
{ "domain": "github.io", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9790357555117625, "lm_q1q2_score": 0.8241774046809758, "lm_q2_score": 0.8418256432832333, "openwebmath_perplexity": 506.04178629676943, "openwebmath_score": 0.9266547560691833, "tags": null, "url": "https://jstac.github.io/continuous_time_mcs/kolmogorov_fwd.html" }
sql, sql-server Title: Efficient way to extract the first row in a Group By group I have a large Sql Server view with this schema: [archive_ID] (int, not null) [archive_date] (datetime, not null) [archdata_path_ID] (varchar(50), not null) [archdata_value] (int not null) I need to group the records by the Date, and I need to extract just the first record for each group. This is the current query: WITH cte AS ( SELECT * ,CAST(archive_date AS DATE) AS C ,ROW_NUMBER() OVER ( PARTITION BY CAST(archive_date AS DATE) ORDER BY CAST(archive_date AS DATE) ASC ) AS ad FROM ArchiveData WHERE archdata_path_ID = @PathID ) SELECT DISTINCT C ,archdata_value AS val FROM cte WHERE ad = 1 ORDER BY C ASC The main problem is to improve the readability. Would be great to optimize also the performance, but it's not mandatory. I believe that DISTINCT is redundant, since the CTE should produce only one row for each date whose ROW_NUMBER() is 1. Avoid selecting * in the CTE, and list the columns you want explicitly. Your naming is poor: CTE, C, val, ad. Please find more descriptive names. If you are using any SQL Server ≥ 2012, then FIRST_VALUE() is the function you want. SELECT CAST(archive_date AS DATE) AS C , FIRST_VALUE(archdata_value) OVER ( PARTITION BY CAST(archive_date AS DATE) ORDER BY CAST(archive_date AS DATE) ) AS val FROM ArchiveData WHERE archdata_path_ID = @PathID ORDER BY C;
{ "domain": "codereview.stackexchange", "id": 8876, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "sql, sql-server", "url": null }
quantum-mechanics, homework-and-exercises, probability, measurement-problem, born-rule Title: Probability of quantum transition I have a question about a task: We have a particle, which is in a linear combination of the first two states of the harmonic oscillator, which we can parametrise as $|\psi\rangle=\cos(\frac{\theta}{2})\space |0\rangle +e^{i\phi}\sin(\frac{\theta}{2})|1\rangle$, where $0\leq\theta \leq \pi $ and $\leq \phi<2\pi$, what is the probability of finding the particle in the state of $|a\rangle=\frac{1}{\sqrt{2}}(|0\rangle+|1\rangle)$.
{ "domain": "physics.stackexchange", "id": 35091, "lm_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, homework-and-exercises, probability, measurement-problem, born-rule", "url": null }
mass, harmonic-oscillator, spring, vibrations What I allready know is the force $ F $ and the mass $ m $. Then I can find the spring stiffness k by sett all the derivatives to zero. Then I can compute the damper $ b $ throught this formula: $$ \ b = \zeta 2 \sqrt{k m}\ $$ According to Wikipedia, the damping ratio $ \zeta = 0.7 \ $ is a good number. And this really works too! I have test it by my own ODE simulations, and it works OK! Perfect! But the question is: If I have two or more ODE:s with diffrent spring stiffness and dampness like this: $$ \ m_{2}\frac{d^{2}z}{dt} = F - C_{2}(\frac{dz}{dt} - \frac{dy}{dt}) - k_{2}(z - y) \\ m_{1}\frac{d^{2}y}{dt} = C_{2}(\frac{dz}{dt} - \frac{dy}{dt}) + k_{2}(z - y) - C_1\frac{dy}{dt} - k_1 y\ $$ I can compute the stiffness $ k_1 , k_2 $ if I know the masses $ m_1 , m_2 $ and the force $ F $ , and also I need to set some position values for $ y , z $ Very easy! But how do I compute the damper $ C_1 , C_2 $ if I determine that $ \zeta = 0.7 $ ? I am going to tackle a special case of the general problem stated in the question. I hope this would leads to some insight into how to handle the general problem. Consider the 2-DOF system, but with each mass equal to $m_1=m_2 =\frac{m}{2}$ (so the total mass is $m$), each stiffness $k_1=k_2 = 2 k$ (so the combined stiffness is $k$) and each damping is $c_1=c_2 =2 c$ for the same reason.
{ "domain": "physics.stackexchange", "id": 44659, "lm_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, harmonic-oscillator, spring, vibrations", "url": null }
ros, installation, catkin, ros-kinetic /opt/ros/kinetic/lib/pkgconfig /opt/ros/kinetic/lib/pkgconfig/catkin.pc /opt/ros/kinetic/etc /opt/ros/kinetic/etc/catkin /opt/ros/kinetic/etc/catkin/profile.d /opt/ros/kinetic/etc/catkin/profile.d/05.catkin_make.bash /opt/ros/kinetic/etc/catkin/profile.d/05.catkin_make_isolated.bash /opt/ros/kinetic/share /opt/ros/kinetic/share/catkin /opt/ros/kinetic/share/catkin/cmake /opt/ros/kinetic/share/catkin/cmake/catkin_python_setup.cmake /opt/ros/kinetic/share/catkin/cmake/stamp.cmake /opt/ros/kinetic/share/catkin/cmake/safe_execute_process.cmake /opt/ros/kinetic/share/catkin/cmake/all.cmake /opt/ros/kinetic/share/catkin/cmake/debug_message.cmake /opt/ros/kinetic/share/catkin/cmake/shell.cmake /opt/ros/kinetic/share/catkin/cmake/list_insert_in_workspace_order.cmake /opt/ros/kinetic/share/catkin/cmake/catkin_package_xml.cmake /opt/ros/kinetic/share/catkin/cmake/templates /opt/ros/kinetic/share/catkin/cmake/templates/setup.zsh.in /opt/ros/kinetic/share/catkin/cmake/templates/env.sh.in /opt/ros/kinetic/share/catkin/cmake/templates/rosinstall.in /opt/ros/kinetic/share/catkin/cmake/templates/env-hook.context.py.in /opt/ros/kinetic/share/catkin/cmake/templates/script.sh.in
{ "domain": "robotics.stackexchange", "id": 31209, "lm_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, installation, catkin, ros-kinetic", "url": null }
mobile-robot, odometry, noise So you can't look at rotations independent of linear translations. Going 100 miles and turning 180 degrees is a lot different than turning 180 degrees and going 100 miles. Similarly, just because the robot is at, say, a local origin, doesn't mean you can determine the wheel encoder counts. There may have been no motion (no encoder counts), or a forward/backward motion, or a circular motion. Driving a circle would have the outboard wheels have higher counts than the inboard wheels, but both would be some net positive number of counts. Forward/backward would give net zero counts and both encoders would be even. All this is to point out why it's not possible to go straight from position to absolute encoder counts or vice-versa. As with any path-dependent problem, the solution is to take an integral. It's not clear how your robot is setup or how you're getting and changing the ground coordinates, but you need to convert the vehicle speed at the center of the vehicle to the linear speed at each wheel. You can then convert that to angular speed of the wheel (by dividing by the wheel circumference). Then you integrate. Multiply the angular speed of the wheel by however long the time step is in your simulation and add it to an existing "position" variable. If you're going for high fidelity simulations, then I would personally opt to "bin" the results based on your simulated wheel encoder resolution than to just add bulk noise to the signal. If you had an 8 bit wheel encoder, then one rotation gets divided into 2^8 = 256 segments. Each segment is then (2*pi/256) = 24.5 mradians. You can keep an internal state that tracks the true wheel rotations, but only update the simulated wheel encoder if it rolls over into the next bin. Consider the following code: wheelLinearSpeed = <your wheel speed>; angularSpeed = wheelLinearSpeed/wheelCircumference; angularPosition = angularPosition + angularSpeed*dT; encoderResolution = (2*pi) / (2^8); encoderCounts = floor(angularPosition/encoderResolution);
{ "domain": "robotics.stackexchange", "id": 1558, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "mobile-robot, odometry, noise", "url": null }
Proposed Proof: Let $a=(a_1,\ldots,a_n)$ be in $f^{-1}(0)$. Then $f(a)=0$ and thus by Spivak's Theorem 2.13 there exists an open set $A$ of $\mathbb R^n$ which contains $a$, and a diffeomorphism $h:A\to\mathbb R^n$ such that $f\circ h(x)=x_{n-p}^+$. Write $M=\{x\in A:x_{n-p}^+=0\}$. We now show that $h(M)=f^{-1}(0)$. Claim 1: $h(M)\subseteq f^{-1}(0)$. Proof: Let $y\in M$. Then $f\circ h(y)=y_{n-p}^+$ and since $y_{n-p}^+=0$, we have $f(h(y))=0$. Therefore $f(h(M))=\{0\}$. This gives $h(M)\subseteq f^{-1}(0)$ and the claim is settled. Claim 2: $f^{-1}(0)\subseteq h(M)$. Proof: Let $x\in f^{-1}(0)$. Since $h$ is a diffeomorphism, it is a bijection and thus there is $y\in A$ such that $h(y)=x$. Thus $f(h(y))=f(x)=0$. This means $f\circ h(y)=0$, that is $y_{n-p}^+=0$, meaning $y\in M$. Hence $x\in h(M)$ and since $x$ was arbitrarily chosen in $f^{-1}(0)$, we conclude that $f^{-1}(0)\subseteq h(M)$ and the claim is settled.
{ "domain": "mathhelpboards.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.972830769252026, "lm_q1q2_score": 0.8268781182027228, "lm_q2_score": 0.849971181358171, "openwebmath_perplexity": 301.5751499546279, "openwebmath_score": 0.8782758116722107, "tags": null, "url": "https://mathhelpboards.com/threads/proof-review-a-theorem-in-spivaks-book.7183/" }
javascript, angular.js, null compareJsons(json1, json2); function compareJsons(model1, model2){ console.log(model1); console.log(model2); var decline = "DECLINED"; var canProceed = false; var nullVal = false; var nullDec = false; var valDec = false; var valVal = false; angular.forEach(model1, function(m1Val, m1Key){ if(!m1Val){ console.log("Found NULL - "+ m1Key +" - " + m1Val); angular.forEach(model2, function(m2Val, m2Key){ if((m2Key === m1Key) && (m2Val !== m1Val)){ console.log(m1Key +" - " + m1Val + " CHANGED TO " + m2Key +" - " + m2Val); if((m2Val === decline) && !(m1Val)){ nullDec = true; } if(((m2Val) && (m2Val !== decline)) && !(m1Val)){ nullVal = true; } } }) } else { angular.forEach(model2, function(m2Val, m2Key){ if(m2Key === m1Key && m2Val !== m1Val){ if(m2Val === decline){ console.log(m1Key +" - " + m1Val + " CHANGED TO " + m2Key +" - " + m2Val); if(((m1Val) && (m1Val !== decline)) && (m2Val)){ valDec = true; } }else{ console.log(m1Key +" - " + m1Val + " CHANGED TO " + m2Key +" - " + m2Val); if((m1Val) && (m2Val)){ valVal = true; } } } }); } }); console.log("NULL to DECLINE - " + nullDec); console.log("NULL to VALUE - " + nullVal); console.log("VALUE to DECLINE - " + valDec); console.log("VALUE1 to VALUE2 - " + valVal);
{ "domain": "codereview.stackexchange", "id": 30414, "lm_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, angular.js, null", "url": null }
This means that the product $IJ$ is the set of all sums $a_1b_1 + a_2b_2 + ... + a_nb_n$ where $a_1, a_2, ..., a_n \in I$, $b_1, b_2, ..., b_n \in J$.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9744347860767304, "lm_q1q2_score": 0.8431044353482885, "lm_q2_score": 0.865224073888819, "openwebmath_perplexity": 192.8580341103168, "openwebmath_score": 0.9339467883110046, "tags": null, "url": "https://math.stackexchange.com/questions/290229/explaining-the-product-of-two-ideals" }
python, python-2.x, functional-programming, regex, plugin Could _remove_all_votes be implemented more cleanly? Is there a way to make the structure of the votes dictionary more clear? Is there a cleaner way to handle abstaining (\1) in _parse_vote? Is there a better way to make the vote shortcut required in implicit_vote but not in vote? Is there a better way to handle diversity emojis? Can _find_longest_matching_option be more explicit? Thanks in advance! Grumble, grumble. Browser tab crashed and SO didn't save my draft apparently. I'll try to recreate everything I remember writing: First off, your question is fantastically written. Often one of the most important skills in writing good code is being able to communicate your intent and any problems you face clearly. You've done an excellent job of this. I'll start with the good: Decent adherence to PEP 8 Good use of spacing - code is coherently grouped into "paragraphs" Some comments to explain unclear intentions Consistent naming patterns Good use of builtins and collections (namedtuple and functools.wrap to name a few) Overall pretty clean code, shows good command of python Small points of improvement:
{ "domain": "codereview.stackexchange", "id": 29157, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "python, python-2.x, functional-programming, regex, plugin", "url": null }
electricity, capacitance, resonance Title: Does changing capacitance in an RLC circuit, while keeping the resistance and inductance constant, dampen the voltage across the resistor? While doing an experiment on RLC circuits, I noticed that by decreasing the capacitance, while keeping the resistance and inductance constant, the resonant frequency changes (which is to be expected), but the graph also changes shape by becoming wider and lower. Why does this happen? Here is a graph of my results:(edit) After redoing my experiments base on Farcher's suggestions, I got the following results:
{ "domain": "physics.stackexchange", "id": 32805, "lm_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, capacitance, resonance", "url": null }
programming-languages Title: What is the difference between a function and a procedure In general, what is the difference between a function and a procedure when talking about programming languages? This is rather old distincion (from pascal - which is the most recognisable for this - see vonbrand's answer). Function returns value, procedure does not. This is only naming convention, the more common is just calling the both function, and if needed say that one does not return value. Some programming languages always return value (like the last statement is sent) or get returning cell on stack and does not use it. Other languages explicitly return empty value, so still you can assign it to variable, so there is no point of this distinction.
{ "domain": "cs.stackexchange", "id": 6115, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "programming-languages", "url": null }
c++, c++11, bash, web-scraping, curl How can I improve it so that it matches industry standard? A few more possibilities to consider: pre-compille your regular expressions Compiling a regular expression is (potentially) a somewhat expensive operation. In this case, the regular expressions remain constant throughout the program, so you might as well compile them once, and use the compiled regular expression after that: bool checkRegex(string & str) { static std::regex pattern{"^\\s{0,}<td\\salign.{0,}$"}; return regex_match (str , pattern); } use operator overloading where sensible For example, your compare function: bool compare (PROBLEM & p1 , PROBLEM & p2) { return p1.users < p2.users; } ...really makes more sense as an overload of operator<: bool operator<(PROBLEM & p1 , PROBLEM & p2) { return p1.users < p2.users; } const correctness Taking the operator above a step further, we don't want x < y to modify either x or y, so we should pass the operands by const reference: bool operator<(PROBLEM const &p1 , PROBLEM const &p2) { return p1.users < p2.users; } This way, when we sort our vector of Problem objects, we don't need to explicitly specify how to compare them: sort(v.rbegin(), v.rend());
{ "domain": "codereview.stackexchange", "id": 20066, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c++, c++11, bash, web-scraping, curl", "url": null }
singularities You are basically doomed to reach the singularity in a finite time period because it is everywhere in your possible future. In fact if you try to rocket away then since you are not on a geodesic, and geodesics are the maximal path, you in fact seal your fate earlier. The case for the timelike singularity occurs with charge or angular momentum. I will use the Reissnor-Nordstrom metric since it is simpler to understand than the Kerr metric. In fact it is a modification of the Schwarzschild metric $$ ds^2~=~\left(1~-~\frac{2m}{r}~+~\frac{Q^2}{r^2}\right)dt^2~-~\left(1~-~\frac{2m}{r}~+~\frac{Q^2}{r^2}\right)^{-1}dr^2~-~r^2(d\theta^2~+~sin^2\theta d^2\phi), $$ Since the metric coefficient $\left(1~-~\frac{2m}{r}~+~\frac{Q^2}{r^2}\right)$ is quadratic in $r$ is vanishes at two radii. There is an inner and outer horizon determined by $r_{\pm}~=~m~\pm~\sqrt{m^2~-~Q^2}$. There is then an inner horizon where the metric flips signature again. This means the region is timelike and the region $r~=~0$ is a point in space evolving in time. This is seen in the Penrose diagram There are subtleties, such as the inner horizon might turn out to be a mass inflation singularity. There is a pile up of null curves there. This appears similar to a Cauchy horizon that could be a sort of singularity. The region with the timelike singularity could be a mathematical fiction.
{ "domain": "physics.stackexchange", "id": 40677, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "singularities", "url": null }
c#, security So basically in a line like byte[] salt = new byte[max_length]; or int max_length = 32; the type of the variables does not add any value to the code. It is too obvious what the assigned type is, using the type instead of var only adds noise to the code without any real value. Disposing If an object implements IDisposable you should either call its Dispose() method or enclose it in an using block. Naming Also variables local to a method aren't mentioned in the naming guidelines I would suggest to use camelCase casing for naming them instead of snake_case casing. For naming private methods you should use PascalCase casing. Comments Comments should only describe why something is done. Let the code itself explain what is done by using meaningful and readable names. A very good answer about comments can be found here: https://codereview.stackexchange.com/a/90113/29371 getSalt() You should allow to pass the max_length to the method instead of hardcoding it. This has the advantage that a change to this value won't need the class class/method to be changed. If you make it an optional parameter you can still call it like it whould have no parameter. Edit Based on the valid comment from Johnbot you should better use a overloaded GetSalt() method instead of using an optional parameter. I don't see the need for converting to base64. Encryption algorithms use byte[] arrays, so you should better just return the byte[]. Applying the above would lead to private static int saltLengthLimit = 32; private static byte[] GetSalt() { return GetSalt(saltLengthLimit); } private static byte[] GetSalt(int maximumSaltLength) { var salt = new byte[maximumSaltLength]; using (var random = new RNGCryptoServiceProvider()) { random.GetNonZeroBytes(salt); } return salt; }
{ "domain": "codereview.stackexchange", "id": 14112, "lm_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#, security", "url": null }
electromagnetism, research-level, multipole-expansion For a neutral system with $Q=0$, however, the concept of centre of charge is meaningless and there is no monopole term in the expansion. The relevant concept is then the dipole moment, $$ \mathbf{d}=\sum_i q_i(\mathbf{r}_i-\mathbf{r}_0), $$ which is independent of the position $\mathbf{r}_0$ of the origin. However, this means that the relative importance of the subleading term in the multipole expansion is higher than above: $$ \Phi(\mathbf{r})=\frac{\mathbf{d}\cdot\mathbf{r}}{|\mathbf{r}-\mathbf{r}_0|^2}+O\left(\frac{1}{|\mathbf{r}-\mathbf{r}_0|^{3}}\right) $$ My question is: for a neutral system, is it possible to find a suitable position $\mathbf{r}_0$ for the origin that will set the subleading, quadrupole term to zero? Since this entails a system of five equations (linear in $\mathbf{r}_0$ when $Q=0$), I suspect this is impossible in general geometries. If this is the case, which geometries allow for vanishing quadrupole moments and which ones don't? In the cases where one can do this, does this position have a special name? More generally, if all multipole moments up to some $l\geq0$ are zero, (when) can the subleading term be made to vanish? Sometimes you can The obvious example is a purely dipolar charge which has been displaced from the origin, such as a dipolar gaussian $$ \rho(\mathbf r) =p_z(z-z_0)\frac{e^{-(\mathbf{r}-\mathbf{r}_0)^2/2\sigma^2}}{\sigma^5(2\pi)^{3/2}} . $$
{ "domain": "physics.stackexchange", "id": 7959, "lm_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, research-level, multipole-expansion", "url": null }
algorithms, optimization, dynamic-programming, combinatorics, depth-first-search Title: Minimum steps needed to partially cover a sequence of points on a grid Problem statement: You are in a 2D grid where you can move in any of the 4 directions, no obstacles. You start at position (0, 0). We say that you partially cover a point $(x,y)$ if your position has the same abscissa or the same ordinate (or both). You are given an ordered sequence of n points $(x_1,y_1), ..., (x_n,y_n)$, which you need to partially cover in that order. Find the distance of shortest path which partially covers the sequence of points. Constraints (just to give an order of magnitude): $n=20 000$ and $0<=x,y<=5000$, and time execution should be <5s. My approach: At first I thought this might be a dynamic programming problem. But now I just don't see how it could be applied. Brute force approach: Starting from $(0, 0)$ there are only two good paths that cover the first point $(x_1, y_1)$: go to $(x_1, 0)$ or $(0, y_1)$. Then there are only four paths that are good candidates to cover the 1st, and 2nd point: $(x_1, 0)->(x_2,0)$ $(x_1, 0)->(x_2,y_1)$ $(0, y_1)->(0, y_2)$ $(0, y_1)->(x_1, y_2)$. And so on. We can explore the tree of all good possible paths, where at the step n, we can choose between $2^n$ paths. Of course we only need to keep track for each path of its final position and the total distance. Pruning exploration approach: Now my idea is to do this exploration, in breadth-first order (BFS exploration), but with some pruning. At each step I can eliminate some possibilities. Indeed consider two paths, which both cover the first $n$ points.
{ "domain": "cs.stackexchange", "id": 19464, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "algorithms, optimization, dynamic-programming, combinatorics, depth-first-search", "url": null }
c, parsing, functional-programming static void print_listn( object a ); static int leading_ones( object byte ); static int mask_off( object byte, int m ); static fSuspension force_first; static fSuspension force_rest; static fSuspension force_apply; fSuspension infinite; static fSuspension force_chars_from_string; static fSuspension force_chars_from_file; static fSuspension force_ucs4_from_utf8; static fSuspension force_utf8_from_ucs4; fBinOperator map; fBinOperator eq; fBinOperator append; fBinOperator assoc; /* Helper macro for constructor functions. */ #define OBJECT(...) new_( (union object[]){{ __VA_ARGS__ }} ) /* Flags controlling print(). */ static int print_innards = 1; static int print_chars = 1; static int print_codes = 0; /* Define simple objects T_ and NIL_, the components of our boolean type. */ static union object nil_object = { .t=INVALID }; object NIL_ = & nil_object; object T_ = 1 + (union object[]){ {.Header={1}}, {.Symbol={SYMBOL, T, "T", & nil_object}} }; /* Allocation function is defined at the end of this file with its file scoped data protected from the vast majority of other functions here. */ static object new_( object prototype ); integer Int( int i ){ return OBJECT( .Int = { INT, i } ); } boolean Boolean( int b ){ return b ? T_ : NIL_; } string String( char *str, int disposable ){ return OBJECT( .String = { STRING, str, disposable } ); } object Void( void *pointer ){ return OBJECT( .Void = { VOID, pointer } ); } list one( object it ){ return cons( it, NIL_ ); }
{ "domain": "codereview.stackexchange", "id": 43487, "lm_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, functional-programming", "url": null }
physical-chemistry Title: Solution with salts Does a solution of water and NaCl increase its volume of the same amount of the volume of salt added? Thank you Does the ions Na+ and Cl- taken separately ,occupy more space than the binded molecule? Suppose we take $100$g of an $x$% by weight solution of sodium chloride, so we have $x$g of salt and $100-x$g of water. The volume of $x$g of salt is: $$ V_S = x/\rho_S $$ where $\rho_S$ is the density of solid salt. Likewise the volume of the water is: $$ V_W = (100-x)/\rho_W $$ Suppose when we dissolve salt in water the volumes just add i.e. $$ V_\text{total} = V_S + V_W = x/\rho_S + (100-x)/\rho_W $$ then the density of our $x$% salt solution would be: $$ \rho_\text{sol}(x) = \frac{100}{x/\rho_S + (100-x)/\rho_W} \tag{1} $$ The density of salt is $2.165$g/cm$^3$, and we'll take the density of water to be $1$g/cm$^3$, so we can use equation (1) to calculate what the density would be if the volumes just added and we can compared this with the experimentally measured density. I did this in Excel and got: $$\begin{matrix} x & Equation (1) & Experimental & Constant Volume\\ 0 & 1.000 & 1.000 & 1\\ 0.5 & 1.003 & 1.002 & 1.005\\ 1 & 1.005 & 1.005 & 1.01\\ 2 & 1.011 & 1.013 & 1.02\\ 3 & 1.016 & 1.020 & 1.03\\ 4 & 1.022 & 1.027 & 1.04\\ 5 & 1.028 & 1.034 & 1.05\\
{ "domain": "physics.stackexchange", "id": 38734, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "physical-chemistry", "url": null }
python, python-3.x, pygame, audio, modules and answer = input("\nDo you want to repeat? ").strip().lower() if answer in ["n", "no", "nah", "nay", "course not", "don't", "dont", "not"] or "no" in answer or "nah" in answer or "nay" in answer or "course not" in answer or "don't" in answer or "dont" in answer or "not" in answer: exiting() elif answer in ["y", "yes", "yeah", "course", "ye", "yea", "yh", "do"] or "yes" in answer or "yeah" in answer or "course" in answer or "ye" in answer or "yea" in answer or "yh" in answer or "do" in answer: input_for_tts("\nPlease input something for the program to say: ") Full code: import os import time import sys import getpass import pip import mmap import imp from contextlib import contextmanager my_file = "Text To Speech.mp3" username = getpass.getuser() @contextmanager def suppress_output(): with open(os.devnull, "w") as devnull: old_stdout = sys.stdout sys.stdout = devnull try: yield finally: sys.stdout = old_stdout def check_and_remove_file(): active = pygame.mixer.get_init() if active != None: pygame.mixer.music.stop() pygame.mixer.quit() pygame.quit() if os.path.isfile(my_file): os.remove(my_file) def wait_for_it(audio_length, greater_than, less_than, time_to_wait): if (audio_length) >= (greater_than) and (audio_length) < (less_than): time.sleep((audio_length) + (time_to_wait)) def exiting():
{ "domain": "codereview.stackexchange", "id": 25824, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "python, python-3.x, pygame, audio, modules", "url": null }
Indeed, a polynomial ring is designed precisely to have this property, i.e. it is the most general ("free") ring that contains $\,R\,$ and a new element $\,x\,$ that commutes with all elements of $R$. Because we use only the ring axioms and constant commutativity when proving polynomial equations, such proofs persist in said ring images where constant commutativity persists. This is true in your example because constants $\,r\,$ map to a constant matrices $\,rI\,$ which commute with $\,T =$ image of $x$. This implies that all familiar polynomial equations (e.g. Binomial Theorem and difference of squares factorization) persist to be true when evaluated into any ring where the constants commute with the indeterminates. Ditto for many other ubiquitous polynomial equations, e.g. cyclotomic polynomial factorizations, polynomial Bezout identities for the gcd, resultants, etc. Therefore such equations represent universal laws (identities), modulo said constant commutativity. These ideas are brought to the fore when one studies $(R-)$algebras, which are rings containing a central image of $R$, i.e. where the images of elements of $R$ commute with everything. Any polynomial equation that holds true in $\,R[x_1,\ldots,x_n]\,$ will persist to be true when evaluated into any $R$-algebra, i.e. it is an identity (law) of $R$ algebras. In fact it is easy to show that an equation holds true in $\,R[x_1,\ldots,x_n]\,$ iff it is true in all all $R$ algebras. Hence the equations that hold true $\,R[x_1,\ldots,x_n]\,$ are precisely the identities (universal laws) of $R$-algebras. • Thank you very much, appreciate it! – jjepsuomi Aug 4 '16 at 18:55
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9811668717616667, "lm_q1q2_score": 0.8319978784968901, "lm_q2_score": 0.847967764140929, "openwebmath_perplexity": 301.5266675768205, "openwebmath_score": 0.8987184166908264, "tags": null, "url": "https://math.stackexchange.com/questions/1882069/why-does-polynomial-factorization-generalize-to-matrices" }
# Math Help - Is this question solvable? 1. ## Is this question solvable? During a "Spirit Week" rally, twenty students, each exerting a force of 8000N [forward], pushed a teacher's car on level ground and accelerated it from rest to 1.5m/s [forward] in 3.0s. If the coefficient of friction was approximately 0.55 for both the static and kinetic cases, determine the mass of the teacher's car. Given: $F_App = 8000N[forward]$ $v_1 = 0m/s$ $v_2 = 1.5m/s[forward]$ $t = 3s$ $\mu_k = 0.55$ $\mu_s = 0.55$ Required: m = ? Analysis: First solve for acceleration by plugging the given values into the equation $\frac{v_2 - v_1}{t} = a$ $\frac{1.5m/s[forward] - 0m/s}{3s} = a$ $0.5m/s^2[forward] = a$ One of the two values has now been obtained to solve for $m$. $\frac{F_net}{a} = m$ The $F_net$ value is still needed. To find this value, plug the corresponding values into the equation $F_net = F_App + F_fk$. To find $F_fk$, plug the corresponding values into the equation $F_N*\mu_k = F_fk$. The $F_N$ value is still needed. This value is equal to $F_G$. To find this value, plug the corresponding values into the equation $m*g = F_G$. This is where the problem is. I need the mass in order to solve for the mass. Does anyone know any other way of solving this? Or was the question erroneously written to a point where it can't be solved? 2. I think you have everything correct, except for the net force is equal to the applied force *minus* the frictional force. Once you get everything into one equation, you can solve for m:
{ "domain": "mathhelpforum.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9808759632491111, "lm_q1q2_score": 0.8317511918030392, "lm_q2_score": 0.8479677583778257, "openwebmath_perplexity": 310.34694490517967, "openwebmath_score": 0.8307979106903076, "tags": null, "url": "http://mathhelpforum.com/math-topics/138332-question-solvable.html" }
organic-chemistry, carbonyl-compounds, reactivity, carbohydrates, protecting-groups Title: Reaction of glucose acetal with acetic anhydride The following problem was asked in JEE Mains 2020 (Sept 2, Shift 1), Consider the following reactions: $\ce{ (i) Glucose + ROH ->[dry HCl] Acetal ->[$x$ eq. of (CH3CO)2O] acetyl derivative }$ $\ce{ (ii) Glucose ->[Ni/H2] A ->[$y$ eq. of (CH3CO)2O] acetyl derivative }$ $\ce{ (iii) Glucose ->[$z$ eq. of (CH3CO)2O] acetyl derivative }$ What are $x, y,$ and $z$ in these reactions, respectively? I know that the reaction in (i) is acetal formation (used to protect aldehyde), and that alcohol reacts with anhydrides to form acids. As, there are only 5 hydroxyl group in acetyl deriv. of (i), so $x=5$. In (ii), carbonyl part of glucose reduces to hydroxyl group, so $y=6$. And, in (iii), glucose directly reacts with anhydride, so $z=5$. But, my answer was wrong (x only), as per the key. What am I doing wrong? The answer given is, x = 4, y = 6, z = 5 I think there's nothing to discussed about this further as all comments directing to the correct answer: $x = 4, \ y = 6,$ and $ z = 5.$ I think it's better show in the structures:
{ "domain": "chemistry.stackexchange", "id": 14447, "lm_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, carbonyl-compounds, reactivity, carbohydrates, protecting-groups", "url": null }
python, beginner, game, tkinter, simon-says Here the i=i is evaluated whenever the function is called. A simple lambda: print i would have failed. The actual solution to this problem, though is to use a class. This way you can pack all those global variables as attributes, can access them within the functions, and so on. I won't go into details about how to write a class, because there are very good tutorials about this (add links). There are a few more noteworthy changes. I made functions to create and place a label, which is pretty straight-forward, and to create and place a button. The latter is a bit more complicated, because, as explained above, the button needs a parameter-less function. For this I used the fact that in python functions are first-class objects. This means that you can return functions from other functions. I therefore wrote a button click handler factory, that produces a custom function given its parameters (with the right color, highlightcolor, etc). To save the data of the different buttons I created a collections.namedtuple, which is just a tuple, where you can access the members also by name (but also still by index if you need to). Then I made the game slightly more complete by adding a variable length of the shown sequence, an actual saving and verification of the user sequence and the correct handling of checking whether it is correct. The attribute self.sequence contains the generated (and shown) sequence, while if a user clicks a button it is added to self.user_sequence if the two are identical the user wins, score is updated (and best if needed). A new sequence can be generated, with a length one longer than before. If the user clicks and the sequence is right so far, nothing happens. But if the user clicks a button which is not the next in the sequence, the game resets (keeping only best). I also placed the actual execution of the game in a if __name__ == "__main__": guard to allow importing parts of the code from other scripts (So you can e.g. do from simon_game import Button, if this code is saved as simon_game.py). Final code: import Tkinter import random from collections import namedtuple
{ "domain": "codereview.stackexchange", "id": 21834, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "python, beginner, game, tkinter, simon-says", "url": null }
javascript, object-oriented, opengl, webgl Why assume shader sourcecode is stored in a HTML container? Split the creation and reading logic into two objects or at least methods. Consider using gl.getAttribLocation and gl.getUniformLocation instead of prebinding locations (if anything, your setupcode is not longer required). Consider using type deduction when uploading uniforms, e.g., (in slightly pseudo code) Shader.prototype.set(uniformName, data) { var handle = this.lookup(uniformName); if(data instanceof Vec2) { // use gl.uniform2fv(uniformName...) } else if(data instanceof Vec3) { // use gl.uniform3fv(uniformName...) } } This will ease development significantly. Names like bindNull and getName are vague. Are we binding a null texture? Is name synonymous for a shader program? Perhaps create a method that checks gl.VALIDATE_STATUS If you go for some fancy documentation as Ethan suggests, consider using three slashes instead of multi-line comments, e.g., /// A simple AND gate. /// @param {bool} port1 - The first input port. /// @param {bool} port2 - The second input port. /// @returns {bool} /// function ANDGate(port1, port2) { return port1 && port2; } This way you can still use multi-line comments to disable whole functions. The syntax is well supported. Future work: Consider implementing your own #include directive for GLSL and a way to define GLSL macro values from your code. var gl = Renderer.getWebGLContext(); seems highly hardcoded. My own last project had about 4 renderers. Perhaps inject this dependency via a constructor. Your code is too friendly, e.g., your ShaderProgram.prototype.bind function silently progresses if the shader isn't even created. Clearly, calling bind on a shader that does not exist is a throwable error. Read about defensive programming. There are some design patterns to create truly private variables, e.g., function Person(name) { var _name = name;
{ "domain": "codereview.stackexchange", "id": 13720, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "javascript, object-oriented, opengl, webgl", "url": null }
javascript, beginner, jquery, twitter-bootstrap Codes index.html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <title>Time Card</title> <link rel="stylesheet" type="text/css" href="css/main.css"/> <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/> <style> html, body { margin : 0; height: 100%; } .container-fluid { height: 100%; } .row { height: 100%; } .box-header { background-color: #6C7E8F; text-align: center; padding: 8px; color: #FFF; } </style> </head> <body style="background-color: #2c3e50;"> <div class="container-fluid"> <div class="row"> <div class="col-sm-8" style="padding: 0; border-right: 1px solid black; height: 100%;"> <div class="card" style="margin: 16px; height: 95%; "> <h3 class="card-header">Interface</h3> <div class="card-block"> <h4 class="card-title">Instructions</h4> <p class="card-text">Press the <b>Clock In</b> button when starting shift. This will get the current time and add it in your <i>Time Card</i>.</p> <p class="card-text">Press the <b>Clock Out</b> button when ending shift. This will get the current time and add it in your <i>Time Card</i>.</p>
{ "domain": "codereview.stackexchange", "id": 26277, "lm_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, twitter-bootstrap", "url": null }
newtonian-mechanics, newtonian-gravity, optimization Title: Maximal Gravity I found this interesting problem in Introduction to Classical Mechanics with Problems and Solutions by David Morin: Given a point $P$ in space, and given a piece of malleable material of constant density, how should you shape and place the material in order to create the largest possible gravitational field at $P$? Any ideas? This Physics quiz website by Yacov Kantor provides the solution in the February 2002 quiz. The optimal surface profile (with max gravity in the origin) in spherical and cylindrical coordinates for the solid of revolution is $r^2=z_0^2 \cos\theta$ and $(z^2+\rho^2)^{3/2}= z_0^2z$, respectively, $0\leq z\leq z_0$. The gravity in the origin is only 2.6% larger than the gravity on the surface of a spherical planet.
{ "domain": "physics.stackexchange", "id": 52956, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "newtonian-mechanics, newtonian-gravity, optimization", "url": null }
algorithms, satisfiability, 3-sat Can someone explain what I'm doing wrong to come to different conclusions? In the Resolution proof system, at any given point in time, we have a set $S$ of clauses. If $S$ contains two clauses $\alpha \lor x$ and $\beta \lor \lnot x$, we can resolve to obtain the new clause $\alpha \lor \beta$, which we add to $S$. We do not remove the original clauses. Rather, they stay in $S$. A given collection of clauses is either satisfiable or unsatisfiable — this is a concept that has nothing to do with Resolution: a set of clauses is satisfiable if there is a truth assignment that satisfies all clauses; otherwise, it is unsatisfiable. Resolution is sound: starting with a set $S$ of clauses, any clause $\alpha$ which is produced by Resolution is logically implied by $S$, in the sense that any truth assignment satisfying $S$ also satisfies $\alpha$. In particular, if $S$ is satisfiable, Resolution would not derive the empty clause. Conversely, Resolution is complete: if a set $S$ of clauses is unsatisfiable, then using Resolution, you can derive from it the empty clause, thus proving that $S$ is unsatisfiable. The proof could be rather long — there are many explicit examples which require exponentially long proofs, though in practice, in many cases much shorter proofs work. One way to deduce the empty clause given an unsatisfiable $S$ is to repeat the following algorithm: while there exist two resolvable clauses in $S$ whose resolvent is not in $S$, resolve the two clauses and add the resolvent to $S$. This process must work. Furthermore, any Resolution proof can be framed as a particular instantiation of this algorithm; the culprit is that at any given point in time, there could be many different pairs of clauses which could be resolved, and finding the optimal pair is hard.
{ "domain": "cs.stackexchange", "id": 19447, "lm_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, satisfiability, 3-sat", "url": null }
algorithms, data-structures, amortized-analysis small_nums, a list of small numbers, which is empty initially, other_nums, a list of numbers, which is empty initially, capacity, a natural number, which is $0$ initially, with three functions: extract_lowerthan_median(): If small_nums is empty, If len(other_nums) < 8, return accordingly. That means, if the smallest element is lower than median, pop it from other_nums and return it. Otherwise, return none. (len(a_collection) is the number of elements in a_collection.) Else, call amass_small_numbers() Pop an element from small_nums and return it. insert(new_num): Append new_num to other_nums. If len(other_nums) > 5 * capacity, call amass_small_numbers(). This step ensures any element poped from small_nums will be lower than median. amass_small_numbers(): Move all numbers in small_nums into other_nums. set capacity to len(other_nums)//4. (// is the integer division such as 7//3=2). Note that capacity is guaranteed to $\ge2$. Find the (capacity + 1)-th smallest element in other_nums, using a linear-time $k$-th-smallest-element selection algorithm as explained here or here. Denote it by p. Move all capacity elements in other_nums that are smaller than p to small_nums. Some minor variations.
{ "domain": "cs.stackexchange", "id": 20465, "lm_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, data-structures, amortized-analysis", "url": null }
Tim Riley and I developed a related construction in The absence of efficient dual pairs of spanning trees in planar graphs where we constructed cell complexes of bounded geometry (the complex and dual both have valence $\le 6$) where the filling length is a quadratic function of diameter. We also showed that quadratic behavInior is sharp. We used this to show that for all spanning trees in the complex, the length of the tree plus the length of the dual tree is bounded below by a quadratic function of the diameter of the graph. You can interpret this as saying that there is no way to sweep across the disk with arcs whose maximum length is less than a quadratic function of the diameter of the disk. These examples also show that for homotopies of the boundary to a point, some point must travel an unbounded distance for arbitrary diameter 1 metrics on the disk, and a quadratic function of diameter, if there are curvature bounds. These examples work for all higher dimensions. In both constructions, the cut locus is has a large diameter, considerably larger than the diameter of the metric itself. To construct the metrics, start with a tree that branches 3 ways at each vertex, and thicken it by replacing the vertices triangles at the vertices and rectangles for edges. Now glue on a strip, all the way around, cut out of the hyperbolic plane between two concentric horocycles with the long edge along the tree and the short edge on the outside. This achieves the metric of bounded diameter. Here are the relevant figures from our paper. The idea is that the lines of any homotopy end up having to cut across the tree numerous times, each time losing some efficiency. See the two cited papers for details. alt text http://dl.dropbox.com/u/5390048/Tree%20pictures.jpg Added: See the answers of Sergei Ivanov and Ian Agol for nice and more general methods that work in higher dimensions. • Very interesting, thank you! Luckily there's at least some bound. Sep 22, 2010 at 1:36
{ "domain": "mathoverflow.net", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9780517424466175, "lm_q1q2_score": 0.8063664173458106, "lm_q2_score": 0.8244619199068831, "openwebmath_perplexity": 212.80503955542915, "openwebmath_score": 0.822840690612793, "tags": null, "url": "https://mathoverflow.net/questions/39537/effective-contraction-of-a-loop-reference-or-a-simple-proof" }
python, catkin, ros-kinetic /usr/lib/python2.7/dist-packages/catkin_pkg_modules-0.4.8.egg-info/PKG-INFO /usr/lib/python2.7/dist-packages/catkin_pkg_modules-0.4.8.egg-info/requires.txt
{ "domain": "robotics.stackexchange", "id": 31648, "lm_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, catkin, ros-kinetic", "url": null }
Hint2: Note, that the digital root for your numbers is always the same, regardless of your choice. • Thanks, I checked your link but I do not understand how your hint leads to the solution. Can you elaborate a bit, please? – Parzifal Oct 2 '18 at 12:53 • @Parzifal I've added one more hint. – Jaroslaw Matlak Oct 2 '18 at 13:08 • So indeed, the digital root always is 12. This means that any combination of the digits will yield this root. And I always get to this root as the minimum digital sum by re-applying the casting out of nines ... the argumentation runs in this direction? – Parzifal Oct 2 '18 at 13:36 • * Digital root is one-digit number, in this case $3$. * The control sum is equal to the digital root (mod 9). Therefore the control sum can't be smaller than the digital root. You've found the number with control sum equal to the digital root, so... – Jaroslaw Matlak Oct 2 '18 at 18:27 • Thank you - your comments and hints were very helpful to me. First time that I came across such concepts. – Parzifal Oct 2 '18 at 19:22 Building on the helpful hints of @Jaroslaw Matlak, the digital root of the sum will equal the digital root of the sum of the digital roots for the summed numbers. Consider your first example: $$243 + 957 = 1200$$ The digital root of $$243$$ is $$2+4+3 = 9$$ and the digital root of $$957$$ is $$9 + 5 + 7 = 21,$$ continuing to sum until we have one digit, $$2+1 = 3$$. So the sum of the digital roots for $$243$$ and $$957$$ is $$9+3 = 12$$ giving $$1+2 = 3$$. This is equal to the digital root of $$1200$$. $$1+2+0+0 = 3$$.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.991554374556315, "lm_q1q2_score": 0.8717218153519007, "lm_q2_score": 0.8791467595934565, "openwebmath_perplexity": 215.21255555354622, "openwebmath_score": 0.8231542706489563, "tags": null, "url": "https://math.stackexchange.com/questions/2939291/find-the-smallest-possible-checksum" }
imu Title: driver for Cloud Cap Christa IMU I've searched in vain for a driver for the Cloudcap Crista IMU, so it looks like I will have to write/modify a driver to convert to ROS message format. I have a specific example driver in C++ that came with the unit along with several other source files as dependencies. I have not been able to find specifics regarding the creation of the ROS wrapper that implements this driver. I can post the example code if need be. Thanks in advance Bruce 06/15/15 Thank you Kleinma. I did find your driver about a month ago and am in the process of putting it all together with robot_localization. At first I had little luck, but after a late night AHA!, I discovered that it was timing-out due to the latency of my setup. It is working fine now after making that adjustment. Thank you so much, I thought I was the only one in the universe using this accelerometer. Also great work on the agricultural applications! Thanks also goes to the ROS community at large. Such a gold mine of knowledge! I did not think I could mix cpp and python in ROS, but the answer was here within the community. I still have a long way to go, but now I have access to your wealth of resources and experience. Many thanks to all. Originally posted by b2256 on ROS Answers with karma: 162 on 2015-03-06 Post score: 1 Original comments Comment by gvdhoorn on 2015-03-06: If you do start writing a wrapper/driver, please pay attention to standards / best practices for IMUs in ROS. See ros-infrastructure/rep#95 for some recent discussion on this. You can find a ROS driver here. "Crista" is mispelled (as "Christa"). However, it should work just fine. Originally posted by kleinma with karma: 48 on 2015-06-15 This answer was ACCEPTED on the original site Post score: 2
{ "domain": "robotics.stackexchange", "id": 21066, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "imu", "url": null }
ds.algorithms, planar-graphs Has a similar algorithm been found for planar directed graphs? To clarify what I mean, although there are several different ways one could generalise the planar Ising model to directed graphs, I have in the mind the following: The 2-local term in the standard Ising model is the symmetric matrix $J_{ij}$. The directed graph would be represented by unsymmetric matrix $J_{ij}$! So the sum over the partition function would be unsymmetrical. I hope this helps. If you take the standard Ising model: min $E= -\sum_{i \neq j}J_{ij}S_iS_j$, where $S_k =\pm 1$, and replace $J_{ij}$ with a non-symmetric matrix, it remains the standard Ising model. This is because you can rewrite the terms $- J_{ij}S_i S_j -J_{ji}S_j S_i = - \frac{J_{ij} + J_{ji}}{2} (S_iS_j + S_j S_i)$. A more interesting asymmetric generalization of the planar Ising model is planar MAX 2-SAT (the problem planar MIN 2-SAT is equivalent). This is the problem MAX 2-SAT where the clauses are on the edges of a planar graph. Planar MAX 2-SAT is NP-hard: look at this paper by Guibas, Hershberger, Mitchell and Snoeyink. Thus, it appears that there may be no interesting polynomial-time generalization of the planar Ising model algorithm. I should note that for planar MAX 2-SAT to be a generalization of the planar Ising model, you need to restrict the Ising model to polynomial-size integers $J_{ij}$. The obvious reduction also requires a planar multigraph, but there's an easy proof that planar MAX 2-SAT on a graph and on a multigraph are equivalent problems.
{ "domain": "cstheory.stackexchange", "id": 519, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "ds.algorithms, planar-graphs", "url": null }
java, mongodb I will appreciate any suggestions even regarding chosen approach. Since you are already on Java 7, you can use try-with-resources on your BufferedReader for safe and efficient handling of the underlying I/O resource. Also, if all you are interested in is to read a file contents as a single String, you can consider reading them into a String, and then there appears to be three simple ways using either Guava, Apache Commons IO or Spark (web framework) libraries: // Guava String content = new String(ByteStreams.toByteArray(is)); // Apache Commons IO String content = IOUtils.toString(is, Charset.defaultCharset()); // Spark (web framework) String content = IOUtils.toString(is); Where applicable, it's recommended to specify the Charset explicitly, instead of relying on the default. One difference with this approach is that newlines aren't normalized to System.getProperty("line.separator") like what you have done here. If this is crucial for your usage, then a slight refactoring can be: private static String getStringFromInputStream(InputStream is) { try (InputStreamReader source = new InputStreamReader(is); BufferedReader bufferedReader = new BufferedReader(source)) { StringBuilder builder = new StringBuilder(); // using for-loop for nicer scoping of 'line' variable for (String line = bufferedReader.readLine(); line != null; line = bufferedReader.readLine()) { if (builder.length() > 0) { builder.append(System.lineSeparator()); } builder.append(line); } return builder.toString(); } catch (IOException e) { // recommended to do something about it instead of just printStackTrace() // e.printStackTrace(); } }
{ "domain": "codereview.stackexchange", "id": 18553, "lm_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, mongodb", "url": null }
homework-and-exercises, newtonian-mechanics, rotational-dynamics, friction Title: If a disc is rolling on a surface, how do you verify that no slip occurs? If I have the values for the coefficient of static friction (0.1) and all the other variables, how do I verify that no slip occurs? Mathematically the no-slip condition is represented by: $$v=\omega R$$ Where $v$ is translational (linear) velocity, $\omega$ is angular (rotational) velocity and $R$ is disc radius. Assuming no air drag we can see that no net forces or net moments act on the disc. By Newton's First Law this means the object's state of motion (both translational and rotational) will remain 'forever' unchanged. The value of the friction coefficient has no influence here. Now consider a different scenario:
{ "domain": "physics.stackexchange", "id": 29170, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "homework-and-exercises, newtonian-mechanics, rotational-dynamics, friction", "url": null }
cc.complexity-theory, circuit-complexity Next, we show that Certified $\mathsf{P/poly}$ is closed under complement, giving the first "$\Longleftrightarrow$" in the statement. Suppose $L \in \mathsf{Cert}\text{-}\mathsf{P/poly}$, with verifier $V$ as in the above definition. Since $L \in \mathsf{NP}$ by the preceding paragraph, there is some $c$ such that $L \in \mathsf{NTIME}(n^c) \subseteq \mathsf{DTIME}(2^{n^c})$. Let $V'(C',\pi)$ compute as follows: if $C'$ has a negation gate as its output gate, then write $C' = \neg C$, and define $V'(C',\pi) = V(C,\pi)$. Otherwise, $V'(C',\pi)$ checks whether $|\pi|=2^{\ell + \ell^c}$ (where $\ell$ is the number of inputs to $C'$); if not, then $V'$ rejects, and if so, then $V'$ simply enumerates all strings $y$ of length $\ell$, and checks whether $C'(y)=L(y)$, using the $2^{\ell^c}$ deterministic algorithm for $L$, which takes time $poly(|\pi|)$. (This latter yoga was needed to make sure that $V'$ satisfies property 1 in the definition.) If $\{(C_n,\pi_n)\}$ is a certified family of circuits for $L$ with verifier $V$, then $\{(\neg C_n, \pi_n)\}$ is a certified family of circuits for $L^c$ with verifier $V'$. QED
{ "domain": "cstheory.stackexchange", "id": 4780, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "cc.complexity-theory, circuit-complexity", "url": null }
c#, algorithm, timer // Check if there are any events to execute if (eventIndex == numEvents) { return; } // Check if the current event has yet to occur if (events[eventIndex].Time > currentTime) { return; } else { // Update the property based on the current event UpdateProperty(events[eventIndex].Value); // Current event has been executed so increase the event index eventIndex++; }
{ "domain": "codereview.stackexchange", "id": 1871, "lm_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, timer", "url": null }
I can figure out the change in A. And my job is to find the derivative of A inverse. So here's a handy identity. Can I just put this here? So here's my usual identity. So as last time, I start with a finite change because calculus always does that, right. It starts with a delta t and then it goes to 0. So here I am up at a full size change. So I think that this is equal to B inverse A minus B A inverse. And if it's true, it's a pretty cool formula. And, look, it is true, because over on this right-hand side, I have B inverse times A A inverse. That's the identity. So that's my B inverse. And I have the minus, the B inverse B is the identity. There's A inverse. It's good, right? So from that, well, I could actually learn from that the rank of this equals the rank of this. That's a point that I made from the big formula. But now, we can see it from an easy formula. Everywhere here, I'm assuming that A and B are invertible matrices. So when I multiply by an invertible matrix, that does not change the rank. So those have the same ranks. But I want to get further than that. I want to find this. So how do I go? How do I go forward with that job to find the derivative of the inverse? Well, I'm going to call this a change in A inverse. And over here, I'll have B will be-- yeah, OK, let's see, am I right? Yeah. So B inverse will be-- this is A plus delta A inverse. And this is-- well, that's A minus B. So that's really minus delta A. From A to B is the change. Here, I'm looking at the difference A minus B. So it's minus a change. And here, I have A inverse. I haven't done anything except to introduce this delta and get B out of it and brought delta in.
{ "domain": "mit.edu", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9877587232667825, "lm_q1q2_score": 0.8509918800373479, "lm_q2_score": 0.8615382076534743, "openwebmath_perplexity": 579.5582326369798, "openwebmath_score": 0.8125327229499817, "tags": null, "url": "https://ocw.mit.edu/courses/mathematics/18-065-matrix-methods-in-data-analysis-signal-processing-and-machine-learning-spring-2018/video-lectures/lecture-15-matrices-a-t-depending-on-t-derivative-da-dt/" }
newtonian-gravity, acceleration, centrifugal-force, equivalence-principle, orbital-motion Title: How is space ship's acceleration perceived if the acceleration is perpendicular to the velocity? Spacecraft in orbit around the Earth are constantly accelerated by the gravitational field of Earth. That's why the spacecraft ($m \ll M$) is in an (elliptical) orbit around the centre of gravity of the Earth, accelerated by $ \mathbf{g}=-{G M \over r^2}\mathbf{\hat{r}} \, .$ Plugging in the numbers for a spacecraft orbiting at roughly 420 km (such as the International Space Station), this gives: $ \mathbf{g} = {- 3.986 \cdot 10^{14} \over (6371 + 420) \cdot 10^3 m} = - 8.6 \, \mathrm{m}/\mathrm{s}^2$ So, an astronaut on-board the ISS is in a reference frame that is constantly accelerating at an acceleration of $8.6 \, \mathrm{g}/\mathrm{m}^2$. Yet unlike the astronauts featured in this related question, they do in fact feel no gravitational acceleration at all; at most they may feel some centrifugal pseudoforce, but this is considerably less than the gravitational acceleration, and at most at microgravity levels. Is acceleration only perceived when it changes the magnitude of the velocity, as opposed to the direction? What is the fundamental reason for this? Or am I misunderstanding something? The important difference is not the direction of the acceleration, it is the cause. When a rocket ship accelerates the engine pushes the hull, the hull pushes the floor and the floor pushes the astronaut's feet. He feels this force through his feet (and spine) and says he has weight. In the case of a spinning ship, looked at from a non-spinning reference point on the outside, inertia will cause the astronaut to move in a straight line until he meets the outer wall. But then the wall will prevent him from continuing in a straight line. If he sticks (instead of slipping without friction) he will begin accelerating away from the trajectory he originally had. Again there is a force on his feet and he says there is gravity (in this case "down" is really away from the axis of rotation).
{ "domain": "physics.stackexchange", "id": 6376, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "newtonian-gravity, acceleration, centrifugal-force, equivalence-principle, orbital-motion", "url": null }
ros Title: unable to see ROS repository during ROS Hydro install on Mint 13 Maya I successfully installed ROS Hydro Desktop Full on my Ubuntu box and now I'm trying to install the bare bones ROS base on my robot's computer which is running Linux Mint 13 Maya. I must be missing something fundamental, because I'm not getting past step 1.4 on the Hydro installation page: [full URL removed from post due to low karma]wiki.ros.org/hydro/Installation/Ubuntu My starting point: $ apt-cache search ros-hydro $ $ cat /etc/*release* DISTRIB_ID=LinuxMint DISTRIB_RELEASE=13 DISTRIB_CODENAME=maya DISTRIB_DESCRIPTION="Linux Mint 13 Maya" DISTRIB_ID=LinuxMint DISTRIB_RELEASE=13 DISTRIB_CODENAME=maya DISTRIB_DESCRIPTION="Linux Mint 13 Maya" NAME="Ubuntu" VERSION="12.04.2 LTS, Precise Pangolin" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu precise (12.04.2 LTS)" VERSION_ID="12.04" $ $ uname -a Linux myhostname 3.2.37-compulab.cm-itc #2 SMP Tue Mar 12 13:36:04 UTC 2013 i686 i686 i386 GNU/Linux $
{ "domain": "robotics.stackexchange", "id": 16612, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "ros", "url": null }
quantum-mechanics, photoelectric-effect Title: Stopping potential in the photoelectric effect, collector work function In this question I am talking about the following situation:
{ "domain": "physics.stackexchange", "id": 28582, "lm_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, photoelectric-effect", "url": null }
python, python-3.x, object-oriented, programming-challenge else: print("No such letter in the word") lives -= 1 hint("check_lives") else: letter_found_count = chosen_word.count(guess) for _ in range(letter_found_count): indexfound = changed_word.find(guess) hidden_list[indexfound] = guess changed_list[indexfound] = "-" hidden_word = "".join(hidden_list) changed_word = "".join(changed_list) if hidden_word == chosen_word: print("\n%s\nYou guessed the word!\nYou survived!" % hidden_word) winner = True break if not winner: print("You are hanged!") if hint_count > 1: print(f"Though you used {str(hint_count)} hints") print() def hint(setting): if setting == "game": global chosen_word, changed_word, changed_list, hidden_word, hidden_list for _ in range(len(changed_list)): guess = changed_list[_] if guess != "-": letter_found_count = chosen_word.count(guess) for _ in range(letter_found_count): indexfound = changed_word.find(guess) hidden_list[indexfound] = guess changed_list[indexfound] = "-" hidden_word = "".join(hidden_list) changed_word = "".join(changed_list) return changed_word, hidden_word, changed_list, hidden_list if setting == "option": global hint_flag, hint_count hint_count = 0 while True: choice = input("With Hints? 'Yes' or 'No': ") if choice.lower() == "yes": hint_flag = True break elif choice.lower() == "no": hint_flag = False break
{ "domain": "codereview.stackexchange", "id": 37906, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "python, python-3.x, object-oriented, programming-challenge", "url": null }
rosjava, android Title: ROS on Android Tutorials Hi, Im new to ROS and Android Programming and Java but I really would like to try out ROS on my Samsung Nexus-S. I have been searching for information/tutorials on how to get it running, I have even intimidated googles with questions on Google+ to try to figure out what Im doing wrong,. So I figured I would write down what I've done, and maybe someone can point out where I went wrong. First. Im running Linux Ubuntu 11.04 on a VMWare fusion 3.1.3 on my MAC OSX 10.6.8. I downloaded ros diamond back (the natty one) from ros.org and followed the installation guide at: http://www.ros.org/wiki/diamondback/Installation/Ubuntu. No problem here except that apt-get didn't find any configuration called: "ros-diamondback-desktop-full" so I used "ros-diamondback-desktop" I ran through a few of the tutorials did some rosmake, roscd, rosls, rosrun etc.. worked fine. The downloaded Eclipse from here http://www.eclipse.org/downloads/ (I took the one for C++ and Linux) and tried to debug an step through the C++ tutorials from ROS. THat worked fine to. I then downloaded Android SDK from here: http://developer.android.com/sdk/installing.html. and the ADT plugin for eclipse. I followed the Hello World tutorial, just to make sure I was http://developer.android.com/resources/tutorials/hello-world.html able to get an app running on my phone. First my phone wouldn't show up in my Linux running in Fusion, to fix that I had to modify the vmware config file. (located in the MAC file directory where I store my Virtual Machines.) The file does't show up in the Finder, but in a Terminal I did: $ vi Ubuntu.vmwarevm/Ubuntu.vmx (my virtual machine is called Ubuntu)
{ "domain": "robotics.stackexchange", "id": 6191, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "rosjava, android", "url": null }
Q.1 Is the above statement and proof correct? Q.2 Is there geometric way to prove the statement? • How do you know that $A$ is invertible? – 5xum Apr 10 '18 at 12:43 • it is matrix of non-degenerate bilinear form (positive definite inner product should be non-degenerate, isn't it?) – Beginner Apr 10 '18 at 12:44 • That's one way of showing it, sure. – 5xum Apr 10 '18 at 12:45 For a geometric proof, just do something akin to Gram-Schmidt orthogonalisation. Take $v=v_1$, so that $(v,v_1)>0$. Let $u_2=v_2-\frac{(v_1,v_2)}{(v_1,v_1)}v_1$ be the component of $v_2$ that is orthogonal to $v_1$. Then $u_2\ne0$, or else $v_1$ and $v_2$ are linearly dependent. Add $c_2u_2$ to $v$ for a sufficiently large $c_2>0$. Then $(v,v_i)>0$ for $i=1,2$. Continue in this manner, you get a desired $v$.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9867771778588347, "lm_q1q2_score": 0.8800187951128634, "lm_q2_score": 0.8918110540642805, "openwebmath_perplexity": 133.78975763635015, "openwebmath_score": 0.9290722608566284, "tags": null, "url": "https://math.stackexchange.com/questions/2730864/vector-whose-inner-product-is-positive-with-every-vector-in-given-basis-of-mat" }
c++ class RateController { using clk_t = std::chrono::system_clock; using time_point_t = std::chrono::time_point<clk_t>; public: RateController(unsigned limit, unsigned long milliseconds) : n_(limit), milliseconds_(milliseconds), q(n_, time_point_t()) {} bool check() { time_point_t t = clk_t::now(); bool allowed = t - q[i_] >= std::chrono::milliseconds(milliseconds_); if (allowed) push(t); return allowed; } private: unsigned n_; unsigned long milliseconds_; unsigned i_ = 0; std::vector<time_point_t> q; void push(time_point_t t) { q[i_] = t; i_ = (i_ + 1) % n_; } };
{ "domain": "codereview.stackexchange", "id": 40372, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c++", "url": null }
MHF Helper Problem : A bike manufacturer has a plant in Minneapolis and another in Philly. The Minneapolis plant produces 70% of the bikes, of which 1% are defective. The Philly plant produces the other 30%, of which 0.5% are defective. 1: What percentage of bikes made by this company are defective? a) 1% b) 0.85% c) 0.5% d) 1.5% I figured that 1% of 70% of production is 0.7% of total production. 0.5% of 30 is 30/100 = 0.3/2 = 0.15. 0.15+0.7= 0.85 so B 2. A bike made by this company is found to be defective. What is the probability that it was produced by the Minneapolis plant? a) .824 b) .176 c) .699 d) .301 3. non defective. What is the probability that is it made by the Minneapolis plant? a) .824 b) .176 c) .699 d) .301 4. A bike made by this company is found to be defective. Probability it was produced by the philly plant? a) .824 b) .176 c) .699 d) .301 5. Non defective. Probability made by Philly plant? a) .824 b) .176 c) .699 d) .301 Frankly I cannot follow what you posted. Lets do #2. If a bike is found to be defective, then what is the probability that the bike was produced by the Minneapolis plant? The bike was produced at one of two plants: $$\displaystyle \mathcal{P}(D)=\mathcal{P}(D\cap M)+\mathcal{P}(D\cap P)$$ Now let us work on the question, if a bike is defective what is the probability it came from Minneapolis?
{ "domain": "mathhelpforum.com", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9777138099151278, "lm_q1q2_score": 0.8104649142727866, "lm_q2_score": 0.8289388019824947, "openwebmath_perplexity": 2973.5140636441297, "openwebmath_score": 0.261248916387558, "tags": null, "url": "https://mathhelpforum.com/threads/bayes-theorem-problem.283230/" }
theoretical-chemistry, intermolecular-forces, hydrogen-bond, dipole We easily see that the bond angles are close to what we expect for hydrogen bonds. I have reproduced a few values from Batsanov's paper below, with the caveat that the value for hydrogen strongly varies depending on the chemical environment from $\pu{110 - 161 pm}$, so I used the classic from Bondi.[7c] Since all the distance are around $\pu{200 pm}$, they are well below the threshold we set earlier. $$ \begin{array}{lr} \text{Element }\ce{Y} & r_\mathrm{vdW}(\ce{Y})/\pu{pm}\\\hline \ce{H} & \approx 120\\ \ce{C} & 196 \\ \ce{N} & 179 \\ \ce{O} & 171 \\\hline \end{array}\hspace{2ex} \begin{array}{lr}\\ \text{H-Bond }\ce{XH\bond{...}Y} & \sum r_\mathrm{vdW}(\ce{Y},\ce{H})/\pu{pm}\\\hline \ce{CH} & 316 \\ \ce{NH} & 299 \\ \ce{OH} & 291 \\\hline \end{array} $$ A quite interesting approach of revealing non-covalent interactions was presented by Johnson et. al., and the corresponding program is easy to use and only requires Cartesian coordinates.[8]
{ "domain": "chemistry.stackexchange", "id": 11389, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "theoretical-chemistry, intermolecular-forces, hydrogen-bond, dipole", "url": null }
c++, beginner, algorithm, programming-challenge, c++17 ,"vokdilvl","likdvlvo","ovlvilkd","lkoildvv","vllovkid","kidovlvl","vvlkldio","ildvokvl","vvkdloli","lvoidvkl","vokvidll","vkdvilol","lkvdvoli","dkillvvo","kdvillvo","ivdklvlo","dlkvilov","vodvklli","vkvilold","ldvvloki","likdlovv","likvdvol","vldilvko","llvovdki","llvvikdo","dvolvkil","dikolvvl","ovkldivl","iovllvkd","vlikolvd","vvdollik","lokivvdl","odivklvl","ldvolivk","lvvidlok","lkovldvi","kvllvdoi","vdvolkli","llkovvid","vloivdkl","vlvkoidl","ldvvolik","idokvlvl","iovlklvd","vlkvidlo","ivv
{ "domain": "codereview.stackexchange", "id": 38967, "lm_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, algorithm, programming-challenge, c++17", "url": null }
newtonian-mechanics, kinematics, acceleration, projectile It might be that the actual change in velocity is as per the green line in the right hand graph but because the change in velocity $\Delta t$ takes place over such a short period of time, perhaps $\Delta t \ll 1$ in this example, the approximation to an "instantaneous" change has little bearing on the final outcome. So every time you see a velocity against tine graph with some sort of "corner", where a gradient (= acceleration) cannot be found, you have to think that the corner is actually rounded but that rounding occurs over a very short period of time compared with the time scale of the whole motion it matters not a lot. Another example is of problems where a ball rebounds from the ground and you have to find the time it takes to reach a certain height after the rebound. It is unlikely that you consider the time that the ball is in contact with the ground and slowing down with an acceleration much greater than $g$ (acceleration of free fall) stopping and then initially accelerating upwards at an acceleration greater than $g$. Usually the sums are done assuming that the acceleration is $g$ all the time because the time that the ball is in contact with the ground is so much smaller than its time of flight through the air.
{ "domain": "physics.stackexchange", "id": 98257, "lm_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, kinematics, acceleration, projectile", "url": null }
c++, performance, c++11, file-system, boost void extractFiles(const std::string& p) { std::vector<path> files; std::vector<std::string> errors; // for files that might cause errors try { path filepath = p; for (auto& i : directory_iterator(filepath)) { changeTag(i.path()); } } catch(const filesystem_error& e) { errors.push_back(e.what()); // output later after all files have been processed } if (errors.size() > 0) { std::cout << "Some operations failed with errors:" << '\n'; for (auto& i : errors) { std::cout << i << '\n'; } } } int main() { std::string dir; while (true) { std::cout << "Directory: Enter 'x' to close: "; std::cin >> dir; if (dir == "x") { break; } extractFiles(dir); } } How can I improve this code? How can I make this faster, cleaner and better? Here are some things I see that may help you improve your code. Add error checking In your changeTag routine, a segfault can occur if there is no file. Add this just after the FileRef line: if(!file.isNull() && file.tag()) {
{ "domain": "codereview.stackexchange", "id": 15443, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c++, performance, c++11, file-system, boost", "url": null }
ros2 Title: incomplate build Hello, I am using humble and moveit2 on ubuntu 22.04 with kernel 5.15.0-33-generic. Terminal windows terminating it self while colcon building. Details; GPU: nvidia-smi Fri May 27 14:38:08 2022 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 510.73.05 Driver Version: 510.73.05 CUDA Version: 11.6 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |===============================+======================+======================| | 0 Quadro P1000 Off | 00000000:01:00.0 Off | N/A | | N/A 55C P8 N/A / N/A | 5MiB / 4096MiB | 0% Default | | | | N/A |
{ "domain": "robotics.stackexchange", "id": 37717, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "ros2", "url": null }
javascript, physics m0[0] = (m2[0] * dt2 + m1[0]) * dt + m0[0]; m1[0] = m2[0] * dt + m1[0]; m0[1] = (m2[1] * dt2 + m1[1]) * dt + m0[1]; m1[1] = m2[1] * dt + m1[1]; aM[0] = (aM[2] * dt2 + aM[1]) * dt + aM[0]; aM[1] = aM[2] * dt + aM[1]; } Whats the gain Arguably there is some loss in readability, personally it makes a lot more sense than a collection of arrays iterators and copying. But the gain is (tested on chrome) huge. // tested on random set of 1000 objects // µs is 1/1,000,000th second. OPS is operations per second. // An operation is a single call to the function being tested. Optimized..: MeanTime 0.175µs OPS 5,710,020 Test Total 322ms 1,836,000 operations Original...: MeanTime 4.198µs OPS 238,185 Test Total 6,566ms 1,564,000 operations The optimized version is 25 times faster, able to do 5.7million operations in the same time as the original could do 0.3million Is readability more important than performance? for games you must seriously consider what you lose via traditional coding styles.
{ "domain": "codereview.stackexchange", "id": 35846, "lm_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, physics", "url": null }
c++, beginner, vectors, median for (int i = 0; i < temps.size(); ++i) cout << temps[i] << ", "; As stated before, temps.size() returns an unsigned value. The comparison i < temps.size() is a signed-unsigned mismatch. If temps contains more values than i can represent, you'll have a bug. If you are simply accessing the elements and don't need to apply transformations on the index, use the range-based for loop. for (auto temp : temps) std::cout << temp << ", ";
{ "domain": "codereview.stackexchange", "id": 32409, "lm_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, vectors, median", "url": null }
inorganic-chemistry, thermodynamics, melting-point Title: Chemical reaction between dichloromethane and solid carbon dioxide I studied heat transfer liquids with low melting point (coolants), and how fast their temperature decreases when they are contacting with solid carbon dioxide. Nearly all liquids (brines, glycols etc.) that I studied have similar behavior, except dichloromethane. When I put solid carbon dioxide grains into dichloromethane, the temperature of the liquid dropped nearly immediately! At first, the temperature was $\pu{20^\circ C}$, and after just $\pu{5 s}$ the temperature of the liquid was $\pu{-70^\circ C}$! Do you know why is it possible? When I freezed $\ce{KCl}$-brine, the temperature had been decreasing from $\pu{20^\circ C}$ to $\pu{-40^\circ C}$ for more than $\pu{5 min}$! This property of dichloromethane may be very useful. I think it is due to its low viscosity. Can you help me and explain this phenomenon? In brine cooling happens only on the surface of the solid carbon dioxide and causes the water to freeze there, forming an insulating layer (the same happens with ethylene glycol). In dichloromethane, which freezes below $-97$ degrees, no freezing occurs. Moreover, carbon dioxide is well soluble in dichloromethane, which makes the heat transfer more efficient. The latter property may cause you problems if you want to use your coolant in closed installations, because after warming the solution may release the excess of carbon dioxide.
{ "domain": "chemistry.stackexchange", "id": 8743, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "inorganic-chemistry, thermodynamics, melting-point", "url": null }
$\ds{\Psi}$ is the Digamma Function and we used its well known integral representation $\ds{\pars{~\gamma\ \mbox{is the}\ Euler\mbox{-}Mascheroni\ Constant~}}$ $$\Psi\pars{z} = -\gamma + \int_{0}^{1}{1 - t^{z - 1} \over 1 - t}\,\dd t\,, \qquad\Re\pars{z} > 0$$
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9883127423485422, "lm_q1q2_score": 0.8400373378973803, "lm_q2_score": 0.8499711699569786, "openwebmath_perplexity": 808.465498045121, "openwebmath_score": 0.9972632527351379, "tags": null, "url": "https://math.stackexchange.com/questions/1863287/conjectured-value-of-int-0-infty-left-fracx-1-ln2-x-frac1-ln-x" }
For the third deal not to be a duplicate, it has to avoid both the first two deals, which happens with probability $1324/1326$, so $q_3 = q_2(1324/1326) = (1326/1326)(1325/1326)(1324/1326)$. And for the fourth deal not to be a duplicate, it has to avoid all of the first three deals, so $q_4 = q_3(1323/1326) = (1326/1326)(1325/1326)(1324/1326)(1323/1326)$. It should be clear by now that $$q_k = \frac{1326}{1326} \cdot \frac{1325}{1326} \cdot \frac{1324}{1326} \cdot \cdots \cdot \frac{1326-k+2}{1326} \cdot \frac{1326-k+1}{1326} = \frac{1326!}{(1326-k)!1326^k}$$ and is terminated by $q_{1327} = 0$, since by the pigeonhole principle, a duplicate is certain to occur by the $1327$th deal. (By convention, we can write $(-1)! = \Gamma(0) = +\infty$, so in some sense, the expression above is applicable even to $k = 1327$.)
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.985496423290417, "lm_q1q2_score": 0.8376435516378518, "lm_q2_score": 0.8499711737573762, "openwebmath_perplexity": 412.72832484710773, "openwebmath_score": 0.6871883869171143, "tags": null, "url": "https://math.stackexchange.com/questions/1242759/when-does-the-probability-of-dealing-2-cards-that-ive-already-dealt-in-a-previo" }
homework-and-exercises, electrostatics, potential-energy What after this? After reading the comment you have made below, I came to realize that the real deal here is that the electric field is not varying as $x$ outside the sphere. The problem here is not the integral (I apologize for that as I did not cross-check). In fact, it seems you are not very clear with the concept of energy density. Energy density is the energy per unit volume. What is important for this question is to realise is that you can use the energy density as a function of $x$ as long as it agrees with the value the electric field would have inside the sphere, and then outside the sphere. Clearly, as you have derived the E-field is varying directly as $x$ inside. If you apply Gauss' law for a region outside the sphere, you get that the electric field varies as $1/x^2$. These fields are clearly different in their functional forms. So what you need to do while calculating the potential energy of the sphere is to add the contribution inside and outside the sphere. i.e. $ U_1 = \int \Omega_1 dV$ having the limits of $x=0$ to $x=R$ (inside the sphere) And $U_2 = \int \Omega_2 dV$ having the limits of $x=R$ to $x \to \infty$. The required potential energy will be: $U=U_1 +U_2$. You would find that $U_1$ is having a number factor of 1/40 as you have found already. And $U_2$ would have a factor of 1/8. Add them together and you get $\frac{3Q^2}{20 \pi \epsilon R}$
{ "domain": "physics.stackexchange", "id": 57157, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "homework-and-exercises, electrostatics, potential-energy", "url": null }
fft, z-transform, transfer-function, frequency-response, laplace-transform Windowing Windowing will be important to minimize distortion in the DFT results. However given we are sweeping the input frequency with time, tapering the signal at the boundaries will reduce the signal levels at these test frequencies. An excellent window choice for this application is the Tukey window as we can selectively taper just the outer edges, while the majority of the window is flat, offering significant performance in frequency even with a relatively small $\alpha$ which is the ratio of the taper portion of the window to the flat portion. Additionally with a low $\alpha$ the resolution bandwidth is minimally impacted. Sampling Rate Given the application will be to use a real tone, the sampling rate needs to be higher than twice the highest frequency over which we would like to measure the transfer function. Number of Samples The number of samples is set based on the resolution bandwidth desired for the transfer function measurement. The number of samples will set the total time duration $T$ of the test signal, which will set the resolution bandwidth of the test according to $1/T$ (as mentioned above, the Tukey window if low $\alpha$ is used will not significantly impact the resolution bandwidth.) Transfer Function With the above considerations, the transfer function is derived by the ratio of the output FFT to the input FFT. This would be a complex function with its associated magnitude and phase components. Demonstration This was done using the same transfer function as the OP used in his own answer for direct comparison to his results (as well as those responses to this question Why does this transfer function estimation not work? System identification) instead of the original one given in the question, repeated here as: $$G(s) = \frac{3}{s^2 + 0.5s +30}$$ In application the transfer function is the unknown, and the objective is to determine the frequency response of this unknown transfer function, and specifically in this case using a real sinusoidal frequency ramp stimulus and FFT's. So this transfer function was used to generate the actual output which was then used along with only the input to predict the frequency response. Below is the resulting estimated frequency response versus ideal showing excellent agreement between the two:
{ "domain": "dsp.stackexchange", "id": 8654, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "fft, z-transform, transfer-function, frequency-response, laplace-transform", "url": null }
tidal-forces Title: What is the real position of the tidal bulge? The wikipage on "tidal accelaeration" has this picture of the tidal bulge: but says that: The average tidal bulge is synchronized with the Moon's orbit, and Earth rotates under this tidal bulge in just over a day. However, Earth's rotation drags the position of the tidal bulge ahead of the position directly under the Moon. As a consequence, there exists a substantial amount of mass in the bulge that is offset from the line On the other hand, this academical article states the opposite: as we move with respect to both tidal bulge and moon, the moon crosses our meridian before we experience the highest tide.] How early? Some books show misleading diagrams with the symmetry axis of the tidal bulges making an angle of 30° or more with the moon. In fact, the angle is only 3°, so the tides are late by about 24(3/360)60 = 12 minutes through the centers of Earth and the Moon Can you say what is the real position of the bulge? it is surely a hard fact not open to interpretations. Do you have access to sites that say where is now the moon and where is the tidal bulge? According to the basic laws of conservation of momentum and energy, a mass moving to a greater radius should be slowed downm and if we add friction the lag of 12 minutes or more makes sense. If the highest point of the bulge is forward wrt to the vertical of the moon, can you explain what stronger force pushes the water in the direction of the spin? I found this site that gives the position of sun and moon, but doesn't show tides
{ "domain": "astronomy.stackexchange", "id": 1724, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "tidal-forces", "url": null }
$$2\int_{0}^{\pi/4}\sin(x)^4\cos(x)^1\,dx =\frac{3}{30\sqrt{2}}$$ $$2\int_{0}^{\pi/4}\sin(x)^6\cos(x)^{-1}\,dx =-\frac{73}{30\sqrt{2}}+4\,\text{arctanh}\tan\frac{\pi}{8}.$$
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9805806518175515, "lm_q1q2_score": 0.8501985022875546, "lm_q2_score": 0.867035771827307, "openwebmath_perplexity": 4024.537863086435, "openwebmath_score": 1.0000100135803223, "tags": null, "url": "https://math.stackexchange.com/questions/2838491/trick-or-indefinite-integration" }
$$\fermi\pars{1} =\color{#66f}{\large\sum_{k = 0}^{n}{1 \over \pars{k + 1}\pars{k + 2}}\, {n \choose k} ={2^{n + 2} - n - 3 \over \pars{n + 1}\pars{n + 2}}}$$ Hint $$\sum_{k=0}^{n}\binom{n}{k}x^k = (1+x)^n$$ Integrate twice both rhs and lhs with respect to $x$ and when finished, plug $x=1$ in your result. • There is no need of integration here. – Tom-Tom Feb 7 '14 at 9:15 • In "mathematic" house are many mansions (adaptation of John 14:2) – Claude Leibovici Feb 7 '14 at 9:19 • I do agree with that, but one may enter into the house without keys to all mansions. – Tom-Tom Feb 7 '14 at 14:35 Sure - you know that $(1 + x)^n = \sum_{k=0} ^n \binom{n}{k} x^k$ from which it follows that $$\frac{(1+x)^{n+1}}{n+1} = \int (1 + x)^n \, \mathrm{d}x = \int \sum_{k=0} ^n \binom{n}{k} x^k \, \mathrm{d}x = \sum_{k=0} ^n \binom{n}{k} \int x^k \, \mathrm{d}x = \sum_{k=0} ^n \binom{n}{k} \frac{x^{k+1}}{k+1} .$$ Based on what I've shown, you can iterate on this method, and allow $x$ to become a certain number, which should give you the closed form you are seeking.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9881308800022474, "lm_q1q2_score": 0.825567080721543, "lm_q2_score": 0.8354835350552604, "openwebmath_perplexity": 536.7621326374015, "openwebmath_score": 0.8002776503562927, "tags": null, "url": "https://math.stackexchange.com/questions/667156/is-there-a-closed-formula-for-sum-k-0n-frac1k1k2-binomnk/667158" }
protein-structure, linux, awk 82.9 1.0 117.0 81.1 -1.0 119.7 83.9 -3.6 119.5 86.8 -1.2 119.9 85.1 0.5 122.9 84.7 -2.8 124.7 88.3 -3.9 123.7 89.8 -0.9 125.5 87.2 -1.3 128.2 88.8 -4.6 129.1 92.3 -3.2 128.8 91.9 -1.8 132.3 91.6 -3.7 135.7 88.3 -5.5 136.6 86.3 -3.2 138.9 85.3 -6.1 141.2 88.7 -7.8 141.0 88.2 -11.1 139.2 87.1 -12.3 135.8 85.6 -10.1 132.9 83.1 -11.6 130.4 81.8 -10.7 126.9 78.9 -12.0 124.9 77.8 -11.6 121.3 74.2 -12.0 120.1 75.2 -13.4 116.7 78.7 -13.1 115.2 77.5 -13.8 111.7 75.7 -10.4 111.7 78.8 -8.2 112.1 80.6 -5.9 109.6 83.7 -7.5 107.9 85.8 -4.8 109.5 84.2 -5.5 112.9 85.6 -9.1 112.6 89.2 -8.1 112.3 88.8 -5.4 114.9 87.8 -8.1 117.3 90.6 -10.6 116.4 93.6 -8.6 117.7 92.2 -8.7 121.2 91.9 -12.5 121.2 95.5 -12.5 120.1 96.5 -10.2 123.0 94.2 -11.8 125.7 93.9 -9.5 128.8 94.7 -11.9 131.7 91.7 -13.9 133.1 89.1 -12.4 130.8 86.3 -14.5 129.1
{ "domain": "bioinformatics.stackexchange", "id": 2415, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "protein-structure, linux, awk", "url": null }
homework-and-exercises, statistical-mechanics, condensed-matter, field-theory I confirmed the given correlation lengths by following section 4.3.1 (pg 154), but looking at two distinct Fourier-space correlation functions, $\chi_{\parallel}$ and $\chi_{\perp}$ : $$\chi_{\parallel}(\vec{q}) = \frac{1}{r + 12 u \langle \phi \rangle^2 + \frac{1}{2} \sum_{i=1}^{m}q_i^2 }$$, $$\chi_\perp(\vec{q}) = \frac{1}{r + 12 u \langle \phi \rangle^2 + \frac{1}{2} \sum_{j=m+1}^d q_j^4 }.$$ The given correlations lengths follow by defining $\xi$ such that $$\chi_{\parallel}(q_i)=\frac{\xi_{\parallel}}{1+(q_i\xi_{\parallel})^2}$$, $$\chi_{\perp}(q_j)=\frac{\xi_{\perp}}{1+(q_j\xi_{\perp})^4}$$ and inserting a value $\langle \phi \rangle^2 =|r|/4u $. I have changed notation to $q_i$ being those with indices between $1$ and $m$ and $q_j$ those with indices between $m+1$ and $d$. Following section 5.1 (pg 214-5), next I will need to retrieve $G(\vec{x},0) = T \chi (\vec{x},0)$ , or at least its scaling $\sim \xi^n$. As I understand it we need $G(\vec{x},0)$ because we have an indication of the size of fluctuations and their relation to mean-field value
{ "domain": "physics.stackexchange", "id": 76507, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "homework-and-exercises, statistical-mechanics, condensed-matter, field-theory", "url": null }
performance, c, reinventing-the-wheel, matrix #define SIZE 4096 #define N_ELS (SIZE * SIZE) #define N_BYTES (sizeof(float) * N_ELS) #define MIN(a, b) ((a > b) ? (b) : (a)) #define N_THREADS 6 #define TILE_SIZE 32 typedef unsigned int uint_t; static void mul_tile(uint_t i0, uint_t i1, uint_t j0, uint_t j1, uint_t k0, uint_t k1, float * restrict A, float * restrict B, float * restrict C ) { for (uint_t i = i0; i < i1; i ++) { for (uint_t k = k0; k < k1; k++) { float a = A[SIZE * i + k]; for (uint_t j = j0; j < j1; j++) { float b = B[SIZE * k + j]; C[SIZE * i + j] += a * b; } } } } typedef struct { float *A, *B, *C; uint_t start_i, end_i; } mul_job_t;
{ "domain": "codereview.stackexchange", "id": 43741, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "performance, c, reinventing-the-wheel, matrix", "url": null }
thermodynamics, food Title: Boiling Pasta resulting in a Torus like shape? I noticed when I was boiling pasta the other day that the pasta uniformly spread out and formed a donut like torus. Why does this happen? Does it have to do with the shape of the pot? I tried to take a picture when it was boiling, but steam got all over my lens. So, this is a more 2d version of what the pasta looked like with boiling (while boiling, the pasta strands were uniform and seemed to be repelled out uniformly from the center of the pot. The walls of your pot act like a thermal sink that transfers heat to the surrounding environment. Therefore, the water temperature gets hotter as you move towards the center of the pot. The cold water then sinks and the hot water pushes up through the center, creating the donut-like torus you are describing.
{ "domain": "physics.stackexchange", "id": 14471, "lm_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, food", "url": null }
mobile-robot, kalman-filter, movement For the process model I thought of x_k+1 = x_k + v_k * cos(heading_k) y_k+1 = y_k + v_k * sin(heading_k) heading_k+1 = heading_k v_k+1 = v_k a_k+1 = a_k curvature_k+1 = curvature_k + a_y_k/v_x_k of course there should be some process noise added, especially for heading, velocity acceleration and curvature because these measurements are rather inaccurate. For heading, velocity and acceleration I would use the previous estimates (or measurements) since no other source except the measurements from the sensors are available. Curvature is computed using the acceleration in (global?) y-direciton and the (global?) velocity in x-direction curvature = a_y/v_x The measurement model looks probably something like this: y = [1 1 1 1 1 0; 0 1 0 0 0 0; 0 0 1 0 0 0; 0 0 0 1 0 0; 0 0 0 0 1 0; 0 0 0 0 0 0]*x where x is the state vector [x-position; y-position; heading (yaw angle); velocity; acceleration; curvature or (yaw rate)] The trajectory must be smooth and should be exactly like the driven path of the leader vehicle. So I think some sort of estimation will be necesseray in order to avoid following the measurements in straight lines, which would lead to an unsteady trajectory. The mesurements of the heading, velocity and acceleration have a rather high variance depending on the situation. My current approach is the following: transform the the noisy leader vehicle state from ego coordinates to global coordinates using the current pose of the ego vehicle $(x_{ego},y_{ego},\theta_{ego})$. estimate an improved (less noisy) trajectory of the leader in global coordinates. backtransform the optimized state estimates from global to ego coordinates using the corresponding ego vehicle pose. It is possible to stay in the ego frame but this seems to need more effort, since it would be harder to tell if the leader or the ego vehicle moved. However, I was told the common approach is the solution in global coordinates.
{ "domain": "robotics.stackexchange", "id": 1188, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "mobile-robot, kalman-filter, movement", "url": null }
orbit, the-moon, the-sun, earth, natural-satellites Has this path been like this since the formation of the Moon? No. The Moon formed at four to six Earth radii, far less than the 40.6 Earth radii figure cited above. The Moon's orbit initially looked like your second image. Do Natural Satellites of other planets also follow the same orbit around the Sun? The massive planets are much further from the Sun than is the Earth and are much more massive than is the Earth. The orbits of most of the moons of Jupiter about the Sun are concave rather than convex. Only the outermost moons of Jupiter have convex orbits about the Sun. A few of Jupiter's innermost moons (Metis, Adrastea, Amalthea, Thebe, Io, and Europa) exhibit the retrograde motion depicted in your first image. With regard to moons whose orbit about the Sun is convex, the distances that correspond to the 259000 km value for the Earth are 129000 km for Mars, 24.1 million kilometers for Jupiter, 24.2 million kilometers for Saturn, 19.0 million kilometers for Uranus, and 32.3 million kilometers for Neptune. Both of Mars' moons orbit close-in. However, all four of the giant planets have moons whose semi-major axis orbit fall outside the corresponding limit.
{ "domain": "astronomy.stackexchange", "id": 4367, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "orbit, the-moon, the-sun, earth, natural-satellites", "url": null }
soft-question Title: A professional physics career without a degree? I learned programming as a child, for fun. Now I am working as a programmer, even though I got a business major degree. I wonder if there are career paths for doing physics other than becoming a researcher in a University or a professor, that are not all about credentials? Although I haven't researched it, you can learn some physics and try to get into computational physics. There is some industry for it out there (e.g the materials sector, though I would doubt they hire anything but Phds). However, if you're a really great programmer and bring in your ideas and experience creating software, with the additional knowledge of being able to conduct simulations of physical systems and conduct solid quantitative analysis, then why not. There is also a market for physics specific software. For example, you can learn electrodynamics and create a (hopefully open source or atleast free ;)) counterpart to Simion. If developing independent software alternative is too much, you can contribute by creating physics modules, writing patches etc. to products like Sage. There are more possible places where you can develop, off the top of my mind the ROOT develeopment team at CERN has two non-physicists working for them. The best strategy I would recommend is to start learning basic physics, and simultaneously research what is going on at the interface of physics and computation. One guide would be to look at the conferences and seminars that are held on the subject and find out what currently engages physicists. For example, have a look at: Physics and Computation 2010 and Conference of Computational Physics. Look at the titles of talks and submitted papers, the workshops, tutorials etc. Find more on the web (keyword search on the arxiv) etc, and you will get a rough idea of the status of the field. Start working on something, make some contributions to open source initiatives or get your own results, basically get some credentials so that employers might pay attention to you and you might find yourself working along with Phds.
{ "domain": "physics.stackexchange", "id": 949, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "soft-question", "url": null }
145^° \$, b = 40° and c = 140° if pair. Each other and ∠AOD = ∠BOC of proof regarding angles being equal when they are opposite per.... Of intersecting lines, the angles opposite each other, then the vertically opposite angles or! Vertex ( where they cross ), NOT up/down and its adjacent angle are supplementary angles, or opposite! Notation. supplementary ( b ) complementary ( c ) adjacent ( D ) equal: All vertically opposite are! And angles Coloring Activity Color Activities vertical angles Activities pair axiom ) …, ∠AOC ∠BOD... Intersection is a type of proof regarding angles being equal when they are equal at... Adjacent angles are equal becomes other pair of vertically opposite angles is equal to 180° but DO form! Of these diagrams are called coterminal angles DO NOT form a linear pair axiom ) … size by an multiple! Shown using the explicit notation. vertical angles Activities point of intersection of them is called as vertically angles...
{ "domain": "iloctech.com", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9669140197044659, "lm_q1q2_score": 0.8348254521788586, "lm_q2_score": 0.8633916099737806, "openwebmath_perplexity": 1344.039299256719, "openwebmath_score": 0.7717637419700623, "tags": null, "url": "https://iloctech.com/sysh4d7z/0c7d45-vertically-opposite-angles-are-equal" }
newtonian-mechanics, forces, energy, work, free-body-diagram $\displaystyle W = \int dW = \int (m \vec g + \vec N) . \vec {dx}$ However, it is much simpler (and gives the same result) if we use conservation of energy to argue that the kinetic energy gained by the block is equal to the potential energy that it loses, which is $mgh$ where $h$ is the vertical distance that it has fallen. To see that these two methods give the same result, notice that $\vec N$ is always perpendicular to $\vec {dx}$, so $\vec N . \vec {dx} = 0$ (in other words, the normal force does no work on the block) and we have $\displaystyle W = \int (m \vec g + \vec N) . \vec {dx} = \int m \vec g . \vec {dx} + \int \vec N . \vec {dx} = m \int \vec g . \vec {dx} = mgh$
{ "domain": "physics.stackexchange", "id": 98036, "lm_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, forces, energy, work, free-body-diagram", "url": null }
java, performance, android, formatting isPressed.add(false); hasBeenPressed.add(false); isHovering.add(false); hasClickedOff.add(false); this.pressNumber = pressNumber; this.doOnClick = doOnClick; this.doOnClickRelease = doOnClickRelease; this.doOnPass = doOnPass; this.doOnRelease = doOnRelease; state.add(STATE_DEFAULT); name.add("button"+(name.size())); } public Button(GUIBase stateDefault, GUIBase statePressed, GUIBase stateReleased, Vector2f position, int pressNumber,int doOnClick, int doOnClickRelease, int doOnPass, int doOnRelease){ this.stateDefault = (stateDefault); this.statePressed = (statePressed); this.stateReleased = (stateReleased); this.position.add(position); this.size.add(new Vector2f(1,1)); this.stateDefault.position.set(0,this.position.get(0)); this.stateDefault.scale.get(0).multiply(this.size.get(0)); this.stateDefault.show.set(0,true); this.statePressed.position.set(0,this.position.get(0)); this.statePressed.scale.get(0).multiply(this.size.get(0)); this.statePressed.show.set(0,false); this.stateReleased.position.set(0,this.position.get(0)); this.stateReleased.scale.get(0).multiply(this.size.get(0)); this.stateReleased.show.set(0,false); isPressed.add(false); hasBeenPressed.add(false); isHovering.add(false); hasClickedOff.add(false);
{ "domain": "codereview.stackexchange", "id": 42976, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "java, performance, android, formatting", "url": null }
quantum-mechanics, harmonic-oscillator Title: Creation and annhilation operator in the Heisenberg picture I am trying to calculate the time evolution of the creation/anni. operator in the Heisenber picture. On this webpage http://quantummechanics.ucsd.edu/ph130a/130_notes/node191.html, they used the Heisenber equation of motion, but instead of using the operators in the Heisenberg picture, they used the operators in the Schrödinger picture. Why does this work? Best Because (assuming a time independent Hamiltonian, operators without subscript referring to Schrödinger operators, those with the subscript $H$ to Heisenberg operators): \begin{align*} [a_H(t), H_H(t)] &= e^{-iHt/\hbar} a e^{iHt/\hbar} e^{-iHt/\hbar} H e^{iHt/\hbar} - e^{-iHt/\hbar} H e^{iHt/\hbar} e^{-iHt/\hbar} a e^{iHt/\hbar} \\ &= e^{-iHt/\hbar} (aH - Ha) e^{iHt/\hbar} = e^{-iHt/\hbar} [a, H] e^{iHt/\hbar} \\ &= e^{-iHt/\hbar} \hbar \omega a e^{iHt/\hbar} = \hbar \omega e^{-iHt/\hbar} a e^{iHt/\hbar} = \hbar \omega a_H(t). \end{align*} Note that $e^{A}e^{-A} = 1$. When looking carefully at the proof, one can see, that this calculation can easily be generalized to prove that $[A_H, B_H] = [A, B]_H$ (we only used the concrete properties of $H$ and $a$ in the last steps).
{ "domain": "physics.stackexchange", "id": 22633, "lm_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, harmonic-oscillator", "url": null }
delta notation: = calculators and Converters ↳ math dictionary ↳ dictionary... Learn what an identity matrix is a square matrix with non-zero determinant is and about its role in most. Non-Zero determinant problem, I 'm newbie and I 'm trying to practice a lot programming... Is always a square matrix with 1 's on the diagonal and zeroes everywhere else I! †³ I ↳ the identity square matrices, the two matrices are said to be 1, 0 1...: Define identity matrix the identity '' matrix is and about its role in matrix multiplication “the... 'S going to be the inverse of each other in matrix multiplication matrix… at! Of identity matrix the cycle again math words from this math dictionary:.... × thing^y = thing^ [ x+y ] modulo 7 dictionary definition of identity matrix,! Exponent rules thing^x × thing^y = thing^ [ x+y ] modulo 7 also the! From midway through, you would go through the cycle 's on the diagonal and zeroes everywhere else its. Matrix”, we are often talking about “an” identity matrix in the linear algebra from through. Travel around within the cycle 4 define identity matrix matrix… Look at the last!. [ x+y ] modulo 7 pronunciation, identity matrix can also be written using the Kronecker notation... Is a square matrix with 1 's on the diagonal and zeroes everywhere.... Its role in the linear algebra 4 identity matrix… Look at the last one find the definition meaning... Matrix can also be written using the Kronecker delta notation: = is … Multiplying by the.... Cycle again exponent rules thing^x × thing^y = thing^ [ x+y ] modulo 7 about “an” matrix... By the identity matrix can also be written using the Kronecker delta notation: = x+y ] 7. 'S going to be square since there is … Multiplying by the identity matrix pronunciation, identity.. You would go through the cycle again delta notation: = any whole number \ ( n\,! Dictionary ↳ I ↳ the identity matrix lot in programming problems linear algebra since... Often talking about “an” identity matrix is the only idempotent matrix with 1
{ "domain": "lockxx.com", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9399133531922388, "lm_q1q2_score": 0.800761807793395, "lm_q2_score": 0.8519527944504227, "openwebmath_perplexity": 979.854458990299, "openwebmath_score": 0.8951935172080994, "tags": null, "url": "https://lockxx.com/wnseq/define-identity-matrix-ed16d3" }
E(y |x). As a reminder, linear regression models are composed of a linear combination of inputs and weights. I tried to do that both with Numpy and. fit follows: np. I typed in the OCTA program from the User's Guide as an example. A word of caution: Polynomials are powerful tools but might backfire: in this case we knew that the original signal was generated using a third degree polynomial, however when analyzing real data, we usually know little about it and therefore we need to be cautious because the use of high order polynomials (n > 4) may lead to over-fitting. If you can describe a method to transmit a C/C++ header file, then I will furnish some code that has worked for 5th order line fit in a production tester. The polyfit method will fit the data to a polynomial with the degree being 2 and return an array of 3 numbers. What I basically wanted was to fit some theoretical distribution to my graph. Linear regression, also called Ordinary Least-Squares (OLS) Regression, is probably the most commonly used technique in Statistical Learning. regexps for parsing (Python is quite well suited for this). 8k points) How do you calculate a best fit line in python, and then plot it on a scatterplot in matplotlib? I was I calculate the linear best-fit line using Ordinary Least Squares Regression as follows:. This post is initialized with a specific solution for only the quadratic polynomial. NET in C#, VB and F#. Many of the principles mentioned there will be re-used here, and will not be explained in as much detail. Ask Question Asked 3 years, 7 months ago. With the single number, there is no unique ordering or definition for the polynomials, so different orderings are used. curve_fit tries to fit a function f that you must know to a set of points. Here is an example of Finding the slope on the log-log plot by. * The polymulx function was added. Transition from IDL to Python. The data set have been fetched from INE (national statistics institute), that data is the EPA (active population survey), that tell us the national total (Spain), both genders. Least Squares Rational Function Apr 21, 2016 · 4 minute read · Comments quant In my paper "Fast and Accurate Analytic Basis Point
{ "domain": "bouhacagne65.fr", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9715639702485929, "lm_q1q2_score": 0.8032033887505842, "lm_q2_score": 0.8267117898012104, "openwebmath_perplexity": 920.895715120783, "openwebmath_score": 0.3821280598640442, "tags": null, "url": "http://zthj.bouhacagne65.fr/polynomial-fit-python.html" }
java, linked-list, generics, mergesort You've used instance methods where static methods would suffice. I would add a private constructor to your class (since no-one needs to construct it) and change all your methods to static methods. Minor point: you can defer the creation of leftVal and rightVal until inside the if statements in your merge method: if (left.getValue().compareTo(right.getValue()) < 0) { Node<T> leftVal = new Node<T>(left.getValue(), null); if (head == null) { head = leftVal; merged = head; } else { head.setNext(leftVal); head = head.getNext(); } left = left.getNext(); } else { Node<T> rightVal = new Node<T>(right.getValue(), null); if (head == null) { head = rightVal; merged = head; } else { head.setNext(rightVal); head = head.getNext(); } right = right.getNext(); }
{ "domain": "codereview.stackexchange", "id": 12792, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "java, linked-list, generics, mergesort", "url": null }
python, performance, gui, pyqt Also, in Python 3 I get a lot of errors because mod isn't set: Traceback (most recent call last): File "qt.py", line 64, in keyPressEvent self.modEvent.emit([x*self.bs/2 for x in mod]) UnboundLocalError: local variable 'mod' referenced before assignment I'd address that with a method like this: def keyPressEvent(self, event): """Move the box with arrow keys.""" if self.mouseOn: return mod = { QtCore.Qt.Key_Up: [0, -1], QtCore.Qt.Key_Down: [0, 1], QtCore.Qt.Key_Left: [-1, 0], QtCore.Qt.Key_Right: [1, 0] }.get(event.key()) if not mod: return self.modEvent.emit([x * self.bs / 2 for x in mod]) Or so; exit early, use declarative syntax (which looks a bit cleaner than a lot of ifs and only use mod when it actually has a value. The save method will raise an error if the user didn't select a filename, so check the return value of getSaveFileName before destructuring it: def save(self): """Save the big image to an image file.""" selection = QtGui.QFileDialog.getSaveFileName(self) if selection: self.view.px.pixmap().save(selection[0]) Zoom level 25% is showing artifacts when the picture isn't big enough. I guess that's somewhat expected, but I'd still rather catch that instead. Style
{ "domain": "codereview.stackexchange", "id": 15064, "lm_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, gui, pyqt", "url": null }
backpropagation Title: "residual error" of LSTM during backprop vs usual "error" What does the residual error mean when we are talking about LSTM? Taken from the middle of section 3 of this paper, where it says: "...of the residual error $\epsilon$" Where $s_0$ is the initial state of the RNN network. Question: how is a residual error different to a usual error? Why to use such a term? Residual errors are the errors that remain after a model has tried fitting to some data. It is the error which resides. People use that term, along with just error or residuals interchangeably, but after a model has been tested, it just means how much of the data cannot be explained by the model. The letter $\epsilon$ is commonly used to explain stochastic noise inherent in (co)-variates of a model, i.e. noise.error that we cannot explain with the given data.
{ "domain": "datascience.stackexchange", "id": 3372, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "backpropagation", "url": null }
quantum-computer, topological-field-theory, anyons $$ Because the algebra is abelian a path around will close up with commutation. This means these four ground states are degenerate. For nonabelian anyons the above algebra, which can be thought of as a transport around the lattice does not close. The transformation of a state $|X_i\rangle\rightarrow |X,_i\rangle$ $=\sum_jU_{ij}|X_j\rangle$ is such that the operator $U_{ij}$ rotates a state into one that is a superposition of the field fluxes. The above algebra is then $x_a\times y_b=N_{abc}z_c$. We no longer have closure of a path around a loop, for now a state or field is mixed with other fields. Further, this means the vacuum degeneracy is broken. All of this obeys braid rules for anyons. That is a subject a bit beyond this post. The abelian anyons are in a sense a global symmetry, while nonabelian anyons have local symmetries and the vacuum degeneracy is broken.
{ "domain": "physics.stackexchange", "id": 60799, "lm_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-computer, topological-field-theory, anyons", "url": null }
quantum-mechanics, schroedinger-equation, hamiltonian, optical-lattices = \begin{bmatrix} v_1 \\ v_2 \\ v_3 \\ v_4 \end{bmatrix} $$ and accordingly, the element of Hamiltonian: $$ H(1,1;2,1) = \langle (1,1)|H|(2,1)\rangle = \langle v_1 |H|v_3\rangle = H_{1,3} $$ Thus to maintain a matrix multiplying a vector. In reality, it increases complicated booking. You have to invent your own way to trace who is who.
{ "domain": "physics.stackexchange", "id": 75386, "lm_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, schroedinger-equation, hamiltonian, optical-lattices", "url": null }
bash, shell, data-management That should work just fine. You say you tried cat and it "didn't work" but since you don't tell us how it failed, I can't really help. The only issues I can think of is that either there are too many files (as in several hundred thousand, whatever the value returned by getconf ARG_MAX on your system which is 2097152 on mine) or, more likely, you are running out of disk space. If it's a disk space issue, you might be able to get around it by adding each file and then deleting it: for i in 1 2 3 4; do for file in NA24694_GCCAAT_L001_R${i}_*fastq.gz; do cat "$file" >> EA00694_GCCAAT_L001_R${i}.fastq.gz && rm "$file" done done IMPORTANT: the command above is destructive. It will delete each file after it has been added to the new one. If everything works fine that's not a problem, but if I've made a mistake or your file names are slightly different you might lose your data. So I strongly urge you to simply run the cat commands in the first section on a machine with enough disk space to deal with them.
{ "domain": "bioinformatics.stackexchange", "id": 987, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "bash, shell, data-management", "url": null }
mathematics, pauli-gates $$=\sigma_z \otimes \sigma_z$$ If you are however looking for a different way to show the equivalence between the operators without using Euler's Identity and whatnot, you can simply write both sides in terms of its matrix elements; since both exponentiations are of diagonal matrices (in the computational basis) their exponentiation is trivial, and really all you have to do is perform 2 simple matrix multiplications.
{ "domain": "quantumcomputing.stackexchange", "id": 3135, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "mathematics, pauli-gates", "url": null }
c++, beginner, c++11, floating-point Other points: Seems you also don't know the conditional-operator (expr ? value-if-true : value-if-false). It can be used to write things better, but beware of getting carried away with it. You are using using namespace std;. That's a bad idea, read "Why is “using namespace std;” considered bad practice?". When you output string- and char-literals consecutively, just concatenate them together. Also, if you have a length-1-string-literal, a char-literal can serve the same purpose more efficiently. Your comments are, I'm sorry to say, useless, as they just rephrase some of the more obvious code. When you use descriptive names, most other comments for describing what code does also become superfluous (exception: doc-comments which will be extracted for bare-bones documentation). Comments are for giving non-obvious reasons for doing things you do, reasons for doing them the way you do them, or describing how you do something. See this good answer by rolfl about how to properly comment.
{ "domain": "codereview.stackexchange", "id": 17220, "lm_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, c++11, floating-point", "url": null }