text
stringlengths
49
10.4k
source
dict
c++, performance, concurrency ////////////////////////////////////////////////////////////////////////////// // Generate the data file. ////////////////////////////////////////////////////////////////////////////// static int rand_in_range(int lo, int hi) { int range = hi - lo; int val = (rand() & 0xff) << 16 | (rand() & 0xff) << 8 | (rand() & 0xff); return (val % range) + lo; } static void run_generate(const char *path) { srand(1234); FILE *f = fopen(path, "wb"); for (int i = 0; i < N_VALUES; i++) { fprintf(f, "%d\n", rand_in_range(MIN_VALUE, MAX_VALUE)); } fclose(f); }
{ "domain": "codereview.stackexchange", "id": 45549, "lm_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, concurrency", "url": null }
condensed-matter G. Kotliar et. al., Review of Modern Physics Vol. 78, 866-951 A. Georges, arxiv:cond-mat/0403123 p.s. a short remark at the end: those functionals are not anymore sole density functionals, but orbital-dependent density functionals
{ "domain": "physics.stackexchange", "id": 6182, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "condensed-matter", "url": null }
java, matrix, floating-point, opengl, garbage-collection public static Matrix4f frustum(final float left, final float right, final float bottom, final float top, final float near, final float far) { return new Matrix4f(new float[] { 2 * near / (right - left), 0.0f, 0.0f, 0.0f, //X column 0.0f, 2 * near / (top - bottom), 0.0f, 0.0f, //Y column (right + left) / (right - left), (top + bottom) / (top - bottom), (near + far) / (near - far), -1.0f, //Z column 0.0f, 0.0f, 2 * near * far / (near - far), 0.0f //Z column }); } public static Matrix4f perspective(final float fovy, final float aspect, final float near, final float far) { float y2 = near * (float)Math.tan(Math.toRadians(fovy * 0.5f)); float y1 = -y2; float x1 = y1 * aspect; float x2 = y2 * aspect; return frustum(x1, x2, y1, y2, near, far); } public static Matrix4f multiply(final Matrix4f... matrices) { Matrix4f output = identity(); for (Matrix4f matrix : matrices) { output = output.multiply(matrix); } return output; } } As far as I see everything is method specific (a local variable) and thus eligible for garbage collection. I have the following questions:
{ "domain": "codereview.stackexchange", "id": 5706, "lm_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, matrix, floating-point, opengl, garbage-collection", "url": null }
Note that we don’t get the exact results due to the fact that [stem]:[\Omega_h = \cup_{K \in \mathcal{T}_h} K] which we use for the numerical integration is different from the exact domain $\Omega = \{ (x,y)\in \mathbb{R}^2 | x^2+y^2 < 1\}$. ### 1.3. Implementation To compile just type ``\$ ./feelpp_tut_myintegrals`` The complete code reads as follows : ``````#include <feel/feel.hpp> using namespace Feel; int main( int argc, char** argv ) { // Initialize Feel++ Environment Environment env( _argc=argc, _argv=argv, _author="Feel++ Consortium", _email="feelpp-devel@feelpp.org" ) ); /// [mesh] // create the mesh (specify the dimension of geometric entity) auto mesh = loadMesh( _mesh=new Mesh<Simplex<2>> ); /// [mesh] /// [expression] // our function to integrate auto g = expr( soption(_name="functions.g") ); /// [expression] /// [integrals] // compute integral of g (global contribution): $\int_{\partial \Omega} g$ auto intf_1 = integrate( _range = elements( mesh ), _expr = g ).evaluate(); // compute integral g on boundary: $\int_{\partial \Omega} g$ auto intf_2 = integrate( _range = boundaryfaces( mesh ), _expr = g ).evaluate(); // compute integral of grad f (global contribution): $\int_{\Omega} \nabla g$ auto intgrad_f = integrate( _range = elements( mesh ), _expr = grad_g ).evaluate();
{ "domain": "feelpp.org", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9732407140980368, "lm_q1q2_score": 0.821313066502541, "lm_q2_score": 0.8438950966654774, "openwebmath_perplexity": 4896.835322820488, "openwebmath_score": 0.7499555349349976, "tags": null, "url": "http://docs.feelpp.org/dev/0.105/08-ComputingIntegrals/" }
organic-chemistry, inorganic-chemistry But then, some inorganic compounds do have carbon too, and there may even be some compounds that some call organic, and others call inorganic, like $CO_2$. As I have felt it, in my learnings so far, it's like inorganic chemistry is the default chemistry and organic chemistry goes a step beyond. But I don't quite grasp the difference. What is the real semantics behind the word "organic"? For example, we humans are made of loads of water, and that's a pretty organic thing to me. But then, water is inorganic. Diamonds are the carbon top of the cake, and do not transmit the idea of being an "organic" thing. Another very confusing thing are polymers, chanins of loads of carbons with other elements, in many shapes and textures. To me, a piece of "plastic" is not a very organic thing, but indeed, they are! That brings the semantics into an even more confusing level. And of course, there must be historical reasons for those chosen words. Could someone please point out where this distinction comes from and why it is important? With all my respect to science and the people who made chemistry a useful thing. This question is not about critics, it's about not knowing the facts, so of course I am the ignorant here. Related and useful: What is the definition of organic compounds? IUPAC is the International Union of Pure and Applied Chemistry, they make recommendations on the nomenclature. IUPAC mentions that the difference between organic and inorganic is not distinct. To quote "The boundaries between ‘organic’ and ‘inorganic’ compounds are blurred." in Brief Guide to the Nomenclature of Inorganic Chemistry R. M. Hartshorn, K.-H. Hellwich, A. Yerin. Since the terminology of organic vs. inorganic is all human classification, it is not a binary system 0 or 1. What we can say now is that traditionally, all organic compounds do contain carbon. It can come from natural sources or purely synthetic. There is no such restriction. Plastic is an organic compound because it contains a lot of carbon chains. Note that this word organic, as used in chemistry, has nothing to with the buzz word used in marketing of organic food, organic fruits, organically grown stuff. The word organic comes from French organique designating the jugular vein, hence related to organs or living beings.
{ "domain": "chemistry.stackexchange", "id": 13739, "lm_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, inorganic-chemistry", "url": null }
boost Title: message_filters-related issue I was following a tutorial on message_filters in order to subscribe to 2 different topics of different type and later use it in a callback function. However, I got a weird long error message as follow: In file included from /usr/include/boost/bind.hpp:22, from /opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/publisher.h:35, from /opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/node_handle.h:32, from /opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/ros.h:45, from /home/shah/code/ros_workspace/point_cloud_drone/src/pointcloud_builder_node.cpp:1:
{ "domain": "robotics.stackexchange", "id": 7718, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "boost", "url": null }
ros, ros-melodic, fanuc How can I install this dependency? did you only git clone https://github.com/ros-industrial/fanuc_experimental.git? If so: that's not enough. When building fanuc_experimental from source, you must also clone ros-industrial/fanuc into the same source space. Originally posted by gvdhoorn with karma: 86574 on 2022-04-29 This answer was ACCEPTED on the original site Post score: 1 Original comments Comment by Theodoro Cardoso on 2022-05-02: Thank you, that solved the issue.
{ "domain": "robotics.stackexchange", "id": 37619, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "ros, ros-melodic, fanuc", "url": null }
evolution, species, speciation Title: Are there any half-evolved animals alive today? I know that there are animals that are "simpler" than other animals but are there any that are half-evolved? Are there any animals with half-evolved functions, like arms, legs, etc? This was part of the original question, but it was incorrect. Saying that every species on the planet is "transitional" is an unacceptable answer because it only works on the assumption that macro-evolution is true. Saying that all the transitional animals just died off also doesn't seem quite right. If all the previous transitional animals just went extinct, then wouldn't we just have a few specialized species alive today? This wouldn't allow for the diversity we see today. I know that there are animals that are "simpler" than other animals but are there any that are half-evolved? Why aren't there living half ape and half humans? Oh come on. You know if Australopithecines or Homo habilis still existed you would be asking "Why aren't there living half Homo habilis and half humans"? And when the other Great Apes go extinct you'll be wondering why there are no transitional forms between humans and monkeys. The answer to that question is, humans are apes; chimpanzees and we are pretty much as close as two species can be; we could have closer forms that survived but we could also have a much bigger gap between us and our closest relatives than we currently do. In other words, any ape is a valid example of something "half-human half-ape". It's like asking for a vehicle that's half-car, half-volvo. Are there animals that are just starting to evolve arms and legs? You mean, modifying fins into limbs in a general movement from water-living to land-living, like the first tetrapods are thought to have done? I like mudskippers. Saying that every species on the planet is "transitional" because there are no ultimate or final species is an unacceptable answer because it only works on the assumption that macro-evolution is true.
{ "domain": "biology.stackexchange", "id": 7049, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "evolution, species, speciation", "url": null }
phylogenetics, hpc, e-utilities Error: The script keep giving below error: 501 Protocol scheme 'https' is not supported (LWP::Protocol::https not installed) No do_post output returned from 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=AKN43077.1 &rettype=gbc&retmode=xml&edirect_os=linux&edirect=11.7&tool=edirect&email=3052771@node126.pri.kelvin2.alces.network' Result of do_post http request is
{ "domain": "bioinformatics.stackexchange", "id": 1582, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "phylogenetics, hpc, e-utilities", "url": null }
ros, build Summary: 120 packages finished [6min 38s] 1 package failed: qt_gui_cpp 3 packages aborted: ament_pyflakes rosidl_typesupport_fastrtps_cpp rviz_rendering 2 packages had stderr output: qt_gui_cpp rviz_rendering 187 packages not processed
{ "domain": "robotics.stackexchange", "id": 37620, "lm_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, build", "url": null }
complexity-theory, terminology, turing-machines, space-complexity if $M_\alpha$ uses more than $t$ bits of workspace on input $x$ before it halts, then we have no requirement for $SU$ if $M_\alpha$ uses at most $t$ bits of workspace on input $x$ we have two requirements for $SU$: $SU$ uses at most $Ct$ units of workspace where $C$ is a function of $\alpha$ but not $t$ or $x$ $SU$ outputs $M_\alpha(x)$ The idea is that for any machine and any input, $SU$ can simulate that machine while using only slightly more space than the original machine. Note that $t$ is a bound on the space that $M_\alpha$ uses, not the space that $SU$ uses. $SU$ cannot be exactly as space efficient as the original machine because simulation requires some overhead, but the point is that the overhead is small as $C$ is fixed for every $\alpha$, no matter how large $x$ is in size. Theorem 1.9. also has some overhead: a machine which stops in $T$ time steps is simulated in $CT\log T$ time steps where $C$ is again some constant independent of $T$ or of the input string.
{ "domain": "cs.stackexchange", "id": 256, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "complexity-theory, terminology, turing-machines, space-complexity", "url": null }
signal-analysis, continuous-signals, laplace-transform, periodic Question How to separate its transient and steady state response? Such as, $ \displaystyle y(t) = y_{tr}(t) + y_{ss}(t) $ At what time t such that the transient vanishes? How many period T of input signal does it take for it to be vanished? I couldn't find any approach since it's difficult to find when the overlapping magnitude became steady. And that depends on the time constant, which results in asymptotic to 0 as t goes to infinity on each summation term. Analytic expression is what I hope for. Let $x_0(t)$ be the part of the input signal $x(t)$ in the interval $[0,T]$: $$x_0(t)=\begin{cases}x(t),&t\in [0,T]\\0,&\textrm{otherwise}\end{cases}$$ The pseudo-periodic input signal is then given by $$x(t)=\sum_{n=0}^{\infty}x_0(t-nT)\tag{1}$$ If $h(t)$ is the impulse response of a causal and stable LTI system, and if $y_0(t)=(x_0\star h)(t)$ is its response to $x_0(t)$, the response to $x(t)$ is given by $$y(t)=\sum_{n=0}^{\infty}y_0(t-nT)\tag{2}$$ Since $x(t)$ starts at $t=0$, the response $y(t)$ is composed of a steady-state component and of a transient component. The latter decays to zero because we have assumed that the LTI system is stable. The steady-state response is the response that would be observed if the input were periodic, i.e., if it had been switched on at $t=-\infty$. Consequently, the steady-state response is
{ "domain": "dsp.stackexchange", "id": 12076, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "signal-analysis, continuous-signals, laplace-transform, periodic", "url": null }
• I think I answered that question here. – Raphael Feb 16 '16 at 23:53 They're not the same, but the one in Wikipedia is a consequence of the simple uniform hashing assumption. Let $E$ be the event that $h(k_1)=h(k_2)$. Let $F_x$ denote the event that $h(k_1)=h(k_2)=x$. Note that $$E = \bigcup_x F_x,$$ and the events $F_x$ are disjoint. Therefore, $$\Pr[E] = \sum_x \Pr[F_x].$$ Now under the simple uniform hashing assumption, \begin{align*} \Pr[F_x] &= \Pr[h(k_1)=x \land h(k_2)=x]\\ &= \Pr[h(k_1)=x | h(k_2)=x] \times \Pr[h(k_2)=x]\\ &= \frac{1}{m} \times \frac{1}{m}\\ &= \frac{1}{m^2}. \end{align*} Plugging in, we find $$\Pr[E] = \sum_x \Pr[F_x] = \sum_x \frac{1}{m^2} = \frac{1}{m}$$ since there are $m$ possible values of $x$. Therefore, if the simple uniform hashing assumption holds, then the equation you found in Wikipedia also holds. The reverse isn't necessarily true. • sorry for my ignorance, but how is it that your explanation shows my suggestion is wrong? – Charlie Parker Feb 16 '16 at 2:17 • @CharlieParker, what suggestion? I wasn't trying to show that your suggestion is wrong: I was trying to explain the relationship between these two notions, and why. – D.W. Feb 16 '16 at 5:13
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9658995767417299, "lm_q1q2_score": 0.8069932027762241, "lm_q2_score": 0.8354835452961427, "openwebmath_perplexity": 501.8402383856353, "openwebmath_score": 0.9896071553230286, "tags": null, "url": "https://cs.stackexchange.com/questions/53159/different-probabilistic-statement-for-simple-uniform-hashing?noredirect=1" }
an easy-to-understand language. Answers on the back. Chapter 4 : Multiple Integrals. In this article, let us discuss what. Translate v. differential calculus questions and answers. 1In fact, the interconnections are even richer than this development indicates. Students who take this course are expected to already know single-variable differential and integral calculus to the level of an introductory college calculus course. 9: 5, 6, 9 (Use Lagrange's method. Your answer should be in the. GATE MATHEMATICS LECTURE/ VECTOR ANALYSIS PART 1 by BANK ON GATE 2 years ago 37 minutes 534 views vector calculus , pdf , vector calculus book , pdf , vector calculus , notes , vector calculus , physics pdf , vector calculus book vector calculus , IIT JAM 2019 VECTOR CALCULUS DETAILED SOLUTIONS. Short Answer Type Questions. The version available for viewing in a web browser is the most complete, integrat-ing all of the components of the book. Let Dbe the upper half of the unit disc, given by x2 +y2 1;y 0. t/k, is the speed of the particle. 30q 12 m 60q 150q 15 m s x x x y y y add the following vectors. The reason is that this book is a complete package of mathematics for any undergraduate engineering branch. We denote vectors by lowercase. Calculus is a branch of mathematics focused on limits, functions, derivatives, integrals, and infinite series. than 10 percent of the problems in the fifth edition are new. There is just so much it can offer. YOU are the protagonist of your own life. Vector Calculus 16. FUNDAMENTALS OF LINEAR ALGEBRA James B. A simple menu-based navigation system permits quick access to any desired topic. CALCULUS ENGINEERING MATHEMATICS GATE STUDY MATERIAL PDF – FREE DOWNLOAD ON CIVILENGGFORALL. Questions pertaining to vectors and scalars If you're seeing this message, it means we're having trouble loading external resources on our website. The book's careful contemporary balance between theory, application, and historical development, provides readers with insights into how mathematics progresses and is in turn influenced by the natural world. result that can be a matrix, a vector, or a scalar, depending on the computations involved. Since then, while I have had ample opportunity to teach, use, and even program numerous ideas from vector calculus, tensor analysis has faded from my consciousness. Textbook presents a modern view of calculus enhanced by the use of
{ "domain": "wikibanking.it", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.984810952529396, "lm_q1q2_score": 0.8206671823606395, "lm_q2_score": 0.8333245891029457, "openwebmath_perplexity": 1036.9361832440816, "openwebmath_score": 0.6265687346458435, "tags": null, "url": "http://wikibanking.it/vector-calculus-questions-and-answers-pdf.html" }
acoustics, terminology, absorption, attenuation Title: Are absorption and attenuation the same thing? Are absorption and attenuation different words for the same thing? Wikipedia separate has articles on Absorption (Acoustics) and Accoustic Attenuation. I don't see a clear physical distinction between these two concepts, but I also don't know much about acoustics. Both seems to measure how much energy is dissipated from a wave passing through a material. Are they genuinely different, or is this a case of different areas having their own terminology? Attenuation is the reduction of power in a signal/wave/whatever-suits-your-field, and absorption is one process of attenuation. However, there are other sources of attenuation as well, such as scattering/reflection of acoustic waves off of surfaces for example. Attenuation and absorption are both terms used in a variety of different fields. In my own for example, photonics we experience attenuation through absorption, scattering and reflections as well. These three are different processes with results in attenuation of a signal. You can view maybe attenuation as the opposite of gain/amplification.
{ "domain": "physics.stackexchange", "id": 62935, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "acoustics, terminology, absorption, attenuation", "url": null }
javascript, jquery <div id="cancelModel" class="modal modal-danger" hidden> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <h4 class="modal-title">Cancel Ordering</h4> </div> <div class="modal-body"> <p>Are you sure you want to cancel? New order will not be saved.</p> </div> <div class="modal-footer"> <button type="button" data-dismiss="modal" class="btn btn-outline pull-left">Continue Reordering</button> <button type="button" onclick="revert()" data-dismiss="modal" class="btn btn-outline">Revert Changes</button> </div> </div> </div> </div>
{ "domain": "codereview.stackexchange", "id": 15467, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "javascript, jquery", "url": null }
cc.complexity-theory, quantum-computing, physics The fine structure constant itself is not something for which anyone knows a purely theoretical formula. So getting more digits of $\alpha$ is a fundamentally different problem from getting more digits of $\pi$. That being said, the challenges are both experimental and computational. Various experiments in particle accelerators and atomic physics laboratories are dedicated to making progressively more precise measurements of fundamental constants such as $\alpha$. Often, the high-precision theoretical calculation of the factors relating the experimentally observed quantities (such as scattering probabilities or spectral lines) to fundamental constants of interest such as $\alpha$ is very difficult and computationally heavy. The computational side can be just as much a limiting factor as the experimental side in these precision metrology problems. (Some of my coworkers at NIST specialize in this sort of thing.) In the quantum algorithm that Keith and John and I developed, we do not use a perturbative expansion in powers of the coupling constant. The simulation algorithm is much more directly analogous to an actual experiment. However, one advantage over experiment is that in a simulation we are free to change $\alpha$ to whatever value we want. So, by computing scattering amplitudes at varying $\alpha$ it might be easier to determine the individual coefficients $c_k$ than it is in the real world. However, the study of quantum algorithms for simulating quantum field theories is in its infancy. The extraction of such coefficients is one of the numerous interesting questions that have not really been explored yet! Also, our algorithms don't yet tackle QED but rather some simplified models.
{ "domain": "cstheory.stackexchange", "id": 2998, "lm_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, quantum-computing, physics", "url": null }
ros, ros2, colcon Originally posted by nuclearsandwich with karma: 906 on 2018-10-04 This answer was ACCEPTED on the original site Post score: 1 Original comments Comment by alsora on 2018-10-04: Thank you, I didn't noticed that part in the README and probably for some reason I had the ROS1 environment sourced when I compiled the first time. Comment by nuclearsandwich on 2018-10-04: @alsora do you mind updating your question title to be ros1_bridge specific. I think it has the potential to help others who encounter the same issue but the title won't be searchable for someone having issues with the ros1_bridge rather than with --merge-install. Comment by alsora on 2018-10-04: Sure! I have also sent a PR to that repo, since using Colcon there was not even a warning message that something was missing... That's why I was searching the solution somewhere else rather than in the ros1_bridge docs
{ "domain": "robotics.stackexchange", "id": 31854, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "ros, ros2, colcon", "url": null }
c++, performance, algorithm, machine-learning Title: C++ performance: Linear regression in other way Here is the code that can be used for calculation of mathematical function, like ax^2 + bx + c. It is fast enough if you choose small length, otherwise if programmer don't know the small range, that code can be really slow. I've made it specially on C++ to be more fast. #include <iostream> #include <vector> using namespace std; template<class var> var Module(var x){ if (x >= 0) return x; else return x*-1; } class Linear { public: float resA, resB, resC; float err; float Predict(float a, float b, float c, float x) { return ((a * (x*x)) + (b*x) + c); } float Predict(float x) { return ((resA * (x * x)) + (resB * x) + resC); } float ErrorAv(float a, float b, float c, vector<float> input, vector<float> output) { float error = Module(Predict(a, b, c, input[0]) - output[0]); for (int i = 1; i < input.size(); i++) error = (Module(Predict(a, b, c, input[i]) - output[i]) + error)/2; return error; } void LinearRegr(vector<float> input, vector<float> output, float maximum, float minimum = 0, float step = 1) { if (step == 0) step++; float a, b, c; float lastError = INFINITY; for (a = minimum; a <= maximum; a += step) for (b = minimum; b <= maximum; b += step) for (c = minimum; c <= maximum; c += step) { float error = ErrorAv(a, b, c, input, output); if (error < lastError) { lastError = error; resA = a; resB = b; resC = c; err = lastError; if (!lastError) return; } } } };
{ "domain": "codereview.stackexchange", "id": 39957, "lm_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, algorithm, machine-learning", "url": null }
ros, planning-scene, arm-navigation, environment-server //must call revertPlanningScene() first before calling setPlanningScene(). otherwise you'll be blocked in setPlanningScene() collisionModels->setPlanningScene(planning_scene_res.planning_scene);
{ "domain": "robotics.stackexchange", "id": 10631, "lm_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, planning-scene, arm-navigation, environment-server", "url": null }
Note $$\int_0^{\pi} \frac{d \theta}{(3+2cos \theta)^2} = \frac12\int_0^{2\pi} \frac{d \theta}{(3+2cos \theta)^2}.$$ Let $z=e^{i\theta}$ and hence one has \begin{eqnarray} &&\int_0^{\pi} \frac{d \theta}{(3+2cos \theta)^2}\\ &=&\frac12\int_0^{2\pi} \frac{d \theta}{(3+2cos \theta)^2}\\ &=&\frac12\int_{|z|=1}\frac{1}{(3+z+z^{-1})^2}\frac{dz}{iz}\\ &=&\frac12\int_{|z|=1}\frac{z}{(z^2+3z+1)^2}dz\\ &=&\pi\text{Res}(f(z),z=\frac{1}{2}(-3+\sqrt5))\\ &=& \frac{3 \pi \sqrt{5}}{25} \end{eqnarray} where $f(z)=\frac{z}{(z^2+3z+1)^2}$ has a pole at $z=\frac{1}{2}(-3+\sqrt5)$. • thank you, I kept checking over my work and realized I made an algebraic mistake. – idknuttin May 16 '17 at 17:08 • You're welcome. – xpaul May 16 '17 at 17:26 By the substitution $\theta=2\varphi$ and the cosine duplication formula we have
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9828232924970204, "lm_q1q2_score": 0.8273658562903078, "lm_q2_score": 0.8418256492357359, "openwebmath_perplexity": 242.71479642934668, "openwebmath_score": 0.9766444563865662, "tags": null, "url": "https://math.stackexchange.com/questions/2283684/how-to-solve-this-integral-using-the-method-of-residues" }
c++, template-meta-programming, c++17 I would have used std::generate instead of that hand rolled loop: std::generate(first, last, [&rng, &pool]() { return pool[rng()]; }); Use std::vector::empty instead of std::vector::size() == 0. Instead of constructing the generator with the range as arguments, I would pass the range when calling the generator. I would also pass the range as a constructor argument. This has 2 advantages: You can nicely pass a lambda: random_selector selector{ { 1, 2, 3 }, [](int min, int max) { return 42; } }; You can pass a function, instead of a function object. You're naming is a bit misleading: reference is a const& and iterator is const. Consider changing them to const_reference and const_iterator respectively.
{ "domain": "codereview.stackexchange", "id": 25333, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c++, template-meta-programming, c++17", "url": null }
homework-and-exercises, special-relativity, inertial-frames Those facts follow directly from Lorentz transformation. The general answer for the position of the aliens at $t'=0$, for spaceship moving at speed $\beta$, alien moving at speed $\alpha$, initially a distance $\ell$ from earth (all statements at t=0 in Earth's coordinate system), is $\frac{1}{\gamma}\frac{\ell}{1-\alpha \beta}$, with $\gamma=1/\sqrt{1-\beta^2}$. THIS is the quantity you can divide by the velocity of the aliens in the spaceship's frame, to get the time taken as measured by the spaceship. That looks eerily similar to length contraction and velocity addition, so maybe there's a nice solution using those. [edit] found one! Proceed as follows: Imagine a line parallel to the alien's world line and passing through the origin, in the Earth's frame. Go to a frame where both world lines are vertical: the horizontal distance between the lines expands by a factor of $1/\sqrt{1-\alpha^2}$ and the spaceship is moving at speed $\beta'=\frac{\beta-\alpha}{1-\beta \alpha}$. Now go into the frame where the spaceship is at rest: the new distance shrinks by a factor of $\sqrt{1-\beta'^2}$. So the answer is: $$\ell''=\ell \sqrt{1-\beta'^2}/\sqrt{1-\alpha^2}$$ Chucking this into mathematica (I'm too lazy to actually expand $\beta'^2$!) shows that indeed: $$\ell_0'=\ell\sqrt{1-\beta'^2}/\sqrt{1-\alpha^2}=\ell\frac{\sqrt{1-\beta^2}}{1-\alpha\beta}$$ Dividing by the absolute value of velocity $\frac{\beta-\alpha}{1-\beta \alpha}$ gives:
{ "domain": "physics.stackexchange", "id": 34190, "lm_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, special-relativity, inertial-frames", "url": null }
python, algorithm This kind of data organization is hard to follow and error-prone. It's just about ok here where you only have two puzzles, but imagine having a hundred puzzles — how would you check that puzzle 57 had been entered correctly and not accidentally mixed up with puzzles 56 and 58? The approach I would take would be to represent the puzzles like this: PUZZLES = ''' BASE + BALL = GAMES SEND + MORE = MONEY ''' The advantages of this representation are that it is clear what it means (no need for complex documentation) and it keeps each puzzle on one line, so that adding and removing puzzles is easy. The data structure can easily be processed by splitting each line into its constituent pieces, like this: for puzzle in PUZZLES.strip().splitlines(): addition, result = puzzle.split(' = ') addends = addition.split(' + ') solveCryptarithmeticBruteForce(addends, result, string.digits) The initial letters (that must be non-zero) might include duplicates. So it would make sense to remove duplicates in the same way as you do with uniqueStrs. The function getNumberFromStringAndMappingInfo translates a string by mapping each character through a dictionary. But this can be done using the built-in str.translate method. The way you use this is to call str.maketrans to make the translation table. So instead of: for tup in itertools.permutations(inPossibleNumsAsStr, len(uniqueStrs)): dictCharAndDigit = {} for i in range(len(uniqueStrs)): dictCharAndDigit[uniqueStrs[i]] = tup[i] I would write: for perm in itertools.permutations(inPossibleNumsAsStr, len(uniqueStrs)): decipher_table = str.maketrans(uniqueStrs, ''.join(perm)) def decipher(s): return s.translate(decipher_table) and then instead of: result = getNumberFromStringAndMappingInfo(inResultStr, dictCharAndDigit)
{ "domain": "codereview.stackexchange", "id": 31785, "lm_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, algorithm", "url": null }
quantum-mechanics, quantum-field-theory, string-theory, virtual-particles, string-field-theory Title: Where do virtual particles come from? Do I understand correctly that for the existence of virtual particles, a single physical object is needed - a quantum field? And virtual particles are excitations of this field that fills all space. In this case, what are virtual strings, because in string theory there is no "string field" from which they could be born? String fields indeed exist. It is usually stated in introductory courses in string theory that string fields do not really exist because off-shell string amplitudes are incompatible with world-sheet symmetries. Heuristic argument: I will give an example to illustrate how worldsheet symmetries force string states (via the operator-state map) to be on-shell. Consider the vertex-operator for a closed string tachyon $$ \int d^{2}{\sigma} \sqrt{g} :e^{ikX}:$$ In locally flat coordinates we have the replacement $$\int d^{2}{\sigma} \sqrt{g} e^{ikX} \rightarrow \int d^{2}{z} e^{ikX}$$ where we can turn $d^{2}{z}:e^{ikX}:$ into a tensor of type $(0,0)$ by noticing that $d^{2}{z}$ is of type $(1,1)$ and choosing $k^{2}=-m^{2}=\frac{4}{l_{S}}$. Notice that this latter choice is the only consistent with worldsheet Weyl invariance and is precisely the light-cone mass-shell condition. See chapter 3, section 3.6, page 103 of Polchinski's textbook (Vol. 1) for an argument for general vertex operators. The idea is the same, namely that worldsheet symmetries fix the conformal dimension of general vertex operators forcing them to be in the mass-shell. Conceptual argument: See the excellent blog post Observables in quantum gravity or my answer to String amplitudes for finite times and string wave-functions.
{ "domain": "physics.stackexchange", "id": 72863, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "quantum-mechanics, quantum-field-theory, string-theory, virtual-particles, string-field-theory", "url": null }
java, multithreading, thread-safety private final String userId; public Task(String userId) { this.userId = userId; } public String call() throws Exception { String url = createURL(userId); // make a HTTP call to the URL RestTemplate restTemplate = new RestTemplate(); String jsonResponse = restTemplate.getForObject(url, String.class); return jsonResponse; } // create a URL private String createURL(String userId) { String generateURL = somecode; return generateURL; } } Is this the correct and efficient way of doing this problem? How about the exception handling? Do I need any other catch blocks at any places? Late answer to this question..... There are a few things which should be considered when implementing a solution like this, and best-practice comes in to play here. One nit-pick ... before we go further, your interface the methods executeAsynchronous and executeSynchronous, whereas your implementation has executeAsync and execute. This is a carelessly posted question? What you have, at the moment, works, but is it the best way? I don't think so. You code has a few features that are important: executeSynchronous() - waits until you have a result, returns the result. executeAsynchronous() - returns a Future immediately which can be processed after other things are done, if needed. it has a private getHandle() method which does the hard work of creating a Callable, and returning a future.
{ "domain": "codereview.stackexchange", "id": 6039, "lm_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, multithreading, thread-safety", "url": null }
ros, ros2, hardware-interface Title: Is there an implementation of JointStateInterface, EffortJointInterface, PositionJointInterface and VelocityJointInterface in ros2? Hi. Sorry for all mistakes, English is not my native language. So, I have folloing lines of code in my ros1 project hardware_interface::JointStateInterface js_interface_; hardware_interface::EffortJointInterface ej_interface_; hardware_interface::PositionJointInterface pj_interface_; hardware_interface::VelocityJointInterface vj_interface_; I have a problem with understanding, how this lines should look in ros2 Foxy. I'll appreciate any help. As far as I know EffortJointInterface can be used in Galactic and all newer version, but I could be wrong. Originally posted by Edvard on ROS Answers with karma: 95 on 2022-10-13 Post score: 0 You may start with https://control.ros.org/master/doc/getting_started/getting_started.html And https://control.ros.org/master/doc/differences_to_ros1/differences_to_ros1.html Originally posted by duck-development with karma: 1999 on 2022-10-13 This answer was ACCEPTED on the original site Post score: 0 Original comments Comment by Edvard on 2022-10-14: Thank you for reply. I read those two yesterday, and maybe I miss something, but there are no answer for this particular question in there. All that I get is assumption, that JointTrajectoryController is doing something similar to JointStateInterface, but still, maybe I am wrong here Comment by duck-development on 2022-10-14: As here written github ros_control's JointStateInterface, EffortJointInterface, PositionJointInterface, VelocityJointInterface, *InterfaceProvider functionalities have been replaced by RobotHardware.
{ "domain": "robotics.stackexchange", "id": 38041, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "ros, ros2, hardware-interface", "url": null }
coordination-compounds, transition-metals, crystal-field-theory, ligand-field-theory Title: Deriving population of $t_{2g}$ orbitals in transition metal oxides I have recently studied ligand field theory but there is one thing I do not understand. Consider an octaedral geometry of ligands around a transition metal with a $t_{2g}$ - $e_g$ splitting of atomic $d$-orbitals due to bonding with the ligands. Suppose that the gap between the two is very large and electrons can only populate $t_{2g}$ orbitals. My question is: how do I understand how many electrons populate the $t_{2g}$ orbitals knowing the number of electrons in the atomic d orbitals? Originally I thought they were just the same, but apparently they are not! For example, in this paper https://journals.aps.org/prl/pdf/10.1103/PhysRevLett.107.256401 the authors consider e.g. SrMnO$_3$ and they say that in this case the $t_{2g}$ is half filled with 3 electrons. However Mn has 5 valence electrons. Why is that? I am a layman in chemistry, so please be patient if this is a silly question! There is more to this question than meets the eye. First I answer with the OP's assumption that the metal ions are "low spin" — meaning because all the $t_{2g}$ orbitals are fully occupied before any of the hugher $e_g$ orbitals start to be populated. Then I will assess the accuracy of this assumption. (Hint: it's about as accurate as my typing. I had to make a lot of corrections and probably missed some.) In this discussion I assume octahedral coordination, which covers at least most oxides. I'll let the reader work out the corresponding situation with tetrahedral coordination, if that comes up. There are three $t_{2g}$ orbitals, and in the low-spin case they would hold the first six $d$ electrons from the metal ion. Thus we render the count of $t_{2g}$ electrons based on the number of valence $d$ electrons in the metal ion:
{ "domain": "chemistry.stackexchange", "id": 17725, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "coordination-compounds, transition-metals, crystal-field-theory, ligand-field-theory", "url": null }
c#, performance, game, state-machine Title: Increase difficulty based on score What I'm trying to do is very straightforward and easy, but I am wondering whether there is a more elegant solution. Basically I have a game and I want the difficulty to increase the moment the score gets between 100 - 500, then increase once again when the score is between 500 - 1500, then again when the score is between 1500 - 3000. In total, the difficulty should increase 3 times. I need to check: Whether I am in one of those ranges. Whether I already increased the score when I got in that range. Here's what I've got. bool Increased100500 = false; bool Increased5001500 = false; bool Increased15003000 = false; void IncreaseScore() { if (Score >= 100 && Score <= 500 && !Increased100500) { Increase(); Increased100500 = true; } else if (Score >= 500 && Score < 1500 && !Increased5001500) { Increase(); Increased5001500 = true; } else if (Score >= 1500 && !Increased15003000) { Increase(); Increased15003000 = true; } } LE: I should have mentioned that the method above is called multiple times per frame. Be careful with your inequalities. You've listed 500 twice: once as if (Score <= 500) and again as else if (Score >= 500). That's confusing, as the first condition takes precedence. I think that you would be better off with one state variable representing the current difficulty level. The code would also be simpler if you determine NewDifficulty using a level-triggered rather than edge-triggered mechanism. int Difficulty; void IncreaseScore() { int NewDifficulty = (Score < 100) ? 0 : (Score <= 500) ? 1 : (Score <= 1500) ? 2 : 3; // One-way ratchet: difficulty can only increase, even if the // score subsequently drops. if (NewDifficulty < Difficulty) { Difficulty = NewDifficulty; } }
{ "domain": "codereview.stackexchange", "id": 41612, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c#, performance, game, state-machine", "url": null }
vba, excel '/================================================== '/ Transpose Data and print to worksheet '/================================================== '/================================================== '/ Re-Populate arrAggregatedData with the transposed data '/================================================== End Sub Public Sub Allocate_Business()
{ "domain": "codereview.stackexchange", "id": 15321, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "vba, excel", "url": null }
to the right place, recalculating the other numbers. Save. In probability theory, conditional probability is a measure of the probability of an event occurring, given that another event (by assumption, presumption, assertion or evidence) has already occurred. Has a state official ever been impeached twice? Free Response Question 1 In a small town, there are three doctors that practice medicine in the town’s clinic. What is the probability a person was in third class given that they survived? The probability that the student knows the answer is 2/3, so that represents the “area” of the Knows circle; the area outside that circle is 1/3. To ask anything, just click here. So this equals = (1/6) / (1/4) = 2/3, which can’t be true. We have also provided number of questions asked since 2007 and average weightage for each subject. Then we can fill in P(K’∩C) = 1/12 from our work before (which does turn out to be useful), and add up to find that P(C) = 2/3 + 1/12 = 3/4. If not they have to guess from the 3 or 4 choices. Sharing research-related codes and datasets: Split them, or share them together on a single platform? Finally, P(K | C) = P(K∩C) / P(C) = (2/3) / (3/4) = 8/9. Are there ideas for remember for the future? Summary. X represent the event that the student knows the correct answer, Let Y the probability they will know the answer to a question is 0.5, the probability that they will be able to eliminate one choice is 0.25, otherwise all 4 choices seem equally plausible. Have you thought about P(C’ ∩ K) or P(C’ | K)? How to solve Aptitude Probability problems? Sometimes it turns out that the problem is defective, because the correct answer is not in the list; knowing that can save a lot of struggle. Can I colorize hair particles based on the Emitters Shading? Conditional Probability. SURVEY . choices seem equally plausible. 5-a-day Workbooks. This quiz on Conditional Probability is a cracker, but can you crack it, and get 10 out of 10? GATE 2019 CSE syllabus contains Engineering
{ "domain": "nazwa.pl", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9770226300899745, "lm_q1q2_score": 0.8055179618244943, "lm_q2_score": 0.8244619285331332, "openwebmath_perplexity": 1204.1833417542236, "openwebmath_score": 0.39735767245292664, "tags": null, "url": "https://kampro.nazwa.pl/overnight-spot-xjquz/conditional-probability-multiple-choice-questions-b6b824" }
quantum-field-theory, general-relativity, mathematical-physics, gauge-theory, spinors $$g_{ab}\to g_{ab}+\mathcal{L}_\xi g_{ab}$$ where $\xi$ is our vector field. The Lorentz group $SO(1,3)$ is a subgroup of the diffeomorphism group. In addition, the Killing vectors are those which produce no gauge perturbation of the metric, i.e. $$\nabla_\mu X_\nu -\nabla_\nu X_\mu=0$$ These Killing vector commutators may form a Lie algebra of a Lie group $G$; the generators $T_a$ of a Lie group $G$ allow us to define the structure constants, $$[T_a,T_b]=f^{c}_{ab}T_c$$ where $f$ are the structure constants, modulo some constants according to convention.
{ "domain": "physics.stackexchange", "id": 13606, "lm_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, general-relativity, mathematical-physics, gauge-theory, spinors", "url": null }
predictive-modeling, churn, aggregation, survival-analysis Title: Can I apply survival analysis to predict if a user will revisit the website? I have one business problem in hand which is to predict if a user will revisit the website or not within 6 months. I need to majorly understand what are the factors which make the user return and also need to give business recommendations on what can be done to make a new user return to the website. My initial idea was to do logistic regression. Lately, I read about survival analysis. I want to know if I can use survival analysis for this problem. Also, my dataset has 20k users; each user having multiple transactions; the target variable was not given I aggregated the dataset to one record per user and did some feature engineering to come up with a target variable. If I want to use survival analysis in this problem, shall I consider only the last transaction of each user or shall I use the aggregated dataset? If you want to use survival analysis (which can be more flexible and insightful), I'd recommend this package and this great tutorial. Speaking shortly, as a result, you'll get "probability of being alive" for each customer. If you want to use logistic regression I think it's trickier. Why I think so - Like any other churn problem, it's hard to define it properly. The definition depends on your task and where the model outcome will be used. Let's say churn is a particular amount of inactivity, e.g. 30 days. You can do an initial analysis of how to find this number. Just pick a particular date (you can do it multiple times) and check % of people who made next transaction. Important thing is - your time period from both sides should be same for all users: if it's a new users he's not able to be inactive for a long period, right? if it's a last date in the dataset (e.g. yesterday) - not all users are not able to perform transaction within 1 day. And you'll get high churn rates. So be attentive to dates.
{ "domain": "datascience.stackexchange", "id": 6298, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "predictive-modeling, churn, aggregation, survival-analysis", "url": null }
mathematics, error-correction, pauli-gates Title: Is the Pauli group for $n$-qubits a basis for $\mathbb{C}^{2^n\times 2^n}$? The $n$-fold Pauli operator set is defined as $G_n=\{I,X,Y,Z \}^{\otimes n}$, that is as the set containing all the possible tensor products between $n$ Pauli matrices. It is clear that the Pauli matrices form a basis for the $2\times 2$ complex matrix vector spaces, that is $\mathbb{C}^{2\times 2}$. Apart from it, from the definition of the tensor product, it is known that the $n$-qubit Pauli group will form a basis for the tensor product space $(\mathbb{C}^{2\times 2})^{\otimes n}$. I am wondering if the such set forms a basis for the complex vector space where the elements of this tensor product space act, that is $\mathbb{C}^{2^n\times 2^n}$. Summarizing, the question would be, is $(\mathbb{C}^{2\times 2})^{\otimes n}=\mathbb{C}^{2^n\times 2^n}$ true? I have been trying to prove it using arguments about the dimensions of both spaces, but I have not been able to get anything yet. Yes, the set of tensor products of all possible $n$ Pauli operators (including $I$) form an orthogonal basis for the vector space of $2^n \times 2^n$ complex matrices. To see this first we notice that the space has a dimension of $4^n$ and we also have $4^n$ vectors ( the vectors are operators in this case). So we only need to show that they are linearly independent.
{ "domain": "quantumcomputing.stackexchange", "id": 278, "lm_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, error-correction, pauli-gates", "url": null }
## Using the washer method Find the volume of a solid of revolution formed by revolving the region bounded above by the graph of $f\left(x\right)=x$ and below by the graph of $g\left(x\right)=1\text{/}x$ over the interval $\left[1,4\right]$ around the $x\text{-axis}\text{.}$ The graphs of the functions and the solid of revolution are shown in the following figure. We have $\begin{array}{cc}\hfill V& ={\int }_{a}^{b}\pi \left[{\left(f\left(x\right)\right)}^{2}-{\left(g\left(x\right)\right)}^{2}\right]dx\hfill \\ & =\pi {\int }_{1}^{4}\left[{x}^{2}-{\left(\frac{1}{x}\right)}^{2}\right]dx\phantom{\rule{0.2em}{0ex}}\text{}\phantom{\rule{0.2em}{0ex}}={\pi \left[\frac{{x}^{3}}{3}+\frac{1}{x}\right]\phantom{\rule{0.2em}{0ex}}|}_{1}^{4}=\frac{81\pi }{4}\phantom{\rule{0.2em}{0ex}}{\text{units}}^{3}.\hfill \end{array}$ Find the volume of a solid of revolution formed by revolving the region bounded by the graphs of $f\left(x\right)=\sqrt{x}$ and $g\left(x\right)=1\text{/}x$ over the interval $\left[1,3\right]$ around the $x\text{-axis}\text{.}$ $\frac{10\pi }{3}$ units 3
{ "domain": "jobilize.com", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9901401467331061, "lm_q1q2_score": 0.8000997848207401, "lm_q2_score": 0.8080672089305841, "openwebmath_perplexity": 268.9913704752733, "openwebmath_score": 0.7838997840881348, "tags": null, "url": "https://www.jobilize.com/calculus/course/6-2-determining-volumes-by-slicing-by-openstax?qcr=www.quizover.com&page=4" }
javascript, optimization, library collection = function(array) { return new Collections(array); }; } ()); And here is an exemple of use: var myArray = [{name: 'chicken', size: 1}, {name: 'cat', size: 2}, {name: 'dog', size: 3}, {name: 'horse', size: 4}, {name: 'skunk', size: 2}]; var newArray = collection(myArray) .where(function(animal){ return animal.size == 2 }) .select(function(animal){ return { animalName: animal.name, category: 'mammal', size: 'small' } }) .getArray() // new array : [{animalName: 'cat', category: 'mammal', size: 'small}, {animalName: 'skunk', // category: 'mammal', size: 'small'}] To clarify the use of your global variable "collection" as a namespace for your library, you should assign it directly to a value returned by your Immediately Invoked Function Expression: var collection = (function(){ ... function collection(array) { return new Collections(array); } return collection; }());
{ "domain": "codereview.stackexchange", "id": 2512, "lm_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, optimization, library", "url": null }
keras, tensorflow, dataset, training max_pooling2d_24 (MaxPooling2D) (None, 32, 32, 64) 0 conv2d_126[0][0] __________________________________________________________________________________________________ batch_normalization_138 (BatchN (None, 32, 32, 64) 256 max_pooling2d_24[0][0] __________________________________________________________________________________________________ conv2d_127 (Conv2D) (None, 32, 32, 64) 36928 batch_normalization_138[0][0] __________________________________________________________________________________________________ batch_normalization_139 (BatchN (None, 32, 32, 64) 256 conv2d_127[0][0]
{ "domain": "datascience.stackexchange", "id": 10173, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "keras, tensorflow, dataset, training", "url": null }
general-relativity, covariance Title: Double covariant derivative of tensor Consider the covariant derivative of a type $(0,2)$ tensor given in terms of the connection: $$ h_{ab;c} \equiv \partial_c h_{ab} - \Gamma^d_{ca} h_{db} - \Gamma^d_{cb} h_{ad} $$ What would the term $$ h_{ab;ce} = \nabla_e \nabla_c h_{ab} $$ look like? First term would be $$ h_{ab;cd} = \partial_e \left( \partial_c h_{ab} - \Gamma^d_{ca} h_{db} - \Gamma^d_{cb} h_{ad} \right) + (\ldots) + (\ldots) $$ What about the second one? Not sure how to juggle with the indices here. $$ h_{ab;cd} = (\ldots) + (\Gamma^f_{ea} h_{fb;c} ) + (\ldots) $$ Does that look right? To answer this, you need to know what the covariant derivative of a rank $(3,0)$ tensor looks like. When in doubt, you can just use an example tensor $A_{\nu}B_{\rho}C_{\sigma}$ and use the product rule for the covariant derivative: $$\nabla_{\mu}(A_{\nu}B_{\rho}C_{\sigma})=\left(\nabla_{\mu}A_{\nu}\right)B_{\rho}C_{\sigma}+A_{\nu}\left(\nabla_{\mu}B_{\rho}\right)C_{\rho}+A_{\nu}B_{\rho}\left(\nabla_{\mu}C_{\sigma}\right)\\
{ "domain": "physics.stackexchange", "id": 41574, "lm_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, covariance", "url": null }
general-relativity, gravity, black-holes, differential-geometry, frame-dragging Title: Why Does Spinning Mass Twist Spacetime Massive spinning objects (such as Kerr black holes) 'twist' spacetime around them, as predicted by Einstein's theory of general relativity. Can someone explain qualitatively why this happens? Is there a fairly simple relation between the mass, radius, and angular velocity of the spinning object, and the degree of frame-dragging that occurs. N.B.: I only have a basic understanding of Einstein's field equations and tensor calculus. You can get a qualitative feeling about this effect by looking at the Einstein field equations. $$R_{\mu \nu}-\frac{R}{2}g_{\mu \nu}=8 \pi GT_{\mu \nu}$$ The left hand side describes the curvature of spacetime and the right hand side the energy momentum content. Now a rotating object has a different energy momentum tensor than a nonrotating object (There are extra terms due to angular momentum and rotational energy). Of course the spacetime curvature will react to these extra terms. This leads to the frame dragging you mentioned. However I think there is no simple general relation, which you wish for. There is a solution in a weak field approximation to this problem (Lense Thirring precession), but this of course does not apply to Kerr black holes.
{ "domain": "physics.stackexchange", "id": 45868, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "general-relativity, gravity, black-holes, differential-geometry, frame-dragging", "url": null }
performance, vba, excel k = 0 'Add the text back to a smaller array For j = StartingLine To EndingLine ChunkofFile(k) = FileData(j) k = k + 1 Next 'Build the string name for the new file 'The file name mirrors the parent file, just with an 'iteration number suffix SplitFileName = FSO.GetParentFolderName(FilePath) & "\" & _ FSO.GetBaseName(FilePath) & "_" & CStr(i) & _ "." & FSO.GetExtensionName(FilePath) StartingLine = StartingLine + LinesToRead + 1 'Adjust ending line to read as dividing by the number of files - 'won't divide evenly (most of the time) If i = NumberOfFiles - 1 Then EndingLine = UBound(FileData) Else EndingLine = EndingLine + LinesToRead + 1 End If 'Write the file by joining the array just created FileNumber = FreeFile() Open SplitFileName For Output Access Write As FileNumber Print #FileNumber, Join(ChunkofFile, vbNewLine) Close #FileNumber Next Debug.Print "Rest of Process took: " & Timer - TimeRoutine & " seconds" End Sub Private Function GetTextFileLines(ByRef Path As String) As String() Const MAX_ROWS As Long = 30000000 Dim TextLine As String Dim FileNumber As Integer Dim i As Long Dim TextArray() As String ReDim TextArray(MAX_ROWS) FileNumber = FreeFile Open Path For Input Access Read As #FileNumber Do While Not EOF(FileNumber) Line Input #FileNumber, TextLine TextArray(i) = TextLine i = i + 1 Loop Close #FileNumber ReDim Preserve TextArray(i - 1) GetTextFileLines = TextArray End Function Results The performance is pretty good. I'm processing a ~200MB file into 11 files in about 12 seconds. Debug Messages: Reading and splitting the file took: 4.609375 seconds. The file size is: 219 MBs Rest of Process took: 7.953125 seconds
{ "domain": "codereview.stackexchange", "id": 29528, "lm_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, vba, excel", "url": null }
audio, sound It is really a case of "realism/expressivity/simplicity, pick any two". I am not sure about your goals - how many instrument sounds should your system provide? do you also want to modulate other parameters of sound besides pitch and volume with the accelerometer data? I am not sure either about your target platform (the ST MCUs go from 24 MHz/32kb flash/no FPU to 168 MHz with FPU and DSP instructions and 1M of onboard flash). Another factor to take into account is polyphony - do you want your system to be able to play several notes at the same time? I would recommend: Sampling if you have at least 128kb of flash and need only one sound/instrument, or if you have very limited CPU. Subtractive synthesis if you have less flash and/or need more sounds/instruments ; or if you need to use external sensor data to easily modulate sound parameters besides pitch/volume.
{ "domain": "dsp.stackexchange", "id": 561, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "audio, sound", "url": null }
black-holes Title: Does Stephen Hawking believe that General Relativity is wrong? Stephen Hawking recently said that black holes do not exist. According to Wikipedia, black holes are predicted by General Relativity. So it would seem to follow that Stephen Hawking believes that General Relativity is wrong. Am I missing something? No, he does not think that GR is wrong. Actually, in his article on arxiv, he gives some ideas in order to (try to) solve a problem associated to the information paradox for evaporating black holes. That would mean that the usual idea of black hole we have would not longer be accurate. It does not imply that GR is wrong (at least on the domain of validity where we believe it provides a pretty good description of physics).
{ "domain": "physics.stackexchange", "id": 11567, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "black-holes", "url": null }
c++, design-patterns Title: Observer pattern with different notifications I'm trying to create an observer pattern that the subject notifies the observers with different notifications. Normally in observer pattern implementations you can see only one method called notify where it notifies the observers that something happened and has a kind of inversion where the observer holds the pointer of the subject and ask the subject for something when it's notified. I'm implementing this a little different, where the subject attaches the observers and notify all of them without the needed of holding the pointer of a subject inside of the observers. For example: #include <iostream> #include <vector> class ObserverEvents { public: virtual addSomethingOne(int) = 0; virtual addSomethingTwo(float) = 0; }; class Observer : public ObserverEvents { public: Observer(); ~Observer(); virtual addSomethingOne(int) {} virtual addSomethingTwo(float) {} }; class Subject : public ObserverEvents { public: Subject() {} ~Subject() { for (int i = 0; i < observers.size(); ++i) { delete observers[i]; } } void attach(Observer * observer) { observers.push_back(observer); } virtual addSomethingOne(int something) { for (int i = 0; i < observers.size(); ++i) { observers[i].addSomethingOne(something); } } virtual addSomethingTwo(float something) { for (int i = 0; i < observers.size(); ++i) { observers[i].addSomethingTwo(something); } } private: std::vector<Observer *> observers; }; class FooObserver : public Observer { public: BarObserver() {} ~BarObserver() {} addSomethingOne(int something) { // do something with something } addSomethingTwo(float something) { // do something with something } }; class BarObserver : public Observer { public: BizObserver() {} ~BizObserver() {} addSomethingOne(int something) { // do something with something }
{ "domain": "codereview.stackexchange", "id": 10509, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c++, design-patterns", "url": null }
mechanical-engineering, structural-engineering, mathematics Title: Question regarding calculation of angular velocity connected to coordinate transformation So i need to calculate the angular velocity of the dark disk, $w^*_3$. In the master solution they state it is : $w^*_3 = w_3 + \overline{w_3}$ with : $w_3 = \frac{|\dot{r}|}{4a}$ $|\dot{r}| = v_a + \overline{w_3}\cdot a$ $|\dot{r}| = v_b - \overline{w_3}\cdot 2a$ $ \Rightarrow|\dot{r}| = 2a\cdot (w_S+w_R)$ $\overline{w_3} = \frac{1}{a}(|r|-v_1)=\frac{1}{2a}(v_b-|r|)=\frac{1}{3a}(v_b-v_a)$ $ \Rightarrow \overline{w_3} = 2w_r-w_s$ $ \Rightarrow w_3^* = \frac{5}{2}w_r-\frac{1}{2}w_s$
{ "domain": "engineering.stackexchange", "id": 2860, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "mechanical-engineering, structural-engineering, mathematics", "url": null }
automata-theory, context-free ***ADDENDUM This is an idea to prove that even with the constraint required by domotorp in the question (at each step 1 POP or 1 PUSH or NO CHANGES ) we can recognize all CFLs. The above theorem says that a PDA $P$ that can "look" at the top symbol $X$ of the stack and according to it and the current input symbol can (i) POP it, (ii) REPLACE it with $B$ or (iii) REPLACE it with $B$ and PUSH $C$ is as powerful as a PDA. In order to build an equivalent $P'$, we expand the set of non-terminals $\Gamma$ of $P$ to $\Gamma' = \Gamma \times (\Gamma \cup \{ = \})$; we also expand the set of states $Q$ to $Q' = Q \times (\Gamma \cup \{*\})$ The double symbols in each "register" $r$ of the stack are used to store both the symbol at $r$ (left element) and to "override" the symbol at $r-1$ (right element): <A,B> in P' is equivalent in P to A <C,.> B .... ....
{ "domain": "cstheory.stackexchange", "id": 4755, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "automata-theory, context-free", "url": null }
biostatistics from which it follows that: P(A | B) = P(A) So in your drug example, there is a probability that a person in the study is given the drug, denoted P(drug), and a probability that a person in the study is released, denoted P(released). The probability of being released is independent of the drug if: P(drug ∩ released) = P(drug) * P(released) Release rates can be higher for individuals given the drug, or they can be lower for individuals given the drug, and in either case, release rates would not be independent of drug. So Ha is not P(released | drug) > P(released) rather, it is P(released | drug) ≠ P(released) In your second example, there is a probability that a person is female, denoted P(female), and a probability that a person has attached earlobes, denoted P(attached). These events are independent if: P(attached ∩ female) = P(attached) * P(female) and Ha can be stated as: P(attached ∩ female) ≠ P(attached) * P(female) or equivalently: P(attached | female) ≠ P(attached)
{ "domain": "biology.stackexchange", "id": 6934, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "biostatistics", "url": null }
c#, algorithm, primes, sieve-of-eratosthenes Title: Threshed and Malachi'd: Sieve of Eratosthenes I took a little bit from all the answers to my previous question Threshing: Sieve of Eratosthenes. This may be bordering on code-golfing, but I think that I have a pretty good piece of code here. Is there any major concepts that I am overlooking, although it still seems super simple? var upperLimit = 9999; var primes = new List<long>(); primes.Add(1); primes.Add(2); for (var i = 3; i < upperLimit; i+=2) { primes.Add(i); } for (var i = 7; i < upperLimit; i+=2) { foreach (var number in primes.ToList()) { if (number == i) { continue; } if (number % i == 0) { primes.Remove(number); } } } primes.ForEach(Console.WriteLine); Console.WriteLine("The Last Prime is " + primes[primes.Count - 1]); Console.WriteLine("what are you waiting for? Exit the program!"); Obviously I could start off with all the primes I know by just adding them to start with and then starting my loops higher, but I think that is cheating just a little bit. Is there any way to make this faster and able to calculate (and store) higher numbers using less memory? First problem: 1 is not a prime number. Second problem, after fixing that: Console.WriteLine(string.Join(", ", primes.Take(10))); 2, 3, 5, 7, 9, 11, 13, 15, 17, 19 Third problem: This is not the Sieve of Eratosthenes. To quote Wikipedia (emphasis mine):
{ "domain": "codereview.stackexchange", "id": 8431, "lm_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, primes, sieve-of-eratosthenes", "url": null }
1. Immediately after getting this flipped filter or kernel the convolution consists of a sum of all the entries of a Hadamard product, which really is sort of a "dot product of matrices". What is the name of this matrix operation in general: $$\text{elementwise}\sum\left(\begin{bmatrix}a&b\\c&d\end{bmatrix}\circ \begin{bmatrix}z&w\\v &y\end{bmatrix}\right)=\text{elementwise}\sum\begin{bmatrix}az&bw\\cv&dy\end{bmatrix}=az+bw+cv+dy$$ ? Thanks to @Omnomnomnom the answer to the second question is the Frobenius inner product: For $A = \begin{bmatrix}a&b\\c&d\end{bmatrix}$ and $\begin{bmatrix}z&w\\v &y\end{bmatrix}$, the Frobenius inner product, $\langle A,B \rangle_\mathbf F$ takes two matrices and returns a number. $$\small\sum_{\text{el.wise}}\left(\begin{bmatrix}a&b\\c&d\end{bmatrix}\circ \begin{bmatrix}z&w\\v &y\end{bmatrix}\right) = tr\left(\begin{bmatrix}a&b\\c&d\end{bmatrix}^\top\cdot \begin{bmatrix}z&w\\v &y\end{bmatrix}\right)=tr\left(\begin{bmatrix}a&c\\b&d\end{bmatrix}\cdot \begin{bmatrix}z&w\\v &y\end{bmatrix}\right)=\tiny az+cv+bw+dy$$ and thanks to @Hurkyl
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9504109812297141, "lm_q1q2_score": 0.8020471799365225, "lm_q2_score": 0.8438951104066293, "openwebmath_perplexity": 486.155172651707, "openwebmath_score": 0.6920716762542725, "tags": null, "url": "https://math.stackexchange.com/questions/2203759/mathematical-name-for-the-flipped-matrix-and-the-subsequent-matrix-dot-product-i" }
organic-chemistry, stereochemistry, cis-trans-isomerism J. Verbeek, J. H. Van Lenthe, P. J. J. A. Timmermans, A. Mackor, and P. H. M. Budzelaar. "On the existence of trans-cyclohexene". J. Org. Chem. 1987, 52, 13, 2955–2957. https://doi.org/10.1021/jo00389a067. Michael E. Squillacote, James DeFellipis, and Qingning Shu "How Stable Is trans-Cycloheptene?" J. Am. Chem. Soc. 2005, 127, 45, 15983–15988. https://doi.org/10.1021/ja055388i
{ "domain": "chemistry.stackexchange", "id": 17893, "lm_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, stereochemistry, cis-trans-isomerism", "url": null }
forces, momentum, coulombs-law Title: An Electron Chasing Another An electron is held in place in deep space. Another electron approaches with speed $v_0$. When the approaching electron is a distance $r_0$ away from the first electron, the first is set free. The electrons exert a force $F = \frac{e^2}{4\pi \epsilon r(t)^2}$ on each other, where $r(t) = r_0 - v(t)*t + u(t)*t$, $u(t)$ is the velocity of the first electron, and $v(t)$ is the velocity of the approaching electron. I want to get $v(t)$ in terms of $r_0$ and $v_0$. The initial conditions are $v(0) = v_0$ and $u(0) = 0$. Also $$F=\frac{e^2}{4 \pi\epsilon r(t)^2} = \frac{e^2}{4 \pi \epsilon (r_0 +(u-v)t)^2}= m_e \dot{u} = -m_e\dot{v} \: \: \: \: \:\:\:\:\:\:\:\:\:\:(1)$$ This then gives us $$\dot{u} = -\dot{v}$$. Integrating both sides and applying the initial conditions gives $$u(t) = v_0 - v(t)$$ Plugging this back into $(1)$ and simplifying we get $$\frac{-e^2}{4 \pi \epsilon m} = \dot{v} (r_0 + (v_0-2v)t)^2$$ For $r0 = 1000m$ and $v0 = 100m/s$ I get this plot for $v(t)$:
{ "domain": "physics.stackexchange", "id": 23995, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "forces, momentum, coulombs-law", "url": null }
homework-and-exercises, thermodynamics, statistical-mechanics, differentiation, mathematics Now, you want to find $\left(\frac{\partial S}{\partial T}\right)_H$. This is simple - you need to decompose $dS$ into a linear combination of $dT$ and $dH$ and whatever stands next to $dT$ is your derivative. On the RHS you have terms where $S$ is a function of $T$ and $M$, so a good starting point would be \begin{equation} dS = \left(\frac{\partial S}{\partial T}\right)_M dT + \left(\frac{\partial S}{\partial M}\right)_T dM. \end{equation} And now we only need to get rid of $dM$, so we express it as: \begin{equation} dM = \left(\frac{\partial M}{\partial T}\right)_H dT + \left(\frac{\partial M}{\partial H}\right)_T dH. \end{equation} I will let you solve the rest of the problem. This is probably not as fast as a simple chain rule but gives you a better control of what's happening. I think it allows for easier backtracking of your steps and avoiding silly mistakes.
{ "domain": "physics.stackexchange", "id": 87091, "lm_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, thermodynamics, statistical-mechanics, differentiation, mathematics", "url": null }
quantum-mechanics, optics, quantum-optics, diffraction, discrete Title: A quantum mechanical interpretation of the diffraction formula, $d \sin \theta = n \lambda$ In the single slit diffraction pattern there exists the following formula: $$d \sin \theta = n \lambda$$ I was looking at and thinking about the quantisation condition of energy, $E = nh\nu$, and saw the formula above, and my brain sparked with the idea that the $n$ might be interpreted in relation to quantisation as such. I think this is quite a valid thing to think about because there are phenomena like electron diffraction and so on. What do you think? The number of a particular diffraction minimum $\color{blue}{n}$ in the single-slit diffraction formula $$ d \sin \theta_\color{blue}{n} = \color{blue}{n} \lambda$$ doesn't have a connection to the number of excitations $\color{green}{n}$ of an electromagnetic field mode (in $E_\color{green}{n} = \color{green}{n} h \nu$). The only thing which is quantized in the diffraction pattern is the number of intensity minima, because $\sin \theta \in [-1, 1]$. Therefore, depending on the slit size $d$ there are cases with $\color{blue}{0}$ minima (if $d < \lambda$), cases with $\color{blue}{2}$ minima (if $\lambda < d < 2 \lambda$), and so on.
{ "domain": "physics.stackexchange", "id": 75563, "lm_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, optics, quantum-optics, diffraction, discrete", "url": null }
The left side of the image below shows the mistery vector we are trying to find. The right side of the image below shows projection of $$\vec{A}$$ onto $$\vec{B}$$. The above image shows that the length of $$proj_{\hat{B}} \vec{A}$$ is $$\frac{1}{2}$$ the length of the mistery vector $$\vec{?}$$. You will also notice that the projection $$proj_{\hat{B}} \vec{A}$$ points in the wrong direction. This leads to the conclusion that the reflection $$reflect_{\hat{B}}\vec{A}$$ is two times the projection of $$proj_{\hat{B}}\vec{A}$$ subtracted from the original vector $$\vec{A}$$. The formula describing this is listed below: $$reflect_{\vec{B}}\vec{A} = \vec{A} - 2\frac{\vec{A} \cdot \vec{B}}{\|B\|^{2}}\vec{B}$$ All of the optimizations that applied to vector projection / rejection apply here as well. This means that as long as $$\vec{B}$$ is normalized, no division is necesarry. The formula assuming $$\vec{B}$$ is normalized is listed below. $$reflect_{\hat{B}}\vec{A} = \vec{A} - 2(\vec{A} \cdot \hat{B})\hat{B}$$ Implementing scaling in code is trivial: vec Reflection(vec a, vec b) { float magBsq = MagnitudeSq(b); assert(magBsq != 0); float scale = Dot(a, b) / magBsq; vec proj_2x = Scale(b, scale * 2.0); return Sub(a, proj_2x); }
{ "domain": "gabormakesgames.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9907319879873278, "lm_q1q2_score": 0.836073878441117, "lm_q2_score": 0.8438951084436077, "openwebmath_perplexity": 369.53611763554306, "openwebmath_score": 0.9318389296531677, "tags": null, "url": "https://gabormakesgames.com/blog_vectors_reflection.html" }
bash, linux, shell, awk For testing purposes, the curl command is printed to console instead of running it. It does the job, but I am not satisfied by the super long last command. How can it be improved? Any suggestion is welcome. As @TobySpeight pointed out in a comment, the cat is redundant. Any time you have a line like cat "$file" | grep "$pattern" you can replace it with grep "$pattern" "$file" If your log entries are already ordered by time (at least for each user's login event), you can likely use tac instead of sort -r Can a user have logged in be their user ID? I assume not, but if they can, we have a bug where instead of sending their most recent login, you might send their most recent event of any kind (or something malformatted, might depend on how the rest of the log looks). Either way, if this turns out to be a problem it can easily be worked around by adding an anchor to the grep's pattern, or using grep -x I'm pretty sure the first two awk calls can be combined into a single one like awk -F' ' '!seen[$4]++ { p = index($2, "+"); print $1 "T" substr($2, 1, p-1) "Z", $4 }' By the way, awk looks dense without spaces, and putting some spaces between operators and delimiters are stuff makes it a lot easier to look at Using awk and cut to remove [ and ] seems a bit awkward. Assuming those characters can't appear inside user IDs (since that's how user IDs are delimited it'd be annoying if they could) tr -d '[]' should do the job just fine here Having a long line like that is annoying, but it becomes less annoying if it's split between multiple physical lines. Which is possible, see below Personally, I think it'd look better if you were to pipe your data into the while instead of sending it in from behind using < <(). It's a matter of opinion, but to me it better represents the flow of data and also subjectively looks nicer
{ "domain": "codereview.stackexchange", "id": 41423, "lm_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, linux, shell, awk", "url": null }
catkin, ros-fuerte, ros-electric, rosbuild Originally posted by Lorenz with karma: 22731 on 2012-10-12 This answer was ACCEPTED on the original site Post score: 0 Original comments Comment by Constantin S on 2012-10-15: Hi Lorenz, I am not build a node but a separate c++ program that happens to use ROS libraries... My colleague succeeded in this but he hardcoded a lot of paths. I would like to redo his CMake's with non hardcoded paths so both Electric and Fuerte could be used. Comment by Lorenz on 2012-10-15: That's why I'm saying you should not use rospack find to get the path to a package and generate cflags and lflags from that path but you should use rospack export. In cmake, you can use execute_process and then add the output to your cmake flags. Btw. in fuerte you could also use pkgconfig.
{ "domain": "robotics.stackexchange", "id": 11345, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "catkin, ros-fuerte, ros-electric, rosbuild", "url": null }
graphs, dag Interpreting your graph as a binary relation (since the edges don't really seem to matter to you, you're only interested in the set of vertices), this is exactly what you want: $xR^*y$ if and only if $y$ is a "descendant" (by your meaning) of $x$. When looking at the literature, you will need to know one more piece of notation: the transitive closure of $R$, denoted $R^+$, is the smallest relation $R^+$ such that $R \subseteq R^+$, and $R^+$ is transitive. Algorithms for computing the transitive closure and the reflexive transitive closure are related, since they differ only by the "diagonal" entries: $R^+ \cup \left\{ (x,x)\,|\,x \in X \right\} = R^*$. There are several standard algorithms for computing the RTC of a relation. If the relation is dense, in the sense that it's feasible to represent it as a bit matrix, the Floyd-Warshall algorithm is one of the fastest practical algorithms; its run time is $\Theta(|V|^3)$ in theory, but the inner loop is quite fast on real hardware given that it it a bunch of bit vector manipulations. For sparse relations, see Esko Nuutila's thesis, which contains a very good survey as well as some more recent algorithms.
{ "domain": "cs.stackexchange", "id": 15440, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "graphs, dag", "url": null }
cc.complexity-theory, boolean-functions, pcp, unique-games-conjecture Title: Proof of Majority is stablest in "reverse" in the MAXCUT hardness paper by Khot et al This is about Proposition 7.4 here. I think there is a slight error in the proof of this proposition. Basically, authors have taken $g$ to be the odd part of the function $f$. Due to which we can say that $\mathbb{E}[g] = 0$, $\operatorname{Inf}_{i}(g) \leq \operatorname{Inf}_{i}(f)$ for all $i$, and $S_{\rho}(f) \geq S_{\rho}(g) = -S_{-\rho}(g)$. So, applying MIS on $g$, we get $S_{\rho}(g) \leq 1 - \frac{2}{\pi}\arccos(\rho) + \epsilon$ for $\rho$ from 0 to 1. which implies $-S_{-\rho}(g) \geq -\left(1 - \frac{2}{\pi}\arccos(-\rho) + \epsilon\right)$ for $\rho$ from -1 to 0. Therefore, $$S_{\rho}(f) \geq -1 - \frac{2}{\pi}\arccos(\rho) - \epsilon$$ But in the statement of the proposition, authors have written $S_{\rho}(f) \geq 1 - \frac{2}{\pi}\arccos(\rho) - \epsilon$. Is it really an error? Or I am missing something? "So, applying MIS on $g$"
{ "domain": "cstheory.stackexchange", "id": 4191, "lm_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, boolean-functions, pcp, unique-games-conjecture", "url": null }
telescope, space-telescope, light-pollution Title: Why is Starlink polluting the night sky a big concern if we have space telescopes? There's a lot of concern in the Astronomy community over the deployment of Starlink satellites. For a good discussion, see the related question How will Starlink affect observational astronomy? But why is there so much concern over this problem, given that there are numerous space telescopes? Presumably a lot more will be launched in the upcoming years thanks to satellite launches becoming cheaper. Aren't space-based observations superior in the first place thanks to the lack of an atmosphere? I understand this sucks for amateur astronomers but is it also a big problem for professional researchers? It's a problem because there are still lots and lots and lots of ground-based telescopes. Ground-based telescopes are still (by far) the biggest optical telescopes, and the cost of space telescopes is prohibitive for many research projects. It will be a long time before a telescope anywhere close in size to the VLT can be launched. Most space telescopes are specialist devices, observing in a particular part of the spectrum that is blocked by the atmosphere (so there are infra-red, ultraviolet and X-ray telescopes in space) Or doing a specific task (looking for exoplanets, or mapping the positions of stars) Space is getting cheaper, but it will be a long time before it is as cost-effective as ground telescopes in the optical range. And so it will be a long time before all professional telescopes are in space. So it is a problem for professional astronomers.
{ "domain": "astronomy.stackexchange", "id": 5446, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "telescope, space-telescope, light-pollution", "url": null }
# Suppose that $|S_n - S| \leq t_n$ for large $n$ and $\lim_{n \to \infty} t_n =0$. Show that $\lim_{n \to \infty} S_n =S$. Suppose that $|S_n - S| \leq t_n$ for large $n$ and $\lim\limits_{n \rightarrow \infty} t_n =0$. Show that $\lim\limits_{n \rightarrow \infty} S_n =S$. As the distance between $S_n$ and the finite number $S$ is bounded above by $t_n$. When $n \rightarrow \infty$ and $t_n$ converges to $0$, the distance $|S_n - S|$ has to converge to zero. $$\lim\limits_{n \rightarrow \infty} |S_n - S|=0$$ As the distance is null $$S_n - S=0$$ As $S$ is finite, it follows that, when $n$ is large, $S_n =S$ Question: Is my argumentation appropriate/correct? How would you show this? • No, it isn't correct. $S_n\to S$ doesn't mean $S_n=S$ for $n$ large. Note that $1/n\to 0$ but $1/n\ne 0,\forall n\in\mathbb{N}.$ – mfl Aug 4 '17 at 21:14
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9825575132207566, "lm_q1q2_score": 0.844669078673402, "lm_q2_score": 0.8596637523076225, "openwebmath_perplexity": 57.40971517910927, "openwebmath_score": 0.9957648515701294, "tags": null, "url": "https://math.stackexchange.com/questions/2382832/suppose-that-s-n-s-leq-t-n-for-large-n-and-lim-n-to-infty-t-n-0" }
ros2 def __init__(self) -> None: super().__init__(DEFAULT_NODE_NAME) self._logger = self.get_logger() self.declare_parameters( namespace='', parameters=[ (LINEAR_PROPORTIONAL_GAIN_PARAM, DEFAULT_LINEAR_PROPORTIONAL_GAIN), (ANGULAR_PROPORTIONAL_GAIN_PARAM, DEFAULT_ANGULAR_PROPORTIONAL_GAIN), (LINEAR_MAX_ERROR_PARAM, DEFAULT_LINEAR_MAX_ERROR), (ANGULAR_MAX_ERROR_PARAM, DEFAULT_ANGULAR_MAX_ERROR), (LINEAR_DEAD_BAND_PARAM, DEFAULT_LINEAR_DEAD_BAND), (ANGULAR_DEAD_BAND_PARAM, DEFAULT_ANGULAR_DEAD_BAND), (SPOT_TURN_THRESHOLD_PARAM, DEFAULT_SPOT_TURN_THESHOLD), (LOOKAHEAD_PARAM, DEFAULT_LOOKAHEAD) ] ) self._linear_gain = self.get_parameter( LINEAR_PROPORTIONAL_GAIN_PARAM ).get_parameter_value().double_value self._angular_gain = self.get_parameter( ANGULAR_PROPORTIONAL_GAIN_PARAM ).get_parameter_value().double_value self._linear_max_error = self.get_parameter( LINEAR_MAX_ERROR_PARAM ).get_parameter_value().double_value self._angular_max_error = self.get_parameter( ANGULAR_MAX_ERROR_PARAM ).get_parameter_value().double_value self._linear_dead_band = self.get_parameter( LINEAR_DEAD_BAND_PARAM ).get_parameter_value().double_value self._angular_dead_band = self.get_parameter( ANGULAR_DEAD_BAND_PARAM ).get_parameter_value().double_value self._spot_turn_threshold = self.get_parameter( SPOT_TURN_THRESHOLD_PARAM ).get_parameter_value().double_value self._lookahead = self.get_parameter( LOOKAHEAD_PARAM ).get_parameter_value().double_value
{ "domain": "robotics.stackexchange", "id": 35239, "lm_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 }
html, css <li><a class="card-frame common-card" href="http://hearthstone.gamepedia.com/Dark_Iron_Dwarf"><span class="card-cost">4</span><span class="card-name">Dark Iron Dwarf</span><span class="card-count">2</span><span class="card-image card-count-ex"><img src="http://i.imgur.com/IrIovTL.png"></span></a></li> <li><a class="card-frame common-card" href="http://hearthstone.gamepedia.com/Dragonkin_Sorcerer"><span class="card-cost">4</span><span class="card-name">Dragonkin Sorcerer</span><span class="card-count">1</span><span class="card-image card-count-ex"><img src="http://i.imgur.com/CiXAN9A.png"></span></a></li> <li><a class="card-frame common-card" href="http://hearthstone.gamepedia.com/Frigid_Snobold"><span class="card-cost">4</span><span class="card-name">Frigid Snobold</span><span class="card-count">1</span><span class="card-image card-count-ex"><img src="http://i.imgur.com/aENN7T6.png"></span></a></li>
{ "domain": "codereview.stackexchange", "id": 19650, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "html, css", "url": null }
python, object-oriented, programming-challenge, python-2.x class Vehicle(): MOVEMENT = {'N': (0, 1), 'E': (1, 0), 'S': (0, -1), 'W':(-1, 0)} def __init__(self, x, y, facing, grid, obstacle): self.x = x self.y = y self.facing = Directions(facing) self.grid_width, self.grid_height = grid self.obstacle = obstacle @property def direction(self): return self.facing.current @property def position(self): return (self.x, self.y) def parse_commands(self, commands): action = { 'L': self.facing.previous, 'R': self.facing.next, 'M': self.move, } for command in commands: action[command]() def move(self): offset_x, offset_y = self.MOVEMENT[self.facing.current] x = self.x + offset_x y = self.y + offset_y if (x, y) != self.obstacle and 0 <= x <= self.grid_width and 0 <= y <= self.grid_height: self.x = x self.y = y def setup_and_move_vehicule(grid, obstacle): x, y, facing = raw_input().split() vehicule = Vehicule(int(x), int(y), facing, grid, obstacle) vehicule.parse_commands(raw_input().strip()) return vehicule.position, vehicule.direction def main(): grid = map(int, raw_input().split()) v1_pos, v1_dir = setup_and_move_vehicule(grid, None) v2_pos, v2_dir = setup_and_move_vehicule(grid, v1_pos) print v1_pos[0], v1_pos[1], v1_dir print v2_pos[0], v2_pos[1], v2_dir
{ "domain": "codereview.stackexchange", "id": 24399, "lm_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, object-oriented, programming-challenge, python-2.x", "url": null }
mongodb, repository, kotlin return User( userDocument.get("chatId") as String, userDocument.get("username") as String, userDocument.get("email") as String ) }
{ "domain": "codereview.stackexchange", "id": 29113, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "mongodb, repository, kotlin", "url": null }
One can use the generalized AM-GM inequality: If $$M_p = \left(\frac{x^p+y^p+z^p}{3}\right)^{\frac{1}{p}}$$ then for $p < q$, $M_p \leq M_q$ with equality holding if and only if $x=y=z$. Here, using $M_2 \geq M_1$, we get $$\left(\frac{x^2+y^2+z^2}{3}\right)^{\frac{1}{2}} \geq \frac{|x|+|y|+|z|}{3} \geq \frac{x+y+z}{3} = \frac{1}{3}$$ We can minimize $x^2 + y^2 + z^2$ subject to the constraint $x+y+z = 1$ using Lagrange multipliers, we then find that $x = y = z = \frac{1}{3}$, therefore $x^2 + y^2 + z^2\geq\frac{1}{3}$. • This only shows that this is a local minimum, right? – Carsten S Apr 24 '17 at 14:05 One more way to prove it is by substituting out for $z$:
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9879462190641612, "lm_q1q2_score": 0.8547948593085478, "lm_q2_score": 0.8652240808393984, "openwebmath_perplexity": 151.66039486157948, "openwebmath_score": 0.9061225652694702, "tags": null, "url": "https://math.stackexchange.com/questions/2247973/knowing-that-for-any-set-of-real-numbers-x-y-z-such-that-xyz-1-the-ineq" }
python, python-3.x, programming-challenge, game Title: Pseudo Game of Cups in Python DESCRIPTION: [Inspired by Chandler's GameOfCups with Joey in "Friends"]. Program gets 5-digit zipcode from user. (Assume user won't make a mistake, and will enter exactly 5 digits). Program awards points based on a series of rules, and reports the total points earned at the end. The 8 rules are embedded as comments in the code. For each rule, besides adding points (or not) to the total, rule displays "Rule _ got _ points, so total is now _" (It prints this even if rule added 0 points to total). """ RULES +5 when first and last digit match +6 when second digit is twice the first AND third digit is greater than second or fourth digit +7 if any 7 is in the zipcode +8 when there's no "13" in MIDDLE the zipcode +9 when all three middle digits match +10 when third and fourth digits match +11 when zipcode is palindrome (12121 == 12121, while 12345 != 54321) """ Here is my solution to the challenge above: zipcode = input("Enter your zipcode: ") total_points = 0 #Rule 1 points = 5 if zipcode[0] == zipcode[-1] else 0 total_points += points print(f"Rule 1 got {points} points, so total is now {total_points}") #Rule 2 points = 6 if (int(zipcode[1]) * 2) > int(zipcode[0]) and (int(zipcode[2]) > int(zipcode[1]) or int(zipcode[2]) > int(zipcode[3])) else 0 total_points += points print(f"Rule 2 got {points} points, so total is now {total_points}") #Rule 3 points = 7 if "7" in zipcode else 0 total_points += points print(f"Rule 3 got {points} points, so total is now {total_points}") #Rule 4
{ "domain": "codereview.stackexchange", "id": 35977, "lm_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, programming-challenge, game", "url": null }
terminology-and-notation, oracles Title: What exactly is an oracle? What exactly is an "oracle"? Wikipedia says that an oracle is a "blackbox", but I'm not sure what that means. For example, in the Deutsch–Jozsa algorithm,$\hspace{85px}$,is the oracle just the box labeled $`` U_f " ,$ or is it everything between the measurement and the inputs (including the Hadamard gates)? And to give the oracle, do I need to write $U_f$ in matrix form or the condensed form: $U_f$ gives $y \rightarrow y \oplus f(x)$ and $x \rightarrow x$ is enough with respect to the definition of an oracle? An oracle (at least in this context) is simply an operation that has some property that you don't know, and are trying to find out. The term "black box" is used equivalently, to convey the idea that it's just a box that you can't see inside, and hence you don't know what it's doing. All you know is that you can supply inputs and receive outputs. In the circuit diagram you depict, it is just the $U_f$ box. Everything else is stuff that you are adding in order order to help interrogate the oracle and discover its properties. To give the oracle, you can write it in any valid form that defines a map from all possible inputs to outputs. This could be a matrix (presumably with an unknown parameter), or it could be the map $U:(x,y)\mapsto (x,y\oplus f(x))$ (strictly, $\forall x,y\in\{0,1\}$), because given either description, you can work out the other.
{ "domain": "quantumcomputing.stackexchange", "id": 451, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "terminology-and-notation, oracles", "url": null }
python, r, data-analysis, excel Then steps in 64-bit Excel, which basically means no more memory limits - only those that come from your hardware, and that means Python and R will also be stopped in their tracks. To provide some numbers, we can simply compute the number of bits able to be stored in each version. Here in Python's interactive prompt: In [1]: (2**32) / 10**9 # 10^9 means the result is 4.3 Gb Out[1]: 4.294967296
{ "domain": "datascience.stackexchange", "id": 3739, "lm_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, r, data-analysis, excel", "url": null }
quantum-circuit, clifford-group, random-quantum-circuit, solovay-kitaev-algorithm, approximation Title: Clifford circuit approximation to a random Clifford circuit Given a random Clifford state on $L$ qubits (defined as an infinite depth Clifford circuit acting on the zero state), what depth Clifford circuit is required to approximate this state to a given accuracy $\epsilon$. I am essentially looking for a Kitaev Solovay theorem restricted to Clifford circuits. For a Haar random unitary on $L$ qubits, it is know that the required circuit depth to approximate it to a given accuracy scales as $2^L$. Is this also the case for random Clifford unitary gates on $L$ qubits? Clifford operations are discrete. They can't approximate arbitrary states. The state may not be close to a state reachable by Clifford operations. There are $O(L^2)$ distinct $L$-qubit states reachable by Clifford operations. By a circuit counting argument (there's only so many ways to place two-qubits gates, and you need to be able to make all the states), you can prove most circuits need to have depth $\Omega(L / \log L)$ (assuming you have $O(L)$ ancilla qubits). All Clifford operations (and therefore all reachable states) on $L$ qubits can be compiled into an $O(L)$ depth circuit, even if you're limited to nearest neighbor interactions on a line: https://arxiv.org/abs/1705.09176 . So for states reachable with Cliffords the answer is either $L$, or $L / \log L$, or something in between. For other states it depends how much error you'll tolerate, since you can't make it arbitrarily small.
{ "domain": "quantumcomputing.stackexchange", "id": 3904, "lm_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-circuit, clifford-group, random-quantum-circuit, solovay-kitaev-algorithm, approximation", "url": null }
homework-and-exercises, newtonian-mechanics, friction, speed, kinematics Title: A question about speed A object with mass 0.5 kg slides in straight line for 200 m, where the friction act on it is 0.4 times the normal reaction acting on it. Find its initial speed. I let $u$ be the speed. $u^2=2as=2*0.4mg*200=2*0.4*0.5*9.81*200,u=28.01ms^{-1}$. But the answer should be $40ms^{-1}$, can someone tell me what's wrong with my solution? Thank you. EDIT: Correct answer: $u^2=-2as=-2(f/m)s=-2(-0.4N/m)s=-2(0.4mg/m)s=2*0.4*10*200=1600$ $u=40ms^{-1}$ You're solution is wrong. For one, the law is $v^2 = u^2 + 2aS$ where v is the final velocity and u is the initial velocity. You've substituted the initial velocity in the wrong place, can't you see? :) Secondly, why do you think the acceleration is equal to 0.4(N)? It is given in the question that the friction is equal to 0.4(N), not acceleration! Think of a way to inter-relate the two?? ;) Thirdly, try taking the acceleration due to gravity (g) as 10, it'll simplify stuff. Try solving it now, and update your question with your answer!
{ "domain": "physics.stackexchange", "id": 8317, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "homework-and-exercises, newtonian-mechanics, friction, speed, kinematics", "url": null }
c#, php if (!File.Exists(filePath)) { return absoluteUri; } DateTime dt = File.GetLastWriteTimeUtc(filePath); int unixTimestamp = (int)(dt.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; return absoluteUri + "?" + unixTimestamp; }
{ "domain": "codereview.stackexchange", "id": 12530, "lm_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#, php", "url": null }
sql, sql-server select h.Company, h.PartNum, 0 as [Level], h.MtlPartNum&#xD;&#xA; from Parts_Neg_CTE as g&#xD;&#xA; inner join dbo.PartMtl as h&#xD;&#xA; on g.Company = h.Company and g.PartNum = h.PartNum&#xD;&#xA; union all&#xD;&#xA; select i.Company, i.PartNum, [Level] - 1, i.MtlPartNum&#xD;&#xA; from dbo.PartMtl as i&#xD;&#xA; inner join Reverse_Recursive_BOM_CTE as j&#xD;&#xA; on i.MtlPartNum = j.PartNum&#xD;&#xA;)&#xD;&#xA;select *&#xD;&#xA;from Reverse_Recursive_BOM_CTE" StatementType="SELECT" QueryHash="0x7FDBDBEEA130262E" QueryPlanHash="0x9402E43E7FD31267">
{ "domain": "codereview.stackexchange", "id": 31682, "lm_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 }
ros, compile, library, ros-groovy, roscpp -- Configuring incomplete, errors occurred! make: *** [cmake_check_build_system] Error 1 Invoking "make cmake_check_build_system" failed Originally posted by Ruud on ROS Answers with karma: 212 on 2014-11-03 Post score: 0 Original comments Comment by ahendrix on 2014-11-03: I suspect there's something in your cmakelists that is causing the library search to fail. Please edit your question to include the CMakeLists.txt from your halcon package. Comment by Ruud on 2014-11-04: The CMakeLists.txt does not search or include pthread. I did found a dependency in a third party source file looking to include "pthread.h", which is nowhere to be found in the include directories. Apparently the compiler looks for it but occasionally does not find it or it sometimes does. Comment by Dirk Thomas on 2014-11-04: As the error message says the library is used by the roscpp package (/opt/ros/groovy/share/roscpp/cmake/roscppConfig.cmake). I can't see any reason why the behavior should be non-deterministic. You might want to post the full code of your example (e.g. in a GitHub repo) for others to take a look. With ^: is pthread directly listed as an argument to a target_link_libraries(..) statement? If so, you probably want to replace that with a proper find_package(Threads ..) and related include_paths(..), etc. Originally posted by gvdhoorn with karma: 86574 on 2014-11-03 This answer was ACCEPTED on the original site Post score: 0
{ "domain": "robotics.stackexchange", "id": 19934, "lm_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, compile, library, ros-groovy, roscpp", "url": null }
game, ocaml, snake-game Edit. I am particularly interested in refactoring this redundant code : let key_pressed_player_1 button_pressed player = (match button_pressed with 'q' -> if player.s_x <> speed then {x = player.x; y = player.y; s_x = (-1)*speed; s_y = 0} else player; |'d' -> if player.s_x <> (-1)*speed then {x = player.x; y =player.y; s_x = speed; s_y = 0} else player; |'z' -> if player.s_y <> (-1)*speed then {x = player.x; y =player.y; s_x = 0; s_y = speed} else player; |'s' -> if player.s_y <> speed then {x = player.x; y =player.y; s_x = 0; s_y = (-1)*speed} else player; |_ -> player) in
{ "domain": "codereview.stackexchange", "id": 37424, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "game, ocaml, snake-game", "url": null }
java, networking, simulation Title: Simulating a random packet routing algorithm and printing packet statistics in Java I have this short program for simulating a random packet routing algorithm: Packet.java package net.coderodde.simulation.network; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; /** * This class implements a packet being transmitted in the network. * * @author Rodion "rodde" Efremov * @version 1.6 (Jun 23, 2016) */ public class Packet { private final int sourceNetworkNodeId; private final int targetNetworkNodeId; private final List<NetworkNode> history = new ArrayList<>(); private int cycles; public Packet(final int id, final int sourceNetworkNodeId, final int targetNetworkNodeId) { this.sourceNetworkNodeId = sourceNetworkNodeId; this.targetNetworkNodeId = targetNetworkNodeId; } public boolean isDelivered() { if (history.isEmpty()) { return false; } return history.get(history.size() - 1).getId() == targetNetworkNodeId; } public final void mark(final NetworkNode networkNode) { history.add(networkNode); } public final void incrementCycleCounter() { cycles++; } @Override public String toString() { final StringBuilder sb = new StringBuilder(); sb.append("[") .append(sourceNetworkNodeId) .append(" -> ") .append(targetNetworkNodeId) .append("; cycles: ") .append(cycles) .append("; history: ["); final Map<Integer, Integer> map = compressPath(history); final Iterator<Map.Entry<Integer, Integer>> iterator = map.entrySet().iterator();
{ "domain": "codereview.stackexchange", "id": 20668, "lm_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, networking, simulation", "url": null }
dataset, bigdata Title: Merging 2 datawarehouses Suppose I have 2 datawarehouses of two different companies that are being merged. Some of the tables are common but includes different records, while others are different. If I use big data environments, can I put all the tables together as data swamp and to create new data lake with archive of the previous datawarehouses data or should I build a new datawarehouse based on the common tables and adding the different ones? In addition, is there a good source for best practice steps for merging datawarehouses? There is a design pattern call "strangler" that might be applicable. The strangler design pattern leaves all legacy systems in place and migrates piece-by-piece to a single, updated system. It does this by creating a proxy interface that routes requests to either legacy system or the updated system. As the migration happens, the proxy routes more traffic to the updated system. The advantages of the strangler design pattern: People can still use legacy system Prioritize system clean-up based on usefulness Can create an explicit roadmap of migration
{ "domain": "datascience.stackexchange", "id": 9670, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "dataset, bigdata", "url": null }
homework-and-exercises, newtonian-mechanics, mathematics, equations-of-motion Title: Control system with equation C = A*x + B*dx/dt This question came up in a computer science / robotics exam and I still don't know the solution for it. I figured out that it's classical mechanics related, so I thought this might be the best place to ask it. Suppose a control system is described by the equation C = A*x + B*dx/dt where B is proportional to the mass of the robot. The behaviour of the system can be characterised by the steady state (e.g. the asymptotic velocity of the robot) and the half-life time of the decrease of the distance to the steady state. Explain how the steady state and the half-life change if the mass of the robot is doubled.
{ "domain": "physics.stackexchange", "id": 3461, "lm_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, mathematics, equations-of-motion", "url": null }
manipulator Title: Why does degree of freedom only consider continuous values? In the book Modern Robotics Chapter 2 Configuration space, we are told that degrees of freedom only considers coordinates with real valued continuous range. Why is this the case? A degree of freedom doesn't necessarily need to be continuous. We can easily define a system that has a discrete degree of freedom. For example, image a mobile robot in $\mathbb{R}^2$ with a heat sensor. If the temperature is greater than 37 degrees celsius, we consider it to be hot. From 15 degrees to 37, we consider mild, and below 15, cold. In this way we have defined our system's state to be ($\mathbb{R}$, $\mathbb{R}$, {hot, mild, cold}). The third element of our state is a discrete degree of freedom. Now an important note is that the system needs to be able to navigate in each degree of freedom. We can easily fit this into our example, by considering that the temperature need not be the same for all $\mathbb{R}$. The book that you reference is not one that I have read, but I am curious to know if the author was rather stating that, for their purposes, they were only considering continuous degrees of freedom.
{ "domain": "robotics.stackexchange", "id": 1889, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "manipulator", "url": null }
evolution, experimental-design, ecosystem Title: What insect/invertebrate species evolves fastest? I am starting an experiment in which I will be forcing evolution in a moderately complex species of insect or invertebrate. I am prepared for the possible longevity of this experiment, but i have no clue what species i should use. I would prefer a species that can easily respond to biotic challengers. Reason being, every abiotic factor will be promoting the growth and prosperity of the target species, however every biotic factor will be trying to kill the target species. The species can be aquatic, amphibious or terrestrial. Drosophila melanogaster. (fruit-fly, pomice-fly) Image, public domain, via Wikipedia 2022. Development time is under ideal conditions 8.5 days (at 25 Celsius, 77 Fahrenheit), the females produce perhaps 500 eggs per generation which can hatch in 12-15 hours - from the point of view of turnover, you should be able to observe many generations in a short-ish period at one generation per ten days in reasonable conditions. Their diet is fruit, fungi - both preferably decomposing and are able to be anaesthetised with ether or carbon dioxide. They have acted as a model organism (eukaryote) for the study of genetics and there are many known mutations, and established ways to produce them (ethyl methane sulfonate, ionising radiation).
{ "domain": "biology.stackexchange", "id": 11772, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "evolution, experimental-design, ecosystem", "url": null }
or two consecutive tails ($TT$) are observed. What is the probability that three of those selected are women? Two standard dice with 6 sides are thrown and the faces are recorded. $$P(A \cup B\cup C)=a+b+c-ac-bc=\frac{11}{12}.$$ two previous problems. $GG$ from $\frac{1}{3}$ to about $\frac{1}{2}$. Compare your Example 1 a) A fair die is rolled, what is the probability that a face with "1", "2" or "3" dots is rolled? Let’s get to it! Compound probability is when the problem statement asks for the likelihood of the occurrence of more than one outcome. $$E_1$$= event did not complete college education; $$E_2$$= event of completion of bachelor's degree; $$E_3$$= event of completion of graduate or professional degree program. (ii) What is the probability that exactly one of them will solve it? Let $$B_k$$ be the event of a black ball on the $$k$$th draw and $$R_k$$ be the event of a red ball on the $$k$$th draw. visualize the events in this problem. Let $$T$$ = event test indicates defective, $$D$$ = event initially defective, and $$G =$$ event unit purchased is good. The probability that it's not raining and there is heavy traffic and I am not late can Here you can assume that if a child is a girl, her name will be Lilia with probability $\alpha \ll 1$ Hence $$P(A_6|S_k) = 1/6, 1/5. the probability that both children are girls, given that the family has at least one daughter named Lilia. What is the (conditional) probability that he or she will make 25,000 or more? Find the total probability that a person's income category is at least as high as his or her educational level. Previous experience indicates that 20 percent of those who do not favor the policy say that they do, out of fear of reprisal. We can calculate the probabilities of each outcome in the sample space by
{ "domain": "pfsrm.pl", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9843363512883316, "lm_q1q2_score": 0.8480433828159828, "lm_q2_score": 0.8615382147637196, "openwebmath_perplexity": 672.5178864302072, "openwebmath_score": 0.8050689697265625, "tags": null, "url": "http://konferencja.pfsrm.pl/7hu3cg/conditional-probability-problems-02b1e4" }
python, beginner, csv, statistics test_name_list = ["(1)Stroop ", "(2)Sözel akıcılık ", "(3)Semantik Akıcılık ", "(4)SBST ", "(5)İz sürme ", "(6)Mini Mental test ", "(7)Saat çizme ", "(8)MOCA ", "(9)Artırılmış İpuçlu Hatırlama ", "(10)Yetişkin Wisconsin Kart Eşleme ", "(11)Wechsler Zeka testi ", "(12)Rey Karmaşık Figür Testi ", "(13)Çizgi yönünü belirleme testi ", "(14)Visual Verbal Test"] #verbal names of the tests menu_ui = ("==================================================\n") for i in range(len(test_name_list)): if (i+1)%3 == 0: menu_ui = menu_ui + test_name_list[i] + "\n" else: menu_ui = menu_ui + test_name_list[i] menu_ui = menu_ui + "\n" print(menu_ui) #creates and prints the mainMenu print("Şu ana kadar yapılan testler: ") print(menu_done_tests) #prints tests that were done so far (could be made into a string, and printed) menu_input = int(input("Girmek istediğiniz testin numarasını giriniz veya çıkış için (" + str(len(menu_list)+1) + ") giriniz: " )) If you created support for a generic text menu, then you could reuse it for sex selection:
{ "domain": "codereview.stackexchange", "id": 20983, "lm_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, csv, statistics", "url": null }
organic-chemistry, stereochemistry, nucleophilic-substitution Title: Nucleophilic allylic substitution via SN2 Since SN2 reaction is more favorable with primary substrates, do allylic primary halides undergo nucleophilic substitution reaction mostly on carbon 1 via "SN2". and in case of secondary allylilc halide would the reaction proceed mostly via SN2 pathway? In case the nucleophilic attack occurs on carbon 3, would we obtain both configurations, R and S? You have not provided any conditions for these reactions so it is difficult to assess specifically how you are substituting a hydroxyl group for bromide. If you use water as a solvent, then an SN1 reaction would be likely but liberated HBr would have to be neutralized to avoid acid-catalyzed isomerization or dehydration of the resultant alcohols. If hydroxide is employed as the nucleophile, then elimination is an issue. The primary bromide will likely undergo SN2 displacement with hydroxide to give the primary allylic alcohol. As to the secondary bromide, elimination is a major concern. Ideally, acetate would be a better nucleophile to optimize substitution and repress elimination. Saponification of the acetate esters will liberate the alcohols. The achiral primary bromide will afford achiral primary alcohol and racemic tertiary alcohol. There is little mechanistic information to be gleaned here. The secondary bromide, if a racemate, will provide racemic products. The secondary bromide is a more interesting case and one that can potentially provide useful information. Ideally, I would employ tosylates as opposed to bromides because they are formed from alcohols that can be prepared as their pure enantiomers. Your secondary bromide R,Z-1 would yield S,Z-2 by SN2 displacement. Syn SN2' addition affords R,E-3 while anti SN2' addition provides S,E-3. In the event that solvolytic conditions are employed, i.e., buffered aqueous acetone, racemic 2 and 3 would be expected barring solvent cage effects. SN1 reactions would proceed via cation transoid-4 and not cisoid-5, which has a syn-pentane interaction.
{ "domain": "chemistry.stackexchange", "id": 14336, "lm_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, stereochemistry, nucleophilic-substitution", "url": null }
terminology, group-theory, notation Title: Terminology of $SU(3)_F$ From a terminological point of view, what is the relatioship between the flavor symmetry group $SU(3)_F$ of strong interaction and the group $SU(3)$ (without subscript $F$) of 3x3 unitary matrices with determinant +1? Is it possible to say that "the flavor group $SU(3)_F$ is a representation of the abstract group $SU(3)$, defined on the Hilbert space of hadron states or quark states."? If the previous sentence was correct, one could also state, about the color transformations, that: "$SU(3)_C$ is a different representation of $SU(3)$, acting on the Hilbert space of quark states.". I have never found sentences of this type in books, so I suspect that there must be something wrong in them. Indeed often representations of the group $SU(3)_F$ (with subscript $F$) are considered, as if it were a "standalone" group. In general I found terminology about groups and representations quite confusing, so please any correction would be appreciared. The subscript "$F$" has no mathematical meaning. It's just there to remind the reader what is the physical significance of that group. For example, a theory may have an $\mathrm{SU}(3)$ flavor group, an $\mathrm{SU}(3)$ gauge group and perhaps maybe even more flavor groups that act on different fields. Whenever a textbook or a paper want to refer to one of these groups in particular they add a subscript in order to save some words. The sentence "the flavor group [...] quark states." that OP states (v1 and 2) is not correct. A given theory can have various particles in different representations of the same flavor group.
{ "domain": "physics.stackexchange", "id": 87144, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "terminology, group-theory, notation", "url": null }
Dick Homework Helper Also good advice. I just took the derivative of my answer, and after combining the fractions I ended up with my original function. So...am I right in thinking that Wolfram might simply be getting this one wrong? You are both somewhat right. The derivative of log(3-x) is the same as the derivative of log(x-3). The usual thing is to write the integral of 1/(x-3) as log(|x-3|). QuantumCurt
{ "domain": "physicsforums.com", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9362850039701653, "lm_q1q2_score": 0.8100963270830064, "lm_q2_score": 0.8652240756264639, "openwebmath_perplexity": 424.917383235874, "openwebmath_score": 0.8558143973350525, "tags": null, "url": "https://www.physicsforums.com/threads/integral-with-partial-fractions.800282/" }
complexity-classes, regular-expressions Title: Are all RegExp solvable in O(n)? I'm wondering if all features, that are often part of modern RegEx engines, are solvable in O(n). I'm talking about features like repeating patterns ([abc]+);\1 would match abc;abc but not abc;cba, lazy or not greedy repetition operators [ab]+?ba$ would match abba or aaaabbbbba but not ababa. I know that things like anchors (^ and $), optional operator (a?), character classes ([abc], or [^abc]) and the plus operator can be reduced to nominal regex operations or are simple checks in the end. Thanks to @emil's comment and this stackoverflow answer, I now know that POSIX extended regular expressions are solvable in O(n) but backreferences are at least NP-hard and maybe NP-complete.
{ "domain": "cstheory.stackexchange", "id": 4971, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "complexity-classes, regular-expressions", "url": null }
of your cabinet can be quite useful when it comes to mixing or recording, specifically at home. These z's and p's are commonly referred to as the zeros and poles of the system. Now this time response can be multiple things as in, it can be a unit step, sinusoid, square wave, some dc value or. For this analysis, we will assume that the filters are Nth order Butterworth filters with a cutoff frequency of fc, and that the sample-and-hold runs at a sampling rate of fs = 1/Ts. In Simulink, I am getting a signal (a crank angle signal from an IC Engine) at a varying rate with in cycle of 720 degrees. > Subject: [matlab] Frequency response to Impulse response conversion > Hi All, > I want the impulse response of a filter from its > frequency response. The zero-order hold is the hypothetical filter or LTI system that converts the sequence of modulated Dirac impulses x s (t)to the piecewise-constant signal (shown in Figure 2): = ∑ = − ∞ ∞ [] ⋅ (− −) resulting in an effective impulse response (shown in Figure 4) of: = (−) = {≤ < The effective frequency response is the continuous Fourier transform of the impulse response. Apps are included in many MATLAB products. If the system has multiple inputs or outputs (MIMO), one input and one output must be selected for the simulation. The parameters input and output do this. Just keep in mind that by giving me that b vector above you are asserting that is the impulse response and that system has a finite impulse response. Finite impulse response filter length. I have a gaussian white noise process with a variance of 1. Finite-duration impulse response (FIR) filter (OrderM-1, LengthM) The impulse response ; The system function ; The difference equation (Linear convolution) The frequency response (DTFT) 2. m determines the impulse response, h(t) from measured input and output waveforms. Implementing Audio Effects in MATLAB and Simulink 2 In practice, simulated reverberations are not carried out with impulse responses measured from actual rooms. 1 on time domain transform 15 7. By nature, the frequency responses of any digital (or, to be more precise: "sampled") system is mirrored at half of the sampling rate
{ "domain": "agenziafunebretassoni.it", "id": null, "lm_label": "1. Yes\n2. Yes", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9539660949832346, "lm_q1q2_score": 0.8108436814776405, "lm_q2_score": 0.8499711737573762, "openwebmath_perplexity": 1101.8294530208088, "openwebmath_score": 0.6673231720924377, "tags": null, "url": "http://txck.agenziafunebretassoni.it/convert-impulse-response-to-frequency-response-matlab.html" }
python, performance, python-3.x # no match found if len(selection) == 0: return None return random.choice(selection) The file has to exist but it can be empty, then there is no error but the function will return None. Use os.exists to test that the file is present. Yes, there is an import but it is a built-in module, does not require installation of a third-party module with PIP. It is also portable and not just Unix. However, if you insist on /dev/random and want no import one thing you could do is retrieve a random integer like what you are doing now and use it in a modulo-type fashion against the list of matching items, to pick one word at random. Be careful with implementation as you may introduce unwanted bias in the selection. Random functions exist for a reason. While it is possible to rely solely on /dev/random reimplementing the functionality with decent randomization will result in more code and reinventing the wheel.
{ "domain": "codereview.stackexchange", "id": 38534, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "python, performance, python-3.x", "url": null }
quantum-mechanics, wavefunction, heisenberg-uncertainty-principle, wave-particle-duality, wavefunction-collapse What happens to the energy of a particle/wave packet after the collapse? Energy and momentum are conserved absolutely, so it will depend on what sort of detection of the particle took place. Some will be carried off by the particle if it has not been absorbed into the detector, as for example these particles in this bubble chamber photograph which continually interact with the transparent liquid of the bubble chamber. In this case a tiny bit of the energy is taken by kicked off electrons (first detector atom of liquid, final detector photographic plate) which show by the ionisation the passage of the particle, which is certainly not idiotically "collapsing" .
{ "domain": "physics.stackexchange", "id": 4207, "lm_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, wavefunction, heisenberg-uncertainty-principle, wave-particle-duality, wavefunction-collapse", "url": null }
java, palindrome The replaceAll() method creates another copy of the string. Then, toLowerCase() creates another copy of the string. Finally, toCharArray() creates yet another copy in a character array of the resulting string. Of course, with the exception of the final result, the rest will get garbage collected. But each of the copies in an additional O(n) time. Here is a suggestion: private static boolean isPalindrome(String s) { int i = 0; int j = s.length() - 1; while (i < j) { if (Character.isWhitespace(s.charAt(i))) { i++; continue; } if (Character.isWhitespace(s.charAt(j))) { j--; continue; } if (Character.toLowerCase(s.charAt(i)) != Character.toLowerCase(s.charAt(j))) { return false; } else { i++; j--; } } return true; } I used the following test code to compare the performances of the two methods: public class Main { public static void main(String[] args) { String palindrome = "a b c de f g h x x xa b a xxx hg f e d c b a"; String nonPalindrome = "abcd e f g h xxxabcxxx hgfe d c ba";
{ "domain": "codereview.stackexchange", "id": 16054, "lm_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, palindrome", "url": null }
ros Title: clean message on topic Hi, I have a publisher to publish message to one topic at different time. Each time before I publish the new message, how can I clean the messages on the topic published at other time? Thanks. Originally posted by tony on ROS Answers with karma: 76 on 2015-09-13 Post score: 0 Original comments Comment by VitaliyProoks on 2015-09-14: Why would you need that? After a subscriber receives a message, this message then vanishes. Probably what you actually need in your situation is to use services as they allow to publish messages only on requests. Comment by tony on 2015-09-14: @VitaliyProoks Because I noticed that the robot didnot stop after publishing (0,0) to topic cmd_vel. I suspect that there is velocity command on topic cmd_vel published at other time. Then it looks like it is issue in your robot's code, messaging in ROS works fine :) ROS provides tools for listening to/publishing from topics either from console or by means of rqt_gui try to debug by sending test messages and see what happens. Originally posted by VitaliyProoks with karma: 75 on 2015-09-14 This answer was ACCEPTED on the original site Post score: 2
{ "domain": "robotics.stackexchange", "id": 22629, "lm_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 }
fluid-dynamics, acceleration, harmonic-oscillator, harmonics Title: Fluid filled harmonic oscillator A vessel (preferably circular) filled with water is accelerating unidirectionally such that the level of water is higher on one end than the other. What I want to know is that if the vessel is immediately stopped, the water level will force itself back to the equilibrium point, but in doing so push the other end up. If water is an ideal fluid, what type of oscillation will occur in this situation. I can tell that maybe the mathematical expression for this oscillation will be complex, but please do let me know if I am thinking this correctly. I am considering, finding the oscillation equation for infinitesimally small u-tubes(considering a 2-d plane) and integrating it to get the final expression. Thanks in advance Consider the following diagram:
{ "domain": "physics.stackexchange", "id": 26755, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "fluid-dynamics, acceleration, harmonic-oscillator, harmonics", "url": null }
Not logged in. Login # Exercise 6 For this exercise, put all of your function definitions in a file exer6.hs. ## Rational Numbers In the Haskell standard library, there is a module Data.Ratio that can be used to be represent rational numbers with the type Ratio Int. A Ratio Int value can be constructed with the % operator: 2%7 represents the fraction 2/7. Write a function rationalSum that produces a list of all rational numbers whose numerator and denominator add to the given argument. *Main> rationalSum 5 [1 % 4,2 % 3,3 % 2,4 % 1] *Main> rationalSum 8 [1 % 7,1 % 3,3 % 5,1 % 1,5 % 3,3 % 1,7 % 1] *Main> rationalSum 1 [] Note that rational values are displayed in lowest-terms. The values displayed in the above example for rationalSum 8 are $$\frac{1}{7}$$, $$\frac{2}{6}=\frac{1}{3}$$, $$\frac{3}{5}$$, $$\frac{4}{4}=\frac{1}{1}$$, $$\frac{5}{3}$$, $$\frac{6}{2}=\frac{3}{1}$$, $$\frac{7}{1}$$. ## Lowest Terms Only Make another version of the above function called rationalSumLowest that produces the same fractions, but only the values are are already in lowest-terms. *Main> rationalSumLowest 5 [1 % 4,2 % 3,3 % 2,4 % 1] *Main> rationalSumLowest 8 [1 % 7,3 % 5,5 % 3,7 % 1] *Main> rationalSumLowest 12 [1 % 11,5 % 7,7 % 5,11 % 1] Hint: there is a built-in function gcd that calculates the greatest common divisor of its arguments. ## All Rational Numbers Use the rationalSumLowest function to construct a list rationals that contains all positive rational numbers exactly once.
{ "domain": "sfu.ca", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9678992951349231, "lm_q1q2_score": 0.8148024467603447, "lm_q2_score": 0.8418256432832333, "openwebmath_perplexity": 4796.481872589143, "openwebmath_score": 0.8486204147338867, "tags": null, "url": "https://coursys.sfu.ca/2018fa-cmpt-383-d1/pages/Exercise6" }
as.matrix(X2) A=(2*pi)^(-ncol(X2)/2)*det(sigma2)^(-0.5) B = exp(-0.5 *rowSums((X2%*%ginv(sigma2))*X2)) p = A*B Next, let's calculate probabilties for the cross-validation data (Xval). In [496]: # Create preProcess object Xval = as.data.frame(Xval) preObj <- preProcess(Xval,method="center") # Center the data- subtract the column means from the data points Xval_centered <- predict(preObj,Xval) In [499]: Xval_centered = as.matrix(Xval_centered) sigma2=diag(var(Xval_centered)) sigma2= diag(sigma2) In [500]: A=(2*pi)^(-ncol(Xval_centered)/2)*det(sigma2)^(-0.5) B = exp(-0.5 *rowSums((Xval_centered%*%ginv(sigma2))*Xval_centered)) pval = A*B Now, we can determine the best probability threshold and also the associated F1 score. In [502]: bestEpsilon = 0 bestF1 = 0 F1 = 0 stepsize = (max(pval) - min(pval)) / 1000 for (epsilon in seq(from =min(pval), by= stepsize,to =max(pval))){ predictions = (pval < epsilon)*1 tp = sum((predictions == 1) & (yval == 1)) fp = sum((predictions == 1) & (yval == 0)) fn = sum((predictions == 0) & (yval == 1)) prec = tp / (tp + fp) rec = tp / (tp + fn) F1 = (2 * prec * rec) / (prec + rec) if (!is.na(F1)&
{ "domain": "datascience-enthusiast.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9808759671623987, "lm_q1q2_score": 0.8042136753092373, "lm_q2_score": 0.8198933425148214, "openwebmath_perplexity": 3841.227988814255, "openwebmath_score": 0.5578902959823608, "tags": null, "url": "https://datascience-enthusiast.com/R/anomaly_detection_R.html" }
bioinformatics, gene-expression, gene, genomes, radiation Title: Is there a negative correlation between the mRNA produced by the cell and the time of extraction? I am doing some data analysis about gene expression time series. When I plot mRNA produced by P. Furiosus cells irradiated by gamma radiation against the time of extraction, it seems that there is a negative correlation between them. Is it a good result from a biological point of view ? $\gamma$-irradiation produces single- and double-strand DNA breaks, depending on the dosage, and activates DNA damage repair pathways like p53. During this time, the cell cycle arrests and most if not all mRNA production ceases. For sub-lethal doses of $\gamma$ rays, I would expect to see newly-produced mRNA levels drop off fairly quickly with time following the initial dose, then possibly begin to ramp up again later as the damage is repaired and the cell cycle arrest checkpoints released.
{ "domain": "biology.stackexchange", "id": 10853, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "bioinformatics, gene-expression, gene, genomes, radiation", "url": null }
quantum-mechanics, nuclear-physics, atomic-physics, atoms Title: Could I turn into a nuclear bomb? Just out of curiousity, could the nuclei of our atoms split via quantum tunnelling, thereby leading to nuclear reactions and ultimately turning us into atomic bombs? I know that this is near-impossible, but wondering if it was technically possible. The thing is, we're made of mostly stable matter of low atomic number. In a nuclear bomb, unstable nuclei split, releasing a number of energetic neutrons which strike other unstable nuclei, and the reactions chain uncontrollably. Splitting a small nucleus actually costs energy, so even if a carbon atom in your body did split, it would only split into smaller, still low-energy atoms, which would interact normally with other atoms in your body. A couple extra lithium or helium atoms isn't going to do anything drastic.
{ "domain": "physics.stackexchange", "id": 25098, "lm_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, nuclear-physics, atomic-physics, atoms", "url": null }
thermodynamics, entropy From the First Law and assuming non-compression work is zero, we get $$\mathrm dH= đq + V~\mathrm dP\tag{II}$$ Now, \begin{align}\mathrm dS &= \frac{đq}{T}\\ \implies \mathrm dS &= \frac{(\mathrm dH- V~\mathrm dP)}{T}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[\mathrm{Using~~ II}]\\ \implies \mathrm dS &= \frac1T\left(\frac{\partial H}{\partial T}\right)_P~\mathrm dT + \frac1T\left[\left(\frac{\partial H}{\partial P}\right)_T- V\right]~\mathrm dP~~~~~~~[\mathrm{Using~~ I}]\tag{III}\end{align} Also, $$\mathrm dS= \left(\frac{\partial S}{\partial T}\right)_P~\mathrm dT + \left(\frac{\partial S}{\partial P}\right)_T~\mathrm dP\tag{IV}$$ Comparing $\rm (III)$ and $\mathrm{ (IV)}$ we get \begin{align}\left(\frac{\partial S}{\partial T}\right)_P&=\frac1T\left(\frac{\partial H}{\partial T}\right)_P\\\implies \left(\frac{\partial S}{\partial T}\right)_P&= \frac{C_p}T\,. \tag{V} \end{align}
{ "domain": "physics.stackexchange", "id": 33764, "lm_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, entropy", "url": null }
ros, colcon, ros-kinetic, ubuntu, cuda from setuptools.dist import Distribution File "/usr/local/lib/python3.5/dist-packages/setuptools/dist.py", line 585 license_files: Optional[List[str]] = self.metadata.license_files ^ SyntaxError: invalid syntax
{ "domain": "robotics.stackexchange", "id": 36579, "lm_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, colcon, ros-kinetic, ubuntu, cuda", "url": null }
quantum-mechanics, condensed-matter, computational-physics, lattice-model What I can't understand is that how do we define our basis vector in fourier space? My understanding about it: What I have understood from this so for is that let we have a 1D line from $-\pi$ to $+\pi$ (first brillion zone) on which $k$ points are discreetly define. If we have M=4 and N=2 then set of $k$-points is $-\pi$, $-\frac{\pi}{2}$,$+\frac{\pi}{2}$, $+\pi$ Now considering these 4 points as sites on which fermions can reside our basis vectors can be again given as they were given in real space i.e. $0011, 0101, 0110, 1001, 1010, 1100$. For simplicity I take limit $U=0$ and calculate Hamiltonian for both real and fourier space case. REAL SPACE: $$H_{R}=-t\begin{bmatrix} 0 & 1 & 0 & 0 & -1 & 0 \\ 1 & 0& 1& 1& 0& -1\\ 0 & 1& 0& 0& 1& 0\\ 0 & 1& 0& 0& 1& 0\\ -1 & 0& 1& 1& 0& 1\\ 0 & -1& 0& 0& 1& 0\\ \end{bmatrix}$$ Let t=1 then Eigenvalues=[-2, -2, -4.4e-16, 0, 2, 2] (using MATLAB function eig()) FOURIER SPACE: $\tilde{c_k^{\dagger}}\tilde{c_k}=\tilde{n_k}=$ number operator in k-space. So our hamiltonian for U=0 should be diagonal with values $$ H_{F}=
{ "domain": "physics.stackexchange", "id": 42245, "lm_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, condensed-matter, computational-physics, lattice-model", "url": null }
rviz, moveit, ros-kinetic, ros-industrial * /move_group/planner_configs/STRIDE/type: geometric::STRIDE * /move_group/planner_configs/STRIDE/use_projected_distance: 0 * /move_group/planner_configs/TRRT/frountierNodeRatio: 0.1 * /move_group/planner_configs/TRRT/frountier_threshold: 0.0 * /move_group/planner_configs/TRRT/goal_bias: 0.05 * /move_group/planner_configs/TRRT/init_temperature: 10e-6 * /move_group/planner_configs/TRRT/k_constant: 0.0 * /move_group/planner_configs/TRRT/max_states_failed: 10 * /move_group/planner_configs/TRRT/min_temperature: 10e-10 * /move_group/planner_configs/TRRT/range: 0.0 * /move_group/planner_configs/TRRT/temp_change_factor: 2.0 * /move_group/planner_configs/TRRT/type: geometric::TRRT * /move_group/planning_plugin: ompl_interface/OM... * /move_group/planning_scene_monitor/publish_geometry_updates: True * /move_group/planning_scene_monitor/publish_planning_scene: True * /move_group/planning_scene_monitor/publish_state_updates: True * /move_group/planning_scene_monitor/publish_transforms_updates: True * /move_group/request_adapters: default_planner_r... * /move_group/sensors: [{'point_subsampl... * /move_group/start_state_max_bounds_error: 0.1 * /move_group/trajectory_execution/allowed_execution_duration_scaling: 1.2 * /move_group/trajectory_execution/allowed_goal_duration_margin: 0.5 * /move_group/trajectory_execution/allowed_start_tolerance: 0.01
{ "domain": "robotics.stackexchange", "id": 33163, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "rviz, moveit, ros-kinetic, ros-industrial", "url": null }
navigation, robot-pose-ekf Originally posted by mmwise with karma: 8372 on 2011-09-02 This answer was ACCEPTED on the original site Post score: 1 Original comments Comment by jbeck27 on 2011-10-14: I want the combined gyro and wheel odometry to be given to the local planner. robot_pose_ekf publishes "odom_combined" that is not a nav_msgs/Odometry message. What is given to the local planner for the turtlebot? Comment by jbeck27 on 2011-10-14: That didn't solve the problem. I think I can clarify what I need now though. the robot_pose_ekf publishes a tf frame that amcl uses. What I need is some way to give the local planner the "odom" message. I am referencing the diagram in http://www.ros.org/wiki/move_base . Comment by mmwise on 2011-09-02: in the configuration files you should see a line: you need to set the param to the frame you want to use. It's in the amcl_turtlebot.launch file. Comment by jbeck27 on 2011-09-02: Thank you for the response. I actually had already found your videos, nice job btw. I guess a better phrasing of the question would if you run robot_pose_ekf and the nav stack is using it in the AMCL, what do you send as "odom" to the local_planner inside the navigation system?
{ "domain": "robotics.stackexchange", "id": 6590, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "navigation, robot-pose-ekf", "url": null }
rosinstall Originally posted by natan on ROS Answers with karma: 3 on 2011-08-15 Post score: 0 You have a problem in your package sources/package install. Can you update your original post with your /etc/apt/sources.list? There should only be lucid entries in there. Some package is "blocking" your install. To figure out the cause, you can choose one in the list, where it says "but is not going to be installed", and install only that. If you get a similar error there, continue with the package causing the next error until you get a different error. Usually you arrive at some error that tells you it wants a package in a certain version, but it can only be installed in another one (or not at all). Post that error here. In general you should make sure that your /etc/apt/sources.list only contains lucid entries, run apt-get update and then resolve the situation. Originally posted by dornhege with karma: 31395 on 2011-08-16 This answer was ACCEPTED on the original site Post score: 2
{ "domain": "robotics.stackexchange", "id": 6426, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "rosinstall", "url": null }