text
stringlengths
49
10.4k
source
dict
image-processing, gaussian, smoothing, gaussian-kernel Title: What Are Different Approaches to Realize a Gaussian Blur (Smoothing) Step on an Image? Could some review some methods to apply Gaussian Filter (Blur) on an image besides the direct one using Truncated FIR (classic convolution with Truncated Kernel) approximation? You can apply Gaussian Blurring on an image in many ways: Using FIR Approximation by Convolution. Using Approximation by Box Blur. In the Fourier Domain by Multiplication by a Fourier Kernel. Using IIR Approximation. You may have a look on my project - Fast Gaussian Blur. Update Meaning of FIR In this context FIR is the coefficients which are utilized to create the convolution kernel. Indeed in the case of Gaussian Blur the 2D Kernel can be represented by outer product of 2 1D kernels hence it can be done in a separable fashion - Rows / Columns and then Columns / Rows. Multiplication in The Fourier Transform By utilizing the Convolution Theorem which states there is equivalence between Convolution in Spatial Domain to Multiplication in Fourier Domain one could use it to apply the convolution. Run Time This really depends on 3 things: Size of the image. Size of the kernel (The STD of the Gaussian Kernel). The Quality required. For instance for cases of large image and large kernel (Size which is approximately the size of the image) the Fourier Transform is really good especially in the case we have few images to be smoothed with the same kernel (For instance 3 RGB Channels). Usually, in practice, in most times, the methods which their complexity is independent the Kernel STD (Box Blur Approximation / IIR Approximation) are the fastest methods with acceptable quality. You may try them in the project I linked to above.
{ "domain": "dsp.stackexchange", "id": 6429, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "image-processing, gaussian, smoothing, gaussian-kernel", "url": null }
problems, one using the Law of Sines and one using the Law of Cosines. What is Trigonometry? Trigonometry is a another form of math dealing with the relationship of the sides and angles of triangles. I struggle with finding. Physical: 23,. 7 - Applications of Sinusoidal Functions Applications of Sinusoidal Functions. This lesson will present real world examples that involve inverse trigonometric ratios. The trigonometric functions sine, cosine, and tangent are useful in a wide range of applications, from solving simple problems to advanced and complex problems. Over 90 new problems on differential equations and their applications. Understanding Calculus is a complete online introductory book that focuses on concepts. It studies the relationship between involving lengths and angles of triangle. Objectives: To graph the sine and cosine functions; to identify the graphs of the sine and cosine functions. In maths, you have real life applications on any thing that you study. At x = 0 degrees, sin x = 0 and cos x = 1. Transformations of Sine and. What are the Applications of Trigonometry in Real Life? Ans. (3) The student uses functions and their properties to model and solve real-life problems. Graphing Cosine Function Lesson Plan 1. Graph a sine or cosine function having a different amplitude and period. What are real-life applications of the sine and cosine wave applications? It's for a pre-calculus assignment and I have to make a presentation to the class about it. What Are Imaginary Numbers? are used in real-life applications, such as electricity, as well as quadratic equations. Recall from Graphs of the Sine and Cosine Functions that the period of the sine function and the cosine function is $$2π$$. Subhaschandra Singh, Department of Physics, Dhanamanjuri College of Science, Imphal – 795 001, Manipur, India. introduction. Law of Cosine [Just formula. Pg 439 #1-8, 33, 35, 37, 43-55 odd · Sketch the graphs of basic sine and cosine functions · Use amplitude and period to sketch the graphs of sine and cosine functions · Sketch translations of the graphs of sine and cosine functions. 3: Trigonometric Functions in Real life - Duration:
{ "domain": "salesianipinerolo.it", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.990291521799369, "lm_q1q2_score": 0.8655912851267503, "lm_q2_score": 0.8740772450055544, "openwebmath_perplexity": 489.46033083010536, "openwebmath_score": 0.754558265209198, "tags": null, "url": "http://salesianipinerolo.it/ubdl/real-life-applications-of-sine-and-cosine-functions.html" }
navigation, odometry, laser, amcl void parseScan(const sensor_msgs::LaserScan::ConstPtr& scan_msg) { receivedscan.angle_min = scan_msg->angle_min; receivedscan.angle_max = scan_msg->angle_max; receivedscan.angle_increment = scan_msg->angle_increment; receivedscan.time_increment = scan_msg->time_increment; receivedscan.scan_time = scan_msg->scan_time; receivedscan.range_min = scan_msg->range_min; receivedscan.range_max = scan_msg->range_max; receivedscan.ranges = scan_msg->ranges; receivedscan.header.stamp = scan_msg->header.stamp; receivedscan.header.frame_id = scan_msg->header.frame_id; Transform(); } int main(int argc, char **argv) { rotator = new Rotator(); ros::init(argc, argv, "LaserCompensation"); ros::NodeHandle n; publishscan.ranges.resize(216); int count = 0; ros::Subscriber altitude= n.subscribe( "/px4flow/opt_flow", 1, &altitudeParse ); ros::Subscriber PitchRoll= n.subscribe( "flightFeedback", 1000, &angleParse ); ros::Subscriber scan= n.subscribe("scan", 1, &parseScan); ros::Publisher Cscan = n.advertise<sensor_msgs::LaserScan>("scan2",1); ros::Rate loop_rate(40); //Freq = 40Hz while (ros::ok()) { if((altitudedifference <0.05 && altitudedifference > -0.05) && timedifference < 0.5) { Cscan.publish(publishscan); } count++; ros::spinOnce();
{ "domain": "robotics.stackexchange", "id": 16403, "lm_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, odometry, laser, amcl", "url": null }
Ebola is one such disease amenable to the SEIR model. Here is the code of it just in R markdown:. In what follows, we describe these two components of our model. # incorrect S = -S * I * beta I = S * I * beta - I * gamma # correct S = -S * I * beta / N I = S * I * beta / N - I * gamma. When a disease is introduced to a population, the people move from one of these classes (or compartments) to the next. 0 = 0 and R 0 = 0. Dear colleagues, I m a new R-help user. Following some basic parameters for Ebola in the popular science to date, we model this disease using parameters for $$R_0$$, the average durations spent in the exposed and. The solutions of SEIIrR model was determined by using fourth order of Runge-Kutta algorithm, equilibrium point obtained was free-drug equilibrium point. In this paper we proved global stability of the SIR and SEIR models with the incidence rate IpSq: This conclusion is valid. The page should load with some parameters already in the box. pulse epidemic model conducted in this paper has analyzed the trend of the disease in the theoretical aspect which will contribute to making the strategy of the disease prevention. 2: Epidemic trajectory A typical trajectory of the system solution in the I-S phase plane is given in Fig. Model specification. We use an epidemic model of SEIR-type that classifies individuals as susceptible (S), exposed (E), infectious (I), recovered (R) and dead (D) (Anderson & May 1991). Featured Article F. SEIR is an epidemiological model used to predict infectious disease dynamics by compartmentalizing the population into four possible states: Susceptible [S], Exposed or latent [E], Infectious [I] or Removed [R]. metrics import mean_squared_error, r2_score: from sklearn. Our group currently maintains operating layouts in HO-Gauge, N-Gauge, and 3-Rail O-Gauge, plus an HO-Gauge traveling layout. (1) Explained the propagation theory of virus spreading on the social networking [3]. In Figure 3, we can examine that the number of susceptible population decreases by 80% in first 100 days as per the listed assumptions. Given a fixed population, let
{ "domain": "saltotech.it", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9854964186047326, "lm_q1q2_score": 0.8080019396751337, "lm_q2_score": 0.8198933293122507, "openwebmath_perplexity": 1856.8157294912369, "openwebmath_score": 0.5575017929077148, "tags": null, "url": "http://saltotech.it/rmty/seir-model-in-r.html" }
gravity, nuclear-physics, stars Title: What will happen if a ball of ice with the mass of sun is thrown into the sun? The question is a bit unrealistic with its circumstances but lets assume there is a bucket of ice cooled down to about absolute zero and is about 1000 km away (all around the sun) from sun and moving with v_0 = 1000km/sec, what will be if that all water with mass of sun reaches the sun. UPDATE Basically I have read about this in gizmodo http://gizmodo.com/could-the-sun-be-extinguished-by-a-bucket-of-water-just-1669914928 but did not agreed , thats why I have decided to ask about this phenomena here, hoping to find out more precise answer This would be a highly energenic event, a gravitational collapse in combination with the initial inward velocity of 1000km/s (which is greater than the escape velocity at the surface of the sun). There would be some type of nova event initially because the hydrogen already present in the sun would be compressed by the infalling new material, greatly enhancing fusion. Some material may be ejected and become a nebula in the nova event; rebouding energy would be a factor in addition to enhanced fusion, as in a core collapse supernova. The water would dissociate into atomic hydrogen and oxygen. Of the material not ejected in the nova event, the oxygen would eventually form a core at the center of a star, with lighter elements (H, He) being a shell around the core. What happens from there depends upon the mass remaining. If the remaining mass is less than 1.39 solar masses (the Chandrasekhar limit), the star would eventually become an inert white dwarf star, with the oxygen core being sustained by electron degeneracy pressure and unable to undergo oxygen fusion. If more than 1.39 solar mass remain, the star could become a neutron star.
{ "domain": "physics.stackexchange", "id": 21941, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "gravity, nuclear-physics, stars", "url": null }
c++, boost expression &expression::less_than(expression rhs) { expr = binary_operator("<", std::move(expr), std::move(rhs)); return *this; } expression &expression::less_equals(expression rhs) { expr = binary_operator("<=", std::move(expr), std::move(rhs)); return *this; } expression &expression::greater_than(expression rhs) { expr = binary_operator(">", std::move(expr), std::move(rhs)); return *this; } expression &expression::greater_equals(expression rhs) { expr = binary_operator(">=", std::move(expr), std::move(rhs)); return *this; } expression &expression::factor(expression rhs) { expr = binary_operator("**", std::move(expr), std::move(rhs)); return *this; } expression &expression::dot(expression rhs) { expr = binary_operator(".", std::move(expr), std::move(rhs)); return *this; } struct printer { void operator()(const double n) const { std::cout << n; } void operator()(const std::string &s) const { std::cout << s; } void operator()(const expression &ast) const { boost::apply_visitor(*this, ast.expr); }
{ "domain": "codereview.stackexchange", "id": 38663, "lm_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++, boost", "url": null }
f#, rss <pubDate>Sun, 22 Jan 2017 14:39:09 +0000</pubDate> <dc:creator><![CDATA[Christopher J. McClellan]]></dc:creator> <category><![CDATA[Programming]]></category>
{ "domain": "codereview.stackexchange", "id": 26939, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "f#, rss", "url": null }
Algebraically the inverse of f ( x ) is y. y=2x+1 x=2y+1 2y+1=x 2y=x-1 y=0.5 ( x-1 which function is the inverse of? there! There is only one output of functions and their inverses Dan received an$ discount... = x2 − 16 i can find the inverse of a function, cubic and polynomial $discount! Is also a function ) when given an equation for an inverse is! Output are switched interval [ 0,4 ] linear, exponential, logarithmic cubic! This answer helpful use the inverse of a function ) when given an of... Has an inverse that is given as input relation ( which may also a!, you agree to our Cookie Policy learning algebra is learning how to find the of. Y. y=2x+1 x=2y+1 2y+1=x 2y=x-1 y=0.5 ( x-1 ) So there you have it is denoted as: f x. Website, you agree to our Cookie Policy explore the graphs of and. Now that we understand the inverse of a function that undoes the action of another function, we will the! ) is y. y=2x+1 x=2y+1 2y+1=x 2y=x-1 y=0.5 ( x-1 ) So there have... Question in Top Homework Answers ( x-1 ) So there you have it a number the. [ 0,4 ] [ 0,4 ] of g ( x ) = x^2 on the interval [ 0,4?! I can find the inverse function, the role of the input and output are switched division..., or f ( x ) = x ( x-1 ) So there you have it ⇔ −... Logarithmic, cubic and polynomial 19 more users found this answer helpful 4 times x the... Given as input in mathematics, an inverse function is the same as dividing its reciprocal and vice.! Input there is only one output 19 more users found this answer helpful it is as. Answer helpful set we can find an equation of a function function ) when given equation... Returns an input for \ ( f\ ) [ 0,4 ] inverse is the inverse an... = x^2 on the interval
{ "domain": "irfandergisi.com", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9658995713428385, "lm_q1q2_score": 0.8110986716685357, "lm_q2_score": 0.8397339596505965, "openwebmath_perplexity": 607.9469687300766, "openwebmath_score": 0.6708158254623413, "tags": null, "url": "https://irfandergisi.com/herbert-vianna-jqtx/which-function-is-the-inverse-of-%3F-cd05b6" }
python, python-3.x, file Title: Open a text file and remove any blank lines I have the following functions which help me to open a text file and remove any blank (empty) lines: def fileExists(file): try: f = open(file,'r') f.close() except FileNotFoundError: return False return True def isLineEmpty(line): return len(line.strip()) < 1 def removeEmptyLines(file): lines = [] if not fileExists(file): print ("{} does not exist ".format(file)) return out = open(file,'r') lines = out.readlines() out.close() out = open(file,'w') t=[] for line in lines: if not isLineEmpty(line): t.append(line) out.writelines(t) out.close() As you can see I open a file 2 times. One for reading and one for writing. Is there anything I can to to improve this code? First thing is that your function fileExists can be replaced with os.path.isfile function Now here you cannot have negative size of string so to make it less confusing you can do just: def isLineEmpty(line): return len(line.strip()) == 0 however I would not even create a function for this, because empty string is a False in boolean meaning so this: for line in lines: if not isLineEmpty(line): t.append(line) will be replaced with: for line in lines: if line.strip(): t.append(line) which can be prettifed using filter function: lines = filter(lambda x: x.strip(), lines) Now speaking about opening files, it is better to use with statement, it is safer, prettier and more pythonic way. So this: out = open(file,'r') lines = out.readlines() out.close() will be just: with open(file,'r') as out: lines = out.readlines() Another thing is that python functions/variables should named using underscore as separtor. So in the end what we have is: import os
{ "domain": "codereview.stackexchange", "id": 22595, "lm_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, file", "url": null }
quantum-mechanics, quantum-information, group-theory, quantum-computer My guess to the first question is that this set of unitaries forms a submanifold of $U(d)$ of dimension $d^2 - d$ isomorphic to $U(d) \ / \ \mathbb{C}^d$, but I am completely unsure about the second. Are there known answers to these questions, or in general is there anything that can be said about this class of unitaries? Say your state space is $D = 2^d$ dimensions. Without loss of generality, consider an orthonormal basis of states we will label by $| i \rangle$, where $i = 1 \ldots D$, where $|1\rangle = | \psi \rangle$, and $|i \rangle$ for $i > 1$ are other random states. In this basis, a few things become clear. If we have any block diagonal matrix of the form $$ U' = \begin{pmatrix} 1 & \mathbf{0} \\ \mathbf{0} & U_{D-1}\end{pmatrix} $$ where $U_{D-1}$ is any $(D-1) \times (D-1)$ matrix, then we clearly have $$ U' |\psi\rangle = U' |1\rangle = |1 \rangle = |\psi \rangle. $$ Therefore, we have a whole $U(D-1)$ worth of transformations that preserve $|\psi \rangle$. If we have your matrix $U_0$, composing it with one of these matrices $U'$ will preserve the property that $(U' U_0) |0 \ldots 0 \rangle = |\psi \rangle$. In fact, once we have $U_0$, we can get all the other such matrices by simply multiplying it in this way $U' U_0$.
{ "domain": "physics.stackexchange", "id": 78145, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "quantum-mechanics, quantum-information, group-theory, quantum-computer", "url": null }
python, sql, database, sqlite Further to that, your select exists and insert should not be separated, but should be in the same query. After executing it, check rowcount to see if anything was successfully inserted. Even more combination: do not have a separate select for get the ID of the paper that was just added; that should also be in the same statement using a returning clause. paper_days_cost and paper_days_delivered appear to have the same keys. If they have the same existence characteristics, they should be merged into one table. I encourage you to work on the above, and (after some time has passed and you've gathered enough feedback from the community) post a new question with your updated code.
{ "domain": "codereview.stackexchange", "id": 43242, "lm_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, sql, database, sqlite", "url": null }
which is option (4) in the problem. Once again, the limit should converge relatively quickly, so let’s check. The claimed value is 1.81093; taking $$n=5$$ the sum is $$0.390476+0.373913+0.36+0.348148+0.337931\approx1.810468$$. That looks pretty good. This site uses Akismet to reduce spam. Learn how your comment data is processed.
{ "domain": "themathdoctors.org", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9787126469647337, "lm_q1q2_score": 0.8239054036205229, "lm_q2_score": 0.8418256432832333, "openwebmath_perplexity": 353.8571032926591, "openwebmath_score": 0.8976531624794006, "tags": null, "url": "https://www.themathdoctors.org/writing-a-riemann-sum-as-an-integral/" }
general-relativity, reference-frames, equivalence-principle, coriolis-effect, frame-dragging \begin{eqnarray} \mathbf{G}&=&-\frac{GM\mathbf{r}}{r^{3}}\\ {\bf H}&=&\frac{2G}{c^{2}}\left(\frac{{\bf J}}{r^{3}}-\frac{3({\bf J}\cdot{\bf r}){\bf r}}{r^{5}}\right)\label{eq:H-Earth}, \end{eqnarray} where $M$ and $\mathbf{J}$ are mass and angular momentum of the planet and $c$ is the speed of light. The $c^{-2}$ coefficient in front of Coriolis field indicates that we are dealing with the first post-Newtonian (gravitomagnetic) approximation to the full GR expression. Note, that this Coriolis field is position-dependent, unlike the pure rotation. Finally, the third possibility slowly rotating spherical planet as seen from the frame, co-rotating with the planet would be the combination of the first and second cases (while possibly, the slowness of rotation means that one could drop the frame dragging terms). Since these expressions are analytic, finding enough derivatives of $\bf G$ and $\bf H$ at the position of the elevator with sufficient precision would in principle allow one to distinguish between possibilities and even calculate parameters such as planet's mass and its rotation. Of course, this is more of a theoretical possibility, since in practice the fields of a planet vary only on the scales comparable to its size, while the size of the elevator (presumably only a few meters) is too small to register noticeable variations. On the other hand, if the centrifuge is of a reasonable size one could at least either confirm or exclude this possibility with ease.
{ "domain": "physics.stackexchange", "id": 73336, "lm_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, reference-frames, equivalence-principle, coriolis-effect, frame-dragging", "url": null }
c#, performance, enum And I have the following performance test: public static void Benchmark(int listCount, int testCount) { var r = new Random(); var randomList = GenerateRandomEnumeration(listCount, () => r.Next()).ToList(); var watch = new Stopwatch(); for (int j = 0; j < testCount; j++) { Console.WriteLine("Test #{0}", j); watch.Start(); var orderedList = randomList.OrderBy(i => i).ToList(); watch.Stop(); Console.WriteLine("Order on random list took: {0} ms", watch.ElapsedMilliseconds); watch.Reset(); watch.Start(); orderedList = orderedList.OrderBy(i => i).ToList(); watch.Stop(); Console.WriteLine("Order on ordered list took: {0} ms", watch.ElapsedMilliseconds); watch.Reset(); watch.Start(); var ordered = randomList.IsOrdered(); watch.Stop(); Console.WriteLine("IsOrdered on random list: {0}", ordered); Console.WriteLine("IsOrdered on random list took: {0} ms", watch.ElapsedMilliseconds); watch.Reset(); watch.Start(); ordered = orderedList.IsOrdered(); watch.Stop(); Console.WriteLine("IsOrdered on ordered list: {0}", ordered); Console.WriteLine("IsOrdered on ordered list took: {0} ms", watch.ElapsedMilliseconds); Console.WriteLine(); watch.Reset(); } Console.WriteLine("Test finished."); Console.ReadLine(); } private static IEnumerable<T> GenerateRandomEnumeration<T>(int count, Func<T> randomizer) { var counter = 0; while (counter < count) { yield return randomizer(); counter++; } }
{ "domain": "codereview.stackexchange", "id": 15996, "lm_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, enum", "url": null }
electrostatics, electric-circuits, electrical-resistance, capacitance, dissipation In the case where the wires have very low resistance, energy will oscillate for a period of time between being stored entirely in the capacitors and being partially stored in the magnetic field due to inductance from the current flow. Let's do an example. Assume $C_1$ is $1\text{F}$ and $C_2$ is $2\text{F}$, and both are charged with $q=1\text{C}$. $$U = \frac{Q^2}{2C}$$ $$U_1 = 0.5\text{J}$$ $$U_2 = 0.25\text{J}$$ $$U_{tot} = 0.75\text{J}$$ This agrees with your first formula, because it's just a sum of the energy on each capacitor. Connecting them in parallel means that each must have the same voltage. $$V_1 = V_2$$ $$\frac{Q_1}{C_1} = \frac{Q_2}{C_2}$$ But the total charge is conserved so $$Q_1 + Q_2 = 2\text{C}$$ $$Q_2 = 2\text{C} - Q_1$$ Solving these two equations means steady-state afterward is $$Q_1 = 0.66\text{C}$$ $$Q_2 = 1.33\text{C}$$ And the energy in this configuration is $$U_1 = \frac{(0.66\text{C})^2}{1\text{F}} = 0.22J$$ $$U_2 = \frac{(1.33\text{C})^2}{2\text{F}} = 0.44J$$ $$U_{tot} = 0.67J$$ So there was a bit of loss from attaching. Oops. Did this wrong the first time, but this agrees with your equation (modified for 2 caps)
{ "domain": "physics.stackexchange", "id": 37380, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "electrostatics, electric-circuits, electrical-resistance, capacitance, dissipation", "url": null }
homework-and-exercises, electromagnetism, maxwell-equations, variational-calculus Title: Understanding why $\frac{\partial (F_{\mu \nu} F^{\mu \nu})}{\partial (\partial_\lambda A_\beta)}=4 F^{\lambda \beta}$ in Maxwell's Equations In trying to derive Maxwell's equations from $$S=\int d^4 x\left(-\frac 1 4 F_{\mu \nu}F^{\mu \nu}\right)$$ Where $$F_{\mu \nu}=\partial_\mu A_\nu-\partial_\nu A_\mu$$ I'm trying to show that $$\frac{\partial (F_{\mu \nu} F^{\mu \nu})}{\partial (\partial_\lambda A_\beta)}=4 F^{\mu \nu}$$ But there seems to be something wrong with how I'm going about doing this. My work currently: $$\frac{\partial F_{\mu \nu}}{\partial(\partial_\lambda A_\beta)} = \frac{\partial F^{\mu \nu}}{\partial(\partial_\lambda A_\beta)}=\delta_{\lambda \mu}\delta_{\beta \nu}-\delta_{\lambda \nu}\delta_{\beta \mu}$$ Where $\delta$ is the Kronecker-Delta function. From this we find that
{ "domain": "physics.stackexchange", "id": 69866, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "homework-and-exercises, electromagnetism, maxwell-equations, variational-calculus", "url": null }
Here is a plot of the integers up to 300. It's a bit jumbled. The six arms are less visible, but do you see anything taking their place? #### r <= 600 The numbers up to 600. Now a new family of spirals is visible. There are 44 of them. That's because 44 is close to a multiple of $2\pi$. This fact is better known as 22/7 is a fair approximation to $\pi$. The spirals are turning counterclockwise because 44 is greater than $7\pi$ whereas the earlier spirals are turning clockwise because 6 is less than $2\pi$. #### r <= 2000 The integers up to 2000. The 44 arcs are dominant. Homework: which arms contain the primes? #### r <= 20000 It was getting crowded, so now it's just the blue points, the primes, up to 20,000. What is that big, white swath? #### r <= 100000 The primes less than 100,000. New structures emerge. These radial arms appear because 355/115 is a remarkably good approximation to $\pi$. We are finally seeing evidence of a deep fact about the primes, Dirichlet's theorem on the distribution of primes among residue classes. See Grant Sanderson's video for the details. #### prime_spiral_2.m Here an animated gif showing my app prime_spiral_2 in action. It automatically zooms in and out continuously, or you can drive it yourself with a scroll bar. This app is included in release 4.7 of Cleve's Laboratory. Send me email if you would like a standalone copy. Published with MATLAB® R2018b |
{ "domain": "mathworks.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9759464499040092, "lm_q1q2_score": 0.8024125673346876, "lm_q2_score": 0.8221891348788759, "openwebmath_perplexity": 727.2861985539555, "openwebmath_score": 0.717467188835144, "tags": null, "url": "https://blogs.mathworks.com/cleve/2019/10/14/prime-spiral-2/" }
robotic-arm, kinect Title: Kinect + Udoo Quad? I am wondering if it would be possible to get Kinect to work with Udoo board (Quad). I have found that there is now support for ROS+Udoo. Also saw a question asked about Xtion + Udoo but it would really be great if it could be possible for Kinect+Udoo. I wish someone could give some insights on this matter. Thanks. Originally posted by Kalmah on ROS Answers with karma: 11 on 2014-01-01 Post score: 1 If the Xtion works, the Kinect will probably work as well. Most of the ARM boards I've seen aren't quite powerful enough to handle the bandwidth of the Kinect, but I think the i.MX6 in the Udoo can probably handle it. I think it's worth a try. If you do give it a try, please let me know how it goes. Originally posted by ahendrix with karma: 47576 on 2014-01-02 This answer was ACCEPTED on the original site Post score: 2
{ "domain": "robotics.stackexchange", "id": 16551, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "robotic-arm, kinect", "url": null }
c, c89, postscript void print_preamble(void) { char const * const *p; char timestr[100]; time_t ct; struct tm *ctime; time(&ct); ctime = localtime(&ct); strftime(timestr, sizeof timestr, "%%%%CreationDate: %A %-d %B %Y, %H:%M:%S %Z", ctime); puts("%!PS-Adobe-1.0\n" "%%Creator: Toby's Fantastic Cassette Labeller (c) 1994 90tms\n" "%%Title: Cassette Labels"); puts(timestr); /* fflush(stdout); */ /* system("date '+%%%%CreationDate: %a %d %b %Y, %H:%M:%S %Z'"); */ /* puts(); */ for (p = ps_preamble; *p; p++) { puts(*p); fflush(stdout); } return; } void print_literal(register const char *cp) { putchar('('); while (*cp) switch (*cp) { case '(': case ')': putchar ('\\'); putchar (*cp++); break; case '\\': putchar (*cp++); putchar (*cp?*cp++:'\\'); /* quote if terminal */ break; default: if (*cp & 0x80) printf("\\%03o", (unsigned int)(unsigned char)*cp++); else putchar(*cp++); } putchar(')'); putchar(' '); return; } void print_title(const char *s) { print_literal(s); puts(" 174 leftfituline"); return; }
{ "domain": "codereview.stackexchange", "id": 31970, "lm_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, c89, postscript", "url": null }
Luz Stokes 2022-07-16 Prove or disprove (discrete math) Prove or disprove the following statement. The difference of the square of any two consecutive integers is odd This is working step: let $m,m+1$ be 2 consective integers: $\left(m+1{\right)}^{2}-{m}^{2}$ ${m}^{2}+1+2m-{m}^{2}$ $1+2m$ If m is odd then $2m=\text{even}$, if m is even then $2m=\text{even}$, then adding 1 will make it odd. Can you please advise me if my working is the right step and could I answer like this? esbalatzaj Expert Step 1 Your proof looks correct. You might want to make it more clear that you are saying $\left(m+1{\right)}^{2}-{m}^{2}=\left({m}^{2}+2m+1\right)-{m}^{2}=2m+1$when you do your arithmetic. Step 2 You also don't need to consider the cases where m is even and odd separately: since 2m is a multiple of 2, it must be even, and so you can conclude that $2m+1$ is not evenly divisible by 2, so it is odd. Raynor2i Expert
{ "domain": "plainmath.net", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.983342957061873, "lm_q1q2_score": 0.8084938930137611, "lm_q2_score": 0.8221891327004133, "openwebmath_perplexity": 237.20823091945638, "openwebmath_score": 0.829393208026886, "tags": null, "url": "https://plainmath.net/discrete-math/82772-prove-or-disprove-the-following-statemen" }
javascript <body> <div id="divSolution"></div> </body> </html> Here's my attempt to help you. As a general rule, keep everything as general as you can and don't split your code into different cases unless you have to. From the if (factor >1) part, I knew things could be improved At the end, the denominators will be the Least Common Multiple of the two initial fractions. Then, you just need to multiply the numerators by the same amount used to multiply the denominators Here's the corresponding code. // Finds the highest common factor of 2 numbers function highestCommonFactor(a, b) { if (b == 0) { return a; } return highestCommonFactor(b, a%b); } function leastCommonMultiple(a,b) { return a*b/(highestCommonFactor(a,b)); } // Input fractions to add //////////////////////////////// // Fraction 1 = 2/6 var fraction1Numerator = 2; var fraction1Denominator = 6; // Fraction 2 = 1/2 var fraction2Numerator = 1; var fraction2Denominator = 2; //////////////////////////////////////////////////////////////// // Find the highest common factor of both denominators var commonMultiple = leastCommonMultiple(fraction1Denominator, fraction2Denominator); fraction1Numerator *= (commonMultiple / fraction1Denominator); fraction2Numerator *= (commonMultiple / fraction2Denominator);
{ "domain": "codereview.stackexchange", "id": 2954, "lm_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", "url": null }
matlab, stft, spectrogram Title: How to obtain the Spectrogram of a signal I am trying to use Matlab to compute the spectrogram of a signal but I can't seem to figure out how Matlab computes the spectrogram.Consider the case where I have a signal x(t) with M samples and I want to compute it's spectrogram using hann windows of length N and using an overlap of K samples. Because there are M samples and the advance time is (N - K) samples, I would expect the resultant spectrogram to have dimensions of either $N$ by $\frac{W}{(N - K)}$ OR if matlab only provides frequencies up to $\frac{f_s}{2}$ then dimensions to be $\frac{N}{2}$ by $\frac{W}{(N-K)}$ but I am getting weird dimensions. The code below shows the case where I have computed the spectrogram when M = 32 * 700 = 24400, N = 256 and K = 256 - 32 = 224. %specgram(data, ChunkSize, SampleRate, Size Of Hanning Window, Overlap (in Samples) D = specgram( 1:1:(32*700),256, 8000 ,256 , 224);
{ "domain": "dsp.stackexchange", "id": 1577, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "matlab, stft, spectrogram", "url": null }
metallurgy, casting, ceramics As an aside I'm not sure how much work you have done on the whole concept of extruding molten titanium through a nozzle but it seems a bit iffy to me as I am not aware of any current process which does anything remotely like this and for absolute certain in TIG welding any contact between the tungsten electrode and the base metal is normally considered a defect as the base/filler will instantly alloy with the tungsten and contaminate it.
{ "domain": "engineering.stackexchange", "id": 798, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "metallurgy, casting, ceramics", "url": null }
c++, unit-testing, classes, c++20, overloading Title: Operator overloading in Image class implementation in C++ This is a follow-up question for Dictionary based non-local mean implementation in C++. There are some issues about operators (operator+ and operator-) mentioned by Edward's answer and JDługosz's comment. I am trying to propose the fixed version of Image class as below. operator+ and operator- operator overloading: friend Image<ElementT> operator+(Image<ElementT> input1, const Image<ElementT>& input2) { return input1 += input2; } friend Image<ElementT> operator-(Image<ElementT> input1, const Image<ElementT>& input2) { return input1 -= input2; } The full Image class implementation: template <typename ElementT> class Image { public: Image() = default; Image(const std::size_t width, const std::size_t height): width(width), height(height), image_data(width * height) { } Image(const std::size_t width, const std::size_t height, const ElementT initVal): width(width), height(height), image_data(width * height, initVal) {} Image(const std::vector<ElementT> input, std::size_t newWidth, std::size_t newHeight): width(newWidth), height(newHeight) { if (input.size() != newWidth * newHeight) { throw std::runtime_error("Image data input and the given size are mismatched!"); } image_data = std::move(input); } constexpr ElementT& at(const unsigned int x, const unsigned int y) { checkBoundary(x, y); return image_data[y * width + x]; } constexpr ElementT const& at(const unsigned int x, const unsigned int y) const { checkBoundary(x, y); return image_data[y * width + x]; }
{ "domain": "codereview.stackexchange", "id": 42598, "lm_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++, unit-testing, classes, c++20, overloading", "url": null }
compilers, parallel-computing, program-optimization Title: Using Loop Dependence analysis for vectorization How exactly Loop Dependence Analysis helps in vectorization ? Are there any standard rules of safety criterias for parallizing such loops ? I found a few resources which helped me to understand the more complex algorithms for use of loop dependence analysis. The basic way in which the result from Loop Dependence Analysis is utilized is through various tests such as Dependence Test of various types such as GCD Test, Conservative Test etc. help in determining if the dependency exists and they can further be utilized to test if the Loop Transformation is safe or not. Following are a few references which helped: 1) http://www.cs.cmu.edu/afs/cs/academic/class/15745-s09/www/lectures/lect6-deps.pdf 2) http://www.cs.utsa.edu/~qingyi/cs6363/slides/Ch02Dependence.pdf 3) http://www.cs.arizona.edu/~collberg/Teaching/553/2011/Handouts/Handout-33.pdf
{ "domain": "cs.stackexchange", "id": 460, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "compilers, parallel-computing, program-optimization", "url": null }
ros-melodic [ERROR] [1597341098.351240102]: Apparently trajectory initialization failed Please, can you help me in this regard. Some suggestions or indicators to anything that may be the cause of this problem. thanks, Zahid Originally posted by zahid990170 on ROS Answers with karma: 135 on 2020-07-13 Post score: 1 If you only start the robot_state_visualize_r1000ia80f.launch, which allows you to visualise the current state, but nothing more, you cannot control motion. Edit: I had added a move_group node in the launch file to be able to experiment with motion control Do not edit the files in the support packages. For normal usage, there is no need. If you think you need to change something in them, it's most likely because you haven't configured something correctly. Also: the robot_state_visualize does not start the necessary driver components to be able to command motion, even if you'd add move_group to the .launch file. However, later I used the following roslaunch fanuc_r1000ia80f_moveit_config moveit_planning_execution.launch robot_ip:=192.168.0.4 use_bswap:=false I was able to see the movements that I performed in rviz being done in Roboguide. That would indeed be the correct .launch file to use for commanding the robot via MoveIt in Roboguide. But, now I am getting this error TPIF-052 WARN FWD/BWD is disabled and I cannot run the ROS TP program again.I had tried FCTN->Abort All, but it does not work. You could see whether FCTN->Disable FWD/BWD helps. But seeing as you write you could command the robot in Roboguide using MoveIt, there is nothing wrong with the ROS side, including fanuc_driver. I would suggest you ask Fanuc about your problems with the Teach Pendant and/or your controller. Originally posted by gvdhoorn with karma: 86574 on 2020-08-14 This answer was ACCEPTED on the original site Post score: 0
{ "domain": "robotics.stackexchange", "id": 35268, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "ros-melodic", "url": null }
homework-and-exercises, classical-mechanics, energy, coordinate-systems Title: Is there a quick way of finding the kinetic energy on spherical coordinates? Assume a particle in 3D euclidean space. Its kinetic energy: $$ T = \frac{1}{2}m\left(\dot x^2 + \dot y^2 + \dot z^2\right) $$ I need to change to spherical coordinates and find its kinetic energy: $$ T = \frac{1}{2}m\left(\dot r^2 + r^2\dot\theta^2 + r^2\sin^2\theta\dot\phi^2\right) $$ Its well known that: $$ x = r\sin\theta\cos\phi \\ y = r\sin\theta\sin\phi \\ z = r\cos\theta $$ A way of doing it is taking the time derivatives, arriving with $3+3+2=8$ different terms with some squares, then open it arriving at $6+6+3 = 12$ different terms majority of them with 4 sine or cossine multiplications. Then to cancel out some terms somehow to arrive in this neat $3$-term expression for kinetic energy in spherical coordinates. In short, a lot of work just to arrive in a simple expression. Here is my question: Is there a shorter way? Or even better: is there an effortless way? There is an effortless way, if you accept geometrical reasoning. You know, that $T = \frac 1 2 m \vec v^2 = \frac 1 2 m \lvert \vec v \rvert^2$. Furthermore, spherical coordinates are orthogonal, therefore you can just write: $$\lvert \vec v \rvert = \sqrt{v_\phi^2 + v_\theta^2 + v_r^2}$$ Geometrically, one easily finds: $v_r = \dot r$, $v_\theta = r \dot \theta$ and $v_\phi = r \sin(\theta) \dot \phi$. And thus the result:
{ "domain": "physics.stackexchange", "id": 21996, "lm_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, classical-mechanics, energy, coordinate-systems", "url": null }
Your approach is pretty good, but I would note that since the limit does not exist, $$\limsup_{n\to\infty}a_n\gt\liminf_{n\to\infty}a_n$$ and that $$\limsup_{n\to\infty}\frac1{a_n}=\frac1{\liminf\limits_{n\to\infty}a_n}$$ Therefore, $$\limsup_{n\to\infty}a_n\cdot\limsup_{n\to\infty}\frac1{a_n} =\frac{\limsup\limits_{n\to\infty}a_n}{\liminf\limits_{n\to\infty}a_n}\gt1$$ • Where can I find a formal proof of this claim: $\limsup_{n\to\infty}\frac1{a_n}=\frac1{\liminf\limits_{n\to\infty}a_n}$? – Mister Bister Jan 29 '18 at 20:17
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9888419677654415, "lm_q1q2_score": 0.8014355588819493, "lm_q2_score": 0.8104789086703225, "openwebmath_perplexity": 593.0734204411618, "openwebmath_score": 0.9885246157646179, "tags": null, "url": "https://math.stackexchange.com/questions/2627062/a-n-non-convergent-sequence-such-that-1-le-a-n-le-2-prove-or-disprove" }
(b) ($\to$)Suppose $S = R$ and $R$ is symmetric. Thus: 1. $R \subseteq S$. 2. $S$ is symmetric. 3. Suppose $T \in A \times A$ is a set such that $R \subseteq T$ and $T$ is symmetric. Since $S = R$, thus $S \subseteq T$. Thus $S$ is reflexive closure of $R$. Since $S = R$, $R$ is symmetric closure of $R$. ($\leftarrow$)Suppose $S = R$ such that $S$ is symmetric closure of $R$. Since $S$ is symmetric closure of $R$, it follows that $S$ is symmetric. Thus $R$ is symmetric. Similarly it can be proved for transitive that $R$ is transitive iff $R$ is transitive closure of $R$. Soln8 Suppose $S$ is symmetric closure of $R$. Thus $S$ is symmetric. Suppose $x \in Dom(S)$. Thus there exist an element $y$ such that $(x,y) \in S$. Since $S$ is symmetric, it follows that $(y,x) \in S$. Thus $x \in Ran(S)$. Since $x$ is arbitrary, it follows that $Dom(S) = Ran(S)$. Now to prove $Dom(S) = Dom(R) \cup Ran(R)$:
{ "domain": "inchmeal.io", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.993096162337438, "lm_q1q2_score": 0.82757146375198, "lm_q2_score": 0.8333246015211008, "openwebmath_perplexity": 87.49871291233737, "openwebmath_score": 0.9989765882492065, "tags": null, "url": "https://www.inchmeal.io/htpi/ch-4/sec-4.5.html" }
ros Originally posted by Rextab on ROS Answers with karma: 71 on 2020-11-25 Post score: 0 This question is I believe related to this one: https://answers.ros.org/question/346578/libroscppso-cannot-open-shared-object-file-no-such-file-or-directory-error/#366424 I my case it is not an issue with the LD_LIBRARY_PATH that is not set but on capabilities that have been increased on the python executable. A sudo setcap cap_net_admin,cap_net_raw+ep /usr/bin/python3.6 has been executed. The problem with that is that for security reasons the LD_LIBRARY_PATH is ignored when one uses setcap. Hence python3.6 would not be able to find the the ros libraries, only the python package. One issue I had to debug this is that the setcap is necessarily done on the executable and not on the symlink. Hence if you do getcap on python or python3 one will see nothing! I hope this issue will help others! Originally posted by Rextab with karma: 71 on 2020-11-26 This answer was ACCEPTED on the original site Post score: 3 Original comments Comment by CodeFinder on 2021-06-08: Indeed, thank you so much for this! A setcap on my Python executable was the reason for rosout terminating immediately due to not finding libroscpp.so (although properly installed, Ubuntu 20.04, ROS1 noetic). Was able to fix it with sudo setcap -r /usr/bin/python3.8. Comment by hipforth on 2022-03-30: sudo setcap -r /usr/bin/python3 Comment by aks on 2023-02-23: This solves the problem. Thanks. However do you know why was this cap set and how ? do we need to always remove this cap ? Comment by miksi on 2023-06-03: I need to have authorized with setcap when running the my python script. So how can I authorize both python and run ros? pysoem issue with ros
{ "domain": "robotics.stackexchange", "id": 35799, "lm_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 }
ros, best-practices, compilation, cmake Originally posted by roehling with karma: 1951 on 2012-04-03 This answer was ACCEPTED on the original site Post score: 2 Original comments Comment by Haikal Pribadi on 2012-04-03: exactly! thank you for reminding me this - it's funny how I overlooked this. Hence I can always have compiled packages on my machine yet the released repo only have the source code. And now i'm confused which one to mark as answer. I guess i'll leave it to the votes till tomorrow. Comment by mlanting on 2012-10-31: what do you do about generated source files that end up in the src directory? Do you just let them be, or add something like src/my_package to svn ignore? Comment by roehling on 2012-11-05: Ignore them; if necessary, name the files individually or by some wildcard like *.moc.cpp
{ "domain": "robotics.stackexchange", "id": 8836, "lm_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, best-practices, compilation, cmake", "url": null }
The compactification of the real numbers, in a useful way that fits in with the ordering of the reals, requires the addition of two points, whereas the compactification of the complex numbers is naturally accomplished by adding just one point. Because analysis readily switches between the real and complex cases, it is considered by some authors appropriate to use a "balanced" pair of symbols, $+\infty$ and $-\infty$, for the real case, which reflects the symmetry of their roles, and the unsigned $\infty$ for the complex case. This is a stylistic choice. Other authors are not of this persuasion. Their argument is "We don't write $+3$ when we mean $3$; so why should we have to write $+\infty$? And, in the complex case, which is always clear from the context, writing $\infty$ is good enough for anyone". In my view, siding with the latter type of author, writing $+\infty$ instead of (real) $\infty$ is unnecessary, just as it is unnecessary to write $(-1\;\pmb,\,+\!1)$ to denote the interval $(-1\;\pmb,\,1)$. • There is a one point compactification of the reals. It's not that useful for studying the reals themselves, though, because it is exactly the same as the circle. – Ian Oct 4 '17 at 16:37
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9702399086356109, "lm_q1q2_score": 0.8852819752442975, "lm_q2_score": 0.9124361586911174, "openwebmath_perplexity": 230.86852229597366, "openwebmath_score": 0.9814448356628418, "tags": null, "url": "https://math.stackexchange.com/questions/2453591/difference-between-infty-and-infty" }
biochemistry Title: Food which does not produce urea My professor of bioengineering said that all foods produce urea. Do foods exist which does not produce urea? Thank you very much. Food doesn't produce urea, your body produces urea from the nitrogen content of the food you eat (mostly comes from proteins). So you can eat e.g honey, which contains minimal, if any, amount of nitrogen.
{ "domain": "chemistry.stackexchange", "id": 8865, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "biochemistry", "url": null }
# Alternating series test #### Alexmahone ##### Active member Alternating series test: If $\{a_n\}$ is positive and strictly decreasing, and $\lim a_n=0$, then $\sum(-1)^n a_n$ converges. Is the alternating series test still valid if "strictly decreasing" is omitted? Give a proof or counterexample. Last edited: #### CaptainBlack ##### Well-known member Alternating series test: If $\{a_n\}$ is positive and strictly decreasing, and $\lim a_n=0$, then $\sum(-1)^n a_n$ converges. Is the alternating series test still valid if "strictly decreasing" is omitted? Give a proof or counterexample. Consider the series with terms $$a_n=1/n$$ for $$n$$ odd and $$2/n$$ for $$n$$ even. Now $$\{a_n\}$$ is a sequence of positive terms and $$\lim_{n \to \infty}a_n=0$$ but $$\sum (-1)^n a_n$$ diverges since the $$k$$-th partial sum is the $$k$$-th partial sum of the alternating harmonic series and the half the $$\lfloor k/2 \rfloor$$-th partial sum of the harmonic series. Hence the sequence of partial sums diverges since the sequence of partial sum of the alternating harmonic series converges and that of the harmonic series diverges. CB Last edited: #### Alexmahone ##### Active member Consider the series with terms $$a_n=-1/n$$ for $$n$$ odd and $$2/n$$ for $$n$$ even. That's not a valid counterexample since $\{a_n\}$ should be positive. #### Also sprach Zarathustra
{ "domain": "mathhelpboards.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9759464527024445, "lm_q1q2_score": 0.8235964375384837, "lm_q2_score": 0.8438951084436077, "openwebmath_perplexity": 1250.4629200043041, "openwebmath_score": 0.9547292590141296, "tags": null, "url": "https://mathhelpboards.com/threads/alternating-series-test.289/" }
c#, beginner, mysql, database /*** * * Search the grid based on which radio button is selected, called when text is entered into the text box * ***/ private void SearchGrid(object sender, TextChangedEventArgs e) { DataView dv = dataGrid.ItemsSource as DataView; if (nNameRad.IsChecked == true) { dv.RowFilter = "em_netname LIKE '%" +searchBox.Text+ "%'"; } if (deptRad.IsChecked == true) { dv.RowFilter = "em_dept LIKE '%" + searchBox.Text + "%'"; } if (sNameRad.IsChecked == true) { dv.RowFilter = "em_name LIKE '%" + searchBox.Text + "%'"; } if (initRad.IsChecked == true) { dv.RowFilter = "em_init LIKE '%" + searchBox.Text + "%'"; } } } } UserSelection takes advantage of another classes functionality, DataAcessor namespace SDC_Database { class DataAccessor { /*** * * Select all of the valid users for use by the DataGrid in UserSelection.xaml * ***/ public DataTable FillDataGrid() { string constr = ConfigurationManager.ConnectionStrings["dbfString"].ConnectionString; using (OleDbConnection dbfCon = new OleDbConnection(constr)) { try { dbfCon.Open(); DataTable dTable = new DataTable(); OleDbCommand MyQuery = new OleDbCommand("SELECT em_pplid, em_name, em_netname, em_init, em_dept FROM employs WHERE em_netname NOT LIKE '' AND em_type != 2", dbfCon); OleDbDataAdapter dataAdapter = new OleDbDataAdapter(MyQuery); dataAdapter.Fill(dTable); return dTable; } catch (OleDbException) { throw; } } }
{ "domain": "codereview.stackexchange", "id": 16135, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c#, beginner, mysql, database", "url": null }
is an integral, and since the integral over a sum of several masses equals the sum of the integrals over the individual masses, we can find the moment inertia of a composite mass by adding the moments of inertia of its parts. Using this moment of inertia calculator is very easy. In-Class Activities: • Check Homework • Reading Quiz • Applications • Mass Moment of Inertia • Parallel-Axis Theorem • Composite Bodies • Concept Quiz • Group Problem Solving. Accurately and quickly calculate the moment of inertia, centroid, torsion constant and statical moment of area of a beam section using SkyCiv's Section Builder. The Iyy of every (small) part of the ship has to be calculated with its own mass and its perpendicular you can use this online calculator for radius of gyration so moment of inertia. The second moment of area is commonly used in engineering disciplines, where by custom is called moment of inertia. 0 in, and t =0. It also determines out how much of your repayments will go towards the principal and how much will go towards interest. The following Steel I beam moment of inertia calculator has been developed to calculate the Steel I beam area moment of inertia and polar moment of inertia. Conversely, the moment of inertia about a base diameter axis can be computed by adding one1-. Each calculator is associated with web pageor on-page equations for calculating the sectional properties. Interactive Graphing Calculator - Desmos Calculator. You can show the division by drawing solid or broken lines across the irregular shape. Calculate the LL in PSF based on the MLL. c) Determine the principal moments of inertia and the orientation of the principal axes. In Tables 6 to 8 are listed the values of inertia moments, for long term effects, relevant to the 3 most common classes of concrete: C20/25, C25/30 and C30/37. Thus, for I-beams in particular, the moment curvature relationship. Moments of Inertia of Common Shapes. They must be combined using their moments about specified axes to find their composite structural properties, which is what this moment of inertia calculator does for you. 0 For brass, nEE== = ba/ 105/70 1. Find Select the object to which you want to calculate the moment
{ "domain": "campusdergenerationen.de", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.986777179025415, "lm_q1q2_score": 0.8044528205223533, "lm_q2_score": 0.8152324938410784, "openwebmath_perplexity": 673.9583066303479, "openwebmath_score": 0.6343695521354675, "tags": null, "url": "http://campusdergenerationen.de/composite-moment-of-inertia-calculator.html" }
electromagnetism, spacetime, metric-tensor, potential, curvature I am really keen on the idea of geometrizing all of physics using the spacetime manifold … As an advise, I would recommend to familiarize yourself with more traditional routes of geometrizing physics (such as mentioned above Kaluza–Klein and Newton–Cartan theories) before studying more radical/lesser known ideas.
{ "domain": "physics.stackexchange", "id": 81335, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "electromagnetism, spacetime, metric-tensor, potential, curvature", "url": null }
Now, here is where things become really interesting. Since we know the mean and variance, lets normalize and look at the function $$\frac{\omega(n)-\log \log n}{\sqrt{\log \log n}}.$$ We can ask, how is this distributed? In 1940, Erdos and Kac proved that $\omega(n)$ is normally distributed. That is, the number of prime factors function behaves like the normal distribution with mean $\log \log N$ and variance $\log \log N$. Specifically, for any fixed real numbers $a,b$, we have that$$\frac{1}{N}\left|\left\{n\leq N:\ a\leq\frac{\omega(n)-\log \log n}{\sqrt{\log \log n}}\leq b\right\}\right|=\frac{1}{\sqrt{2\pi}}\int_a^b e^{-x^2/2}dx +o(1).$$ - I am not quite sure that I understand exactly what you're asking, but I think that some of the following points may shed some light on the matter. Suppose we fix $n$ and let $k$ vary. Studying $\pi_k(n)/n$ is then equivalent to looking at the distribution of the number of prime factors of integers up to $n$ (by the way, this turns out not to be very sensitive to the distinction between "with repetition" and "without repetition"). We have to be a bit careful as the asymptotic for $\pi_k(n)$ is intended for $k$ fixed and $n$ growing (but we can still use it as long as $k$ grows sufficiently slowly with $n$). With that caveat in mind, the approximate distribution given by GPNT can be rewritten as: $$\frac{\pi_{k+1}(n)}{n} \approx \frac{\lambda^{k} e^{-\lambda}}{k!},\quad k=0,1,2,\ldots$$
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9863631619124992, "lm_q1q2_score": 0.8219606908972948, "lm_q2_score": 0.8333246035907933, "openwebmath_perplexity": 114.08612731405819, "openwebmath_score": 0.9398696422576904, "tags": null, "url": "http://math.stackexchange.com/questions/168307/generalized-pnt-in-limit-as-numbers-get-large" }
quantum-chemistry, molecular-orbital-theory, orbitals, basis-set Title: The eigenvector matrix C I was wondering what the difference between $c_n$ and $c_{jn}$ is? In the context of molecular orbital construction, for example, if $c_{jn}$ is the coefficient of the basis functions $\phi_j$ (contribution of the constituting atomic orbitals), what would $c_n$ be? $\mathbf{c}_n$ is a vector with $N$ entries (I switched to boldface to indicate - hopefully slightly more clearly - that it is a vector): $$\mathbf{c}_n = \begin{pmatrix}c_{1n} \\ c_{2n} \\ \vdots \\ c_{Nn}\end{pmatrix}$$ This effectively means the same thing as writing $$\psi_n = c_{1n}\phi_1 + c_{2n}\phi_2 + \cdots + c_{Nn}\phi_N = \sum_j c_{jn}\phi_j$$ I'll try to contextualise it. The columns of the eigenvector matrix are simply the eigenvectors themselves, so if (for example) the eigenvectors of an operator $\mathbf{A}$ are $$\mathbf{c}_1 = \begin{pmatrix}p \\ q\end{pmatrix}; \qquad \mathbf{c}_2 = \begin{pmatrix}r \\ s\end{pmatrix}$$ then the corresponding eigenvector matrix $\mathbf{C}$ is $$\mathbf{C} = \begin{pmatrix} \mathbf{c}_1 & \mathbf{c}_2 \end{pmatrix} = \begin{pmatrix} p & r \\ q & s \end{pmatrix}$$ [As an addendum: If the eigenvectors $\mathbf{c}_i$ are normalised, then you will find that
{ "domain": "chemistry.stackexchange", "id": 8266, "lm_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-chemistry, molecular-orbital-theory, orbitals, basis-set", "url": null }
python, python-3.x, file-system, ssh def copy_all_files(lst, origin_directory, destination, ssh, sftp): """ This copies files from a list, from an origin directory to the destination. """ for _file in lst: if type(_file) != str: _file = _file.decode('utf-8') if not bool(re.search(r'\_c\.', _file)): try: download_file(sftp, _file, origin_directory, destination) rename_file(sftp, _file, origin_directory, "_c.") except FileNotFoundError: print("Could not find", origin_directory + _file) continue except OSError: print("OSError on", str(os.path.join( origin_directory, _file)), "--------------<<") continue else: print(_file, "already copied") def main(): sftp, ssh = connect_to_ssh_server( "192.168.0.100", 2222, "testUsr", "supersecretpassword") android_path = "DCIM/camera/" # use `.*` to copy all filetypes files = list_files(android_path, ".*", ssh) origin_directory = '/storage/emulated/0/' + android_path copy_all_files(files, origin_directory, '/media/pi/My Passport/Galaxy S8/', ssh, sftp) ssh.close() if __name__ == "__main__": main() This is decent code, job well done! I have a few nitpicks, PEP8 violations Functions and variables should be snake_case Group your imports
{ "domain": "codereview.stackexchange", "id": 33895, "lm_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, file-system, ssh", "url": null }
c#, beginner, tic-tac-toe, unity3d It might require some fixing I haven't tested this, but I'm pretty sure it should work like this. And the usage : ManualCheck(0, 1, 2); ManualCheck(3, 4, 5); ManualCheck(6, 7, 8); ManualCheck(0, 3, 6); ManualCheck(1, 4, 7); ManualCheck(2, 5, 8); ManualCheck(0, 4, 8); ManualCheck(2, 4, 6); However this will only work if there's never a Tie. I see you haven't implemented this one yet so I will help you a little bit. Declare a boolean variable called haveWinner. You will change it's value inside the ManualCheck method whenever we find a winner. Next you will need some LINQ to determine whether the entire board is filled and add few more lines under the place where you check if the board is full using System.Linq; ManualCheck(0, 1, 2); ManualCheck(3, 4, 5); ManualCheck(6, 7, 8); ManualCheck(0, 3, 6); ManualCheck(1, 4, 7); ManualCheck(2, 5, 8); ManualCheck(0, 4, 8); ManualCheck(2, 4, 6); if (haveWinner) { return; } int count = Slots.Count(slot => slot.Used); if (count != Board.Length) { return; } Debug.Log("Tie"); Fix your formatting, also else if is usually written on 1 line not 2.
{ "domain": "codereview.stackexchange", "id": 21301, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c#, beginner, tic-tac-toe, unity3d", "url": null }
python, python-3.x, interpreter class HRMException(Exception): pass class TileError(HRMException): def __init__(self, data): super().__init__( "Bad tile address! " "Tile with address {} does not exist! " "Where do you think you're going?" .format(data)) class OutOfBoundsError(HRMException): def __init__(self): super().__init__( "Overflow! " "Each data unit is restricted to values between -999 and 999. " "That should be enough for anybody.") class OperandsError(HRMException): def __init__(self, operator): super().__init__( "You can't {0} with mixed operands! " "{0}'ing between one letter and one number is invalid. " "Only nice respectable pairs of two letters or two numbers are allowed.! " .format(operator)) class HRMType: letters = set() def get(self, *_): return self.data class Empty(HRMType): def __init__(self, data): self.data = data class Number(HRMType): letters = set(string.digits) def __init__(self, data): self.data = int(data) class Word(HRMType): letters = set(string.ascii_letters) def __init__(self, data): self.data = str(data) class Pointer: letters = set('[]') def __init__(self, other): self.other = other self.letters |= other.letters self.pointer = False self.data = None def __call__(self, data): data = str(data) self.pointer = False if data[0] == '[': if data[-1] != ']': raise HRMException("Mismatched parenths") self.pointer = True data = data[1:-1] self.data = self.other(data).get() return self
{ "domain": "codereview.stackexchange", "id": 20645, "lm_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, interpreter", "url": null }
graphs, network-flow Title: Basic questions about network flow calculations Flow networks are often constructed when one is interested in measuring how resilient a graph is. The idea goes as follows: two vertices are designated as source $(s)$ and sink $(t)$ respectively, to each edge $e$ of the graph a capacity $c_e$ is assigned (which can be defined as a function vertex properties of the endpoints of an edge), and in analogy to flow of water through pipes for example, a net flow is assumed to take place from the source towards the sink. That is the net flow out of the source, is equal to the net flow entering the sink: $$ \sum_{u\in O(s)} f(s,u)-\sum_{u\in I(s)}f(u,s)=\sum_{u\in I(t)} f(u,t)-\sum_{u\in O(t)}f(t,u) $$ where $O(s)$ denotes the set of vertices, that $s$ is incident on, and $I(s)$ denotes the set of vertices that are incident to $s.$ Now often, one is interested in computing the maximum possible flow in the graph, which leads to using Menger's theorem, which relates maximum number of distinct paths (between $s$ and $t$) to the minimal cut-set, or in a general setting, it relates the maximum flow to minimum cut capacity (summing the capacities of the minimum cut, that disconnects source from sink). There are many algorithms that allow computing the maximum flow rather efficiently, for a given digraph. But my questions are (sadly) rather basic, but are solely related to computing maximum flow:
{ "domain": "cs.stackexchange", "id": 6733, "lm_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, network-flow", "url": null }
ros <node pkg="gscam" type="gscam" name="gscam" cwd="node"> <env name="GSCAM_CONFIG" value="v4l2src device=/dev/video0 ! video/x-raw-rgb,framerate=30/1 ! ffmpegcolorspace"/> </node> <node pkg="image_proc" type="image_proc" ns="gscam" name="image_proc"> </node> <node pkg="nodelet" type="nodelet" args="standalone image_proc/crop_decimate" name="my_decimator"> <param name="x_offset" type="int" value="1" /> <param name="y_offset" type="int" value="1" /> <param name="width" type="int" value="639" /> <param name="height" type="int" value="439" /> <!-- remap input topics --> <remap from="camera/image_raw" to="/gscam/image_rect_color"/> <remap from="camera/image_info" to="/gscam/camera_info"/> <!-- remap output topics --> <remap from="camera_out/image_raw" to="/camera_crop/image_rect_color"/> <remap from="camera_out/image_info" to="/camera_crop/camera_info"/> </node> </launch> Originally posted by Thomas with karma: 4478 on 2012-10-04 This answer was ACCEPTED on the original site Post score: 7
{ "domain": "robotics.stackexchange", "id": 11228, "lm_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 }
wireless, ros-hydro, network, network-setup, multiple-machines Information of onboard computer: ecejames01@ECE521:~$ hostname ECE521 ecejames01@ECE521:~$ ifconfig eth0 Link encap:Ethernet HWaddr 00:0a:9d:e0:08:e4 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:304 errors:0 dropped:0 overruns:0 frame:0 TX packets:28624 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:82259 (82.2 KB) TX bytes:5861182 (5.8 MB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:7216011 errors:0 dropped:0 overruns:0 frame:0 TX packets:7216011 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:244946501281 (244.9 GB) TX bytes:244946501281 (244.9 MB) wlan1 Link encap:Ethernet HWaddr c4:d9:87:eb:90:fb inet addr:192.168.0.101 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::c6d9::87ff:feb:90fb/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:8273 errors:0 dropped:0 overruns:0 frame:0 TX packets:4890 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2417399 (2.4 MB) TX bytes:473450 (473.4 KB)
{ "domain": "robotics.stackexchange", "id": 21155, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "wireless, ros-hydro, network, network-setup, multiple-machines", "url": null }
signal-analysis, signal-detection, bandpass $$ = 0.2 \bigg(\cos(2\omega_c t) + 1 \bigg) - 0.6\bigg(\sin(2\omega_c t)+0\bigg)- 0.2j\bigg(\sin(2\omega_c t)-0\bigg) + 0.6j\bigg( 1 - \cos(2\omega_c t)\bigg)$$ $$ = 0.2 + j0.6 - 0.2\sin(2\omega_c t) - j0.6\cos(2\omega_c t)$$ $$ = x(t) - (0.6\sin(2\omega_c t) + j0.6\cos(2\omega_c t)) \tag{4} \label{4}$$ Thus we see how each individual sample of $y(t)2e^{-j\omega_c t}$ is the sum of $x(t)$ and a high frequency signal at frequency $\omega_c$. To recover $x(t)$ from the passband signal, a filter is required to separate these, which necessitates multiple samples (not just one). Trying to recover $x(t)$ from one sample of the product is the same as asking what the variables $a$ and $b$ are in the equation $a+b=5$! Alternatively in implementation and with the mathematical analysis we can recover the baseband signal from the real passband signal using the analtic signal which is given as: $$y_a(t) = y(t) + j\hat y(t)$$ Where $y_a(t)$ is the "analytic signal" given by the above relationship, and $\hat y(t)$ is the Hilbert Transform of $y$ (which I will note also requires multiple samples to solve for in implementation).
{ "domain": "dsp.stackexchange", "id": 11093, "lm_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, signal-detection, bandpass", "url": null }
java, android, unit-conversion fromRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { if (fromInput.getText().toString().trim().length() > 0) { checkFrom(); } } }); toRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { if (fromInput.getText().toString().trim().length() > 0) { checkFrom(); } } }); } private void fromGram(double valueToConvert) { toOutput.setText(String.valueOf(valueToConvert * fromGramMap.get(toRadioGroup.getCheckedRadioButtonId()))); } private void fromKilogram(double valueToConvert) { toOutput.setText(String.valueOf(valueToConvert * fromKilogramMap.get(toRadioGroup.getCheckedRadioButtonId()))); } private void fromMicrogram(double valueToConvert) { toOutput.setText(String.valueOf(valueToConvert * fromMicrogramMap.get(toRadioGroup.getCheckedRadioButtonId()))); } private void fromMilligram(double valueToConvert) { toOutput.setText(String.valueOf(valueToConvert * fromMilligramMap.get(toRadioGroup.getCheckedRadioButtonId()))); } private void fromOunce(double valueToConvert) { toOutput.setText(String.valueOf(valueToConvert * fromOunceMap.get(toRadioGroup.getCheckedRadioButtonId()))); }
{ "domain": "codereview.stackexchange", "id": 18610, "lm_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, android, unit-conversion", "url": null }
ros, c++, installation, rosbag, windows Title: What do I need to read in a .bag file? Hey everybody, this is the first time I got in contact with ROS as part of my work and I could really need some advice as I can't really seem to find the information I need in the documentation. All I have to do is to read data from a .bag file using c++ (preferably on Windows). I know how to do it in code (saw the example) and I know know that there is a version for Windows (although experimental). But I'm wondering if I have to go through the whole installation process or if I can just download some required parts, and if so which parts would that be? At the moment, I'm pretty confused concerning what I actually need to write a very simple reader application in Visual Studio. I already have the .bag file, there's no need for any functionality apart from reading and I don't want to bloat the project. I hope some of you guys can help me figure this out. If you only know an answer for Linux, that's fine, maybe it can be applied on Windows, too. Thank you very much in advance! Originally posted by BlurEffect on ROS Answers with karma: 7 on 2017-07-25 Post score: 0 I'm not aware of any C++ version of a rosbag library that is Windows compatible -- other than the one that ROS comes with and would require "going through the whole installation process" (but then on Windows) -- but if Java is acceptable then you could take a look at swri-robotics/bag-reader-java. You could also just take the swri-robotics classes and reimplement a C++ version. Edit: the main thing here is rosbag_storage, which is a plain C++ library, but with a set of ROS dependencies. With some work it could potentially be ported to Windows, but that's probably more work than you're willing to do. Originally posted by gvdhoorn with karma: 86574 on 2017-07-25 This answer was ACCEPTED on the original site Post score: 1
{ "domain": "robotics.stackexchange", "id": 28431, "lm_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, c++, installation, rosbag, windows", "url": null }
lattices Title: Finding optimal set for a sum of a product function over a 2D lattice Given a 2D lattice with coordinates $1 \leq x \leq c$ and $1 \leq y \leq d$, we define $f(x, y) = xy$. We wish to find a boolean function $I(x,y)$ that determines in $O(1)$ time whether or not $(x,y)$ belongs to the set of points $S$ of size $k$ such that the sum $Z(S) = \sum_{(x,y) \in S} f(x,y)$ is smaller or equal to any other set of size $k$. One may use $O(c+d+k)$ time and space to construct $I$. Is this possible? Is this a known problem (my search turned up nothing)? Can https://en.wikipedia.org/wiki/Divisor_summatory_function and its approximation help us? Motivation: I work in NLP and am trying to find an optimal way of storing part of a word-word cooccurrence matrix in memory and part on disk. This matrix is very sparse. I'm making the simplifying assumption that the probability of two works co-occurring is proportional to their unigram frequencies. By ranking words in terms of frequency, we get the $c$ and $d$ terms. So the smaller the ranks $c$ and $d$, the more likely they are to co-occur, so this value should be stored in memory. Since there will be billions of lookups, $I$ needs to be fast. Thanks! The set $S$ must have the following form: there must exist a threshold $t$ such that: If $xy < t$, then $(x,y)$ is in $S$. Some or all of the points $(x,y)$ with $xy=t$ are in $S$. If $xy > t$, then $(x,y)$ is not in $S$.
{ "domain": "cs.stackexchange", "id": 7941, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "lattices", "url": null }
c++, array, casting Title: Converting from `std::array>` to `void*` I'm doing some work with Vulkan, in this I need to pass a set of values of various types. Currently I'm using std::array<std::variant<>> in my interface, but I must pass Vulkan a void*. To convert to the void* I use this function: template <uint32_t Size> void* voidArray(std::array<std::variant<uint32_t,float>,Size>& array, uint32_t size) { char* bytes = new char[size]; uint32_t byteCounter = 0; for(uint32_t i=0;i<array.size();++i) { if(float* flt = std::get_if<float>(&array[i])) { *reinterpret_cast<float*>(bytes+byteCounter) = *flt; byteCounter += sizeof(float); } else if(uint32_t* uin = std::get_if<uint32_t>(&array[i])) { *reinterpret_cast<uint32_t*>(bytes+byteCounter) = *uin; byteCounter += sizeof(uint32_t); } } void* data = static_cast<void*>(bytes); return data; }
{ "domain": "codereview.stackexchange", "id": 40669, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c++, array, casting", "url": null }
co.combinatorics, pr.probability, it.information-theory, shannon-entropy where $\delta()$ is the total variation distance . 5. The last step I tried is to find any connection between $\delta(\mu,\eta)$ and $|\text{Cov}[X,Y]|$ - ideally $|\text{Cov}[X,Y]| \leq \delta(\mu, \eta)$ - the problem is that seems like there is no such connection, I can find distribution where $|\text{Cov}[X,Y]| > \delta(\mu, \eta)$ and other distribution where the opposite holds. I strongly believe that if this claim is correct, the proof goes through Pinsker's inequality, since it is very similar. Any advice will be appreciated. EDIT: As I was told in the comments, it holds that if $|X|, |Y| \leq 1$, $|\text{Cov}[X,Y]| \leq \delta (\mu, \eta)$ - the proof is in the comments. I was wrong when I thought I had a counter example. I also believe that the accepted answer below is correct. I think you can show it as follows, and even get a better constant in the end. Forewarning, there's enough cleverness here that I'm kind of suspect that everything is right. But the basic idea is simple enough: reduce to the case where $X$ and $Y$ take values in $\{0,1\}$, where we can exploit a nice relationship between covariance and total variation distance for such variables. From there, the rest of your proof idea works out. First, introduce $\tau_X$ and $\tau_Y$ as uniform, independent draws from $[0,1]$. Define $\hat{X} = 1$ if $X \ge \tau_X$ and $\hat{X}=0$ otherwise, and define $\hat{Y}$ similarly. Then we have the following relationships:
{ "domain": "cstheory.stackexchange", "id": 4069, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "co.combinatorics, pr.probability, it.information-theory, shannon-entropy", "url": null }
ros2, docker, macos Title: ROS2 listener/talker only works for talker on MacOS Sonoma 14.2 on M1-Max within docker I have Sonoma 14.2 on my M1-Max and can not make it run for talker/listener couple of ROS2 in docker container I followed steps at here Talker sends messages but no response from listener. How should I discover the issue ? I am running talker/listener in same container and not giving any config definition for startup docker run -it osrf/ros:iron-desktop in docker shell : ros2 run demo_nodes_cpp listener & ros2 run demo_nodes_cpp talker When you start your Docker ROS container are you telling it --net=host ? This is my start ROS 2 Docker (on Raspberry Pi5 but you'll get the idea): #!/bin/bash cd ~/pi5desk/ros2ws # --rm removes container after exit # --w working dir to start in echo -e "\n*** STARTING ROS 2 HUMBLE PLUS IN DOCKER ***" docker run -it --net=host -v /home/pi:/home/pi -w /home/pi/pi5desk/ros2ws --rm r2hdp echo -e "\n*** EXITED DOCKER ***" If you used the first example - it should have worked. ros2 run demo_nodes_cpp listener & ros2 run demo_nodes_cpp talker Did it? Did you start the Docker container detached and connect two terminal sessions to the same container? (That should have worked without needing a network.) If you started two docker containers interactively, without specifying a network - the two containers cannot see each other. That will not work. Please clarify exactly your sequence of commands to start docker, and run the talker and listener.
{ "domain": "robotics.stackexchange", "id": 38836, "lm_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, docker, macos", "url": null }
c, image, music return 0; } I know this is probably the most random thing ever, but it is quite intriguing in my opinion. (You just got Rickroll'd). Strange loop initialization Hm, what's up with this loop initialization? for (int i = i; i < 12000028; i++) { i is not even defined at this point. Write it the non-confusing way: for (int i = 0; i < 12000028; i++) { Magic number 12000028 The number 12000028 and 12000028 + 1 and 12000028 + 15 appears in multiple places in the code. It would be better to #define and reuse. #define BMP_SIZE 12000028 char bmp[BMP_SIZE]; // Need 12000028 bits, 1 pixel is 3 // ... int main() { // ... for (int i = 26; i < BMP_SIZE; i++) { bmp[i] = fgetc(fp); } // ... for (int i = 0; i < BMP_SIZE; i++) { fputc(bmp[i], fp); } // ... } Error checking You checked nicely the result of opening the input file file.wav. But then, why didn't you do the same for the output file file.bmp? Use puts instead of printf when possible When you print plain text ending with newline and you don't need to print variables, then puts is better than printf. So instead of: printf("Error opening 'file.wav'\n"); This is slightly better: puts("Error opening 'file.wav'"); Usability The input and output filenames are hardcoded. That makes this difficult to use. It would be great to take them as command line arguments Suggested implementation Applying the above suggestions: #include <stdio.h> #define BMP_SIZE 12000028 char bmp[BMP_SIZE]; // Need 12000028 bytes, 1 pixel is 3 // bits and table is 28 (1500^2 * 3 + 28) int main(int argc, char ** argv) {
{ "domain": "codereview.stackexchange", "id": 16513, "lm_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, image, music", "url": null }
noise, power-spectral-density, power % Initialize sum variables for Y and Ypad sumY = zeros(1, windowSize); sumYpad = zeros(1, 5 * windowSize); for i=0:totalIterations % Check if the current iteration corresponds to a progress increment if any(abs(i / totalIterations - progressIncrements) < eps) % Display progress to the command window fprintf('%.0f%% completed\n', i / totalIterations * 100); end % signal plus noise noise = noise_amplitude * randn(size(x)); y = signal + noise; ywindowed = y.* hanningWindow'; % Zero-padding by a factor of 4 ywindowed_padded = [ywindowed, zeros(1, 4*length(ywindowed))]; if i==0 figure(n); n = n+1; plot(x, ywindowed); title('Time Domain - Windowed Signal'); end Y = abs(fft(ywindowed)).^2; % zero padding Ypad = fft(ywindowed_padded).^2; % Accumulate Y and Ypad values sumY = sumY + Y; sumYpad = sumYpad + Ypad; end fprintf("Calculation done\n"); % two sides average bin width PSD window function sumYpad = 2*sumYpad / (totalIterations * (length(ywindowed))^2);%/0.25; sumY = 2*sumY / (totalIterations * (length(ywindowed))^2);%/0.25; %sumY = sumY -(sumY(10000)-sumYpad(10000)); % get padded and not padded to same level
{ "domain": "dsp.stackexchange", "id": 12409, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "noise, power-spectral-density, power", "url": null }
machine-learning, python, deep-learning, numpy, reshape ..., [[0.01006036], [0.01006036]], [[0.01006036], [0.00804829]], [[0.00804829], [0.01207243]]], dtype=float32) Try the following code. As you want all first value of zeroth dimension. test=test[:,0,0]
{ "domain": "datascience.stackexchange", "id": 7731, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "machine-learning, python, deep-learning, numpy, reshape", "url": null }
optics, waves, field-theory, refraction, huygens-principle The maximum rate of increase of $\psi$ with respect to distance is $|\nabla\psi|$ and it is in the direction of $\nabla\psi$. The neighboring surface $\psi = 2\,\pi\,\omega\,(t+\mathrm{d} t)$ lies a constant, normal distance $\mathrm{d}r$ from the surface $\psi = 2\,\pi\,\omega\,t$; the phase difference between them is $2\,\pi\,\mathrm{d}r/\tilde{\lambda}$, where $\tilde{\lambda}(\vec{x})$ is the wavelength in the medium at the point in question. So the maximum rate $|\nabla\psi|$ is $2\,\pi/\tilde{\lambda}$ radians per meter, whence: $$|\nabla \psi|^2 = k^2 = n(\vec{x})^2\,k_0^2$$ where $k_0=2\,\pi/\lambda_0$ is the freespace wavenumber and $\lambda_0$ the freespace wavelength. Now if we divide $\psi,\,\phi$ by the constant $k_0$ and use these as the phase fields instead of measuring the phase in radians, we get the result claimed. So we're actually measuring the phase in cycles and distance in wavelengths.
{ "domain": "physics.stackexchange", "id": 46201, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "optics, waves, field-theory, refraction, huygens-principle", "url": null }
python, algorithm, python-3.x, array Depending on the value that ends the current subarray, a new subarray can start where it changed between min to max, or the reverse. Or it could start with the new value. For example, [1,1,2,2,3,3] has overlapping subarrays [1,1,2,2] and [2,2,3,3]. But [1,1,2,2,0,0] doesn't: [1,1,2,2] and [0,0].
{ "domain": "codereview.stackexchange", "id": 38729, "lm_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, python-3.x, array", "url": null }
newtonian-mechanics, kinematics, geometry, rotation, rigid-body-dynamics Title: How is Chasles' Theorem, that any rigid displacement can be produced by translating along a line and then rotating about the same line, true? Chasles' Theorem in its strong form says: The most general rigid body displacement can be produced by a translation along a line (called its screw axis) followed (or preceded) by a rotation about that same line. Now, Euler's Theorem simply says that any rigid body displacement can be decomposed into a rotation plus translation. This is easy to visualize. But what Chasles' Theorem says is something much stronger. Unfortunately, I am just not able to visualize it. Perhaps, I am comprehending it wrong. I mean how is it possible to have the axis of rotation and translation the same (or parallel) for the most general displacement. I mean, think of this case:
{ "domain": "physics.stackexchange", "id": 38825, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "newtonian-mechanics, kinematics, geometry, rotation, rigid-body-dynamics", "url": null }
If $$k = 12,13$$ or $$14$$, we've already seen that $$p(k+1)$$ is also true, so suppose that $$k \geq 15$$. Then we know that $$12 \leq k-3\leq k$$ so then by our strong inductive hypothesis, there exists $$x,y \in \mathbb{Z}$$ such that $$k-3 = 4(x) + 5(y)$$. Then adding $$4$$ to both sides gives that $$k+1 = 4(x+1)+5(y)$$ so that $$P(k+1)$$ is true. Thus by the principle of mathematical induction, $$P(n)$$ must be true for all $$n \geq 12$$. • Wow this is very detailed and helped me understand it more, thank you! – MathNoob Feb 15 '19 at 4:15 • No problem! I'm glad this helped! – JonHales Feb 15 '19 at 4:17 $$4x+5y=\underbrace{4(x-1)+5y}_{n-4}+4$$ So, if $$n-4$$ is expessible so will be $$n$$ $$12=4\cdot3$$ $$13=2\cdot4+5$$ $$14=4+2\cdot5$$ $$15=3\cdot5$$
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9828232950125849, "lm_q1q2_score": 0.8539032067010474, "lm_q2_score": 0.8688267881258485, "openwebmath_perplexity": 89.83641628509169, "openwebmath_score": 0.828149139881134, "tags": null, "url": "https://math.stackexchange.com/questions/3113510/prove-that-each-integer-n-%E2%89%A5-12-is-a-sum-of-4s-and-5s-using-strong-induction" }
javascript, mapreduce Title: Looping over a bidimensional array and extract data to a new one I have a bidimensional array like this: const bArray = [ [ 'Hello World', 'Hi everybody', 'How are you?' ], [ { text: 'Hola Mundo', from: [Object], raw: '' }, { text: 'Hola a todos', from: [Object], raw: '' }, { text: 'Cómo estás?', from: [Object], raw: '' }, ] ] And I need to get as a result, only one array that should look like this: [ { en: 'Hello World', es: 'Hola Mundo' }, { en: 'Hi everybody', es: 'Hola a todos' }, { en: 'How are you?', es: 'Cómo estás?' }, ] This is how I do it: let val1 = bArray[0].map(tuple => tuple); let val2 = bArray[1].map(tuple => tuple); let result = val1.reduce((arr, v, i) => arr.concat({"en" : v, "es" : val2[i].text}), []); And now in the result variable, I have only one array with the result showed before. My question? Is there any improved way in which I can get the same result but with fewer lines of code? I mean, something like a combination of map with reduce, filter or concat in only one or two lines of code. You can compact a lot into a single line, but that is most times not the best thing to do in both source code quality and execution efficiency. const bArray = [['Hello World', 'Hi everybody', 'How are you?'], [{ text: 'Hola Mundo', from: [Object], raw: '' }, { text: 'Hola a todos', from: [Object], raw: '' }, { text: 'Cómo estás?', from: [Object], raw: '' },]];
{ "domain": "codereview.stackexchange", "id": 30702, "lm_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, mapreduce", "url": null }
newtonian-mechanics, reference-frames, acceleration, centripetal-force, coriolis-effect [Later edit] About names of things: there are some conventions in circulation, but there is little consistency, and in that sense there is no right or wrong. Issues of language aside: The overall underlying phenomenon is inertia. Because of inertia: to sustain circular motion a centripetal force is required. Next case: Let an object be in sustained circular motion. At some point the amount of centripetal force is dialed down. Then the object will gain a radial velocity. Because of inertia: as the radial distance increases the angular velocity decreases. Nowadays there is the following convention: When this effect is described with respect to an inertial coordinate system it is attributed to conservation of angular momentum. When this effect is described with respect to a rotating coordiante system it is attributed to the coriolis force. (If you find that confusing: I find it confusing too. Using two different names for trhe same thing doesn't make any sense.)
{ "domain": "physics.stackexchange", "id": 72188, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "newtonian-mechanics, reference-frames, acceleration, centripetal-force, coriolis-effect", "url": null }
graphs, weighted-graphs Title: Detect cycles of odd total weight in a graph with {0,1}-weighted edges Given an edge-weighted digraph $G = (V, E \subseteq V^2, w \in E \to \{0, 1\})$, is there an algorithm that returns TRUE if there is a cycle in this graph whose total weight is odd and FALSE otherwise, which runs faster than $O((|V| + |E|)(c + 1))$ (where $c$ is the number of simple cycles in the graph, which is of course $\Omega(2^{|V|})$)? As the question implies, I already came up with an algorithm that runs in $O((|V| + |E|)(c + 1))$ time. This algorithm involves first running Johnson's simple cycle enumeration algorithm, which gives us all the simple cycles in the graph. Since even + even = even, and all cycles are made by adding together simple cycles, the graph contains a cycle of odd length iff it contains a simple cycle of odd length. Thus, we just compute the parity of the simple cycles and return TRUE if any of them are odd, and FALSE otherwise. Can anyone come up with a more efficient approach? Ideally, one that is not just "replace Johnson's algorithm with another simple cycle enumeration algorithm that has slightly better asymptotics", since the graphs I'm dealing with really aren't that large, and constant factors may well dominate as a result. You can solve this in $O(|V| \cdot |E|)$ time. Construct a digraph with vertices of the form $\langle v,b\rangle$ where $v \in V$, $b \in \{0,1\}$, as follows: for each edge $v \stackrel{t}{\to} w$ in your graph, add the edges $\langle v,b \rangle \to \langle w,b + t \bmod 2 \rangle$ for each $b \in \{0,1\}$ to the new graph.
{ "domain": "cs.stackexchange", "id": 16196, "lm_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, weighted-graphs", "url": null }
java, algorithm, sorting, kotlin import org.junit.jupiter.api.Assertions.assertFalse import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test internal class ArrayHelperTest { @Test internal fun smallAscendingTest() { val arr = arrayOf(1, 2, 3, 4, 5) assertTrue(arr.isSorted()) assertTrue(arr.isSorted(0, arr.size)) assertTrue(arr.isSorted(naturalOrder(), 0, arr.size)) } @Test internal fun smallDescendingTest() { val arr = arrayOf(9, 7, 6, 4, 3, 2) assertFalse(arr.isSorted()) assertFalse(arr.isSorted(0, arr.size)) assertTrue(arr.isSorted(reverseOrder(), 0, arr.size)) } } Few typical problems: if (comparator.compare(from[i], from[k]) < 0) causes merge sort to lose stability. If the elements compare equal, the value from the right subarray is merged first. Insertion sort implementation is suboptimal: at each iteration of while (i >= lower && comparator.compare(key, arr[i]) < 0) { two conditions are tested. It is possible to test only one. In pseudocode: if key <= array[lower] // Don't bother to compare values. We are guaranteed // that everything is not less than the key. Just shift. while i >= lower arr[i + 1] = arr[i--] else // Don't bother to check indices. We are guaranteed // to not fall off: the first element is less than the key, // and naturally guard the insertion. while key < arr[i] arr[i + 1] = arr[i--] arr[i + 1] = key;
{ "domain": "codereview.stackexchange", "id": 33193, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "java, algorithm, sorting, kotlin", "url": null }
logic, discrete-mathematics, hoare-logic, loop-invariants Title: Hoare Logic for Factorial I came across this hoare logic for factorials but I don't quite understand it. We multiply F and X but we're not adding up all values of F so how do we get the sum/factorial at the end? Precondition: $\{ X > 0 \land X = x \}$ $F := 1$ while $X > 0$ do $\quad F := F \cdot X$ $\quad X := X - 1$ od Postcondition: $\{F = x!\}$ What the Hoare invariant state is the following: If you run the code with $X$ equal to some value $x > 0$, then at the end, $F$ will have the value $x!$ ($x$ factorial). You can check that this is indeed the case.
{ "domain": "cs.stackexchange", "id": 15778, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "logic, discrete-mathematics, hoare-logic, loop-invariants", "url": null }
java if (gtin14.length() != 14) { throw new IllegalArgumentException("GTIN must be 14 digits long"); } Long company_prefix = Long.valueOf(gtin14.substring(1, (company_prefix_length + 1))); Long item_reference_and_indicator = Long.valueOf(gtin14.charAt(0) + gtin14.substring(company_prefix_length + 1, 13)); String bin_filter_value = longToBinaryWithFill((long) filter_value, sgtin96_filter_value_bits); String bin_partition_value = longToBinaryWithFill((long) partition_value, sgtin96_partition_value_bits); String bin_company_prefix = longToBinaryWithFill(company_prefix, company_prefix_bits); String bin_item_reference = longToBinaryWithFill(item_reference_and_indicator, item_reference_and_indicator_bits); String bin_serial_number = longToBinaryWithFill(serial_number, sgtin96_serial_number_bits); String bin_epc = sgtin96_bin_header + bin_filter_value + bin_partition_value + bin_company_prefix + bin_item_reference + bin_serial_number; return zeroFill(binaryToHex(bin_epc), sgtin96_length_hex); }
{ "domain": "codereview.stackexchange", "id": 38361, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "java", "url": null }
mobile-robot, kalman-filter, movement Title: Estimating state of moving object from other moving object What is the best way to estimate the state [x-position; y-position; heading (yaw angle); velocity; acceleration; curvature (or yaw rate)] of a moving leading vehicle with sensors mounted on a follower/ego vehicle? The following measurements of the leading vehicle are obtained via radar sensors mounted on the ego vehicle. x-y-position in the ego coordinate frame heading in ego coordinates relative and absolute velocity and acceleration No information about curvature (yaw rate). This should be estimated which is possible using the lateral acceleration and longitudinal velocity. For estimation I think of using EKF or nonlinear moving horizon estimation. Considering that no prediction about the moving leader vehicle can be made because the control inputs are unknown. Only the measurments (update step) and the movements of the ego vehicle are available (incroporate in prediction). What kind of model would be appropriate for the whole scenario? just a model for the leading vehicle? (e.g. bicycle model) just a model for the following ego vehicle? or a combination of both vehicles? Option 1 would be perfect in combination with a simple bicycle model if there was an outside observer who is not moving. Option 2 is not really an option because the configuration of the leader vehicle should be estimated. Option 3 seems to me the right way because of the following thoughts: Looking from the ego coordinates: is it correct correct that a motion change of the ego vehicle will seem as if the measured locations of the leading vehicle changed? If so will I need a coordinate transformation or is it better to use a model in global coordinates, then transform the measurements (which are in ego coordinates)?. The approach using global coordinates seems counter intuitive because the final estimate should be used for the follower/ego vehicle as reference trajectory. Can you give me a hint which coordinate frame (global or ego) to use, which model to use in the prediction step and if my thoughts on motion changes are correct? Or do you know any sources that address this or a similar issue?
{ "domain": "robotics.stackexchange", "id": 1188, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "mobile-robot, kalman-filter, movement", "url": null }
quantum-mechanics, perturbation-theory Title: Spin degeneracy in perturbation theory In pag. 270 of Griffith's "Introduction to Quantum Mechanics" a perturbative method for finding relativist correction to the energy levels of the Hydrogen athom is exposed. It is asserted, if I understand well, that the operator consisting in $\hat{L}^2\hat{L}_z$ commutes with the Hamiltonian (both the perturbed one and the unperturbed) and has different eigenvalues for each of the $n^2$ eigenstates that have the same $E_n$. This justifies the use of the nondegenerate theory. However, it seems to me that the degeneracy is really $2n^2$, because of the spin. This problem can indeed be solved if we consider the operator $\hat{L}^2\hat{L}_z\hat{S}_z$, but Griffith makes no mention of this. Am I missing something? Note that the underlying point of the paragraph you mention is to justify the use of nondegenerate perturbation theory. Earlier in the chapter he shows that the nondegenerate perturbation theory is justified to use even for a problem $H^0$ that has degenerate states \begin{align} H^0|a^0\rangle&=E_a|a^0\rangle,\\H^0|b^0\rangle&=E_b|b^0\rangle,\\E_a&=E_b \end{align} iff the perturbation matrix elements in the degenerate subspace disappear, i.e. $\langle a^0|H^1|b^0\rangle=0$. On the other hand this is precisely what happens if you happen to find a hermitian operator $A$ which commutes with both the original ($H^0$) and perturbation ($H^1$) Hamiltonians, and has distinct eigenvalues in the degenerate subspace ($A|a^0\rangle=a|a^0\rangle,A|b^0\rangle=b|b^0\rangle$). This is because $$
{ "domain": "physics.stackexchange", "id": 8481, "lm_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, perturbation-theory", "url": null }
nuclear-physics, stability, binding-energy Title: If we assume that protons don't decay, then will all matter ultimately decay into Iron-56 or into nickel-62? Wikipedia says that all matter should decay into iron-56. But it also says Nickel-62 is the most stable nucleus. So could this mean that in the far future, everything could (through quantum tunneling) fuse and/or decay into nickel-62 rather than iron-56? Question inspired by an interesting comment made on a post here: http://www.quora.com/Do-atoms-ever-deteriorate-over-time/answer/Alex-K-Chen/comment/574730 The binding energy curve, again in wikipedia, shows iron as the one with the smallest binding energy per nucleon. Though in the table, the following is stated: 56Fe has the lowest nucleon-specific mass of the four nuclides listed in this table, but this does not imply it is the strongest bound atom per hadron, unless the choice of beginning hadrons is completely free. Iron releases the largest energy if any 56 nucleons are allowed to build a nuclide—changing one to another if necessary, The highest binding energy per hadron, with the hadrons starting as the same number of protons Z and total nucleons A as in the bound nucleus, is 62Ni. Thus, the true absolute value of the total binding energy of a nucleus depends on what we are allowed to construct the nucleus out of. If all nuclei of mass number A were to be allowed to be constructed of A neutrons, then Fe-56 would release the most energy per nucleon, since it has a larger fraction of protons than Ni-62. However, if nucleons are required to be constructed of only the same number of protons and neutrons that they contain, then nickel-62 is the most tightly bound nucleus, per nucleon.
{ "domain": "physics.stackexchange", "id": 22026, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "nuclear-physics, stability, binding-energy", "url": null }
c++, game player_one_roll = will_of_tyche() + player_one_boosts; player_two_roll = will_of_tyche() + player_two_boosts; if (std::max(player_one_roll, player_two_roll) == player_one_roll){ std::cout << player_one_roll << " > " << player_two_roll << "\n"; std::cout << names[0] << " wins!\n"; player_stats_malleable[0][2] += 1'000; player_stats_malleable[1][2] -= 1'000; } else if (std::max(player_one_roll, player_two_roll) == player_two_roll){ std::cout << player_one_roll << " < " << player_two_roll << "\n"; std::cout << names[1] << " wins!\n"; player_stats_malleable[0][2] -= 1'000; player_stats_malleable[1][2] += 1'000; } else { std::cout << "Tie!\n"; } } /* -----PASSIVES----- */ void game_logic::passive_income(){ int upgrade_addition = 1'000 * (.1 * player_stats_malleable[turn_counter][4]); player_stats_malleable[turn_counter][2] += 1'000 + upgrade_addition; }
{ "domain": "codereview.stackexchange", "id": 45206, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c++, game", "url": null }
nielsen-and-chuang, fault-tolerance My question is, how is the size of the circuit derived in Eq(10.114)? It is closely related to Eq(10.113) after some rearranging, but I cannot see exactly how to get Eq(10.114). From Eq(10.113) we can work out the size a simulating circuit must be to achieve the desired accuracy of $\epsilon/p(n)$. Rearranging Eq(10.113), we see $1/(cp)^{2^k} = p(n)/c\epsilon$. Taking the logarithm (base 2, as per @ChrisD) of both sides and rearranging \begin{equation} 2^k = \frac{\log(p(n)/c\epsilon)}{\log(1/cp)} \end{equation} Raising both sides to the power $\log(d)$ and noting $(2^k)^{\log{d}} = d^k$ (as per @ChrisD, again), we can express the size of our circuit as \begin{equation} d^k = \left(\frac{\log\left(p(n)/c\epsilon\right)}{\log\left(1/pc\right)}\right)^{\log{d}} \end{equation} The expression for $d^k$ suggests that the size of the simulating circuit scales as \begin{equation} O\left(\text{poly}(\log p(n)/\epsilon)\right) \end{equation} i.e. the size of the circuit grows no faster than some polynomial function of $\log p(n)/\epsilon$.
{ "domain": "quantumcomputing.stackexchange", "id": 5111, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "nielsen-and-chuang, fault-tolerance", "url": null }
many-body, quantum-chemistry \hat{h}(\boldsymbol{r}_1)\delta(\boldsymbol{r}_1-\boldsymbol{r}'_1) \ \ \ , \ \ \ \langle\boldsymbol{r}_1\boldsymbol{r}_2|\hat{V}|\boldsymbol{r}'_1\boldsymbol{r}'_2\rangle= \frac{1}{|\boldsymbol{r}_1-\boldsymbol{r}_2|} \delta(\boldsymbol{r}_1-\boldsymbol{r}'_1)\delta(\boldsymbol{r}_2-\boldsymbol{r}'_2) \ . $$ The symmetry operator $\hat{R}_1$ acts on $|\phi_p^{(1)}\rangle$ as $$ \hat{R}_1|\phi_p^{(1)}\rangle=\sum_{q=1}^DR_{pq}|\phi_q^{(1)}\rangle \ , $$ and the analogous equation holds for $\hat{R}_2$ and $|\phi_p^{(2)}\rangle$ (note that the $R_{pq}$ matrix elements do not carry any Hilbert space index). Now, let us hit $\hat{F}|\phi_p^{(1)}\rangle$ with $\hat{R}_1$: $$ \begin{aligned} \hat{R}_1\hat{F}|\phi_p^{(1)}\rangle &= \hat{R}_1\hat{h}|\phi_p^{(1)}\rangle + \sum_{k \in \, \text{occ}}
{ "domain": "physics.stackexchange", "id": 94529, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "many-body, quantum-chemistry", "url": null }
Quote: $x^4 + \sqrt{3}x^2 - 3 \:=\: 0$ $\sqrt{3}x^2 \:=\: 3 - x^4$ I squared all terms to get rid of the root. . This is illegal! $3x^4 \:=\: 9 - x^8$ . This is wrong. You must square "legally": . . $\begin{array}{c}\left(\sqrt{3}x^2\right)^2 \:=\:(3-x^4)^2 \\ \\[-3mm] 9x^4 \;=\;9 - 2x^4 + x^8 \\ \\[-3mm] x^8 - 11x^4 + 9 \;=\;0 \end{array}$ Now you can apply the Quadratic Formula. . . $x^4 + \sqrt{3}x^2 - 3 \;=\;0$ . . $x^2 \;=\;\frac{\text{-}\sqrt{3} \pm\sqrt{(\sqrt{3})^2 - 4(1)(\text{-}3)}}{2(1)} \;=\;\frac{\text{-}\sqrt{3}\pm\sqrt{15}}{2}$ Discarding the negative root, we have: . . $x \;=\;\pm\sqrt{\frac{\sqrt{15}-\sqrt{3}}{2}} \;=\;\pm1.034633399$ • Oct 20th 2012, 05:39 PM Prove It Re: Find the real solutions of the equation help Quote: Originally Posted by Soroban Hello, alex95! You must square "legally":
{ "domain": "mathhelpforum.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9504109784205502, "lm_q1q2_score": 0.8115680567852928, "lm_q2_score": 0.8539127548105611, "openwebmath_perplexity": 1663.8312330843046, "openwebmath_score": 1.0000088214874268, "tags": null, "url": "http://mathhelpforum.com/algebra/205751-find-real-solutions-equation-help-print.html" }
c++, animation, physics, polymorphism case SDLK_c: changeColour(); break; default: break; } } return true; } /* * handleMouse: * * The mouse event processing handler. Presently not used. * */ bool MoleculeAnimation::handleMouse(const GraphicsWindow::Event& event) { return true; } /////////////////////////////////////////////////////////////////////////////// // Molecule System (physical) effects // /////////////////////////////////////////////////////////////////////////////// /* * expand() * * Expand the system container (indefinitely) without volume checks. * */ void MoleculeAnimation::expand() { MoleculeSystem::Extents extents = dynamic_cast<MoleculeSystem*>(ptrSystem_)->getExtents(); double speed = 0.1; extents.xmin -= speed * MoleculeVisualisation::kMoleculeRadius_; extents.xmax += speed * MoleculeVisualisation::kMoleculeRadius_; extents.ymin -= speed * MoleculeVisualisation::kMoleculeRadius_; extents.ymax += speed * MoleculeVisualisation::kMoleculeRadius_; extents.zmin -= speed * MoleculeVisualisation::kMoleculeRadius_; extents.zmax += speed * MoleculeVisualisation::kMoleculeRadius_; dynamic_cast<MoleculeSystem*>(ptrSystem_)->setExtents(extents); }
{ "domain": "codereview.stackexchange", "id": 37730, "lm_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++, animation, physics, polymorphism", "url": null }
machine-learning Title: how to derive the steps of principal component analysis? I'm trying to understand the theoretical reasoning behind the method, but I can't understand a particular step in the middle of this page. "The constraint on the numbers in $v_1$ is that the sum of the squares of the coefficients equals $1$. Expressed mathematically, we wish to maximize $$\frac1N\sum_{i=1}^NY_{1i}^2$$ where $$y_{1i}=v_1'z_i,$$ and $$v_1'v_1=1$$ (this is called "normalizing" $v_1$). Computation of first principal component from $R$ and $v_1$. Substituting the middle equation in the first yields $$\frac1N\sum_{i=1}^NY_{1i}^2=v_1'Rv_1."$$ I don't understand how $R$ suddenly appeared in this equation. The right hand side "$v_1' R v_1$" seems to have appeared out of nowhere. Please help \begin{align} \frac1N\sum_{i=1}^N Y_{1i}^2 &= \frac1N\sum_{i=1}^N (v_1'z_i)(z_i'v_1)\\ &=v_1'\left(\frac1N \sum_{i=1}^N z_iz_i' \right) v_1 \\ &= v_1'Rv_1 \end{align} where $R=\frac1N \sum_{i=1}^N z_iz_i'.$
{ "domain": "datascience.stackexchange", "id": 3044, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "machine-learning", "url": null }
fluid-dynamics, home-experiment, viscosity Title: Is a non-Newtonian gas possible? I was wondering if it was possible to have a Non-Newtonian Gas. I was planning a science fair experiment to try to create one if its possible. They exist, but are rare and as far as I know they always contain 'exotic' molecules that will probably be unsuitable for a science fair. A quick google results in this paper as the major result: Cousins et al. 1997 PRL, 79 (2285) Cousins et al. study the excitation gas in superfluid $^3$He-B and find that it behaves in a non-newtonian fashion.
{ "domain": "physics.stackexchange", "id": 14861, "lm_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, home-experiment, viscosity", "url": null }
c# This is the part of the code that actually does anything: static string AtBash(int index) => letters[Math.Abs((index + 1) - letters.Count)]; The code works but I am interested in knowing if it can be made faster/more efficient. I would also like to know if there is an official term for this kind of algorithm. If the entire goal is absolute performance of the AtBash() request, I would simply reverse the letters at startup. I'm speaking outside the context of this particular program and more towards your library where I am making the assumption that the AtBash() method calls vs. startup ratio is much higher to infinite. If that's the case and we can eat some startup time, and you really want that per-access performance on AtBash(), simply eat a tiny bit of memory to get there: static List<string> letters = new List<string> { "Aleph", "Beis", "Gimmel", "Daled", "Hei", "Vav", "Zayin", "Chies", "Teis", "Yud", "Chof", "Lamed", "Mem", "Nun", "Samech", "Ayin", "Pei", "Tzadik", "Kuf", "Reish", "Shin", "Taf" }; static List<string> lettersReversed = letters.AsEnumerable().Reverse().ToList(); static string AtBash(int index) => lettersReversed[index];
{ "domain": "codereview.stackexchange", "id": 20004, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c#", "url": null }
computability, rice-theorem Title: Rice's Theorem for Total Computable Functions Fix a Gödel numbering, and write $\phi_n$ for the function coded by $n$. Rice's theorem states that if $P$ is the set of partial computable functions, and $A \subseteq P$, then the decision problem Given $n$, does $\phi_n \in A$? is decidable if and only if $A = \emptyset$ or $A = F$; that is, if the decision problem always has the same answer. Now consider the set $T$ of total computable functions instead. Clearly, the problem Given $n$ with $\phi_n \in T$, does $\phi_n \in A$? is no longer decidable if and only if $A \in \{\emptyset,T\}$. In fact, for recursive set $M\subseteq \mathbb N^k$, the problem is also decidable for $$ A_M = \{\phi_n \in T \mid (\phi_n(0),\ldots,\phi_n(k-1)) \in M\}. $$ So is it true that the problem is decidable if and only if $A$ is of the form $A_M$ as above? If not, can we give a different restriction on the form of $A$ that does give us a theorem? Almost The correct answer is that a property of recursive languages is r.e. if and only if it can be verified by a finite number of values (though unlike in your example the exact number of values can be unbounded, so $k$ can depend on $n$). In fact, the wikipedia page for Rice's theorem has a section on this: ...the analogue says that if one can effectively determine for every recursive set whether it has a certain property, then only finitely many integers determine whether a recursive set has the property.
{ "domain": "cs.stackexchange", "id": 9804, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "computability, rice-theorem", "url": null }
graph-theory, pr.probability, randomness, random-walks Title: Graph that maximizes minimum hitting time? Let $G$ be some connected bidirectional (or undirected) graph. We define a random walk as a walk that begins at a vertex chosen uniformly at random, and at each step proceeds to one of its current vertex's neighbors uniformly at random. The expected hitting time for a vertex $v$ is the time it takes, on average, for the walk to reach $v$. For what family of graphs is the minimum of all expected hitting times as large as it can be? It is well known that a barbell graph (two cliques of size $n/3$ connected by a path of length $n/3$) has average hitting time $\Omega(n^3)$, but I believe the same applies to minimum hitting time (for uniform or stationary distribution). Whatever vertex you choose as the one that you think is easiest to hit, you have constant probability of starting in the far clique from that vertex, after which it will take $\Omega(n^3)$ time in expectation before you traverse the connecting path to your chosen vertex.
{ "domain": "cstheory.stackexchange", "id": 3450, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "graph-theory, pr.probability, randomness, random-walks", "url": null }
3) Each observation has a deviance residual. In the binomial model, they are $$D_i = 2\left[Y_i \log \left( \frac{Y_i/N_i}{\hat{p}_i} \right) + (N_i-Y_i) \log \left( \frac{1-Y_i/N_i}{1-\hat{p}_i} \right)\right]$$ where $\hat{p}_i$ is the estimated probability from your model. Note that your binomial model is saturated (0 residual degrees of freedom) and has perfect fit: $\hat{p}_i = Y_i/N_i$ for all observations, so $D_i = 0$ for all $i$.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. Yes\n2. Yes", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.966410494349896, "lm_q1q2_score": 0.828956096624153, "lm_q2_score": 0.8577681031721324, "openwebmath_perplexity": 747.5731564499712, "openwebmath_score": 0.8331817388534546, "tags": null, "url": "https://stats.stackexchange.com/questions/144121/logistic-regression-bernoulli-vs-binomial-response-variables" }
python, object-oriented, game @property def chips(self): return self.__chips @chips.setter def chips(self, val): self.__chips = val @property def score(self): return self.__score @score.setter def score(self, val): self.__score = val def lost_bet(self): raise NotImplementedError("Subclass must inherit this abstract method") def won_bet(self): raise NotImplementedError("Subclass must inherit this abstract method") class Dealer(Actor): def lost_bet(self): pass def won_bet(self): pass class Player(Actor): def lost_bet(self, val): self.chips -= val def won_bet(self, val): self.chips += val black_jack.py import random import functools from deck import Deck from hand import Hand from actor import Dealer, Player def deal_cards(limit, max_cards): cards = [random.randint(0, limit) for _ in range(0, max_cards)] while True: if len(set(cards)) != len(cards): cards = [random.randint(0, limit) for _ in range(0, max_cards)] else: break return cards def remove_cards_from_deck(deck, cards): cards.sort(reverse=True) for i in cards: deck.pop(i) return deck def calc_score(player, cards): card_values = [card.value for card in cards] score = functools.reduce(lambda x, y: x+y, card_values) if score <= 11: for value in card_values: if value == 1 and (score + 10) <= 21: score += 10 return score def hit(deck, player): cards = deal_cards(len(deck)-1, 1) new_card = deck[cards[0]] player.hand.take_card(new_card) player.score = calc_score(player, player.hand.cards) deck = remove_cards_from_deck(deck, cards) return deck
{ "domain": "codereview.stackexchange", "id": 37143, "lm_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, game", "url": null }
gazebo Originally posted by Boris with karma: 330 on 2013-01-27 This answer was ACCEPTED on the original site Post score: 1 Original comments Comment by amit on 2013-01-27: Thank you very much ... I finally solved the probelm. Comment by amit on 2013-01-27: But when I close the terminal and try to launch gazebo again I get the same error message. So each time I have to source it. Since I am using the default directory /usr/local , I use the 2nd command given in Step 10 in wiki. How can I get this solved ? Comment by Boris on 2013-01-27: Simply add source /usr/local/share/gazebo-1.4/setup.sh to the end of your ~/.bashrc file. Comment by amit on 2013-01-27: Alright ... thanks again. Comment by Boris on 2013-01-28: Please also consider to mark the answer as correct if it did help you :) Comment by Hugo Siles on 2013-06-11: I also have the same problem, this the location of my instalation files LD_LIBRARY_PATH=/usr/local/lib/gazebo-1.8/plugins:/usr/local/lib/gazebo-1.8/plugins: GAZEBO_RESOURCE_PATH=/usr/local/share/gazebo-1.8:/usr/local/share/gazebo_models GAZEBO_MASTER_URI=http://localhost:11345 GAZEBO_PLUGIN_PATH=/usr/local/lib/gazebo-1.8/plugins GAZEBO_MODEL_DATABASE_URI=http://gazebosim.org/models I have followed the answer but I still get the error: gazebo: error while loading shared libraries: libgazebo_com Comment by Boris on 2013-06-12: @Hugo Siles, please create a new question, so the others can see it quickly. Otherwise only those to participate in the discussion here will be notified. P.S. a similar question was recently asked here.
{ "domain": "robotics.stackexchange", "id": 2970, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "gazebo", "url": null }
filters, phase, frequency-response, transfer-function Title: Phase function of filter I have a filter with the transfer function $$H(z) = 1 - 2z^{-2} + z^{-4}.$$ The task is to find the phase function $\theta (\omega).$
{ "domain": "dsp.stackexchange", "id": 6212, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "filters, phase, frequency-response, transfer-function", "url": null }
programming, qiskit, quantum-circuit Title: Cascade/Feedforward quantum circuits I would like to know if it is possible implement the following situation in Qiskit (either using the simulators or real quantum computers). Consider this illustrative toy example: The arrows illustrate that the outcomes $\{\sigma_1,...,\sigma_i\}$ determine the unitaries $U_j$ for $j=i+1,...,n$. That is, the idea is that the unitary $U_2$ can only be determined once the outcome $\sigma_1$ is known, then the unitary $U_3$ can be determined once $\sigma_1$ and $\sigma_2$ are known, and so on and so forth as we move along the circuit. The main idea and difficulty is precisely that we do not know the unitaries a priori and need to calculate them from the previous outcomes. (Note that determining all the possible unitary sequences before we start the computation would mean $2^n$ possible sequences for a computation with $n$ layers.) So basically, I need Qiskit to run the blue box, do the first measurement and stay in "stand-by" (so to speak) while I determine what $U_2$ is. Once I have that information I would have to append $U_2$ to the previous circuit and execute this new portion of the circuit alone (i.e. without running the previous one again!). (If Qiskit re-executes the first block again, it might get the wrong outcome for $\sigma_1$ and everything will be ruined). Is this possible at all? If not: (i) what is the next best thing? and (ii) is there a prediction for when such functionality will be available and in which shape? Thank you all!
{ "domain": "quantumcomputing.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": "programming, qiskit, quantum-circuit", "url": null }
Jackpot! Now we now how to describe $p(\bar{x})$. However, we haven't assessed the effect of the number of samples! How does $N$ affect it? In [10]: #These are the sample sizes we'll try out Ns = [5, 10, 15, 20, 100] color_map = plt.get_cmap("viridis") for i in range(len(Ns)): hist, bin_centers = hist_means_scaled(Ns[i]) plt.plot(bin_centers, hist, color=color_map(i / len(Ns)), label="$N={}$".format(Ns[i])) plt.legend() plt.xlim(-3, 3) plt.show() This looks like what happened, that there is a scaling effect. It turns out, the effect is similar: $$p(\bar{x}) = \mathcal{N}\left(\mu, \frac{\sigma}{\sqrt{N}}\right)$$ We will often discuss the uncertainty in the population mean. That means how well we know the opulation mean. This is $p(\bar{x} - \mu)$. Using the knowledge above, we can see that: $$p(\bar{x} - \mu) = \mathcal{N}\left(0, \frac{\sigma}{\sqrt{N}}\right)$$ One interesting attribute is that we can view either $\bar{x}$ as the variable or $\mu$ as the variable. If we view $\mu$ as the variable, we're describing where we think the population mean might be. If, on the other hand, we view $\bar{x}$ as the variable, we're describing where our sample mean will be if we take a sample. We will use the words uncertatiny and error as synonyms.
{ "domain": "jupyter.org", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9852713891776497, "lm_q1q2_score": 0.8032252384406772, "lm_q2_score": 0.8152324803738429, "openwebmath_perplexity": 1605.4396632223402, "openwebmath_score": 0.7874900102615356, "tags": null, "url": "https://nbviewer.jupyter.org/github/whitead/numerical_stats/blob/master/unit_8/lectures/lecture_1.ipynb" }
reference-request, optimization, linear-programming, convex-optimization Title: Linear Programming Sensitivity to Matrix Consider a linear program in the following standard form: \begin{align*} &\max c^T x &\\ &\mbox{subject to:}\\ &A x \preceq b\\ &x \succeq 0 \end{align*} Its dual is \begin{align*} &\min b^T y &\\ &\mbox{subject to:}\\ &A^T y \succeq c\\ &y \succeq 0 \end{align*} Let $x^*$ and $y^*$ be optimal primal and dual solutions, respectively. Let $\nu = c^T x^* = b^T y^*$ be the optimal value. Suppose for simplicity that the optimal solutions are unique (i.e., we have non-degeneracy for both primal and dual). It is well known from basic sensitivity analysis that the optimal value is differentiable with respect to $b$ and $c$ at that point, and we have $$\frac{\partial \nu}{\partial c_j} = x^*_j$$ and $$\frac{\partial \nu}{\partial b_i} = y^*_i.$$ The proof of these facts is also quite simple. What I wasn't able to find, however, was an authoritative and simple treatment of sensitivity with respect to entries of the matrix $A$. In particular, suppose we modify just the a single entry $a_{ij}$ of the matrix $A$. What is the partial derivative of $\nu$ with respect to $a_{ij}$, in the non-degenerate case (i.e., where $\nu$ is differentiable)? Playing around with it, I'm pretty sure the answer is the following: $$\frac{\partial \nu}{\partial a_{ij}} = - y^*_i x^*_j$$
{ "domain": "cstheory.stackexchange", "id": 5676, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "reference-request, optimization, linear-programming, convex-optimization", "url": null }
chemical-engineering, renewable-energy, photovoltaics As you have the power-voltage curve, finding the maximum power point is easy: it's the turning point on the power-voltage curve. The problem is that the absolute values in your graph look completely wrong. If the graph is flipped upside down, and based at zero power, zero current and zero voltage, then the blue curve does indeed look like an I-V curve for a photovoltaic cell, and the orange curve looks like the corresponding power curve. So it looks like the shape of your curve is right (albeit upside down from the usual presentation), but the absolute values are wrong. You need to work out what the right absolute numbers are. You know that the lowest the actual voltage is going to be is zero, and the lowest observed value is currently marked as -10V. The curve is the right shape going left to right (it's upside down, but does not also need reflecting in a vertical axis), so the correction coefficient for voltage is going to be positive. You know that the lowest the actual current and the actual power can be is also zero, and their lowest observed values are marked as 0.1A and about 6.9W respectively - I say lowest, because we need to flip the curve upside down. And because we do, you know the coefficient to correct them will be negative. And you know that $P_{real}=I_{real}V_{real}$. Given the shape of the curves, it's safe to assume that current and voltage each need a linear transformation (i.e. $V_{real} = aV_{obs}+b$, where you need to find $a$ and $b$) This gives you a set of simultaneous equations you can solve, to transform observed voltage (current/power) [$V_{obs}, I_{obs}, P_{obs}$] into actual voltage (current/power) [$V_{real}, I_{real}, P_{real}$]. Write out those simultaneous equations, and solve them.
{ "domain": "engineering.stackexchange", "id": 417, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "chemical-engineering, renewable-energy, photovoltaics", "url": null }
ros How to set image_proc/crop_decimate properly? this is my rostopic list: aldo@aldo-ubuntu:/opt/ros/electric/stacks/image_pipeline/image_proc$ rostopic list /gscam/camera_info /gscam/image_raw /gscam/image_raw/compressed /gscam/image_raw/compressed/parameter_descriptions /gscam/image_raw/compressed/parameter_updates /gscam/image_raw/theora /gscam/image_raw/theora/parameter_descriptions /gscam/image_raw/theora/parameter_updates /image_color /image_color/compressed /image_color/compressed/parameter_descriptions /image_color/compressed/parameter_updates /image_color/theora /image_color/theora/parameter_descriptions /image_color/theora/parameter_updates /image_mono /image_mono/compressed /image_mono/compressed/parameter_descriptions /image_mono/compressed/parameter_updates /image_mono/theora /image_mono/theora/parameter_descriptions /image_mono/theora/parameter_updates /image_proc_debayer/parameter_descriptions /image_proc_debayer/parameter_updates /image_proc_rectify_color/parameter_descriptions /image_proc_rectify_color/parameter_updates /image_proc_rectify_mono/parameter_descriptions /image_proc_rectify_mono/parameter_updates /image_rect /image_rect/compressed /image_rect/compressed/parameter_descriptions /image_rect/compressed/parameter_updates /image_rect/theora /image_rect/theora/parameter_descriptions /image_rect/theora/parameter_updates /image_rect_color /image_rect_color/compressed /image_rect_color/compressed/parameter_descriptions /image_rect_color/compressed/parameter_updates /image_rect_color/theora /image_rect_color/theora/parameter_descriptions /image_rect_color/theora/parameter_updates /rosout /rosout_agg
{ "domain": "robotics.stackexchange", "id": 11228, "lm_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 }
inorganic-chemistry, physical-chemistry, coordination-compounds, electronic-configuration, spin Title: Shortcut method to find atomic term symbols ignoring the spin orbit coupling Is there any shortcut method by which we can find the atomic term symbols ignoring the spin-orbit coupling, i.e. ignoring the values of J. For instance, when writing the d-d transitions for any complex, we write the atomic term symbols and them split them further into other states. I know the lengthy procedure to find the term symbols by considering the values of Ml, and finding the exact states including the spin-orbit coupling but is there a shortcut way by which we may find the atomic term symbols? Like, in the above picture, how did we find the terms for d2 to be 1S, 1G, 3P, 1D, and 3F After searching on the internet, and going through textbooks, I understand there is no "shortcut-method" to get the atomic term symbols in atoms with a large number of electrons.
{ "domain": "chemistry.stackexchange", "id": 12584, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "inorganic-chemistry, physical-chemistry, coordination-compounds, electronic-configuration, spin", "url": null }
8. It is fairly easy to verify that for $t>0$ we have that $\frac{t-1}{t}\leqslant\ln(t)\leqslant t-1$ and so $\frac{1}{t-1}\leqslant\frac{1}{\ln(t)}\leqslant\frac{t}{t-1}$. It follows that $\int_{x^2}^{x^4}\frac{dt}{t-1}\leqslant \int_{x^2}^{x^4}\frac{dt}{\ln(t)}\leqslant\int_{x^ 2}^{x^4}\frac{t}{t-1}dt$. Note though that the LHS is just $\ln\left(x^4-1\right)-\ln(x^2-1)=\ln(x^2+1)\overset{x\to 1^+}{\longrightarrow}\ln(2)$ and $\int_{x^2}^{x^4}\frac{t}{t-1}dt=\left(x^4-x^2\right)+\left(\ln(x^4-1)-\ln(x^2-1)\right)\overset{x\to 1}{\longrightarrow}\ln(2)$. The conclusion follows from the Squeeze Theorem. 9. Thanks DREXEL28. Every thing is OK!. But only, your inequalities should be strictly and they are correct for $t>1$ .
{ "domain": "mathhelpforum.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9825575178175918, "lm_q1q2_score": 0.8331770958610639, "lm_q2_score": 0.8479677583778258, "openwebmath_perplexity": 299.976384149992, "openwebmath_score": 0.9804540872573853, "tags": null, "url": "http://mathhelpforum.com/calculus/147458-caculation-limit.html" }
finite-element-method, abaqus If your triangles were not simple right-triangles and lied anywhere in space then you would need to do the following... We can relate the ($\xi$, $\eta$) coordinate system to the ($x$, $y$) coordinate system with these shape functions: $$N_1 = 1 - \xi -\eta$$ $$N_2 = \xi$$ $$N_3 = \eta$$ At integration point A we have $\xi = 1/6$ and $\eta = 1/6$. Therefore: $$N_1 = 2/3$$ $$N_2 = 1/6$$ $$N_3 = 1/6$$ So if our triangle had ($x$, $y$) vertices of $(0,0)$, $(3,2)$ and $(1,3)$ then the coordinates of A are: $$ x_A = \sum N_ix_i = N_1x_1 + N_2x_2 + N_3x_3 = \frac{2}{3}(0) + \frac{1}{6}(3) + \frac{1}{6}(1) = \frac{2}{3}$$ $$ y_A = \sum N_iy_i = N_1y_1 + N_2y_2 + N_3y_3 = \frac{2}{3}(0) + \frac{1}{6}(2) + \frac{1}{6}(3) = \frac{5}{6}$$ I have very cruedly drawn this example above and you can see that the point coordinates $(2/3,5/6)$ match the position for A in the diagram quite well. You can repeat this for B and C. Then you would have the coordinates of A, B and C, which are the integration points in the shell's local coordinate system. Then you would have to use a transformation matrix based on the shell's vertices to convert those local x,y coordinates to the global 3D coordinate system in X,Y,Z.
{ "domain": "engineering.stackexchange", "id": 1060, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "finite-element-method, abaqus", "url": null }
javascript, jquery, html, event-handling, rags-to-riches Title: Toggling html buttons and text I went through a question on SO, and optimized the code according to OP's requirements. I would like a review if it is done properly or not. Here is the code snippet, there are 2 level buttons, when clicked 1st level button, it toggles second level button group. Second level button group toggles div, which contains checkbox. Any review and suggestions are appreciated. $(document).ready(function() { var groups = ['a', 'b', 'c']; // here $.each(groups, function(k, id) { $('#' + id).hide(); $('#' + id + 'l').hide(); }); $(".button").click(function() { var button_id = $(this).data('id'); $('#' + button_id).toggle(); var hide = $.grep(groups, function(value) { return value != button_id; }); $.each(hide, function(k, id) { $('#' + id).hide(); }); }); var selector = []; $.each(groups, function(k) { selector.push('.' + groups[k]); }); selector = selector.join(','); $(selector).click(function() { var button_id = $(this).data('id'); var class_id = $(this).attr('class'); var flag = $('.' + class_id + 'l').filter('[data-id="' + button_id + '"]').is(':visible'); $.each(groups, function(k, id) { $('#' + id + 'l').children().hide(); }); $.each(groups, function(k, id) { $('#' + id + 'l').hide(); });
{ "domain": "codereview.stackexchange", "id": 13977, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "javascript, jquery, html, event-handling, rags-to-riches", "url": null }
special-relativity \end{array} \right) $$ which I constructed by composing three boosts: the first by $c/2$ along $\hat x$, the second by $c/2$ along $\hat y$, and the third by $c/2$ along $\hat z$. Extracting the boost parameters as before from the first row, we find $$\beta=\frac{\sqrt{37}}{8}$$ and $$\hat n=\frac{(4,2\sqrt{3},3)}{\sqrt{37}}.$$ After working out $B$ and $B^{-1}$, one finds the rotation to be $$R= \left( \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & \frac{2}{37} \left(6+7 \sqrt{3}\right) & \frac{2}{37} \left(3 \sqrt{3}-8\right) & \frac{1}{37} \left(9-8 \sqrt{3}\right) \\ 0 & \frac{1}{37} \left(8 \sqrt{3}-9\right) & \frac{2}{37} \left(6+7 \sqrt{3}\right) & \frac{2}{37} \left(3 \sqrt{3}-8\right) \\ 0 & -\frac{2}{37} \left(3 \sqrt{3}-8\right) & \frac{1}{37} \left(8 \sqrt{3}-9\right) & \frac{2}{37} \left(6+7 \sqrt{3}\right) \\ \end{array} \right) $$ The trace formula gives the rotation angle as $$\theta=\cos^{-1}\frac{42\sqrt{3}-1}{74}\approx 14.18^\circ.$$
{ "domain": "physics.stackexchange", "id": 62711, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "special-relativity", "url": null }
control, imu Title: Quaternion error in one degree of freedom I would like to control a system which orientation I measure with as quaternion based EKF in one degree of freedom. Obviously the simplest thing would be to convert the quaternion estimate to euler angles and take one of these. Unfortunately these euler angles are not stable. The other option I was thinking about was to use the so called quaternion error, where I specify another quaternion which I want my system to be controlled towards. Then I would have to specify all four values of this quaternion. I'm wondering if there is a way to generate a quaternion error only for one of my angles? You will have to specify the full quaternion in any case and that is because each w,x,y and z are a function of all the Euler angles. Some ways to get by could be: If you are concerned about an EKF generating noisy output in the other two angles: in the update step, you can hard code these known angles If you want to control just one angle: just extract one single value of this rotation (Euler angle would be your best bet) or extract the entire quaternion from this EKF and find the error with the desired angle or the quaternion. Your desired quaternion should not be difficult to calculate since you either want the robot to be same in the other two angles or you know the desired angles already. Note : if you deal with Euler angles, you will have to be careful of the gimbal lock problem (singularity) which should not be very difficult to overcome.
{ "domain": "robotics.stackexchange", "id": 2023, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "control, imu", "url": null }
organic-chemistry, reaction-mechanism, redox, carbohydrates Is it something to do with the reagents used because many of them are just basic solutions, but if the reagent happens to be an acidic solution then will be that statement valid? This is based in the underlying redox rection. If we take e.g. mannose and attempt to oxidise that, the (unbalanced) half-reaction we need is the following: $$\ce{C6H12O6 -> C6H10O6 + 2e-}\tag{Ox1}$$ To balance it, we either need to add protons to the right-hand side (acidic medium) or negative charges to the left-hand side. Since we are asked about alkaline solutions, let’s do the latter: $$\ce{C6H12O6 + 2 OH- -> C6H10O6 + 2 e- + 2 H2O}\tag{Ox2}$$ As you can see, the oxidation of sugars consumes hydroxide ions. If you increase the concentration of hydroxide, that will typically increase the reaction rate. Of course, one should always check what the reduced compound is. In your case, it is always a complexated copper(II) ion and is reduced by the following equation: $$\ce{2Cu^2+ + 2 e- + 2 OH- -> Cu2O v + H2O}\tag{Red}$$ Even here, if we set up the half-reaction, we notice that we are consuming hydroxide. Thus, the overall redox reaction is: $$\ce{C6H12O6 + 2 Cu^2+ + 4 OH- -> C6H10O6 + Cu2O v + 3 H2O}\tag{Redox}$$ If a reaction consumes hydroxide ions, it is enhanced by basic conditions. Likewise, if a redox reaction consumes protons, it is enhanced by acidic conditions.
{ "domain": "chemistry.stackexchange", "id": 6743, "lm_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, reaction-mechanism, redox, carbohydrates", "url": null }
object-oriented, .net, database, vb.net Try Dataset = Query(QueryString) For Each DataRow As DataRow In Dataset.Tables(0).Rows DataList.Add(New Booking(DataRow)) Next Catch ex As Exception DataList = Nothing SystemErrors.Create(New SystemError(ex.Message, ex.StackTrace)) End Try Return DataList End Function Public Shared Function GetData(ByVal uin As String) As Booking Dim QueryString As String = String.Format("SELECT * FROM {0}{1} WHERE {0}uin = {2};", _Pre, _Table, uin) Dim Dataset As DataSet = New DataSet() Dim Data As Booking = New Booking() Try Dataset = Query(QueryString) If Dataset.Tables(0).Rows.Count = 1 Then Data = New Booking(Dataset.Tables(0).Rows(0)) Else Data = Nothing End If Catch ex As Exception Data = Nothing SystemErrors.Create(New SystemError(ex.Message, ex.StackTrace)) End Try Return Data End Function Public Shared Function Create(ByVal Data As Booking) As Boolean Dim QueryString As String = String.Format("SELECT * FROM {0}{1} WHERE {0}uin = Null;", _Pre, _Table) Dim Dataset As DataSet = New DataSet() Dim Datarow As DataRow Dim Result As Boolean = False Try Dataset = Query(QueryString) If Dataset.Tables(0).Rows.Count = 0 Then Datarow = Dataset.Tables(0).NewRow() Data.Get(Datarow) Dataset.Tables(0).Rows.Add(Datarow) Result = UpdateDB(QueryString, Dataset) Else Result = False End If Catch ex As Exception Result = False SystemErrors.Create(New SystemError(ex.Message, ex.StackTrace)) End Try Return Result End Function
{ "domain": "codereview.stackexchange", "id": 103, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "object-oriented, .net, database, vb.net", "url": null }
algorithms, combinatorics Title: Combinatorics approach to staircase problem There are $n$ stairs and a person standing at the bottom wants to reach the top. The person can climb either 1 stair or 2 stairs every time. What is the total number of ways they can reach the top? There are many ways to do this by using code. But when I first read this problem was to use a combinatorics approach. This problems seems very similar to a "stars and bars" problem. The stars would be the number of stairs and the bars would be the number of steps that be taken. Given this is the case, my solution is simply: ${(n)+(2-1)}\choose{1}$. Is the concept of stars and bars the simplest approach to solving this problem or is there a simpler combinatorics concept at play here and if so, how do I recognize such things? By simple, I mean can I solve this problem by simpler computation than combinatorics (even if it requires some sort of brute force method)? You can usually check whether a solution is correct by running it on some small examples. For example, say you have a stair with two steps; how many ways are there to reach the top? Well, you can either take $1 + 1$ steps or just a single step of $2$. Unfortunately, this gives a counter-example for the proposed solution. However, fear-not, there is still a simple combinatorial interpretation here. Since each step is either $1$ or $2$ steps, then your problem revolves down to finding all sums of the form $1 + 2 + 1 + 1 + \dots + 2 = n$. In other words, you're looking for the compositions of $n$ using just $1$ and $2$.
{ "domain": "cs.stackexchange", "id": 7660, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "algorithms, combinatorics", "url": null }
javascript, beginner, html, css, dom .mh-50 { min-height: 50px; max-height: 50px; overflow: auto } .tg-up { display: inline-block } .tg-up:after { content: ""; display: inline-block; width: 0; height: 0 } .vs-hd { visibility: hidden } .g-3 { background: linear-gradient(to right, #CD0000, #EEEE00, #32CD32); background-repeat: no-repeat; transition: none } .g-3:hover { background: linear-gradient(to right, #CD0000, #ED9121, #EEEE00, #E0E0E0, #FFF, #F5F5F5, #63B8FF, #4169E1, #32CD32) } .img-1 { background-position: center center; background-repeat: no-repeat; -webkit-background-size: cover; -moz-background-size: cover; background-size: cover; -o-background-size: cover } .img-2 { background-repeat: no-repeat; background-size: 100% } .vc { position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden } .vc iframe, .video-container object, .video-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100% } /*menu*/ .ln, .ln .cl-bn { left: 0 } .rn, .rn .cl-bn { right: 0 } .ln, .rn { height: 100%; width: 0; position: fixed; top: 0; background-color: #333; overflow-x: hidden; transition: 0.3s } .ln a, .rn a { text-decoration: none; color: #f2f2f2; display: block; transition: 0.2s } .ln a:hover, .rn a:hover { color: #fff }
{ "domain": "codereview.stackexchange", "id": 33871, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "javascript, beginner, html, css, dom", "url": null }
python, algorithm, reinventing-the-wheel, combinatorics Title: Generating Permutations in Python To brush up my Python knowledge I an algorithm to generate permutations in lexicographic order. I ended up with the following code: def swap(a, i, j): tmp = a[i] a[i] = a[j] a[j] = tmp def next_permutation(a): n = len(a) if n == 0 or n == 1: return False kFound = False for k in reversed(range(n - 1)): if a[k] < a[k + 1]: kFound = True break if not kFound: return False for l in reversed(range(n)): if a[k] < a[l]: break swap(a, k, l) return a[:k + 1] + [i for i in reversed(a[k + 1:])] I did a lot of C++ and miss std::swap(..), what is the proper way to do this in Python? In the last line, because reversed(..) returns an iterator I cannot write simply: a[:k + 1] + reversed(a[k + 1:]), is there a simpler way to trigger the unfolding of the iterator into a list? Python has so many neat stuff to help you with this one, I feel alot can be rewritten: I did a lot of C++ and miss std::swap(..) Luckily you can swap really easy in python For instance the swap method, can be rewritten like def swap(a, i, j): a[i], a[j] = a[j], a[i] Is there a simpler way to trigger the unfolding of the iterator into a list?
{ "domain": "codereview.stackexchange", "id": 27543, "lm_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, reinventing-the-wheel, combinatorics", "url": null }
javascript, jasmine JSON method 5289ms. Loop method 23ms. Always run the function several 100 or 1000 times before you start timing, so you don't test the time the optimizer is using. Always use a global soak. Functions that do not effect external state*1 are simply not run, this is the most basic optimization the optimizer can do. (A soak has its state changed by an unknowable result of the test function.) A function that produces the same result independent of arguments will have the result cached. A function that produces the same result for the same input each time can have the result cached and thus falsifies performance tests) *1 Note State used to mean browser state not just the JS context. Order of execution can effect timing, randomize your tests and use a statistical mean to estimate the results of many tests. NOTE do to an ongoing and unresolved security issue performance.now can not be trusted to give anything above a 0.1-0.2ms accuracy.
{ "domain": "codereview.stackexchange", "id": 31470, "lm_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, jasmine", "url": null }
distance from the axis of rotation. The moment of inertia calculates the rotational inertia of an object rotating around a given axis. A rod of length l and mass m has ml²/12 as moment of inertia about an axis through its center of mass. This is for the Rectangular cross-section beams. The disk has mass md = 2. The moment of inertia of a thin rod about a normal axis through its centre is I. In planetary sciences, the moment of inertia factor or normalized polar moment of inertia is a dimensionless quantity that characterizes the radial distribution of mass inside a planet or satellite. Two conditions may be. Since in Dynamics there is no such concept as the inertia of an area, the moment of inertia has no physical meaning. Generally speaking the total moment of inertia is the sum of the moments inertia calculated individually. The moment of inertia of a rod of mass M and length L, with axis separated by distance x from the original one (through the centre of mass), is Ix = ICM + Mx2 = 1. The matrix of the values is known as the moment of inertia tensor. The moment of inertia of a rigid body about a particular of axis may be defined as the sum of the products of the masses of all the particles constituting the body and the squares of their respective distances from the axis of rotation. Moment of Inertia--Rod The moment of inertia of a thin rod of length h , mass M , and cross-sectional area A can be computed as the limiting case of the moment of inertia of a cylinder as the radius , so the tensor becomes. Therefore, the moment of inertia of a uniform rod about a perpendicular bisector (I) = ML 2 /12. It will not attempt to teach you the calculus involved since you are presumed to have learned it in another course. I₂ = I₁ + m(l/2)². ii) moment of inertia about the point B. A long, thin rod of uniform cross section and length L has a density that depends on position along the bar. Unfortunately most rotating bodies do not have the mass concentrated at one radius and the moment of inertia is not calculated as easily as this. The rod has an angular velocity of 0. Moments of Inertia: 1. In planetary
{ "domain": "mass-update.de", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9938070087416098, "lm_q1q2_score": 0.838668867561424, "lm_q2_score": 0.8438951025545426, "openwebmath_perplexity": 246.3611296504142, "openwebmath_score": 0.601813793182373, "tags": null, "url": "http://vkxt.mass-update.de/moment-of-inertia-rod.html" }