text
stringlengths
49
10.4k
source
dict
c#, performance, strings, .net, formatting public static string ReadToEnd(this TextReader reader, int lineLength) { return string.Join(Environment.NewLine, reader.ReadLines(lineLength)); } public static IEnumerable<string> ReadLines(this TextReader reader, int lineLength) { var line = new StringBuilder(); foreach (var word in reader.ReadWords()) if (line.Length + word.Length < lineLength) line.Append($"{word} "); else { yield return line.ToString().Trim(); line = new StringBuilder($"{word} "); } if (line.Length > 0) yield return line.ToString().Trim(); } public static IEnumerable<string> ReadWords(this TextReader reader) { while (!reader.IsEof()) { var word = new StringBuilder(); while (!reader.IsBreak()) { word.Append(reader.Text()); reader.Read(); } reader.Read(); if (word.Length > 0) yield return word.ToString(); } } static bool IsBreak(this TextReader reader) => reader.IsEof() || reader.IsWhiteSpace(); static bool IsWhiteSpace(this TextReader reader) => string.IsNullOrWhiteSpace(reader.Text()); static string Text(this TextReader reader) => char.ConvertFromUtf32(reader.Peek()); static bool IsEof(this TextReader reader) => reader.Peek() == -1; }
{ "domain": "codereview.stackexchange", "id": 18229, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c#, performance, strings, .net, formatting", "url": null }
c++, reinventing-the-wheel, memory-management, overloading friend std::ostream& operator<<(std::ostream& lhs, const DynString& a) { return lhs << a.c.get(); } char& operator[](size_t i) noexcept { return c.get()[i]; } const char& operator[](size_t i) const noexcept { return c.get()[i]; } DynString& operator+=(const DynString& other) { DynString newString(*this, other); swap(newString); return *this; } DynString operator+(const DynString& other) const { return DynString(*this, other); } DynString& operator=(DynString other) noexcept { swap(other); return *this; } };
{ "domain": "codereview.stackexchange", "id": 26064, "lm_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++, reinventing-the-wheel, memory-management, overloading", "url": null }
ros-kinetic, custom-message Title: Writing a Publisher and Subscriber with a Custom Message(Python) Tutorial Not Working I am trying to follow the tutorial as detailed in this link: (http://wiki.ros.org/ROS/Tutorials/CustomMessagePublisherSubscriber%28python%29) I am using ROS Kinetic on ubuntu 16.04. I was able to build the Person messages fine without errors and using rosmsg show command. ROS was able to find the message and show the following as output: string name int32 age I created two different packages to run it. One is called the quadrotor_receive node while the other is called the transmit_thrust node. The transmit_thrust runs the custom_talker.py script while the quadrotor_receive runs the custom_listener.py. I am having the following errors trying to run the custom_listener.py by itself. Below is my script on the quadrotor_receive node. #!/usr/bin/env python import rospy from quadrotor_receive.msg import Person def callback(data): rospy.loginfo("%s is age: %d" % (data.name, data.age)) def listener(): rospy.init_node('custom_listener', anonymous=True) rospy.Subscriber("custom_chatter", Person , callback) # spin() simply keeps python from exiting until this node is stopped rospy.spin() if __name__=='__main__': listener() When I tried to run the above code I get the error Traceback (most recent call last): File "/home/ted/catkin_ws/src/quadrotor_receive/scripts/custom_listener.py", line 4, in from quadrotor_receive.msg import Person ImportError: No module named quadrotor_receive.msg I also tried to replace the line: from quadrotor_receive.msg import Person with the following: import quadrotor_receive.msg I then get the following error:
{ "domain": "robotics.stackexchange", "id": 33814, "lm_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-kinetic, custom-message", "url": null }
reinforcement-learning, q-learning, dqn, deep-rl, pseudocode Title: Can this be a possible deep q learning pseudocode? I am not using replay here. Can this be a possible deep q learning pseudocode? s - state a - action r - reward n_s - next state q_net - neural network representing q step() { get s,a,r,n_s q_target[s,a]=r+gamma*max(q_net[n_s,:]) loss=mse(q_target,q_net[s,a]) loss.backprop() } while(!terminal) { totalReturn+=step(); } It looks generally valid to me. There are a couple of things missing/implied that I'd like to give feedback on though: I am not using replay here Then it won't work, except for the most simple and trivial of problems (where you probably would not need a neural network anyway). get s,a,r,n_s I would make it more explicit where you get these values from, and split up the assignments. # before step() s = env.start state() a = behavior_policy(q_net[n_s,:]) # inside step(), first action r, n_s = env.step(s, a) # ....rest of loop # inside step(), last actions s = n_s a = behavior_policy(q_net[n_s,:]) In the above code, env is the environment which takes state, action pairs as input and returns reward plus next state. It would be equally valid to have current state as a property of the environment, and query that when needed. The behaviour_policy is a function that selects an action based on current action values - typically this might use an $\epsilon$-greedy selection. while(!terminal) {
{ "domain": "ai.stackexchange", "id": 1817, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "reinforcement-learning, q-learning, dqn, deep-rl, pseudocode", "url": null }
c#, object-oriented, .net, interface, polymorphism If your application is completely event/UI-driven and does not have an application loop per se, you can register a callback to fire when a message arrives. The registration must happen from the correct SynchronizationContext (ie. call RegisterReceivedCallback from the same thread you want to receive the message notification on) peer.RegisterReceivedCallback(new SendOrPostCallback(GotMessage)); public static void GotMessage(object peer) { var msg = peer.ReadMessage(); // process message here } where you need to cast the object peer to a NetServer. This callback instead of the while(true) loop will decrease the work for the CPU. Now all you have to do is creating a NetServerAdapter object in your NetworkServer class and register to the events.
{ "domain": "codereview.stackexchange", "id": 14700, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c#, object-oriented, .net, interface, polymorphism", "url": null }
resource-request, quantum-optics Title: Are there resources to learn about quantum optics that focus on math and/or are addressed to those familiar with the qubit formalism? Most of my knowledge in the field of Quantum Information comes from the lectures I've had as an MSc Student and from Nielsen and Chuang's textbook. Both of these focused on the "qubit" formalism. By that, I mean: Working in a finite dimensional Hilbert space; Working in a "discrete" Hilbert space (by that I mean that its bases are countable); $|i\rangle$ represents a vector of the canonical basis of the Hilbert space, and more generally a vector $|\psi\rangle$ represents a state the quantum system can be in (focusing on pure states for now). Now, I've heard that the mathematical formalism is quite different to deal with quantum optics. I would like to learn about it, but I would like to avoid as much as possible the "physics" side of it, since saying that I'm bad at it would be an euphemism. Are there some resources that teach about this domain while focusing on the mathematical side of things, or that are addressed to those familiar with the qubit formalism? If it's not clear (because I don't know what I'm talking about), the topic I would like to learn about concerns stuff like:
{ "domain": "quantumcomputing.stackexchange", "id": 5409, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "resource-request, quantum-optics", "url": null }
array, multithreading, matlab VarIntraEuclideanDistancesPar function function [output] = VarIntraEuclideanDistancesPar(X1) Avg = AverageIntraEuclideanDistancesPar(X1); D = 0; for i = 1:size(X1, 4) element1 = X1(:, :, :, i); for j = i:size(X1, 4) element2 = X1(:, :, :, j); D = D + (EuclideanDistance(element1, element2) - Avg)^2; end end k = 2; NormalizationFactor = ( 1 / nchoosek(size(X1, 4), k)); output = NormalizationFactor * D; end EuclideanDistance function function [output] = EuclideanDistance(X1, X2) %EUCLIDEANDISTANCE Calculate Euclidean distance between two inputs if ~isequal(size(X1), size(X2)) error('Sizes of inputs are not equal!') end output = sqrt(SquaredEuclideanDistance(X1, X2)); end All suggestions are welcome. The summary information: Which question it is a follow-up to? Calculate distances between two multi-dimensional arrays in Matlab What changes has been made in the code since last question? I am trying to implement AverageIntraEuclideanDistancesPar and VarIntraEuclideanDistancesPar functions in this post. Why a new review is being asked for? If there is any possible improvement, please let me know. My only comment here is that AIED = AverageIntraEuclideanDistancesPar(Collection) VIED = VarIntraEuclideanDistancesPar(Collection) computes the average twice, since VarIntraEuclideanDistancesPar also calls AverageIntraEuclideanDistancesPar. I would suggest writing a function that returns both the average and the variance. That said, your way of computing variance is precise, but expensive because it computes the distances twice, first to determine the mean, and then again to determine the variance. I suggest you read this Wikipedia article on computing variance. Depending on the properties of the input, either the naive algorithm or Welford’s could be used. Three more details:
{ "domain": "codereview.stackexchange", "id": 42217, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "array, multithreading, matlab", "url": null }
machine-learning, word-embeddings, convolution # Returns A sepCNN model instance. """ op_units, op_activation = _get_last_layer_units_and_activation(num_classes) model = models.Sequential() # Add embedding layer. If pre-trained embedding is used add weights to the # embeddings layer and set trainable to input is_embedding_trainable flag. if use_pretrained_embedding: model.add(Embedding(input_dim=num_features, output_dim=embedding_dim, input_length=input_shape[0], weights=[embedding_matrix], trainable=is_embedding_trainable)) else: model.add(Embedding(input_dim=num_features, output_dim=embedding_dim, input_length=input_shape[0])) for _ in range(blocks-1): model.add(Dropout(rate=dropout_rate)) model.add(SeparableConv1D(filters=filters, kernel_size=kernel_size, activation='relu', bias_initializer='random_uniform', depthwise_initializer='random_uniform', padding='same')) model.add(SeparableConv1D(filters=filters, kernel_size=kernel_size, activation='relu', bias_initializer='random_uniform', depthwise_initializer='random_uniform', padding='same')) model.add(MaxPooling1D(pool_size=pool_size))
{ "domain": "datascience.stackexchange", "id": 5417, "lm_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, word-embeddings, convolution", "url": null }
java, beginner, game, game-of-life you respect Java naming conventions you separate different parts in methods contra use of static methods Java is an object oriented language so the use of objects is encouraged. in your code you'd need one more method to move the code from main to and then you would call that method on a new instance of your class: public static void main(String[] args) throws InterruptedException { new GameOfLife().run(); } private void run() throws InterruptedException { for (int i = 0; i < BOARD_HEIGHT; i++) { for (int j = 0; j < BOARD_HEIGHT; j++) { board[i][j] = Cell.DEAD; } } //... then you should remove the static key word from all methods except main. You could (and should) also remove the static key word from most of your variables, except the constants. enums used in switch In Java enums are full featured class. That means it is possible benefit from polymorphism. In your printBoard() method you have this: switch (board[i][j]) { case DEAD: System.out.print(DEAD_CELL_SYMBOL); break; case ALIVE: System.out.print(ALIVE_CELL_SYMBOL); break; when we change the enum Cell to this: private enum Cell { DEAD(DEAD_CELL_SYMBOL), ALIVE(ALIVE_CELL_SYMBOL); private final String symbol; Cell(String symbol){ this.symbol = symbol; } String getSymbol(){ return symbol; } } the code in printBoard would change to this: System.out.print(board[i][j].getSymbol()); // that replaces the whole switch! something similar is possible for the calculation of the next state. you have a rather complicated list of ifstatements:
{ "domain": "codereview.stackexchange", "id": 23666, "lm_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, game, game-of-life", "url": null }
$\displaystyle . \ \ \ \ \ \ U_0,V_0,U_1,V_1,\cdots,U_{n-1},V_{n-1},\cdots$ such that $U_0=\sigma(\varnothing)$, and for each $n \ge 1$, $U_n=\sigma(V_0,\cdots,V_{n-1})$ and player $\alpha$ wins in this play of the game, that is, $\bigcap \limits_{n=0}^\infty V_n \ne \varnothing$. In the game $BM(X,\alpha)$ (player $\alpha$ making the first move), a strategy for player $\beta$ is a function $\gamma$ such that for each partial play of the game $\displaystyle (**) \ \ \ \ \ V_0,U_1,V_1,\cdots,U_{n-1},V_{n-1}$, $U_n=\gamma(V_0,V_1,\cdots,V_{n-1})$ is a nonempty open set such that $U_n \subset V_{n-1}$. We now present a lemma that helps translate game information into topological information. Lemma 1 Let $X$ be a space. Let $O \subset X$ be a nonempty open set. Let $\tau$ be the set of all nonempty open subsets of $O$. Let $f: \tau \longrightarrow \tau$ be a function such that for each $V \in \tau$, $f(V) \subset V$. Then there exists a disjoint collection $\mathcal{U}$ consisting of elements of $f(\tau)$ such that $\bigcup \mathcal{U}$ is dense in $O$. Proof This is an argument using Zorn’s lemma. If the open set $O$ in the hypothesis has only one point, then the conclusion of the lemma holds. So assume that $O$ has at least two points.
{ "domain": "wordpress.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9833429619433693, "lm_q1q2_score": 0.8278033273593683, "lm_q2_score": 0.8418256492357358, "openwebmath_perplexity": 239.6477656412658, "openwebmath_score": 0.995428204536438, "tags": null, "url": "https://dantopology.wordpress.com/tag/baire-category-theorem/" }
recursion, bash, macos rename Any way to make it more brilliant? With this code and your example data, both a/c/0.png and b/0.png get renamed to 1_0.png. This happens because changes to $n inside ( ) get lost when you leave the subshell. Use bash's "globstar" feature to recurse for you, and assign numbers as normal. **/ matches all subdirectories. You want the current directory too, so add . to the list. This doesn't exactly match your example (A/C will be numbered before B) but it's close: shopt -s globstar n=0 for d in ./ **/ ; do ( cd $d && for f in *.png; do [[ -f $f ]] && mv "$f" $n"_$f" done ) (( n++ )) done
{ "domain": "codereview.stackexchange", "id": 35938, "lm_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, bash, macos", "url": null }
light, radio-astronomy, photons, electromagnetic-spectrum Title: Does a photon need to have EXACTLY the right energy to be absorbed by a gas molecule? From an answer to this question, https://physics.stackexchange.com/questions/281660/how-does-an-electron-absorb-or-emit-light, Absorption of a photon will occur only when the quantum energy of the photon precisely matches the energy gap between the initial and final states of the system. (the atom or a molecule as a whole) i.e., by the absorption of a photon, the system could access to some higher permissible quantum mechanical energy state. If there is no pair of energy states such that the photon energy can elevate the system from the lower to the upper energy state, then the matter will be transparent to that radiation.
{ "domain": "astronomy.stackexchange", "id": 5333, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "light, radio-astronomy, photons, electromagnetic-spectrum", "url": null }
Can u explain more the step in yellow, please? Thanks _________________ I hated every minute of training, but I said: "Don't quit. Suffer now and live the rest of your life as a champion." Manager Joined: 07 Sep 2011 Posts: 63 Location: United States GMAT 1: 640 Q39 V38 WE: General Management (Real Estate) Followers: 6 Kudos [?]: 38 [0], given: 3 Re: Find the power of 80 in 40!??? [#permalink] ### Show Tags 24 Jun 2012, 23:49 Hi Anan, Not to worry much as this particular concept has been explained very well was Bunuel in math book as well as in one of the topics related to factorial. You can find them here at everything-about-factorials-on-the-gmat-85592.html and math-number-theory-88376.html. AnanJammal wrote: AtifS wrote: This is regarding the topic "Factorial" written by Bunuel for GMAT Club's Math Book. When finding the power of non-prime number in $$n!$$ we first do prime-factorization of the non-prime number and then find the powers of each prime number in $$n!$$ one by one using the following formula $$\frac{n}{p}+\frac{{n}}{{p^2}}+\frac{{n}}{{p^3}}+....+\frac{{n}}{{p^x}}$$ such that $$p^x <n$$, where $$p$$ is the prime number.
{ "domain": "gmatclub.com", "id": null, "lm_label": "1. Yes\n2. Yes\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9702399129382357, "lm_q1q2_score": 0.8303809387543108, "lm_q2_score": 0.855851143290548, "openwebmath_perplexity": 2503.628611856309, "openwebmath_score": 0.6841710209846497, "tags": null, "url": "https://gmatclub.com/forum/find-the-power-of-80-in-103098.html" }
homework-and-exercises, newtonian-mechanics, moment-of-inertia I solved problem II-6 using a surface integral and obtained the correct answer, but II-7 is where the trouble began. You see, Schey doesn't talk about moment of inertia at all in his textbook so I had to go off my AP Physics C knowledge from high school, but for some reason, I just couldn't land on a correct answer (AP Physics C was a while ago so maybe I'm rusty). I just hope to get some tips or hints on how to proceed. The answer to II-6 is $4\pi R^2 \sigma_0/3$ if that helps and the answer to II-7 is $16\pi R^4 \sigma_0/15$. Below, I give a summary of my thoughts and an attempt. My Attempt Noting that the distribution of mass depends only on $x^2+y^2$, which itself is dependent only on $z$ (note that $r^2=x^2+y^2=R^2-z^2$), my idea is to turn the hemisphere into a series of thin rings of radius $r$ and add up the moments of inertia $\int dI$ for each ring along the $z$ axis.
{ "domain": "physics.stackexchange", "id": 80807, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "homework-and-exercises, newtonian-mechanics, moment-of-inertia", "url": null }
vba, ms-access Title: A function that implements a query I have some parameterized queries in Access 2010. They are often used in VBA functions having the same parameters. In such cases, I give the query and function the same name. The following is such a function (from my actual project): Public Function get_assignments(e_id As Long, yr As Integer, wk As Integer) As DAO.Recordset Dim db As DAO.Database Set db = CurrentDb Dim qd As DAO.QueryDef Set qd = db.QueryDefs!get_assignments qd.Parameters![e_id] = e_id qd.Parameters![year] = yr qd.Parameters![week] = wk Set get_assignments = qd.OpenRecordset qd.Close End Function Both the query and function are named get_assignments and things work fine. Am I asking for trouble? While I don't usually add "type" suffixes to names, I could rename the query as get_assignments_qry or even rename the function as get_assignments_fn. What's best? Feel free to give feedback on any aspects of this code. Having different types of objects with the same name can be confusing. In Access it is a established practice to use prefixes for stored objects and sometimes also for functions. I use these prefixes: frm for a normal data entry form bound to a table or query. fdlg for modal dialog forms typically having "OK" and "Cancel" buttons. qfrm for queries used as record source of a form. qrpt for queries used as record source of a report. qsel for other select queries. qupd for update queries. qdel for delete queries. qapp for append (insert) queries. qcbo for queries used as row source of ComboBoxes. tbl for main tables. tlkp for lookup tables (countries, address-types etc.) rpt for reports.
{ "domain": "codereview.stackexchange", "id": 17966, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "vba, ms-access", "url": null }
special-relativity, dark-matter, large-hadron-collider Title: Dark matter: Will Special Relativity hold? Part 1: It’s been said that dark matter makes up about 26 % of the universe. The restart of LHC would be dealing with the existence of dark matter also. Consider a situation that the results are positive, i.e there is dark matter? Would it demands any revisions for theories which currently we use? For example, Special Relativity, in which Einstein establishes that velocity of light in vacuum (will it be still valid to use the word vacuum? Well I am not quite certain) is a constant(=3x$10^8 ms^{-1}$, I hope this fact doesn’t need any revision other than redefining “vacuum”) and is the highest attainable velocity. $$c=1/(ε_0μ_0)^{1/2}$$ Where the symbols have their usual meaning. Then $ε_0$&$μ_0$ are the values of permittivity and permeability of free space (as we say today) should be the values for dark matter? The question: Do we have to revise any theory? If yes, what would be its aftereffects? And are we capable of revising them and coming up with more accurate theories? Part 2: Consider a situation where we have absolute vacuum (i.e. nothing including dark matter is present), what would be the values of $ε_0$&$μ_0$? From their definition, I think they should be zero, which in turn shows that radiation has an infinite velocity in absolute vacuum, is it possible? The permittivity and permeability of free space are non-zero in 'absolute vacuum' and they will be unaffected by dark matter which interacts extremely weakly (if at all) with the EM force. We might need to modify gravity to account for dark matter (hopefully not) but that's all.
{ "domain": "physics.stackexchange", "id": 20976, "lm_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, dark-matter, large-hadron-collider", "url": null }
electromagnetic-radiation, electric-fields, dipole, dipole-moment, coherence The above analysis is phrased in terms of powers, but applies to both coherent and incoherent signals. You could also equivalently phrase everything in terms of amplitudes, by "taking the square root" of everything. In this case, you would have a signal amplitude, and the signal noise would be characterized by something with units of $\text{Ampl.}/\sqrt{\text{Hz}}$, and the SNR would increase as $\sqrt{t_{\text{int}}}$ or $t_{\text{int}}^{1/4}$, for a coherent or incoherent signal respectively. These two ways of thinking about it are equivalent in power as long as the signal doesn't have any kind of special substructure (which the transient events in LIGO do). In any case, your desired example doesn't, and whether or not this substructure exists doesn't depend on $r$. In the example you propose, we can phrase the result in terms of either power or amplitude, with equivalent results. For example, in terms of power, we could cool down the receiver by a factor of $4$, reducing the thermal noise power spectral density by a factor of $4$. So since power goes as $1/r^2$, we can see twice as far. This is completely equivalent to saying that the cooling reduces the voltage fluctuations (in units of $\text{V}/\sqrt{\text{Hz}}$) by a factor of $2$, so since amplitude goes as $1/r$, we can see twice as far. For things like radiometers, you want to phrase the analysis in terms of power, because it's easier to think of the dominant noise sources (thermal noise, shot noise, etc.) in this way. For things like LIGO, you want to phrase the analysis in terms of amplitude, for the same reason -- the amount the mirror wobbles or the ground shakes is naturally an amplitude. But there's no fundamental difference, you could describe radiometers in terms of amplitudes if you wanted to.
{ "domain": "physics.stackexchange", "id": 65200, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "electromagnetic-radiation, electric-fields, dipole, dipole-moment, coherence", "url": null }
of and have their -values and -values reversed with any of the graph of would. By exactly one input graphs Preliminary ( horizontal line test only if any horizontal lines intersect the function plotted.. Is only one x that can be paired with the given y buttons... Restricted to [ 0, –2 ) to take 4 to -2 function h, question Solutions... Nonprofit organization is easy can graph our function ready for spades of practice with these inverse by! Learn how we can tell whether a function using a graph is easy would use degrees Celsius the! Like x in its inverse function of the inverse of a house to provide cooling this section graph a! Invertible or not pump is a one-to-one function, given any y is... With the given function is a 45° line, halfway between the and! Across by 1 trying to explain with their sets of points ( horizontal line test horizontal... There is no function using graph to demonstrate a function which is invertible function is the graph of f and its reflection about the identity does... Thus have reversed ordered pairs of and have their -values and -values reversed reversed ordered pairs ) of inputs the. As long as we can find the inverse of a function too for this function behaves well because domain. Of practice with these inverse function of the x that the ordered.. To submit project for class 12 our x ’ s line on a is. Reciprocal function, so we need to using graph to demonstrate a function which is invertible function the domain and range not tricky.
{ "domain": "apartmanisokobanja.net", "id": null, "lm_label": "1. Yes\n2. Yes", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9770226354423304, "lm_q1q2_score": 0.8589462932796026, "lm_q2_score": 0.8791467690927439, "openwebmath_perplexity": 433.61432681108704, "openwebmath_score": 0.5981078743934631, "tags": null, "url": "https://apartmanisokobanja.net/cubic-centimeter-jvmor/5e7e83-using-graph-to-demonstrate-a-function-which-is-invertible-function" }
c, socket, tcp if(ret < 0) { // --- Waiting until one or more of the file descriptors become "ready" perror("Select error"); close(fd); exit(EXIT_FAILURE); } if(state == STATE_SEND) { buf_send = fill_n_send(fd); state = STATE_RECEIVE; } if (FD_ISSET(fd, &rfd)) { // --- Tests to see if a file descriptor is part of the set receive_n_compare(fd, buf_send); state = STATE_SEND; } } } unsigned char *fill_n_send(int fd) { unsigned int start = 0; unsigned char *buf_send; buf_send = malloc(bytes + 2); if(buf_send == NULL) { fprintf(stderr, "Memory not allocated\n"); close(fd); exit(EXIT_FAILURE); } while(start <= bytes){ // --- fill send buf like A, AA, AAA, AAAA ..... upto 200KB size and send one by one like first A then AA then AAA ... buf_send[start] = 'A'; start++; } buf_send[++bytes] = 0; if(bytes >= 200*KB) { free(buf_send); close(fd); exit(EXIT_SUCCESS); } send_str(fd, buf_send, bytes + 1); return buf_send; } void receive_n_compare(int fd, unsigned char *buf_send) { unsigned char *buf_recv; buf_recv = receive(fd, bytes + 1); if(buf_recv == NULL) { fprintf(stderr, "Memory not allocated\n"); free(buf_send); close(fd); exit(EXIT_FAILURE); }
{ "domain": "codereview.stackexchange", "id": 31002, "lm_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, socket, tcp", "url": null }
filters, signal-analysis, fourier-transform, highpass-filter $$ Then, remember $e^{i\omega t} = \cos(\omega t) + i \cdot \sin(\omega t)$. Therefore: $$ x(\omega) = \sqcap_{2\pi} (\omega - \omega_0) + \sqcap_{2\pi} (\omega + \omega_0) $$ Doing inverse: $$ \begin{align} x(t) &= \mathcal F^{-1}\left\{x(\omega)\right\} \\ &=\mathrm{sinc} (\pi t) \cdot \big(\cos(\omega_0 t) + i \cdot \sin(\omega_0 t)\big) + \mathrm{sinc} (\pi t) \cdot \big(\cos(-\omega_0 t) + i \cdot \sin(-\omega_0 t)\big) \\ &= 2 \cdot \mathrm{sinc} (\pi t)\cdot \cos(\omega_0 t) \\ &= 2 \cdot \frac{\sin(\pi t)}{\pi t}\cdot \cos(3 \pi t) \end{align} $$ since $\cos(-x)=\cos(x)$ and $\sin(-x)=-\sin(x)$
{ "domain": "dsp.stackexchange", "id": 5317, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "filters, signal-analysis, fourier-transform, highpass-filter", "url": null }
fl.formal-languages, regular-language, regular-expressions, monoid where $e'_n$ is a copy of $e_n$ with fresh letters $a_{2^n},\dots ,a_{2^{n+1}-2}$, and $a_{2^{n+1}-1}$ is another fresh letter. On binary alphabet: \begin{alignat}{2} e_1 & = (ab)^* \\ e_2 & = \left(aa(ab)^*bb(ab)^*\right)^* \\ e_3 & = \left(aaaa \left(aa(ab)^*bb(ab)^*\right)^* bbbb \left(aa(ab)^*bb(ab)^*\right)^*\right)^* \\ \, & \cdots \\ e_{n+1} & = (\,\underbrace{a\cdots a}_{2^n}\, \cdot \, e_n\, \cdot\, \underbrace{b\cdots b}_{2^n}\, \cdot\, e_n \,)^* \end{alignat} Intuitively, we can see these languages never need to count modulo, so they are star-free. To prove formally that $e_n$ always describes a star-free language, you can for example show by induction that the NFAs obtained from these expressions have no "counter", i.e. no path of the form $p\stackrel{u}{\to}q\stackrel{u^k}{\to}p$ with $p\neq q$.
{ "domain": "cstheory.stackexchange", "id": 5307, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "fl.formal-languages, regular-language, regular-expressions, monoid", "url": null }
planetary-atmosphere Do solar winds contain any larger atoms than helium. For instance, Oxygen? Yes, but only trace amounts. The Solar wind is 92% hydrogen and 8% helium. Source. Very close to the universal average ratio. Solar particles are so hot that when they're ejected from the sun the electrons and atomic nuclei are largely separated so you get a stream of charged particles, electrons and protons being the most common and Alpha Particles (Helium Nuclei) 3rd. This means that any planets with a magnetic field, those particles get caught in planet's magnetic field. That's why a magnetic field is considered very important in preserving a planet's atmosphere. Some of the captured solar wind particles would probably get deposited into the Planet's atmosphere over time but I'm not clear on that process and I don't know the percentages. Getting back to the Sun, it has about 2% "heavy" elements in it, see article, and by "heavy" I mean, Oxygen, Carbon, Neon, others, but gravity draws the heavier elements towards the center of the sun. Also, the helium the sun creates is largely formed near the center of the sun, so the outer parts where the solar wind gets ejected has a more standard/universal balance of about 92% hydrogen by element. My intuition on this issue is mixed since we have Mars with a very thin atmosphere, but Venus with a very thick atmosphere, neither having a very strong magnetosphere to protect them from solar winds
{ "domain": "astronomy.stackexchange", "id": 1424, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "planetary-atmosphere", "url": null }
ros, stampedtransform, transform ) at /usr/include/boost/bind/mem_fn_template.hpp:162 #5 operator() > >, boost::_bi::list1 >&> > ( function_obj_ptr=..., a0=DWARF-2 expression error: DW_OP_reg operations must be used either alone or in conjuction with DW_OP_piece. ) at /usr/include/boost/bind/bind.hpp:306 #6 operator() > > (function_obj_ptr=..., a0=DWARF-2 expression error: DW_OP_reg operations must be used either alone or in conjuction with DW_OP_piece. ) at /usr/include/boost/bind/bind_template.hpp:32 #7 boost::detail::function::void_function_obj_invoker1 > >, boost::_bi::list2, boost::arg > >, void, geometry_msgs::PointStamped_ > >::invoke (function_obj_ptr=..., a0=DWARF-2 expression error: DW_OP_reg operations must be used either alone or in conjuction with DW_OP_piece. ) at /usr/include/boost/function/function_template.hpp:153 #8 0x000000000042bb92 in boost::function1 > >::operator() (this=0x7fffd0016780, params=) at /usr/include/boost/function/function_template.hpp:1013 #9 ros::SubscriptionCallbackHelperT >, void>::call (this=0x7fffd0016780, params=) at /opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/subscription_callback_helper.h:180
{ "domain": "robotics.stackexchange", "id": 7272, "lm_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, stampedtransform, transform", "url": null }
ros, rosbridge, multiple, roslibjs, websocket Title: Multiple rosbridge_websocket nodes I'd like to run two rosbridge_websocket nodes - the only difference would be their names. What's the easiest way to do that? I was thinking that I could create my own ROS package based on the rosbridge_server package and modify the contents of the .launch file to assign appropriate node names. I'm not sure how to do this though or whether this is the right approach. Any help greatly appricated. Originally posted by Leonid on ROS Answers with karma: 163 on 2016-11-30 Post score: 1 If you want to reuse launch/rosbridge_websocket.launch, then you could probably get away with pushing both instances into their own namespaces. I haven't tried it, but something like: <launch> <include ns="bridge0" file="$(find rosbridge_server)/launch/rosbridge_websocket.launch"> <!-- use default port --> <arg name="port" value="9090" /> </include> <include ns="bridge1" file="$(find rosbridge_server)/launch/rosbridge_websocket.launch"> <!-- use other port --> <arg name="port" value="9091" /> </include> </launch> You can override any of the args in rosbridge_websocket.launch in the same way. Note that this will prefix all topics, services and actions that the rosbridge_websocket node creates/offers with the value in the ns attribute of the include tag. If you want to avoid using namespaces, you could just copy rosbridge_websocket.launch to a package of your own (in your workspace), and copy the relative entries while making sure to change the name attribute of the node tag that starts rosbridge_websocket. But note that this will not work if rosbridge_websocket creates any global topics, services or actions, as they will then clash with each other.
{ "domain": "robotics.stackexchange", "id": 26368, "lm_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, rosbridge, multiple, roslibjs, websocket", "url": null }
quantum-mechanics, hilbert-space, quantum-entanglement I'm looking for examples of entanglement in which the mechanism that creates the entanglement is explicit. The only example I can think of is Hong-Ou-Mendel interference creating NOON states like, $|2,0\rangle + |0, 2\rangle$. I get that generally identical possible outcomes can sometimes destructively interfere, but I'm looking for something a little bit more clear generally. In particular I'd like to build some intuition so that when I see am looking at given physical system I'll have an idea if entanglement could be generated. Any procedure in a quantum system can be described by a unitary operator $U$ (quantum evolution) and/or a projection operator $P$ (measurement). If you want to bring two isolated subsystems in a state $|\psi_1\rangle\otimes|\psi_2\rangle$ into an entangled state $|\psi\rangle$ you need to ask what type of unitary operator $U$ and/or projection operator $P$ you should use such that: $$ P\left(U\left(|\psi_1\rangle\otimes|\psi_2\rangle\right)\right)=|\psi\rangle $$ As an example, imagine two $1/2-$spin systems in an initial state $|\uparrow\rangle \otimes|\uparrow\rangle$, doing the following procedures:
{ "domain": "physics.stackexchange", "id": 45475, "lm_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, quantum-entanglement", "url": null }
automata-theory, turing-machines, regular-language, space-bounded Title: Do bounded-visit nondeterministic linear bounded automata recognize only regular languages? Do bounded-visit nondeterministic linear bounded automata recognize only regular languages? By a nondeterministic linear bounded automaton (nLBA) I mean a single-tape nondeterministic Turing machine where the input comes "padded" with endmarkers on both ends which can never be overwritten, and so that the head can never move out of the input region, "outside" the endmarkers. The LBA is bounded-visit if there is a number $k$ such that all runs on all inputs terminate and visit every cell of the tape at most $k$ times. Does such a machine recognize only regular languages? Hennie's result seems to say this only for deterministic machines, if I'm reading it right. Does the result hold for nondeterministic machines too? If yes, a reference would be appreciated. A bit overkill, but: this paper shows (among other nice things) that non-deterministic Hennie transducers realize exactly the class of non-deterministic MSO-definable transductions. The latter have regular domains.
{ "domain": "cstheory.stackexchange", "id": 3540, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "automata-theory, turing-machines, regular-language, space-bounded", "url": null }
c++, c++11, template, interface, polymorphism I think I will place all the setters under a namespace in a separate header. Of course any hint and improvement to this design is more than welcome. You said that you packed all the suggestions from the previous question, but there are still some pieces of advice that you did not integrate into your code. Here is how you can still improve your it: math.h legacy In your code, you are using the constant M_PI. While it will probably work on most of the compilers I know, this macro isn't defined anywhere in any C or C++ standard. The math.h/cmath constants are only a common POSIX extension. You should define your own math constant somewhere in order to avoid portability problems. Since it was the only feature from <cmath> you used, you can remove the include. Perfect forwarding There are many places where you should use std::forward to perfectly forward your arguments from a function to another. For example, you could turn this piece of code: template<typename T, typename S, typename ...Args> void apply(T *t, const S & setter, const Args &... args) { t->set(setter); apply(t, args...); } into this one: template<typename T, typename S, typename ...Args> void apply(T *t, const S & setter, Args &&... args) { t->set(setter); apply(t, std::forward<Args>(args)...); }
{ "domain": "codereview.stackexchange", "id": 6295, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c++, c++11, template, interface, polymorphism", "url": null }
• If $n=100$, then $m=0.5$, hence Condition $(1)$ satisfied, so AP is $\color{red}{\underbrace{-49,-48,\cdots -2,-1,0}_{50\text{ terms}},\underbrace{1,2,3,\cdots 48,49,50}_{50 \text{ terms}}}$ ($AP 3$) • For higher values of $n$, $0<m<0.5$ - not possible. Without reading other answers... this should tell you how an old computer programmer thinks, versus a real mathematician. First the obvious answer is the single integer 50. However, if negative numbers are allowed, then we can scoop up the sequence from -49 to 50 for 100 consecutive numbers. This is the longest possible sequence. If n is the starting number of a sequence and s is the number of consecutive numbers, then we end up with 50 = (n+0) + (n+1) + (n+2) +... + (n+s-1) 50 = ns + (s-1)(s)/2 This is helpful, maybe, as ns pretty much puts a box around the solution set. Since we know the nature of the rightmost term, we can tell that s is 10 or less. Consider the transformation if we multiply both sides by 2/s: 100/s = 2n + s - 1 The right side will always be an integer. Therefore, s must always divide 100 evenly. From above we know that s is between 1 and 10, so the only possible values for s are 1, 2, 4, 5, and 10. That reduces the problem to 5 single-degree-of-freedom equations. Let's do it.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9728307708274401, "lm_q1q2_score": 0.8584529740026536, "lm_q2_score": 0.8824278587245935, "openwebmath_perplexity": 340.1789331339958, "openwebmath_score": 0.9552640318870544, "tags": null, "url": "https://math.stackexchange.com/questions/2334607/the-sum-of-consecutive-integers-is-50-how-many-integers-are-there/2334733" }
gazebo Title: Casting shadows on textured meshes Using gazebo 1.3.1, objects do not cast shadows on textured objects. How to reproduce: start an empty world, add a coke can and a cube. The can casts shadows on the cube (and the ground), but the cube does not shadow the can (it shadows only the ground). Importance: I would like to use a texturized terrain with shadows on the ground. Originally posted by rasmus25 on Gazebo Answers with karma: 1 on 2013-01-16 Post score: 1 With the current version of Gazebo and the version of Ogre in Ubuntu, shadows will be cast on textured objects as long as the texture is not tiled. This will be fixed in the next version of Ogre. Originally posted by nkoenig with karma: 7676 on 2013-07-23 This answer was ACCEPTED on the original site Post score: 0
{ "domain": "robotics.stackexchange", "id": 2938, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "gazebo", "url": null }
forces, home-experiment Finally, we exit the dip at point E and once again have a resting stomach: Now for maximizing the "stomach drop feeling" (via acceleration / coasting / braking) If we acceleration between point A & point B, we add an additional sideways force onto our stomach spring. So not only does it "move upward", it will always move "backward" a little: We then coast / maintain speed from point B to point C, and then from point C to point D we decelerate / brake to make our stomach get a horizontal forward movement: That gives a final set of instructions as follows: Up to point A, maintain constant speed Point A -> B, accelerate Point B -> C, maintain constant speed Point C -> D, decelerate Point D -> onwards, accelerate back up to speed
{ "domain": "physics.stackexchange", "id": 61273, "lm_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, home-experiment", "url": null }
a = F/(M1+M2) = amax = µsg Fmax = µsg(M1+M2) // 3. Jun 17, 2009 Patta1667 Thank you RoyalCat. Here's the catch: The problem originally came in two parts, the first part being that a force F is applied to the upper block, all other components are the same. Intuitively I saw $$F_{max} = \mu M_1 g$$ in this new situation (both blocks sitting on a frictionless table, recall). The text gives $$M_1 = 4, M_2 = 5$$ (M1 on top), and says that a force of 27 N applied to the lower block causes them to slip. Thus, from the original formula $$F_{max} = \mu g (M_1 + M_2)$$ I calculated the appropriate $$\mu = 0.306$$. Then it asks for the maximum force which applied to the upper block, so plugging in $$\mu = 0.306$$ should give the text's answer. $$F_{max} = (0.306)(9.8)(4) = 12 N$$ but the "correct answer" is 21.6 N. Either my formula for the top-block force is wrong, we're both wrong for the bottom formula, or the text's answer is wrong, or a combination! What do you think? 4. Jun 17, 2009 RoyalCat Oh, I see it now. If you're pushing the top block at just enough force so that it doesn't slip, what forces are acting on the bottom block, and in what acceleration do they result? Now remember that the acceleration of the bottom block is shared by the top block, and since they are moving in tandem, the force acting on them needs to provide the acceleration for both of them. 5. Jun 17, 2009 Patta1667 Right, that was pretty silly of me. Thanks again - answer makes sense now.
{ "domain": "physicsforums.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9658995733060719, "lm_q1q2_score": 0.8090567710491767, "lm_q2_score": 0.8376199694135332, "openwebmath_perplexity": 460.4207078124687, "openwebmath_score": 0.6948283910751343, "tags": null, "url": "https://www.physicsforums.com/threads/block-friction.320381/" }
c++, algorithm, c++17 TemplateFinder::TemplateFinder(const std::string& pattern, char splitter) : pattern_size_(pattern.size()), splitter_(splitter) { root_ = std::make_shared<Node>(); auto [split_text, bias] = Split(pattern, splitter_); for (size_t i = 0; i < split_text.size(); ++i) { AddSubTemplate(split_text[i], bias[i]); } } /* Splitting the template to subtemplates */ auto TemplateFinder::Split(const std::string &text, char splitter) -> std::pair<std::vector<std::string>, std::vector<size_t>> { std::vector<std::string> split_text; std::vector<size_t> bias; //Position of subtemplates in the template std::string buffer; size_t counter = 0; for (char c : text) { if (c == splitter && !buffer.empty()) { bias.push_back(counter - buffer.size()); split_text.push_back(buffer); buffer = ""; } else if (c != splitter) { buffer += c; } ++counter; } if (!buffer.empty()) { bias.push_back(counter - buffer.size()); split_text.push_back(buffer); } return std::make_pair(split_text, bias); }
{ "domain": "codereview.stackexchange", "id": 39592, "lm_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, c++17", "url": null }
java, event-handling public void clearListeners() { this.bindings.clear(); this.registeredListeners.clear(); } public void removeListener(EventListener listener) { for (Entry<Class<? extends IEvent>, Collection<EventHandler>> ee : bindings.entrySet()) { Iterator<EventHandler> it = ee.getValue().iterator(); while (it.hasNext()) { EventHandler curr = it.next(); if (curr.getListener() == listener) it.remove(); } } this.registeredListeners.remove(listener); } public Map<Class<? extends IEvent>, Collection<EventHandler>> getBindings() { return new HashMap<Class<? extends IEvent>, Collection<EventHandler>>(bindings); } public Set<EventListener> getRegisteredListeners() { return new HashSet<EventListener>(registeredListeners); } } EventHandler.java public class EventHandler implements Comparable<EventHandler> { private final EventListener listener; private final Method method; private final Event annotation; public EventHandler(EventListener listener, Method method, Event annotation) { this.listener = listener; this.method = method; this.annotation = annotation; } public Event getAnnotation() { return annotation; } public Method getMethod() { return method; } public EventListener getListener() { return listener; }
{ "domain": "codereview.stackexchange", "id": 5130, "lm_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, event-handling", "url": null }
graphs, sampling Title: Uniformly sampling from cycles of a graph I was wondering if, given an arbitrary cycle basis (that's complete, e.g. every cycle in the graph can be expressed as the $\mathbb{Z}/2\mathbb{Z}$ sum of elements from the basis) of some graph $G$, is there some way of sampling all cycles uniformly? I'm not able to find papers on it, and I was wondering if anyone had any results on this. Exponential-time algorithm One (slow) approach is to rejection sampling. Let $c_1,\dots,c_k$ be the cycle basis. Then we obtain an isomorphism $\varphi : (\mathbb{Z}/2\mathbb{Z})^k \to \mathcal{E}$, where $\mathcal{E}$ is the set of Eulerian subgraphs of $G$, given by $$\varphi(\alpha_1,\dots,\alpha_k) = \alpha_1 \cdot c_1 + \cdots + \alpha_k \cdot c_k.$$ This gives us a way to sample uniformly at random from the set of Eulerian subgraphs. Note that the set $\mathcal{C}$ of simple cycles of $G$. Note that every simple cycle is an Eulerian subgraph, i.e., $\mathcal{C} \subseteq \mathcal{S}$. Thus, a simple procedure to sample uniformly at random from $\mathcal{C}$ is: Sample uniformly at random from $\mathcal{E}$, to get a subgraph $e$. (Namely, pick $\alpha_1,\dots,\alpha_k$ uniformly at random and set $e = \varphi(\alpha_1,\dots,\alpha_k)$.) If $e$ is a simple cycle, output it. Otherwise, go back to step 1.
{ "domain": "cs.stackexchange", "id": 7129, "lm_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, sampling", "url": null }
reference-request, periodic-trends, atomic-radius Title: Covalent atomic radii: oxygen vs nitrogen Many books state that $R_\ce{N} > R_\ce{O}$ which is in accordance with the general trend. However, some books say that $R_\ce{O} > R_\ce{N}$ because of repulsion caused by pairing of electrons. Which one is correct and should be followed? Older version of NCERT, cengage, arihant and JD Lee state the latter, while the newer version of NCERT, Wikipedia and many websites say the former. Why was the theory discarded? Note: van der Waal's radii follow the general trend. The van der Waals radius of nitrogen is larger than that of oxygen, and has been calculated as such for quite a long time. $$ \begin{array}{lll} \hline \text{Reference} & R_\ce{O} & R_\ce{N} \\ \hline \text{Pauling, 1939} & 1.40 & 1.5 \\ \text{Bondi, 1964} & 1.52 & 1.55 \\ \text{Zefirov, 1974} & 1.29 & 1.50 \\ \text{Gavezzotti, 1983–1999} & 1.40 & 1.50 \\ \text{Batsanov, 1995} & 1.51 & \\ \text{Wieberg, 1995} & 1.5 & 1.6 \\ \text{Rowland, 1996} & 1.58 & 1.64 \\ \hline \end{array} $$ As is evident from the table, $R_\ce{N} > R_\ce{O}.$ An interactive webpage of this reference can be seen here, which has the van der Waals radii of quite a few other elements as well. Edit:
{ "domain": "chemistry.stackexchange", "id": 14423, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "reference-request, periodic-trends, atomic-radius", "url": null }
cpu, assembly Title: Are EAX , EBX registers 64 bit in length in modern processors The EAX, EBX and ECX registers on a cpu are they 64 bits for a 64-bit cpu ? No, they still refer to a 32bit register. But they are part of 64bit registries RAX, RBX and RCX. The main reason for this is backward compatibility.
{ "domain": "cs.stackexchange", "id": 17978, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "cpu, assembly", "url": null }
python s * n or n * s equivalent to adding s to itself n times so you don't need itertools.repeat, you can just multiply. Revised code with doctests: def zeros(length): """Create and return a list of zeros with the given length. >>> zeros(2) [0, 0] >>> zeros(0) [] """ return [0] * length The doctests can be run using python -m doctest program.py.
{ "domain": "codereview.stackexchange", "id": 17828, "lm_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 }
c++ Triangle TranslateAndRotate(const float rotationAngle, olc::vf2d offset) { Triangle tri; tri.p1.x = cosf(rotationAngle) * p1.x - sinf(rotationAngle) * p1.y + offset.x; tri.p1.y = sinf(rotationAngle) * p1.x + cosf(rotationAngle) * p1.y + offset.y; tri.p2.x = cosf(rotationAngle) * p2.x - sinf(rotationAngle) * p2.y + offset.x; tri.p2.y = sinf(rotationAngle) * p2.x + cosf(rotationAngle) * p2.y + offset.y; tri.p3.x = cosf(rotationAngle) * p3.x - sinf(rotationAngle) * p3.y + offset.x; tri.p3.y = sinf(rotationAngle) * p3.x + cosf(rotationAngle) * p3.y + offset.y; return tri; } }; class PlayGround : public olc::PixelGameEngine { public: PlayGround() { sAppName = "PlayGround"; } private: bool debug = true; private: Triangle agent1; float rotationAngle1 = 0.0f; float sensoryRadius1 = 50.0f; float fov1 = PI; float agent1Speed = 120.0f; float directionPointDistance1 = 60.0f; olc::vf2d position1 = { 300.0f, 150.0f }; private: olc::Pixel offWhite = olc::Pixel(200, 200, 200); private: float pointsSpeed = 10.0f; int nPoints = 1000; std::vector<std::unique_ptr<Point>> points; private:
{ "domain": "codereview.stackexchange", "id": 41251, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c++", "url": null }
performance, c, strings, search, rags-to-riches Function ran in 198460 clock cycles Produced output: string Function ran in 448832 clock cycles Produced output: this is not a test Program ended with exit code: 0 The only thing I would like to be reviewed in this question is the speed of the rmSubstr function. Other comments are welcome, but alone will not be accepted. Also, please include the output of the program with your answer so that I can get a feeling for how much my function was improved. In surveying these answers I surmised that the best solution would be to do partial memory copies rather than to-end-of-line copies. This would pay dividends in the event of multiple matches. As a result, I put together this method: void rolfl(char *str, const char *toRemove) { if (NULL == (str = strstr(str, toRemove))) { // no match. //printf("No match in %s\n", str); return; } // str points to toRemove in str now. const size_t remLen = strlen(toRemove); char *copyEnd; char *copyFrom = str + remLen; while (NULL != (copyEnd = strstr(copyFrom, toRemove))) { //printf("match at %3ld in %s\n", copyEnd - str, str); memmove(str, copyFrom, copyEnd - copyFrom); str += copyEnd - copyFrom; copyFrom = copyEnd + remLen; } memmove(str, copyFrom, 1 + strlen(copyFrom)); }
{ "domain": "codereview.stackexchange", "id": 10298, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "performance, c, strings, search, rags-to-riches", "url": null }
This means that the "oblique" asymptote is $y = \sqrt{x + 1}$. • $y = \sqrt{x + 1}$ is a curvilinear asymptote. It is not oblique since an oblique asymptote is a line. – N. F. Taussig Sep 30 '14 at 9:32 • @N.F.Taussig Hence why I put quotes around the term oblique...this function asymptotes to the function $f(x) = \sqrt{x}$ as I stated--it doesn't exactly asymptote to that, but it essentially does. – Jared Sep 30 '14 at 9:32 • I knew you understood the question. I just wanted to make sure that the person who posted the question understood why you put the quotes there. – N. F. Taussig Sep 30 '14 at 9:33 A necessary condition for the function $f$ to have an oblique asymptote at $\infty$ is that $$\lim_{x\to\infty}\frac{f(x)}{x}$$ exists, is finite and is non zero. If the oblique asymptote exists, then this limit is its slope. It mustn't be zero, because otherwise it wouldn't be oblique in the first place. If an oblique asymptote exists, with equation $y=mx+q$ ($m\ne0$), then, by definition, $$\lim_{x\to\infty}(f(x)-mx-q)=0$$ so also $$\lim_{x\to\infty}\frac{f(x)-mx-q}{x}=0$$ and then $$\lim_{x\to\infty}\left(\frac{f(x)}{x}-m\right)=0$$ because, of course, $\lim_{x\to\infty}\frac{q}{x}=0$.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9825575188391108, "lm_q1q2_score": 0.8331771023898595, "lm_q2_score": 0.847967764140929, "openwebmath_perplexity": 369.75495133434436, "openwebmath_score": 0.9491041898727417, "tags": null, "url": "https://math.stackexchange.com/questions/952304/does-the-function-fracx-sqrt1x-have-an-oblique-asymptote" }
qiskit, quantum-gate, linear-algebra $$=\sum_{x_1,y_1,x_2,y_2,x_3,y_3...=\{0,1\}} |x_1x_2x_3...\rangle\langle y_1y_2y_3...|$$ A decomposition with nice properties The above probably doesn't quite answer the essence of your question. The problem is that there are many ways to decompose a unitary into sums of tensor products, but most of them won't give the nice simple decomposition of the RZZ gate that you want. So more needs to be specified. Do you want to write the gate as a sum over projection operators, like $U = \sum_{i={0,1}} |i\rangle\langle i| U_i$? That's not possible in general (consider the swap gate). Do you want a decomposition with the minimum number of terms? That sounds tricky, especially the n-qubit case. Probably worth a separate question! It's not too bad to say something useful about the two-qubit case, using the Cartan decomposition. Any two-qubit unitary can be written as $$U = U_1 \otimes U_2 \exp(-i(c_x X\otimes X + c_y Y\otimes Y + c_z Z\otimes Z)) V_1^\dagger \otimes V_2^\dagger$$ If you consider the Taylor expansion of the exponential term, you can see that it will only contain four terms when written in the Pauli basis: $II$, $XX$, $YY$ and $ZZ$. (I suspect that this is the minimal general decomposition, but I'm not sure). For the $R_{ZZ}$ gate, only $c_z$ is non-zero and $U$ only contains $II$ and $ZZ$ terms. The same applies for the $R_{XX}$ and $R_{YY}$ terms, and a bit of algebra gives you the expressions at the top. For more details on the Cartan decomposition, see this paper.
{ "domain": "quantumcomputing.stackexchange", "id": 4711, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "qiskit, quantum-gate, linear-algebra", "url": null }
quantum-mechanics, hilbert-space, schroedinger-equation, definition, scattering In cases where the potential goes to zero at infinity, which is the majority case in everyday life, then we have that: $$E\lt 0\;\implies\;\text{bound state},$$ $$E\gt 0\implies\;\text{scattering state}.$$ Even if a particle looks like it is trapped in a well as in example, I, if the potential doesn't grow to infinity, then the particle will leak by tunneling and the problem becomes a scattering problem in the technical sense. If you can get a hold of Griffith's book then take a look at section 2.5, it should clear up all of your doubts.
{ "domain": "physics.stackexchange", "id": 99990, "lm_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, schroedinger-equation, definition, scattering", "url": null }
quantum-mechanics, thermodynamics, statistical-mechanics, pressure, gas Intuitively you can think of it in this way. The pressure in a particular direction is proportional to the average kinetic energy of particles in that direction. If it is possible to expand one dimension of the box (say the $x$-direction) without causing a shift in energy levels then the average kinetic energy in that direction will decrease, causing an anisotropic decrease in pressure. However, the interaction processes work so as to divide the total energy equally between different degrees of freedom (this is a consequence of the equipartition theorem, which is a good rule-of-thumb as long as the average energy spacing between levels is much less than $k_B T$). Hence during expansion the interactions will transfer energy from the $y$ and $z$ directions to the $x$ direction, ensuring the average kinetic energies (and thus the pressures) remain the same in all directions.
{ "domain": "physics.stackexchange", "id": 35109, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "quantum-mechanics, thermodynamics, statistical-mechanics, pressure, gas", "url": null }
rviz Title: What is the axis system followed in rviz? This is very basic question , sorry for asking but i can't find the information .. What is the Grid plane in rviz , is it XY or YZ or ZX ? Originally posted by rajat on ROS Answers with karma: 175 on 2011-07-17 Post score: 0 The default plane is XY, but you can change this. There is extensive documentation on the rviz wiki page, specifically http://www.ros.org/wiki/rviz/DisplayTypes/Grid in the Plane section. Originally posted by makokal with karma: 1295 on 2011-07-17 This answer was ACCEPTED on the original site Post score: 4 Original comments Comment by rajat on 2011-07-17: Ohk Great!! Thanks .
{ "domain": "robotics.stackexchange", "id": 6164, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "rviz", "url": null }
php, performance, css Title: Quick CSS style generator One day, I was thinking: Wouldn't it be nice to set a class and have all the styles defined? And that is exactly what I did: a PHP file that generates CSS with pre-defined styles. So, for fun, I built the following: <?php if( @is_file($file = basename(__FILE__, '.css.php') . '-config.php' ) ) { $config = (array)include( $file ); } else { $config = array( 'class'=>'color', 'force'=>true, 'text'=>true, 'border'=>true, 'back'=>true, 'shadow'=>true, 'sizes'=>true, 'styles'=>true, 'send_header'=>true, 'custom'=>null ); } if( isset( $config['send_header'] ) && $config['send_header'] && !headers_sent() ) { header('Content-type: text/css'); } $colors = array( 'black', 'red'=>array('dark','indian','mediumviolet','orange','paleviolet'), 'green'=>array('dark','light','forest','yellow','lawn','lime','pale','darkolive','sea','darksea','lightsea','mediumsea','spring','mediumspring'), 'blue'=>array('alice','cadet','cornflower','dark','darkslate','deepsky','dodge','light','lightsky','lightsteel','medium','mediumslate','midnight','powder','royal','sky','slate','steel'), 'white' );
{ "domain": "codereview.stackexchange", "id": 14096, "lm_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, performance, css", "url": null }
# Velocity and acceleration in a frictionless circular loop 1. Aug 4, 2013 ### KKiefhaber This is a problem I encountered while studying/practicing for my upcoming MCAT exam: 1. The problem statement, all variables and given/known data A 1kg block slides down a ramp and then around a circular loop of radius 10m. Assume that all surfaces are frictionless. 1)What is the minimum height of the ramp required so that the block makes it all the way around the loop without falling? (solved) 2)How fast does the block need to be going at the bottom of the ramp so that the acceleration of the block at the top of the loop is 4g? (stuck) 2. Relevant equations $$U=mgh$$ $$KE={1}/{2}mv^2$$ $$F_(net)=ma_y=mg+F_N$$ 3. The attempt at a solution In the initial problem, I set $$F_N=0$$ because that would be the point at which the block would begin to fall off the loop, allowing me to find the minimum height. Using $$a_c$$ for $$a_y$$ I got that $$v=\sqrt{gr}.$$ Using energy equations to set the potential energy at the top of the track equal to the (potential energy+kinetic energy) found at the top of the loop, I found that the minimum height of the ramp would be 25m. However, for problem 2, the solutions I have tried have been incorrect. Given that the desired acceleration of the block is $$4g$$ I first set $$4g=\frac{v^2}{r}$$ This gives v=19.95m/s which is incorrect according to the answer key provided (v=28m/s). Next I attempted setting $$ma_c=mg+F_N$$ or $$\frac{mv^2}{r} = mg+F_N$$ but couldn't get much further.
{ "domain": "physicsforums.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9702399034724605, "lm_q1q2_score": 0.8167728424304769, "lm_q2_score": 0.841825655188238, "openwebmath_perplexity": 272.27006861723095, "openwebmath_score": 0.5451053977012634, "tags": null, "url": "https://www.physicsforums.com/threads/velocity-and-acceleration-in-a-frictionless-circular-loop.704260/" }
thermodynamics, thermal-radiation, thermal-conductivity Title: What can I do to be invisible for the IR-camera on board of a police helicopter? I think we all have seen the images of crime suspects, running in the dark of the night to escape the police, made with the help of infrared cameras. What can I do to be invisible to these cameras when I run from a bank I just robbed, through gardens, jumping over fences, but not running through long tunnels, or through woods with densely packed trees? When I run without having done anything (except robbing the bank) I show up on the screens connected to these cameras as a highlighted "blob" looking remotely human. Should I wear a suit filled with ice, enclosing my entire body? Or would that also be visible, because in that case, I can imagine you see a dark human blob on the screen because the temperature of that suit is lower than my surroundings (unless it's a cold winter night, but let's assume it's a normal summer night or winter night if I lived on the southern hemisphere). Should I wear a suit with excellent heat-isolation enclosing my body and which I've prepared in such a way that it has the same temperature as the air that night? Keeping something (a big heat-isolating plate) above my head seems unpractical to me, and some parts of my body will certainly show up on the screen helicopter with the cops in it. What else can I do to be invisible while still being able to run freely? By the way, I'm not planning anything... Military gear is typically pretty good at trumping police gear. BAE systems recently came out with an adaptive camouflage system that can make a tank's IR signature look like anything they please The next best approach is probably confusion. There's a long history of using Craigslist to put a "want ad" for people dressed exactly like you, then you rob a bank and the police don't know who to go after. Failing that, an IR camera picks up heat, so anything highly insulative will be effective. My recommendation is something fuzzy, or made of foam. The fuzzy things tend to stay very close to room temperature What could possibly go wrong.
{ "domain": "physics.stackexchange", "id": 45295, "lm_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, thermal-radiation, thermal-conductivity", "url": null }
= \\ \frac{1}{2\pi^2}\int_{0}^{2x\pi} [2\pi(2x-1)+\theta]d\theta = \frac{1}{2\pi^2}[(2\pi)(2x-1)(2x\pi)+2x^2\pi^2] =5x^2-2x.$$ Thus, I obtain $b(x)=1-(5x^2-2x)=-5x^2+2x+1.$ The result is much different to the the goal.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9904406012172462, "lm_q1q2_score": 0.8143295032213594, "lm_q2_score": 0.8221891370573388, "openwebmath_perplexity": 88.04336067080047, "openwebmath_score": 0.9412232041358948, "tags": null, "url": "https://math.stackexchange.com/questions/2237562/compute-the-probability-that-at-least-one-of-the-angles-of-the-triangle-abc-ex" }
python class coordinate: def __init__(self,x,y,z): self.x=x self.y=y self.z=z class verticies_structure: def __init__(self): self._verts=[] def add_vert(self,x,y,z): self._verts.append(coordinate(x,y,z)) def get_coords(self,indexes): return self._verts[indexes[0]:indexes[1]] class camera: def __init__(self,w,h,render_distance,fov=45): self.fov=360-fov self.w=w self.h=h self.x=0 self.rx=0 self.cx=0 self.y=0 self.ry=0 self.cy=0 self.z=0 self.rz=0 self.cz=0 self.render_distance=render_distance def false(f,value): if value==f: value=f+0.01 return value def inf360(value): if value>359:value=0 if value<0:value=359 return value class mesh(object): def __init__(self,file_obj,cam): self.cam=cam self.verts=verticies_structure() self.source=file_obj self.read_object_file() self.verts=verticies_structure() size=100 for x in range(size): for z in range(size): self.verts.add_vert(x-size//2,0,z-size//2) self.w2s_vect=numpy.vectorize(self.w2s) self.array_verts=numpy.array(self.verts._verts) def w2s(self,coord): cam=self.cam
{ "domain": "codereview.stackexchange", "id": 44349, "lm_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 }
$$T(z) = z \exp\left(\sum_{\ell\ge 1} \frac{T(z^\ell)}{\ell}\right).$$ It was proved at the following MSE link using this functional equation that these have recurrence $$t_{n+1} = \frac{1}{n} \sum_{q=1}^{n} t_{n+1-q} \left(\sum_{\ell|q} \ell t_{\ell}\right).$$ Using the cycle index $$Z(D_q)$$ of the dihedral group we have $$U(z) = \sum_{q\ge 3} Z(D_q; T(z)).$$ Therefore the number of non-isomorphic connected unicyclic graphs is $$U_n = [z^n] \sum_{q=3}^n Z\left(D_q; \sum_{p=1}^n t_p z^p\right).$$ This yields the sequence $$0, 0, 1, 2, 5, 13, 33, 89, 240, 657, 1806, 5026, 13999, \\ 39260, 110381, 311465, 880840, 2497405, 7093751, 20187313, \ldots$$ with two leading zeros because the smallest cycle is on three nodes. The data point to OEIS A001429 where the procedure is confirmed. In particular we get for six nodes $$\bbox[5px,border:2px solid #00A000]{ U_6 = 13.}$$ Remark. The cycle index of the cyclic group is given by $$Z(C_q) = \frac{1}{q} \sum_{k|q} \phi(k) a_k^{q/k}$$ and of the dihedral group
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9828232894783426, "lm_q1q2_score": 0.857363304933064, "lm_q2_score": 0.8723473630627235, "openwebmath_perplexity": 632.1313096455588, "openwebmath_score": 0.7259795069694519, "tags": null, "url": "https://math.stackexchange.com/questions/2992385/non-isomorphic-connected-unicyclic-graphs" }
electrostatics, electricity, charge, potential, equilibrium What if that other point is already neutral? For example if you connect a neutral (uncharged) metal piece to a negatively charged metal piece. Will no charges move to the neutral piece, since there is no net charge to neutralize here? Of course it will - the charge will spread out as much as it can. Until not the charge, but the potential at any point is the same. Before connection, there are excess charges (electrons) caught at the charged piece. These are pushing each other as far away as possible - they all repel. They can't move beyond the objects surface, though, because the air is not conducting. But when the other neutral but conducting object is connected, they can move over there. They are pushed over there due to the repulsion of the others - and there is no (or at least a smaller) repulsion from the neutral piece. The push is stronger towards the neutral piece than away from it. And so, the move. This is potential. That charges are pushed away from a point is what we call a potential (potential energy per charge). When there is a potential difference between two points, it means that the charge is being pushed more towards than away from a point. And so, the charge will move if it can. And it can when there is a connection between the two points. It will not want to move if there is no potential difference. In the same way, a ball on a shelf will not want to move sideways, since this is a point of equal (gravitational) potential. It will only want to move downwards, towards a decrease in potential. Indeed, the motion of charges is caused by the amounts of charge present, but we are not talking about charge being neutralized. Rather about electric forces being balanced - in other words, about electric potentials being balanced.
{ "domain": "physics.stackexchange", "id": 43949, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "electrostatics, electricity, charge, potential, equilibrium", "url": null }
the solution will satisfy the boundary condition. For parabolic equations, the boundary @ (0;T) [f t= 0gis called the parabolic boundary. Solve a 1D wave equation with absorbing boundary conditions. Boundary Condition Types. Within the context of the finite element method, these types of boundary conditions will have different influences on the structure of the problem that is being solved. The setup of regions, boundary conditions and equations is followed by the solution of the PDE with NDSolve. The is assumed to be a bounded domain with a boundary. x W and x B are the intersection point and the nearest fluid node along the intersection direction, respectively. Approximate solution for an inverse problem of multidimensional elliptic equation with multipoint nonlocal and Neumann boundary conditions, Vol. TPherefore, we impose the additional condition that the net heat flux through the surface vanish, (ds~ i. The first number in refers to the problem number in the UA Custom edition, the second number in refers to the problem number in the 8th edition. One-dimensional Heat Equation Description. some given region of space and/or time, along with some boundary conditions along the edges of this domain. The Dirichlet boundary condition is relatively easy and the Neumann boundary condition requires the ghost points. Mixed boundary condition itself is a special example of Robin boundary condition by taking the coefficient = ˜ D and = ˜ N. zero derivatives, at $$x=0$$ and $$y=0$$, as illustrated in figure 79. function Y=heattrans(t0,tf,n,m,alpha,withfe) # Calculate the heat distribution along the domain 0->1 at time tf, knowing the initial # conditions at time t0 # n - number of points in the time domain (at least 3) # m - number of points in the space domain (at least 3) # alpha - heat coefficient # withfe - average backward Euler and forward Euler to reach second order # The equation is # # du. A boundary condition-enforced-immersed boundary-lattice Boltzmann flux solver is proposed in this work for effective simulation of thermal flows with Neumann boundary conditions. This article is organized as follows. and they too are homogeneous only if Tj (I. Two-Dimensional Laplace and Poisson Equations In the previous chapter we saw that when solving a wave or heat equation it
{ "domain": "danieledivittorio.it", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9865717460476701, "lm_q1q2_score": 0.8019519313003395, "lm_q2_score": 0.8128673201042492, "openwebmath_perplexity": 606.8482181438628, "openwebmath_score": 0.8299397826194763, "tags": null, "url": "http://danieledivittorio.it/vube/neumann-boundary-condition-heat-equation.html" }
parsing, go // will try to match consecutive productions against // a token stack, keeping track of the length of each // match. if every consecutive rule matches, return // the length of every match added to the base pointer // originally passed to this function func Consecutive(s TokenStack, p int, rules ...Production) int { var match_len = 0 for _, rulei := range rules { if p1 := rulei(s, p+match_len); M(p1) { match_len += p1 - (p + match_len) } else { return NoMatch } } return p + match_len } // return a production func that will // match a given token value func V(v string) Production { return func(s TokenStack, p int) int { if len(s) > p && string(s[p].Value) == v { return p + 1 } return NoMatch } } // return a production func that will // match a given token type func T(t int) Production { return func(s TokenStack, p int) int { if len(s) > p && s[p].Type == t { return p + 1 } return NoMatch } } // a function to conveniently check the // return value of a production for a match func M(p int) bool { return p > NoMatch } Go fmt First off, always go fmt your source code. The best thing about Go is that it always looks the same. Godoc Follow the godoc standard for comments. When commenting a function, start with the function name, capitalized, and end with a dot. Use proper grammar (like capital letter after punctuation). This makes automatically generated documentation look great, and further normalizes how Go code looks. TokenStack represents the input stack. is a good first sentance to start with. (Actually, maybe TokenStack should be named InputStack, if that's what it really is?) Const Using iota to assign a single value like you are doing looks wierd. It's not that clear what you are doing. const T_NUM = 1 or const T_NUM = iota+1
{ "domain": "codereview.stackexchange", "id": 19746, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "parsing, go", "url": null }
And when we take s samples and combine them, that will cancel the s, and I think it'll knock that out when we combine the s samples. OK. OK. Now what? Now, we get to choose those probabilities. And how are we going to choose them? What will be the best choice? Here is the expression for the variance. Yeah, this is good. This is good. Stay with me for now, and you will be saying to yourself, there's some steps there that I didn't see fully, and I want to check. And I agree. But let me say that we get to that point, and this is a fixed number. So it's C that we would like to make small, and that's our final job. This was true for any choice of the probabilities P. Well, oh, yeah, sorry. Yeah, yeah. So I want to-- this still had in it a probability. Yeah. What do I want to do? I want to show that that was the best choice, that this was the best choice. Yeah, yeah. I want to show that that's the best choice, that the choice of weights of probabilities, based on length of a times the length of b-- of course, it sounds reasonable, doesn't it? We want to-- for big columns and big rows, we want to have a higher probability to choose those. But is the probability proportional to the length of both, or should it be proportional to the 10th power or the square root or what? That's what our final step of optimizing the P. So this is the final step. Optimize the probabilities, P1 to P2, I guess, no, P1 to Pr, for the r rows, r columns of a and r rows of b, subject to-- they have to add up to 1. And what do I mean by optimize? I mean minimize. This optimize means minimizing this expression, C. So aj bj transpose.
{ "domain": "mit.edu", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9871787827157817, "lm_q1q2_score": 0.8204867739895384, "lm_q2_score": 0.8311430394931456, "openwebmath_perplexity": 531.7775349371691, "openwebmath_score": 0.8814080357551575, "tags": null, "url": "https://ocw.mit.edu/courses/mathematics/18-065-matrix-methods-in-data-analysis-signal-processing-and-machine-learning-spring-2018/video-lectures/lecture-13-randomized-matrix-multiplication/" }
quantum-mechanics, wavefunction, heisenberg-uncertainty-principle, measurement-problem, wavefunction-collapse The same applies the other way round. If we collapse it into a momentum eigenfunction, an endlessly repeating wave, then to build this wave from the spike functions, we find we need to add up an infinite amount of them, and so the particle could be anywhere! Generally speaking, the more position eigenstates we need to describe a wavefunction, the fewer momentum eigenstates we'll need. Vice versa is also true. This is the uncertainty principle. EDIT: It would be good if you could indicate your education background, e.g. knowledge of maths/physics, so we could direct you to further resources, as you clearly could go a step further than the app you're using now.
{ "domain": "physics.stackexchange", "id": 40722, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "quantum-mechanics, wavefunction, heisenberg-uncertainty-principle, measurement-problem, wavefunction-collapse", "url": null }
magnetic-fields, conservation-laws, magnetic-moment, magnetostatics $$\nabla \times \mathbf E =-\frac{\partial}{\partial t} \mathbf B\tag3$$ $$\nabla \times \mathbf B =\mu_0 \mathbf J+ \epsilon_0\mu_0\frac{\partial}{\partial t} \mathbf E \tag4$$ Take the divergence of (4) and use (1) to get the continuity equation for the charge $$\nabla \cdot \mathbf J = - \frac{\partial}{\partial t}\rho \tag5$$ The continuity equation has nothing to do with statics, it holds always. In the case of electrostatics as $\partial E/\partial t =0$, the continuity equation becomes $\partial \rho/\partial t =0$. Which in turns means $\nabla \cdot \mathbf J=0$. Now let us replace $\mathbf B=\mu_0(\mathbf H+\mathbf M)$, we get $$\nabla \cdot \mathbf E =\rho/\epsilon_0 \tag1$$ $$\nabla \cdot \mathbf H =-\nabla \cdot \mathbf M \tag6$$ $$\nabla \times \mathbf E =-\mu_0\frac{\partial}{\partial t} \mathbf M-\mu_0\frac{\partial}{\partial t} \mathbf H \tag7$$ $$\nabla \times \mathbf H = \mathbf J-\nabla \times \mathbf M+ \epsilon_0\frac{\partial}{\partial t} \mathbf E \tag8$$ these new magnetic equations look more symmetric between $E$ and $H$, specially if we define $\rho_m=\nabla \cdot \mathbf M$ and $\mathbf J_m=\nabla \times \mathbf M$. We get $$\nabla \cdot \mathbf E =\rho/\epsilon_0 \tag1$$
{ "domain": "physics.stackexchange", "id": 84095, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "magnetic-fields, conservation-laws, magnetic-moment, magnetostatics", "url": null }
quantum-field-theory, scattering, feynman-diagrams, perturbation-theory, greens-functions Title: Connected parts of Feynman diagrams and Green functions I have a doubt about the following formula (label (1)) $\langle \Omega | T \{ \phi(x) \phi(y) \} | \Omega \rangle = \lim_{t\rightarrow \infty (1-i \epsilon)} \frac{ \langle 0 | T [ \phi_i(x) \phi_i(y) \exp \{ -i \int_{-t}^{t} dt V(t) \} ] | 0 \rangle}{\langle 0 | U(t,-t) | 0 \rangle}$ in perturbation theory, where $H=H_0 + V$, $|\Omega \rangle$ is $H$ ground state, $| \ 0 \rangle $ is $H_0$ ground state, $V$ a weak perturbation so that $\langle \Omega | 0 \rangle \neq 0$, $T[]$ is the time-ordered product and $\phi_i(x)$ denotes the scalar quantum field in the interaction picture. In the weak interaction and $t \rightarrow \infty$ approximations, it is found that $| \Omega \rangle$ can be obtained from the ground state of the free hamiltonian through a time evolution, i.e. $| \Omega \rangle = \lim_{t\rightarrow \infty (1-i \epsilon)} (e^{-iE_0 t} \langle \Omega | 0 \rangle )^{-1} e^{-iHt} | 0 \rangle$, where $ H_0 | \Omega \rangle =E_0 | \Omega \rangle $. In Peskin-Schroeder it is explained how the denominator leads to the exclusion of the disconnected parts of Feynman diagram. Now, my doubt is: if the (n-points) Green function is given by
{ "domain": "physics.stackexchange", "id": 42850, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "quantum-field-theory, scattering, feynman-diagrams, perturbation-theory, greens-functions", "url": null }
newtonian-mechanics, kinematics Title: According to Newton's third law, why don't Action and Reaction make equilibrium? According to Newton's third law, Action and Reaction are equal and in opposite direction. If both forces are equal and in opposite direction then why they don't make equilibrium and void the effect of force? Because the forces act on different objects. If you write it as $F_{AB}=-F_{BA}$, the first term is object $A$ acting on $B$ and vice versa for the second.
{ "domain": "physics.stackexchange", "id": 9536, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "newtonian-mechanics, kinematics", "url": null }
java, beginner, math-expression-eval Comment your code. Don't explain what it does. For example, // Calculating String output = Calculating.calculating(stringForProcessing); this one is pretty redundant. The code is self-explanatory. Or at least should be (again, split it into multiple methods). So don't explain what. Explain why. //checking value for negativity if ((workingString.charAt(position) == '-') && (position == 0 || workingString.charAt(position - 1) == '-' || workingString.charAt(position - 1) == '+' || workingString.charAt(position - 1) == '*' || workingString.charAt(position - 1) == '/')) { So this one checks for negativity. Cool. That comment should have been a method name private static boolean checkNegative(String workingString, int pos). Or something similar. The comment? Not needed. What I don't understand (usually until I dive really deep into the code) is why is the condition so long and why is it checking previous characters, too. That should be commented: // checking previous chars, because of ... Cache often used values. If you wrote workingString.charAt(position - 1) four times in a condition, you probably should have used char previousChar = workingString.charAt(position - 1); And then use this cached value in your condition. Your lines will be shorter, your code will be more clear and faster. Same problem: if (Float.valueOf(result) == Math.floor(Float.valueOf(result))) { result = Integer.toString(Math.round(Float.valueOf(result))); } return result; Use: float numResult = Float.valueOf(result); if (numResult == Math.floor(numResult)) { result = Integer.toString(Math.round(numResult)); } return result;
{ "domain": "codereview.stackexchange", "id": 4217, "lm_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, math-expression-eval", "url": null }
newtonian-mechanics, earth Title: How long would a lever have to be to move the planet Earth? Give me a lever long enough and a fulcrum on which to place it, and I shall move the world. -Archimedes How long would that lever have to be? That is to say, how long a lever would be needed on Earth, to lift a sphere with the mass of Earth if a human of average size were to sit on the other side of the lever? The mass of Earth is $6\times10^{24}kg$. If Archimedes can lift 60 kg, he would need a lever with an arm ratio of $10^{23}:1$. So if the short arm is one meter long, the lever length will be $10^{23}$ meters plus one. Also, note that he would have to push the lever for $10^{20}$ meters to shift the Earth just by one millimeter.
{ "domain": "physics.stackexchange", "id": 5250, "lm_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, earth", "url": null }
php, beginner, json //updater function updater(){ $now = strtotime('now'); //<--store current unix timestamp $stat = json_decode(file_get_contents('wp-content/themes/World-of-Warcraft-New/includes/stat.json'),true);//<--open updater status file $opts =stream_context_create(array( 'http' => array( 'timeout' =>3, 'user_agent'=> "The WarCraft Call Board - http://swcallboard.com"))); if ($now > $stat['update'] && $stat['heath']=="alive" ){// <--check if currnet timestamp is greater than last updated timestamp and if no errors recorded $file = file_get_contents("https://wowtoken.info/wowtoken.json", 0, $opts); //<--grab remote file if check clears if($file){ rename("wp-content/themes/World-of-Warcraft-New/includes/token.json", "wp-content/themes/World-of-Warcraft-New/includes/back.json");//<-creates backup file file_put_contents("wp-content/themes/World-of-Warcraft-New/includes/token.json",$file );//<--writes remote file data to local file $stat['update']= strtotime('+20 minute');//<-- sets the "update" value of status file to 20mins. from now file_put_contents("wp-content/themes/World-of-Warcraft-New/includes/stat.json",json_encode($stat));//<--writes new values to status file } } } //erorr catchers
{ "domain": "codereview.stackexchange", "id": 17762, "lm_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, beginner, json", "url": null }
This is how i do it: First $dx=(a-a\cos{t})dt$ $dy=a\sin{t}dt$ So now i include all of that into the integral. But i don't know how to determine the borders. It can be seen from the picture that if i want to integrate until the first arc, i should use limits from 0 to 2*r*pi or in my case to 2*a*pi. But those would be the limits if i would integrate with dx. So how do i find the limits when integrating with dt? 6. Originally Posted by Pinsky Let's say we use a cykloide, and it is already given as a parametric equation x=f(t) y=f(t) $x=a(t-\sin{t})$ $y=a(1-\cos{t})$ So now i have to calculate a line integral $\int_c(2a-y)dx+xdy$ Where c is the first arc of the cycloide (the first example i gave, it turned to be a cycloide after all). This is how i do it: First $dx=(a-a\cos{t})dt$ $dy=a\sin{t}dt$ So now i include all of that into the integral. But i don't know how to determine the borders. It can be seen from the picture that if i want to integrate until the first arc, i should use limits from 0 to 2*r*pi or in my case to 2*a*pi. But those would be the limits if i would integrate with dx. So how do i find the limits when integrating with dt? $\int_c (2a-y) \, dx + x \, dy = \int_{t = t_1}^{t = t_2} \left( (2a-y) \, \frac{dx}{dt} + x \, \frac{dy}{dt} \right) \, dt = .......$
{ "domain": "mathhelpforum.com", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9780517475646369, "lm_q1q2_score": 0.8313157974484454, "lm_q2_score": 0.8499711794579723, "openwebmath_perplexity": 381.09352077283904, "openwebmath_score": 0.8866435885429382, "tags": null, "url": "http://mathhelpforum.com/calculus/25555-line-integrals-how-determine-limits.html" }
c#, mathematics, generics BandedInterpolatedAttribute This is the real meat and potatoes. For reference, the Operator class is from the MiscUtils library, and allows you to perform generic operations such as addition and subtraction on any type, provided that type supports the required operator. public class BandedInterpolatedAttribute<TKey, TResult> : IAttribute<TResult> { private IInterpolator<TResult, TKey> interpolator; private Func<TKey> deltaGetter; private IDictionary<TKey, TResult> bands; public BandedInterpolatedAttribute(Func<TKey> deltaGetter, IDictionary<TKey, TResult> bands, IInterpolator<TResult, TKey> interpolator) { if (deltaGetter == null) { throw new ArgumentNullException("deltaGetter"); } if (bands == null) { throw new ArgumentNullException("bands"); } if (interpolator == null) { throw new ArgumentNullException("interpolator"); } this.bands = bands; this.deltaGetter = deltaGetter; this.interpolator = interpolator; } public TResult Value { get { var orderedKeys = bands.Keys.OrderBy(x => x); var lowestKey = orderedKeys.First(); var highestKey = orderedKeys.Last(); var delta = deltaGetter(); if (Operator<TKey>.LessThanOrEqual(delta, lowestKey)) { return bands[lowestKey]; } else if (Operator<TKey>.GreaterThanOrEqual(delta, highestKey)) { return bands[highestKey]; } else { var lowBand = orderedKeys.Last(x => Operator<TKey>.LessThan(x, delta)); var highBand = orderedKeys.First(x => Operator<TKey>.GreaterThan(x, delta)); var normalizedDelta = Operator<TKey>.Divide(Operator<TKey>.Subtract(delta, lowBand), Operator<TKey>.Subtract(highBand, lowBand));
{ "domain": "codereview.stackexchange", "id": 11889, "lm_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#, mathematics, generics", "url": null }
c#, algorithm, performance, game public Random random; public clsNoise2D(int iSeed) { random = new Random(iSeed); //Randomize permutations array with values 0-255 List<byte> listByte = new List<byte>(); for (int i = 0; i < 256; i++) listByte.Add((byte)i); for (int i = 256; i > 0; i--) { Permutations[256 - i] = listByte[random.Next(i)]; listByte.Remove(Permutations[256 - i]); } //Take permutations array up to 512 elements to reduce wrapping needs in GetNoise2D call for (int i = 256; i < 512; i++) { Permutations[i] = Permutations[i - 256]; } //Set values to be between 0 and 1 incrementally from 0/255 through 255/255. for (int i = 0; i < 256; i++) { Values[i] = (i / 255f); } } public float GetNoise2D(float CoordX, float CoordY) { //Get floor value of inputs dX = (int)Math.Floor(CoordX); dY = (int)Math.Floor(CoordY); //Get fractional value of inputs xLerpAmount = CoordX - dX; yLerpAmount = CoordY - dY; //Wrap floored values to byte values dX = dX & 255; dY = dY & 255; //Start permutation/value pulling pX = Permutations[dX]; pXa = Permutations[dX + 1]; v00 = Values[Permutations[(dY + pX)]]; v10 = Values[Permutations[(dY + pXa)]]; v01 = Values[Permutations[(dY + 1 + pX)]]; v11 = Values[Permutations[(dY + 1 + pXa)]];
{ "domain": "codereview.stackexchange", "id": 5204, "lm_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, performance, game", "url": null }
error-correction, superconducting-quantum-computing, surface-code Title: How does Surface-17 tell apart Z errors on Db and Dc? I'm looking into this paper from DiCarlo's group Scalable quantum circuit and control for a superconducting surface code. I don't understand how it's supposed to identify specific single-qubit errors, specifically how it tells apart single qubit X or Z errors on the data qubits belonging only to one of the weight-4 syndromes. Does it? Maybe that's not even required, if it really isn't, why? I have added the layout from the paper. A Z error on Db will fire Xb and Xa. A Z error on Dc will fire Xa. Thus these two are distinguishable. If a X error occurs on Dc this will fire Zb. This can be corrected by applying X on Dc. If a X error occurs on Db this will also fire Zb. It is also corrected by applying X on Dc. At the end Db and Dc have been flipped, this does not change the logical state, because X-Db X-Dc is one of the stabilizers. This stabilizer is measured by Xa. Remember that applying a stabilizer is the same as applying the identity gate.
{ "domain": "quantumcomputing.stackexchange", "id": 1203, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "error-correction, superconducting-quantum-computing, surface-code", "url": null }
python, beginner, algorithm, programming-challenge, python-2.x idvlvko","kdvliolv","okvvlild","ldkvvloi","ilokldvv","vlvloikd","violdklv","lvlvkoid","dvkiollv","ldkvovil","olvvdikl","vollivkd","dlklvovi","ovikvdll","lodlkvvi","vidokvll","lilvkdvo","lvdvkoil","olvkdilv","vkliovdl","vldivolk","vlidolkv","volkdvli","ilvodlkv","lldviovk","vdklovil","vdlkvloi","lodlkivv","kdvovlil","klviolvd","ovdkillv","dlvlovik","llodivvk","dovvilkl","lvkiolvd","ivdvlolk","odivvkll","vlovdkli","ivdklvol","livodlkv","vidlkvol","vodlvikl","koidvlvl","ovdlkivl","dvvklilo","klvldo
{ "domain": "codereview.stackexchange", "id": 39357, "lm_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, algorithm, programming-challenge, python-2.x", "url": null }
Let us now make sure that our answer matches the textbook one $$\displaystyle\frac{1}{4}\left[\frac{1}{6}\cos 6x - \frac{1}{4}\cos 4x - \frac{1}{2}\cos 2x\right] + C = \frac{1}{24}\cos 6x - \frac{1}{16}\cos 4x - \frac{1}{8}\cos 2x + C$$ Indeed, observe that \begin{aligned} \cos 6x &= \cos \big(2(3x) \big) \\ & = \cos^2 3x - \sin^2 3x \\ & = 1 - 2 \sin^2 3x \\ & = 1 - 2 \big(3\sin x - 4\sin^3 x\big)^2 \\ & = 1 - 2 \big(9\sin^2 x - 24\sin^4 x + 16\sin^6 x\big) \\ & = 1 - 18\sin^2 x + 48 \sin^4 x - 32\sin^6 x \\ \cos 4x &= \cos \big(2(2x) \big) \\ & = \cos^2 2x - \sin^2 2x \\ & = 1 - 2 \sin^2 2x \\ & = 1 - 2 \big(2\sin x \cos x \big)^2 \\ & = 1 - 2 \big(4 \sin^2 x \cos^2 x\big) \\ & = 1 - 8\sin^2 x \left(1 - \sin^2 x \right) \\ & = 1 - 8\sin^2 x + 8 \sin^4 x \\ \cos 2x &= \cos^2 x - \sin^2 x \\ & = 1 - 2 \sin ^2 x \end{aligned}
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9790357591818725, "lm_q1q2_score": 0.82005989472364, "lm_q2_score": 0.837619961306541, "openwebmath_perplexity": 736.3301952661021, "openwebmath_score": 1.0000098943710327, "tags": null, "url": "https://math.stackexchange.com/questions/1393098/why-i-am-getting-different-answer/1393158" }
classical-mechanics, lagrangian-formalism, kinematics, coordinate-systems, differential-equations Basics $l$ is the length of the Pendulum, $m_p$ is the mass of the pendulum, $m_c$ is the mass of the cart, $\theta$ denotes the azimuthal and $\phi$ the polar As generalized Coordinates I use the conversion between spherical Coordinates and cartesian Coordinates: $$x=l\sin(\theta)\cos(\phi)$$ $$y=l\sin(\theta)\sin(\phi)$$ $$z=l\cos(\theta)$$ The generalized Coordinates for the Pendulum look like this: $$x_p=l\sin(\theta)\cos(\phi)+x$$ $$y_p=l\sin(\theta)\sin(\phi)+y$$ $$z_p=l\cos(\theta)$$ and $$\dot x_p = -l\sin(\phi)\sin(\theta)\dot\phi+l\cos(\phi)\cos(\theta)\dot\theta+\dot x$$ $$\dot y_p = l\sin(\phi)\cos(\theta)\dot\theta+l\sin(\theta)\cos(\phi)\dot\phi+\dot y$$ $$\dot z_p = -l\sin(\theta)\dot \theta$$ The Lagrangian Equation is defined by: $$L=T-V$$ with $$T=T_c+T_p$$ $$T_c=\frac{1}{2}m_c(\dot x^2+\dot y^2)$$ $$T_c=\frac{1}{2}m_p(\dot x_p^2+\dot y_p^2 + \dot z_p^2)$$ and $$V=m_p\cdot g \cdot z_p$$ results in:
{ "domain": "physics.stackexchange", "id": 88053, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "classical-mechanics, lagrangian-formalism, kinematics, coordinate-systems, differential-equations", "url": null }
sdformat Comment by alextoind on 2016-02-17: Nothing happens, but no warning is displayed this time... At a closer look it seems that no properties in the <gazebo> tags pass from the URDF to Gazebo (I've specified frictional parameters but they are filled with default values), even if the gazebo_ros_control plugin is properly loaded... I'm using Gazebo7 with ROS Jade; could this be a problem? Comment by hsu on 2016-02-17: which version of sdformat and urdf are you running? There are some examples in the unit tests, see equivalent examples in https://bitbucket.org/osrf/sdformat/src/753c70f286d59790160cf458ad18fa322def0691/test/integration/fixed_joint_reduction_collision_visual_extension.urdf?at=default and https://bitbucket.org/osrf/sdformat/src/753c70f286d59790160cf458ad18fa322def0691/test/integration/fixed_joint_reduction_collision_visual_extension.sdf?at=default Comment by alextoind on 2016-02-17: Thanks @hsu, I probably got the problem: as I said in http://answers.ros.org/question/226659/ros-jade-gazebo7-and-gazebo_ros_control-compatibility/ I compiled directly the jade-devel branch of gazebo_ros_pkgs because there is no gazebo_ros_pkgs for ROS Jade and Gazebo7 yet. I thought that it was quite fine because I could control my robot from ROS as explained in the tutorials, but now I believe that the spawn_model could be a bit dated. Why gz sdf and spawn_model use distinct code? Comment by alextoind on 2016-02-17:
{ "domain": "robotics.stackexchange", "id": 3862, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "sdformat", "url": null }
digital-communications Title: Baseband Signals have zero imaginary component I was revising a few basics on communication systems and I stumbled upon this line that I thought was incorrectly articulated. I thought that baseband signals were complex and passband signals were real. If $x_z (t)$ is the baseband signal with in-phase component $x_I (t)$ and quadrature component $x_Q (t)$ such that $$x_z (t) = x_I (t) + j x_Q(t)$$ then passband signal is $$x_c (t) =\sqrt{2} Re(x_z (t)e^{2\pi f_c t})$$ which would imply that baseband signals may have non zero imaginary component and passband signals cannot have non-zero imaginary component. But still the following statement from the book(Fundamentals of Communication System by Michael P.Fitz Chapter:Digital Communication Basics) seems to say it the other way around: The only caveat that needs to be stated is that baseband data communication will always have a zero imaginary component, while for bandpass communication the imaginary component of the complex envelope might be nonzero.
{ "domain": "dsp.stackexchange", "id": 9729, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "digital-communications", "url": null }
javascript, stackexchange, userscript // Define edit rules App.edits = { i: { expr: /(^|\s|\()i(\s|,|\.|!|\?|;|\/|\)|'|$)/gm, replacement: "$1I$2", reason: "basic capitalization" }, so: { expr: /(^|\s)[Ss]tack\s*overflow|StackOverflow(.|$)/gm, replacement: "$1Stack Overflow$2", reason: "'Stack Overflow' is the proper capitalization" }, se: { expr: /(^|\s)[Ss]tack\s*exchange|StackExchange(.|$)/gm, replacement: "$1Stack Exchange$2", reason: "'Stack Exchange' is the proper capitalization" }, expansionSO: { expr: /(^|\s)SO(\s|,|\.|!|\?|;|\/|\)|$)/gm, replacement: "$1Stack Overflow$2", reason: "'SO' expansion" }, expansionSE: { expr: /(^|\s)SE(\s|,|\.|!|\?|;|\/|\)|$)/gm, replacement: "$1Stack Exchange$2", reason: "'SE' expansion" }, javascript: { expr: /(^|\s)[Jj]ava\s*script(.|$)/gm, replacement: "$1JavaScript$2", reason: "'JavaScript' is the proper capitalization" }, jsfiddle: { expr: /(^|\s)[Jj][Ss][Ff]iddle(.|$)/gm, replacement: "$1JSFiddle$2", reason: "'JSFiddle' is the currently accepted capitalization" }, caps: { expr: /^(?!https?)([a-z])/gm, replacement: "$1", reason: "basic capitalization" }, jquery: {
{ "domain": "codereview.stackexchange", "id": 10442, "lm_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, stackexchange, userscript", "url": null }
message, msg, topic, publisher, node Title: Publish an length unknown vector message on a topic hi, i'm trying to publish a self-defined message composed by 4 vector whose length is unknown. my .cpp code (incomplete) could be the following: std::vector <int> l,d,r,u; data_pub_ = it_.advertise<rd_ctrl::proc_data>("data", 1); //vectors u,d,l,r computation data.u=u; data.d=d; data.l=l; data.r=r; data_pub_.publish(data); if it works (i don't know...if there are errors please tell me), how can i define the .msg file? thank you very much for your help! Originally posted by mateo_7_7 on ROS Answers with karma: 90 on 2013-02-26 Post score: 0 For creating a msg file,create a folder "msg" in ur package directory. In directory create msg file name.msg with following content: int32[] l int32[] d int32[] r int32[] u Also make changes in CMakelist.txt for compiling msg files. If u ur not sure of vector size u can just declare a variable of message type and publish it without assigning them a value. Originally posted by ayush_dewan with karma: 1610 on 2013-02-26 This answer was ACCEPTED on the original site Post score: 2 Original comments Comment by shan333 on 2013-02-27: I followed this way to create a message containing an array with unknown size. But when I assigned some value to the array in the program and publish, it gave "Segmentation fault (core dumped)" when running. Should I have to declare the size of the array in the program? How can it be done? Comment by shan333 on 2013-02-27: I followed this way to create a message containing an array with unknown size. Comment by ayush_dewan on 2013-02-27: U need to first allot memory. Do it using msg.a.resize(size of vector) or u can push elements into it using " msg.a.push_back(integer value) .
{ "domain": "robotics.stackexchange", "id": 13066, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "message, msg, topic, publisher, node", "url": null }
newtonian-mechanics, newtonian-gravity, fluid-statics Title: Is the force due to gravity between two objects immersed in a fluid correctly given by$ -G(M_1-m_1)(M_2-m_2)/r^2$? ($m$ = mass of displaced fluid) There seems to be general disbelief over this formula, so I'm challenging someone to show me the fallacy in the proof below. The assumptions are that the two objects are rigid and spherically symmetric and that the fluid is of uniform density and incompressible. Note that the gravitational fields induce pressure gradients in the fluid and these affect the force between the two objects. Proof:
{ "domain": "physics.stackexchange", "id": 72932, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "newtonian-mechanics, newtonian-gravity, fluid-statics", "url": null }
c #define MYDEBUG 1 #if MYDEBUG #define DBGMSG( ... )\ do{\ fprintf(stderr, "*** %s(): ", __func__ );\ fprintf( stderr, __VA_ARGS__ );\ }while(0) #endif // ----------------------------------------------- // Read a line from an already open text-stream, and Return it as a dynamically // allocated c-string. Return NULL on failure (errno is also set). The caller // is responsible for freeing the returned c-string. // NOTE: Description details removed for brevity. // char *fgetline_alloc( FILE *fp, bool flush, int *nchars, bool eolend ) { errno = 0; // sanity checks and early exits if ( !fp ) { DBGMSG( "invalid stream\n" ); errno = EDOM; goto fail; } if ( ferror(fp) ) { DBGMSG( "stream error\n" ); goto fail; } if ( feof(fp) ) { DBGMSG( "already at EOF\n" ); goto fail; }
{ "domain": "codereview.stackexchange", "id": 41329, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c", "url": null }
algorithms, python, breadth-first-search, maze You may also want to comment out version 1, i.e. #seen_or_visited.add(frontier) # Uncomment for version (1) since the invariant, fulfilled by the two points above, guarantees that whatever you pick from the queue (here, frontier) has already been added to the seen queue. By the way, your function is missing a return None in case it doesn't find the target position.
{ "domain": "cs.stackexchange", "id": 15732, "lm_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, python, breadth-first-search, maze", "url": null }
# Math Help - Can you help me prove or disprove this floor/ceiling equation? 1. ## Can you help me prove or disprove this floor/ceiling equation? Can you prove or disprove this floor/ceiling equation for positive integers $k$ and $b$, $b \geq 2$? $\lfloor \log_{b}{k} \rfloor + 1 = \lceil \log_{b}{\left( k+1 \right)} \rceil$ I think I can prove the equation when either $k$ or $k+1$ is a positive integer power of $b$ as follows. When $k=b^n$ for positive integer $n$, the original equation becomes $\lceil \log_{b}{\left( b^n + 1 \right)} \rceil = n + 1$. Which can be proven because $0 < \log_{b}{\left( b^n + 1 \right)} - n < 1$. Similarly, when $k+1=b^n$ for positive integer $n$, the original equation becomes $\lfloor \log_{b}{\left( b^n-1 \right)}\rfloor = n-1$. Like before, this is easy to prove because $0 < n - \log_{b}{\left( b^n-1 \right)} \leq 1$. Is this correct so far? I'm not sure what implications this has for when neither $k$ nor $k+1$ is a positive integer power of $b$. Any pointers you can offer will be greatly appreciated. Thanks! 2. You're saying that $log_b (b^n+1) = n + 1?$. That is not correct. To see that it is incorrect, try setting b=10 and n = 2: $ log_{10}101 = 2.004 \ne 2+1 $ I would approach it like this - given: $ (log_b k) + 1 = log_b(k+1) $
{ "domain": "mathhelpforum.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9852713878802045, "lm_q1q2_score": 0.8123187528298286, "lm_q2_score": 0.824461932846258, "openwebmath_perplexity": 146.31058556467872, "openwebmath_score": 0.8321318030357361, "tags": null, "url": "http://mathhelpforum.com/pre-calculus/154079-can-you-help-me-prove-disprove-floor-ceiling-equation.html" }
quantum-mechanics, homework-and-exercises, hamiltonian, eigenvalue, two-level-system \left (\frac{E_1 - E_2}{2} \sigma_z -A\sigma_x \right)^2\psi=-\left ( \frac{E_1 +E_2-2\lambda}{2}\mathbb{I} \right ) \left (\frac{E_1 - E_2}{2} \sigma_z -A\sigma_x \right )\psi =\left ( \frac{E_1 +E_2-2\lambda}{2}\mathbb{I}\right)^2\psi \qquad \Longrightarrow \\ \left (A^2 +\left (\frac{E_1 - E_2}{2}\right )^2 \right )\psi =\left ( \frac{E_1 +E_2-2\lambda}{2}\right )^2\psi , $$ since each Pauli matrix squares to the identity and the two anticommute. You then have your algebraic equation $$ \pm \sqrt{A^2 +\frac{(E_1 - E_2)^2}{4}} = \frac{E_1 +E_2}{2} -\lambda $$ without determinants, etc... Perhaps hardly worth it.
{ "domain": "physics.stackexchange", "id": 59567, "lm_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, hamiltonian, eigenvalue, two-level-system", "url": null }
interference, double-slit-experiment Title: Concerning the dark bands in the light "wave" interference pattern I'll begin with a with a brief and familiar example to frame the question: |_>EXAMPLE When water waves pass through a double slit experiment everyone knows that an interference pattern is created. The interference pattern is simply a combination of crests and troughs, but the "dark bands" here represent flat water (no up/down motion). This means that water is still reaching the observed wall in these dark band regions. The interference pattern is thus defined with crests, troughs, and flats. |_> QUESTION When light passes through a double slit experiment, an interference pattern is created (with no recording instruments). Following the example above, the dark bands created should instead be horizontal 'flat light' (light which no longer exhibits wave properties, only the particle of light itself should be here). Thus, light should still be reaching the observed wall in these dark band regions if analogous. Why then is there no light reaching these "dark band" regions instead of a flat horizontal line of light or other expected outcome based on standard wave/particle motion? I have many other questions and of course, more to read. But I think this is the most important start. The question has been slightly addressed here, but I welcome more complicated answers: Are double-slit patterns really due to wave-like interference? Since no one else has contributed, and the most satisfactory answer was the pdf I found, I will state that that is the answer to my question: "The Illusion of Light as Transverse Electromagnetic Waves" (bit.ly/1etSb0n)
{ "domain": "physics.stackexchange", "id": 23841, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "interference, double-slit-experiment", "url": null }
In all, we have concluded that a point $Z$ belongs to the tangent to $\mathcal C$ at $B$ iff $r(h(t(Z)))=(Z-C)(\bar B-\bar C)/r^2$ belongs to the tangent to the unit circle at $1$. As we say before, this happens exactly if the real part of $(Z-C)(\bar B-\bar C)/r^2$ is $2$, that is, if $$(Z-C)(\bar B-\bar C)/r^2+(\bar Z-\bar C)(B-C)/r^2=2.$$ Moving the $r^2$ to the right hand side and expanding a bit that is left on the left,, we get the equivalent equation $$Z(\bar B-\bar C)+\bar Z(B-C)=2r^2+C(\bar B-\bar C)+\bar C(B-C). \tag{1}$$ Since $B$ is in the circle $\mathcal C$, we have $r^2=(B-C)(\bar B-\bar C)$, and using this to massage a bit the right hand side of (1) gives you the equation you want. - Haha, I guess I didn't understand completely! I think this answer is definitely over my level/what I've learned though in class :) – Jay C Oct 21 '13 at 9:55 You have learned everything in this answer, trust me. – Mariano Suárez-Alvarez Oct 21 '13 at 15:09
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9763105238756898, "lm_q1q2_score": 0.8004704858630269, "lm_q2_score": 0.8198933293122507, "openwebmath_perplexity": 70.38147359955474, "openwebmath_score": 0.9886878132820129, "tags": null, "url": "http://math.stackexchange.com/questions/534149/circles-in-complex-planes" }
ros-kinetic Title: Is it possible that the spawn service rotates the 2D frame of turtlesim? The blue screen where the turtles appear has of course four angles. Is it true that the origin is in the left bottom angle, right???? because when I use the spawn service it seems to me that the origin changes. It this possible???? Originally posted by v.leto on ROS Answers with karma: 44 on 2018-08-17 Post score: 0 Solved! in the spawn command the parameters are not the real positions but the pixel of the screen Originally posted by v.leto with karma: 44 on 2018-08-17 This answer was ACCEPTED on the original site Post score: 0
{ "domain": "robotics.stackexchange", "id": 31566, "lm_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-kinetic", "url": null }
general-relativity, special-relativity, reference-frames, coordinate-systems \begin{equation} \frac{dt}{d\tau} = \gamma, \quad \frac{dx}{d\tau} = \gamma \mathbf{v}, \end{equation} where $\mathbf{v}$ is the three-velocity and $\gamma = (1-\mathbf{v})^{-1/2}$. This makes the magnitude of the four-velocity always equal to $-1$ in the original coordinates. This is a Lorentz scalar in that it is invariant under Lorentz coordinate transformation. However, now I am left with the situation that \begin{equation} -1 = -(\alpha X)^2. \end{equation} Question: By changing coordinates I have gone from a constant function on spacetime to one that varies in coordinates. To me, this seems wrong. A constant function in one set of coordinates should be constant in all coordinates. Was I wrong in the inclusion of $\gamma$? Or am I wrong in this final assertion? Should I set $X = \pm 1/\alpha$? But surely I can change $X$ as I like? Should this not be considered a function on spacetime? In Minkowski spacetime coordinates $(t, x)$ the worldline of a body in hyperbolic motion, with a constant proper acceleration $\alpha$ in the $+x$ direction, as function of proper time $\tau$ is described by $t =\ \frac{1}{\alpha} \ \sinh (\alpha \tau)$ $x = \ \frac{1}{\alpha} \ \cosh (\alpha \tau)$ The path in Minkowski is an hyperbola of equation $x^2 -t^2 = 1 / \alpha^2$ The velocity is $v = (\cosh (\alpha \tau), \sinh (\alpha \tau))$ The acceleration is $a = \alpha (\sinh (\alpha \tau), \cosh (\alpha \tau))$ With $\eta_{\mu \nu} = diag(-1, 1)$ metric tensor in 1+1-dimensional Minkowski, we have $v^2 = -1$ time-like vector
{ "domain": "physics.stackexchange", "id": 47056, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "general-relativity, special-relativity, reference-frames, coordinate-systems", "url": null }
quantum-field-theory, string-theory, supersymmetry, symmetry, superspace-formalism Domenico Fiorenza, Hisham Sati, Urs Schreiber, The brane bouquet The brane bouquet diagram itself appears for instance on p. 5 here. Notice that this picture looks pretty much like the standard "star cartoon" that everyone draws of M-theory. But this brane bouquet is a mathematical theorem in super $L_\infty$-algebra extension theory. Each point of it corresponds to precisely one $\kappa$-symmetric Green-Schwarz action functional generalized to tensor multiplet fields.
{ "domain": "physics.stackexchange", "id": 8968, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "quantum-field-theory, string-theory, supersymmetry, symmetry, superspace-formalism", "url": null }
I get rid of the negative values and I have: x=3.9201... x=0.2602.... but I only take x=3.9201... when I use you equation , I have x=15.36... x=0.06775... 17. Sep 17, 2005 ### Staff: Mentor And why do you ignore the other answer? That's the one you want! Right. And when you take the square roots, you get the same four solutions. 18. Sep 17, 2005 ### lightgrav Look, the coconut is 5m away from the start (along a diagonal). If the stone travels 20m in 1 sec then (ignoring gravity) it takes about 1/4 sec to go 5m. WITH gravity, in 1/4 sec the stone deviates from its path by 0.3 m, so you have to aim about twice as high, and stone will take anout twice as long ... about half sec. Why do you inisist on discarding the t^2 = 0.2602 [s^2] (which means t about .51 sec) ? You know that during 2 seconds of free-fall, a stone would deviate from its path by nearly 20 meters - so you want to aim 20 meters high? That's what DocAl meant by "the long way" almost straight up.
{ "domain": "physicsforums.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9693241991754918, "lm_q1q2_score": 0.8404387451919326, "lm_q2_score": 0.8670357615200474, "openwebmath_perplexity": 1720.3434624095084, "openwebmath_score": 0.5040285587310791, "tags": null, "url": "https://www.physicsforums.com/threads/help-understand.89292/" }
python EMBED_URLS = [ "https://www.youtube.com/embed/NL5ZuWmrisA?controls=2&fs=0&rel=0&modestbranding=1&showinfo=0&autohide=1&iv_load_policy=3&cc_load_policy=0&autoplay=0", "https://www.youtube.com/embed/gnZImHvA0ME?controls=2&fs=0&rel=0&modestbranding=1&showinfo=0&autohide=1&iv_load_policy=3&cc_load_policy=0&autoplay=0", "https://www.youtube.com/embed/FjHGZj2IjBk?controls=2&fs=0&rel=0&modestbranding=1&showinfo=0&autohide=1&iv_load_policy=3&cc_load_policy=0&autoplay=0" ] def convert_to_watch_url(embed_url: str) -> str: """Convert a YouTube embed URL into a watch URL.""" scheme, netloc, path, params, query, fragment = urlparse(embed_url) video_id, path = Path(path).stem, '/watch' return urlunparse((scheme, netloc, path, params, f'v={video_id}', fragment)) def main() -> None: """Convert and print the test URLs.""" for embed_url in EMBED_URLS: print(convert_to_watch_url(embed_url)) if __name__ == '__main__': main()
{ "domain": "codereview.stackexchange", "id": 42686, "lm_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 }
ros, gazebo, gazebo-ignition Title: Gazebo Ignition how to bridge SerializedStepMap I have a robot in .sdf, that I'm simulating in Gazebo Ignition. For further development I need TF of that robot. How can I get it? I found information, that TF is published to /world/<world_name>/model/<model_name>/state (source), in my case /world/roomba_world/state, with message of type How can i bridge it to ROS Humble? What is ROS substitute of SerializedStepMap? ros2 run ros_gz_bridge parameter_bridge /world/roomba_world/state@???[ignition.msgs.SerializedStepMap My second question: I found other tutorials using ros_gazebo_pkgs, but current documentation of Gazebo for ROS users tells to install Ignition, what is current way to do simulations? URDF of robot in ROS + ros_gazebo_pkgs? Currently I have SDF for Ignition/Gazebo and simplified URDF for RViz2, it is convinient, because I can simulate lidar without <gazebo></gazebo> tags etc, but on the other hand it is not that easy to get TF. The JointStatePublisher plugin publishes a gz.msgs.Model (might be the SerializedStepMap on older Ignition versions - which version do you use?) to a joint_state topic by default and the equivalent for that in the ROS domain is a sensor_msgs/msg/JointState, see here. But this isn't a TF2 yet. You also need a robot_state_publisher that subscribes to the joint states and generates a TF2 based on the input robot description. Yes, for new projects one should use the new Gazebo (Ignition). You can convert a SDF to URDF via sdformat_urdf and this is also available in RViz as it is published to the robot_description topic as usual.
{ "domain": "robotics.stackexchange", "id": 38541, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "ros, gazebo, gazebo-ignition", "url": null }
cosmology, cosmological-inflation, cosmological-principle, homogeneity Title: How can cosmic inflation make an infinite universe homogeneous? As it is explained in this video, one of cosmic inflation's observable effects is the homogeneity of our universe. Inflation allows two points on the different sides of the observable universe to be causally connected at some point in time, so they may exchange their mass densities and temperatures, which are then going to be about the same for both of them. While I do understand, that this effect doesn't have to end on the edge of the observable universe and might go on for whatever distance the rate of inflation will make it to, I do not understand how this could be valid for the entire Universe if it is infinite. From my guessing, if the Universe is infinite, there will allways be two points, that was never causally connected, no matter how fast it expanded at the inflation period. That will mean, that, while the Universe should be homogeneous on the sufficiently large scales, it doesn't have to on the scales even larger. I guess I either don't fully understand the idea of cosmic inflation or don't get the particular way the Universe is infinite in. Inflation is used to explain why the observable universe is extremely homogeneous. Without inflation, we can do the following crude calculation. The cosmic microwave background was formed about 300,000 years after the big bang, at a redshift of about 1100. Thus causally connected regions at the epoch of CMB formation would have a radius of $\sim 300,000$ light years, which has now expanded by a factor of 1100 to be $3.3\times 10^{8}$ light years in radius. This can be compared with the radius of the observable universe, which is currently around 46 billion light years. This means that causally connected regions should only be $\sim 4 \times 10^{-7}$ of the observable universe, or equivalently, patches of CMB of $\sim 2$ degrees radius on the sky are causally connected. This is clearly not the case as the variations in the CMB are no more than about 1 part in $10^{5}$ across the whole sky. Inflation solves this by allowing previously causally connected regions to inflate to become larger than the entire observable universe.
{ "domain": "astronomy.stackexchange", "id": 1469, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "cosmology, cosmological-inflation, cosmological-principle, homogeneity", "url": null }
semiconductor-physics, crystals Title: Why is the silicon crystalline structure is called cubic? Silicon has a valence 4 (electron shells: 2, 8, 4), hence having 4 neighbors in the 3D space, which for me should appear as a mesh of regular tetrahedrons, with the Si atoms at the centre. But silicon's crystal structure is Face Centered Diamond Cubic. From a tetrahedral mesh, I can obtain a hexahedral mesh by proper selection of vertex... But why isn't the mesh defined as tetrahedrons, which could be more intuitive? Or it is indeed a hexahedral mesh? The silicon lattice has a diamond structure where each Si atom has four nearest neighbors connected by a covalent bond forming tetrahedra that are periodic in space as can be seen in the picture. Thus one tetrahedron represents a possible primitive unit cell of the crystal whose translational repetition generates the crystal lattice. Each tetrahedron contains two Si atoms, one in the center and a quarter on each corner of the tetrahedron. However, different unit cells can be used to describe the same crystal lattice. It is easier to visualize the diamond lattice by the depicted conventional (not primitive) cubic unit cell with side length $a$. It can be seen that this corresponds to two interpenetrating face centered cubic Bravais point lattices that are displaced with respect to each other by a quarter of the cube's diagonal. From the perspective of crystal structure, the Si atoms belonging to these two sub-lattices are different, although they are chemically identical. It can be seen in the picture that a corner atom has a nearest neighbor in one direction of the diagonal but not in the other direction. Thus the crystal needs two Si atoms per primitive unit cell whose choice is not unique. One possible primitive unit cell is, as you suspected, the tetrahedron. Possible basis vectors for this primitive unit cells of the face centered lattice are the translations from one corner of the conventional cubic unit cell to its adjacent quadratic face centers. See, e.g., Ashcroft and Mermin, 1976, Chapter 4.
{ "domain": "physics.stackexchange", "id": 48275, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "semiconductor-physics, crystals", "url": null }
coordinate arrays x, y , and z into cylindrical coordinates theta, rho , and z. If the inputs are matrices, then polarplot plots columns of rho versus columns of theta. → Find also C and V. a) Write given plot in rectangular form. For more information on legend label The values can be an array of angles or array of magnitude. Description: This plugin will convert images to and from polar coordinates. POLAR(THETA, RHO) makes a plot using polar coordinates of the angle THETA, in radians, versus the radius RHO. theta = linspace (-pi/2,pi/2,1000); u = 2*pi*a*sin (theta); % initialize matrix. ⭐⭐⭐⭐⭐ Matlab 3d Plot Rotate Label; Views: 33705: Published: 19. A Polar coordinate system is determined by a fixed point, a origin or pole, and a zero direction or axis. This is an advantage of using the polar form. HALFPOLAR (phi,gain) makes a plot with phi in radians angle range [0 pi] and gain in half polar coordinates. Radius values limits can be adjusted by using the rlim function in Matlab. histogram2Polar. See PLOT for a description of legal linestyles. Plot the angle (in degrees) of the line of sight from an observer at the coordinate origin to the boat as a function of time for 3 hours. If this wasn't what you were looking for, check out the linked script, perhaps it can help as well. Where the radius and the angle are respectively. My one column is the degree of rotation from 0-360 in increments of 10s, and my second colum is the intensity measured at each angle. patternCustom(helixdata(:,3),helixdata(:,2),helixdata(:,1));. The polar form of a complex number is another way to represent a complex number. Complex Numbers and Polar Form of a Complex Number. Description. Polar Plots The polar plot of a sinusoidal transfer function G(j ω) is a plot of the magnitude of G(j ω) versus the phase angle of G(j … - Selection from MATLAB® and Its Applications in Engineering: [Based on MATLAB 7. My code to solve the problem is below. This tutorial will show you how to use
{ "domain": "limbury.de", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9869795114181106, "lm_q1q2_score": 0.8246051312267167, "lm_q2_score": 0.8354835350552604, "openwebmath_perplexity": 960.1824974765693, "openwebmath_score": 0.8298311829566956, "tags": null, "url": "http://limbury.de/polar-angle-matlab.html" }
machine-learning, deep-learning, neural-network, classification, machine-learning-model Title: Why best hyperparameters leads to drop in test performance? I am working on a binary classification problem using random forests (75:25 - class proportion). Label 0 is minority class. So, I am following the below approach a) execute RF with default hyperparameters b) execute RF with best hyperparameters (GridsearchCV with stratified K fold and scoring was F1) While with default hyperparameters, my train data was overfit as can be seen from the results below. But, I went ahead and tried the default paramters in test data as well (results below) default hyperparameters - Test data confusion matrix and classification report Best hyperparameters - Test confusion matrix and classification report So, my question is a) Why does a best parameters lead to drop in test data performance? Despite my model.best_score_ returning 86.5 as f1-score? I thought f1 scoring would allow us to find the best f1-score for both the classes. Looks like it is only focusing on class 1. How can I make the score function to work to increase the f1-score for minority class? b) This makes me feel like it is okay to stick with the overfit model as it provides me relatively good performance on test data (when compared to best parameter model because it performs poorly) c) My objective is to maximize the metrics like recall and precision for label 0 (minority class)? How can I do that? Any suggestions please? d) In this case, should I go ahead with the overfit model with default parameters? update when I invert the labels based on below answer, meaning 0's as 1's and 1's as 0's, I get the below performance
{ "domain": "datascience.stackexchange", "id": 10546, "lm_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, deep-learning, neural-network, classification, machine-learning-model", "url": null }
organic-chemistry, molecular-structure The deposit of a single molecule on a clean, flat, and cold surface. From the outsider's perception of work done @IBM Zurich and other groups, preparing such a pad accommodating an organic molecule is something understood well; perhaps some adjustments in how the molecules are then deposited are needed. Are nanoputains as substance well sublimable, would be OMBE feasible? The cold surface tightens the contact between molecule and substrate, lowers thermal vibrations of the molecule deposited; contributes that the then collected AFM is crisp. Provided the earlier mentioned conformational flexibility of the material (not necessary flat molecule, either), how do you -- if necessary -- decoil the members of a nanoputain? To move small molecules entirely, optical tweezers come to my mind, but here it were moving just a portion of a molecule representing a leg, redressing bow tie and hat that I assume as even more delicate. So my speculation is the second part is the more challenging one. Maybe it was already addressed as the original work was published in 2003, a citation analysis may shed some light on this aspect.
{ "domain": "chemistry.stackexchange", "id": 7940, "lm_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, molecular-structure", "url": null }
python filterJSON = { 'time': str(JSON['data']['time']['s']), 'co': str(JSON['data']['iaqi']['co']['v']), 'h': str(JSON['data']['iaqi']['h']['v']), 'no2': str(JSON['data']['iaqi']['no2']['v']), 'o3': str(JSON['data']['iaqi']['o3']['v']), 'p': str(JSON['data']['iaqi']['p']['v']), 'pm10': str(JSON['data']['iaqi']['pm10']['v']), 'pm25': str(JSON['data']['iaqi']['pm25']['v']), 'so2': str(JSON['data']['iaqi']['so2']['v']), 't': str(JSON['data']['iaqi']['t']['v']), 'w': str(JSON['data']['iaqi']['w']['v']), } liste.append(filterJSON) try: os.remove("airquality.xlsx") except: pass pd.DataFrame(liste).to_excel('airquality.xlsx') print(liste) if __name__ == "__main__": schedule.every(3).seconds.do(write_to_excel) while True: schedule.run_pending()
{ "domain": "datascience.stackexchange", "id": 7306, "lm_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 }
# How to prove the following for inner product and positive semidefinite matrices? In the solution of problem 2.10(b) of Stephen Boyd & Lieven Vandenberghe's Convex Optimization, it is mentioned that if $$g^Tv = 0, \qquad v^TAv \geq 0 \qquad \forall v$$ where $A$ is a positive semidefinite matrix and $g$ is a vector with real elements), then there must exist $\lambda$ such that $A+\lambda gg^T$ is positive semidefinite. How to obtain this? Here is the solution image which I am talking about: • You need to provide more details. What is given here? $A$ and $g$? What about $v$? For all $v$? etc. May 15 '18 at 3:34 • If $g^T v=0$ for all $v$ then $g=0$. May 15 '18 at 3:41 • @NicNic8 no $g^Tv$ is not zero for all $v$ but $v^TAv\geq 0$ for all $v$ May 15 '18 at 3:44 • @FrankMoses: If $v^T A v \geq 0$ for all $v$ then you can choose $\lambda =0$ (as $A$ is already semidefinite). May 15 '18 at 3:48 • @Fabian can you please explain why I cannot chose any value I like because $g^Tv=0$? May 15 '18 at 3:52 From what's given, $A$ is positive semidefinite. Therefore,
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9793540704659681, "lm_q1q2_score": 0.8052142674025745, "lm_q2_score": 0.8221891261650248, "openwebmath_perplexity": 211.61503922888716, "openwebmath_score": 0.7681928873062134, "tags": null, "url": "https://math.stackexchange.com/questions/2781736/how-to-prove-the-following-for-inner-product-and-positive-semidefinite-matrices" }
thermodynamics, forces, torque, power Today, many engines on the road use double overhead cam valve systems, which can squeeze almost 7000RPM out of that engine. Smaller pistons support faster operation of the engine, so a parallel trend has been to smaller-displacement engines, which when coupled with dual overhead cam valves can pull almost 70HP out of 1 liter displacement turning at 9000RPM, as on my Suzuki GS1000GL motorcycle.
{ "domain": "physics.stackexchange", "id": 46279, "lm_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, forces, torque, power", "url": null }
special-relativity, tensor-calculus, linear-algebra, conventions, covariance Title: The definition of transpose of Lorentz transformation (as a mixed tensor) In the appendix of the textbook of Group Theory in Physics by Wu-Ki Tung, the transpose of a matrix is defined as the following, Eq.(I.3-1) $${{A^T}_i}^j~=~{A^j}_i.$$ This is extremely confusing for me, since in the case of Lorentz transformation ${\Lambda_\nu}^\mu$ is considered in the text (eg. Ch.10) as a matrix, and one can show that (eg. see Eq.(2.3.10) of The Quantum Theory of Fields Vol.1 by Steven Weinberg) $${{(\Lambda^{-1})}^\nu}_\mu ~=~g_{\mu\sigma}{\Lambda^\sigma}_\alpha g^{\alpha\nu}.$$ In particular, it is defined on the very same line (of the above equation in Weinberg) $${\Lambda_\mu}^\nu ~=~ {{(\Lambda^{-1})}^\nu}_\mu.$$ The above definition is quite natural, since it can be viewed as that the metric tensors $g_{\mu\nu}$ were used to raise and lower and corresponding subscript and superscript of the original ${\Lambda^\sigma}_\alpha$.
{ "domain": "physics.stackexchange", "id": 17348, "lm_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, tensor-calculus, linear-algebra, conventions, covariance", "url": null }
homework-and-exercises, electrostatics, charge, equilibrium which could be rewritten as $$\frac{2 \sqrt{2}\delta r}{\frac{l^3}{2}(1 + (\frac{\sqrt{2}\delta r}{l})^2)} = \frac{4 \sqrt{2}\delta r}{l^3(1 + (\frac{2(\delta r)^2}{l^2}))}$$ Since the last factor is small, it can be treated using the binomial theorem, $(1+x)^{-1} \approx (1-x)$. This reduces the above factor to $$\frac{4 \sqrt{2}\delta r}{l^3} (1 - (\frac{2(\delta r)^2}{l^2})) \approx \frac{4 \sqrt{2}\delta r}{l^3} $$ since the other term is of the order of $(\delta r)^3/l^5$ and hence, is very very small. This is the extra component aimed towards B. Now, we have to find the net difference between the force along A and total force along B. For evaluating these, one would need the value of separation squared for both of these cases (in terms of such binomial expansions). Let us do these first. $$\frac{1}{(\frac{l}{\sqrt 2} - \delta r)^2} = \frac{2}{l^2} (1 - \frac{\sqrt{2}\delta r}{l})^{-2} \approx \frac{2}{l^2} (1 + \frac{2\sqrt{2}\delta r}{l})$$ and by the same token $$ \frac{1}{(\frac{l}{\sqrt 2} + \delta r)^2} \approx \frac{2}{l^2} (1 - \frac{2\sqrt{2}\delta r}{l}) $$ So, we have
{ "domain": "physics.stackexchange", "id": 21015, "lm_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, charge, equilibrium", "url": null }
chaos-theory, complex-systems Title: Do the Lyapunov exponents depend on integrals of motion When calculating the Lyapunov exponents it is usual to average over initial conditions. In a Hamiltonian system is it correct to average of energy as well, or do we pick an ensembles of trajectories with the the same energy, and understand the Lyapunov spectra to be a function of energy. Furthermore when calculating the Lyapunov exponents do we consider the divergence of trajectories that differ in the value of energy, or do we only calculate the Lyapunov exponents within an equal-energy manifold? eg. If we have a point (x,y), and (x+dx,y) has the same energy whereas (x,y+dy) has a different energy, do I consider divergence of trajectories with initial perturbation in both of these directions? or just the equal-energy direction? Is it the same story for other integrals of motion? When calculating the Lyapunov exponents it is usual to average over initial conditions. Yes and no – depends on what you consider an initial condition. You regularly rescale your separation to be able to approximate the $t→∞$ in the definition of Lyapunov exponents. You could however say that every rescaling corresponds to a different initial condition. In the following I assume that initial condition does not refer to this. Now, you usually calculate Lyapunov exponents along one trajectory defined by some initial condition. Whether you average over one long trajectory starting from one initial condition or several trajectories starting from different initial conditions makes no difference, if the latter lie on the same irreducible invariant manifold: If you cut up the long trajectory into several small ones, you have essentially the same situation. If your dynamics has an attractor (which does not happen in Hamiltonian systems), its easy to ensure that different initial conditions lie on the same irreducible invariant manifold (the attractor) and this may facilitate distributed computing and similar. For Hamiltonian systems, it is not that easy. In a Hamiltonian system is it correct to average of energy as well, or do we pick an ensembles of trajectories with the the same energy, and understand the Lyapunov spectra to be a function of energy.
{ "domain": "physics.stackexchange", "id": 35675, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "chaos-theory, complex-systems", "url": null }
classical-mechanics, energy, definition $$ W = \phi(\vec{r}) - \phi(\vec{r}_0) = - \int_{\vec{r}_0}^{\vec{r}} \vec{F} \cdot d\vec{r} $$ and can even be defined (in terms of the integral) if the force $\vec{F}$ is not conservative. In conlusion: Total energy $E$ is a conserved quantity. Work is the energy needed to go from a point $\vec{r}_0$ to $\vec{r}$ (and end up with the same velocity), e.g. the difference in potential energy. Kinetic energy is associated with movement and potential energy is associated with the presence of external forces.
{ "domain": "physics.stackexchange", "id": 34766, "lm_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, energy, definition", "url": null }
javascript newLine.appendChild(newButton); newLine.appendChild(newName); newLine.appendChild(newWeekSet); newWeekSet.appendChild(newMoveIcon); dashboard.appendChild(newLine); modal.style.display = "none"; } } } @import url(https://fonts.googleapis.com/css?family=Open+Sans:700,300); body { background: white; font-family: 'Open Sans', Helvetica, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } .add-button { display: inline-block; height: 50px; width: 50px; color: orange; padding-left: 18px; padding-top: 10px; background: white; border: 2px solid orange; border-radius: 25px; cursor: pointer; } .name-font { font-size: 2em; padding-left: 35px; } .submit-button { display: inline-block; border: 1px solid orange; border-radius: 5px; height: 40px; background-color: white; cursor: pointer; } .submit-button:hover { background-color: #ffd796 } .clickable { cursor: pointer; } .right-align { float: right; } /* The Modal (background) */ .modal { position: fixed; display: none; padding-left: 75%; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(255,255,255,0.5); } /* Modal Content */ .modal-content { padding: 20px; border: 2px solid orange; height: 100%; overflow: auto; } /* The Close Button */ .close { display: inline; color: gray; float: right; }
{ "domain": "codereview.stackexchange", "id": 37837, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "javascript", "url": null }
electrostatics, electric-fields, gauss-law, conductors Title: Confusion from textbook about the internal electric field being 0 within a closed conductor I am wondering if I have misunderstood something. If the electric field within a closed conducting surface is supposed to be 0 why are there electric field lines drawn in this example inside the conductor? The textbook is describing a hollow metal sphere (the spherical shell). The field lines are drawn only in the empty space inside the sphere and not within the conductive shell.
{ "domain": "physics.stackexchange", "id": 75580, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "electrostatics, electric-fields, gauss-law, conductors", "url": null }
electric-current, electrical-resistance, time, voltage, estimation Title: How fast does an electric shock pass through the human body? So essentially I want to make a 1,000,000 volt Van de Graaff machine and I'm trying to calculate the energy that would pass through the human body if I charged it completely and let it arc to my hand. I may be doing many things wrong here but theoretically with a voltage of 1,000,000 volts we can calculate the current through my body by dividing by the human body's resistance. Being about 500 ohms the current should be about 2,000 amps. The power is then 2,000,000 watts. Then to find the energy I believe I have to use the equation joules = watts * seconds but I'm not sure where to find a measurement on how long it will take to pass through my body. This is where I'm stuck: any help is appreciated. It is typically difficult to determine the duration of the discharge in this kind of situation. It would be easier to work out how much energy is initially stored on the generator. This sets an upper limit on how much energy could be delivered to your body when you contact it.
{ "domain": "physics.stackexchange", "id": 64052, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "electric-current, electrical-resistance, time, voltage, estimation", "url": null }