text
stringlengths
49
10.4k
source
dict
java, unit-testing, fizzbuzz, junit Title: Fizz Buzz Test Driven Development Task: Create the Fizz Buzz game using Test Driven Developoment. Print the correct word for range 1-100. The implementation: public class Main { static final String FIZZ = "Fizz"; static final String BUZZ = "Buzz"; static final String FIZZ_BUZZ = "Fizz Buzz"; public static void main(String[] args) { IntStream.range(1, 101).forEach((x) -> System.out.println(getWordForNumber(x))); } public static String getWordForNumber(int x) { if (isDivisibleWithoutRemainder(x, 15)) { return FIZZ_BUZZ; } else if(isDivisibleWithoutRemainder(x, 3)) { return FIZZ; } else if(isDivisibleWithoutRemainder(x, 5)) { return BUZZ; } return Integer.toString(x); } private static boolean isDivisibleWithoutRemainder(int dividend, int divisor) { return (dividend%divisor == 0); } } The JUnit Test: final class Number { private final int n; Number (int number) { n = number; } final boolean isMatchedToWord(final String word) { return Main.getWordForNumber(n).equals(word); } }
{ "domain": "codereview.stackexchange", "id": 30543, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "java, unit-testing, fizzbuzz, junit", "url": null }
javascript, node.js, asynchronous getOne(req, res) .then(function (result) { return getTwo(result); }) .then(function (result) { // do something useful with final result }) .catch(function (err) { console.error("Three was an error", err); res.send("Error in serving request."); }) .done();
{ "domain": "codereview.stackexchange", "id": 5600, "lm_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, node.js, asynchronous", "url": null }
urdf, camera I was trying to change the image width and hight but that just makes my image bigger not change the pixel size. Thx so much friends. Originally posted by End-Effector on ROS Answers with karma: 162 on 2015-03-19 Post score: 0 Ok I was confused about the definition of Pixel. You can't change the size of pixels. Originally posted by End-Effector with karma: 162 on 2015-03-19 This answer was ACCEPTED on the original site Post score: 0
{ "domain": "robotics.stackexchange", "id": 21170, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "urdf, camera", "url": null }
homework-and-exercises, electrostatics, electric-fields, vectors where $\mathbf r_i$ are the position vectors of the charges under consideration. In our case, it's easy to see that $$\mathbf r_{\rm COM}=\frac{ \vec{OA}+\vec{OB}+\vec{OC}+\vec{OD}+\vec{OE}}{5}$$ Thus, we can say that $\mathbf E\propto -\mathbf r_{\rm COM}$ Now in the case where these charges are placed symmetrically across the unit circle, the value of $\mathbf r_{\rm COM}$ vanishes to become a null vector. Thus, the electric field which, as we discussed, was proportional to $-\mathbf r_{\rm COM}$, bow also vanishes and becomes zero. In fact, these set of arguments can be generalized to any $n$-sided polygon, always yielding the same value (zero) if the electric field.
{ "domain": "physics.stackexchange", "id": 70488, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "homework-and-exercises, electrostatics, electric-fields, vectors", "url": null }
5. Originally Posted by masters You'll have to tell me if this is what you have coded: $\dfrac{\dfrac{2x}{\sqrt{x-1}}-\sqrt{x-1}}{x-1}$ Yeah it is. Did you actually type \dfrac{\dfrac{2x}{\sqrt{x-1}}-\sqrt{x-1}}{x-1} between the math brackets? Or do you use a program and then copy/paste or something o_O; Thanks. 6. Originally Posted by DHS1 Yeah it is. Did you actually type \dfrac{\dfrac{2x}{\sqrt{x-1}}-\sqrt{x-1}}{x-1} between the math brackets? Or do you use a program and then copy/paste or something o_O; Thanks. Just type it in just like that. You can go here for a tutorial on this tool. $\dfrac{\dfrac{2x}{\sqrt{x-1}}-\sqrt{x-1}}{x-1}\cdot \dfrac{\sqrt{x-1}}{\sqrt{x-1}}=\dfrac{2x-(x-1)}{(x-1)(\sqrt{x-1})}=\dfrac{2x-x+1}{(x-1)(\sqrt{x-1})}=$ $\dfrac{x+1}{(x-1)(\sqrt{x-1})} \cdot \dfrac{\sqrt{x-1}}{\sqrt{x-1}}=\dfrac{(x+1)(\sqrt{x-1})}{(x-1)^2}$ 7. Wow great! I'm learning so much. Last one I'll ask for help with, I promise! Directions: Re-write each expression as a single fraction in lowest terms.
{ "domain": "mathhelpforum.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9688561721629776, "lm_q1q2_score": 0.8828020912524748, "lm_q2_score": 0.9111797154386843, "openwebmath_perplexity": 558.2787990628507, "openwebmath_score": 0.8530687093734741, "tags": null, "url": "http://mathhelpforum.com/pre-calculus/62653-negative-exponents.html" }
javascript, jquery, playing-cards // .suit is created in the template card css class // It will search for this css class and add the content aka innerHTML card.find(".playerCardSuit").html("&" + _card.suit + ";"); // ♠ -> ♠, ♣ -> ♣, ♥ -> ♥, ♦ -> ♦ // more char, https://www.w3schools.com/charsets/ref_utf_symbols.asp // hearts and diamonds are red color. otherwise, default black color. if (_card.suit === "hearts" || _card.suit === "diams") { card.addClass("red"); } // option: replace previous card with new card (show one card all the time) $("#cardContainerPlayer").append(card); } // This function use JQuery lib function makeCardDealer(_card, _holeCard) { // .card is created in the template card css class var card = $(".card.templateDealer").clone(); card.removeClass("templateDealer"); // .cardFace is created in the template card css class // It will search for this css class and add the content aka innerHTML card.find(".dealerCardFace").html(_card.face); // .suit is created in the template card css class // It will search for this css class and add the content aka innerHTML card.find(".dealerCardSuit").html("&" + _card.suit + ";"); // ♠ -> ♠, ♣ -> ♣, ♥ -> ♥, ♦ -> ♦ // more char, https://www.w3schools.com/charsets/ref_utf_symbols.asp
{ "domain": "codereview.stackexchange", "id": 35048, "lm_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, playing-cards", "url": null }
quantum-mechanics, measurement-problem, wavefunction-collapse, decoherence Title: Wave Function Collapse Versus Decoherence I'm aware that wave function collapse is still a topic of debate-and that decoherence is a pretty good explanation for how things might approach wave function collapse, in some sense. But the way I've seen it be explained, it seems that the reason things collapse is that upon interacting with macroscopic things, the wave function decoheres until there is only one component left. But in this light, it's just that the remaining components are arbitrarily small, correct? The analogy I saw was that you wouldn't be able to reconstruct the waves in a far off country by looking at the ripples at your local beach- but theoretically you could, right? But the way I've seen it be explained, it seems that the reason things collapse is that upon interacting with macroscopic things, the wave function decoheres until there is only one component left. No. That's not the way decoherence works at all. A system $S$ interacts with the environment $E$ with a Hamiltonian that does the following: $$ |k\rangle_S|0\rangle_E\to|k\rangle_S|k\rangle_E. $$ So a superposition evolves so that $$ \sum_k\alpha_k|k\rangle_S|0\rangle_E\to\sum_k\alpha_k|k\rangle_S|k\rangle_E. $$ In the latter state you can't do interference between the $k$ values using the system $S$ alone whereas in the former state you could do that. So owing to the interaction between the environment and the system the system doesn't evolve coherently. This process does not change the amplitudes of the different possible outcomes. But in this light, it's just that the remaining components are arbitrarily small, correct? The analogy I saw was that you wouldn't be able to reconstruct the waves in a far off country by looking at the ripples at your local beach- but theoretically you could, right?
{ "domain": "physics.stackexchange", "id": 18035, "lm_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, measurement-problem, wavefunction-collapse, decoherence", "url": null }
ros, subscribe, callback Title: Is it necessary to using Callback function when I subscribe? Hi guys! I'm begginer studying ros at this moment. When I do tutorials that make talker and listener (Publisher & Subscriber), I really wonder weather it is necessary to using callback function in subscriber. If I dosen't use callback function, I could get the message? Or If I can use it, How to I get the message? Thanks guys! Have a good day also. Originally posted by haryngod on ROS Answers with karma: 30 on 2015-11-22 Post score: 0 Original comments Comment by Dimitri Schachmann on 2015-11-23: Never seen such a possibility and I think the fact that ros works heavily with callbacks is one of the good things about ros. Why would you avoid callbacks? Comment by haryngod on 2015-11-23: I just curious about it for understanding ros system. Thanks a lot comment to me! The short answer is yes they are necessary. Callbacks are triggered when messages are received. They are required to be able to do something useful with new data. There are other approaches which would require the user to poll for new messages that could be implemented, but that's generally a completely different programming model. Originally posted by tfoote with karma: 58457 on 2018-03-21 This answer was ACCEPTED on the original site Post score: 2 Original comments Comment by JamesGiller on 2018-03-21: Also, to answer "How to I get the message?": The function you supply as a callback is provided with the message as an argument, so that is how you access it.
{ "domain": "robotics.stackexchange", "id": 23054, "lm_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, subscribe, callback", "url": null }
quantum-operation, kraus-representation The Choi matrix $J(\Phi)$ is a linear operator mapping $\mathcal{H}_B \otimes \mathcal{H}_A$ onto itself. Thus the maximal rank of $J(\Phi)$ is $d_A d_B$, where $d_A = \mathrm{dim}(\mathcal{H}_A)$, and likewise for $B$. This is the maximal number of different Kraus operators $M_n$ one might need. Each $M_n$ is a linear operator from $\mathcal{H}_A$ to $\mathcal{H}_B$. Thus it has in general $d_A d_B$ complex entries, i.e. $2 d_A d_B$ free real parameters. The completeness relation given above fixes $d_A^2$ real parameters. This leaves us with $d_A d_B \cdot 2 d_A d_B - d_A^2 = d_A^2 (2d_B^2 - 1)$ free parameters. Is my reasoning correct or did I overlook something? I get the same result when considering the Stinespring representation and counting the free real parameters in the isometry. Any help much appreciated. An easier way of counting is to consider the Choi state: It is a hermitian $d_Ad_B\times d_Ad_B$ matrix, and thus has $(d_Ad_B)^2$ real parameters. The condition that the reduced state of $A$ is the identity gives $d_A^2$ real constraints (real since the reduced state is already hermitian). You thus remain with $$ d_A^2(d_B^2-1) $$ real parameters.
{ "domain": "quantumcomputing.stackexchange", "id": 5498, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "quantum-operation, kraus-representation", "url": null }
homework-and-exercises, thermodynamics, temperature, conductors Title: Relation between Temperature and heat current This problem: I was able to solve it doing this: But I think i have nowhere " exploited " the equivalence given above. How can this be used in this problem? The first relation has been derived by using the equivalence given above. $$\frac {dQ}{dt} = j(\vec r)*4\pi r^2$$ Putting $$\frac {dT}{dr} =k* j(\vec r)$$ Since $$\frac {dV}{dr} = \vec E(\vec r)$$ We will get the same relation
{ "domain": "physics.stackexchange", "id": 55606, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "homework-and-exercises, thermodynamics, temperature, conductors", "url": null }
## A generalization Suppose, for sake of induction, that for some $$k\ge 1$$ we have shown that $$*n\vee*k$$ is connected. Then if we have a position like $$*m\vee*(k+1)$$, it has moves to $$*(k+1)$$ and to $$*m\vee*k$$, both of which are connected, distinct (unless $$m=1$$ and $$k=1$$, which was handled earlier) and nonzero. Then if $$*m\vee*(k+1)$$ is a disjunctive sum, it must be the sum of those two. But the length of the longest run in the disjunctive sum is $$m+2k+1$$, and the length of the longest run in $$*m\vee*(k+1)$$ is the smaller $$m+k+1$$.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.983596967483837, "lm_q1q2_score": 0.8340585099959253, "lm_q2_score": 0.8479677526147223, "openwebmath_perplexity": 174.4666860889316, "openwebmath_score": 0.8474658131599426, "tags": null, "url": "https://math.stackexchange.com/questions/2932577/can-the-following-nim-like-game-be-broken-down-into-two-parallel-nim-sub-games" }
ros, add-message-files Title: catkin_make error after creating custom message after creating a custom messages files .msg under /mypackage/msg/ when i run the catkin_make i git this error Messages depends on unknown pkg: geometry_msgs (Missing find_package(geometry_msgs?)) even after uncommented this in the Cmake file ## Generate added messages and services with any dependencies listed here generate_messages( DEPENDENCIES geometry_msgs std_msgs ) note when i run the command rospack find geometry_msgs i got this /opt/ros/indigo/share/geometry_msgs Originally posted by g-emad on ROS Answers with karma: 15 on 2016-03-26 Post score: 1 You're probably missing some things in your CMakeLists.txt and / or package.xml. See catkin 0.6.18 documentation » How to do common tasks » Package format 2 (recommended) » Building messages, services or actions. Originally posted by gvdhoorn with karma: 86574 on 2016-03-27 This answer was ACCEPTED on the original site Post score: 3 Original comments Comment by g-emad on 2016-03-27: i will check again
{ "domain": "robotics.stackexchange", "id": 24250, "lm_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, add-message-files", "url": null }
Does that make sense? Please do not hesitate to ask if you have any questions. Mike _________________ Mike McGarry Magoosh Test Prep Education is not the filling of a pail, but the lighting of a fire. — William Butler Yeats (1865 – 1939) Kudos [?]: 8757 [15], given: 105 Director Status: Finally Done. Admitted in Kellogg for 2015 intake Joined: 25 Jun 2011 Posts: 532 Kudos [?]: 4216 [0], given: 217 Location: United Kingdom GMAT 1: 730 Q49 V45 GPA: 2.9 WE: Information Technology (Consulting) Re: If x is an integer then x(x-1)(x-k) must be evenly divisible [#permalink] ### Show Tags 31 Jan 2012, 16:18 Thanks Mike. Really appreciate your solution too. _________________ Best Regards, E. MGMAT 1 --> 530 MGMAT 2--> 640 MGMAT 3 ---> 610 GMAT ==> 730 Kudos [?]: 4216 [0], given: 217 Intern Joined: 31 Jan 2012 Posts: 1 Kudos [?]: 4 [4], given: 0 Re: If x is an integer then x(x-1)(x-k) must be evenly divisible [#permalink] ### Show Tags 31 Jan 2012, 16:34 4 KUDOS This is my 1st post finally thought of jumping in instead of just being an observer I attacked this problem in a simple way. As it states it is divisible by 3 that means both x & (x-1) cannot be a multiple of 3 otherwise whatever the value of k it will be still divisible by 3 so plugging in number i chose 5 in this case you can establish answer is -2 does not fit... Kudos [?]: 4 [4], given: 0 Director Status: Finally Done. Admitted in Kellogg for 2015 intake Joined: 25 Jun 2011 Posts: 532 Kudos [?]: 4216 [0], given: 217
{ "domain": "gmatclub.com", "id": null, "lm_label": "1. Yes\n2. Yes\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 1, "lm_q1q2_score": 0.8596637451167997, "lm_q2_score": 0.8596637451167997, "openwebmath_perplexity": 2078.5322086005, "openwebmath_score": 0.5184522271156311, "tags": null, "url": "https://gmatclub.com/forum/if-x-is-an-integer-then-x-x-1-x-k-must-be-evenly-divisible-126853.html?fl=similar" }
electromagnetism, electrostatics This qualitatively is consistent with having two $-Q$ spheres below: In contrast, the $±Q$ situation seems decidedly wrong (as you'd expect): As is the $+2Q$ situation: Why? How do I explain this "simply"? There's nothing "inconsistent", it's just that the method of image charges doesn't work in this situation, in the sense that there is no simple arrangement of image point charges that will enforce the desired boundary conditions. In fact, the method of images almost never works, it only works for a small number of highly symmetric boundary conditions, so this isn't really surprising. Furthermore, contrary to what the other answer says, you can't fix the situation by moving the charge. If you do this, the method of images will fail in an even worse way: reflecting in the planes will force an image charge to appear in the physical region (i.e. the sector where the real charge is), while the whole point of image charges is that you can satisfy boundary conditions by putting charges in unphysical regions alone.
{ "domain": "physics.stackexchange", "id": 57663, "lm_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, electrostatics", "url": null }
automata, pushdown-automata, nondeterminism This is just an example; what I want to know is how it works for any automaton that has several following states for one and the same state before it. Quite simply, the mechanism is magic. The idea of non-determinism is that it simply knows which way it should take in order to accept the word, and it goes that way. If there are multiple ways, it goes one of them. Non-determinism can't be implemented as such in real hardware. We simulate it using techniques such as backtracking. But it's primarily a theoretical device, which can be used to simplify the presentation of certain concepts. For the palindrome, you can think about it in two ways. Either there's a magical power that lets your machine say "this is the middle of the word, time to switch from pushing to popping", or after reading each letter, it says "I'm going to fork a new process which that this letter is the middle of the word, and see if it finds it's a palindrome. Then in this other thread, I'll keep trying, assuming this isn't the middle of the word". Another way to think of it is as infinite parallelism. So an equivalent model would be that, instead of choosing a new path, it simultaneously tries both paths, branching off new "processes," succeeding if any are in a final state after reading the whole word. Again, this can't be built using real hardware, but can be modelled with non-determinism. The interesting thing about nondeterminism is that for finite-automata and Turing machines, it doesn't increase their computational power at all, just their efficiency.
{ "domain": "cs.stackexchange", "id": 5026, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "automata, pushdown-automata, nondeterminism", "url": null }
mass, astronomy, measurements, asteroids $$ {\bf g}_{\rm rad} = \left(\frac{L_\odot a^2}{4 m r^2}\right) e_r\ .$$ Thus the trajectory will be determined by an acceleration that is slightly smaller than the gravity due to the Sun by an amount that depends on the ratio the area it presents to the Sun divided by its mass. This could well be a tiny perturbation - though obviously gets bigger the more like a "solar sail" the object is (i.e. a large $a^2/m$) - but of course the effects are integrated over the course of its passage through the Solar System. It was exactly this type of argument that lead Bialy & Loeb (2018) to suggest that "Oumuamua" (the first example of an identified interstellar rock) had a non-gravitational acceleration that could be explained if it had a high area to mass ratio, such that it might be less than a cm thick and weigh only of order 1000 kg. The problem with using this technique is that you have to eliminate or separate it from other sources of non-gravitational acceleration - like outgassing from cometary material.
{ "domain": "physics.stackexchange", "id": 93273, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "mass, astronomy, measurements, asteroids", "url": null }
moveit, ros-melodic planning_scene_msg.world.collision_objects.clear(); planning_scene_msg.world.collision_objects.push_back(robot_workspace); // where robot_workspace has been filled with obstacles planning_scene_msg.is_diff = true; planning_scene_msg.robot_state.is_diff = true; ros::ServiceClient update_planning_scene_service_client = nodeHandle.serviceClient<moveit_msgs::ApplyPlanningScene>("apply_planning_scene"); moveit_msgs::ApplyPlanningScene apply_scene_msg; apply_scene_msg.request.scene = planning_scene_msg; update_planning_scene_service_client.call(apply_scene_msg) I can verify that the obstacle is visible in rviz under "Scene Geometry". I invoke the planner as follows planning_scene_monitor::LockedPlanningSceneRO lscene(ur10_planning_scene_monitor); ur10_planning_pipeline -> generatePlan(lscene, motion_request, motion_response); However, the generated trajectory just passes through the obstacle. ----------------------------------- UPDATE 1 ------------------------------------------ After much digging and referring to moveit/moveit_ros/move_group/src/default_capabilities/move_action_capability.cpp, changing ur10_planning_pipeline -> generatePlan(lscene, motion_request, motion_response); to ur10_planning_pipeline -> generatePlan(lscene->diff(planning_scene_msg), motion_request, motion_response);
{ "domain": "robotics.stackexchange", "id": 34972, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "moveit, ros-melodic", "url": null }
visible-light, plasma-physics Title: Is looking at a toy plasma ball dangerous for your eyes? I have a rather cheap USB toy plasma ball. Now I read, that plasma balls can be an eye hazard, if the glass does not filter the emitted UV light. I do not find many sources on how dangerous this actually might be, but I suspect that such a cheap toy will probably have cheap glass which does not filter much of the UV spectrum. Should I be worried, that a cheap plasma ball may be an eye hazard? Cheap glass absorbs UV. If one wants to make a UV lamp one needs more expensive materials like for example quartz glass (fused silica). And the light levels are low anyway. Such plasma spheres only look good in dark surroundings. Light levels and UV levels are much lower than outside in sun light.
{ "domain": "physics.stackexchange", "id": 55588, "lm_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, plasma-physics", "url": null }
forces, pressure, unit-conversion Converting Pa to psi Using the recommendations above, note that the units of Pa are: $[\frac{kg}{m-s^2}]$, and that is the first factor to write. Starting with the numerator, it is seen that the units are kg, which is a mass, and this needs to be converted to $lb_f$ in order to arrive at psi. Thus, the complete set of factors required to convert 1 Pa to psi is as follows: $[\frac{1 kg}{m-s^2}][\frac{2.2 lb_m}{1 kg}][\frac{1 lb_f-s^2}{32.2 ft-lb_m}][\frac{3.28 ft}{1 m}][\frac{1 m}{39.37 in}]^2 = 0.00014458 psi$
{ "domain": "physics.stackexchange", "id": 75975, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "forces, pressure, unit-conversion", "url": null }
algorithms, scheduling, algorithm-design Title: Schedule two trains whose tracks overlap so they don't crash I've encountered scheduling problems in my algorithms class before like the type we use vertex cover to solve. Recently I was asked this question and did not even know what algorithmic technique to use to answer it! There are two trains, which run between stations and share a portion of track. For instance train 1 runs between stations A B C D E F G H and train 2 runs between stations I J K B C D E F L M so the trains share the track between B C D. At each end of the track the train turns around and goes the other way on its track. The trains go from station to station in 1 unit time. I need to prevent the trains from crashing head on on the shared track, I have the power to stop either train at any station and restart it again when I please. How can I solve this problem without using a ton of if else clauses, what CS principles should I be using here? edit Some background, the first solution I wrote was just a simple check to see if the other train was on the shared track before sending the other train out. That seemed ad hoc to me and I'm sure it did to the company I interviewed for as well. I figure there must be an algorithm or at least a school of thought for this type of problem, after all how do they build extensible systems for managing shared runway space at an airport, or managing traffic flow at stop lights. My intuition is that this is a very introductory problem to a school of thought in computational problem solving I have not yet encountered. I might be wrong, but could anybody clear the air for me? If you calculate the cycle, as there are only two trains and distance between every station is one, you could simply run them in order and appoint wait in some station to avoid crash. If you have to implement some unfortunate events (first one stops for some reason, reschedule it to run on itd own time). With two trains it will work without problems. Otherwise use semaphores (it fits even literally ;) There is no explicitly given synchronisation problem, so nasty trick works.
{ "domain": "cs.stackexchange", "id": 5092, "lm_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, scheduling, algorithm-design", "url": null }
ros, ros2, ros-melodic, answers.ros.org Title: How to maximise engagement with questions posted on ROS Answers? I've been posting questions on ROS Answers for a while now and I have found it to be an amazing resource. It's helped me a great deal and it is vital part of the robotics community. However, I'm sometimes unsure whether I am following best practices as some questions I post seem to get a lot of views, comments and answers and some don't. My question is, what do I need to do to maximise engagement in a question? Originally posted by Py on ROS Answers with karma: 501 on 2021-05-18 Post score: 1 A question I've asked myself a few times! It can definitely be tricky, when you maybe aren't even sure what the problem is, to write a clear engaging question. Disclaimer: I'm definitely new enough to ROS answers that I won't claim to have the answer, and haven't looked at your past questions so don't take this as personal advice, but my general tips are as follows: DO: Have a clear and concise title; it doesn't need to have all the details, but should give people a good idea of what issue you've run into Use appropriate tags so the right people can find your question, or know to click in when looking through unanswered questions Make the question as readable as possible; USE CODE FORMATTING please. I've . Let us know what you've tried; people don't want to do your homework for you. Show people you've exhausted basic google search results and tried solutions from existing questions or github issues, or tell us why they don't apply. DON'T: Post lengthy, single format blobs of text and code and console output that make the whole thing unreadable Post vague, unactionable statements and try to pass them off as questions; if you're looking for discussion and input from several users, I've found ROS Discourse to be a more reliable resource
{ "domain": "robotics.stackexchange", "id": 36432, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "ros, ros2, ros-melodic, answers.ros.org", "url": null }
java, beginner, swing, calculator {CalcButton.SEVEN, CalcButton.EIGHT, CalcButton.NINE, CalcButton.PLUS}, {CalcButton.FOUR, CalcButton.FIVE, CalcButton.SIX, CalcButton.MINUS}, ..... } JPanel panel = new JPanel(...); // set up appropriate Layout Manager.... for (int row = 0; row < calclayout.length; row++) { for (int col = 0; col < calclayout[row].length; col++) { CalcButton b = calclayout[row][col]; panel.add(b.getJButton()); b.getJButton().setActionListener(this); } } Conclusion Right now, your code could do with a major refactor and shuffle. have a look at your options, and then try to bring it together in a more structured framework. Your current code has out-grown it's exoskeleton, and it's time to spread it's wings and try something different.
{ "domain": "codereview.stackexchange", "id": 5977, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "java, beginner, swing, calculator", "url": null }
java, unit-testing, junit CountryEntity anotherCountry = createNewCountry(); CityEntity cityEntity = new CityEntity(); cityEntity.setName("Bratislava"); cityEntity.setCountryEntity(anotherCountry); cityDao.create(cityEntity); Assert.assertNotNull("Expected not null value.", cityDao.find(cityEntity.getId())); } There are no more meaningless numbers (such as 2L) in this test case, and the assumptions are loud and clear. Another similar example: @Test public void update_ExistingNameSameCountry_ExceptionThrown(){ exception.expect(ConstraintViolationException.class); CityEntity cityEntity = cityDao.find(2L); cityEntity.setName("Bratislava"); cityDao.update(cityEntity); cityDao.flush(); } This test case seems to assume that the city with id=2 is named Bratislava. Consider this instead: @Test public void update_ExistingNameSameCountry_ExceptionThrown(){ exception.expect(ConstraintViolationException.class); CityEntity cityEntity = cityDao.findSomeCity(); cityEntity.setName(cityEntity.getName()); cityDao.update(cityEntity); cityDao.flush(); } No more hidden assumptions and invisible external data. The city can be any city, if you try to create a new city with the same name as the sample city, the method should throw. Many of your other methods suffer from the same problem. Review them and ask yourself if there are any assumptions that are not written inside the method itself, and make them explicit. Covering all corners Some of your test cases could be more strict, for example: In create_Created, in addition to checking that you can load the new entry that was created, you could check that: the number of entries in the database got increased by 1 Assert.assertEquals(cityEntity, cityDao.find(cityEntity.getId())) Similarly in create_ExistingNameDifferentCountry_Created
{ "domain": "codereview.stackexchange", "id": 7353, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "java, unit-testing, junit", "url": null }
phase-transition, critical-phenomena Landau’s theory of phase transition is some sort of truncated expansion of order parameter around the critical point. According to this theory, at or around the critical point fluctuations are large, hence any mean-field theory shouldn't work. Sufficiently below the critical point, where the order parameter is large, the expansion and truncation at lower powers of order parameters shouldn't hold. So how come everything turns out to be so clean? Why does Landau theory work [so well]?
{ "domain": "physics.stackexchange", "id": 68992, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "phase-transition, critical-phenomena", "url": null }
electromagnetism, magnetic-fields, electric-fields, poynting-vector Title: Is the Poynting vector always perpendicular to the plane a circuit lies in? The Poynting vector is the cross product of electric and magnetic field (divided by $\mu_0$). Given an electric circuit that lies on the plane of a circuit board, the magnetic field is usually "in" or "out" of the plane, according to the direction of the current, and the electric field usually lies in the circuit's plane, with top-bottom or bottom-top direction (correct me if I am wrong). So according to this the Poynting vector, as their cross-product, can only have a direction that is perpendicular to the plane of the sheet of paper, i.e. the plane the circuit lies in. Is it correct to say, then, that the Poynting's vector direction is the same at every point of the circuit? Intuitively I would expect it to be perpendicular to all sides but I might be wrong. Given an electric circuit that lies on the plane of a sheet of paper, the magnetic field is usually "in" or "out" of the page, according to the direction of the current, and the electric field usually lies in the circuit's plane, with top-bottom or bottom-top direction (correct me if I am wrong). I would caution you on this. It isn’t entirely wrong, but it is a pretty big approximation and simplification. So take all of the subsequent comments in that light. This is very approximate average overall behavior. For simplicity let’s assume a single loop planar circuit with a battery on the left and a resistor on the right with the positive terminal of the battery at the top and the negative terminal at the bottom. The current will form a clockwise loop and the magnetic field of that loop will be pointing into the plane. The electric field will point in the plane from the top (positive) towards the bottom (negative). Now, the energy flux is $\vec S = \vec E \times \vec H$ so with $\vec E$ pointing down and $\vec H$ pointing into the plane that means that $\vec S$ points in the plane to the right. In other words, energy flows from the battery on the left to the resistor on the right, as we would expect.
{ "domain": "physics.stackexchange", "id": 75624, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "electromagnetism, magnetic-fields, electric-fields, poynting-vector", "url": null }
c++, beginner, programming-challenge, array, time-limit-exceeded You are checking whether reading from std::cin succeeded, which is great! However, if you really want to be correct, you might also want to check that writing to std::cout also succeeded, and if not return EXIT_FAILURE. This is especially important for programs that are running unattended, or are part of a pipeline, as the output might not be visible, and the exit code is the only thing able to signal that things went wrong. Make it more generic Your code works only on std::vector<int>. It would be nice to have a function that can rotate arbitrary containers. It might be good practice to try to implement std::rotate() yourself, and make it work not only for random access containers like std::vector, but also for things like std::list.
{ "domain": "codereview.stackexchange", "id": 43040, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c++, beginner, programming-challenge, array, time-limit-exceeded", "url": null }
control-problem, mythology-of-ai, neo-luddism, ai-takeover Title: Will robots rebel against their human creators? There are several science fiction movies where the robots rebel against their creators: for example, the Terminator's series or I Robot. In the future, is it possible that robots will rebel against their human creators (like in the mentioned movies)? I don't like to be a killjoy, but this question seems premature (that's why it's hd the "mythology of AI" tag added to it). The kinds of emergent artificial general intelligence depicted in the movies you mention are in science fiction films because they are science fiction. Most AI researchers do not think they are likely to appear anytime soon. The overwhelming majority of researchers think the most likely times for such a system to appear are "More than 50 years [from now]" or "Never". In part, this is because AI researchers thought we were close to such systems for several decades, despite failing to create them. This suggests that making an artificial general intelligence is much harder than we might expect. Despite AGI being a long show, there's a lot of recent interest in the AI research community in the social impact of our technologies. The study of these systems is called "ethical AI", and this is the path that the research community as a whole has begun to embark on. A promising approach is to model the process by which humans decide to treat each other well, in the hopes of creating programs act according to that process.
{ "domain": "ai.stackexchange", "id": 1091, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "control-problem, mythology-of-ai, neo-luddism, ai-takeover", "url": null }
python, beginner, python-3.x Title: Automate the Boring Stuff Chapter 8 Sandwich Maker I am currently learning Python by working my way through Automate the Boring Stuff with Python. This project is from Chapter 8 which is focused on validating input by using the PyInputPlus module. Whenever I finish, I like to look the problem up and compare to other's solutions to see what I could have done better. However, I can only find a couple of links to this problem. Here is the problem: Sandwich Maker Write a program that asks users for their sandwich preferences. The program should use PyInputPlus to ensure that they enter valid input, such as: Using inputMenu() for a bread type: wheat, white, or sourdough. Using inputMenu() for a protein type: chicken, turkey, ham, or tofu. Using inputYesNo() to ask if they want cheese. If so, using inputMenu() to ask for a cheese type: cheddar, Swiss, or mozzarella. Using inputYesNo() to ask if they want mayo, mustard, lettuce, or tomato. Using inputInt() to ask how many sandwiches they want. Make sure this number is 1 or more. Come up with prices for each of these options, and have your program display a total cost after the user enters their selection. That being said, I'd like to hear what I can do better and how I can improve this code: import pyinputplus as pyip # store a dictionary of ingredients and their respective prices optionPrices = {'white' : 2.00, 'wheat' : 2.50, 'sour dough' : 3.00, 'chicken' : 2.50, 'turkey' : 2.25, 'ham' : 1.75, 'tofu' : 4.00, 'cheddar' : 1.00, 'swiss' : 1.25, 'mozzarella' : 2.00, 'mayo' : 0.25, 'mustard' : 0.25, 'lettuce' : 0.30, 'tomato' : 0.50 } customerOrder = [] # a list to store the current order extras = ['mayo', 'mustard', 'lettuce', 'tomato'] sandwichTotal = 0.0
{ "domain": "codereview.stackexchange", "id": 40523, "lm_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, python-3.x", "url": null }
c++, linked-list template <class T> DoubleLinkedLists<T>::DoubleLinkedLists(DoubleLinkedLists const& value) : head(nullptr), tail(nullptr) { for(Node* loop = value->head; loop != nullptr; loop = loop->next) { createNode(loop->data); } } template <class T> DoubleLinkedLists<T>::DoubleLinkedLists(DoubleLinkedLists<T>&& move) noexcept : head(nullptr), tail(nullptr) { move.swap(*this); } template <class T> DoubleLinkedLists<T>& DoubleLinkedLists<T>::operator=(DoubleLinkedLists<T> &&move) noexcept { move.swap(*this); return *this; } template <class T> DoubleLinkedLists<T>::~DoubleLinkedLists() { while(head != nullptr) { deleteHead(); } } template <class T> DoubleLinkedLists<T>& DoubleLinkedLists<T>::operator=(DoubleLinkedLists const& rhs) { DoubleLinkedLists copy(rhs); swap(copy); return *this; } template <class T> void DoubleLinkedLists<T>::swap(DoubleLinkedLists<T>& other) noexcept { using std::swap; swap(head, other.head); swap(tail, other.tail); } template <class T> void DoubleLinkedLists<T>::createNode(const T& theData) { Node* newData = new Node; newData->data = theData; newData->next = nullptr; if(head == nullptr) { newData->previous = nullptr; head = newData; tail = newData; } else { newData->previous = tail; tail->next = newData; tail = newData; } }
{ "domain": "codereview.stackexchange", "id": 30922, "lm_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++, linked-list", "url": null }
newtonian-mechanics, energy-conservation, conservation-laws, spring In solving this problem, an apparent paradox appears. Because the block-spring system and the ball have the same mass, and because the ball is at rest after the interaction, momentum conservation implies that the final velocity of the block should equal the initial velocity of the ball. This would imply that the final kinetic energy of the block is the same as the initial kinetic energy of the ball. But then there can be no potential energy stored in the spring, even though it has been compressed. Obviously such a setup is impossible because of the massless spring and the lack of energy dissipation. However, these assumptions are fairly standard in physics, so one would not expect them to lead to a contradiction. Also, I am aware of the principle that an idealized ratchet-like mechanism cannot exist because it could be used to violate the second law of thermodynamics. I understand that argument, but the problem here is not a violation of the second law, but rather a contradiction of energy and momentum conservation. Which of the premises of the problem is responsible for this contradiction, and why? If the spring locks when the ball is at rest in the lab frame, then by the arguments you give it follows that the spring must not be compressed at all. This is indeed the case. As the ball slows down, the block begins to speed up. Eventually they are traveling at the same speed, at which point the spring has reached its maximum compression. As the spring begins to expand, the block's velocity becomes greater than that of the ball. When the spring attains its uncompressed length, the ball comes to rest and the block is traveling with speed $v$.
{ "domain": "physics.stackexchange", "id": 72177, "lm_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, energy-conservation, conservation-laws, spring", "url": null }
example of the cycle graph which is connected As in above graph a vertex 1 is unreachable from all vertex, so simple BFS wouldn’t work for it. generate link and share the link here. A graph represents data as a network.Two major components in a graph are … By using our site, you So, for above graph simple BFS will work. Cut Points or Cut Vertices: Consider a graph G=(V, E). The meta-lesson is that teachers can also make mistakes, or worse, be lazy and copy things from a website. Proof: We prove this theorem by the principle of Mathematical Induction. A subgraph of a graph is another graph that can be seen within it; i.e. Answer Save. Report LA-3775. In graph theory, the degreeof a vertex is the number of connections it has. Weisstein, Eric W. "Disconnected Graph." Components of a Graph : The connected subgraphs of a graph G are called components of the.' Does such a graph even exist? Draw the following: a. K. b. a 2-regular simple graph c. simple graph with v = 5 & e = 3 011 GLIO CL d. simple disconnected graph with 6… Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. Definition 1.1.2. If the graph is disconnected, it’s called a forest. https://mathworld.wolfram.com/DisconnectedGraph.html. ? The complement of a simple disconnected graph must be connected. If G is disconnected, then its complement is connected. Join the initiative for modernizing math education. Disconnected Graph. Answer to G is a simple disconnected graph with four vertices. The complement of a graph G = (V,E) is the graph (V,{{x,y} : x,y ∈ V,x 6= y}\E). K 3 b. a 2-regular simple graph c. simple graph with ν = 5 & ε = 3 d. simple disconnected graph with 6 vertices e. graph that is not simple. A forest is a set of components, where each component forms a tree itself. A graph in which there does not exist any path between at least one pair of vertices is called as a disconnected graph. A graph is disconnected if at least two vertices of the graph are not connected by a
{ "domain": "forfur.com", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9566341999997378, "lm_q1q2_score": 0.8072989219496426, "lm_q2_score": 0.8438951084436077, "openwebmath_perplexity": 656.0075029038798, "openwebmath_score": 0.5356816053390503, "tags": null, "url": "https://www.forfur.com/when-do-kihjjvj/57280c-simple-disconnected-graph" }
The answer of @Jesus RS is brilliant! It shows the more important point of the problem: $C$ does not have to be connected. If we have a closed subspace $C$ of $\mathbb{R}^2$ and a continuos and bijective function $g:C\to\mathbb{R}^2\setminus\{p\}$, where $p\in\mathbb{R}^2$, then we just have to consider a point in the complement of $C$, say $q$, and the function $$f:C\cup\{q\}\to\mathbb{R}^2$$ $$f(z)= \begin{cases} &g(z)&,&x\neq q\\ &p&,&x=q \end{cases}$$ will be continuous and bijective, but is not open because $\{q\}$ is open in $C\cup\{q\}$ but $f(\{q\})=\{p\}$ is not open in $\mathbb{R}^2$. Now it is very easy to show an explicit function satisfying these conditions. The function $f:\big([0,+\infty)\times\mathbb{R}\big)\cup\{(-1,0)\}\to\mathbb{R}^2$ defined by $$f(x,y)= \begin{cases} &\bigg(e^y\cos\big(\frac{2\pi x}{x+1}\big),e^y\sin\big(\frac{2\pi x}{x+1}\big)\bigg)&,&(x,y)\neq (-1,0)\\ &(0,0)&,&(x,y)=(-1,0) \end{cases}$$ is continuous, bijective and not open, where the domain is a closed subspace of $\mathbb{R}^2$.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9783846628255123, "lm_q1q2_score": 0.8335375512193229, "lm_q2_score": 0.8519527982093666, "openwebmath_perplexity": 168.15719546406524, "openwebmath_score": 0.9223070740699768, "tags": null, "url": "https://math.stackexchange.com/questions/1208457/find-fc-to-mathbbr2-continuous-and-bijective-but-not-open-c-subset-mathb" }
joint, action, state, ros-industrial, robot 11000 11002 Why and how to use those, like what should be used to receive or send on which node? Originally posted by RosBort on ROS Answers with karma: 27 on 2014-11-25 Post score: 0 First: there aren't necessarily really any ports that you need to use. simple_message was meant to be usable on top of different transports / protocols, so it doesn't really make sense to specify a TCP port that should always be used. However, if you want to re-use the nodes that the industrial_robot_client package provides, then you are expected to be using certain TCP ports in your controller-specific driver (in the general case). You can find which ports are used for what in the simple_message api docs, which are accessible through the ROS wiki page for simple_message. A quote from the linked API doc page: Enumeration of standard socket ports (supported by all platforms). These are defined for convenience. Other ports may be used. Additional ports for application specific needs may also be defined. enum StandardSocketPort { MOTION = 11000, SYSTEM = 11001, STATE = 11002, IO = 11003 }
{ "domain": "robotics.stackexchange", "id": 20152, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "joint, action, state, ros-industrial, robot", "url": null }
co.combinatorics, permutations, asymptotics Title: Shortest Common Supersequence of Permutations For integers $k$ and $n$, let $P_{k,n}$ be the set of all size-$k$ sets of permutations of $[n]$. The Shortest Common Supersequence for Permutations (SCSP) problem is: given a set $S\in P_{k,n}$, return a shortest string $s$ over the alphabet $[n]$ such that each $s_i\in S$ can be obtained by removing symbols from $s$.
{ "domain": "cstheory.stackexchange", "id": 5662, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "co.combinatorics, permutations, asymptotics", "url": null }
c++, algorithm, security, cryptography, aes return state; } Note that I take the argument by value, not by const&, because we’re making a copy anyway. You could also take it by const& as you do, then copy it into result, again, as you do; that’s fine, nothing wrong with that at all. The un-shift functions are basically identical, so I’ll skip ’em. auto mixColumn(const array<int,4>& stateColumn){ //Function takes a column of the state and 'mixes' it according to the matrix multiplication defined in FIPS 197 array<int,4> result = {}; result[0] = multiply_by_2(stateColumn[0]) ^ multiply_by_3(stateColumn[1]) ^ stateColumn[2] ^ stateColumn[3]; result[1] = multiply_by_2(stateColumn[1]) ^ multiply_by_3(stateColumn[2]) ^ stateColumn[3] ^ stateColumn[0]; result[2] = multiply_by_2(stateColumn[2]) ^ multiply_by_3(stateColumn[3]) ^ stateColumn[0] ^ stateColumn[1]; result[3] = multiply_by_2(stateColumn[3]) ^ multiply_by_3(stateColumn[0]) ^ stateColumn[1] ^ stateColumn[2]; return result; }
{ "domain": "codereview.stackexchange", "id": 43329, "lm_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, security, cryptography, aes", "url": null }
frequency-spectrum, frequency, amplitude The last figure shows the last 20 seconds of the previous figure's results (same colors for the respective outputs). The final value (at t = 500 s) of the long term average (red trace) was 6.22 mV and the final value of the N = 1200 point running integration (green trace) was 6.39 mV. Note in the last figure that the noisy sinewave is at 0.5 Hz, i.e., the difference frequency between the 12.5 Hz squarewave reference frequency and the 12 Hz interfering sinewave. The sum frequency, at 24.5 Hz, was largely attenuated by the RC LPF, since the -3dB frequency was roughly 0.016 Hz Note added: The product of the 12.5 Hz signal sinewave and 12.5 Hz reference squarewave generates a sum frequency of 25 Hz (largely attenuated by the RC LPF) and 0 Hz, i.e., DC. The RC LPF passes that without attenuation. Also, it is easy to replace the simple RC LPF with a higher order low pass filter having steeper roll-off. This was not necessary in this simple example, but if the interfering sinewave had been closer to the signal sinewave, or if the interfering sinewave had some frequency jitter, then a better LPF would be needed.
{ "domain": "dsp.stackexchange", "id": 7532, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "frequency-spectrum, frequency, amplitude", "url": null }
algorithm, go, fibonacci-sequence // Analytic (Binet's formula) func fibonacciBinet(num int) int { var n float64 = float64(num); return int( ((math.Pow(((1 + math.Sqrt(5)) / 2), n) - math.Pow(1 - ((1 + math.Sqrt(5)) / 2), n)) / math.Sqrt(5)) + 0.5 ) } For tailHelper(), the term == 1 case is superfluous and should be eliminated. In fibonacciBinet(), the quantity \$\frac{1 + \sqrt{5}}{2}\$ appears twice. Since that quantity is known as the Golden Ratio, I would define an intermediate value var phi = (1 + math.Sqrt(5)) / 2; However, none of these four solutions is particularly idiomatic for Go. The most expressive way to write a Fibonacci sequence in Go is as an iterator, such as this one.
{ "domain": "codereview.stackexchange", "id": 7242, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "algorithm, go, fibonacci-sequence", "url": null }
the-moon, solar-flare, dust Title: Any new info about solar flares hitting the Moon added by the LADEE mission? This article from 2011 mentions simulations about the sputtering effect caused by a solar flare hitting the Moon: "We found that when this massive cloud of plasma strikes the moon, it acts like a sandblaster and easily removes volatile material from the surface," said William Farrell, DREAM team lead at NASA Goddard. "The model predicts 100 to 200 tons of lunar material – the equivalent of 10 dump truck loads – could be stripped off the lunar surface during the typical 2-day passage of a CME." The researchers said they were waiting for LADEE to confirm these simulations and add new data, but I didn't find any conclusions on this subject on the mission website. I was interested if this event can create a significant static electricity difference between the 2 sides of the Moon, causing some sort of lightnings on the edges or even a mini-version of a dust storm. You'd probably be most interested in the results of the Lunar Dust EXperiment (LDEX). A 2015 paper states LDEX data show no evidence for an electrostaticallylofted dust component at densities greater than a few per m3 I am assuming the solar flare stuff didn't pan out, otherwise it would be mentioned in the various LDEX summary papers. In addition, the NASA DREAM group site doesn't seem to have anything relevant LADEE results, and they're the ones that brought the subject up in the first place.
{ "domain": "astronomy.stackexchange", "id": 1205, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "the-moon, solar-flare, dust", "url": null }
rosdep, joint-state-publisher Title: rosdep won't install joint_state_publisher $ rosdep install joint_state_publisher ERROR: the following packages/stacks could not have their rosdep keys resolved to system dependencies: joint_state_publisher: Unsupported OS [mint] would it help if i moved to ubuntu from mint? else what is the solution? Originally posted by jay75 on ROS Answers with karma: 259 on 2013-08-05 Post score: 1 There seem to be a problem detecting recent mint versions: rospkg mint issue Related: rosdep issues containing 'mint' Originally posted by felix k with karma: 1650 on 2013-08-05 This answer was ACCEPTED on the original site Post score: 1
{ "domain": "robotics.stackexchange", "id": 15181, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "rosdep, joint-state-publisher", "url": null }
and (−2)({x}^{4}−4{x}^{3}+5{x}^{2}−x−2)+8(2{x}^{4}−3{x}^{3}−6{x}^{2}+6x+4) = 14{x}^{4}−16{x}^{3}−58{x}^{2}+50x+36 and each of these polynomials must be in W since it is closed under addition and scalar multiplication. But you might check for yourself that both of these polynomials have x = 2 as a root. I can tell you that y = 3{x}^{4} − 7{x}^{3} − {x}^{2} + 7x − 2 is not in U, but would you believe me? A first check shows that y does have x = 2 as a root, but that only shows that y ∈ W. What does y have to do to gain membership in U = \left \langle S\right \rangle ? It must be a linear combination of the vectors in S, {x}^{4} − 4{x}^{3} + 5{x}^{2} − x − 2 and 2{x}^{4} − 3{x}^{3} − 6{x}^{2} + 6x + 4. So let’s suppose that y is such a linear combination,
{ "domain": "ups.edu", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9912886163143679, "lm_q1q2_score": 0.8081306774443168, "lm_q2_score": 0.8152324803738429, "openwebmath_perplexity": 1830.3624001576297, "openwebmath_score": 0.9782329797744751, "tags": null, "url": "http://linear.ups.edu/jsmath/0230/fcla-jsmath-2.30li38.html" }
navigation, move-base /* Select now the next Waypoint */ counter++; } while( counter < MAX_NUMBER_WAYPOINT ); I "heard" on the topic /move_base/goal and /odom and the robot reaches the pose and orientation sent to the drivers. Since removing the client server and implementing a "manual" routine, which sends the goals comparing the actual and planned position, works everything. That means that the server or client of /move_base stucks somewhere, but I don't know what can I do to find where. Any help? UPDATE #1: I tried to see at the output of /move_base/feedback and /move_base/goal. As you can see there no difference: /move_base/goal goal: target_pose: header: seq: 0 stamp: secs: 1413827513 nsecs: 677924498 frame_id: map pose: position: x: 7.08270146189 y: -2.97619508848 z: 2.37645603035 orientation: x: 0.0 y: 0.0 z: 0.748654179258 w: 0.662960722727 and here rostopic echo /move_base/feedback status: 1 text: This goal has been accepted by the simple action server feedback: base_position: header: seq: 0 stamp: secs: 1413827562 nsecs: 543686202 frame_id: map pose: position: x: 7.08269246838 y: -2.97619141834 z: 2.37645603031 orientation: x: 5.69693569291e-08 y: 1.81862260271e-08 z: 0.748654179258 w: 0.662960722727
{ "domain": "robotics.stackexchange", "id": 19772, "lm_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, move-base", "url": null }
Note that not every partially ordered set has well-defined suprema and infima - this kind of poset is called a lattice. For a sequence of real numbers, the definition of limit superior is $${\limsup} \,\{a_n\}_n = \lim_{n \rightarrow \infty} \sup_{m \geq n} a_m.$$ The notation $\lim_{n \rightarrow \infty} A_n$ doesn't make sense for a sequence $\{A_n\}_n$ of sets. But observe that if $B_n = \bigcup_m A_{m \geq n}$ then $B_n$ is a nested sequence: $B_{n+1} \subseteq B_n$, since $B_{n+1}$ is the union over a smaller set of indices. Since $B_n$ is getting smaller and smaller, we might define the "limit" of $B_n$ to be small: the set of $x$ so contained in every $B_n$, or $\cap_n B_n$. Putting this together, a reasonable analog for the $\lim \sup$ of a sequence of real numbers applied to sets is $$\limsup A_n := \bigcap_{n=1}^\infty \bigcup_{m =n}^\infty A_m.$$ Taking apart this definition, we see that $x \in \lim \sup A_n$ if and only if for all $n \in \mathbb{N}$ there exists $m \geq n$ so that $x \in A_m$: $$\forall n \in \mathbb{N}\, \exists m \in \mathbb{N} \,m \geq n \text{ and } x \in A_m.$$
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.971992482639258, "lm_q1q2_score": 0.8035576470709659, "lm_q2_score": 0.8267117919359419, "openwebmath_perplexity": 138.40111892116903, "openwebmath_score": 0.9554848074913025, "tags": null, "url": "http://math.stackexchange.com/questions/222192/what-does-the-supremum-of-a-sequence-of-sets-represent" }
c, linux, http, socket, server #include <errno.h> #include <sys/stat.h> #include <fcntl.h> #include <netinet/tcp.h> #include <time.h> #define PORT 80 void accept1(int server_fd,struct sockaddr_in address,int addrlen); struct connection { int *new_socket; int type; struct sockaddr_in address; char *request_line; int request_line_size; int server_fd; }; struct lh { int adid; char title[250]; float price; char city[75]; char state[125]; char country[125]; }; void *handle_request(void *arg); void *process(void *p); int handle_process(struct connection *con_obj,char **path,char **request_type); int get_dirs_file( char *path,char *file); int respond_main(struct connection *con_obj,int response_type); ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count); //request type #define TYPE_MAIN 2 #define TYPE_CSS 3 #define TYPE_QUERY 4 //reply type #define RESPONSE_MAIN_HTML 2 #define RESPONSE_MAIN_CSS 3 #define RESPONSE_MIAN_QUERY 4 // #define BUF_SIZE 20000 #define SEEK_SET 0 #define SEEK_CUR 1 #define SEEK_END 2 //HTTP RESPONSE #define HTTP_OK_200 200 #endif makefile HEADERS = headers/ lh: accept.o server.o process.o file.o listhell.o cc -g -pthread -o lh accept.o server.o process.o file.o listhell.o listhell.o: $(HEADERS)accept.h listhell.c cc -g -c -pthread listhell.c process.o : $(HEADERS)accept.h process.c cc -g -c -pthread process.c
{ "domain": "codereview.stackexchange", "id": 42215, "lm_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, linux, http, socket, server", "url": null }
with D as above. Hence Theorem (p.37, 2.16 = integrality condition) f and g are nonnegative integers. Example (see exercise 10, page 46): a Moore graph (of girth 5) is strongly regular with parameters (k^2+1, k, 0, 1). So Type I iff k=2 (seen already), and otherwise D = (0-1)^2 + 4(k-1) = 4k-3 is a square, necessarily odd so 4k-3=(2m+1)^2 and k=m^2+m+1 for some m>1. m=1 and m=2 yield k=3 (Petersen) and k=7 (Hoffman-Singleton) respectively. Any m is allowed by rationality, but integrality limits us to m=1,2,7 so k=3, 7, or 57. Here the numerator n - 1 + ((n-1)(μ-λ) - 2k) is k^2 - 2k = (m^2+m+1)(m^2+m-1), while sqrt(D) = 2m+1, so we need 2m + 1 | (m^2+m+1)(m^2+m-1). We've already seen the technique: write the RHS as a multiple of the LHS plus a remainder, which is a constant of which 2m+1 must be a factor. Trouble is the remainder here is -15/16 (the value at the root m=-1/2). OK, but if we multiply the RHS by 16 then it's still a multiple, and then 16(m^2+m+1)(m^2+m-1) = (8m^3+12m^2+2m-1) (2m+1) - 15
{ "domain": "harvard.edu", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9907319853876677, "lm_q1q2_score": 0.8277402594148112, "lm_q2_score": 0.8354835330070839, "openwebmath_perplexity": 2557.5821634393883, "openwebmath_score": 0.8611697554588318, "tags": null, "url": "http://abel.math.harvard.edu/~elkies/M155.15/notes.html" }
• As it turns out, you could also use FunctionExpand[DifferenceRoot[(* stuff *)][n]] to derive explicit expressions for $k$-nacci numbers. – J. M. is away Oct 10 '15 at 16:50 Tribonacci[0] := 0; Tribonacci[1] := 1; Tribonacci[2] := 1; Tribonacci[3] := 2; Tribonacci[n_] := Tribonacci[n] = Tribonacci[n - 1] + Tribonacci[n - 2] + Tribonacci[n - 3]; Array[Tribonacci, 9] (* {1, 1, 2, 4, 7, 13, 24, 44, 81} *) An alternate expression can be found in https://oeis.org/A000073: CoefficientList[Series[x^2/(1 - x - x^2 - x^3), {x, 0, 50}], x] Also you can find more information about: Tribonacci[n] - Fibonacci[n], in: https://oeis.org/A000100 Even more... a = (19 + 3*Sqrt[33])^(1/3); b = (19 - 3*Sqrt[33])^(1/3); Trib[n_] := Round[3*((a + b + 1)/3)^(n + 1)/(a^2 + b^2 + 4)] Table[Trib[n] - Tribonacci[n], {n, 1, 20}] (* {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} *) tribonacci[n_] := SequenceFold[Plus, {1, 1, 2}, ConstantArray[0, n - 3]] tribonacci[1] = tribonacci[2] = 1; Array[tribonacci, 9]
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.971992476960077, "lm_q1q2_score": 0.8392101410233833, "lm_q2_score": 0.8633916011860785, "openwebmath_perplexity": 1824.4722821558005, "openwebmath_score": 0.2697817087173462, "tags": null, "url": "https://mathematica.stackexchange.com/questions/96654/how-can-i-make-a-tribonacci-sequence-in-the-form-of-a-list/96689" }
machine-learning, scikit-learn Title: Using machine learning specifically for feature analysis, not predictions I'm new to machine learning and have spent the last couple months having a blast using Sci-Kit Learn to try to understand the basics of building feature sets and predictive models. Now I'm trying to use ML on a data set not to predict future values but to understand the importance and direction (positive or negative) of each feature. My features (X) are boolean and integer values that describe a product. My target (y) is the sales of the product. I have ~15,000 observations with 16 features a piece. With my limited ML knowledge to this point, I'm confident that I can predict (with some level of accuracy) a new y based on a new set of features X. However I'm struggling to coherently identify, report on and present the importance and direction of each feature that makes up X. Thus far, I've taken a two-step approach: Use a linear regression to observe coefficients Use a random forest to observe feature importance The code First, I try to get the directional impact of each feature: from sklearn import linear_model linreg = linear_model.LinearRegression() linreg.fit(X, y) coef = linreg.coef_ ... Second, I try to get the importance of each feature: from sklearn import ensemble forest = ensemble.RandomForestRegressor() forest.fit(X, y) importance = forest.feature_importances_ ...
{ "domain": "datascience.stackexchange", "id": 10518, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "machine-learning, scikit-learn", "url": null }
algorithms, dynamic-programming Its order is $O(NP^2)$. There is an $O(NP)$ solution for it. How can I enhance my solution to reach it? Further updates might come to reformat the solution in a mathematical notation. Source: Tehran University, Fall 2018, Advanced algorithms practice A very nice question. Here is the brief idea of a more efficient algorithm. The central idea is how to fill one package and close it with minimal unfilled capacity left. That is a standard knapsack problem that can done efficiently with dynamic programming. However, now we have two packages available, each might have different initial capacities available, as you have pointed out. What to do? Then do two knapsack problems at the same time! Right after you have closed one package, you have two packages, one with $a_1$ available capacity and the other with $a_2$ available capacity. We have two knapsack problems here: how to fill the one with $a_1$ capacity as much as possible without bursting the other one and how to fill the one with $a_2$ capacity as much as possible without bursting the other one. Solve them separately. Compare the result to find which one get less free capacity left. Choose that package and its maximal filling found just now and close it. Fill the other one with the items that should have been used before closing the previous one. Repeat the process. (Further update might come to clarify the above explanation. But this should get you going.)
{ "domain": "cs.stackexchange", "id": 12432, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "algorithms, dynamic-programming", "url": null }
c++, game, console, makefile void draw_slash_bracket_style(const Disk d) { cout << '['; int j = 2 * d.size() + 1; if(d.size() >= 10 && d.size() <= 99) j--; for(int i = 0; i < j; i++) { if(i == (2 * d.size() + 1) / 2) cout << d.size(); else if(i == ((2 * d.size() + 1) / 2) - 1) cout << ' '; else if(i == ((2 * d.size() + 1) / 2) + 1) cout << ' '; else cout << '/'; } cout << ']'; } Tower.h #pragma once #include "Disk.h" #include <vector> class Tower { public: Tower(); Tower(size_t num_disks); size_t num_disks() const; int size_of_top() const; int size_of_largest_disk() const; int size_of_disk_at(size_t place) const; bool is_diskless() const; bool are_strictly_decreasing() const; const Disk& disk_at(size_t index) const; void top_to_top(Tower& dest_tower); bool compare(const Tower&) const; private: std::vector<Disk> disks_; }; size_t highestTower(const std::vector<Tower>& towers); Tower.cpp #include "Tower.h" #include "Disk.h" #include <cassert> #include <iostream> using namespace std; Tower::Tower() { } Tower::Tower(size_t num_disks) { assert(num_disks >= 0); for(int i = num_disks; i > 0; i--) { disks_.push_back(Disk(i)); } }
{ "domain": "codereview.stackexchange", "id": 44337, "lm_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, console, makefile", "url": null }
experimental-physics, nuclear-physics, neutrons, accelerator-physics \end{alignat}} $$ which is close to what I've been told is the relativistic limit for a cyclotron (I think on the lower side of the limit, but can't remember). However, even if it's on the wrong side of that limit: a heavy element like mercury can be multiply-ionised, and even fully ionising mercury requires far less energy than accelerating it to that speed, so even a linac with that design could be 20 times shorter. If spallation works like that. I'm mainly thinking of this in terms of a spacecraft powered by an accelerator-driven subcritical reactor, and reducing the linac length from 335 m to 16.75 m seems like a significant improvement for such a task. [My physics level is {UK: AS-level equivalent, USA: probably highschool, I'm not sure}; my maths level is {UK: double-A2-level, USA: probably between freshman and somophore year at university, but I'm not sure}, please target answers at that sort of level] First, you have to analyze the collision in the center-of-momentum reference frame. Since the mercury nucleus is eighty times more massive than the proton, simply swapping the kinetic energies doesn't give you the same interaction. This is a famous introductory physics problem that I'll let you think about on your own. Furthermore, in spallation on heavy-metal targets, the typical neutron yield is twenty or thirty neutrons for each proton entering the target. That suggests that, when the proton beam interacts with the metal target, each proton interacts with perhaps ten of the metal nuclei. If you were to accelerate the mercury nuclei, you would lose this advantage: you'd have to send each mercury nucleus into the hydrogen target with enough energy to drive the spallation reaction, and any secondary reaction would be between fast mercury fragments and protons at rest rather than between a still-fast proton and another intact mercury nucleus. You might be interested to know that the spallation source at PSI, which like the SNS is a one-megawatt machine, is driven by a half-GeV cyclotron. For beam-based space propulsion, you might read about ion drives.
{ "domain": "physics.stackexchange", "id": 49673, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "experimental-physics, nuclear-physics, neutrons, accelerator-physics", "url": null }
javascript, css, html5, angular.js, graphics function newTweakColor(aColor, aDiff) { var hsv = aColor.toHSV(); var vAdj = (aDiff / 128) * (hsv.v - 0.5); return (new HSVColor(hsv.h, hsv.s, hsv.v - vAdj)).toRGB(); } fieldset { display: inline-block; width: 25%; } fieldset#tweak { display: block; width: 100%; border-width: 0; } label { display: block; } .swatch { border: 1px solid grey; width: 100%; height: 1em; } input[type=range] { width: 40%; } <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app> <form ng-controller="ColorTweakerCtrl"> <fieldset id="tweak"> <label>Diff <input ng-model="diff" type="range" min="0" max="255" ng-change="tweak()"> <input ng-model="diff" type="number" min="0" max="255" ng-change="tweak()"> </label> </fieldset> <fieldset> <legend>Input Color</legend> <div class="swatch" style="background-color: {{ inColor.toString() }}"></div> <label>R <input ng-model="inColor.r" type="range" min="0" max="255" ng-change="tweak()"> <input ng-model="inColor.r" type="number" min="0" max="255" ng-change="tweak()"> </label> <label>G
{ "domain": "codereview.stackexchange", "id": 10897, "lm_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, css, html5, angular.js, graphics", "url": null }
ros, moveit, planning-scene Title: Assimp and RViz will not import .scene file I am trying to load a collision object into my hydraulic arm's planning scene, but it doesn't work with the pillar example provided for the baxter robot: [ WARN] [1412647012.600856139]: Assimp reports no scene in file:///home/controller/Downloads/baxter_pillar.scene There is a box.stl from the MoveIt! tutorial example that loads perfectly well. Why is Assimp not loading these text scene files? All I want to do is have a cylinder that my robot is not allowed to collide with when executing a path. Kind Regards Bart Originally posted by bjem85 on ROS Answers with karma: 163 on 2014-10-06 Post score: 0 I think Assimp is only capable of loading 3D models in a number of 'standardised' formats (stl, obj, etc). I doubt .scene is one of those. From the tutorial you linked (section "Introducing an environment representation for planning", emphasis mine): We will now create a scene object in a text file to be imported into our environment. and: You can now import this scene from the Scene Geometry field selecting Import From Text Are you sure you clicked the Import from text button in the MoveIt RViz plugin, and not Import File? Originally posted by gvdhoorn with karma: 86574 on 2014-10-07 This answer was ACCEPTED on the original site Post score: 1 Original comments Comment by bjem85 on 2014-10-12: That was it. Out of interest how come there are two ways of importing the files? Comment by gvdhoorn on 2014-10-13: There are more, but in this case I'm guessing that there was a need to separate the import of a single mesh, versus a .scene file that may contain an entire world (although I don't think it was meant for that).
{ "domain": "robotics.stackexchange", "id": 19645, "lm_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, moveit, planning-scene", "url": null }
neuroscience, neurophysiology, memory, cognition Title: What are the advantages of forgetting? How forgetting things is helpful for the brain or the human body biologically? This web page After some moment of being rude, selfish, or weak, either we are able to put it behind us, or the person who suffered at the result of our imperfection moves on. The reason for this is our ability to forget about it. We forget not because we have an imperfect hippocampus (our brain’s memory organ); it's actually an evolved solution. The ability to lose information allows new information to come in that is more relevant, more pertinent to an ongoing reality. Forgetting allows us to update. and this Huffington post article According to a study in Nature, our awareness is limited to only three or four objects at any given time. To be able to think at your highest level, you therefore must be very efficient at filtering out all of the background noise: Your racing thoughts, the ringing phone, your neighbor’s barking dog, and the list goes on. The Nature study found that when participants were asked to “hold in mind” certain objects while ignoring others, there are significant variations in how well each of us can keep irrelevant objects out of our awareness. The researchers concluded that our memory capacity is therefore not simply about storage space, but rather “how efficiently irrelevant information is excluded from using up vital storage capacity.” provide some backgrounds. Short answer It has been shown that loss of long-term memories may enhance the retrieval of others. Short-term working memory is explicitly designed to be volatile and non-lasting. However, there are many other types of memories where memory loss may not be explicitly beneficial, or even outright debilitating such as in the case of Alzheimer's or stroke. Background First off all, there are many types of memories, including sensory memory, motor memory, short-term (working) memory, long-term memory, explicit & implicit memory, declarative & procedural memory and so on. Hence, because the question is quite broad, I will focus on long-term memory, short term-memory and sensory memory to discuss that memory loss can be beneficial, neutral, or detrimental.
{ "domain": "biology.stackexchange", "id": 6784, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "neuroscience, neurophysiology, memory, cognition", "url": null }
thermodynamics Now let's take heat in consideration. A similar expression may be written: $W_{ext}+Q=\Delta E_{system}=\Delta\left(\frac{1}{2}m_tv_{cm}^2\right)+\Delta\mathcal{U}$, but comparing it with the first law of thermodynamics, there is an extra term, $\Delta\left(\frac{1}{2}m_tv_{cm}^2\right)$, because, as far as I know, the first law of thermodynamics is formulated as $W_{ext}+Q=\Delta\mathcal{U}$. My question is why we don't write the term $\Delta\left(\frac{1}{2}m_tv_{cm}^2\right)$ in the first law of thermodynamics? Is it that I have misconceptions in some of the concepts used here, or is it that, for example, in thermodynamics we always work in a reference frame moving with the center of mass of the system, making $v_{cm}=0$ always, or what's the issue I'm having here? Thank you. The general form of the first law for a closed system includes the kinetic energy (KE) and potential energy (PE) of its center of mass (COM) with respect to an external frame of reference. I like to call this the system's "external" KE and PE to contrast it with the "internal" molecular KE and PE of the system with respect to the COM reference frame. The total change in system energy is then the sum of its internal and external energy. The figure below is my attempt to illustrate the difference. (Note: only shows gravitational PE as the external PE). Hope this helps.
{ "domain": "physics.stackexchange", "id": 92268, "lm_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 }
calibration, cv-bridge, camera File "/opt/ros/groovy/lib/python2.7/site-packages/cv_bridge/core.py", line 73, in encoding_as_cvtype from cv_bridge.boost.cv_bridge_boost import getCvType ImportError: No module named cv_bridge_boost
{ "domain": "robotics.stackexchange", "id": 14606, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "calibration, cv-bridge, camera", "url": null }
statistics, probability, probability-distribution-function x = pos(1); y = pos(2); % Compute position to display. yper = normcdf(y,0,1); yperexp = normcdf(polyval([slope,yinter],x)); xexp = polyval([1/slope,-yinter/slope],y); % Get the original row number of the selected point. originds = getappdata(target,'originds'); origind = originds(ind); % Get the group number, which is set if more than one. group = getappdata(target,'group'); % Generate text to display. datatipTxt = { sprintf('%s: %s',getString(message('stats:probplot:Data')),num2str(x)),... sprintf('%s: %s',getString(message('stats:probplot:Probability')),num2str(yper)),... '' }; datatipTxt{end+1} = sprintf('%s: %s',... getString(message('stats:probplot:Observation')),num2str(origind)); if ~isempty(group) datatipTxt{end+1} = sprintf('%s: %s',... getString(message('stats:probplot:Group')),num2str(group)); end
{ "domain": "dsp.stackexchange", "id": 8467, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "statistics, probability, probability-distribution-function", "url": null }
time-complexity, binary-search-trees Title: How to find time complexity of this pseudocode Recently, I came across a question about finding sum of all values in range $[low, high]$ in BST $T$. Then I formulated following algorithm to carry out that task: We do inorder traversal of BST ($sum = 0$ in start) But whenever we encounter any node having value strictly less than $low$ than we don't visit it's left subtree. We only traverse it's right subtree recursively in same manner. In same manner if we find any node having value strictly greater than $high$ than we don't traverse it's right subtree. If value of node falls in given range then we increment $sum$ by 1. I think this algorithm correctly solve above problem in time complexity $O(m+lg(n))$ where $m$ is number of nodes having value in given range. My reasoning for that time complexity is that we traverse at most $O(lg(n))$ nodes(This statement I'm not able to prove) which don't get added and we traverse $m$ nodes that gets added into $sum$. Which gives above time complexity. At least any hint regarding how to prove this time complexity would be great. Thanks. It sounds like your pseudocode is equivalent to the following: Do search for low in the BST. Find this value or the next largest value. (assuming that the BST is somewhat balanced, this is $O(lg(n))$) In-order traverse until we reach an element that is greater than high, adding all values that we traverse to some running sum. (in order traversal of $m$ elements in a BST is time $O(m)$ since each element is visited at most twice.) The running sum gives us our answer. The total runtime of this is $O(lg(n) + m)$ This is equivalent to what you write in your psuedocode I believe. The ignoring of subtrees that are not in the range of interest is what is done in a search. Hope this helps!
{ "domain": "cs.stackexchange", "id": 15219, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "time-complexity, binary-search-trees", "url": null }
java, error-handling, exception private void executarLoopDeExecucaoDeSequenciasDeComandos() throws DeveDerrubarOProcessoException, RuntimeException { while (true) { try { JSONObject jsonComando = aguardarProximaSequenciaDeComandos(); Integer idDoComando = jsonComando.getInt("idComando"); try { atualizadorDeStatusDeSequenciasDeComandos.enviarParaFilaStatusDoComando(idDoComando, StatusDeSequenciaDeComandos.EM_EXECUCAO, null); ResultadoDaSequenciaDeComandos resultado = executarSequenciaDeComandos(jsonComando); atualizadorDeStatusDeSequenciasDeComandos.enviarParaFilaStatusDoComando(idDoComando, resultado.getStatus(), resultado.getDescricao()); } catch (JsonSyntaxException e) { atualizadorDeStatusDeSequenciasDeComandos.enviarParaFilaStatusDoComando(idDoComando, StatusDeSequenciaDeComandos.ERRO, "Erro lendo os parâmetros do JSON: " + e.getMessage()); } catch (ViaDeComunicacaoFechadaException | InterruptedException e) { atualizadorDeStatusDeSequenciasDeComandos.enviarParaFilaStatusDoComando(idDoComando, StatusDeSequenciaDeComandos.TIMEOUT, null); break; } catch (DeveDerrubarOProcessoException e) { throw e; } catch (RuntimeException e) { logarComIdDoPainel(e); atualizadorDeStatusDeSequenciasDeComandos.enviarParaFilaStatusDoComando(idDoComando, StatusDeSequenciaDeComandos.ERRO, "Ocorreu um erro ao executar o comando."); }
{ "domain": "codereview.stackexchange", "id": 21006, "lm_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, error-handling, exception", "url": null }
machine-learning, neural-networks The TRAINING process can be very time-intensive, however. The only way I can think of in which the weights affect your training process is with respects to which starting weights you choose. In this case, you could very well have "better" starting weights that result in a faster training process. The way to think of starting weights is like determining your location on a graph. Neural Network training algorithms try to work themselves into a minimum error state, and some weights are "closer" to a minimum than others. Also, some weights might put the training process into a situation where it is more likely to fall into local minima, which could make some starting weights more accurate than others. That said, it's very difficult (not realistic?) to know for any given set of training data what your starting weights should be. You could randomly assign starting weights and train with each set to try and pinpoint the ideal training starting weight, but that weight would only be valid for that one set of training data on that specific neural network (and once you have trained the network, essentially your optimal starting weight IS a finished network). So, ultimately, I'm not sure how useful this information will be for what you're trying to accomplish, but I'm interested in knowing more about what it is you think you might do!
{ "domain": "cs.stackexchange", "id": 4465, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "machine-learning, neural-networks", "url": null }
python, game, python-3.x for i in (1,)])), "remaining.") elif gameState.turnsRemaining == 1: print("Last turn!") else: print("Turn {}, {} turns remaining.".format( gameState.turn, gameState.turnsRemaining)) print(board) s = "Y" while True: inp = input(s + " coordinate: ") try: inp = int(inp) except ValueError: print("Please type a valid number!") continue if s == "Y": s = "X" x = inp continue y = inp if not gameState.disableConfirmations: inp = not getBoolFromInput("Are you sure that you want" + "to aim for {}, {}? ".format( x, y), True) if inp: print("Try again then.") s = "Y" continue break aim = board.updateMark(x, y) if aim == "OUT OF OCEAN": print("That's not even in the ocean...") elif aim == "ALREADY HIT": print("You already hit that one.") elif aim == "NO HIT": print("You didn't hit anything...") else: print("Congratualtions, you hit part of a battleship!") cont = gameState.hitBattleship() if gameState.battleshipsRemaining != 0: cont = gameState.nextTurn() if gameState.turnsRemaining != 0 and \ gameState.battleshipsRemaining != 0: continue else: board.revealBoard() print("\n" + str(board) + "\nThese were the battleships!") playing = False if cont: print("\n\nRestarting...\n\n") continuing = True else: continuing = False if continuing: continue print("Thanks for playing!") if __name__ == "__main__": main()
{ "domain": "codereview.stackexchange", "id": 11361, "lm_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, game, python-3.x", "url": null }
recursion, integer, elixir Title: Extract and divide algorithm implementation in Elixir I just started learning Elixir and stumbled upon this challenge over on Programming Puzzles & Code Golf. It is a well-suited task for beginners, so I chose to give it a go (to be clear, give it a go means solve it normally, not golfing it). To keep this question self-contained, here is the task – citing the linked post: For a given positive integer \$n\$: Repeat the following until \$n < 10\$ (until \$n\$ contains one digit). Extract the last digit. If the extracted digit is even (including 0) multiply the rest of the integer by \$2\$ and add \$1\$ ( \$2n+1\$ ). Then go back to step 1 else move to step 4. Divide the rest of the integer with the extracted digit (integer / digit) and add the remainder (integer % digit), that is your new \$n\$. For example, \$61407\$ gives \$5\$ when ran through this mechanism. I've come up with the following code: defmodule ExtractAndDivide do def extract_and_divide(x) do if x < 10 do x else head = div x, 10 tail = rem x, 10 case rem tail, 2 do 0 -> head * 2 + 1 |> extract_and_divide 1 -> div(head, tail) + rem(head, tail) |> extract_and_divide end end end end I'm seeking general advice, but mainly focusing on the following:
{ "domain": "codereview.stackexchange", "id": 32016, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "recursion, integer, elixir", "url": null }
electromagnetism, electromagnetic-radiation, gauge-theory, gauge Title: Can I call additional conditions on potentials a Gauge choice? Let's say I have an electromagnetics problem in a spatially varying medium. After I impose Maxwell's equations, the Lorenz gauge choice, boundary conditions, and the Sommerfeld radiation condition, I still have more unknowns than equations and the solution for (say) the magnetic vector potential is not uniquely determined by the above. This does actually happen when you formulate the equations in plane-stratified media in the plane-wave / Fourier domain. The way to proceed that I have seen is to choose that one of the cartesian components of the vector potential is zero, i.e. impose one of the following as an additional condition to ensure uniqueness of the potentials: $A_x=0$, $A_y=0$ or $A_z=0$. We could of course make up an infinite number of other conditions that leave the fields invariant. My question is, can I call the above arbitrary choice about the vector potential a "gauge choice"? The reason for imposing it seems to be identical to the reasons we normally impose the Lorenz or Coulomb gauge, namely that the field equations don't dictate anything about certain potential quantities, the choice makes solving the equations uniquely possible, and the physical $\mathbf{E},\mathbf{H}$ fields are invariant to the extra condition on the potentials. Setting $A_z = 0$ is usually called 'axial gauge'. (The choice of the $z$-direction is arbitrary, of course.) This is a perfectly valid gauge condition, and used a lot in QCD. However, I don't think it makes sense in general to simultaneously impose Lorenz gauge and axial gauge. This is too many constraints; you'll kill off physical degrees of freedom. However, in specific situations, it may be that your boundary conditions are actually imposing these constraints, so accidentally imposing them a second time with the gauge condition causes no harm. It's hard to say more without knowing exactly what you're doing. Is it possible that you are missing the secondary constraint implied by the gauge choice?
{ "domain": "physics.stackexchange", "id": 8828, "lm_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, electromagnetic-radiation, gauge-theory, gauge", "url": null }
quantum-mechanics, condensed-matter, superconductivity If we want to deduce flux quantization, the current equation should be integrated in a closed curve around the magnetic flux in which there is no current, equating phase change over the closed curve and the magnectic flux itself by the integral of $\vec{A}$. In order to deduce the second London equation we must assume $\nabla\theta=0$. How can we justify this, considering that phase gradient is fundamental for explaining flux quantizaion? We needed $\nabla\theta$ before and now it is $=0$. What is different in this situation? If we assume London equation is correct in the case of flux quantization, there should be current all around every vortex (for the whole bulk), where there is non-zero vector potential. Why is this reasoning wrong? In a Josephson junction, current is related to phase difference between the two superconductors, again we need $\nabla\theta$, however London equations tell us current should be only related to vector potential $\vec{A}$. How can we make sense of this? The main point here is that the London equation in the form $\vec J(\vec r)=-\frac{\hbar}{m}\rho(\vec r)\vec A(\vec r)$ is not gauge invariant, hence it is valid only in a specific gauge, where you can set an homogeneous electric potential $\nabla\phi(\vec r)=0$. This is possible when you consider a simply connected superconductor domain in a magnetic field, but it is inappropriate when you describe multi-connected domains, like superconducting rings. In the latter case, you have indeed to use the more general expression
{ "domain": "physics.stackexchange", "id": 52549, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "quantum-mechanics, condensed-matter, superconductivity", "url": null }
• I think the proof is okay, I can't find anything wrong. – Anik Bhowmick Aug 8 '18 at 15:51 • probably $n\in \mathbb N$ in the claim – Exodd Aug 8 '18 at 15:51 • @Exodd I have made this change. – Benjamin Aug 8 '18 at 15:52 • @AnikBhowmick I feel a bit uncomfortable with the step where I multiply by $x$, since I (a) feel like I am ignoring the LHS and (b) am not sure how this exactly relies on the fact that P(n) is true. – Benjamin Aug 8 '18 at 15:53 • (a) Since $x>0$, it's completely okay. There is no fact of ignoring the LHS. (b) That's the statement of mathematical induction, right ?? If $P(K+1)$ is true whenever $P(K)$ is true, then $P(n)$ is true $\forall n \in \mathbb N$ !! Where is the ambiguity ?? – Anik Bhowmick Aug 8 '18 at 15:59 In my opinion you should work better out where and how you use the inductive claim (I. C.). $x^{n+1}=x\cdot x^n\stackrel{I.C}{<}x\cdot y^n\stackrel{x<y}{<}y\cdot y^n=y^{n+1}$
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9873750525759486, "lm_q1q2_score": 0.8411969352127124, "lm_q2_score": 0.8519527944504227, "openwebmath_perplexity": 297.41938929057505, "openwebmath_score": 0.8784292936325073, "tags": null, "url": "https://math.stackexchange.com/questions/2876248/have-i-used-induction-correctly-in-this-proof-of-xy-implies-xnyn" }
$X,Y$ are Banach spaces and $A\in B(X,Y)$ is a Fredholm operator (that is, the dimensions of ker($A$) and coker($A$) are both finite), then are closed linear subspaces ker($A$) and Im($A$) complemented? (A closed linear subspace $H$ in a Banach space $Z$ is called complemented iff there is a closed linear subspace $G$ such that $H+G=Z$ and $H \cap G=0$) - I think you mean complemented rather than complementary. – Jonas Meyer May 18 '12 at 16:06 They are both complemented: $\ker(A)$ is finite-dimensional, hence complemented, and $\text{im}(A)$ is finite-codimensional, so any algebraic complement is finite-dimensonal, hence closed. – Scott LaLonde May 18 '12 at 17:17 @Scott L:why is finite-dimensional subspace complemented? For example we can consider the kernel of an unbounded non-zero linear functional and its algebraic complement. – Hezudao May 19 '12 at 1:11 @Adterram the kernel of a unbounded linear functional is never closed. It's a fact of life that a linear functional is bounded if and only if its kernel is closed. – user12014 May 19 '12 at 1:18 Yes.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. Yes\n2. Yes", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9787126444811032, "lm_q1q2_score": 0.8155853204146097, "lm_q2_score": 0.8333245973817158, "openwebmath_perplexity": 128.6249178494357, "openwebmath_score": 0.9513838887214661, "tags": null, "url": "http://math.stackexchange.com/questions/146723/question-about-fredholm-operator" }
organic-chemistry Title: In the question given below in the question if we go in accordance with+M effect instead of+I effect we will get the required answer but why are we going in accordance with +M effect and when do and how do we choose which phenomenon to consider ? CH3 does not show resonance effects noticeably. In case of solving problems like this, the order to consider is +M >+H >+I, where +M refers to the resonance effect, +H to the hyper conjugation effect and +I to the inductive effect. Note that in the above problem, if you consider the number of alpha-hydrogen atoms involved in hyper conjugation, you will get the correct order.
{ "domain": "chemistry.stackexchange", "id": 14044, "lm_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", "url": null }
total number of corresponding elements that have different values. I tried to apply mahal to calculate the Mahalanobis distance between 2 row-vectors of 27 variables, i.e mahal(X, Y), where X and Y are the two vectors. ( Log Out /  The Mahalanobis distance. find.outliers provides two metrics for detecting outliers: Procrustes distance and Mahalanobis distance. The reason why MD is effective on multivariate data is because it uses covariance between variables in order to find the distance of two … if p = (p1, p2) and q = (q1, q2) then the distance is given by For three dimension1, formula is ##### # name: eudistance_samples.py # desc: Simple scatter plot # date: 2018-08-28 # Author: conquistadorjd ##### from scipy import spatial import numpy … Learn more about us. The first test is used in order to derive a decision whether to split a component into another two or not. Note that the argument VI is the inverse of V. Parameters: u: (N,) array_like Input array. Hi, I'm trying to compare the color between 2 images (A model and a ROI extracted with Local Features). mahalanobis distance for 2 vectors matlab. Here you can find a Python code to do just that. Suppose we have some multi-dimensional data at the country level and we want to see the extent to which two countries are similar. I have two vectors, and I want to find the Mahalanobis distance between them. First, we’ll create a dataset that displays the exam score of 20 students along with the number of hours they spent studying, the number of prep exams they took, and their current grade in the course: Step 2: Calculate the Mahalanobis distance for each observation. Change ), You are commenting using your Google account. def mahalanobis(x=None, data=None, cov=None): """Compute the Mahalanobis Distance between each row of x and the data x : vector or matrix of data with, say, p columns. Computes the Mahalanobis distance between two 1-D arrays. We can see that the first observation is an outlier in the dataset because it has a p-value
{ "domain": "milsabores.net", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9572778024535094, "lm_q1q2_score": 0.8078420455163772, "lm_q2_score": 0.8438950986284991, "openwebmath_perplexity": 723.3441140890131, "openwebmath_score": 0.6857232451438904, "tags": null, "url": "http://milsabores.net/french-vanilla-bzqbtkv/mahalanobis-distance-between-two-vectors-python-4bc1bb" }
# Indefinite integral $\int \arctan^2 x dx$ in terms of the dilogarithm function I read about the integral $$\int \arctan^2 x dx$$ in this old post: Evaluation of $\int (\arctan x)^2 dx$ By replacing $$\arctan x = -\frac{i}{2}\left[\log(1+ix) - \log(i-ix)\right],$$ as suggested there, I ended up with this solution $$\int\arctan^2 x dx = x\arctan^2x - \frac{1}{2}\log(1+x^2)\arctan x -\log 2 \arctan x + \mbox{Im}\left\{\mbox{Li}_2\left(\frac{1+ix}{2}\right)\right\} + K, \tag{1}\label{uno}$$ where, as usual, $\mbox{Li}_2(z)$ is the dilogarithm function $$\mbox{Li}_2(z) = -\int_0^z \frac{\log(1-u)}{u}du=\sum_{k=1}^{+\infty}\frac{z^k}{k^2}.$$ Is this a correct development?
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9811668739644686, "lm_q1q2_score": 0.8359078656284417, "lm_q2_score": 0.8519528000888387, "openwebmath_perplexity": 202.18757760108622, "openwebmath_score": 0.9951183199882507, "tags": null, "url": "https://math.stackexchange.com/questions/2428653/indefinite-integral-int-arctan2-x-dx-in-terms-of-the-dilogarithm-function" }
quantum-mechanics, hilbert-space, wavefunction, singularities, spherical-harmonics on the unit 2-sphere $\mathbb{S}^2$. However, we are using a "tropical" coordinate system $(\theta,\phi)$ that is singular at the north & south poles $\theta=0,\pi$. Hence, we should strictly speaking also solve the TISE in mathematically well-defined "arctic/antarctic" coordinate neighborhoods of the north & south poles, respectively, and see if we can glue the local solutions together into a global solution on $\mathbb{S}^2$. Not surprisingly$^2$, the "arctic/antarctic" coordinate solutions have no singularities at the poles. So the gluing is not possible if the tropical $(\theta,\phi)$ coordinate solution displays singularities at $\theta=0,\pi$, i.e. such singularities are physically unacceptable. -- $^1$ Here we stick to the differential-geometric formulation using wavefunctions. There is of course also a well-known algebraic formulation using ladder operators, which we will not address here. We can assume wlog that $\ell\geq 0$. The single-valuedness of the wavefunction $Y$ implies that the constant $m\in\mathbb{Z}$ is an integer. Its range $|m|$ is bounded by $\ell$ for physical reasons. In particular it follows that for fixed $\ell$, the number of independent tropical solutions are finite. $^2$ After all the $Y$ solutions should maintain $SO(3)$ covariance. Recall that the tropical solutions $Y$ have no singularities or discontinuities at internal points. In fact they are smooth maps in the interior. This can e.g. be derived by a bootstrap argument a la what is done in my Phys.SE answer here. A formulation using weak solutions doesn't change the main conclusion. An arctic/antarctic solution should then be a linear combination of the finitely many $90^{\circ}$-rotated tropical solutions for the corresponding problem with ${\bf L}_z$ replaced by, say, ${\bf L}_x$. A finite sum cannot develop internal singularities. $\Box$
{ "domain": "physics.stackexchange", "id": 70675, "lm_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, hilbert-space, wavefunction, singularities, spherical-harmonics", "url": null }
Taking $x = sn$, we have a solution to the linear congruence $cx \equiv b \pmod m$. My Question I am not sure how to prove uniqueness from here. Should I say that $cx \equiv b \pmod m$ gives that, for $d = \gcd(c,m)$, $$m | (cx -b ) \Longrightarrow \left({m \over d}\right) \mid \left({cx - b \over d}\right) = {c \over d}x - {b \over d}$$ However, I'm not sure how to move from here to uniqueness. I have that ${c \over d}x = {m\over d}k + {b\over d}$, but this doesn't seem to be much. - Lemma: $gx \equiv gy \pmod{gn}$ if and only if $x \equiv y \pmod n$. –  Hurkyl Sep 14 '12 at 23:27 Hint $\$ If $\rm\:x,y\:$ are solutions then $\rm\ cx\equiv b\equiv cy\pmod m\$ so, defining $\rm\ d=(m,c)\:$ we have $$\rm\,m\:|\:c\,(x\!-\!y) \iff \frac{m}d\:\bigg|\:\frac{c}d\,(x\!-\!y)\color{#C00}{\iff} \frac{m}d\:\bigg|\ x\!-y\,\ \ by \ \ \left(\frac{m}d,\frac{c}d\right)= \frac{(m,c)}d = 1$$ Remark $\$ The $\rm\color{#C00}{final}\,$ equivalence employs Euclid's Lemma and the distributive law for GCDs.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.977022625406662, "lm_q1q2_score": 0.8224827098281192, "lm_q2_score": 0.8418256532040707, "openwebmath_perplexity": 137.88834870604995, "openwebmath_score": 0.9999874830245972, "tags": null, "url": "http://math.stackexchange.com/questions/195871/proving-a-congruence-solution-is-unique-pmod-m-gcdc-m" }
absolute value of the complex number, the same as we had before in the Polar Form; θ is in radians; and. IntMath feed |. And, using this result, we can multiply the right hand side to give: 2.50(cos\ 220^@ + j\ sin\ 220^@) = -1.92 -1.61j. Exponential form of a complex number. Learn more about complex numbers, exponential form, polar form, cartesian form, homework MATLAB Representation of Waves via Complex Numbers In mathematics, the symbol is conventionally used to represent the square-root of minus one: that is, the solution of (Riley 1974). ], square root of a complex number by Jedothek [Solved!]. Express in polar and rectangular forms: 2.50e^(3.84j), 2.50e^(3.84j) = 2.50\ /_ \ 3.84 Complex number forms review Review the different ways in which we can represent complex numbers: rectangular, polar, and exponential forms. Active 1 month ago. $z = r (\cos(\theta)+ i \sin(\theta))$ The above equation can be used to show. Sitemap | j = −1. condition for multiplying two complex numbers and getting a real answer? This formula can be interpreted as saying that the function e is a unit complex number, i.e., it traces out the unit circle in the complex plane as φ ranges through the real numbers. Recall that $$e$$ is a mathematical constant approximately equal to 2.71828. But there is also a third method for representing a complex number which is similar to the polar form that corresponds to the length (magnitude) and phase angle of the sinusoid but uses the base of the natural logarithm, e = 2.718 281.. to find the value of the complex number. Here φ is the angle that a line connecting the origin with a point on the unit circle makes with the positive real axis, measured counterclockwise and in radians. The power and root of complex numbers in exponential form are also easily computed Multiplication of Complex Numbers in Exponential Forms Let $$z_1 = r_1 e^{ i \theta_1}$$ and $$z_2 = r_2 e^{ i
{ "domain": "digiloopdesigns.com", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9755769049752756, "lm_q1q2_score": 0.8212656594744931, "lm_q2_score": 0.8418256472515683, "openwebmath_perplexity": 908.6045495790235, "openwebmath_score": 0.7954952120780945, "tags": null, "url": "http://nitrous.digiloopdesigns.com/kristine-cofsky-rae/pt5uzlr.php?tag=09e9e4-exponential-form-of-complex-numbers" }
textbook-and-exercises, density-matrix, linear-algebra Title: (Proof verification) Kaye Exercise 3.5.5, partial trace in larger system This is the exercise as stated in Kaye's book, Introduction An Introduction to Quantum Computing: Show that for any density operator $\rho$ on a system $A$, there exists a pure state $|\psi\rangle$ on some larger system $A \otimes B$ such that $\rho = \text{Tr}_B|\psi\rangle \langle \psi|$ and $\dim(A)\geq \dim(B).$
{ "domain": "quantumcomputing.stackexchange", "id": 3988, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "textbook-and-exercises, density-matrix, linear-algebra", "url": null }
convolution, linear-systems, frequency-response, stability Title: why exponential term neglected in equation? where does that exponential term gone, is this because it is a constant term or it has to do something with stablity? The magnitude of that complex exponential is 1. Recall from complex algebra: any complex number can be expressed as $z = r e^{j \phi}$ where $|z|=r$ is its magnitude and $\arg z = \phi$ is the argument. Using this note that $$ |e^{-j\Omega \lambda}| = 1 $$ which is why it "disappeared".
{ "domain": "dsp.stackexchange", "id": 5723, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "convolution, linear-systems, frequency-response, stability", "url": null }
electromagnetism, magnetic-monopoles, dipole, multipole-expansion Title: Why do we need poles? The electric force is the attraction or repulsion between charges. If we for example had a metal with only positive charges, and another metal with only negative charges. The two metal pieces will then attract each other by the electric force. In an electric system, no poles is mentioned. The magnetic force is just a relativistic side effect of the electric force, and the difference is that it is created by moving charges and acts on other moving charges. If we have the two metal pieces, they will also feel the magnetic attraction because of the particles inside the metals have motion. The two metals is then said to be magnets. However, in a magnetic system, poles is mentioned.
{ "domain": "physics.stackexchange", "id": 40976, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "electromagnetism, magnetic-monopoles, dipole, multipole-expansion", "url": null }
quantum-mechanics, angular-momentum, quantum-spin, group-theory, representation-theory One may show that $\Phi$ is a star algebra monomorphism, i.e. the Hermitian conjugated matrix satisfies $$ \Phi(x)^{\dagger}~=~\Phi(\bar{x}), \qquad x~\in~\mathbb{H}. \tag{7}$$ Moreover, the determinant becomes the quaternionic norm square $$\det \Phi(x)~=~ |\alpha|^2+|\beta|^2~=~\sum_{\mu=0}^3 (x^{\mu})^2 ~=~|x|^2, \qquad x~\in~\mathbb{H}.\tag{8}$$ Let us for completeness mention that the transposed matrix satisfies $$\Phi(x)^t~=~\Phi(x|_{x^2\to-x^2})~=~ \Phi(-j\bar{x}j), \qquad x~\in~\mathbb{H}. \tag{9} $$ Consider the Lie group of quaternionic units, which is also the Lie group $$U(1,\mathbb{H})~:=~\{x\in\mathbb{H}\mid |x|=1 \} \tag{10}$$ of unitary $1\times 1$ matrices with quaternionic entries. Eqs. (7) and (8) imply that the restriction $$\Phi_|:~U(1,\mathbb{H})~~\stackrel{\cong}{\longrightarrow}~~ SU(2)~:=~\{g\in {\rm Mat}_{2\times 2}(\mathbb{C})\mid g^{\dagger}g={\bf 1}_{2\times 2},~\det g = 1 \} $$
{ "domain": "physics.stackexchange", "id": 75713, "lm_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, angular-momentum, quantum-spin, group-theory, representation-theory", "url": null }
physiology, entomology, biophysics, anatomy, flight Title: Why don't dragonflies wings collapse? How do dragonflies manage to fly at such high speeds without their wings collapsing? Their wings are thinner than paper, but they do not even flutter. What gives them their strength? Wootton (1992) reviewed the anatomy and biomechanics of insect wings. Basically the wing is a lightweight but strong scaffolding of veins, supporting a thin membrane. The veins are composed by a sandwich of cuticle with a potential space in between. The membrane is also a double-layer but without the space. In the venous space are is circulating hemolymph and often nerves and tracheae. The wikipedia image is pretty good: The nerves carry sensory information and the tracheae oxygen.The hemolymph is continuous with the body and thus is able to circulate and hydrate the wing (important for maintaining flexibility). As Wootton says: desiccation destroys both compliancy and toughness, and a dry cuticle would be mechanically disastrous So by maintaining a flexible tissue, insects have strong and tough wings that remain light enough.
{ "domain": "biology.stackexchange", "id": 242, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "physiology, entomology, biophysics, anatomy, flight", "url": null }
ros2, simulation Node( package='gazebo_ros', executable='spawn_entity.py', name='urdf_spawner', output='screen', # arguments=["-topic", "/robot_description", "-entity", -f"AGV_CAR"]) # arguments=['-entity', # 'mobot', # '-x', '3.5', '-y', '1.0', '-z', '0.1', # '-file', urdf # ] ) ]) my running enviroment: Linux ubuntu20.04 gazebo11 ROS_VERSION=2 ROS_PYTHON_VERSION=3 ROS_LOCALHOST_ONLY=0 ROS_DISTRO=foxy Originally posted by zhangys on ROS Answers with karma: 13 on 2022-04-26 Post score: 0 raise ValueError(f"No '{name}' annotation") I think the gazebo_ros spawn_entity.py wants a name. You have a name in there, which you commented out. It uses -entity to request a name. However, you have it in there twice. first as "-entity", -f"AGV_CAR" which I am not quite sure how to interpret that. And second # arguments=['-entity', # 'mobot', Which would spawn a robot called mobot. I'm not sure why you commented those lines out? I don't think spawn_entity uses -file anymore. It used to be possible to use -file to give the URDF file, but it has switched to using a topic (for instance robot_description as you have used, but you might want to remove the /). I hope this helps, otherwise drop a comment. Originally posted by Joe28965 with karma: 1124 on 2022-04-28 This answer was ACCEPTED on the original site Post score: 0
{ "domain": "robotics.stackexchange", "id": 37613, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "ros2, simulation", "url": null }
java, interview-questions Title: Simple online auction system in Java I recently applied for a Java developer position and I was asked to completed a coding task. After review of the coding task, the company said they do not want to take me forward to interview. They refused to give feedback so I have no idea of what went wrong. I'd love some insights on what I did wrong. The task: You have been tasked with building part of a simple online auction system which will allow users to bid on items for sale. Provide a bid tracker interface and concrete implementation with the following functionality: Record a user's bid on an item Get the current winning bid for an item Get all the bids for an item Get all the items on which a user has bid You are not required to implement a GUI (or CLI) or persistent storage. You may use any appropriate libraries to help, but do not include the jars or class files in your submission. The code: The interface: package com.nbentayou.app.service; import com.nbentayou.app.exception.InvalidBidException; import com.nbentayou.app.model.Bid; import com.nbentayou.app.model.Item; import com.nbentayou.app.model.User; import java.util.List; import java.util.Optional; import java.util.Set; /** * The interface for a Bid Tracker. * This interface exposes methods allowing {@link User}s to post {@link Bid}s on {@link Item}s * and query the current state of the auction. */ public interface BidTracker { /** * Records a bid for a given item. * @param bid the bid to record * @param item the item to bid on * @throws InvalidBidException when the bid is invalid */ void recordUserBidOnItem(Bid bid, Item item) throws InvalidBidException; /** * @param item the item * @return the current winning bid (last valid bid), as an {@link Optional}, for the given item */ Optional<Bid> getCurrentWinningBidForItem(Item item);
{ "domain": "codereview.stackexchange", "id": 35523, "lm_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, interview-questions", "url": null }
ruby Title: LuhnyBin - my first Ruby script I created my first Ruby program. Even though it works, I wondered whether I could do something different/better? #!/usr/bin/ruby class LuhnyBinChecker def initialize(number) @number = number end def check createNumberArray doubleSecond sumNumbers getResult end def createNumberArray @numberArray = @number.scan(/\d/).map { |c| c.to_i } end def doubleSecond puts "Checker: doubling every second number from the right.." i = @numberArray.length - 1 pos = 0 while i >= 0 if pos.modulo(2) == 1 @numberArray[i] = @numberArray[i] * 2 end i = i - 1 pos = pos + 1 end end def sumNumbers puts "Checker: calculating the sum.." @sum = 0 @numberArray.each do |i| if i > 9 @sum = @sum + splittedSum(i) # treat numbers >= 10 individually # e.g. 12 -> 1 + 2 = 3 else @sum = @sum + i end end end def splittedSum(number) numberAsString = number.to_s() splittedNumbers = numberAsString.scan(/\d/).map { |c| c.to_i } splittedSum = 0 splittedNumbers.each do |n| splittedSum = splittedSum + n end return splittedSum end def getResult if @sum.modulo(10) == 0 puts "Credit card number is valid" else puts "Credit card number is not valid" end end end class CreditCard def setCardNumber(number) @cardNumber = number end def getCardNumber if @cardNumber!= nil @cardNumber end end def verify puts "Verifying card number now..." checker = LuhnyBinChecker.new(@cardNumber) checker.check end end if __FILE__ == $0 card = CreditCard.new
{ "domain": "codereview.stackexchange", "id": 1911, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "ruby", "url": null }
graphs, algorithm-analysis, runtime-analysis, search-algorithms, graph-traversal Rules: 1. Bote can only carry two people 2. One person has to drive the boat 3. Cannibals can't outnumber the missionaries or they the missionaries will be eaten. Cost: 1 per crossing. Exhaustive Search (or Brute Search): (3, 3, I, 0, 0) -> (2, 2, F, 1, 1) -> (3,2,I,0,1), -> (3,2,I,0,1) -> (3,2,1,0,1) -> (3,0,F,0,3) -> (3,1,I,0,2) -> (1,1,F,2,2) -> (2,2,F,1,1) -> (0,2,F,3,1) -> (0,3,I,3,0) -> (0,1,F,3,2) -> (0,2,I,3,1) -> (0,0,F,3,3)
{ "domain": "cs.stackexchange", "id": 7165, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "graphs, algorithm-analysis, runtime-analysis, search-algorithms, graph-traversal", "url": null }
ros Title: raspberry rosdep initialised, but still asking to initialise Hi Trying to install ros desktop on raspberry pi. I am at the resolving dependencies point and the command sudo rosdep install --from-paths src --ignore-src --rosdistro groovy -y fails with ERROR: your rosdep installation has not been initialized yet. Please run: rosdep update rosupdate runs fine, but the error still happens. Tried running rosdep init again, but get ERROR: default sources list file already exists:Please delete if you want to re-initialize tried deleting and re-initializing, but still getting the same error Originally posted by nickw on ROS Answers with karma: 1504 on 2013-02-07 Post score: 2 Hi, I got this to work by running sudo rosdep update. Give it a try. Originally posted by tonybaltovski with karma: 2549 on 2013-02-14 This answer was ACCEPTED on the original site Post score: 1 Original comments Comment by Dirk Thomas on 2013-02-15: You should not run rosdep update as root since it creates the database in your user home with root ownership. Comment by tonybaltovski on 2013-02-19: Without root access , I was not able to update the database. Is there any reason it cannot be done without root access?
{ "domain": "robotics.stackexchange", "id": 12803, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "ros", "url": null }
$$\displaystyle -\sum_{k=0}^{\infty}\frac{\sin k\theta}{k^2}-i\sum_{k=0}^{\infty}\frac{\cos k\theta}{k^2}+i\sum_{k=0}^{\infty}\frac{1}{k^2}=$$ $$\displaystyle -\text{Cl}_2(\theta)-i\text{Sl}_2(\theta)+i\zeta(2)=-\text{Cl}_2(\theta)-i\text{Sl}_2(\theta)+\frac{i\pi^2}{6}$$ Combining this with our earlier results, and equating the imaginary parts to zero, we deduce that $$\displaystyle \text{Sl}_2(\theta)=\frac{\pi^2}{6}-\frac{\pi\theta}{2}+\frac{\theta^2}{4}$$ Or, equivalently... $$\displaystyle \sum_{k\ge 1}\frac{\cos k\theta}{k^2}= \frac{\pi^2}{6}-\frac{\pi\theta}{2}+\frac{\theta^2}{4}\, .\, \Box$$ ------------------------------------------- For $$\displaystyle m\in \mathbb{N}^+\,$$, all series of the form $$\displaystyle \text{Sl}_{2m}(\theta)=\sum_{k=0}^{\infty}\frac{ \cos k\theta}{k^{2m}}$$
{ "domain": "mathhelpboards.com", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9773707986486797, "lm_q1q2_score": 0.8438537491044119, "lm_q2_score": 0.863391611731321, "openwebmath_perplexity": 6799.2106437441125, "openwebmath_score": 0.9352215528488159, "tags": null, "url": "https://mathhelpboards.com/threads/clausen-sum.6090/" }
javascript, server, express.js Title: Express server for an artists website I am currently creating a website for an artist (my grandfather). My main concern with the code below is readability, as for the most part I have not worked with others on a (programming) project. I use a few external modules but hopefully their purpose is obvious/irrelevant. I have been programming with javascript as a hobby for about two years. Here is my code: const express = require('express') const app = express() const fs = require('fs') const gzip = require('express-gzip') const handleRequest = require('./handleRequest') const verify = require('../Admin/login').verify app.use(gzip) app.use(express.json())
{ "domain": "codereview.stackexchange", "id": 36363, "lm_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, server, express.js", "url": null }
The system has 2 different solutions: $$x=y=z=\sqrt 2$$ and $$x=y=z=-\sqrt 2$$ Your system can be written as follows $$\left\lbrace\begin{array}{clc}\tag{1} \left( {x}^{2}-2 \right) ^{2}+ \left( y-z \right) ^{2}+ \left( x-z \right) \left( x+z \right) +3\,({x}^{2}-\,zy)&=&0 \\ \\[1mm] \left( {y}^{2}-2 \right) ^{2}+ \left( z-x \right) ^{2}+ \left( y-x \right) \left( y+x \right) +3(\,{y}^{2}-\,zx)&=&0 \\ \\[1mm] \left( {z}^{2}-2 \right) ^{2}+ \left( x-y \right) ^{2}+ \left( z-y \right) \left( z+y \right) +3(\,{z}^{2}-\,xy) &=&0 \end{array}\right.$$ Now one solution of the $(1)$ is $x=y=z=\sqrt{2}$ which is mentioned in the first comment. Another way, adding gives you $$\sum x^4 + \sum x^2 +4 =5\sum xy$$ where $\sum$ represents cyclic sums. However by AM-GM, $\sum (x^4+4) \geqslant 4\sum x^2$ and $\sum x^2 \ge \sum xy$. So we need equality in both those inequalities, which is possible iff $a=b=c=\pm\sqrt2$.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9740426458162398, "lm_q1q2_score": 0.8199740749668948, "lm_q2_score": 0.8418256412990657, "openwebmath_perplexity": 1206.3501809636323, "openwebmath_score": 0.8722236752510071, "tags": null, "url": "https://math.stackexchange.com/questions/2556960/if-x-y-z-in-mathbb-r-solve-this-system-equation/2557121" }
php, pdo, authentication Title: Admin section - Secure login and authentication After a lot of back and forth on various sites, reading articles, watching videos etc i still can not figure out the best way to secure my admin section. The session id is regenerated every page reload / action to make session hijacking / fixation more difficult. Let me know in the comments if you need any more details. My Goal: Securely log the user in Set a session / cookie Authenticate the user Do this without HTTPS The following code attempts to deal with authenticating the user / allowing use of the various admin pages / functions if successfully logged in, what am i missing? Config.php <?php session_name('wcx'); session_start(); session_regenerate_id(true); define( 'DB_HOST', '' ); // set database host define( 'DB_USER', '' ); // set database user define( 'DB_PASS', '' ); // set database password define( 'DB_NAME', '' ); // set database name spl_autoload_register(function ($class) { require_once 'classes/class.'. $class .'.php'; }); $backend = new backend(); ?> Index.php <?php define('WCX', TRUE); require_once('config.php'); $pagearray = array('dashboard'); if(isset($_COOKIE['wcxadmin'], $_SESSION['loggedin'], $_SESSION['session']) && $backend->isLoggedIn()===true) { if(isset($_GET['page']) && !empty($_GET['page'])) { $page = filter_input(INPUT_GET, 'page', FILTER_SANITIZE_STRING); } else { $page = 'dashboard'; } include_once('includes/header.php');
{ "domain": "codereview.stackexchange", "id": 9245, "lm_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, pdo, authentication", "url": null }
• Should you break up your proof? This proof does not require any “helper functions”. It is short and simple enough. • Does your proof type-check? The variable $$n$$ is not introduced properly. From the problem statement, we can infer that $$n$$’s type is a natural number. However, the variable should still be declared properly. For instance, $$F_n$$ is supposed to be the statement “$$2^n > n$$”, but here $$n$$ is undefined/unquantified. • Are your references clear? There seems to be a reference to an induction hypothesis, but it is poorly presented since there is no indication that the proof is by induction until there is an attempt to make a reference to the induction hypothesis. • Where are you using the assumptions? The part “because $$n \geq 1$$” is a reference to an assumption that is given by the problem statement, so we expect the author to point this out explicitly. Once again, this point may seem pedantic, but in longer and more complicated proofs, these things really do make a difference. • Is the proof idea clear? As the given problem and its proof are quite simple, a ‘proof idea’ section is not necessary. Here is an example of how the proof can be written using good style. Good solution We will prove that for all integers $$n \geq 1$$, $$2^n > n$$. The proof is by induction on $$n$$. Let’s start with the base case which corresponds to $$n=1$$. In this case, the inequality $$2^n > n$$ translates to $$2^1 > 1$$, which is indeed true.
{ "domain": "cs251.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9481545348152283, "lm_q1q2_score": 0.863939178653115, "lm_q2_score": 0.9111797148356995, "openwebmath_perplexity": 308.24805973162677, "openwebmath_score": 0.7259247303009033, "tags": null, "url": "https://s23.cs251.com/Text/Ch_Proof_Guidelines/contents.html" }
c++, algorithm, comparative-review, random if (m_total_assertions == 0) { std::cout << "N/A"; } else { std::cout << ((float) (m_total_assertions - m_failed_assertions)) / m_total_assertions; } std::cout << "]"; if (m_failed_assertions == 0) { std::cout << " Test success!\n"; } else { std::cout << " Some tests failed.\n"; } } Assert assert; main.cpp #include "ArrayProbabilityDistribution.hpp" #include "BinaryTreeProbabilityDistribution.hpp" #include "LinkedListProbabilityDistribution.hpp" #include "ProbabilityDistribution.hpp" #include "assert.hpp" #include <algorithm> #include <chrono> #include <cstdint> #include <iostream> using net::coderodde::util::ProbabilityDistribution; using net::coderodde::util::ArrayProbabilityDistribution; using net::coderodde::util::BinaryTreeProbabilityDistribution; using net::coderodde::util::LinkedListProbabilityDistribution; static void test_all(); static void demo(); static void benchmark(); int main() { demo(); benchmark(); test_all(); REPORT } static void test_array(); static void test_linked_list(); static void test_tree(); static void test_all() { test_array(); test_linked_list(); test_tree(); } static void test_impl(ProbabilityDistribution<int>* dist) { ASSERT(dist->is_empty());
{ "domain": "codereview.stackexchange", "id": 27192, "lm_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, comparative-review, random", "url": null }
special-relativity, speed-of-light Title: How to see the obstacles ahead when moving at the speed of light? Imagine we're operating a space vehicle that moves at the speed of light. How can we set up our route based on the obstacles ahead? We need to send some sort of signal to see if there's anything in front of us and collect the reflections from the objects. However, moving at the speed of light, we will be traveling with the signal. Do I miss something? Even if you could travel at the speed of light (which you can't) length contraction would mean all of space would flatten into a single plane. This can be seen from the length contraction formula $$L_{\text{obs}}=L_{\text{reference}}\sqrt{1-\frac{v^2}{c^2}}$$ where $L_{\text{obs}}$ is the length you would observe going at the speed $v$ wrt a reference frame in which the object has length $L_{\text{reference}}$. As can be seen from the above equation as $v\rightarrow c$, $L_{\text{obs}}\rightarrow 0$ and thus all object lengths and distances tend to zero, implying obstacles would get closer to you as you approach the speed of light.
{ "domain": "physics.stackexchange", "id": 84038, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "special-relativity, speed-of-light", "url": null }
solar-system, gravity, astrophysics, n-body-simulations Title: Initial state for a 3-body problem to create Figure 8 [ restricted to 2D ] I've made an n-body simulation solution using the naive algorithm of O(n^2) in my library ChelseaaJS. I was trying to make some pleasing 3 Body simulations. I wanna do the 8 figure thing. I know it's a 3D simulation restricted to 2D to create 8-figure as given in the famous research paper on the same. I wanted to know if there is any particular initial state of the system in 2d i.e. given position and speed of masses. Example of the n-body simulation: This is just a basic solar system, nothing fancy. I will put it live if anyone wants to use it, tweak it. EDIT : Here is the paper: https://arxiv.org/abs/math/0511219 [thanks to @PM 2Ring] and I want to make something like : The initial condition are supposedly given in table 1 of Simó, C. (2001). New Families of Solutions in N-Body Problems, however I couldn't decipher the y position of the first and second bodies from there. I found a slightly different version of the initial conditions in this website: r[0][0] = 0.9700436; r[0][1] = -0.24308753; r[0][2] = 0; v[0][0] = 0.466203685; v[0][1] = 0.43236573; v[0][2] = 0; r[1][0] = -r[0][0]; r[1][1] = -r[0][1]; r[1][2] = -r[0][2]; v[1][0] = v[0][0]; v[1][1] = v[0][1]; v[1][2] = v[0][2];
{ "domain": "astronomy.stackexchange", "id": 6504, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "solar-system, gravity, astrophysics, n-body-simulations", "url": null }
inorganic-chemistry, stability Because of its ability to serve as a $\sigma$ donor and $\pi$ acceptor simultaneously, CO is a stronger ligand than $\ce{NH3}$ which can only act as a $\sigma$ donor with its lone pair in the nitrogen $sp^3$ hybrid orbital. $\ce{NH3}$ lacks a $\pi$ system and therefore cannot act as a $\pi$ acceptor. Because $\pi$ backbonding is crucial for stabilization of a metal center in low oxidation state, ammonia is unlikely to form stable ammin complexes which are analogous to the corresponding metal carbonyls.
{ "domain": "chemistry.stackexchange", "id": 1188, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "inorganic-chemistry, stability", "url": null }
audio, sampling, frequency, music Title: Sampling frequency of audio Based on what we choose sampling frequency when sampling some song? Do we use Nyquist–Shannon sampling theorem, or maximum sampling frequencies are pre-defined, so it will never come to aliasing effect? Audio is generally regarded to cover the frequency range from 20 Hz to 20,000 Hz, because the human ear is not capable of detecting signals outside of that range. When converting audio to a discrete signal, then, you must follow these steps: Bandpass filter the audio to eliminate any signals above 20 kHz. These may be produced by the audio source itself and by non-linearities in the electronics. Filtering prevents those higher frequencies to appear as alias in the 20 Hz -- 20 kHz range. Sample the audio at a frequency of at least 40 kHz (based on the Nyquist sampling theorem). In practice, the sampling frequency will be larger than 40 kHz, to make the reconstruction filter easier to implement. The reconstruction filter converts the sampled audio back to analog audio. Use an appropriate quantization -- for high quality audio, 16 bits per sample is considered acceptable. Note that for specific audio signals and for different applications the specific numbers will change. For example: Digital telephony limits the audio (voice) signal to around 3.3 kHz and quantizes using 8 bits per sample. High-end studio equipment usually samples at higher frequencies (like 96,000 Hz) and uses up to 24 bits per sample. Compressed audio uses a variable number of bits per sample.
{ "domain": "dsp.stackexchange", "id": 3749, "lm_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, sampling, frequency, music", "url": null }
ros, navigation, turtlebot, frontier-exploration, move-base I've run the program in debugging mode and this is what it prints for the various nodes that are running (note. I've deleted some of the repeated lines to keep the output more readable): Local planner [DEBUG] [1465797982.956315651]: Path/Goal distance computed [DEBUG] [1465797982.958396979]: Trajectories created [DEBUG] [1465797982.987519030]: Cost PointCloud published [DEBUG] [1465797982.987591393]: A valid velocity command of (0.10, 0.00, -0.22) was found for this cycle. [DEBUG] [1465797983.141464666]: Nearest waypoint to <0.000000, 0.000000> is <-0.025508, -0.019038>
{ "domain": "robotics.stackexchange", "id": 24901, "lm_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, turtlebot, frontier-exploration, move-base", "url": null }
beginner, bash, linux, shell, installer Before diving in though understand that I'm sharing what I know and think will be helpful, there's defiantly more clever people out there with Bash, and perhaps those that are will be kind enough to let us all know if any of the following would lead readers astray. "Could you add some features to the program that are practical, convenient or cool for setting up new installs?" Yes, however I don't think either of us would want to look at it after... Addressing some of your list; Abandon customizing nano and instead focus on vim, be very targeted about plugins and customizing, and try to focus on learning the built in goodies to tweak. For example vimdiff as a merge tool for git is super handy for remote (or local) merge conflict resolution, and vim-gpg allows for editing encrypted files in-place. Combined with either screen or tmux and it's possible to have a similar (or better) experience as what IDEs like Atom provides. iptables and ssh setup is something that should be handled by separate scripts at the very least, and I'll reiterate that systemd combined with iptables is an avenue worth exploring... may be in the future I'll push a related project, when it's ready... Additionally on iptables, look into chains, and insert to keep things organized and in somewhat predictable order respectively. Also check into fail2ban for an easy way of mitigating some forms of hacktackory, it also has templating options for automating changes in rules based off various logged events.
{ "domain": "codereview.stackexchange", "id": 34363, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "beginner, bash, linux, shell, installer", "url": null }
ros | ^~~~~~~~~~~~~~~~~~~~~~~~~ /home/failedmesh/ws_moveit2/src/moveit2_tutorials/doc/tutorials/pick_and_place_with_moveit_task_constructor/src/minimal.cpp: In member function ‘moveit::task_constructor::Task MTCTaskNode::createTask()’: /home/failedmesh/ws_moveit2/src/moveit2_tutorials/doc/tutorials/pick_and_place_with_moveit_task_constructor/src/minimal.cpp:127:43: warning: ‘void moveit::task_constructor::solvers::CartesianPath::setMaxVelocityScaling(double)’ is deprecated: Replace with setMaxVelocityScalingFactor [-Wdeprecated-declarations] 127 | cartesian_planner->setMaxVelocityScaling(1.0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ In file included from /home/failedmesh/ws_moveit2/install/moveit_task_constructor_core/include/moveit/task_constructor/solvers.h:41, from /home/failedmesh/ws_moveit2/src/moveit2_tutorials/doc/tutorials/pick_and_place_with_moveit_task_constructor/src/minimal.cpp:5: /home/failedmesh/ws_moveit2/install/moveit_task_constructor_core/include/moveit/task_constructor/solvers/cartesian_path.h:60:14: note: declared here 60 | void setMaxVelocityScaling(double factor) { setMaxVelocityScalingFactor(factor); } | ^~~~~~~~~~~~~~~~~~~~~
{ "domain": "robotics.stackexchange", "id": 38474, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "ros", "url": null }
classical-mechanics Title: Organ pipe, waves, longitudinal waves, traverse waves We all know that organ pipe work because of longitudinal stationary sound waves then why in diagrams showing the analysis of the physics behind the organ pipe transverse waves are drawn inside the pipe. You are correct in what you've said. The reason they are drawn as transverse waves is because they are easier to draw and visualize than if you were to try and draw them as longitudinah waves. Furthermore a standing wave is not a wave in itself but rather an interference of two waves traveling in opposite directions. The transverse wave illustration is a convenient way to show it.
{ "domain": "physics.stackexchange", "id": 26038, "lm_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", "url": null }
algorithms, graphs, shortest-path Finding a counterexample is a little tricky, but draw it out and try some ideas, and I bet you'll be able to figure out. Your approach doesn't work, but there are other algorithms to solve this problem. However, they're fairly complicated: more complicated than your could reasonably be expected to discover on your own. Assuming this is a homework/exercise, I can't just can't believe your teacher would assign you an exercise that requires you to independently re-discover those algorithms -- so there must be some other trick or background information available to you. You might check in with your teacher. The other algorithms use the following idea: Look for a "funnel" edge $e$ such that all paths from $s$ to $t$ "funnel through" the edge $e$ (i.e., all paths from $s$ to $t$ must include the edge $e$). If you find such an edge, obviously there is no pair of edge-disjoint paths from $s$ to $t$. If you don't find such an edge, then it turns out that there's guaranteed to exist two edge-disjoint paths from $s$ to $t$. Proving this is tricky, though, as is devising an efficient algorithm to rapidly test for the existence of such an edge.
{ "domain": "cs.stackexchange", "id": 2207, "lm_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, graphs, shortest-path", "url": null }
php, object-oriented, design-patterns /** * * Check if there is a logged in user * */ public function check_logged_in() { if ( Session::exists(Config::$secret) && # Secret session exists Session::exists(Config::$session_id) && # Session_id session exists Session::exists(Config::$session_name) && # User session exists Session::exists(Config::$is_logged_in) && # Check if 'logged in' session exists Session::exists(Config::$session_name) # Check if sys_user id is set in session ) { # Get users ip $ip = $this->get_system_user_ip(); # if the saved bombined session if ( (Session::get(Config::$combined) === Hash::make_from_array(array(Session::get(Config::$secret), session_id()), $ip)) && (Session::get(Config::$is_logged_in) === true ) ) { # Set ip to system user object $this->user_ip = $ip; return true; } else { return false; } } else { return false; } } /** * * Check if loggin session is timeout * */ public function check_timeout() { if (Session::exists(Config::$login_timestamp)){ # Calculate time $session_lifetime_seconds = time() - Session::get(Config::$login_timestamp) ; if ($session_lifetime_seconds > Config::MAX_TIME){ $this->logout(); return true; } else { return false; } } else { $this->logout(); return false; } }
{ "domain": "codereview.stackexchange", "id": 33117, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "php, object-oriented, design-patterns", "url": null }
python Monomer-Closed,1.0355285991781933,445,k,scaling_factor2_2,1768.6165511868628±133.37423027538938,1.151150952338753e-09±5.097243955583818e-12 Open-Closed,1.6310132144695257,445,k,scaling_factor0_45,6.110232320111209e-10±0.0405197656696667,2.3157564754683335e-10±1.5422258273095806e-12 Monomer-Open,1.4451484300339723,445,k,scaling_factor0_45,17268.28261839559±1616.3344267222324,3.5018987709634075e-10±4.613703295574204e-12 Monomer-Closed,1.1788814567239638,445,k,scaling_factor0_45,7141.302548479925±1077.4530781042545,2.938829180010316e-10±4.8942396558448616e-12 Open-Closed,2.0473742914774045,445,k,scaling_factor8_8,8.531841899639403e-12±0.0006707084729411748,4.372231465765708e-09±2.3522225211330147e-12 Monomer-Open,83.20355792437526,445,k,scaling_factor8_8,2152.549420623712±389.0190619421427,5.394261037849901e-09±5.7365519987939135e-11
{ "domain": "codereview.stackexchange", "id": 44935, "lm_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", "url": null }
java, optimization, calculator Op op = null; for (Op operation : Op.values()) { if (operation.key.equals(action)) { op = operation; break; } } if (op != null) { System.out.println("Now type in the first number you would like to " + op.command + "."); int x = scan.nextInt(); System.out.println("Now type the second number."); int y = scan.nextInt(); int z = op.eval(x, y); System.out.println(x + " " + op.result + " " + x + " equals " + z + "!"); } System.out.println("Would you like to start over? (yes,no)"); String startOver = scan1.nextLine(); if ("no".equals(startOver)) { System.out.println("Bye"); return; } } } } So all operation specific information is captured in the Op enums. If you want to add other operations like min, max, and, or, xor or mod, you don't have to introduce new if-blocks, just new enums.
{ "domain": "codereview.stackexchange", "id": 950, "lm_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, optimization, calculator", "url": null }
algorithm, c, multithreading, file, homework printf("Server ON.\n"); // unlink then initialize semaphore to 1 so locking works sem_unlink("mysem"); sem_t *sem = sem_open("mysem", O_CREAT | O_EXCL, S_IRUSR | S_IWUSR, 0); if (sem == SEM_FAILED) { fputs("Unable to initialize semaphore\n", stderr); cleanup(); return 3; } pthread_mutex_init(&qlock, NULL); pthread_mutex_init(&wlock, NULL); int num_threads = 3; pthread_t *tid = malloc(num_threads * sizeof(pthread_t)); for(int i = 0; i < num_threads; ++i) { err = pthread_create(tid + i, NULL, (void*)listener, sem); if (err) { fputs("Unable to create threads\n", stderr); cleanup(); return 4; } } readloop(sem); for(int i = 0; i < num_threads; ++i) { err = pthread_join(tid[i], NULL); if (err) { fputs("Unable to join threads\n", stderr); cleanup(); return 5; } } cleanup(); } One more thing Processing concurrent client messages also introduces a question of whether or not synchronisation is important. It's possible that the third message received might be processed faster than the second message, resulting in it being sent back to the client before the second. If ordering of the messages is important then either the server would need to manage this, or a message structure would need to be passed (for example that contained a message id) rather than just the text.
{ "domain": "codereview.stackexchange", "id": 22995, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "algorithm, c, multithreading, file, homework", "url": null }
quantum-mechanics, homework-and-exercises, fourier-transform Title: Finding $\phi(k)$ If you have $\Psi(x,0) = c(\psi_1 + \psi_2)$ where $\psi_n$ is an Energy eigenfunction for a quantum number $n$. I'm supposed to find $\phi(k,t)$ at $t$ = 0. This is for an infinite square well from 0 to a. I'm not exactly sure how to do this. I assume since $V(x)=0$ from $0<x<a$ then $\phi(k,t)$ will not evolve in time, thus $\phi(k,t) = \phi(k)$. $$\phi(k,0) = \frac{1}{\sqrt{2\pi}}\int_{0}^{a} \Psi(x,0) e^{-ikx} dx.$$ While, I believe that I'm on the right track the $\phi(k)$ I get is not correct in the sense that when I find $|\phi|^2$ it is still complex, which can't be right. Can someone guide me in the correct direction? Firstly, the Shroedinger's equation is: $$H\Psi(x,t)=i\hbar\frac{\partial}{\partial t}\Psi(x,t)$$ so, every wave funtion does evolve in time. In the case of infinite square well (and also for cases where the potential V is independent of t), we can use separation of variable for the above Shroedinger's equation. Then: $$\Psi(x,t)=e^{\frac{-iEt}{\hbar}}\Psi(x,0)$$ Now, the wave equation in momentum space is just a Fourier transform of $\Psi(x,t)$ with integral in $x$ variable as you presented. Moreover, $|\phi|^2$ is always a positive real number for all complex $\phi$. So, if you find $|\phi|^2$ is complex after calculating, please re-check.
{ "domain": "physics.stackexchange", "id": 25018, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "quantum-mechanics, homework-and-exercises, fourier-transform", "url": null }