text
stringlengths
1
1.11k
source
dict
c#, wpf, mvvm Title: Combobox with multiple itemssources MVVM I'm trying to make a list of either customers or suppliers based on a radio button. I have a solution that works but I want to know if it is a correct solution to work with the MVVM-model. Next to that I want to know if I make correct use of the collecions. If there would be a more efficient way of coding for this part, I'd very happy to hear it. I have one interface (customers and suppliers) which both implement an interface (IStakeholder). In my UI I have a two radio buttons and a combobox. Based on which radio button is used, another list should be displayed in the combobox. In my InputViewModel I use three list, one general for the combobox (CustomersSuppliers), one for customers (CustomerList) and one for Suppliers (SupplierList). The code is found below. To generate the INotifyProperty, I use Fody Weaver. C# - ViewModel public class InputViewModel : BaseViewModel { // Combobox list
{ "domain": "codereview.stackexchange", "id": 28137, "lm_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#, wpf, mvvm", "url": null }
c#, error-handling, wpf In real life, nobody is reading log files. Every developer avoids it. And for sure, nobody reads them daily to check if any of the hundreds of customers experienced a critical runtime error. Indeed, it's an uncomfortable situation when a customer experiences an application crash, but at least it will draw everybody's attention to look for an immediate fix. An application error reporter can be a very powerful enhancement to provide quick and proper bug support. Nevertheless log files can be a very valuable support to reproduce and find bugs. Also, exceptions of the same type might get thrown at different code segments in a totally different context. A global exception handler will have a hard time to get the context of the exception to find out if NotSupportedException was thrown in context of a invalid user input (recoverable error) or a wrong call to an API method (non-recoverable).
{ "domain": "codereview.stackexchange", "id": 37235, "lm_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#, error-handling, wpf", "url": null }
audio, noise, nyquist, aliasing With this approach, the signal sampling (and, consequently, Nyquist) frequency is much lower than the noise sampling frequency. To avoid aliases in the noise frequency domain, you must bandlimit the noise. In this process, the noise is averaged over the time interval between the adjacent signal samples in a manner dependent of the filter used. By force of the central limit theorem, the averaged noise values tend to approach a Gaussian distribution -- the more samples used in averaging process, the closer the distribution to Gaussian. But this fact suggest the idea to directly generate samples from a Gaussian distribution and avoid oversampling at frequency much higher than the signal sampling frequency. The method generating a random variable with a Gaussian distribution is readily available in matlab, numpy and scipy (I believe). In the general-purpose computer languages you can easily implement the Marsaglia polar method or the Box–Muller transform.
{ "domain": "dsp.stackexchange", "id": 9369, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "audio, noise, nyquist, aliasing", "url": null }
javascript, react.js index.js: import React from 'react'; import ReactDOM from 'react-dom'; import { BrowserRouter as Router, Route } from "react-router-dom"; import ParseRoutes from "./Utils/ParseRoutes" import { routes } from "./routes.json" function AppContainer() { const routeProps = ParseRoutes(routes) return ( <Router> {routeProps.map((props, i) => (<Route key={i} {...props} /> ))} </Router> ) } ReactDOM.render(<AppContainer />, document.getElementById("root")) ParseRoutes.js: import MainPageContainer from "../Components/MainPage" import WidgetContainer from "../Components/Widget" const stringToComp = { MainPageContainer: MainPageContainer, WidgetContainer: WidgetContainer } const ParseRoutes = (routes) => ( routes.map((props) => ({...props, component: stringToComp[props.component]})) ) export default ParseRoutes RedirectIfRequested.js: import React from "react" import { Redirect } from "react-router-dom"
{ "domain": "codereview.stackexchange", "id": 40238, "lm_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, react.js", "url": null }
ros, gazebo, simulation, ros-kinetic [ 12%] Built target kobuki_description_xacro_generated_to_devel_space_ [ 12%] Built target sphero_gazebo_xacro_generated_to_devel_space_ [ 16%] Linking CXX shared library /home/fred/catkin_ws/devel/lib/libgazebo_sphero_controller.so /usr/bin/ld: cannot find -lgazebo_ros_utils collect2: error: ld returned 1 exit status bb8/bb_8_gazebo/CMakeFiles/gazebo_bb_8_controller.dir/build.make:243: recipe for target '/home/fred/catkin_ws/devel/lib/libgazebo_bb_8_controller.so' failed make[2]: *** [/home/fred/catkin_ws/devel/lib/libgazebo_bb_8_controller.so] Error 1 CMakeFiles/Makefile2:3373: recipe for target 'bb8/bb_8_gazebo/CMakeFiles/gazebo_bb_8_controller.dir/all' failed make[1]: *** [bb8/bb_8_gazebo/CMakeFiles/gazebo_bb_8_controller.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... /usr/bin/ld: cannot find -lgazebo_ros_utils collect2: error: ld returned 1 exit status
{ "domain": "robotics.stackexchange", "id": 30018, "lm_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, gazebo, simulation, ros-kinetic", "url": null }
php, html, validation, email, sql-injection 3. OS Command Attacks!!! --- Solutions: Striping whitespace (not necessary with emails), validating against a whitelist of permitted values. 4. DOS Attacks!!! --- Solution: None implemented. I'm unsure if any additional precaution is necessary, since there are no login possibilities on my website. 5. PHP Email Injection!!! --- Solution: A Regular Expression (the one I have is mostly designed to allow for international characters).
{ "domain": "codereview.stackexchange", "id": 39487, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "php, html, validation, email, sql-injection", "url": null }
reaction-mechanism, home-experiment Title: Are children's sparklers based on a magnesium reaction? We were letting our kids play with sparklers on New Year's Eve, and my friend's son asked his Dad: What would happen if we threw the sparkler into the water? Would it keep burning under water. My friend pondered that for a moment - and said it depended if the reaction was based on magnesium or not. My question is: Are children's sparklers based on a magnesium reaction? What would happen if we threw the sparkler into the water? Would it keep burning under water. Most likely, not. Water is an effective coolant, so a wet sparkler wouldn't be able to propagate a burn front. Pyrotechnic compositions often severely degrade in a wet air (some might self-ignite and some might loose the ability to burn). Are children's sparklers based on a magnesium reaction? The most common sparkler composition I'm aware about is
{ "domain": "chemistry.stackexchange", "id": 9370, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "reaction-mechanism, home-experiment", "url": null }
thermodynamics So, now we have $\delta q_{rev} = C_V(T)dT + \Big(\big(\frac{\partial U}{\partial V}\big)_T + P\Big)dV $. Also, from the definition of Helmholtz free energy ($A = U - TS $ and $dA = -SdT -PdV$) and by using Maxwell's relation it can be shown that $\Big(\big(\frac{\partial U}{\partial V}\big)_T + P\Big) = T \big(\frac{\partial P}{\partial T}\big)_V$ Now, it can be shown properly that $$\left(\frac{\partial C_V(T)}{\partial V}\right)_T = \frac{\partial^2 U}{\partial T \partial V} = T \left(\frac{\partial^2 P}{\partial T^2}\right)_V \qquad(= 0\text{ if } PV=nRT)\tag{i} $$ $$\left(\frac{\partial (\frac{C_V(T)}{T})}{\partial V}\right)_T = \frac{1}{T} \frac{\partial^2 U}{\partial T \partial V} = \left(\frac{\partial^2 P}{\partial T^2}\right)_V \tag{ii}$$ and for the right hand side $$\frac{\partial}{\partial T}\Bigg(T\Big(\frac{\partial P}{\partial T}\Big)_V\Bigg)_V = T\Big(\frac{\partial^2 P}{\partial T^2}\Big)_V + \left(\frac{\partial P}{\partial T}\right)_V\tag{iii}$$
{ "domain": "chemistry.stackexchange", "id": 11371, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "thermodynamics", "url": null }
c++, calculator number_flag = true; rightParen_flag = false; } else if (isLetter(expression[i])) { if (number_flag || rightParen_flag) // omitted multiplication sign parseOperator('*', expression_RPN, operation_stack);
{ "domain": "codereview.stackexchange", "id": 37688, "lm_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++, calculator", "url": null }
visible-light Title: Relationship between diffused light and intensity I was wondering if the relationship of the intensity of diffused light is a linear correlation to the diffusing material. Basically will the intensity of the diffused light change in a linear fashion as the diffusing factor increases/decreases? One simple model of a diffusive material is a material where there is a certain probabability per path length that a photon will be scattered in a random direction, similar to how a colored material absorbs photons with a certain probability per path length. If the characteristic length of the material is $L=d^{-1}$, where $d$ is a "diffusivity factor" for the material, then it's easy to show that if the incoming beam is collimated, the amount of light that exits the material and remains collimated is $$P_c=Pe^{-Td}$$ where $P$ is the power of the incoming beam and $T$ is the thickness of the diffusing material.
{ "domain": "physics.stackexchange", "id": 12272, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "visible-light", "url": null }
c++, algorithm, object-oriented, graph using EdgeNodes = vector<EdgeNode *>; class Graph { public: unordered_map<char, EdgeNodes *> adj; void addNode(char node) { if(adj.find(node) == adj.end()) { adj[node] = new EdgeNodes(); } } void addEdge(char start, char end, int weight) { if(adj.find(start) != adj.end()) { for(auto node : *adj[start]) { if(node->label == end) { node->weight = weight; return; } } } else { adj[start] = new EdgeNodes(); } if(end) { adj[start]->push_back(new EdgeNode(end, weight)); } } void get_parent(unordered_map<char, char>& parent, char c) { cout << "Parent chain of \'" << c << "\' ="; while((parent.find(c) != parent.end()) && parent[c]) { cout << parent[c] << ", "; c = parent[c]; } cout << endl; }
{ "domain": "codereview.stackexchange", "id": 35601, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c++, algorithm, object-oriented, graph", "url": null }
c++, memory-management, c++20, heap //-------------------------------------------------------------------------- // Free the second block heap.free(alloc_b); // Again, the used bytes count decreases by sizeof(BlockHeader) and alloc_b // due to the coallescing of free space REQUIRE(heap.current_used() == 128); REQUIRE(heap.current_allocs() == 1); REQUIRE(heap.peak_used() == 416); REQUIRE(heap.peak_allocs() == 3); // Still zero fragmentation REQUIRE_THAT(heap.calc_fragmentation(), WithinAbs(0.0f, epsilon)); // Now header_b is the "new" free_header REQUIRE(header_a->next == nullptr); REQUIRE(header_a->prev == nullptr); REQUIRE(header_b->next == nullptr); REQUIRE(header_b->prev == nullptr); REQUIRE(header_c->next == nullptr); REQUIRE(header_c->prev == nullptr); REQUIRE(free_header->next == nullptr); REQUIRE(free_header->prev == nullptr);
{ "domain": "codereview.stackexchange", "id": 45151, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c++, memory-management, c++20, heap", "url": null }
gazebo-ignition code snippet void CessnaPlugin::PublishState(EntityComponentManager &_ecm) { IGN_PROFILE("CessnaPlugin::PublishState"); // Read current state double propellerRpms = _ecm.ComponentData<components::JointVelocity>(this->joint[6.0])/(2.0*M_PI)*60.0; float propellerSpeed = propellerRpms / this->propellerMaxRpm; float leftAileron = _ecm.Component<components::JointPosition>(this->joint[2500]); float leftFlap = _ecm.Component<components::JointPosition>(this->joint[1.0]); float rightAileron = _ecm.Component<components::JointPosition>(this->joint[2.0]); float rightFlap = _ecm.Component<components::JointPosition>(this->joint[3.0]); float elevators = _ecm.Component<components::JointPosition>(this->joint[4.0]); float rudder = _ecm.Component<components::JointPosition>(this->joint[5.0]); ----> error occurs here }
{ "domain": "robotics.stackexchange", "id": 4599, "lm_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-ignition", "url": null }
ros, ros-indigo, pixhawk, mavros Comment by sergioma on 2019-06-07: I am having a similar problem. I have created a new issue. Can somebody help me please? #1248 Long story short, the mavros topics weren't publishing because there were firmware updates for the various radios in the system that we hadn't implemented. 1) The radio modem that connected to the computer was correct 2) The radio modem on the Pixhawk was out of date 3) The firmware on the Pixhawk itself was out of date It's our first time working with the Pixhawk so we didn't think to check the firmware of various components, when we upgraded using the APM Mission Planner GUI then we started getting all topics being published correctly. Thanks to @vooon for his help.
{ "domain": "robotics.stackexchange", "id": 19515, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "ros, ros-indigo, pixhawk, mavros", "url": null }
Try this one! $$\int_{0}^{1}\frac{\ln(1+x)}{1+x^{2}}dx$$ • This is a good one! I also came across another very nice identity, which I have added to my original post. Can you think of any interesting integrals that this new identity can help solve? – wrb98 Feb 11 '17 at 20:24 • Since neither answer addressed the second identity in the update, I shall have to award the 50 point bounty to the answer which I thought gave the most interesting example of where the first identity is useful, which in this case was courtesy of BaroqueFreak – wrb98 Feb 22 '17 at 14:29 There are a lot of possible answers. For example, $$\int_{0}^{1} \frac{x^3}{3x^2-3x+1} \mathrm{d} x=\int_{0}^{1} \frac{x^3}{x^3+(1-x)^3} \mathrm{d} x=\frac{1}{2}$$ or $$\int_{0}^{1}\frac{x^5}{5x^4-10x^3+10x^2-5x+1}\mathrm{d}x=\frac{1}{2}$$ are both good examples of how this property can be used. We can use this property to calculate these complicated looking integrals in less than a few seconds.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9805806523850542, "lm_q1q2_score": 0.8171419814080764, "lm_q2_score": 0.8333246015211008, "openwebmath_perplexity": 287.25495370517075, "openwebmath_score": 0.8251010179519653, "tags": null, "url": "https://math.stackexchange.com/questions/2135675/two-interesting-results-in-integration-int-0afa-x-mathrmdx-int" }
classical-mechanics, lagrangian-formalism, path-integral, action, non-locality Title: Is there a deep reason why action comes from a local lagrangian? In both classical and quantum physics Lagrangians play a very important role. In classical physics, paths that extremize the action $S$ are the solutions of the Euler-Lagrange equations, and the action is given by the integral of a Lagrangian. $$ S[q] = \int\mathrm{d}t L(q, \dot{q})$$ $$ \delta S[q] = 0 \iff q(t) \in \{Solutions~to~EoM\}$$ For fields the picture is similar, with the action coming from the integral of a lagrangian density: $$ S[\phi] = \int\mathrm{d}^4x \mathcal{L}(\phi, \partial_{\mu} \phi)$$ $$ \delta S[\phi] = 0 \iff \phi(t, \mathbf{r}) \in \{Solutions~to~EoM\}$$ I learnt then that in QFT we see that this as a consequence of amplitudes being path integrals of the exponential of the action, for particles and fields respectively: $$K(t_f, t_i, q_f, q_i) = \int Dq~\exp i S[q]$$ $$K(t_f, t_i, \phi_f, \phi_i) = \int D\phi~\exp i S[\phi]$$
{ "domain": "physics.stackexchange", "id": 65529, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "classical-mechanics, lagrangian-formalism, path-integral, action, non-locality", "url": null }
ros, nodes, topic, publisher Originally posted by Toletum with karma: 195 on 2013-07-15 This answer was ACCEPTED on the original site Post score: 4 Original comments Comment by joq on 2013-07-16: Sending acknowledgements is a reasonable design. Messages could get lost, so the answer may not be exact.
{ "domain": "robotics.stackexchange", "id": 14909, "lm_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, nodes, topic, publisher", "url": null }
electromagnetism, electric-circuits, electric-current 3.now to your actual question , here it looks like you just randomly square two numbers thinking that they are 90 degree out phase and that would be answer but unfortunately that's not how math works ,so what we do?
{ "domain": "physics.stackexchange", "id": 71201, "lm_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, electric-circuits, electric-current", "url": null }
I received a PM asking me to respond. First, this is definitely not a realistic GMAT question. For one thing, it's horribly written (the phrase 'to complete a work' is not English, the question should read '*By* how many times...', the question needs to make clear that each man works at the same rate, as does each woman, the word 'sooner' is non-idiomatic, the word 'output' is misused, etc). For another, it's terribly contrived, and altogether tedious if you take any normal approach; I don't see any direct way to solve that will allow you to avoid a quadratic equation. Real GMAT questions are never designed in such a way, so you can confidently move on to better material and ignore this question (incidentally, where is it from?).
{ "domain": "gmatclub.com", "id": null, "lm_label": "1. Yes\n2. Yes", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9678992932829918, "lm_q1q2_score": 0.820747397779396, "lm_q2_score": 0.8479677622198946, "openwebmath_perplexity": 1275.580241492516, "openwebmath_score": 0.6380464434623718, "tags": null, "url": "https://gmatclub.com/forum/it-takes-6-days-for-3-women-and-2-men-working-together-to-82718.html" }
# How does $n^4 + 6n^3 + 11n^2 + 6n + 1 = (n^2 + 3n + 1)^2?$ C++ student here, not quite familiar with these type of expressions. Can someone explain how does this work? I'm familiar with $(a+b)^2$ etc. mathematics but this seems to be like $(a+b+c)^2$ and having searched online, the opened form for this formula doesn't look much alike. Any help will be appreciated. Thanks! • You know how to do this if you know how to compute $131^2$, since $131=n^2+3n+1$ where $n=10.$ Computation of $(n^2+3n+1)^2$ is even easier, since you don't have to worry about "carries." – Thomas Andrews Mar 23 '18 at 15:52 • Try $$(a+b+c)^2=(a+(b+c))^2$$ – Dave Mar 23 '18 at 15:53 • Thanks guys! Makes sense now. – Idaisa Mar 24 '18 at 15:52 • @Idaisa Please remember that you can choose an answer among the given if the OP is solved, more details here meta.stackexchange.com/questions/5234/… – gimusi Mar 24 '18 at 21:33
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9752018354801187, "lm_q1q2_score": 0.8754340912266927, "lm_q2_score": 0.8976952866333484, "openwebmath_perplexity": 487.5758791971208, "openwebmath_score": 0.9685267210006714, "tags": null, "url": "https://math.stackexchange.com/questions/2704997/how-does-n4-6n3-11n2-6n-1-n2-3n-12" }
of a positive matrix is not symmetric positive definite matrix the! Or covariance matrix MN has positive eigenvalues 82 silver badges 112 112 badges. Have the property that is non-decreasing along the diagonals n two symmetric positive-definite matrices and λ ian of..., Irene Yu-Hua Gu, in Ambient Assisted Living and Enhanced Living Environments, 2017 and n two symmetric matrices. Product yields a positive definite 0 and thus MN has positive eigenvalues the set orthonormal... And n two symmetric positive-definite matrices and positive definite­ness symmetric matrices are good – their eigenvalues real... A = LL T, wobei L eine untere Dreiecksmatrix mit positiven Diagonaleinträgen ist usual notation! Thus MN has positive eigenvalues positive matrices is a matrix in which all the diagonal entries of s.t. Thousands ) so eigenanalysis is expensive matrix are all positive where n is in order. One for which a = at square root are the practical ways to make a matrix has Unique! Invertible then
{ "domain": "liekens.net", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9615338112885302, "lm_q1q2_score": 0.8210659838535335, "lm_q2_score": 0.8539127529517044, "openwebmath_perplexity": 701.6805871954706, "openwebmath_score": 0.848247766494751, "tags": null, "url": "http://piet.liekens.net/158jr0/839d9a-show-a-matrix-is-positive-definite" }
homework-and-exercises, electricity and in the other a copper wire instead of the nichrome wire when electricity is passed through which wire gets more heated? Since resistance is more in nichrome it has to be nichrome that should get more heated right? heat is the product of I,R and T and I will be more in copper since it has low resistance so which one will be it an explained answer will be more appreciated I have to cite @CarlWitthoft from the comments. Intensity is not a term used in electric circuits. Intensity of current would not make any sense. However, I can vaguely make out what you are trying to ask: What you are trying to say is: "Two circuits are identical to the one in the figure, except for the fact that one has a nichrome wire and the other has a copper wire. Now, 1) the wires get heated as current passes and Nichrome, having a higher resistance than copper should get heated more. 2) But since copper has a lower resistance, it will admit more flow of current, so copper should get heated more."
{ "domain": "physics.stackexchange", "id": 16414, "lm_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, electricity", "url": null }
energy, nuclear-engineering, fusion, cold-fusion Title: Is the E-cat by Andrea Rossi et al. for real? Does this thing really do what they say? http://www.youtube.com/watch?v=EhvD4KuAEmo If it does, it looks like this will probably be the biggest breakthrough in science ever :) This question is a near duplicate of Does the "Energy Catalyzer" by Andrea Rossi et al. generate energy by converting Nickel to Copper? , but perhaps it is ok, because some time has passed, and there is more confidence in the assessment.
{ "domain": "physics.stackexchange", "id": 1800, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "energy, nuclear-engineering, fusion, cold-fusion", "url": null }
Let $$x=a+d_a$$, $$y=b+d_b$$, and $$z=c+d_c$$; then you want to minimize $$|d_a|+|d_b|+|d_c|$$ while satisfying $$d_a+d_b+d_c=3d-a-b-c\equiv D$$. By the triangle inequality, $$|d_a|+|d_b|+|d_c|\ge|d_a+d_b+d_c|=|D|;$$ so the minimized quantity can't possibly be smaller than $$|D|$$. Clearly this optimal value can be achieved by setting $$d_a=d_b=d_c=D/3$$, and this is one pleasantly symmetric solution. (For instance, it also minimizes $$(x-a)^2+(y-b)^2+(z-c)^2$$.) In terms of the original variables, you would want $$x=d+\frac{2}{3}a-\frac{1}{3}b-\frac{1}{3}c, \\ y=d-\frac{1}{3}a+\frac{2}{3}b-\frac{1}{3}c, \\ z=d-\frac{1}{3}a-\frac{1}{3}b+\frac{2}{3}c.$$ But in fact the optimal value is achieved whenever $$d_a$$, $$d_b$$, and $$d_c$$ have the same sign as $$D$$ and sum to $$D$$. As OP describes, this solution space is geometrically an equilateral triangle, with vertices where $$(d_a,d_b,d_c)$$ is equal to $$(D,0,0)$$, $$(0,D,0)$$, and $$(0,0,D)$$. In terms of the original values, those
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9828232904845687, "lm_q1q2_score": 0.8012294754888734, "lm_q2_score": 0.8152324871074608, "openwebmath_perplexity": 228.7638517654585, "openwebmath_score": 0.8999483585357666, "tags": null, "url": "https://math.stackexchange.com/questions/3080686/how-to-optimize-three-numbers-such-that-their-sum-is-always-equal/3085290" }
c++, c++11, linux, socket, tcp Maybe you need to check if it is connected before disconnecting. Member accesses clientSock::host = host; clientSock::port = port; This is a funny way of accessing member variables. Normally I would use this-> to specify the exact member (rather than className:: as that implies static members). But better yet is not never to shadow member variables. Shadowed variables will eventually cause a problem as you will forget to disambiguify them from the shadow and your compile will not warn you when you go wrong. A nice trick is to turn on your compiler warnings to tell you about shadowed variables and to treat them as errors. Comments I hate bad comments. But this would be a nice place for a comment. setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (char*)&tv, sizeof(struct timeval));*/ enable_keepalive(sockfd);
{ "domain": "codereview.stackexchange", "id": 26095, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c++, c++11, linux, socket, tcp", "url": null }
quantum-field-theory, cosmology, field-theory, dark-matter, axion Title: Scalar field displacement from the minimum of the potential gives rise to particles/dark matter, why? In This paper (Kobayashi et al -- Lyman-alpha Constraints on Ultralight Scalar Dark Matter: Implications for the Early and Late Universe) it says, at the beginning of Section 3.1: A light scalar field stays frozen at its initial field value in the early Universe. Hence, any initial displacement from the potential minimum gives rise to a scalar dark matter density in the later universe.
{ "domain": "physics.stackexchange", "id": 80694, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "quantum-field-theory, cosmology, field-theory, dark-matter, axion", "url": null }
performance, matrix, postscript end } dup 0 10 dict put def %u v {operator} vop u(op)v %apply a binary operator to corresponding elements %in two vectors producing a third vector as result /vop { 1 dict begin /op exch def 2 copy length exch length ne { /vop cvx end /undefinedresult signalerror } if [ 3 1 roll % [ u v 0 1 2 index length 1 sub { % [ ... u v i 3 copy exch pop get % u v i u_i 3 copy pop get % u v i u_i v_i op exch pop % u v u_i(op)v_i 3 1 roll % u_i(op)v_i u v } for % [ ... u v pop pop ] end } def %length of a vector /mag { 0 exch { dup mul add } forall } def /elem { % M i j 3 1 roll get exch get % M_i_j } def
{ "domain": "codereview.stackexchange", "id": 18165, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "performance, matrix, postscript", "url": null }
lowpass-filter, digital-filters, analog-to-digital, highpass-filter Title: Should we use a digital low pass or high pass filter to remove sensor bias? Consider a continuous signal oversampled at, say $2 \;kHz$, and then system digital low pass filtered to a $100\;Hz$ frequency which is the control loop frequency. It is known that there is some bias in the signal since it is an accelerometer output.
{ "domain": "dsp.stackexchange", "id": 10029, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "lowpass-filter, digital-filters, analog-to-digital, highpass-filter", "url": null }
ros, gazebo, wxwidgets NODES / gazebo (gazebo_ros/gzserver) gazebo_gui (gazebo_ros/gzclient) auto-starting new master process[master]: started with pid [13148] ROS_MASTER_URI=http://localhost:11311 setting /run_id to 0bc030d2-8882-11e3-81c2-00216a476f4e process[rosout-1]: started with pid [13161] started core service [/rosout] process[gazebo-2]: started with pid [13175] process[gazebo_gui-3]: started with pid [13180] Gazebo multi-robot simulator, version 1.9.3 Copyright (C) 2013 Open Source Robotics Foundation. Released under the Apache 2 License. http://gazebosim.org Gazebo multi-robot simulator, version 1.9.3 Copyright (C) 2013 Open Source Robotics Foundation. Released under the Apache 2 License. http://gazebosim.org
{ "domain": "robotics.stackexchange", "id": 16809, "lm_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, gazebo, wxwidgets", "url": null }
javascript, jquery, sorting, lodash.js Ideally the original data set would be sorted by this array's values. jQuery is an option. To clarify: I don't actually want to order by desc or asc, I want to order by a random array of values. If I specify ['random3', 'random2'] in an array, I want the object in the dictionary which corresponds to name: 'random3' to be first in the result. Lodash provides orderBy (formerly sortByOrder), as mentioned in this answer. Something like this might work: var dict_sorted = _.orderBy(dict, ['name'], ['asc']); Edit: Based on your comments, you don't want lodash at all. You just want to sort an array by an arbitrary key. The key, in this case, is the order in which a value appears in another array of values provided by you. Array.sort() takes a comparison function as its argument. I'd suggest the following:
{ "domain": "codereview.stackexchange", "id": 29428, "lm_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, sorting, lodash.js", "url": null }
So, the case when the matrix is not invertible is not so much special in terms of matrix method versus convex optimization algorithm. It's just that linear regression allows a special simple solution with matrices or linear systems, when general problems do not, and you have to find the minimum with an iterative method: an optimization algorithm. Note that there are cases where, in spite of apparent simplicity, inverting the matrix has a much higher algorithmic complexity than a reasonably precise convex optimization algorithm. This is usually when there are lots of features (hundreds to millions). That's why people use convex optimization methods even for linear regression.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9830850872288504, "lm_q1q2_score": 0.8037452708751844, "lm_q2_score": 0.817574471748733, "openwebmath_perplexity": 206.77107746339317, "openwebmath_score": 0.8210034370422363, "tags": null, "url": "https://stats.stackexchange.com/questions/295343/usefulness-of-convexity-of-linear-regression-when-there-is-no-closed-form-soluti" }
python, algorithm, strings, programming-challenge, time-limit-exceeded The length of a root must be a divisor of the length of the input string: you could skip other lengths. For example for the input string "abcabcabc" (length = 9), "ab" (length = 2) or "abcd" (length = 4) cannot be a root, so no need to check those The length of a root must be less than equal to half the length of the input string, otherwise it's the input string itself (frequency = 1) Taking the above into consideration, this implementation should be faster: def sroot(text): text_len = len(text) for segment_len in range(1, text_len // 2 + 1): if text_len % segment_len != 0: continue frequency = text_len // segment_len if text[:segment_len] * frequency == text: return frequency return 1
{ "domain": "codereview.stackexchange", "id": 10957, "lm_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, strings, programming-challenge, time-limit-exceeded", "url": null }
ros, python, raspberrypi (rosbridge must be started at you robot before) Nice tool for remote teleop and first person camera view :-) Comment by burf2000 on 2017-01-03: Whats Rosbridge for? I go and google it :) So when I mean teleop, I mean a way to control the robot via the keyboard etc Comment by burf2000 on 2017-01-04: Just tried your script, you rock mate, super useful! Comment by burf2000 on 2017-01-10: Did you do any encoder examples mate?
{ "domain": "robotics.stackexchange", "id": 26597, "lm_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, python, raspberrypi", "url": null }
The theoretical and computational aspects of Fourier analysis are vast and far-reaching. We have given only the briefest of introductions. ## Exercises¶ 1. ⌨ Each of the following functions is 2-periodic. Use Function 9.5.3 to plot the function together with its trig interpolants with $$n=3,6,9$$. Then, for $$n=2,3,\ldots,30$$, compute the max-norm error in the trig interpolant by sampling at $$1000$$ or more points, and make a convergence plot on a semi-log scale. (a) $$f(x) = e^{\sin (2\pi x)}\qquad$$ (b) $$f(x) = \log [2+ \sin (3 \pi x ) ]\qquad$$ (c) $$f(x) = \cos^{12}[\pi (x-0.2)]$$ 2. (a) ✍ Show that the functions $$\sin(r\pi x)$$ and $$\sin(s\pi x)$$ are identical at all of the nodes given in (9.5.2) if $$r-s=mN$$ for an integer $$m$$. This important fact is called aliasing, and it implies that only finitely many frequencies can be distinguished on a fixed node set.
{ "domain": "tobydriscoll.net", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9898303413461358, "lm_q1q2_score": 0.8413272589355137, "lm_q2_score": 0.849971175657575, "openwebmath_perplexity": 953.1833547414302, "openwebmath_score": 0.8837364315986633, "tags": null, "url": "https://tobydriscoll.net/fnc-julia/globalapprox/trig.html" }
scala, validation object WorkSheetStreetSecondaryJ { println("required by ScalaIDE or a silent/unexplained execution failure occurs") object StreetSecondary extends ((String, Option[String]) => StreetSecondary) { type Parameters = (String, Option[String]) val cache = CacheBuilder .newBuilder() .maximumSize(10000L) .expireAfterAccess(30, TimeUnit.SECONDS) .build[String, Object] implicit val scalaCache: ScalaCache = ScalaCache(GuavaCacheWrapper(cache)) def apply(designator: String, value: Option[String] = None): StreetSecondary = validate(designator, value) match { case Some(runtimeExceptionsException) => throw runtimeExceptionsException case None => create(designator, value) } def apply(parameters: Parameters): StreetSecondary = StreetSecondary(parameters._1, parameters._2)
{ "domain": "codereview.stackexchange", "id": 14931, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "scala, validation", "url": null }
javascript // If file type is set to CSS, create dynamic stylesheet link element if (filetype === 'css'){ stylesheet.type = 'text/css'; stylesheet.rel = 'stylesheet'; stylesheet.href = (filename + '.css'); stylesheet.media = (mediaquery) ? mediaquery : 'screen'; // Use screen for media unless otherwise specified // If a file name has been specified, append dynamic stylesheet link element if (filename.length){ head.appendChild(stylesheet); } } // If file type is set to JS, create dynamic script element link else if(filetype === 'js'){ script.type = 'text/javascript'; script.src = (filename + '.js'); // If a file name has been specified, append dynamic script element if (filename.length){ head.appendChild(script); } } else{ return; } };
{ "domain": "codereview.stackexchange", "id": 2973, "lm_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 }
fft, ofdm, lte, sc-fdma Title: For a 20 MHz channel, with 1200 usable subcarriers(18 MHz occupied), what should be the size of the FFT on the transmitter before IFFT is applied? I am trying to simulate the SC-FDMA transmission and I read H Myung's paper and research on the topic but I am not sure exactly on what should be the size of FFT at the transmitter. For a 20 MHz channel, with 1200 available subcarriers, what should be the size of the FFT block? The research talks about IFFT at transmitter sized N = M·Q where Q is the number of users and M is the no. of subcarriers in each block of Q. So do we perform a M pt. FFT on each Q block or on the entire 1200 symbols at the transmitter before IFFT? Link to paper: https://ieeexplore.ieee.org/abstract/document/4099344 We perform M point FFT on each Q block, then map the FFT results to intended positions of 1200 available subcarriers (subcarrier mapping), which are finally the input of a 2048-iFFT operation. See the figure below.
{ "domain": "dsp.stackexchange", "id": 7743, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "fft, ofdm, lte, sc-fdma", "url": null }
cosmology, gravity, space-expansion, universe you'll see that the lines of constant latitude are curved, and the lines of constant longitude are roughly straight but not parallel. The same thing happens to FLRW coordinates: surfaces of constant cosmological time are curved (extrinsically in the full spacetime) and lines of constant cosmological position are straight (they're geodesics) but they aren't parallel. If two people at the same latitude but different longitudes in Australia both walk due north, they will get further apart. This is not because Australia expands as you go north, but because their paths aren't parallel. They are literally walking away from each other. The same is true in spacetime.
{ "domain": "physics.stackexchange", "id": 79346, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "cosmology, gravity, space-expansion, universe", "url": null }
rotational-dynamics, geophysics, newtonian-gravity, centrifugal-force, equilibrium If you include the non-spherically-symmetric correction to the gravitational field of the Earth, $hg$ will approximately change to $hg-hg/2=hg/2$, and correspondingly, the required bulge $\Delta h$ will have to be doubled to compensate for the rotational potential. A heuristic explanation of the factor of $1/2$ is that the true potential above an ellipsoid depends on "something in between" the distance from the center of mass and the distance from the surface. In other words, a "constant potential surface" around an ellipsoidal source of matter is "exactly in between" the actual surface of the ellipsoid and the spherical $R={\rm const}$ surface. I will try to add more accurate formulae for the gravitational field of the ellipsoid in an updated version of this answer. Update: gravitational field of an ellipsoid
{ "domain": "physics.stackexchange", "id": 4505, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "rotational-dynamics, geophysics, newtonian-gravity, centrifugal-force, equilibrium", "url": null }
organic-chemistry, acid-base, resonance, inductive-effect Title: Acidic strength of nitrophenols I've seen the pKa values of Nitrophenol as follows:- pKa of o-nitrophenol= 7.23 pKa of p-nitrohenol= 7.14 so p-nitrophenol is more acidic than p-nitrophenol
{ "domain": "chemistry.stackexchange", "id": 17228, "lm_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, acid-base, resonance, inductive-effect", "url": null }
ros, c++, ros-melodic, pcl, pointcloud Title: Removing Single Points from a sensor_msgs::PointCloud2 Hi, I am trying to build a dynamic mask for robot systems using a Kinect2. My Idea is to use a naive euklidean distance search to remove the robot from the world. (I want to have a hole in the cloud where the robot is) Unfortunately I don't know how to do that. Can you help me? This is the part that needs help: for (sensor_msgs::PointCloud2ConstIterator<float> it(output, "x"); it != it.end(); ++it) { // TODO: do something with the values of x, y, z try { transformStamped = tfBuffer.lookupTransform("kinect2_rgb_optical_frame", "RobotCenter",ros::Time(0), ros::Duration(2)); CamRobX = transformStamped.transform.translation.x; CamRobY = transformStamped.transform.translation.y; CamRobZ = transformStamped.transform.translation.z; CamPointX = it[0]; CamPointY = it[1]; CamPointZ = it[2];
{ "domain": "robotics.stackexchange", "id": 32503, "lm_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++, ros-melodic, pcl, pointcloud", "url": null }
transform Original comments Comment by Lorenz on 2012-09-05: I guess the problem is actually that, if sim time is enable and clock is not published yet, the current time ros::Time::now() is always zero. That is, as far as I know, by intention. I remember that you are not the first one who ran into this and I think it was ticketed before. Comment by piyushk on 2012-09-06: @Lorenz: /clock was being published. Perhaps the node did not have enough time to receive a /clock message before calling ros::Time::now()? That seems a bit odd. Comment by Lorenz on 2012-09-06: Actually, to me it doesn't seem odd at all :) It takes a while until the tcpip connection between a publisher and a subscriber is set up because there are a few xmlrpc requests and topic negotiation involved. Comment by piyushk on 2012-09-06:
{ "domain": "robotics.stackexchange", "id": 10906, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "transform", "url": null }
x = Cos[ϕ] Sin[θ]; y = Sin[ϕ] Sin[θ]; z = Cos[θ]; A = {{4, 11, 14}, {8, 7, -2}}; ParametricPlot[ A.{x, y, z}, {θ, 0, Pi}, {ϕ, 0, 2 Pi}, MeshStyle -> {Red, Blue}, ColorFunction -> "MintColors"] • Very nice: shows what happens to the latitudes and longitudes, facilitating OP's interpretation of the actual transformation. – march Sep 30 '16 at 19:51 • @yarchik Is all the code present here for drawing this image? I am using Mathematica 11 and I'm not getting all of those mesh lines. – David Sep 30 '16 at 21:15 • @David, yes, I have MA9 – yarchik Sep 30 '16 at 21:22 • On Mathematica 10 I get the lines only after I add Mesh -> 20 to the ParametricPlot. @David – user484 Sep 30 '16 at 22:01 • I'd like to thank all of my colleagues for all of their wonderful assistance. This page has some absolutely wonderful answers. – David Oct 1 '16 at 16:10 Visualization From a GeometricTransformation on the unit sphere:
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9728307724028542, "lm_q1q2_score": 0.8189539023653125, "lm_q2_score": 0.8418256551882382, "openwebmath_perplexity": 4579.699253993769, "openwebmath_score": 0.24556739628314972, "tags": null, "url": "https://mathematica.stackexchange.com/questions/127645/transform-sphere-to-an-ellipse-in-mathbbr2/127647" }
c#, algorithm, datetime So the usual cure of incomprehensible code - clear variables names - won't help much here. What can we do for the poor person who has to maintain this code 6 months, or 6 years, later? We can let them know where this algorithm comes from. This is easy enough. A comment referencing the source would allow someone seeing this to check that it is still doing what it is supposed to do. Beyond adding this comment, the algorithm for calculating Easter is unlikely to be a bottleneck in any piece of software, so assuming that this algorithm is correct (proven and tested) I would leave it as is.
{ "domain": "codereview.stackexchange", "id": 30482, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c#, algorithm, datetime", "url": null }
Question 40 Explanation: As here we want subset of edges that connects all the vertices and has minimum total weight i.e. Minimum Spanning Tree Option A - includes cycle, so may or may not connect all edges. Option B - has no relevance to this question. Option C - includes cycle, so may or may not connect all edges. Related: http://www.geeksforgeeks.org/greedy-algorithms-set-2-kruskals-minimum-spanning-tree-mst/ http://www.geeksforgeeks.org/greedy-algorithms-set-5-prims-minimum-spanning-tree-mst-2/ This solution is contributed by Mohit Gupta. Question 41 Consider a weighted undirected graph with positive edge weights and let uv be an edge in the graph. It is known that the shortest path from the source vertex s to u has weight 53 and the shortest path from s to v has weight 65. Which one of the following statements is always true? A weight (u, v) < 12 B weight (u, v) ≤ 12 C weight (u, v) > 12 D weight (u, v) ≥ 12 Graph Shortest Paths    Graph Theory    Gate IT 2007 Discuss it
{ "domain": "geeksforgeeks.org", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9780517469248845, "lm_q1q2_score": 0.8407956329542221, "lm_q2_score": 0.8596637505099167, "openwebmath_perplexity": 504.4346073515372, "openwebmath_score": 0.564095675945282, "tags": null, "url": "http://quiz.geeksforgeeks.org/graph-theory/" }
newtonian-mechanics Notice that the the normal reaction force is a reaction force, that is, it depends on the resultant downward force applied by an object on a surface and the surface hence applies an equal force upwards on the object(These are a Newton’s Third Law Pair as these forces are essentially from repulsion of electron clouds in the atoms of one object and the other). Start from interpreting the free body diagram of the top block(Block 1). It has a Weight $W_1$ so the box is pushing down on Block 2 with a contact force equal to $W_1$, so this is the normal force, $N_1$ on Block 2 from Block 1 and now Block 2 thus pushes back on Block 1 with an equal and opposite force of $N_1$ on Block 1. Thus Block 1 is at equilibrium as it’s own weight is now balanced by a normal reaction force($N_1$) from Block 2.
{ "domain": "physics.stackexchange", "id": 53332, "lm_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", "url": null }
ros, c++, function void stage_listener::addOdomNode (const nav_msgs::Odometry mes){ geometry_msgs::Pose robot_pose = mes.pose.pose; geometry_msgs::Point robot_point = robot_pose.position; odom_node *on = new odom_node(); (*on).xCoord = robot_point.x; (*on).yCoord = robot_point.y; (*on).frame_id = mes.header.frame_id; double orientation = tf::getYaw(robot_pose.orientation); (*on).angle = (float)orientation; odom_list.push_back(*on); }
{ "domain": "robotics.stackexchange", "id": 11987, "lm_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++, function", "url": null }
ros, navigation, move-base, gdb I hope this information is sufficient. Please ask me anything else that you might require. Cheers! Originally posted by Shanker on ROS Answers with karma: 259 on 2012-02-06 Post score: 1 I would run top while you try to run this program to see how much of your system memory you are consuming. You're using a 4000x4000 pixel map, so this could easily use the majority of your RAM. Maybe I read it wrong, but it looked like you loaded this map more than once in the backtrace. This could explain your problem. Originally posted by DimitriProsser with karma: 11163 on 2012-02-06 This answer was ACCEPTED on the original site Post score: 2
{ "domain": "robotics.stackexchange", "id": 8123, "lm_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, navigation, move-base, gdb", "url": null }
algorithms, strings, correctness-proof, stacks Algorithm: let stck be an empty stack of characters for each character c in the string b: if c=="c": if length of stack is strictly less than 2: return False if the second to last character is not "a" OR the last character is not "b": return False stck.pop stck.pop else: stck.push(c) return true if and only if stck is empty Congratulation, your algorithm works fast and correctly like magic. However, why is it correct? Claim: A string $s$ is valid iff either $s$ is empty or the two letters to the left of the leftmost occurrence of $c$ in $s$ is "$ab$" and $s$ with that "$abc$" removed is still valid. Proof: "$\impliedby$" is by definition.
{ "domain": "cs.stackexchange", "id": 19815, "lm_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, strings, correctness-proof, stacks", "url": null }
programming-challenge, time-limit-exceeded, swift, collatz-sequence var cache = [Int](repeating: 0, count: cacheSize) cache[1] = 1 func collatzLengthCached(n: Int64) -> Int { if let smallN = Int(exactly: n), smallN < cacheSize { if cache[smallN] > 0 { return cache[smallN] } let len = 1 + collatzLengthCached(n: collatzFunc(n: n)!) cache[smallN] = len return len } return 1 + collatzLengthCached(n: collatzFunc(n: n)!) } let (maxN, maxLength) = (1...999_999) .map { ($0, collatzLengthCached(n: $0)) } .max { $0.1 < $1.1 }! This code, compiled with Xcode with optimization ("Release" configuration) runs in about 0.08 seconds on my 1.2 GHz Intel Core m5 MacBook.
{ "domain": "codereview.stackexchange", "id": 24627, "lm_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-challenge, time-limit-exceeded, swift, collatz-sequence", "url": null }
r, sql Expected Output as a new df: Key1 BV1 Key2 BV2 A1 100 A1 150 A2 200 A2 250 A3 300 A3 350 A4 400 NA NA A5 500 NA NA If I understand correctly: Table1 <- data.frame(key = seq(1,100),a.data = rnorm(100)) Table2 <- data.frame(key = c(seq(1,30),rep(NA,30)), b.data = seq(1,60)) ##Assuming this is what you want library(sqldf) sql.ans <- sqldf("select a.*, b.key from Table1 a LEFT OUTER JOIN Table2 b on a.key = b.key where b.key is null") ## dplyr version library(dplyr) dplyr.ans <- Table1 %>% filter(!key %in% Table2$key) ## Regular R version R.ans <- Table1[which(!Table1$key %in% Table2$key),] EDIT after dummy data and expected output dplyr.ans2 <- left_join(df1,df2, by = c("Key1" = "Key2")) Key1 BV1 BV2 1 A1 100 150 2 A2 200 250 3 A3 300 350 4 A4 400 <NA> 5 A5 500 <NA>
{ "domain": "datascience.stackexchange", "id": 684, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "r, sql", "url": null }
java, performance, radix-sort You mentioned decimal digits, and I see no reason to go there. But consider sorting into 4 buckets during a pass, or 8, or 16....
{ "domain": "codereview.stackexchange", "id": 26942, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "java, performance, radix-sort", "url": null }
I think there is some problem stating the induction hypothesis this way, becuase for n=1, it may be m, but for n=2, it may be something else (note necessarily m), and etc...for n=k ? 9. Originally Posted by kingwinner OK, then if we're using strong induction, I am wondering how we can state the induction hypothesis properly? For all 1≤n≤k, $ $ $n = 2^{j_0} + \ldots + 2^{j_m} " alt="n = 2^{j_0} + \ldots + 2^{j_m} " /> where m≥0 and 0≤jo<j1<j2<...<jm
{ "domain": "mathhelpforum.com", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9799765575409524, "lm_q1q2_score": 0.814500706963124, "lm_q2_score": 0.8311430520409023, "openwebmath_perplexity": 363.76801993595166, "openwebmath_score": 0.9033180475234985, "tags": null, "url": "http://mathhelpforum.com/number-theory/123347-every-natural-number-sum-powers-2-a.html" }
homework-and-exercises, newtonian-mechanics, projectile $$\begin{align} v_x = \sqrt{\frac{g}{2(h-P_{1y})}}\frac{P_{2x}-P_{1x}}{1\pm\sqrt{\frac{h-P_{2y}}{h-P_{1y}}}} \end{align}$$ The (+) solution has the trajectory reach the maximum height, $h$, before reaching point $P_2$, and the (-) solution's trajectory reaches the maximum height after passing through $P_2$.
{ "domain": "physics.stackexchange", "id": 97460, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "homework-and-exercises, newtonian-mechanics, projectile", "url": null }
c, game, memory-management, console, hangman } closedir(dir); } return a; } /*/ * * Check if str2 contains str1 * return 1 if true */ int stringCont(char *str1, char *str2) { int str2Len = strlen(str2); int counter = 0; int str1Len = strlen(str1); for (int i = 0; i < str2Len; i++) { counter = i; for (int a = 0; str1[a] == str2[counter]; a++) { counter++; } if ((counter - i) > str1Len) { return 1; } } return 0; } There's a lot of code here (the poor indentation in making it harder to read), but I'll skim through and recommend several things I've found.
{ "domain": "codereview.stackexchange", "id": 6939, "lm_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, memory-management, console, hangman", "url": null }
c++, beginner, simulation, physics, sfml pBodies.clear(); } void PollEvent(sf::RenderWindow* pTarget, bool* pIsPaused, sf::View* pSimView) { sf::Event event; while (pTarget->pollEvent(event)) { if (event.type == sf::Event::Closed) pTarget->close(); if (event.type == sf::Event::KeyPressed) { if (event.key.code == sf::Keyboard::Space) *pIsPaused = !*pIsPaused; //toggle what is pointed to by IsPaused } if (event.type == sf::Event::MouseWheelScrolled) { zoom *= 1 + (static_cast <float> (-event.mouseWheelScroll.delta) / 10); //for each notch down, -10%, for each notch up, +10% pSimView->zoom(1 + (static_cast <float> (-event.mouseWheelScroll.delta) / 10)); } }
{ "domain": "codereview.stackexchange", "id": 14510, "lm_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, simulation, physics, sfml", "url": null }
photons, heisenberg-uncertainty-principle, double-slit-experiment, diffraction out of the slit are not coming exactly straight. The pattern is spread out by the diffraction effect, and the angle of spread, which we can define as the angle of the first minimum, is a measure of the uncertainty in the final angle. How does the pattern become spread? To say it is spread means that there is some chance for the particle to be moving up or down, that is, to have a component of momentum up or down. We say chance and particle because we can detect this diffraction pattern with a particle counter, and when the counter receives the particle, say at $C$ in Fig. 2–2, it receives the entire particle, so that, in a classical sense, the particle has a vertical momentum, in order to get from the slit up to $C$. To get a rough idea of the spread of the momentum, the vertical momentum $p_y$ has a spread which is equal to $p_0\Delta\theta$, where $p_0$ is the horizontal momentum. And how big is $\Delta\theta$ in the spread-out pattern?
{ "domain": "physics.stackexchange", "id": 92051, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "photons, heisenberg-uncertainty-principle, double-slit-experiment, diffraction", "url": null }
design If the print-head pins are driven ballistically they might not be able to work with the high duty cycle that a Braille dot would require. If you use push wires, you could have a cam that moves a latch plate back and forth, alternately latching wires in place or releasing them so they can move up or down. Or you could have a cam that lifts all the Braille pins at once, and a print head that drives some latch pins sideways to catch those Braille pins that that should remain up. Another cam would clear all the latch pins at the beginning of each character cycle.
{ "domain": "robotics.stackexchange", "id": 152, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "design", "url": null }
python, performance, python-3.x, pyqt, minesweeper Here is the code: (I know it's not the best, it's still a prototype) def update_display(self): if(Debug == 1): print("[Updating Cells...]") for column in range(self.cells): #print(column) for row in range(self.cells): #print(row) #if(Debug == 1): # print("[Changing tile ({},{})]".format(row,column)) if self.initialArray[row][column] <= 9: self.button[row, column].setIcon(QtGui.QIcon(dataFolder + 'tile_plain.gif')) elif self.initialArray[row][column] == 10: self.button[row, column].setIcon(QtGui.QIcon(dataFolder + 'tile_clicked.gif')) elif self.initialArray[row][column] == 11:
{ "domain": "codereview.stackexchange", "id": 42582, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "python, performance, python-3.x, pyqt, minesweeper", "url": null }
c#, game, winforms, chess // Add squares _squares = new Square[ColumnCount, RowCount]; for (int y = 0; y < ROW_COUNT; y++) { for (int x = 0; x < COL_COUNT; x++) { _squares[x, y] = new Square(this, x, y); } } // Add pieces AddDefaultPieces(); } private void AddDefaultPieces() { char[,] defaultPieces = { { 'P','P','P','P','P','P','P','P'}, { 'R','N','B','Q','K','B','N','R'} }; // Pieces Player player; Square square; for (int i = 0; i < 2; i++) { player = _players[i]; for (int y = 0; y < 2; y++) { for (int x = 0; x < COL_COUNT; x++) { if (player.Colour == PieceColour.White) {
{ "domain": "codereview.stackexchange", "id": 44471, "lm_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, winforms, chess", "url": null }
neural-network, nlp, lstm, prediction Consider an LM that is trained on a dataset having the example sentences given above — given the word “magical”, what should be the most likely next word: realism, music, or power? Say, that, in fact, the next word is neither one, but "power", but my LSTM has never seen that word before. So, the LSTM is going to predict one of the three words it has seen, but I would like it to output a low confidence score. Is this possible? Couldn't you require your softmax output to exceed a threshold for the prediction or you call it "not confident"? I have not tried word prediction, but the softmax gives you a value for each output, where all of those values sum to 1. So pick the column with the highest value as your predicted word and use that value to determine your confidence. (It may be fairly low, since there might be a small chance of lots of words and then larger chances of your most-common three.)
{ "domain": "datascience.stackexchange", "id": 2843, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "neural-network, nlp, lstm, prediction", "url": null }
navigation, mapping, gmapping Originally posted by igoliao on ROS Answers with karma: 41 on 2012-06-03 Post score: 1 It's not gmapping that is using only three discrete values, but the nav_msgs/OccupancyGrid.msg message format. Internally, gmapping uses probabilistic cell values, but in the slam_gmapping.cpp source, starting in line 631, those are converted to above linked message format like so: for(int y=0; y < smap.getMapSizeY(); y++) { /// @todo Sort out the unknown vs. free vs. obstacle thresholding GMapping::IntPoint p(x, y); double occ=smap.cell(p); assert(occ <= 1.0); if(occ < 0) map_.map.data[MAP_IDX(map_.map.info.width, x, y)] = -1; else if(occ > occ_thresh_) { //map_.map.data[MAP_IDX(map_.map.info.width, x, y)] = (int)round(occ*100.0); map_.map.data[MAP_IDX(map_.map.info.width, x, y)] = 100; } else map_.map.data[MAP_IDX(map_.map.info.width, x, y)] = 0; }
{ "domain": "robotics.stackexchange", "id": 9643, "lm_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, mapping, gmapping", "url": null }
javascript, jquery, html, html5, jquery-ui For your second point, I'd probably wrap the code in an addFolder function somewhere. But it's a little hard to be more specific without knowing more about the context. For your third point, you could again make a simple jQuery plugin that'd only forward events to your click handler if the element doesn't have the "clicked" class. There are also various "debounce" plugins out there to throttle clicks, but most simply impose a time limit rather than explicitly wait for an ajax operation to finish. In any event, here's another (very quick) sketch of a jQuery plugin $.fn.clickOnce = function(handler) { return this.each(function() { var element = $(this); element.on("click", function (event) { if( !element.hasClass("clicked") ) { element.addClass("clicked"); if( typeof handler === "function" ) { handler.call(this, event); } } }); }); };
{ "domain": "codereview.stackexchange", "id": 3844, "lm_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, html5, jquery-ui", "url": null }
c#, json, validation, api, .net-core In this code block i apply a json schema validation against an http request with json body. But because of this validation will perform against every request maybe it will cause a performance issues. For now, this code block took under 2ms but i want to improve the performance. Do you have any idea? And also if you have an advice about code quality, i would be glad to know it. Useless Copying You're creating a lot of lists for no reasons. No need to copy one list to another just to iterate over it. Separation of Concerns The schema validation code pollutes the controller method. It's much better placed in a custom model binder or Filter
{ "domain": "codereview.stackexchange", "id": 43879, "lm_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#, json, validation, api, .net-core", "url": null }
navigation, gps, ros-kinetic, robot-localization Originally posted by Tom Moore with karma: 13689 on 2019-01-30 This answer was ACCEPTED on the original site Post score: 0
{ "domain": "robotics.stackexchange", "id": 32202, "lm_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, gps, ros-kinetic, robot-localization", "url": null }
quantum-mechanics, thermodynamics, statistical-mechanics, temperature, atomic-physics Title: What is meant by the temperature of an atom? Does it make sense to ask 'what is the temperature of an atom?'. An atom can be considered a SYSTEM of particles (electrons and nucleons) that are structured in a particular way. So can it be assigned a temperature? How? Systems in equilibrium have the energy of their atoms described by the Boltzmann distribution (https://en.m.wikipedia.org/wiki/Boltzmann_distribution) $p_i \propto e^{\frac{E_i}{k_BT}}$ $p_i$ is the probability of finding an atom in state $i$ $E_i$ is the energy of state $i$ $k_B$ is the Boltzmann constant $T$ is the temperature Like most other probability distributions, you can calculate averages using them, and in this case the average kinetic energy of the atoms is proportional to the temperature.
{ "domain": "physics.stackexchange", "id": 64061, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "quantum-mechanics, thermodynamics, statistical-mechanics, temperature, atomic-physics", "url": null }
qiskit, cirq, angular-momentum My Code #!/usr/bin/env python3 import numpy as np import qiskit_nature from qiskit import QuantumCircuit, QuantumRegister from qiskit.providers.aer import Aer from qiskit.quantum_info import Statevector from qiskit_nature.converters.second_quantization import QubitConverter from qiskit_nature.drivers import Molecule from qiskit_nature.drivers.second_quantization import ElectronicStructureMoleculeDriver, ElectronicStructureDriverType from qiskit_nature.mappers.second_quantization import JordanWignerMapper from qiskit_nature.problems.second_quantization import ElectronicStructureProblem from qiskit_nature.transformers.second_quantization.electronic import ActiveSpaceTransformer if __name__ == '__main__': qiskit_nature.settings.dict_aux_operators = True backend = Aer.get_backend('statevector_simulator')
{ "domain": "quantumcomputing.stackexchange", "id": 4124, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "qiskit, cirq, angular-momentum", "url": null }
particle-physics, string-theory, standard-model So an open string is equivalent to a $24\infty$-dimensional harmonic oscillator (yes, it's twenty-four times infinity). Each of the directions in this oscillator contributes $Nn/ \alpha'$ to the squared mass $m^2$ of the resulting particle where $N$ is the total excitation level of the harmonic oscillators that arise from the $n$-th Fourier mode. At any rate, the possible values of the squared mass $m^2$ of the particle are some integer multiples of $1/\alpha'$. This dimensionful parameter $1/\alpha'$ is also called $1/l_{string}^2=m_{string}^2$.
{ "domain": "physics.stackexchange", "id": 5374, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "particle-physics, string-theory, standard-model", "url": null }
knowrob Can someone help me? Any suggestion is welcome! Maybe @moritz can help me :) Thank you Originally posted by Noah on ROS Answers with karma: 15 on 2014-02-05 Post score: 0 Hmm, do you use an up-to-date knowrob from github? The binaries are quite outdated and somewhat broken. You'll need the 'complete' version from here if you want to use the GUI. http://www.knowrob.org/installation#installation_from_source Originally posted by moritz with karma: 2673 on 2014-02-06 This answer was ACCEPTED on the original site Post score: 0 Original comments Comment by Noah on 2014-02-07: Hi @moritz, you're right. I installed the .deb version. Now with source installation seems working.
{ "domain": "robotics.stackexchange", "id": 16897, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "knowrob", "url": null }
c#, brainfuck, compiler static void WriteIndents(StringBuilder sb, int indents) { sb.Append($"{new string(' ', indents * 4)}"); } } The nice thing about it is that it writes well-structured Brainfuck. The template is: using System; namespace Brainfuck_Interpreter { class CompiledTemplate { static byte ReadChar() { return (byte)Console.ReadKey().KeyChar; } static void Main(string[] args) { byte[] buffer = new byte[BufferSize]; int index = 0; BrainfuckCode; Console.WriteLine("Program terminated successfully..."); Console.ReadLine(); } } } HelloWorld is converted from: [ This program prints "Hello World!" and a newline to the screen, its length is 106 active command characters. [It is not the shortest.]
{ "domain": "codereview.stackexchange", "id": 16211, "lm_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#, brainfuck, compiler", "url": null }
java, graph @Test public void hasSelfLoop() { UndirectedGraph<Integer> graph = new UndirectedGraph<>(); graph.addEdge(1, 1); Assert.assertTrue(graph.hasCycles()); } @Test public void hasNoLoopsSingleNode() { UndirectedGraph<Integer> graph = new UndirectedGraph<>(); graph.addNode(12); Assert.assertFalse(graph.hasCycles()); } @Test public void hasSelfLoop2() { UndirectedGraph<Integer> graph = new UndirectedGraph<>(); graph.addEdge(1, 2); graph.addEdge(2, 3); graph.addEdge(3, 3); Assert.assertTrue(graph.hasCycles()); } @Test public void hasCycles() { UndirectedGraph<Integer> graph = new UndirectedGraph<>(); graph.addEdge(1, 3); graph.addEdge(1, 2); graph.addEdge(2, 3); Assert.assertTrue(graph.hasCycles()); }
{ "domain": "codereview.stackexchange", "id": 23830, "lm_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, graph", "url": null }
c#, .net, wcf value = ddc.GetDatabaselist(); return result; case "GetProcesslist": value = ddc.GetProcesslist(); return result; case "GetCurrenttime": value = ddc.GetCurrenttime(); return result; case "GetUptime": value = ddc.GetUptime(); return result; default: result = UNDEFINED_OPERATION; return result; } } catch (Exception ex) { result = ex.Message; return result; } finally { DisplayTransmissionOnTextbox(operation, host, result); } }
{ "domain": "codereview.stackexchange", "id": 2391, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c#, .net, wcf", "url": null }
solid-state-physics Title: Bloch's Theorem validity can someone explain me what kind of solids does Bloch's Theorem apply to? Does it only apply to crystalline solids? I mean ionic crystals should fall in this category, but what about other periodic solids? It applies to solids whereby you can meaningfully identify a unit cell being repeated for hundreds of such cells in any one direction, so that you can meaningfully pretend that the repetition actually goes on infinitely, and then later come back to say that it only goes for a finite size. Note that the dimensions that are not repeated will not have Bloch's theorem apply to those directions. Crystalline solids, by definition of crystalline, necessarily will work. There are quasiperiodic systems, and Bloch's theorem should not be working for them. I wonder if we have resident experts on them to chime in on how they are studied.
{ "domain": "physics.stackexchange", "id": 94978, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "solid-state-physics", "url": null }
ros, pose, camera-pose-calibration, camera EDIT: In the file calibrate_4_cameras.launch, the lines that give me the error are the following: <!-- generate robot measurements --> <node pkg="camera_pose_calibration" type="multicam_capture_exec.py" name="capture_exec" args="$(arg camera1_ns) $(arg camera2_ns) $(arg camera3_ns) $(arg camera4_ns)" output="screen"> <param name="cam_info_topic" value="camera_info" /> <remap from="request_interval" to="interval_filtered" /> </node> Do I need that lines to have camera calibrated? What does they do? EDIT2: I've followed the stack trace and I've found that multicam_capture_exec.py calls robot_measurement.cache.py. At the line 34 it try to import a package that is not available: import roslib; roslib.load_manifest('pr2_calibration_executive') I've tryed to comment out that lines and the error goes away but I'm still not able to have some output to /tf.
{ "domain": "robotics.stackexchange", "id": 9704, "lm_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, pose, camera-pose-calibration, camera", "url": null }
python, performance, primes, mathematics for i, isprime in enumerate(a): if isprime: yield i for n in xrange(i * i, limit, i): a[n] = False if __name__ == "__main__": prod = 1 for p in prime_sieve(240000): prod *= (1 - 1.0 / p) print prod primes_less_than = p - 1 amta = 1 - prod print "The convergence:", primes_less_than print "All the way up to the number:", amta print "The amount of active inhibitors are:", prod * primes_less_than
{ "domain": "codereview.stackexchange", "id": 23471, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "python, performance, primes, mathematics", "url": null }
computer-engineering, computer-hardware Title: Computer "Ports", port scans and daemons If I do a port scan from the internet, do I hit a bundle of wires that are physical ports into the motherboard (like a PCE port)? Or do I actually go into the operating system and interact with the virtual or 'logical' ports of the OS? I am trying to understand what the difference is between these ports, and why, if they are logical, I would be able to scan any of them from the internet, because it implies my bytes are passing over hardware to reach these 'logical' ports inside the CPU and cache, rather than on the peripheral hardware (before they are rejected)… This feels wrong... But if they are actually physical, then where are they? And, if I have a daemon listen on a port that is "opened", does this mean that the program is listening to bytes that pass over a physical component on the motherboard, exterior to the cache-ram-cpu area? The ports referred to in a "port scan" are logical.
{ "domain": "engineering.stackexchange", "id": 2135, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "computer-engineering, computer-hardware", "url": null }
newtonian-mechanics, forces, classical-mechanics, friction, torque I need some guidance to solve the problem. I know that the force of friction is $\mu mg$ where $\mu$ is some friction coefficient (not sure which) and $mg$ is the normal force of the tire. I also know that the necessary condition for rolling without slipping is that $v = R\omega$, where $v$ is the velocity of the tire's center of mass, $R$ is the radius of the tire and $\omega$ the angular speed of the tire. I think I have to involve the torque of the tire somehow and use Newton's second law, but I am not sure how. $\mu$ is the frictional coefficient for static friction since the tire is rolling without slipping. In the non-sliding case, $\mu N$ give a maximum value for the frictional force, not necessarily the actual amount. These links may be helpful:
{ "domain": "physics.stackexchange", "id": 74993, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "newtonian-mechanics, forces, classical-mechanics, friction, torque", "url": null }
optics, refraction Assumption that speed and wavelength are multiplied by the same factor There is the basic relationship $c = \lambda f$ for the phase velocity of a wave (which comes from the observation, that within one period of the wave, the wave front must advance by one wave length by the very definition of the quantities). So for the the wave length and phase velocity to change by a different factor the frequency of the wave would have to change. This can't happen (up to non-linear effects which may induce higher harmonics of the base frequency), because the wave in the medium is excited by the incident wave, so the excitation there has the same frequency of the incoming wave.
{ "domain": "physics.stackexchange", "id": 86509, "lm_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, refraction", "url": null }
kalman-filters, estimation, bayesian-estimation As you can see above, different estimators are derived from different loss. In the case the posterior is Gaussian the Mode, Median and Mean collide (There are other distributions which have this property as well). So in the classic model of the Kalman Filter (Where the Posterior is also Gaussian) the Kalman Filter is actually the MMSE, The Median and the MAP Estimator all in one. Derivation with More Details To show full derivation we will assume $ \theta \in \mathbb{R} $ just for simplicity. The $ {L}_{2} $ Loss We're after $ \hat{\theta} = \arg \min_{a} \int {\left( a - \theta \right)}^{2} p \left( \theta \mid x \right) d \theta $. Since it is smooth with respect to $ \hat{\theta} $ we can find where the derivative vanishes: $$\begin{aligned} \frac{d}{d \hat{\theta}} \int {\left( \hat{\theta} - \theta \right)}^{2} p \left( \theta \mid x \right) d \theta & = 0 \\
{ "domain": "dsp.stackexchange", "id": 8600, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "kalman-filters, estimation, bayesian-estimation", "url": null }
radicands to radicands ( do... ( see next step ) that create a perfect square to negative!. Step is to simplify any radical expressions whole number outside of the number inside the radical sign every.... Roots ) Essential Question How do I multiply and divide radicals can be simplified into.. ) to remove the parenthesis because neither number is a number outside of the common students... Often make with radicals ( square Roots, you want to take out as much as.!: Always simplify radicals task cards are Numbered for easy Recording and include standard that! A reverse operation of squaring the radical of their products when you simplify a radical, but radical. Value is that we do not know if y is positive or negative a... Radical form and show How to simplify radicals they are like radicals How simplify... Sqrt ( 4 ) can be simplified into 2 I can simplify it as a whole outside. A number outside of the number inside the radical when you simplify a when... Product of two radicals does not
{ "domain": "gob.mx", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.981735721648143, "lm_q1q2_score": 0.8116124997470036, "lm_q2_score": 0.8267117940706734, "openwebmath_perplexity": 607.5708475436666, "openwebmath_score": 0.7944364547729492, "tags": null, "url": "http://gob2018.morelia.gob.mx/m879h4w8/viewtopic.php?id=becddd-how-to-simplify-radicals-with-a-number-on-the-outside" }
rosjava Title: Building new rosjava package I try to build a new ros package using rosjava. I followed the tutorial and stored my source code in the new package (i.e. /src/main/java/org/ros/reasoner/). Than I took the sample file for build.gradle apply plugin: 'application' mainClassName = 'org.ros.RosRun' dependencies { compile 'ros.rosjava_core:rosjava:0.0.0-SNAPSHOT' } When running my gradle with "gradle build" I get the following error. :compileJava FAILURE: Build failed with an exception. * What went wrong: Could not resolve all dependencies for configuration ':compile'. > Could not find group:ros.rosjava_core, module:rosjava, version:0.0.0-SNAPSHOT. Required by: :rosjava_cylinder_reasoner:unspecified rosjava was build according to the tutorial with gradlew install and all went right. What is wrong with my approach? Cheers, Markus
{ "domain": "robotics.stackexchange", "id": 9416, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "rosjava", "url": null }
dsp-core, bandpass, digital-filters, fixed-point Please see below a frequency characteristics of the filter in $z$-domain generated by MATLAB. As one can see, this type of a filter is very sensitive in terms of a frequency response. Even smallest changes in parameters could cause completely different behavior, e.g., an unexpected gain, phase shift etc.
{ "domain": "dsp.stackexchange", "id": 4714, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "dsp-core, bandpass, digital-filters, fixed-point", "url": null }
lo.logic, type-theory, linear-logic which forces conjunction and disjunction apart much further than we are used to in conventional logic, I recommend not to think of linear logic in terms of resources (although this is an important reading). Instead think of linear logic formulae $A$ as processes that communicate at a port / name / channel. This interpretation has been fleshed out first in (1) to the best of my knowledge, but it's already alluded to in Girard's original work. As a picture: (I'm not sure how properly to center images here.) Linear conjunction $A \otimes B$ is interpreted as running processes $A$ and $B$ in parallel. The process $A \otimes B$ communicates pairs $(a, b)$ at its port, where $a$ comes from $A$ and $b$ is $B$'s communication.
{ "domain": "cstheory.stackexchange", "id": 4043, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "lo.logic, type-theory, linear-logic", "url": null }
evolution, natural-selection, mathematical-models, population-genetics, evolutionary-game-theory Reference: Hamilton 1970 "Selfish and Spiteful Behaviour in an Evolutionary Model" http://www.nature.com/nature/journal/v228/n5277/abs/2281218a0.html It is not a regression (not at this stage of the paper, a regression will be done latter) The only complicated thing to understand is $b_i$, which is the 'base relatedness', ie how $i$ is related to a random individual (to be compared to how related it is to individuals with whom it interacts). To simplify let's first consider the situation where $b_i = 0$: $E(qj) = b_{i,j} q_i + (1-b_{i,j}) q$ is just the translation of 'the gene frequency of the replica part is q_i' and 'the gene frequency of the non replica part is $q$'; because $b_{i,j}$ is the fraction of the replica part, ie the chances that our locus of interest belongs to the replica part of individual $i$ in individual $j$.
{ "domain": "biology.stackexchange", "id": 3762, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "evolution, natural-selection, mathematical-models, population-genetics, evolutionary-game-theory", "url": null }
c#, object-oriented, design-patterns, interview-questions, console and some concrete types class Circle : Shape { } For each type you can write a factory that implements a common interface: interface IShapeFactory { Shape CreateShape(); } Each factory of course can depend on other services like reading from the console etc. class CircleFactory : IShapeFactory { public Shape CreateShape() { // read params etc return new Circle(); } } Finally you create a dictionary with all the shape factories var shapeFactories = new Dictionary<string, IShapeFactory>(StringComparer.OrdinalIgnoreCase) { [nameof(Circle)] = new CircleFactory() }; var shapeName = // read shape name... if (shapeFactories.TryGetValue(shapeName, out IShapeFactory shapeFactory)) { var shape = shapeFactory.CreateShape(); } You can now add as many shapes and factories as you want without touching any other shapes or common code.
{ "domain": "codereview.stackexchange", "id": 24699, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c#, object-oriented, design-patterns, interview-questions, console", "url": null }
quantum-mechanics, schroedinger-equation, klein-gordon-equation, time-reversal-symmetry, charge-conjugation Title: Schroedinger and Klein-Gordon equation and their complex conjugate Let's consider the Schroedinger equation: \begin{equation} i\hbar\frac{\partial}{\partial t}\psi=-\frac{\hbar}{2m}\nabla^2\psi \end{equation} If I have a wavefunction $\psi$ as a solution, then its complex conjugate $\psi^*$ is not a solution. If I'm not mistaken this means that the Schroedinger equation is NOT invariant under charge conjugation C, am I right? And what does $\psi^*$ represent, if $\psi$ is the wave function describing my particle?
{ "domain": "physics.stackexchange", "id": 31147, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "quantum-mechanics, schroedinger-equation, klein-gordon-equation, time-reversal-symmetry, charge-conjugation", "url": null }
For example, you might think that the Quaternion group can be presented by $\langle i, j \mid i^2 = j^2, i^4=1\rangle$. But note that $F_2/N \twoheadrightarrow \mathbb Z/4\mathbb Z \times \mathbb Z/2\mathbb Z$, via $i \mapsto (1, 0)$ and $j \mapsto (1, 1)$. Since $\mathbb Z/4\mathbb Z \times \mathbb Z/2\mathbb Z$ is not a quotient of the quaternion group (it is the same size as the quaternion group, but, e.g., it is abelian while the quaternion group is not), our presentation must not be complete.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9838471613889295, "lm_q1q2_score": 0.8020641705209959, "lm_q2_score": 0.815232489352, "openwebmath_perplexity": 99.86610400583318, "openwebmath_score": 0.8577318787574768, "tags": null, "url": "https://math.stackexchange.com/questions/1997108/how-do-you-know-which-relations-will-define-a-group" }
But how do I prove this? As in, I'm only given the starting equation, how do I get from there to a right angled triangle? • Note that, $\sin^2b=\cos^2a+\cos^2c$ or any other combination. – Mann Jun 15 '15 at 12:27 • i think you mean $sin^2(c) = AB^2/BC^2$ and not $sin(c) = AB^2/BC^2$ – supinf Jun 15 '15 at 12:36 • Yup, thanks for the catch, that's what I meant. Fixed now. – MikhaelM Jun 15 '15 at 12:38 Notice, in $\Delta ABC$ , we have $a+b+c=180^o$
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9817357211137666, "lm_q1q2_score": 0.8284819670507599, "lm_q2_score": 0.8438951025545426, "openwebmath_perplexity": 447.3578115539249, "openwebmath_score": 0.8719284534454346, "tags": null, "url": "https://math.stackexchange.com/questions/1326114/problem-with-sine-in-a-right-triangle" }
python, algorithm, python-2.x for x, color in enumerate(row): cell = state[CURRENT][x] for dir_index, (y_diff, x_diff) in enumerate(DIRECTIONS): prev_x = x + x_diff if color == EMPTY: cell[dir_index] = 0 elif 0 <= prev_x < len(row) and color == matrix[y + y_diff][prev_x]: # There's a piece which doesn't match the previous one # or previous was out of bounds cell[dir_index] = state[CURRENT + y_diff][prev_x][dir_index] + 1 else: cell[dir_index] = 1 if cell[dir_index] == WIN: if color == WHITE: white_win = True else: black_win = True # Early termination if both win conditions met if white_win and black_win: return white_win, black_win
{ "domain": "codereview.stackexchange", "id": 24037, "lm_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-2.x", "url": null }
python, music, acoustics, array-signal-processing, doa Why do we need this tensor X in the first place? The MUSIC algorithm provided by the original paper (and anywhere else as far as I know) does not use any frequency representation. It only calculates the autocorrelation matrix in time domain and uses the steering vector which is known due to the geometry of the setup then follows it by eigenvalue decomposition. def _process(self, X): """ Perform MUSIC for given frame in order to estimate steered response spectrum. """ # compute steered response self.Pssl = np.zeros((self.num_freq, self.grid.n_points)) C_hat = self._compute_correlation_matricesvec(X) # subspace decomposition Es, En, ws, wn = self._subspace_decomposition(C_hat[None, ...]) # compute spatial spectrum identity = np.zeros((self.num_freq, self.M, self.M)) identity[:, list(np.arange(self.M)), list(np.arange(self.M))] = 1
{ "domain": "dsp.stackexchange", "id": 11278, "lm_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, music, acoustics, array-signal-processing, doa", "url": null }
electrons Title: Does an "excited atom" lose energy gradually? When an electron absorbs energy and is in a higher energy orbit (I guess the atom would be in an unstable state), when the electron releases this energy, would all of this energy be released at the same time, or could it release energy one "level" at a time? So for example if a Hydrogen atom absorbed a lot of energy and its electron went to some level n = 5, could it slowly make its way back down to level 1? Yes, it certainly can. In fact, it can do either, traverse gradually across excitation states down to its ground state, or jump from its current state to its ground state, or to any lower state for that matter. So essentially, as long as the target state is equal or lower in energy than the current one the electron can jump to it.
{ "domain": "chemistry.stackexchange", "id": 5987, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "electrons", "url": null }
organic-chemistry, reaction-mechanism, synthesis (2) -COOH is deactivating meta directing group (due to presence of >C=O) so friedel-crafts bromination would take place at meta position. (3)Yes,as -NH2 is better activator than -CH3 so bromination would take place ortho with respect to -NH2 (4)I think it is mistake of your book for not showing any catalysts like AlCl3 but It should be friedel-crafts bromination as -Br replaced one of the -H at ortho (to -CH3) of benzene. (5) As it is friedel-crafts bromination,Br+ ion will be easily satisfied(to be octet) by pi bond of benzene than sigma bond -C-H of-CH3.(since sigma bond is more stronger than pi bond so pi bond can be easily broken and form meta-stable sigma complex)
{ "domain": "chemistry.stackexchange", "id": 5419, "lm_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, synthesis", "url": null }
javascript, ajax, finance You could use an Ajax function to avoid repetition of that bit of code: function getAjaxRequest() { var ajaxRequest; try { // ... return ajaxRequest; } If you extend your code you will ultimately want a more capable function for controlling ajax requests, in which case look at this Stack Overflow answer. Not using synchronous requests is probably good advice. Also, I think the usual way of dealing with IE is as shown here. It is better to build HTML using createElement and appendChild rather than setting the innerHTML. In particular, using innerHTML to set event handlers will get confusing and unreadable very quickly for code of any complexity. Better to do something like... var creditTd = document.createElement('td'); creditTd.className = 'credit'; creditTd.id = 'credit0'; creditTd.addEventListener('keypress', function() { addRow(1); }); creditTd.contentEditable = "true"; dataCell[0].appendChild(creditTd);
{ "domain": "codereview.stackexchange", "id": 3949, "lm_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, ajax, finance", "url": null }
python, beginner, performance, python-3.x, portability def runntfs(): ''' This function runs the Windows specific tests that can't be put into the cross platform checks ''' print('NTFS Tests running!') ############################ # OSX SPECIFIC THINGS HERE # ############################ def runosx(): ''' This function runs the OSX specific tests that can't be put into the cross platform checks ''' print('OSX Tests runnning!') ################# # MAIN CODE RUN # ################# if args.ntfs and args.osx: print ("You can't run both Windows and OSX flags on the same system!") exit(0) if args.ntfs: print('You chose NTFS!') runntfs() elif args.osx: print('You chose OSX!') runosx() else: print('No OS specified!')
{ "domain": "codereview.stackexchange", "id": 14899, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "python, beginner, performance, python-3.x, portability", "url": null }
ros, c++, ros-fuerte, multi-machine Originally posted by Lorenz with karma: 22731 on 2012-08-28 This answer was ACCEPTED on the original site Post score: 0 Original comments Comment by SivamPillai on 2012-08-29: I did go through your link but it did not seem so simple for me the way its stated there coz am nt tht good on networking concepts. but it acts like a starter. Maybe I'll read more before i could post any sensible query on tht if i come across one. Thanks for your link and your answer there. :) Comment by SivamPillai on 2012-09-03: I'll implement this answer at quiet a later time... but after my reading through several information on the internet your answer makes perfect sense now... vpn should definitely work. Thanks.
{ "domain": "robotics.stackexchange", "id": 10800, "lm_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++, ros-fuerte, multi-machine", "url": null }
sorting, partial-order Title: Efficiently determine relative ordering between two elements in a PO-set What algorithms/heuristics exist for efficiently determining the relative order between two elements in a partially ordered set? In my case, the PO-set is stored as a directed acyclic graph where an edge is an happened before relation and I am streaming live data into this PO-set. Nodes usually have less than 5 backward edges, with 1 being the most common, and there will be at most 10^6 nodes. The newly inserted nodes usually have edges to the previously most recently inserted nodes. I am usually doing this query just after I've added a node to the graph, to find the relative ordering between the inserted node and a few select other nodes, so the traversal paths tend to overlap a lot. I am also maintaining a total order of the PO-set as I go, which might be useful for this as well.
{ "domain": "cs.stackexchange", "id": 8588, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "sorting, partial-order", "url": null }
python, genetic-algorithms Title: Genetic Algorithm Python Snake not improving So, i have created Snake game using Pygame and Python. Then i wanted to create an AI with Genetic algorithm and a simple NN to play it. Seems pretty fun, but things aren't working out. This is my genetic algorithm: def calculate_fitness(population): """Calculate the fitness value for the entire population of the generation.""" # First we create all_fit, an empty array, at the start. Then we proceed to start the chromosome x and we will # calculate his fit_value. Then we will insert, inside the all_fit array, all the fit_values for each chromosome # of the population and return the array all_fit = [] for i in range(len(population)): fit_value = Fitness().fitness(population[i]) all_fit.append(fit_value) return all_fit
{ "domain": "ai.stackexchange", "id": 2257, "lm_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, genetic-algorithms", "url": null }
classical-mechanics, coordinate-systems, conventions, constrained-dynamics Assumptions: No friction, $m_1 = m_2 = m$, $l$ is the length of the rigid bar which connects Block 1 with Block 2, $\vec{g}$ goes down. In order to apply d'Alembert's and virtual work principles, I can define the virtual displacements differentiating the following equations: \begin{align*} x &= l \cos \theta \\ y &= l \sin\theta \end{align*} Thus, the virtual displacements are: \begin{align*} \delta x &= - l \sin \theta \delta \theta \\ \delta y &= l \cos \theta \delta \theta \end{align*} Assuming that Block 1 goes down and Block 2 goes right, the equation for the virtual work can be written as: $$ \delta W = m\vec{g} \cdot \delta\vec{y} - m\vec{\ddot{y}} \cdot \delta\vec{y} - m\vec{\ddot{x}} \cdot \delta\vec{x} = mg \delta y - m\ddot{y}\delta y - m\ddot{x}\delta x= 0 $$ The last equation becomes: $$
{ "domain": "physics.stackexchange", "id": 86024, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "classical-mechanics, coordinate-systems, conventions, constrained-dynamics", "url": null }
One more clue : the ink stain can be several separate pieces, but total area must be smaller than 1 cm2
{ "domain": "physicsforums.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9648551566309689, "lm_q1q2_score": 0.8122398148204444, "lm_q2_score": 0.8418256452674008, "openwebmath_perplexity": 476.77327747512834, "openwebmath_score": 0.46526506543159485, "tags": null, "url": "http://www.physicsforums.com/showthread.php?t=146519" }
classical-mechanics, forces, work, potential-energy, conservative-field In the second step, the author changes the order of integration and summation. Integration theory will tell you when that is possible mathematically, but generally speaking, for most physical situations, this can be done without worrying too much. Further he interprets the $q_j$ coordinate as a parametrisation of a special curve connecting $q_A$ and $q_B$. For conservative forces $F_i^S$, of course the integral is path independent, so we can as well write it as the integral over an arbitrary path. The third equality is using the fact that, if an integral is path independent, there is a potential and the integral value only depends on the potential difference between beginning and end points. With your suggested definition $V=\sum_i V_i$ we arrive at the fourth expression, as all the $V_i$ are evaluated at the same points. Edit: Follow-Up questions by OP in the comments:
{ "domain": "physics.stackexchange", "id": 32632, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "classical-mechanics, forces, work, potential-energy, conservative-field", "url": null }