text stringlengths 49 10.4k | source dict |
|---|---|
homework-and-exercises, quantum-field-theory, greens-functions
Title: Stuck with derivation of correlation functions in QFT The Green's function for Feynman propagator satisfy:
$$\Box_{x}D_{x1}=-i\delta_{x1}$$
where $$\Box_{x}=\partial_{t}^{2}-\partial_{x}^{2}$$
then:
$$\langle \phi_{1}\phi_{2}\rangle=\int d^{4}x \delta_{x1}\langle \phi_{x}\phi_{2}\rangle =i\int d^{4}x(\Box_{x}D_{x1})\langle\phi_{x}\phi_{2}\rangle.$$
the derivation I am stuck is on this following step:
$$i\int d^{4}x D_{x1}\Box_{x}\langle \phi_{x}\phi_{2}\rangle.$$
I am puzzled as it claim integration by parts shall yield the result but
$$\partial_{x}AB=A\partial_{x}B+B\partial_{x}A$$
and
$$\partial_{x}^{2}(AB)=(\partial_{x}^{2}A)B+(\partial_{x}^{2}B)A+2(\partial_{x}A)(\partial_{x}B)$$
so the final equation I couldn't obtained from these equations should yield negative sign The identity you have derived,
$$
\partial_{x}^{2}(AB)=(\partial_{x}^{2}A)B+(\partial_{x}^{2}B)A+2(\partial_{x}A)(\partial_{x}B),
$$
is true but it doesn't help you integrate by parts. Specifically, if you were to integrate both sides, you would get (up to boundary terms)
$$ | {
"domain": "physics.stackexchange",
"id": 82332,
"lm_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, quantum-field-theory, greens-functions",
"url": null
} |
c++, c++11, programming-challenge, time-limit-exceeded
N -> populationHeadCount
M -> executionCount
val -> currentVisitorWealth
visits -> stillLivingWealthiest
Unused variable
The variable i is initialized and incremented but never read.
Inserting "the king"
Your code unconditionally inserts the wealth val even if it is the king (-1), thus introducing even more entries in visits.
Speed up
Reading rules more closely than you have given them here yields:
You may assume that no two citizens have the same wealth.
Which makes this problem a perfect fit for an std::set (as mentioned by Loki):
#include <iostream>
#include <set>
#include <algorithm>
int main() {
int populationHeadCount, expectedExecutionCount;
std::cin >> populationHeadCount >> expectedExecutionCount;
std::set<int> stillLivingWealthiest;
int executionNumber = 0;
while (executionNumber < expectedExecutionCount) {
int currentVisitorWealth;
std::cin >> currentVisitorWealth;
if (currentVisitorWealth == -1) {
std::cout << *--stillLivingWealthiest.end() << std::endl;
stillLivingWealthiest.erase(--stillLivingWealthiest.end());
++executionNumber;
} else {
stillLivingWealthiest.insert(currentVisitorWealth);
}
}
}
Explanation: A std::set stores the elements sorted from minimum to maximum, so we only need to look at the end to get and delete the maximal element. | {
"domain": "codereview.stackexchange",
"id": 9378,
"lm_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, programming-challenge, time-limit-exceeded",
"url": null
} |
rotation, movement, transformation, matrix, coordinate-system
0\\
0\\
1
\end{bmatrix}
$$
Solving for T matrix members, we get dx = −286.8, dy = −338.0 and dz = 244.6
From P2 calibration, we have:
$$p_2=\begin{bmatrix}
140.3 \\
−422.2\\
246.7\\
1
\end{bmatrix}
=
\begin{bmatrix}
r_{11} & r_{12} & r_{13} & −286.8\\
r_{21} & r_{22} & r_{23} & −338.0\\
r_{31} & r_{32} & r_{33} & 244.6\\
0 & 0 & 0 & 1\\
\end{bmatrix}
\begin{bmatrix}
435.3 \\
0\\
0\\
1
\end{bmatrix}
$$
Solving for the Rotation matrix, we get:
$$
R = \begin{bmatrix}
0.981112257 & r_{12} & r_{13}\\
-0.193378015 & r_{22} & r_{23}\\
0.004866365 & r_{32} & r_{33}
\end{bmatrix}
$$
Based on OMRON calibration wizard, the following matrix is obtained after finishing teaching the 3 points:
$$
T = \begin{bmatrix}
0.981112257 & -0.193427089 & 0.00216786 & −286.8\\
-0.193378015 & -0.981022085 & -0.01416372 & −338.0\\
0.004866365 & 0.013476983 & -0.999897339 & 244.6\\
0 & 0 & 0 & 1\\
\end{bmatrix}
$$ | {
"domain": "robotics.stackexchange",
"id": 2176,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "rotation, movement, transformation, matrix, coordinate-system",
"url": null
} |
c++
Title: Custom stream-like classes Consider the following code:
#include <iostream>
#include <vector>
using namespace std;
struct test {
int j;
test& operator>>(int & i) { i = ++j%26; return *this; }
operator bool() { return j%26; }
};
int main () {
test t;
int i;
while (t >> i) {
cout << i << endl;
}
}
I have implemented a simple class that can be used in a similar fashion as for example std::cin. I implemented it this way, because I wanted to have an object that hides some IO-operations from me and provide a nice interface to yield the data items each one-at-a-time.
Although it does want I want, I know there is at least one issue with the implementation:
ignorance w.r.t. the safe bool idiom
Are there probably any more? For simple 10 lines 10 programs you can get away with this:
using namespace std;
Anything bigger and it starts to be a pest more than a help. Thus it best not to get into the habit of using it. Anyway it is simpler even in this case just to prefex cout with std:: (that is why standard is named std to make it short and easy to use).
You don't initialize the value of j in your class.
int j;
Thus any usage is undefined behavior.
You have two options:
Add a constructor that initaizes j
Always force zero-initialization of your class.
In anything but this trivial program I would go with (1) and add a constructor. But just to show zero initialization the alternative is:
Test t = Test(); // The () brackets at the end of Test() force zero initialization;
Note: The equivalent for new is
Test* t = new Test(); // force zero-initialization (when no constructor)
Test* t = new Test; // Use default-initialization (un-initialized)
Note 2: Normally you would think you could do this:
Test t(); // Unfortunately this is a forward declaration of a function. | {
"domain": "codereview.stackexchange",
"id": 2386,
"lm_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
} |
be given to help you understand the core meaning. Similar to the simple linear regression problem, you have N-paired observations. The linear regression problem and the data set used in this article is also from Coursera. 0502X2 from a series of simple regression equations for the coefficient of X2. # Other useful functions. More practical applications of regression analysis employ models that are more complex than the simple straight-line model. Interpreting coefficients in multiple regression with the same language used for a slope in simple linear regression. Simple linear regression relates X to Y through an equation of the form Y = a + bX. LinearModel is a fitted linear regression model object. When the correlation (r) is negative, the regression slope (b) will be negative. 46 is obtained. In addition to these variables, the data set also contains an additional variable, Cat. ), the computing package used may refuse to fit the full model. Deming Regression. For example, if we wanted to include more variables to our GPA analysis, such as measures of motivation and self-discipline, we would use this equation. Multiple linear regression model is the most popular type of linear regression analysis. The distance to the line is the “error” - because ideally we prefer every point is on that line. Mar 30 - Apr 3, Berlin. Conducting regression analysis without considering possible violations of the. SIMPLE LINEAR REGRESSION. The following example illustrates XLMiner's Multiple Linear Regression method using the Boston Housing data set to predict the median house prices in housing tracts. Thus we find the multiple linear regression model quite well fitted with 4 independent variables and a sample size of 95. Yes, Linear regression is a supervised learning algorithm because it uses true labels for training. linear regression problem. The regression. It fits linear, logistic and multinomial, poisson, and Cox regression models. In practice, we often have more than one predictor. This tutorial goes one step ahead from 2 variable regression to another type of regression which is Multiple Linear Regression. Chapter 9 Multiple Linear Regression "Life is really simple, but we insist on making it complicated. The model is linear because it is linear in the parameters , and. This paper investigates the problems of inflation in Sudan by adopting a multi-linear regression model of analysis based on descriptive econometric framework. Flow , Water. raw or auto1. In this blog post, we explore Linear Regression where the relationship between the dependent and independent variable is | {
"domain": "laquintacolonna.it",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9711290922181331,
"lm_q1q2_score": 0.8113623629833243,
"lm_q2_score": 0.8354835309589074,
"openwebmath_perplexity": 859.6916552022177,
"openwebmath_score": 0.4258139729499817,
"tags": null,
"url": "http://zybl.laquintacolonna.it/multiple-linear-regression-example-problems-with-solutions-in-r.html"
} |
turing-machines, automata, pushdown-automata
There are many type of PDAs, such as deterministic or nondeterministic, accepting by final states or empty stack, even various generalized version. It should not be too difficult to see how they can be simulated by Turing machines.
"Allowing backtracking but no rewriting on the tape may make a Turing machine with equivalent power to a PDA." No, it does not. As mentioned above, read-only Turing machines are equivalent to DFAs in power. Here is the explanation from Wikipedia. The proof involves building a table which lists the result of backtracking with the control in any given state; at the start of the computation, this is simply the result of trying to move past the left endmarker in that state. On each rightward move, the table can be updated using the old table values and the character that was in the previous cell. Since the original head-control had some fixed number of states, and there is a fixed number of states in the tape alphabet, the table has fixed size, and can therefore be computed by another finite state machine. This machine, however, will never need to backtrack, and hence is a DFA. | {
"domain": "cs.stackexchange",
"id": 12734,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "turing-machines, automata, pushdown-automata",
"url": null
} |
python, array, interview-questions
for i, elem in enumerate(copy):
if elem > 0 and (i+1 == len(copy) or copy[i+1] == 0):
strokes += 1
if elem > 0:
copy[i] -= 1
the ifs can be merged:
for i, elem in enumerate(copy):
if elem > 0:
copy[i] -= 1
if i+1 == len(copy) or copy[i+1] == 0:
strokes += 1 | {
"domain": "codereview.stackexchange",
"id": 36725,
"lm_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, array, interview-questions",
"url": null
} |
acid-base, aqueous-solution, solutions, concentration, water-treatment
Title: Adjustment of calcium, magnesium and alkalinity in drinking water? It's been a long time since I did any molar chemistry in school and despite doing a lot of reading on the subject this week, I am making a mess of some basic calculations. I hope that someone who understands water chemistry & molar equations a lot better than I do can point me in the right direction.
I am trying to add mineral salts to soft water to adjust the calcium, magnesium and alkalinity in a predictable manner. But I can't get past the basic equations so far.
The source water I am working with is:
12.6 mg/L Hardness as CaCO3 equivalent
11.3 mg/L Alkalinity as CaCO3 equivalent
4.8 mg/L Calcium
0.2 mg/L Magnesium
1.5 mg/L Sodium
And the desired target water is:
70 mg/L Hardness as CaCO3 equivalent
40 mg/L Alkalinity as CaCO3 equivalent
20 mg/L Calcium
4.9 mg/L Magnesium
8 mg/L Sodium
I would prefer to have most of the hardness derive from calcium, rather than magnesium if possible. I plan to try
adding sufficient baking soda, NaHCO3 to the source water to obtain 8 mg/L sodium, then
add sufficient calcium carbonate (chalk), CaCO3 to the source water to make 50/50 GH/KH water (general hardness/carbonate hardness) i.e. 50 mg/L hardness and 50 mg/L alkalinity, both expressed as CaCO3 equivalents
add sufficient lactic acid (88% CH3CH(OH)COOH) to neutralize some carbonate and (I hope) get to 50/40 GH/KH
add sufficient epsom salt, MgSO4*7H2O to obtain a final result of 70/40 GH/KH.
This assumes that adding lactic acid won't remove (precipitate) calcium hardness.
The solubility of calcium carbonate in water shouldn't be an issue, I can put it under pressure with carbon dioxide, C02 if necessary to dissolve it.
If the above is not feasible, then alternately | {
"domain": "chemistry.stackexchange",
"id": 11898,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "acid-base, aqueous-solution, solutions, concentration, water-treatment",
"url": null
} |
mechanical-engineering, electrical-engineering, telecommunication
Title: Rotary Phones vs Pushbutton -- why did we ever have rotary? I remember when we first got pushbutton phones -- I would say user experience is literally ten times better -- if you used a rotary phone extensively as part of your job, you would rapidly develop a callous on your dialing finger. Of course, you also push the same number (we still use the term dial, at least some people do) maybe ten times faster than a dial.
My question is, why was a dial ever used? Could not something like a pushbutton phone have been developed much sooner? What is the idea behind the dial "UI"?
Note that I know something about computer history, how incredibly hard it used to be, for example, to store a byte of memory using mercury delay lines -- so if I suggest that a musical note be sent (as maybe push button phones did it) instead of N pulses for the integer N I can guess that this is much easier said than done. Rotary phones were controlled by sending pulses down the line. These pulses were the equivalent of hanging up the phone quickly - hence what you see in old movies and TV shows when they quickly tap the hang-up mechanism to get the operator. In the final versions of rotary phones, you could "dial" by quickly pressing down the hang-up button the right number of times for each number. All the rotary mechanism did was send the equivalent of a hang-up press quickly in succession the right number of times.
So why didn't tones work? Because mechanical relays won't send tones, the phones system listeners wouldn't accept tones, and because in general technology has to be invented before it works. You might as well ask why Mr. Bell didn't invent cell phones straight off. | {
"domain": "engineering.stackexchange",
"id": 4431,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "mechanical-engineering, electrical-engineering, telecommunication",
"url": null
} |
quantum-field-theory, condensed-matter, non-equilibrium, strong-correlated
Perhaps you mistakenly said Matsubara for the analytical continuation of the statistical equilibrium methods (i.e. the true Matsubara method) to time-dependent problems of statistical mechanics. Then the two methods are equivalent. It is just a matter of convention and preference which one you prefer to use (either Keldysh or analytic continuation of imaginary time). The reason is that in Matsubara method of equilibrium systems you suppose the time to be pure imaginary, so taking both real-time (i.e. evolution) and statistics means the time variable goes smoothly to the complex plane $t\rightarrow t+i/k_{B}T$ (sketchilly speaking, more details can be found in this question).
Also, time-dependent quantum field problems can be attacked using Keldysh methods (I mean, problem discussing only one particle, not statistical mechanics). But this is completely unrelated to Kubo or Matsubara approximations, so I guess your question was not about that possibility.
Finally, (and I'm less certain about that) I feel that quantum statistics can be discussed only in the Keldysh formalism. The reason is that the Green's function approach uses the classical statistics (I call classical both the fermionic and bosonic gases), i.e. the thermal equilibrium. This is the condition under which the replacement $e^{iHt}\rightarrow e^{H/k_{B}T}$ between quantum field and statistical fields works. Beyond this Boltzmann statistical weighting, I fear you need Keldysh or more powerful methods. | {
"domain": "physics.stackexchange",
"id": 73808,
"lm_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, condensed-matter, non-equilibrium, strong-correlated",
"url": null
} |
ros, raspberrypi
int main(){
int fd;
struct input_event ie;
Display *dpy;
Window root, child;
int rootX, rootY, winX, winY;
unsigned int mask;
dpy = XOpenDisplay(NULL);
XQueryPointer(dpy,DefaultRootWindow(dpy),&root,&child,
&rootX,&rootY,&winX,&winY,&mask);
if((fd = open(MOUSEFILE, O_RDONLY)) == -1) {
perror("opening device");
exit(EXIT_FAILURE);
}
while(read(fd, &ie, sizeof(struct input_event))) {
if (ie.type == 2) {
if (ie.code == 0) { rootX += ie.value; }
else if (ie.code == 1) { rootY += ie.value; }
printf("time%ld.%06ld\tx %d\ty %d\n",
ie.time.tv_sec, ie.time.tv_usec, rootX, rootY);
} else if (ie.type == 1) {
if (ie.code == 272 ) {
printf("Mouse button ");
if (ie.value == 0)
printf("released!!\n");
if (ie.value == 1)
printf("pressed!!\n");
} else {
printf("time %ld.%06ld\ttype %d\tcode %d\tvalue %d\n",
ie.time.tv_sec, ie.time.tv_usec, ie.type, ie.code, ie.value);
}
}
}
return 0;
} | {
"domain": "robotics.stackexchange",
"id": 26345,
"lm_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, raspberrypi",
"url": null
} |
php, static
Title: A decent use-case for static property I'm currently writing a REST-tool that connects to a third-party server (duh). They offer a fairly large (if not too large) API in a single wsdl file, as well as separate wsdl's for each specific part of data you want to work on.
When writing my code, I created an abstract Api class, and a number of child classes, one for each subset of the API.
Since all requests are available through a single, "master-api", there is only 1 user-password required to connect, so I've created the getClient and setClient methods in the abstract class.
Since it's not unlikely form me to be working with two, or three of these API-classes, I decided to create a private static property in the abstract class. This is to avoid excessive internal method calls, brought along by lazy-loading.
Is this a valid use-case for the static keyword? It's the only time I'm using static in my entire code, and I have this acquired repulsion for using it.
Anyway, here's some (grossly oversimplified) version of my code:
namespace MyLib;
use Tool\Application,
Tool\Command;//it's a CLI tool
use MyLib\Soap\Client;
use \Zend_Config;//can't help but liking the old Zend_Config
absctract class Api
{
//all properties have a getter, which lazy-loads the correct object, where possible
//can be injected through constructor, setter or via $this->command
private $app = null;
//inject via setter, get from application or command
private $config = null;
//inject via setter or child constructor
private $command = null;
/* This is the one */
private static $login; | {
"domain": "codereview.stackexchange",
"id": 4080,
"lm_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, static",
"url": null
} |
c++, algorithm, recursion, c++20
template<std::ranges::input_range T>
requires (std::ranges::input_range<std::ranges::range_value_t<T>>)
constexpr T recursive_print(const T& input, const int level = 0)
{
T output = input;
std::cout << std::string(level, ' ') << "Level " << level << ":" << std::endl;
std::ranges::transform(std::ranges::cbegin(input), std::ranges::cend(input), std::ranges::begin(output),
[level](auto&& element)
{
return recursive_print(element, level + 1);
}
);
return output;
}
void recursive_any_of_tests()
{
std::cout << "***recursive_any_of_tests function***\n";
auto test_vectors_1 = n_dim_container_generator<std::vector, 4, int>(1, 3);
test_vectors_1[0][0][0][0] = 3;
std::cout << "Play with test_vectors_1:\n";
if (recursive_any_of(test_vectors_1, [](int i) { return i == 2; }))
std::cout << "2 is one of the elements in test_vectors_1\n";
if (recursive_any_of(test_vectors_1, [](int i) { return i == 3; }))
std::cout << "3 is one of the elements in test_vectors_1\n";
}
void recursive_none_of_tests()
{
std::cout << "***recursive_none_of_tests function***\n"; | {
"domain": "codereview.stackexchange",
"id": 45344,
"lm_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, recursion, c++20",
"url": null
} |
botany, metabolism, plant-physiology, nutrition, amino-acids
Title: Why would the citrulline content of the watermelon be so high? Citrulline is a non-proteinogenic amino acid (that is, citrulline is an amino acid that is not coded for in mRNA), and it is an important metabolic intermediate in the Urea Cycle. The Urea Cycle is critical for nitrogen (e.g. ammonia) excretion in humans as well as other mammals.
Citrulline is an interesting amino acid, given its vital function in the Urea Cycle, but also because it has such a high concentration in the watermelon. The name citrulline is actually derived from citrullus vulgaris, which is the Latin word for watermelon.
A notable fact about the watermelon is that the watermelon is the only food known to have such high content of citrulline. There are NO other foods that have such high endogenous levels of this amino acid.
As a physiologist citrulline is very interesting metabolically, but I wonder why the watermelon would have such a high concentration? Why would that occur? Would high citrulline content offer some type of competitive advantage to the watermelon in terms of out-competing other plants? As biologists, we usually think about things from a teleologic perspective in order to make sense of the world around us. With that perspective, is there a logical reason that citrulline would be so enriched in the watermelon? It seems very odd that it would be the only plant with notable quantities. According to molecular botanists and plant physiologists, watermelon is the only plant that is known to contain significant amounts of citrulline. Interestingly, it appears that the reason for this tremendous enrichment in citrulline stems from the environment in which wild watermelons naturally thrived hundreds of years ago prior to the development of agriculture.
According to botanists, drought is one of the most severe stresses to which a plant can be exposed. Drought generates a high level of free radicals and oxidative stress, in part because plants maintain their photosynthetic machinery even in the face of severe drought. A number of investigators have shown that different plants have unique molecular mechanisms/systems to allow them to tolerate such harsh conditions and oxidative stress. | {
"domain": "biology.stackexchange",
"id": 4946,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "botany, metabolism, plant-physiology, nutrition, amino-acids",
"url": null
} |
cosmology, dark-energy
Title: Is dark energy homogeneous and/or isotropic? Shouldn't there be at least some fluctuations of dark energy in various regions, analogous to the fluctuations we observe in other forms of energy like matter? Both the isotropy and homogeneity are amenable to observational test. One can measure the peak brightness and redshifts for type Ia supernovae in different directions and at a range of redshifts. One can then see whether the same cosmological models (including $\Lambda$) are required or can consistently model all datasets, or whether there are angular correlations at particular scales in the peak magnitudes of supernovae at a given redshift.
There are actually quite a lot of papers that have examined this question - some have claimed to detect an anisotropy (at low significance) - e.g. Cai et al. (2013), whilst others find no such signal - e.g. Blomqvist et al. 2010.
Another possibility is to look for the signature of dark energy inhomegeneity or anisotropy imprinted on the cosmic microwave background (e.g. Weller & Lewis 2003).
A review of this plus some other suggested diagnostics - Baryon Acoustic Oscillations, Weak Lensing measurements etc. are reviewed by Battye et al. (2015). My (very) limited understanding of the situation is that inhomogeneities would be expected if the dark energy obeys an equation of state that is other than the $P = -\rho$ corresponding to a cosmological constant, where $P$ is the pressure and $\rho$ is the energy density due to dark energy.
In other words, if $P = w \rho$, with $w \ne -1$ (for example in dynamical scalar field theories for the dark energy such as Quintessence, or k-essence), then clustering of dark energy is predicted
The final conclusion of Battye et al.'s review is that any clustering in the data is limited to scales larger than $30 h^{-1}$ Mpc, and the data are still compatible with no inhomogeneity and $w=-1$. | {
"domain": "physics.stackexchange",
"id": 23692,
"lm_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, dark-energy",
"url": null
} |
You may see an expression like:
A, \equiv, B, left parenthesis, start text, m, o, d, space, end text, C, right parenthesis
This says that A is congruent to B modulo C.
We will discuss the meaning of congruence modulo by performing a thought experiment with the regular modulo operator.
Let's imagine we were calculating mod 5 for all of the integers:
Suppose we labelled 5 slices 0, 1, 2, 3, 4. Then, for each of the integers, we put it into a slice that matched the value of the integer mod 5.
Think of these slices as buckets, which hold a set of numbers. For example, 26 would go in the slice labelled 1, because 26, start text, space, m, o, d, space, end text, 5, equals, 1.
Above is a figure that shows some integers that we would find in each of the slices.
It would be useful to have a way of expressing that numbers belonged in the same slice. (Notice 26 is in the same slice as 1, 6, 11, 16, 21 in above example).
A common way of expressing that two values are in the same slice, is to say they are in the same equivalence class.
The way we express this mathematically for mod C is: A, \equiv, B, space, left parenthesis, start text, m, o, d, space, end text, C, right parenthesis
The above expression is pronounced A is congruent to B modulo C.
Examining the expression closer:
1. \equiv is the symbol for congruence, which means the values A and B are in the same equivalence class.
2. left parenthesis, start text, m, o, d, space, end text, C, right parenthesis tells us what operation we applied to A and B.
3. when we have both of these, we call “\equivcongruence modulo C.
e.g. 26, \equiv, 11, space, left parenthesis, start text, m, o, d, space, end text, 5, right parenthesis
26, start text, space, m, o, d, space, end text, 5, equals, 1 so it is in the equivalence class for 1, | {
"domain": "khanacademy.org",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9848109520836026,
"lm_q1q2_score": 0.8051563026769116,
"lm_q2_score": 0.8175744806385543,
"openwebmath_perplexity": 1959.2055052581015,
"openwebmath_score": 0.6432403922080994,
"tags": null,
"url": "https://en.khanacademy.org/computing/computer-science/cryptography/modarithmetic/a/congruence-modulo"
} |
homework-and-exercises, lagrangian-formalism, gauge-theory, variational-principle, yang-mills
Attempt: Since the space of gauge potentials is an affine space we may consider the variations $\mathcal A + t\mathcal B$ (family of 1-parameter of gauge potentials) thus
$$\begin{aligned}\frac{d}{dt} \Big(\mathcal {YM}(\mathcal A + t \mathcal B)\Big)\Big|_{t= 0} &= \frac{1}{4}\int_{\mathbb R^4} \frac{d}{dt} \Big(\|\mathcal F\|^2\Big)\Big|_{t = 0} d (\bf vol_{\mathbb R^4})\\ &=\frac{1}{2} \int_{\mathbb R^4} \|\mathcal F\| \frac{\left\langle \mathcal F, \frac{d}{dt} (\mathcal F)\Big|_{t =0}\right\rangle}{\|\mathcal F\|} d(\bf vol_{\mathbb R^4})\\&=\frac{1}{2} \int_{\mathbb R^4} \left\langle \mathcal F, \frac{d}{dt} (\mathcal F)\Big|_{t=0}\right\rangle d(\bf vol_{\mathbb R^4})\end{aligned}$$ where | {
"domain": "physics.stackexchange",
"id": 82371,
"lm_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, lagrangian-formalism, gauge-theory, variational-principle, yang-mills",
"url": null
} |
react.js, react-native
// other logics...
setState(stateData);
};
// other methods...
export const renderReusableTextInput = (
state,
setState,
inputRef,
styles, // contains all the styles from Main component
) => {
return (
<ReusableTextInput
inputName={state.name}
inputLabel={state.label}
inputValue={state.value}
inputRef={inputRef}
secureTextEntry={state.secureTextEntry}
textInputContainerWarperStyle={{...styles.textInputContainerWarper, ...styles[`${state.name}ExtraTextInputContainerWarper`]}}
textInputContainerStyle={state.styleNames.textInputContainer}
textInputLabelStyle={state.styleNames.textInputLabel}
textInputStyle={state.styleNames.textInput}
textInputHelperStyle={{...styles.textInputHelper, ...styles[`${state.name}ExtraTextInputHelper`]}}
textInputErrorStyle={{...styles.textInputError, ...styles[`${state.name}ExtraTextInputError`]}}
helperText={state.helperText}
inputError={state.error}
onFocus={() => handleFocus(state, setState, styles)}
onChangeText={(text) => handleChangeText(state, setState, text)}
onBlur={() => handleBlur(state, setState, styles)}
/>
);
};
Main.js
// import Joi from 'joi';
// import { joiPasswordExtendCore } from 'joi-password';
// import { renderReusableTextInput } from ''; ... | {
"domain": "codereview.stackexchange",
"id": 44190,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "react.js, react-native",
"url": null
} |
in order to draw the graph. At the point e−y ( 2x − 4 ) $some point [. Above calculator is a slope ( one that you can calculate ) but not differentiable calculator! Multivariable function … in this section of sinx want to calculate the differential! A sequence of points that leads to smaller and smaller values of the variable x of a can! This method for the absolute value function to your differential equations calculator m... That you can calculate ) speaking, is … Homogeneous differential equations calculators to calculate the calculus online expression! Tan ( xsec^3 ( x ) equations calculators to calculate the ordered differential equations of differentials in this section must! Differentiable it is also continuous be continuous, so no need to about... Equations calculators to calculate the calculus online similarly differentiable function calculator tanxsec^3x will be parsed as tan... = 4sin ( 3t )$ \frac { dr } { d\theta } =\frac r^2! And give the derivative of the function and its tangent at the point be differentiable at a point if derivative... Change is not differentiable the given input function must also be continuous but not differentiable functions with all power... At least a whitespace, i.e your expression, add parentheses and multiplication signs needed... Asking for help, clarification, or responding to other answers, and consult the table below singularities ( g.! Your expression, add parentheses and multiplication signs where needed, and consult the table below Stack!! Function containing abs or sign, ensure that the arguments are real values of.. Y = 4sin ( 3t ) $ty'+2y=t^2-t+1$ differential calculus calculator online with our math and... Function that is differentiable is also continuous parentheses or a multiplication sign type! We will compute the differential of the power of calculus when working with it t2... Best experience you skip parentheses or a multiplication sign, type at least a whitespace, i.e you. … Homogeneous differential equations leads to smaller and smaller values of the given input tool... Derivative to get tan ( x ) , use parentheses: (... Example illustrates some applications of the variable x to calculate the calculus online also continuous ) is happening | {
"domain": "pamovalleyvineyards.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9763105259435195,
"lm_q1q2_score": 0.8027119109523548,
"lm_q2_score": 0.8221891392358014,
"openwebmath_perplexity": 573.1514211923685,
"openwebmath_score": 0.8361150026321411,
"tags": null,
"url": "https://pamovalleyvineyards.com/0a8q8v/viewtopic.php?tag=4e5227-differentiable-function-calculator"
} |
storage, caching
Title: Is reading contiguous pages (let's say 4KB) any faster than reading non-contiguous pages on SSDs? I'm working my way on a problem which requires me to store elements in fixed 4KB-sized pages on an SSD. Each page is requested once for some computation on its elements, and then the CPU requests for another different page from the SSD. I'm trying to ascertain whether any page contiguous-ness can be exploited here for smaller latency times. Any research papers or articles on this area would be very appreciated. Short answer: no.
On an SSD, non-contiguous access (very slightly) increases the protocol and processing overhead - in theory, contiguous (or rather: longer) transfers could be slightly faster but you'd be hard pressed to actually measure that difference in real life, especially with NVMe.
That is caused in part by today's extremely fast processing capabilities but mostly due to the (almost) general overlap of I/O requests and data transfers using (deep) command queueing.
Note that I'm assuming a somewhat decent size of I/Os - most SSDs hit their peak (or even the interface's) with 4 KiB I/Os already. | {
"domain": "cs.stackexchange",
"id": 19563,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "storage, caching",
"url": null
} |
performance, c, raycasting
char MAP[32][32] = {
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, | {
"domain": "codereview.stackexchange",
"id": 36675,
"lm_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, raycasting",
"url": null
} |
quantum-field-theory, special-relativity, causality, commutator
You can see the relation between a manifestly Lorentz invariant form like this $$\int d^4p \frac{e^{-ipx}}{(p^2-m^2)} \ \ \ (1) $$ and the not-so-obviously Lorentz invariant form $$ \int d^3p \frac{1}{E_{{\bf{p}}}}{e^{-ipx}} \ \ \ (2)$$ by using the identity $$\frac{1}{(p^2-m^2)}= \frac{1}{2E_{{\bf{p}}}}\{\frac{1}{(E_{{\bf{p}}}+p_0)}-\frac{1}{(E_{{\bf{p}}}-p_0)}\} $$ Here $E_{{\bf{p}}} = \sqrt{{\bf{p}}^2+m^2}$ is the on-shell time component of the momentum four vector, and $p_0$ is the "generic" time component - not necessarily on-shell.
If you substitute this in (1) and do the $p_0$ integral using the appropriate contour, you'll get (2).
What's actually going on is explained in the discussion near equation (2.40), you're doing a 4 momentum integral, but just restricting it to the mass shell using a delta function. Restriction to a mass shell is a Lorentz invariant operation, so you're maintaining Lorentz invariance throughout (even though with the three momentum integral it doesn't look like it!). | {
"domain": "physics.stackexchange",
"id": 6669,
"lm_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, special-relativity, causality, commutator",
"url": null
} |
ros-kinetic, camera
Title: How to stop recording by camera node through an user input?
I would like to stop the camera node through a different node. I was trying to implement this by sending a message through another node which is read by the camera node But, the problem is that the camera node runs on an infinite loop. Can I get a cpp implementation to stop this while loop through a subscribed message.
#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <opencv2/highgui/highgui.hpp>
#include <cv_bridge/cv_bridge.h>
#include <sstream> // for converting the command line parameter to integer
#include "std_msgs/Int32.h"
bool camOn = true;
void sendCamera(const std_msgs::Int32::ConstPtr& msg)
{
if (msg->data == 1){
camOn = true;}
else if (msg->data == 2){
camOn = false;}
}
int main(int argc, char** argv)
{
ros::init(argc, argv, "image_publisher");
ros::NodeHandle nh;
ros::Subscriber sub = nh.subscribe("/camera_status", 1000, sendCamera);
image_transport::ImageTransport it(nh);
image_transport::Publisher pub = it.advertise("camera/image", 1);
cv::VideoCapture cap(0);
if(!cap.isOpened()) return 1;
cv::Mat frame;
sensor_msgs::ImagePtr msg; | {
"domain": "robotics.stackexchange",
"id": 33713,
"lm_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, camera",
"url": null
} |
newtonian-mechanics, energy, reference-frames, velocity, relative-motion
Title: Kinetic energy of an object We know that motion is relative. So let an object(o) be moving with a certain velocity with respect to an object (A).If another object (B) is moving with respect to (A) at a given moment and they calculate the kinetic energy of the (same) object(o), they will get different answers.How is that possible? As others have already said, kinetic energy is reference frame dependent. The same applies to gravitational potential energy.
It should be pointed out, however, we are talking about kinetic energy at the macroscopic level. It is not necessarily the case at the microscopic level.
For example, I have a box resting on a table containing an ideal gas which I define as my system. The gas molecules have some average value of random translational kinetic energy which is reflected by the temperature of the gas. This kinetic energy is the internal kinetic energy of my system.
I set the box in motion. The temperature of the gas does not change. The internal kinetic energy of my system does not change. It is reference frame independent. But macroscopically, the overall mass of the gas (my system) has acquired kinetic energy that is reference frame dependent. We call this the system’s external kinetic energy because it depends on an external frame of reference.
The total energy of the system is the sum of its internal and external kinetic and potential energy. In general the external energy of the system depends on an external frame of reference. The internal energy does not.
Hope this helps. | {
"domain": "physics.stackexchange",
"id": 58576,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "newtonian-mechanics, energy, reference-frames, velocity, relative-motion",
"url": null
} |
Let's rewrite this slightly: $$\int_a^x f(t)\,dt = F(x)-F(a).$$ We've replaced the variable $x$ by $t$ and $b$ by $x$. These are just different names for quantities, so the substitution doesn't change the meaning. It does make it easier to think of the two sides of the equation as functions. The expression $$\int_a^x f(t)\,dt$$ is a function: plug in a value for $x$, get out some other value. The expression $F(x)-F(a)$ is of course also a function, and it has a nice property: $${d\over dx} (F(x)-F(a)) = F'(x) = f(x),$$ since $F(a)$ is a constant and has derivative zero. In other words, by shifting our point of view slightly, we see that the odd looking function $$G(x)=\int_a^x f(t)\,dt$$ has a derivative, and that in fact $G'(x)=f(x)$. This is really just a restatement of the Fundamental Theorem of Calculus, and indeed is often called the Fundamental Theorem of Calculus. To avoid confusion, some people call the two versions of the theorem "The Fundamental Theorem of Calculus, part I'' and "The Fundamental Theorem of Calculus, part II'', although unfortunately there is no universal agreement as to which is part I and which part II. Since it really is the same theorem, differently stated, some people simply call them both "The Fundamental Theorem of Calculus.''
Theorem 7.2.2 (Fundamental Theorem of Calculus) Suppose that $f(x)$ is continuous on the interval $[a,b]$ and let $$G(x)=\int_a^x f(t)\,dt.$$ Then $G'(x)=f(x)$. $\square$ | {
"domain": "whitman.edu",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9938070094752999,
"lm_q1q2_score": 0.8054596227431438,
"lm_q2_score": 0.8104789109591832,
"openwebmath_perplexity": 114.96026588112824,
"openwebmath_score": 0.9464420080184937,
"tags": null,
"url": "https://www.whitman.edu/mathematics/calculus_online/section07.02.html"
} |
our ROIC example. Use MathJax to format equations. This would require an integer, however vavg is a ratio of type double. Calculate the average velocity of your car (in cm/tu) for the entire run using the formula Vavg = total distance covered/total time. Formula One Grand Prix (known as World Circuit in the United States) is a racing simulator released This version of Formula One Grand Prix was designed for personal computers with operating system. For a particle in simple harmonic motion, show that Vmax = (pi/2)*Vavg where Vavg is the average speed during one cycle of the motion. repeatlast If set to 1, force the filter to extend the last frame of secondary streams until the end of the primary stream. The Formula Sim is specifically engineered to help drivers to improve their craft in Formula categories. Copy AFL di bawah dan paste ke Formula Editor di amibroker kemudian save. The term streamline flow is descriptive of the laminar flow because, in laminar flow, layers of water flowing over one another at different speeds with virtually no mixing between layers, fluid particles move in definite and observable paths or streamlines. This set focuses on formulas, important numbers, word problems, and linear motion terminology. The Center-Tapped Full-Wave Rectifier A center-tapped rectifier is a type of full-wave rectifier that uses two diodes connected to the secondary of a center-tapped transformer, as shown in Figure (a). What do you want to calculate?. Substitute (3) into (2) (4) Vavg = (0 + v)/2. Thus, the total of the masses of neutrons and protons is the atomic mass. 3535 * V pp Where V pp is the peak to peak volatge and V rms is the root mean square voltage. It is akin to Ohm’s Law, but something I was never taught in tech school –I had to learn it myself much later –now I use it at least weekly. 0321-5455195 Home Delivery Service is Also Available. (d) The object hits the ground when its position is s(t) = 0. The average velocity of the ball can be found using these values and the formula: v avg = 0. Silica is most commonly found in nature as sand or | {
"domain": "freccezena.it",
"id": null,
"lm_label": "1. Yes\n2. Yes",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9833429590144717,
"lm_q1q2_score": 0.8798849102566718,
"lm_q2_score": 0.894789454880027,
"openwebmath_perplexity": 1900.9799295418693,
"openwebmath_score": 0.6601222157478333,
"tags": null,
"url": "http://mryf.freccezena.it/vavg-formula.html"
} |
python, tic-tac-toe, pyqt
if choice == QtGui.QMessageBox.Yes:
self.close()
self.__init__()
else:
sys.exit()
def close_application(self):
# add functionality to see if we want to exit
choice = QtGui.QMessageBox.question(self,'Exit','Are you sure you want to exit?',
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
if choice == QtGui.QMessageBox.Yes:
sys.exit()
else:
pass
def main():
app = QtGui.QApplication(sys.argv)
GUI = Tic()
sys.exit(app.exec_())
if __name__ == '__main__':
main() I looked through your code and I have a few comments.
Major Bugs
new_game() function doesn't reset the game
Clicking the new game menu item or pressing Ctrl+N does not reset the game board or the moves.
This can be solved by adding some code to the new_game() function that resets the 'coin' inside the buttons, as well as moving some code from your board() so that it executes every time new_game() is called. Shown below.
def new_game(self):
#### CODE ADDED #####
#This resets the board
[self.btnDict[key]("") for key in self.btnDict]
self.winner = ''
#### END CODE ADDED ####
#### CODE MOVED FROM board() ####
# list of taken move positions
self.taken = [0, 0, 0, 0, 0, 0, 0, 0, 0]
self.takenBy = [0, 0, 0, 0, 0, 0, 0, 0, 0]
#### END OF CODE MOVED FROM board() #### | {
"domain": "codereview.stackexchange",
"id": 22842,
"lm_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, tic-tac-toe, pyqt",
"url": null
} |
c++, performance, parsing
You can't prevent yourself from eventually outrunning the disk and blocking. However, you can reduce the number of stalls, push the time of the first stall back, and you can eliminate several round trip times between requests, maximizing throughput. Certainly, prefetching a couple of megabytes in one go is more efficient (even if broken down to smaller requests at driver level) than to do a lot of small requests ad-hoc as page faults are realized with sync-points in between, which are necessarily full stalls.
Trying to tune the actual parsing is unlikely to give very substantial gains. Using a custom isnumeric as you've done is probably the single best thing to start with, but the gains beyond that won't likely be great.
The reason is that you're trying to turn the wrong knob (for the same reason, the ideology-driven environmental craze that is so much en vogue is failing). Thing is, even if you reduce something that makes up 3% of the total to one half, or eliminate it altogether, the gains are not very substantial. The gains, however, are substantial if you reduce the other 97%. Which, unluckily, is hard to do because that's forementioned disk access, followed by memory bandwidth and memory latency.
Parsing of very simple data (integers on a line), even badly implemented easily runs in the "dozen gigabyte per second" realm. Converting numbers is very fast and almost certainly hidden by memory latency.
Your CPU cache is probably not much help, and prefetching most likely will not help much either. The reason being that fetching a cache line takes something around 300-400 or so cycles, and you hardly need that much to parse the data. You're still going to be memory bandwidth bound (in addition to being I/O bound). | {
"domain": "codereview.stackexchange",
"id": 37043,
"lm_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, parsing",
"url": null
} |
We first approximate the integral using trapezoids. This gives
\begin{equation*} \begin{split} \int_1^3 \frac{1}{x}\,dx \amp \approx \frac{1}{4}\bigl(f(1) + 2f\left(\frac{3}{2}\right) + 2 f(2) + 2 f\left(\frac{5}{2}\right) + f(3)\bigr)\\ \amp = \frac{1}{4} \bigl(1 + 2 \frac{2}{3} + \frac{2}{2} + 2\frac{2}{5} + \frac{1}{3}\bigr)\\ \amp = \frac{67}{60} \end{split} \end{equation*}
To compute a bound on the error to this approximation, we differentiate:
\begin{equation*} f'(x) = -\frac{1}{x^2}, \text{ and } f''(x) = \frac{2}{x^3}\text{.} \end{equation*}
Therefore, on the interval $[1,3]\text{,}$ we see that
\begin{equation*} |f''(x)| \leq 2\text{.} \end{equation*}
Hence,
\begin{equation*} E\left(\frac{1}{2}\right) = \frac{2^3}{12(16)} (2) = \frac{1}{12}\text{.} \end{equation*}
Therefore, the Trapezoid approximation is
\begin{equation*} \int_1^3 \frac{1}{x}\,dx = \frac{67}{70} \pm \frac{1}{12}\text{.} \end{equation*}
Now using Simpson's rule, we find | {
"domain": "sfu.ca",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.991422514586288,
"lm_q1q2_score": 0.8035270421915378,
"lm_q2_score": 0.810478913248044,
"openwebmath_perplexity": 1790.7639840630734,
"openwebmath_score": 0.9808958172798157,
"tags": null,
"url": "https://www.sfu.ca/math-coursenotes/Math%20158%20Course%20Notes/sec_Numerical_Integration.html"
} |
ordinary and partial differential equations, finite difference approximations, accuracy. copy() u_num1 = u_0. A high-level system with Matlab-like syntax for system control and signal processing applications. 0:17 python. shape) bm_vec_30 = np. A numerical method for solving the hyperbolic telegraph equation. Innovative methods for numerical solutions of partial differential equations. Module III: Classification of linear partial differential equation. Singular Solutions of Differential Equations. This course is devoted to the numerical solution of partial differential equations (PDEs). 5), one may naturally solve the parabolic equation until stationary conditions occurs. Numerical Solution of Partial Differential Equations, 1994. What is SymPy? SymPy is a Python library for symbolic mathematics. 1 Partial Differential Equations in Physics and Engineering 82. Here you can solve systems of simultaneous linear equations using Gauss-Jordan Elimination Calculator with complex numbers online for free with a very detailed solution. This equation is typical of most SPH dis-cretizations. Linear differential equation can be added and multiplied by coefficients Ordinary Differential Equations that lack additive solution are known as non linear, and solving them is more intricate. Solution of block-tridiagonal systems of linear algebraic equations. Featured on Meta. ode The Python tuple is returned as expected in a reduced amount of time. However, many models consisting of partial differential equations can only be solved with implicit methods because of stability demands [73. Thus if we know the distance along the road from a fixed point we can find the height. Some of the numerical analysis techniques used in these models include: Finite difference, finite element, and finite volume techniques for solving sets of partial differential equations Eulerian-Lagrangian solutions for advection-dispersion problems. Here you can solve systems of simultaneous linear equations using Gauss-Jordan Elimination Calculator with complex numbers online for free with a very detailed solution. It provides readers with an easily accessible text explaining main concepts, models,. J W Thomas. NumPy - Indexing & Slicing. pL and qL are the coefficients for the left boundary, while pR and qR are the coefficients for the right boundary. The techniques for solving differential equations based on numerical. NUMERICAL. It will totally squander the time. So, we hope this compilation will help students from different backgrounds and fields. Chapter8 also introduces the reader to the solution of coupled | {
"domain": "circoloartidecorative.it",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9871787857334058,
"lm_q1q2_score": 0.8070921808494271,
"lm_q2_score": 0.817574478416099,
"openwebmath_perplexity": 611.0340591978346,
"openwebmath_score": 0.5929720401763916,
"tags": null,
"url": "http://circoloartidecorative.it/numerical-solution-of-partial-differential-equations-python.html"
} |
python, beginner, python-3.x, machine-learning, neural-network
def init_parameters(self):
self.weights = [
np.random.normal(size=size) * scale for size, scale in PARAMETERS
]
I will explain the second function later.
Matrix multiplication
Don't use np.dot to get the dot product of two matrices. .dot() is six characters. You should use the matrix multiplication operator @ to do that. It is designed for exactly this purpose. And much more concise (saves five characters).
Repetition and passing way too many arguments that go around
def forward_prop(W1, b1, W2, b2, X):
Z1 = W1.dot(X) + b1
A1 = ReLU(Z1)
Z2 = W2.dot(A1) + b2
A2 = softmax(Z2)
return Z1, A1, Z2, A2
def backward_prop(Z1, A1, Z2, A2, W1, W2, X, Y):
one_hot_Y = one_hot(Y)
dZ2 = A2 - one_hot_Y
dW2 = 1 / m * dZ2.dot(A1.T)
db2 = 1 / m * np.sum(dZ2, axis=1).reshape(-1, 1)
dZ1 = W2.T.dot(dZ2) * ReLU_deriv(Z1)
dW1 = 1 / m * dZ1.dot(X.T)
db1 = 1 / m * np.sum(dZ1, axis=1).reshape(-1, 1)
return dW1, db1, dW2, db2
def update_parameters(W1, b1, W2, b2, dW1, db1, dW2, db2, a):
W1 = W1 - a * dW1
b1 = b1 - a * db1
W2 = W2 - a * dW2
b2 = b2 - a * db2
return W1, b1, W2, b2 | {
"domain": "codereview.stackexchange",
"id": 44691,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, beginner, python-3.x, machine-learning, neural-network",
"url": null
} |
urdf, transform
Title: How should we represent the thrusters on an AUV?
We're looking to run ROS on an in-house AUV while hopefully bring more support in ROS for AUVs. While we could just use topics to transport thruster information between our device driver and controller using a specialized topics, I'd like to find a better approach. Our nodes consist of a thruster driver, a controller, and a thruster mapper which converts Wrenches to thruster efforts. I'd like for the mapper to be entirely generic, and somehow retrieve the names, positions, orientations, min/max thrust, etc of the thrusters relative to the vehicle's center of mass, then publish a generic thruster effort message that is compatible with thruster drivers besides our own.
It seems like there are a lot of parallels to URDF and joints in a ground vehicle. Could URDF be extended to support thrusters? What would it take to accomplish this, and would it potentially be merged into a future ros release?
It also seems like this could be done in terms of tf static transforms, one for each thrusters. Would this be a better approach instead?
Originally posted by matthewbot on ROS Answers with karma: 51 on 2012-10-15
Post score: 5
Have you seen the hector_quadrotor package? There might be stuff there you can use.
Originally posted by Airuno2L with karma: 3460 on 2015-07-22
This answer was ACCEPTED on the original site
Post score: 1 | {
"domain": "robotics.stackexchange",
"id": 11378,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "urdf, transform",
"url": null
} |
formal-languages, context-free
Now, we pump the word down. That is, consider the words $w'=xz$ which should be also in $L_E$ by the pumping Lemma.
However, we can interpret $w'$ as being $w'=\langle A',B\rangle$ where $A'$ is a malformed encoding (it begins with stating the DFA has less then $2^n$ states, but then it describes transitions of $2^n$ states, which is inconsistent with the claimed number of states).
Therefore, by our assumption $L(A')=\emptyset$ while $L(B)=\Sigma^*$. Thus, $\langle A',B\rangle \notin L_E$ and we reached a contradiction. | {
"domain": "cs.stackexchange",
"id": 801,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "formal-languages, context-free",
"url": null
} |
c++, beginner, object-oriented, game
int onet = 0;
int twot = 0;
int threet = 0;
int fourt = 0;
int fivet = 0;
int sixt = 0;
int sevent = 0;
int eightt = 0;
int ninet = 0;
int tent = 0;
int onev = 0;
int twov = 0;
int threev = 0;
int fourv = 0;
int fivev = 0;
int sixv = 0;
int sevenv = 0;
int eightv = 0;
int ninev = 0;
int tenv = 0;
string champname, champname2;
string prospect1 = "Jonas Hill - QB";
string prospect2 = "Kyle Matthew - DB";
string prospect3 = "Julius Brown - RB";
string prospect4 = "Reece David - C";
string prospect5 = "Cole Anderson - FS";
string prospect6 = "Andy Tyler - WR";
string prospect7 = "Macus Reed - FB";
string prospect8 = "Elijah Moore - LB";
string prospect9 = "Larry Steel - RB";
string prospect10 = "Nicholas Dean - LB";
int oner = 0;
int twor = 0;
int threer = 0;
int fourr = 0;
int fiver = 0;
int sixr = 0;
int sevenr = 0;
int eightr = 0;
int niner = 0;
int tenr = 0;
int ones = 0;
int twos = 0;
int threes = 0;
int fours = 0;
int fives = 0;
int sixs = 0;
int sevens = 0;
int eights = 0;
int nines = 0;
int tens = 0;
string one = " ";
string two = " ";
string three = " ";
string four = " ";
string five = " ";
string six = " ";
string seven = " ";
string eight = " ";
string nine = " ";
string ten = " ";
int minutes = 120;
class Team
{
public:
string name;
int overall, game;
int win, loss;
string week1, week2, week3, week4, week5, week6, week7, week8, next;
}; | {
"domain": "codereview.stackexchange",
"id": 39714,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, beginner, object-oriented, game",
"url": null
} |
in computer science, suppose we are given n objects, a1,a2,,an, to sort. 1 Factorials, Permutations and Combinations Fundamental Counting Principle: counts the number of ways a task can occur given a series of events. Then (12)α 6= (12) β. Putting all of this together, we can see that, in the case of an even n, the number of permutations where no adjacent numbers of the same parity is 2*((n/2)!) 2. [3] There are two main ways to calculate permutations and it will differ whether you allow repetition or. Now, again we independently choose a permutation of odd and even numbers, and in the case where n is even, that number is (n/2)! in both cases. If n and r are positive integers, with n greater than r, then. They describe permutations as n distinct objects taken r at a time. If we want to generated all n C k combinations of n integers from 0. permutation 1. If Sn be the set consisting of all permutation of degree n then the set Sn will have n! different permutation of degree n. For example if we want to get permutations of ABC over only 2 places. Some Simple Counting Rules r-Permutations How many permutations of n distinct objects, taken r at a time are possible? Again, we have n ways of choosing the rst object. The sum of the cubes of the first n odd numbers is 2n 4 - n 2 = n 2 (2n 2 - 1). Nov 27, 2013 · Permutations of n elements are: Example: Specify the number of permutations of the letters contained in the student OSIS! Permutations of n unsure are: Answer: O = 1 S = 2 I = 1 n = number of the letters = 4, Thus 3. Counting problems using permutations and combinations. So a string with n. can be represented as a permutation on nelements, 1 to n, storing a ranking is equivalent to storing a permutation. Let β be any other odd permu-tation (β 6= α). How many different ways can they be seated?. If such arrangement is not possible, it must be rearranged as the lowest possible order i. Furthermore, we see that | {
"domain": "tvniederrhein.de",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9805806472775278,
"lm_q1q2_score": 0.8150027796464006,
"lm_q2_score": 0.8311430394931456,
"openwebmath_perplexity": 409.6601729542495,
"openwebmath_score": 0.7891137003898621,
"tags": null,
"url": "http://glyk.tvniederrhein.de/permutation-of-numbers-from-1-to-n.html"
} |
c++, algorithm, graph
// Since we have defined output operators for edge and vertex
// We can do the same for graph:
friend std::ostream& operator<<(std::ostream& s, graph const& g)
{
std::copy(v.vertexes.begin(), v.vertexes.end(),
std::ostream_iterator<vertex>(s, "\n"));
return s;
}
// Now you can print a graph like this:
// std::cout << g;
};
After cleaning up all the comments.
It looks like this:
Headers
#include <iostream>
#include <list>
#include <vector>
#include <iterator>
Edge
class edge
{
int destination_vertex;
public:
int getDest() const {return destination_vertex;}
edge(int ver)
: destination_vertex(ver)
{}
friend std::ostream& operator<<(std::ostream& s, edge const& e)
{
return s << e.destination_vertex;
}
};
Vertex
class graph;
class vertex
{
friend class graph;
int id;
std::list<edge> list;
public:
vertex(int id)
: id(id)
{}
friend std::ostream& operator<<(std::ostream& s, vertex const& v)
{
s << v.id << "->";
std::copy(v.list.begin(), v.list.end(),
std::ostream_iterator<edge>(s, ","));
return s;
}
};
Graph
class graph
{
private:
std::vector<vertex> vertexes;
int next;
public:
graph()
: next(0)
{} | {
"domain": "codereview.stackexchange",
"id": 3930,
"lm_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, graph",
"url": null
} |
quantum-mechanics, wavefunction, quantum-information, complex-numbers
'Real quantum theory' is defined analagously, but with a real-valued Hilbert space in (1).
Renou et al's game
They give a spesific game involding 'entanglement teleportaiton' which complex quantum theory allows but real quantum theory does not. Basically, it works by having A and B share a Bell pair, B and C share a different Bell pair, and B performing a Bell measurement on the two halves of the pairs they have access to, resulting (in complex quantum theory) in A and C now sharing a Bell pair. The entanglement between AB and BC has been 'teleported' to be between AC, despite A and C never interacting. Reproducing this in a real values quantum theory is not posible. Interestingly, they need a 'multi-party' Bell-like game to separate real and complex theories; a regular 'single-party' Bell game keeps the same predictions in both. Still, multiparty games of this type (if not exactly this game) have been performed before.
Chen et al impliments this game precisely on superconducting quanutm hardware. You can see in Fig2 they make 2 Bell pairs (labeled EPR), and then perform a bell measurements (labeled BSM). They show what we should expect is true for complex quantum theory. (If you're especially interested, I'll note that this game is quite easy to impliment on current superconducting hardware, and it would not be a stretch to reproduce it on IBM's quantum experience.)
Locality
Assumption (4) above is perhaps non-descript but important; it corresponds to locality of information in the theory, sometimes called 'Local Tomography'. Renou et al notes that while their game distinguishes real and complex quantum theory with assumption (4), it is easy to construct a real valued theory that prefectly matches quantum theory by also violating (4) and introducing some non-locality. Examples they give include the path-integral formalism and Bohmian mechanics. To return to the game above, reproducing the result in a real quantum theory is only possible if you add some non-locality that lets you reproduce the necessary correlations between A and C. | {
"domain": "physics.stackexchange",
"id": 85732,
"lm_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, quantum-information, complex-numbers",
"url": null
} |
for $$0<x<1$$. Now, we can use the joint p.d.f $$f(x,y)$$ that we were given and the marginal p.d.f. $$f_X(x)$$ that we just calculated to get the conditional p.d.f. of $$Y$$ given $$X=x$$:
$$h(y|x)=\dfrac{f(x,y)}{f_X(x)}=\dfrac{\frac{3}{2}}{\frac{3}{2}(1-x^2)}=\dfrac{1}{(1-x^2)},\quad 0<x<1,\quad x^2 \leq y \leq 1$$
That is, given $$x$$, the continuous random variable $$Y$$ is uniform on the interval $$(x^2, 1)$$. For example, if $$x=\frac{1}{4}$$, then the conditional p.d.f. of $$Y$$ is:
$$h(y|1/4)=\dfrac{1}{1-(1/4)^2}=\dfrac{1}{(15/16)}=\dfrac{16}{15}$$
for $$\frac{1}{16}\le y\le 1$$. And, if $$x=\frac{1}{2}$$, then the conditional p.d.f. of $$Y$$ is:
$$h(y|1/2)=\dfrac{1}{1-(1/2)^2}=\dfrac{1}{1-(1/4)}=\dfrac{4}{3}$$
for $$\frac{1}{4}\le y\le 1$$.
What is the conditional mean of $$Y$$ given $$X=x$$?
Solution | {
"domain": "psu.edu",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9890130596362788,
"lm_q1q2_score": 0.8085918407749154,
"lm_q2_score": 0.8175744828610095,
"openwebmath_perplexity": 111.56740183510094,
"openwebmath_score": 0.9511004090309143,
"tags": null,
"url": "https://online.stat.psu.edu/stat414/book/export/html/735"
} |
quantum-field-theory, particle-physics, field-theory, fourier-transform, wave-particle-duality
They are only interested in obtaining results
They usually are lazy to decipher mathematitician's language that differs sometimes from the their language considerably. And unlike physicist mathemations more often than not do not give "the complete idiot's explanation of my idea" in their papers.
There is often an actual physical reason to consider model as a limit of regularized stuff
They often work with bad models (like non-renormalizable effective QFTs) that actually have regularization-dependence and other issues. And while mathematicians with give you their abstract constructs we return to the reasons 1-3 for the physicsit to skip them.
In fact most physicists don't care even about all the complicated stuff about QM: that there is all these stuff about definitions on dense subspaces, about self-adjoint extensions of symmetric operators, about rigged Hilbert spaces etc. When they find the issues with naive ways they usually regularize the problem and take the limit and reinvent e.g. symmetric operator with multiple self-adjoint extensions in the fashion they need for their physics problem. Or find that actually this limiting definition pinpoints the specific self-adjoint extensions whereas the abstract approach do not give you the answer. I personally had such experience.
So if you are a physicst do not cling to any nice model and actually absorb all viewpoints because you don't know which one will actually be more useful in the future. | {
"domain": "physics.stackexchange",
"id": 97302,
"lm_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, particle-physics, field-theory, fourier-transform, wave-particle-duality",
"url": null
} |
java, json, spring
Title: Read from dynamic source and caching I want to load JSON data from a link at the beginning of an application.
I need to be a little bit about clear the following code.
And also want to ask about another opinions that what could be the best approach if I need to read from a URL and want to read data from this resource.
package com.app;
import com.app.entity.Event;
import com.app.service.EventCommandService;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
@SpringBootApplication
public class Application {
static HttpURLConnection connection;
Logger logger = LoggerFactory.getLogger(Application.class);
@Value("${url.path}")
String urlValue;
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
CommandLineRunner runner(CommandService CommandService) {
return args -> {
BufferedReader reader;
String line;
StringBuilder responseContent = new StringBuilder();
// read json and write to db
ObjectMapper mapper = new ObjectMapper();
TypeReference<List<Event>> typeReference = new TypeReference<>() {
};
try {
URL url = new URL(urlValue);
connection = (HttpURLConnection) url.openConnection(); | {
"domain": "codereview.stackexchange",
"id": 43680,
"lm_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, json, spring",
"url": null
} |
ds.algorithms, co.combinatorics, randomized-algorithms
Theorem 1. There is a poly-time algorithm for the problem.
We give a direct proof, then another proof using Hall's theorem.
Both proofs use the following utility lemma,
which recasts the problem into a more convenient form.
Fix a problem instance $(S_1, S_2, \ldots, S_n)$.
The problem is to decide
whether the instance is feasible,
meaning that there exists $C\subseteq [n]$
such that $n-1 \ge |C| = |\bigcup_{i\in C} S_i| \ge 1$.
If there is a set $S_i$ of size 1, the instance is feasible
(take $C=\{i\}$), so assume otherwise.
Note that in the definition above
WLOG we can restrict to collections $C$
containing at least one index $a$ with $|S_a| \ge 2$,
and not containing at least one other index $b\in[n]$.
Given $(a,b)\in [n]\times [n]$ with $|S_a| \ge 2$ and $a\ne b$,
define subproblem $\mathcal S(a, b)$ as follows.
Let $S'_1, S'_2, \ldots, S'_{n-2}$ be obtained
from $S_1, \ldots, S_n$ by
removing the two sets $S_a$ and $S_b$,
then replacing each remaining set $S$
by $(S \setminus S_a) \cup \{n+1, n+2, \ldots, n+|S_a|-2\}$.
(This removes all elements in $S_a$ from the problem,
and adds $|S_a|-2$ new elements to each remaining set.
Intuitively, this
forces $S_a$ to be chosen,
forces $S_b$ not to be chosen,
and artificially increases the size of any (non-empty)
union of the sets by $|S_a|-2$.)
The subproblem is to determine whether
$\mathcal S(a, b)$ is feasible, | {
"domain": "cstheory.stackexchange",
"id": 5790,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ds.algorithms, co.combinatorics, randomized-algorithms",
"url": null
} |
c++
void PreliminaryTest::send_the_report_for_confirmatory_test()
{
// Use iterators to access to the algorithms
// I know this is lengthy but this is standard for almost all STL containers like deque, vectors etc.,
// This method is called half open and closed iterators
// itr = iterators which links algo to the container
std::list<std::string>::iterator itr1 = preliminary_result.begin();
std::list<std::string>::iterator itr2 = preliminary_result.end();
for (std::list<std::string>::iterator itr = itr1; itr != itr2; ++itr)
{
std::cout << "\nSending the result for confirmatory test...\n";
preliminary_test_result.push_back(*itr);
std::cout << *itr;
}
std::list<std::string>::iterator itr3 = preliminary_test_result.begin();
std::list<std::string>::iterator itr4 = preliminary_test_result.end();
for (std::list<std::string>::iterator itr = itr3; itr != itr4; ++itr)
{
std::cout << "\nProcessing confirmatory test...\n";
std::cout << *itr;
confirm(*itr);
}
}
confirmatory.h
// SWAMI KARUPPASWAMI THUNNAI
#pragma once
#include"headers.h" | {
"domain": "codereview.stackexchange",
"id": 22921,
"lm_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
} |
c++, algorithm, 2048
std::string clockwiseMovementTransform(std::string movement)
{
for (auto &c : movement)
switch (c)
{
case 'r':
case 'R':
c = 'd';
break;
case 'd':
case 'D':
c = 'l';
break;
case 'l':
case 'L':
c = 'u';
break;
case 'u':
case 'U':
c = 'r';
break;
}
return movement;
} | {
"domain": "codereview.stackexchange",
"id": 31876,
"lm_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, 2048",
"url": null
} |
electromagnetism, geometry, orbital-motion
Title: Uniqueness and existence of polygonal orbits through a spherical shell Say we have a spherical wire mesh raised to a negative voltage. Then let's say we release a proton from near the surface, and away from the surface, at some angle and speed. Also, imagine that the proton will always miss the mesh wires and pass through the surface.
The field in the center of this sphere is zero, so the proton travels in straight lines there, and outside of the sphere the proton travels in elliptical orbits with one focus located at the center of the sphere.
If the proton exits 3 times and winds up back at the same point it started, I imagine its trajectory would look something like this, where the dotted lines are the other part of the elliptical orbit that did not travel.
I wonder about a few things about this:
Is the above idea possible in the first place?
would it be possible to have a 2-exit orbit in the same sense?
Is there only one combination of angle and velocity you can release it at to get a N-gon orbit?
Alternatively, is there a relationship between angle and speed that fits such an N-gon orbit? | {
"domain": "physics.stackexchange",
"id": 7505,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "electromagnetism, geometry, orbital-motion",
"url": null
} |
molecular-genetics, pathology, gene-expression, mammals, literature
Title: Specific mechanism behind lethality of yellow coat color in mice Our high school genetics chapter has some extra information about L.Cuenot. It only covered his research, and the fact that mice homozygous for yellow coat color would die before birth. It was an example of a lethal allele.
We have learned about sickle cell anemia, thalassemia, and hemophilia. All of them had a specific reason/mechanism which caused damage. For example, it's not the shape of the red blood cell in itself which is problematic, it is the fact that it can't carry enough oxygen. Therefore the cell will die off much quicker than normal cells.
I asked few of the biology teachers why the yellow coat color was lethal, but they couldn't provide any answer.
My question is, what causes the mice to die before birth?
Links to relevant articles or excerpts from them are highly appreciated. Really interesting question: The lethal yellow mutation (also abbreviated Ay) affects the agouti signalling protein which plays a major role in pigmentation. Heterozygous expression of it leads to the dominant expression of pheomelanin (which is yellow), causing the mice to express this color (among other effects). To understand why it is homozygous embryonic lethal, we need to take a further look at the gene and its organisation.
Agouti is located on chromosome 2 of the mouse genome and downstream of a gene called "Raly" (synonymous also MERC)(Image from NCBI Genes)
The Ay mutation now deletes a large chunk of DNA, removing about 170kb between these genes. This removes parts of the coding sequence of the Raly gene and the complete promoter and (non-coding) exon1 of the Agouti gene and results in a fusion protein in which the agouti gene is put under the control of the Raly promoter. This leads to the expression of Agouti every time when Raly should be turned on.
Schematically, this looks like this (figure 4 from reference 2): | {
"domain": "biology.stackexchange",
"id": 10939,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "molecular-genetics, pathology, gene-expression, mammals, literature",
"url": null
} |
universe, differential-geometry, integration, holographic-principle
Some people including Leonard Susskind and Steve Shenker etc. do suspect that there exists some "conceptually simple" proof of the holography in which almost all the degrees of freedom in the volume would be unphysical or topological – some huge gauge symmetry that allows one to eliminate all the bulk degrees of freedom except for some leftovers on the surface. But such a proof of holography remains a wishful thinking. Meanwhile, we have several frameworks – especially the AdS/CFT – that seem to unmask the actual logic behind holography. The surface theory is inevitably "strongly coupled" (i.e. strongly dependent on quantum corrections) if the volume description appears at all so things can't be as simple as you suggest, it seems. | {
"domain": "physics.stackexchange",
"id": 5698,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "universe, differential-geometry, integration, holographic-principle",
"url": null
} |
java
private final K key;
private final V value;
public KeyValuePair(K key, V value) {
this.key = key;
this.value = value;
}
// Arbitrarily decide to sort null keys first. Values are disregarded for
// the purposes of comparison.
@Override
public int compareTo(KeyValuePair<K, V> item) {
if (this.key == null) {
return (item.key == null) ? 0 : -1;
} else {
return this.key.compareTo(item.key);
}
}
public K getKey() {
return this.key;
}
public V getValue() {
return this.value;
}
@Override
public boolean equals(Object other) {
if (other == null || !this.getClass().equals(other.getClass())) {
return false;
}
KeyValuePair item = (KeyValuePair)other;
return (this.key == null ? item.key == null : this.key.equals(item.key)) &&
(this.value == null ? item.value == null : this.value.equals(item.value));
}
@Override
public int hashCode() {
return ((this.key == null) ? 0 : this.key.hashCode()) ^
((this.value == null) ? 0 : this.value.hashCode());
}
} | {
"domain": "codereview.stackexchange",
"id": 4673,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "java",
"url": null
} |
ros, rosdep-install, rosjava, android
Title: ROS Android project-rosmake failed
Hi guys, I am trying to set up the environment for developing a ROS Android application and I followed the tutorial here and I got stuck when I tried to rosmake "android_app_chooser". At first I get the error "Failed to find stack for package actionlib_java", but then by following the tutorial to downgrade the rosjava_android repository seems to have solve the error.
So I run the rosmake command again, but this time I get another error "Failed to find rosdep daemontools for package android_app_chooser on OS:ubuntu version:lucid
[ rosmake ] rosdep install failed: Rosdep install failed ". Can anyone tell me where I did wrong and help me solve the problem?
Edit1:By the way, by browsing through other questions here I found some proposed solution such as running sudo apt-get install ros-electric-turtlebot but to no success as when I tried to run sudo-apt-get install daemontools it says my daemontools is already the latest version.
P/S: Honestly I have tried few approaches on setting up such environment but to no success so far. I would really appreciate if someone can upload a VM image that can run the android examples as well as developing one. Thanks a lot.
Originally posted by steven7 on ROS Answers with karma: 1 on 2012-09-20
Post score: 0
The current way to do Android / ROS development is to use the android_core package by Damon Kohler. I don't think the ROS electric Android stuff is supported any more.
Originally posted by jbohren with karma: 5809 on 2012-09-20
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by orion on 2012-09-21:
I have followed the android_core package by Damon Kohler and it works well. This is the correct and current way to do ROS on Android. | {
"domain": "robotics.stackexchange",
"id": 11082,
"lm_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, rosdep-install, rosjava, android",
"url": null
} |
lagrangian-formalism, string-theory, differential-geometry, metric-tensor, action
Title: Polyakov action I've started to read something about strings and I feel a little confused with the Polyakov action. The reason is because in this action you get two metrics, one of them is the induced metric over the world-sheet and the other is an arbitrary metric on every point of this world-sheet.
This is the definition I have of the Polyakov action:
$\int d\tau d\sigma(-\gamma)^{1/2}\gamma^{ab}h_{ab}$
Here $h_{ab}=\partial_{a}X^{\mu}\partial_{b}X^{nu}g_{\mu\nu}$ and is called induced metric, because you can get it from the metric of the spacetime. On the other hand, the second one $\gamma^{ab}$ is called metric as well, but is dynamical and arbitrary, because is as a field smeared on worldsheet, this new dynamical metric don't have any relation to $h_{ab}$, this $\gamma^{ab}$ get a dependence on $h^{ab}$ only when we start to work with the EOM with regard to this metric.
So now I'm confused. Which of this metrics $h^{ab}$ or $\gamma^{ab}$ I must use to rising and lowering indices in a tensor living in the world-sheet?
My answer would be $h^{ab}$, because it has a geometric meaning , but then why you give the name of metric to the other field $\gamma^{ab}$ The key here is to distinguish between two different manifolds. We have $M$ taken to be space-time, and within this manifold $M$, we imagine a string propagating which sweeps out a surface $\Sigma \subset M$.
The embedding functions of $\Sigma$ are $X^\mu(\tau,\sigma)$ which carry a $\mu$ index over space-time but are functions of coordinates defined for $\Sigma$ treated as a manifold in its own right.
The Polyakov action is, | {
"domain": "physics.stackexchange",
"id": 37791,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "lagrangian-formalism, string-theory, differential-geometry, metric-tensor, action",
"url": null
} |
mvc, ios, swift
Title: Model for math facts I've written a model for an app that generates math facts kids have to solve by evaluating the operation and the difficulty you pass to it at initialization.
I don't like how I am repeating the code that performs the operations. For instance, performAddition() and performMultiplication() both perform the same thing. How can I make this model better?
import UIKit
class QuestionGenerator: NSObject {
enum BinaryOperation {
case Addition
case Subtraction
case Multiplication
case Division
}
enum Difficulty {
case Easy
case Intermediate
case Difficult
}
struct Settings {
var binaryOperation: BinaryOperation
var difficulty: Difficulty
}
private var brain: Settings
var number1: Int = 0
var number2: Int = 0
var answer: Int = 0
init(operation: BinaryOperation, difficulty: Difficulty) {
brain = Settings(binaryOperation: operation, difficulty: difficulty)
super.init()
}
func newQuestion() {
switch brain.binaryOperation {
case .Addition:
performAddition()
break
case .Multiplication:
performMultiplication()
break
default: break
// operation not implemented yet
}
}
private func performAddition() {
switch brain.difficulty {
case .Easy:
number1 = Int.random(1...10)
number2 = Int.random(1...10)
case .Intermediate:
number1 = Int.random(10...100)
number2 = Int.random(10...100)
case .Difficult:
number1 = Int.random(109...999)
number2 = Int.random(109...999)
}
answer = number1 + number2
} | {
"domain": "codereview.stackexchange",
"id": 20294,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "mvc, ios, swift",
"url": null
} |
organic-chemistry, stereochemistry, isomers
Title: How many stereoisomers are possible for hepta-1,6-diene? I am asked to identify the number of stereoisomers that are possible for hepta-1,6-diene $(\ce{H2C=CHCH2CH2CH2CH=CH2})$.
I drew the bond-line structure as follows, and I think that there can be cis and trans isomers, but my answer is wrong. The correct answer states that since neither of the double bonds exhibit stereoisomerism, this compound does not have any stereoisomers.
Originally, I thought that single bonds can be considered too. But I think I my error is that by looking at the single bonds, we are considering the constitutional isomers of this compound, rather than the stereoisomers (which are determined by the 'fixed' double bonds). Since double bonds lack the free rotation that single bonds have, for any compound that may exhibit stereoisomerism, we can only consider the double bonds. Also, are we considering only one double bond at a time?
Is this reasoning correct? Can someone clarify and expound more on this please? In the case of your original drawing with the terminal double bonds, there are no E or Z (trans or cis) isomers!
E and Z isomers are only possible if both ends of the $\ce{C=C}$ double bond each carry a substituent other than a hydrogen atom.
As far as the other structure is concerned, E and Z isomers look as follows: | {
"domain": "chemistry.stackexchange",
"id": 3393,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "organic-chemistry, stereochemistry, isomers",
"url": null
} |
physical-chemistry, thermodynamics, equilibrium, kinetics
I tried to go back to the Arrhenius equation to understand this. Arrhenius' equation gives a relation for the forward rate constant $k_{f}$ of the reaction with its activation energy $E_{a}$
$$k_{f}=Ae^{-\frac{E_{a}}{RT}}$$
and we take $k_{eq}=\frac{k_{f}}{k_{b}}$. However, it doesn't improve my understanding on the subject because we have to assume $\Delta H$ to be constant with temperature to get equation (i). There is no need to invoke the Arrhenius equation to understand it. I will give the various form of that equation so you are out of doubts.
The significance is clear when you go back to the differential form, this is, van't Hoff's equation
$$ \boxed{\frac{\mathrm{d}\ln K}{\mathrm{d}T} = \frac{\Delta_\mathrm{r} H^\circ(T)}{RT^2}} \tag{1}$$
in words: $\Delta_\mathrm{r} H^\circ$ is the enthalpy of reaction when $1$ mol of $A$ in its standard state at temperature $T$ reacts with $1$ mol of $B$ in its standard state at temperature $T$, to yield $2$ mol of $C$ in its standard state at temperature $T$ and $1$ mol of $D$ in its standard state at temperature $T$.
The following points are true: | {
"domain": "chemistry.stackexchange",
"id": 17448,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "physical-chemistry, thermodynamics, equilibrium, kinetics",
"url": null
} |
python, html, parsing, logging, modules
This is the Report class that represents the HTML report:
import os
from .utils import get_date
class Report:
"""
A simple report class that store data related to report.
Reports with the same date counts as equal.
"""
def __init__(self, path, data=None):
self.path = path
self.name = os.path.split(self.path)[1]
self.date = get_date(self.name)
self.data = data
@property
def programs(self):
"""Returns parsed programs for a report"""
return self.data.keys()
@property
def timings(self):
"""Returns parsed timings for a report"""
return self.data.values()
def items(self):
return self.data.items()
def __eq__(self, other):
return self.date == other
def __gt__(self, other):
return self.date > other
def __lt__(self, other):
return self.date < other
def __ge__(self, other):
return self.__gt__(other) or self.__eq__(other)
def __le__(self, other):
return self.__lt__(other) or self.__eq__(other)
def __hash__(self):
return hash(self.date)
def __repr__(self):
return "Report({}, {})".format(self.name,
self.date.strftime('%Y_%m_%d'))
This is Storage class which is used to store the Reports and do some job on sequences of Reports:
import pickle
from collections import defaultdict, Sequence
from datetime import timedelta
from .report import Report
from .utils import update_default_dict, convert_date
class Storage:
"""Storage class""" | {
"domain": "codereview.stackexchange",
"id": 27917,
"lm_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, html, parsing, logging, modules",
"url": null
} |
c++, edit-distance
Title: Edit distance function Could you please help me to review my first function (modified from an example) in terms of best practice, coding style suggestions and any obvious language mistake/improvements?
unsigned int edit_distance(const vector<string> &s1, const vector<string> &s2)
{
const size_t len1 = s1.size(), len2 = s2.size();
vector<vector<unsigned int>> d(len1 + 1, vector<unsigned int>(len2 + 1));
d[0][0] = 0;
for(unsigned int i = 1; i <= len1; ++i) d[i][0] = i;
for(unsigned int i = 1; i <= len2; ++i) d[0][i] = i;
for(unsigned int i = 1; i <= len1; ++i)
for(unsigned int j = 1; j <= len2; ++j)
{
unsigned int a = d[i - 1][j] + 1;
unsigned int b = d[i][j - 1] + 1;
unsigned int c = d[i - 1][j - 1] + (s1[i - 1] == s2[j - 1] ? 0 : 1);
d[i][j] = std::min( std::min(a,b), c);
}
return d[len1][len2];
} Do you want unsigned int or do you want std::size_t?
unsigned int edit_distance(const vector<string> &s1, const vector<string> &s2)
It comes down to what you are trying to convey.
The use of string and vector suggests you are doing using namespace std; try not to do this. Prefer to qualify your types: std::string and std::vector.
Personally, I prefer const on the right. But it's only a preference thing.
Only declare one variable per line:
const size_t len1 = s1.size(), len2 = s2.size(); | {
"domain": "codereview.stackexchange",
"id": 3939,
"lm_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++, edit-distance",
"url": null
} |
particle-physics, terminology, standard-model, conventions, mesons
I think you already understand what happens for the $B$ mesons: the $b$-quark is negatively charged so we follow the same scheme as for the Kaons. Unlike the Kaons we can distinguish the $B^0$ and $\bar B^0$ experimentally, so we see the $b$ quark in $\bar B^0$ production and decays and $\bar b$ quarks in $B^0$ production and decays. And thus we have to keep in mind that the $B$ particles contain $\bar b$ anti-particles and vice versa.
In short, remember this rule: the up-type quark content determines whether we consider the meson a particle or an antiparticle. The historical reason is that strangeness predates the quark model. | {
"domain": "physics.stackexchange",
"id": 69890,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "particle-physics, terminology, standard-model, conventions, mesons",
"url": null
} |
c, linked-list
ASans crashes @ node->next = NULL of addToList with heap-buffer-overflow.
What do you think of this implementation? - How can it be improved?
Special cases are bad. Eliminate them if possible.
Specifically, an empty list is not all that special.
Is an empty list any more special than an unexpectedly short list?
Extract useful functions if possible. Appending consists of finding the end, and prepending to it, two useful functions.
Do you write C or C++?
In C, casting the result of malloc() is heavily frowned upon, as it means useless repetition.
Avoid sizeof(TYPE).
One easily gets it wrong (as you do!!), it haphazardly sprinkles unchecked duplicate information (the type) about which has to be manually verified, and it impedes refactoring.
Use sizeof *target instead, which properly couples size and use.
Unless you are restricted to strict C90 or earlier, you can mix declarations and instructions. Doing so limits scope and simplifies code.
A pointer has a truth-value, no need to compare to a null pointer constant.
Use concise but precise names.
If you add to a list, where do you add it?
To every element.
Prepended.
Appended.
Behind a given node / index / value.
Randomly.
Arbitrarily.
...
C does not have namespaces, thus the use of prefixes to avoid collisions. Consider an appropriate one.
Dynamic allocation can fail. Deal with it. | {
"domain": "codereview.stackexchange",
"id": 43140,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c, linked-list",
"url": null
} |
php
Title: Need review on concatenation I am trying to concatenate the echo statements but I am failing. Also any other tips are appreciated in your review.
<?php
// load all 'category' terms for the post
$terms = get_the_terms($post->ID, 'category');
// we will use the first term to load ACF data from
if( !empty($terms) )
{
$term = array_pop($terms);
$custom_field = get_field('category_image', 'category_' . $term->term_id );
// do something with $custom_field
echo "<a href=" get_field('category_link', $custom_field) ">";
echo "<img src="<?php echo $image; ?>" alt="<?php echo get_cat_name($cat->term_id); ?>" class="item-image">";
echo "</a>";
}
?> The places where I have worked, as well as a number of articles I have read, have taught me that echoing HTML is bad practice, and really if you think about it from a maintenance perspective you want that clear separation of PHP and HTML. An example of your code with that separation:
<?php
$terms = get_the_terms($post->ID, 'category');
if(!empty($terms)){
$term = array_pop($terms);
$custom_field = get_field('category_image', 'category_' . $term->term_id );
?>
<a href="<?php echo get_field('category_link', $custom_field); ?>">
<img src="<?php echo $image; ?>" alt="<?php echo get_cat_name($cat->term_id); ?>" class="item-image" />
</a>
<?php } ?>
Or if you wanted to simplify it a bit for future readers:
<?php
$terms = get_the_terms($post->ID, 'category'); | {
"domain": "codereview.stackexchange",
"id": 5516,
"lm_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",
"url": null
} |
robotic-arm, ros, linux, ros-electric
Originally posted by StrongEnough on ROS Answers with karma: 11 on 2012-02-04
Post score: 0
Original comments
Comment by Stefan Kohlbrecher on 2012-02-04:
I'm not sure you can get Cortex A8 precompiled .debs. AFAIK, only i386 and amd64 are packaged right now. See also http://www.ros.org/debbuild/electric.html
Comment by joq on 2012-02-04:
I meant apt-get update, not upgrade.
Comment by StrongEnough on 2012-02-04:
I searched for this problem and saw nothing. Now, on the right, I see this issue http://answers.ros.org/question/1776/error-while-successful-sudo-apt-get-install-ros. Is it possible this is a mirror issue too? I'll look around for a way to change the mirror. I'm not a Linux expert yet.
Comment by StrongEnough on 2012-02-04:
Yes, You say "sudo apt-get upgrade" but I did "sudo apt-get update" per the instructions. Is that the problem? I don't have enough Karma to upload a screen shot, but in the Lucid "Software Sources, Other Software" tab; the item "http://packages.ros.org/ros/ubuntu lucid main" is checked.
Comment by joq on 2012-02-04:
Did you update the sources list? Is it correct? Did you apt-get upgrade?
You will have to build from source, see http://www.ros.org/wiki/electric/Installation/Ubuntu/Source
Originally posted by Kent Williams with karma: 91 on 2012-02-04
This answer was ACCEPTED on the original site
Post score: 3
Original comments
Comment by ahendrix on 2012-02-04:
Agreed. There are some debs available for ARM, but not nearly the full set that are available on x86. See http://ros.org/debbuild/electric.html for the current build status. | {
"domain": "robotics.stackexchange",
"id": 8109,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "robotic-arm, ros, linux, ros-electric",
"url": null
} |
python, programming-challenge, game, dice
def __str__(self) -> str:
return f"Player({self.name}): {self.score}"
def fetch_users() -> dict:
users = {}
with open(USERS_FILE, "r") as f:
users = dict([line.strip().split(",") for line in f])
return users
def authenticate(users: dict, name: str, password: str) -> bool:
return users.get(name) == password
def show_highscores() -> None:
with open(SCORES_FILE, "r") as f:
print(f.read())
def fetch_highscores() -> list:
scores = []
with open(SCORES_FILE, "r") as f:
for line in f:
name, score = line.strip().split(": ")
score = int(score)
scores.append((name, score))
return scores
def write_score(player: Player, limit: int = 5):
current_highscores = fetch_highscores()
current_highscores.append((player.name, player.score))
sorted_scores = sorted(current_highscores, key=itemgetter(1), reverse=True)
with open(SCORES_FILE, "w") as f:
for name, score in sorted_scores[:limit]:
f.write(f"{name}: {score}\n")
def get_player(_id: int, users: dict) -> Player:
print(f"Players {_id} login")
while True:
name = input("username: ")
password = input("password: ")
if authenticate(users, name, password):
return Player(_id, name)
print("Invalid details. Try again!") | {
"domain": "codereview.stackexchange",
"id": 39660,
"lm_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, programming-challenge, game, dice",
"url": null
} |
quantum-state, mathematics, bloch-sphere
\end{equation}
The expression for $|\psi^\perp \rangle$ from the question is different from this $|\psi^\perp \rangle$ by a global phase. The reason why I prefer this notation is that I want to keep Bloch sphere formalism (e.g. $0 \leq (\pi - \theta) \leq \pi$ constrant that is true for $|\psi^\perp \rangle$ presented here). Note that:
$$\langle \psi | \psi^\perp \rangle = \cos \frac{\theta}{2} \sin \frac{\theta}{2} - \sin \frac{\theta}{2} \cos \frac{\theta}{2} = 0$$
By doing the same calculations we can obtain for $|\phi\rangle= \gamma |\psi\rangle + \delta |\psi^{\perp}\rangle = \alpha |0\rangle + \beta |1\rangle$:
\begin{align*}
&\alpha = \gamma \cos \frac{\theta}{2} + \delta \sin \frac{\theta}{2}
\\
&\beta = \gamma e^{i\varphi}\sin \frac{\theta}{2} - \delta e^{i\varphi} \cos \frac{\theta}{2}
\end{align*}
Then (here I take into account that $|e^{i\varphi}| = 1$):
\begin{equation}
|\alpha|^2 = |\gamma|^2 \cos^2 \frac{\theta}{2} + |\delta|^2 \sin^2 \frac{\theta}{2}
+ 2 Re(\gamma) Re(\delta) \cos \frac{\theta}{2}\sin \frac{\theta}{2} +
2 Im(\gamma) Im(\delta) \cos \frac{\theta}{2}\sin \frac{\theta}{2}
\end{equation} | {
"domain": "quantumcomputing.stackexchange",
"id": 1412,
"lm_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-state, mathematics, bloch-sphere",
"url": null
} |
quantum-chemistry, bond, molecular-structure, molecular-orbital-theory
I also feel like depending on the value of $C_o$, the energy of this new state should vary continuously between the energy of the bonding state and the energy of the anti-bonding state? If this is the case, then the coupling that occurs when $N=2$ hydrogen nuclei are brought to within bonding distance of each other should result in an infinite continuum of energy eigenstates. Not merely two eigenstates. Similarly, when $N\approx 10^{23}$ atoms are brought within bonding distance of each other, we shouldn't get $N$ energy levels but rather an infinite amount of energy levels. This would then ruin the whole notion that energy bands in a solid of N atoms should each contain $N$ energy levels. Your problem seems to stem from confusing the number of linear independent basis functions(which is the same number as the size of the atomic orbital basis with which we started) and the number of all possible functions that can be built using this basis. Just as in a two dimensional vector space, where you have a maximum of two independent basis functions, but an infinite number of possible vectors by adding those two basis vectors by varying the coefficients.
A way to obtain eigenfunctions is to express the Hamilton operator in a basis, for example, the atomic orbital basis. If the basis is finite, we obtain a finite matrix representation for the Hamilton operator which can be diagonalized to obtain its eigenvectors. These eigenvectors are the molecular orbitals expressed with respect to the atomic orbital basis, which means that we get for each a molecular orbital a set of coefficients that tells us how to linearly combine the original atomic orbitals to form each molecular orbital. | {
"domain": "chemistry.stackexchange",
"id": 15960,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-chemistry, bond, molecular-structure, molecular-orbital-theory",
"url": null
} |
snakemake, conda
setuptools pkgs/main/linux-64::setuptools-46.1.3-py36_0
six pkgs/main/linux-64::six-1.14.0-py36_0
smmap pkgs/main/noarch::smmap-3.0.2-py_0
snakemake bioconda/linux-64::snakemake-5.3.0-py36_1
snakemake-minimal bioconda/linux-64::snakemake-minimal-5.3.0-py36_1
sqlite pkgs/main/linux-64::sqlite-3.31.1-h62c20be_1
tk pkgs/main/linux-64::tk-8.6.8-hbc83047_0
typing_extensions pkgs/main/linux-64::typing_extensions-3.7.4.1-py36_0
urllib3 pkgs/main/linux-64::urllib3-1.25.8-py36_0
wheel pkgs/main/linux-64::wheel-0.34.2-py36_0
wrapt pkgs/main/linux-64::wrapt-1.12.1-py36h7b6447c_1
xmlrunner conda-forge/noarch::xmlrunner-1.7.7-py_0
xz pkgs/main/linux-64::xz-5.2.5-h7b6447c_0
yaml pkgs/main/linux-64::yaml-0.1.7-had09818_2
yarl pkgs/main/linux-64::yarl-1.4.2-py36h7b6447c_0
zipp pkgs/main/noarch::zipp-2.2.0-py_0
zlib pkgs/main/linux-64::zlib-1.2.11-h7b6447c_3 | {
"domain": "bioinformatics.stackexchange",
"id": 1395,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "snakemake, conda",
"url": null
} |
python, image, gui, tkinter
Title: Image editing in the frequency space I wrote a little script that should load a GUI for deciding the bandpass filter.
I'm a hobbyist programmer so I look here for comments that will help to improve my code abilities.
The applet should look like this:
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 21 15:44:04 2017
@author: Mauro
The idea of the script is to create a small GUI managing the bandpass filter.
Since Tkinter can import only GIF image, an interface creates the images and
saves them in a buffer folder, that are then read by the GUI class
"""
#==============================================================================
# Define Imports
#==============================================================================
# TkInter
from tkinter import (Tk, PhotoImage, Label, Frame, Canvas, Entry, Button, Menu,
filedialog, StringVar, IntVar, Checkbutton)
# sys imports
from os import mkdir
from os.path import join, split, isdir, splitext
from shutil import rmtree
from copy import deepcopy
# matlibplot imports
from scipy.misc import imsave
# my imports
from MyImage_class import MyImage, Mask
from ImageFFT_class import ImgFFT
# todo:
# save files button: V
# save composite
# add loading screen
# support for RGB images | {
"domain": "codereview.stackexchange",
"id": 26174,
"lm_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, image, gui, tkinter",
"url": null
} |
ros, turtlebot, turtlebot-calibration
Originally posted by Jaap Reitsma on ROS Answers with karma: 76 on 2012-09-26
Post score: 2
To answer my own question: I remembered again this type of code: It is linear regression. The basics is that the wall is assumed to be straight and that the laser scanner or Kinect projects within a sufficient small window a number of scans with points (range, angle) on a straight line y = a.x + b. These polar coordinates are converted to (x, y) coordinates and inserted in a linear regression (least squares) formula. We are interested in the direction of the line, or better the perpendicular line (that is rotated 90 degrees). I think the code snip above is mixing the cos and sin as for a right-handed coordinate system the normal definition is x = r.cos(alfa). Because of the perpendicular line the final result is ok after all.
For a line you need of course at least 2 scan points, and for a reliable result many more. Perhaps you also need to average the angle for less noise.
Originally posted by Jaap Reitsma with karma: 76 on 2012-09-27
This answer was ACCEPTED on the original site
Post score: 4 | {
"domain": "robotics.stackexchange",
"id": 11142,
"lm_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, turtlebot, turtlebot-calibration",
"url": null
} |
# [SOLVED]derivative of ln(sin5x)
#### DeusAbscondus
##### Active member
Hi folks,
For some reason, the following does not make sense to me:
If 1. $$f(x)=ln(sin(5x))$$ then 2. $$f'(x)=5cot(5x)$$ but I can only get as far as
$$f(x)=ln(sin(5x))\implies\frac{1}{u}*5cosx=\frac{5cos(x)}{sin(5x)}$$
Can someone please show me how to get from here to 2.? Thanks kindly, DeusAbs
#### Sudharaka
##### Well-known member
MHB Math Helper
Hi folks,
For some reason, the following does not make sense to me:
If 1. $$f(x)=ln(sin(5x))$$ then 2. $$f'(x)=5cot(5x)$$ but I can only get as far as
$$f(x)=ln(sin(5x))\implies\frac{1}{u}*5cosx=\frac{5cos(x)}{sin(5x)}$$
Can someone please show me how to get from here to 2.? Thanks kindly, DeusAbs
Hi DeusAbscondus,
What you need here is the Chain rule of differentiation. Please refer the link given and try to understand how to use this rule so that you can easily differentiate the given function.
$f(x)=\ln(\sin(5x))$
Using the chain rule of differentiation we can write,
$\frac{d}{dx}f(x)=\frac{d}{d(\sin(5x))}f(x)\frac{d}{dx}\sin(5x)$
Try to continue from here.
Kind Regards,
Sudharaka.
#### CaptainBlack
##### Well-known member
Hi folks,
For some reason, the following does not make sense to me: | {
"domain": "mathhelpboards.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9763105280113491,
"lm_q1q2_score": 0.8336840088950818,
"lm_q2_score": 0.8539127510928476,
"openwebmath_perplexity": 1631.350638691949,
"openwebmath_score": 0.9007788300514221,
"tags": null,
"url": "https://mathhelpboards.com/threads/derivative-of-ln-sin5x.1602/"
} |
$\displaystyle |HQ|=\frac{|H| \cdot |Q|}{|H \cap Q|}=\frac{m^2}{|H \cap Q|}. \ \ \ \ \ \ \ \ \ \ \ \ (2)$
Since $Q$ is normal, $HQ$ is a subgroup of $G$ and thus, by $\displaystyle (2), \ \frac{m^2}{|H \cap Q|}$ must divide $|G|=pm$ and that is possible only if $|H \cap Q|=m.$ Thus $|H \cap Q|=|H|$ and hence $H \cap Q=H,$ which gives $H=Q$ because $|H|=|Q|.$ So $H$ is normal in $G$ and the solution is complete. $\Box$
Remark 2. Note that Problem 1 follows from Problem 4.
## Kernel of the commutator of two involutions
Posted: March 23, 2021 in Elementary Algebra; Problems & Solutions, Linear Algebra
Tags: , , ,
Problem. Let $V$ be a vector space over a field of characteristic $\neq 2.$ Let $f,g: V \to V$ be two linear transformations such that $f^2=g^2=I,$ where $I : V \to V$ is the identity map. Show that
$\ker(fg-fg)=\ker(f+g) \oplus \ker(f-g).$
Solution. We need to prove three things.
i) $\ker(f+g) \cap \ker (f-g)=(0).$
Proof. If $x \in \ker(f+g) \cap \ker (f-g),$ then
$2f(x)=(f+g)(x)+(f-g)(x)=0$
and so $f(x)=0$ hence $x=f^2(x)=0.$
ii) $\ker(f+g) + \ker(f-g) \subseteq \ker(fg-gf).$ | {
"domain": "wordpress.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.99253935499126,
"lm_q1q2_score": 0.8044322223327997,
"lm_q2_score": 0.8104789178257654,
"openwebmath_perplexity": 53.15373097102637,
"openwebmath_score": 0.984871506690979,
"tags": null,
"url": "https://ysharifi.wordpress.com/"
} |
java, algorithm, traveling-salesman
Title: Travelling Salesman Problem solver I am writing a program that can implement algorithms to solve the TSP. My goals:
The solver can record every algorithm step, so that the whole solving process can be later visualised by charts or animations
It's easy to add new algorithm implementation
End user has full control over the simulation parameters
I tried to do this before a year ago and even asked. Thought I will try this again with more knowledge.
Point - a basic structure used across the application to represent cities.
public class Point {
private final double x;
private final double y;
public double getX() {
return x;
}
public double getY() {
return y;
}
public Point(double x, double y) {
this.x = x;
this.y = y;
}
public Point(Random r, int rangeX, int rangeY) {
this.x = r.nextInt(rangeX);
this.y = r.nextInt(rangeY);
}
public double calculateDistanceToPoint(Point p) {
return Math.sqrt((this.x - p.x) * (this.x - p.x) + (this.y - p.y) * (this.y - p.y));
}
}
General solver
public abstract class TSPSolver {
protected ArrayList<Point> initialSetOfPoints = new ArrayList<>();
public abstract void solve();
public TSPSolver(int noOfPoints, Random r, int rangeX, int rangeY) {
for (int i = 0; i < noOfPoints; i++) {
addPoint(new Point(r, rangeX, rangeY));
}
}
public TSPSolver(ArrayList<Point> points) {
initialSetOfPoints = points;
}
public void addPoint(Point p) {
initialSetOfPoints.add(p);
}
}
Solver that can record and store history
public abstract class RecordableTSPSolver extends TSPSolver {
protected SolutionHistory solutionHistory = new SolutionHistory();
public RecordableTSPSolver(int noOfPoints, Random r, int rangeX, int rangeY) {
super(noOfPoints, r, rangeX, rangeY);
} | {
"domain": "codereview.stackexchange",
"id": 20167,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "java, algorithm, traveling-salesman",
"url": null
} |
classical-mechanics, vectors, rotational-kinematics
Title: Infinitesimal rotation vector Chapter 4.8, Goldstein 3rd ed classical mechanics under infinitesimal rotations
(p.166~167)
($\mathbf{B}$ is an orthogonal matrix and $\mathbf{r}$ is a position vector and $d\boldsymbol{\Omega}$ is the infinitesimal rotation
"vector" which we are trying to prove is indeed a vector)
If $d\boldsymbol{\Omega}$ is to be a vector in the same sense as $\mathbf{r}$, it must transform under $\mathbf{B}$ in the same way.
What is the author trying to say? Goldstein says that under a coordinate transformation by $\boldsymbol{B}$ we have $\boldsymbol{r'=Br}$ but not $d\boldsymbol{\Omega'=B\,d\Omega}\,.$ The correct transformation is
$$
\boldsymbol{d\Omega'=|B|B\,d\Omega={\rm det}(B)B\,d\Omega}\,.
$$
See his eq. (4.74) and also the accepted answer to this question. | {
"domain": "physics.stackexchange",
"id": 83830,
"lm_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, vectors, rotational-kinematics",
"url": null
} |
ros-kinetic
Title: Is it possible to implement ros in python GUI using tk
I'm creating a GUI for robot operations. I have created one using TK. Now I want to implement ROS to the GUI. Is it possible to implement ros in that python TK GUI program?
Thank you in advance.
Originally posted by Nannapaneni on ROS Answers with karma: 1 on 2018-04-03
Post score: 0
There are 2 ways to do this:
If you have ROS installed in the place, where you are going to run Tk program, you can simply use rospy Subscribers to subscribe to topics, where you will get the data.
If you want to run the Tk program in an OS, which doesn't have ROS, you can convert the messages to JSON format using rosbridge_suite and then use generic python packages to convert JSON to be compatible with your Tk package.
Originally posted by Akash Purandare with karma: 61 on 2018-04-03
This answer was ACCEPTED on the original site
Post score: 0 | {
"domain": "robotics.stackexchange",
"id": 30518,
"lm_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
} |
energy, nuclear
"[...] how many Joules per gram would a C14 nuclear diamond produce if it weighed 20 grams"
I think it's important to understand that the bolded/italicized phrase is redundant, because your are discussing (as did the article) the energy output per gram. So the per-gram output of a 20 gram battery is the same as that of a 1 gram battery. The 20 gram battery would have a total output of 14000 Joules in it's lifetime, where the one gram battery would have a total output of 700 Joules. The fact that the article, and your question, normalize to a per-gram basis is how they've maintained an apples-to-apples comparison.
The semantics get tricky when they talk about the mass of the diamond battery, and by my thinking this is where they may fail to give an apples-to-apples comparison. The diamond would not be pure $\ce{C^{14}}$, and at a minimum would contain a thin protective coating of non-radioactive $\ce{C^{12}}$ (protecting those on the outside from the radiation on the inside). So when they say "A diamond beta-battery containing 1 gram of $\ce{C^{14}}$", it is not made clear what the total mass of diamond would be (e.g. we aren't given the ratio of $\ce{C^{14}}$ to the $\ce{C^{12}}$ that would also be present).
That said, I think that the apples-to apples answer to your question, based on the information given in the article, is as follows:
Conventional 20 gram battery: 14000 Joules/day, for 1 day.
Nuclear 20 gram $\ce{C^{14}}$ battery: 300 Joules/day, for 5,730 years.
or, equivalently:
Conventional 1 gram battery: 700 Joules/day, for 1 day.
Nuclear 1 gram $\ce{C^{14}}$ battery: 15 Joules/day, for 5,730 years. | {
"domain": "chemistry.stackexchange",
"id": 7469,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "energy, nuclear",
"url": null
} |
newtonian-mechanics, energy, work
Title: Generalized version of work-energy theorem I know that for rigid bodies only the work-energy theorem states that the net work done on the body equals the change in kinetic energy of the body since a rigid body has no internal degrees of freedom and hence no other forms of energy such as potential energy.
Is there a most generalized form of work energy theorem that is valid for rigid as well as non rigid bodies and for conservative as well as non-conservative force?
I would like a work-energy equation that would be valid for point particles, rigid bodies and non-rigid bodies. The "generalized work energy theorem" is extremely simple:
The work done on or performed by the system equals the difference in energy of the system. The energy of the system is the sum of all different kinds of energies of your system: kinetic, potential, chemical, etc.
How does the work split across different types of energies? I can't tell you, that really depends on the body in question.
Ultimately, you only have two "energies": potential energy of conservative forces and kinetic energy. All other energies, such as heat or chemical energy or the like constitute an effective description of something that ultimately can be described by kinetic and potential energy only. Stored heat energy is undirected kinetic energy of internal degrees of freedom (how to model that is one of the questions of statistical mechanics and condensed matter theory). Chemical energy is mostly potential energy of atomic bonds and atoms. Reversible deformation results in potential energy from potential energy in distorted atomic bonds. There is no simple equation to accurately model all of it for every system - otherwise we wouldn't use effective descriptions and physicists would be out of work soon. | {
"domain": "physics.stackexchange",
"id": 34431,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "newtonian-mechanics, energy, work",
"url": null
} |
c++, networking, windows
SOCKET get_socket(Protocol protoc);
get_socket(Protocol::udp); // that's fine
get_socket(1); // that's bad and doesn't compile
You make your code more self-descriptive.
your Socket class
Your class suggests an other meaning, than it provides. It should handle the sending and receiving without the need, to specify the WINSOCKET explicit. The user shouldn't be forced to pass the WINSOCKET themselves. That's up to the class, to provide the correct socket (at least you are holding a socket as private member). Think about that, perhaps your class has simply the wrong name for its purpose.
use std::string instead of heap array
You are using a heap char array as a read buffer. This yields exception errors, and it isn't totally clear (at least for the user of the Socket class) who is responsible for the cleanup (delete[]) of this buffer. It is never a good idea, to hand back a pointer, and let the user cleanup the stuff by themselves. Instead, you should simply return a std::string. That's clean, smart and has no hidden traps. If the user decides, he doesn't need the buffer anymore, he can simply let it go out of scope and it will be deleted automatically. The problems are even bigger, when an exception is thrown by any part of your framework, the users code or any other part of the program. If you want to pass ownership, use the provided classes. For strings it's std::string, for every other point it is std::unique_ptr or std::shared_ptr.
When you think, "returning a char* has better performance than returning a std::string", that's not totally true. Most of modern compilers can optimize that. You should google for "return value optimization" (RVO). In C++17 it is guaranteed, but in c++11 or c++14 it might fail. But even in that cases, a simple move of the std::string happens, which is not as bad as it sounds. | {
"domain": "codereview.stackexchange",
"id": 28921,
"lm_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++, networking, windows",
"url": null
} |
c, windows, sdl, virtual-machine
else if (address == 0xFF41)
IOregister_STAT = (BIT_7 | (data & 0x78)) | IOregister_STAT & (BIT_1 | BIT_0); // Make sure the mode flag is not affected and the 7th bit always returns 1.
else if (address == 0xFF46)
{
IOregister_DMA = data;
for (int i = 0; i < 0xA0; i++)
emu.memory.sprite[i] = ReadMemory((IOregister_DMA << 8) + i); // If data is written to the OAM register, begin an OAM transfer.
}
else
emu.memory.ioRegs[address - 0xFF00] = data;
}
//else if ((address >= 0xFF4C) && (address <= 0xFF7F)) // Restricted memory space.
// return;
else if ((address >= 0xFF80) && (address <= 0xFFFE))
emu.memory.highRam[address - 0xFF80] = data;
else if (address == 0xFFFF)
IOregister_IE = 0xE0 + (data & 0x1F); // Only the low 5-bits of IE can be written.
}
//----------------------------------------//
// This instruction will add a given value//
// plus the carry flag to register A. //
//----------------------------------------//
void z80_ADC_A_immediate()
{
unsigned char value;
value = ReadMemory(emu.cpu.regs.PC); | {
"domain": "codereview.stackexchange",
"id": 32065,
"lm_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, windows, sdl, virtual-machine",
"url": null
} |
python, c++, c++11
def _factor_code(self):
'''
Yields the template specialization of the
conversion factor for each unit.
If a conversion factor has not been given for some
unit, this will throw a NameError.
'''
factor_code = string.Template('''
template <>
const double basic_convert<$unit>::factor = $value;
''')
non_cannon = (unit for unit in self._units if unit != self._canonical)
for unit in non_cannon:
if unit not in self._factors:
raise NameError('No conversion factor exists for {}'.format(unit))
yield textwrap.dedent(
factor_code.substitute(unit=unit, value=self._factors[unit])
)
def _ostream_operator(self):
'''Returns a string impelementing the ostream<< operator.'''
ostream_code = string.Template('''
template <typename T>
std::ostream& operator<<(std::ostream& os, $unit_name<T> unit)
{
return os << unit.value() << T::to_string();
}
''')
return textwrap.dedent(ostream_code.substitute(unit_name=self._unit_type))
def _literal_operators(self):
'''
Yields strings containing the implementation of the
user-literal operators for each unit. The suffix used
is an underscore followed by the unit name.
All literals are placed in an inner inline namespace
named "literals".
'''
# Generate this for long double and unsigned long long double,
# so that the the user can use integer values with their
# literals.
types = ('long double', 'unsigned long long int')
literals = string.Template('''
$unit_name<$unit> operator"" _${unit}($type d)
{
return $unit_name<$unit>(d);
}
''')
yield textwrap.dedent('''
inline namespace literals
{
''') | {
"domain": "codereview.stackexchange",
"id": 16195,
"lm_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, c++, c++11",
"url": null
} |
statistical-mechanics, partition-function
Clearly I am missing the point and do not fully understand the physics that is taking place here.
I would be most grateful if someone could give me some hints or an explanation that will dispel my confusion. | {
"domain": "physics.stackexchange",
"id": 37195,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "statistical-mechanics, partition-function",
"url": null
} |
general-relativity, metric-tensor, boundary-conditions, dirac-delta-distributions
Title: Israel first junction condition I am studying Eric Poisson's book A Relativist's Toolkit: The Mathematics of Black-Hole Mechanics and it states that the metric, $g_{\alpha \beta}$, can be expressed as a distributions-valued tensor:
$$g_{\mu\nu} = \Theta(\ell) g^{+}_{\mu\nu}+\Theta(-\ell) g^{-}_{\mu\nu}\tag{1} \, .$$
According to the book, differentiating this equation, one should get the following:
$$g_{\mu\nu , \gamma} = \Theta(\ell) g^{+}_{\mu\nu , \gamma}+\Theta(-\ell) g^{-}_{\mu\nu, \gamma} + \epsilon \delta(\ell)\left[ g_{\mu \nu} \right] n_{\gamma}\tag{2} \, .$$
However, I can't reach the last term. The book also says that from $(1)$ to $(2)$, the following identity is used:
$$n_{\alpha} = \epsilon \partial_{\alpha}\ell \, .$$ Nonetheless, I can't calculate the last term of Eq.$(2)$. Can you help me, please? | {
"domain": "physics.stackexchange",
"id": 93119,
"lm_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, metric-tensor, boundary-conditions, dirac-delta-distributions",
"url": null
} |
javascript, algorithm, programming-challenge
console.log(checkVersion("1.2.2","1.2.0")); // returns 1 as expected
console.log(checkVersion("1.0.5","1.1.0")); // returns -1 as expected
console.log(checkVersion("1.0.5","1.00.05")); // returns 0 as expected
console.log(checkVersion("0.9.9.9.9.9.9","1.0.0.0.0.0.0")) // returns -1 as expected;
The above function seems to be working fine with any random two version numbers that I've tried so far but when I try to submit the above function for the challenge, there is always one hidden test with two unknown version numbers that keeps failing. What logic am I missing in the above code?
EDIT:
Thanks to @RomanPerekhrest's comment below, I have found out that my regex is the problem. Instead of using the 2nd regex, I just remove any occurence of e from the z variable using the split() method and then just check if the first character is m or l and now the function is working correctly as seen in the following Code Snippet:
function checkVersion(a,b) {
let x=a.split('.').map(e=> parseInt(e));
let y=b.split('.').map(e=> parseInt(e));
let z = "";
for(i=0;i<x.length;i++) {
if(x[i] === y[i]) {
z+="e";
} else
if(x[i] > y[i]) {
z+="m";
} else {
z+="l";
}
}
if (!z.match(/[l|m]/g)) {
return 0;
} else if (z.split('e').join('')[0] == "m") {
return 1;
} else {
return -1;
}
} | {
"domain": "codereview.stackexchange",
"id": 37260,
"lm_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, algorithm, programming-challenge",
"url": null
} |
the norm for the example vector. The matrix norm of. Norms are 0 if and only if the vector is a zero vector. Sep 08, 2020 · Vector direction and magnitude. 28 (Matrix Norm subordinate to a vector norm). General class of p-norms: 1-norm: 2-norm: -norm: Properties of Vector Norms For any vector norm: These properties define a vector norm Matrix Norms We will only use matrix norms “induced” by vector norms: 1-norm: -norm: Properties of Matrix Norms These induced matrix norms satisfy: Condition Number If A is square and nonsingular, then If A. They are shown with an arrow $$\vec{a}$$. Namely Norm is a function with the concept of “length” 。. If axis is None then either a vector norm (when x is 1-D) or a matrix norm (when x is 2-D) is returned. N = vectorNorm(V); Returns the euclidean norm of vector V. 1-Norm of a Matrix; 2-Norm of a Matrix; Frobenius Norm of a Matrix; Infinity Norm of a Matrix; P-Norm of a. If norm type is User Defined, this VI uses user defined norm as the norm type. Infinity norm, the largest row sum of the absolute values of A. Most of the spaces that arise in analysis are vector, or linear, spaces, and the metrics on them are usually derived from a norm, which gives the "length" of a vector De nition 7. norm <- function(x, k) { # x = matrix with column vector and with dimensions mx1 or mxn # k = type of norm with integer from 1 to +Inf stopifnot(k >= 1) # check for the integer value of k greater than 0 stopifnot. All of them can be proven to satisfythenormproperties,andtheirdefinitionsare: 61 (Inalldefinitionsbelow,x = (x 1,x 2,. Norm An inner product space induces a norm, that is, a notion of length of a vector. If you think of the norms as a length, you easily see why it can't be negative. Calculate the 1-norm of the vector, which is the sum of the element magnitudes. Eigen also provides the norm() method, which returns the square root | {
"domain": "babyslove.de",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9859363750229257,
"lm_q1q2_score": 0.8299865329213281,
"lm_q2_score": 0.8418256532040707,
"openwebmath_perplexity": 753.3848851755552,
"openwebmath_score": 0.9124736785888672,
"tags": null,
"url": "http://babyslove.de/norm-of-a-vector.html"
} |
thermodynamics, temperature
Title: What is highest possible temperature?
The Planck and maximum temperature
In the Planck temperature scale, $0$ is absolute zero, $1$ is the Planck temperature, and every other temperature is a decimal of it. This maximum temperature is believed to be $1.416833(85)\times 10^{32}$ Kelvin, and at temperatures above it, the laws of physics just cease to exist.
It states that max. Possible temperature is plancks Temperature but i have read that temperature of negative kelvin is hottest temperature and is hotter than infinite temperature means also hotter than plancks Temperature but how its possible
(From What happens as you approach/cross the Planck temperature?)
I expect it's impossible to cross the Planck temperature, just like it's impossible to cross absolute zero or the speed of light.
At the Planck temperature, you start producing miniature Planck-mass black holes, which are the hottest black holes that can exist. If you try to put more energy in the system, you would get larger black holes, which are cooler, and they would start absorbing stuff and cooling things down.
If it's not possible, then how can we talk about infinite temperature? The point is that a system cannot be heated above the Planck temperature, which does not necessarily preclude systems from existing at a higher temperature (effectively $\infty$, here), just like the impossibility to accelerate a particle to $c$ doesn't mean there aren't particles speeding at $c$.
One could also say that the apparent paradox arises from using a naive concept of temperature, when a more precise one is necessary.
The answers you quote already clarify the role of the Planck temperature as an upper limit. Negative absolute temperatures exist in particular systems (typically with population inversion) and are better understood in a statistical mechanics context - see, e.g., Physical significance of negative temperature and How to make physical sense of negative temperatures. Why negative temperatures are effectively infinite (with regard to heat exchange) is well explained in the answers to:
Prove that negative absolute temperatures are actually hotter than positive absolute temperatures.
Also the Wikipedia entry on negative temperatures is useful: | {
"domain": "physics.stackexchange",
"id": 50689,
"lm_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, temperature",
"url": null
} |
However, as 'micromass' has pointed out, if you choose a small enough $\epsilon > 0$ so that $(1+\epsilon) r < 1$, then for some finite $N> 0$ we have $n+1 \leq (1+\epsilon)^n$ for all $n \geq N$, so for $n \geq N$ we have $0 \leq (n+1) r^n \leq [(1+\epsilon) r]^n$ and we can compare with the geometric series $\sum [(1+\epsilon) r]^n$. Note, however, that some such argument as this must be acknowledged and recognized in order for C to be a valid and well-founded answer. Without this realization, just saying it would, again, be false reasoning.
Last edited: Aug 5, 2015 | {
"domain": "physicsforums.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.98087596269007,
"lm_q1q2_score": 0.8776774720883306,
"lm_q2_score": 0.8947894590884705,
"openwebmath_perplexity": 1510.018116703927,
"openwebmath_score": 0.8369911313056946,
"tags": null,
"url": "https://www.physicsforums.com/threads/identifying-types-of-converging-series.826074/"
} |
robotic-arm, stepper-motor, power, gearing
Title: Stepper Motor: Direct Drive vs. Belt Drive vs. Geared Stepper Motor I have built a juggling machine. Each arm is driven by a 4A 23mm stepper motor. The motors are each driven by a TB6600 set to 800 microsteps. By trial and error, I have found that the motors skip when the drivers are set at 2A (running at 36v) but not when set at 3A.
The motors are directly attached to the panto-graph arm mechanism. Each arm makes 81 start-and-stop revolutions per minute. The each arm is at rest for 25% of the time. I believe this causes the arms to jerk and induces error into the balls trajectory.
The obvious advantage of direct drive is simplicity. The next easiest options are belt drive or a geared stepper motor.
Would a geared or belt drive help reduce the vibration in the mechanism?
Would I be able to run the drivers at a lower power setting if I used gearing?
This is the Arduino Code.
Video of the machine running.
Vibration is a matter of optimal motion control problem, not the type of motor that is used (as long as you used more than 16 micro steps for your steppers). You already used AccelStepper which is the best thing you can do without the complicated motion control.
If your system still works with slower speed than your current motor speed you are good to use a geared motor and lower your motor current. But if you need the same speed as the motor without gear, you need to rotate the stepper very fast which requires either high current or high voltage. For example, if your gear is 1:5 you need to run your stepper five times faster to achieve the same rotation speed. | {
"domain": "robotics.stackexchange",
"id": 2332,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "robotic-arm, stepper-motor, power, gearing",
"url": null
} |
mfcc, dct
I can't find out what I am doing wrong, any help will be appreciated. Thanks in advance.. I think you misinterpret the output coefficients of the DCT. If you want to look at the frequency content of your input signal, you need to look at the output of the triangular filter bank, before the DCT. So if there is a fricative, like an "s" sound, the outputs of the high frequency filter bank kernels will have a higher energy than when the input is a vowel. However, after the DCT you do not have this type of frequency information, because you take the DCT of a frequency-domain signal, not of a time-domain signal. So the "high-frequency" bins of the DCT output correspond to fast variations in the shape of the spectrum, not to high frequencies in the input (time-domain) signal. The very effect you see, is exactly what the DCT is supposed to do. It compresses the input data, in the sense that almost all information is contained in the lower DCT bins. Usually the higher DCT bins are not used, which in fact means that you are doing lossy compression of your data. Luckily it turns out the the information that is being thrown away is actually irrelevant for the performance of the speech recognizer, and neglecting this information makes the recognition even more robust.
Having said that, of course there can still be a bug in your code, but the effect you describe is actually a desired result and nothing to worry about. | {
"domain": "dsp.stackexchange",
"id": 985,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "mfcc, dct",
"url": null
} |
c#, performance, file, compression
try
{
//Attempt to extract to zip file
Say($"Attempting to extract files into: {zipDir}");
ZipFile.CreateFromDirectory(startDir, zipDir);
Success($"Extracted files successfully to: {zipDir}");
}
catch (Exception e)
{
//Catch any error that occurs during
//the archiving stage and log the error
//to a text file for further analysis
var programPath = System.Reflection.Assembly.GetExecutingAssembly();
FatalErr($"Something went wrong and the program cannot continue, exiting process with error code {e}..");
FatalErr("Writing error to file for further analysis.");
File.WriteAllText($"{programPath}/log/errorlog.txt", e.ToString());
}
Say("Press enter to exit..");
Console.ReadLine();
}
}
} As has been said in the stack overflow answer, the easiest way to improve performance is to use the alternate overload for ZipFile.CreateFromDirectory that supports you specifying the compression level.
ZipFile.CreateFromDirectory(startDir, zipDir, CompressionLevel.Fastest, false);
This tells the algorithm to prioritize speed over compression, so you trade size for time. Running some tests on my computer, it doesn't look like the compression algorithm has been used to maximize processor usage. It should be possible to improve the performance by using multiple threads to perform the compression, which is why zip products usually offer this as an option. Achieving this is however, a larger undertaking than just calling the library function so again it's a trade off between development time/complexity and run time.
As far as the rest of your code goes, I would consider moving your output methods behind an interface and implementing it in another class.
public interface IReporter {
string Success(string input);
string Warn(string input);
string Say(string input);
string FatalError(string input);
string MinorError(string input);
} | {
"domain": "codereview.stackexchange",
"id": 20102,
"lm_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, file, compression",
"url": null
} |
the-moon, earth, angular-diameter
As in the previous diagrams, the Moon & Earth circles are blue. The radii are approximately in their correct ratio in this diagram, but the distance between them is (of course) radically reduced, which magnifies the angular size. The large purple circle is the circle of radius $q$, the small pale purple circle makes it a bit easier to see that the angles are equal.
Let $M=(-d_1, 0)$ be the centre of the Moon and $E=(d_2, 0)$ be the centre of the Earth, as in the top diagram. We want to find points $P=(x,y)$ such that
$$\sin(\theta/2)=r_1/PM=r_2/PE$$
That is,
$$d_2^2((x+d_1)^2+y^2)=d_1^2((x-d_2)^2+y^2)$$
$$d_2^2(x^2+2d_1x+d_1^2+y^2)=d_1^2(x^2-2d_2x+d_2^2+y^2)$$
$$d_2^2x^2+2d_1d_2^2x+d_1^2d_2^2+d_2^2y^2=d_1^2x^2-2d_1^2d_2x+d_1^2d_2^2+d_1^2y^2$$
$$(d_2^2-d_1^2)x^2+2d_1d_2(d_1+d_2)x+(d_2^2-d_1^2)y^2=0$$
$$x^2+2\left(\frac{d_1d_2}{d_2-d_1}\right)x+y^2=0$$ | {
"domain": "astronomy.stackexchange",
"id": 6022,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "the-moon, earth, angular-diameter",
"url": null
} |
ros-melodic, octomap, ubuntu, ubuntu-bionic
/opt/ros/melodic/include/ros/message_traits.h: In instantiation of ‘static const char* ros::message_traits::MD5Sum<M>::value() [with M = grid_map::GridMap]’: /opt/ros/melodic/include/ros/message_traits.h:228:102: required from ‘const char* ros::message_traits::md5sum() [with M = grid_map::GridMap]’ /opt/ros/melodic/include/ros/advertise_options.h:92:39: required from ‘void ros::AdvertiseOptions::init(const string&, uint32_t, const SubscriberStatusCallback&, const SubscriberStatusCallback&) [with M = grid_map::GridMap; std::__cxx11::string = std::__cxx11::basic_string<char>; uint32_t = unsigned int; ros::SubscriberStatusCallback = boost::function<void(const ros::SingleSubscriberPublisher&)>]’ /opt/ros/melodic/include/ros/node_handle.h:252:7: required from ‘ros::Publisher ros::NodeHandle::advertise(const string&, uint32_t, bool) [with M = grid_map::GridMap; std::__cxx11::string = std::__cxx11::basic_string<char>; uint32_t = unsigned int]’ /home/emanuele/catkin_ws/src/map_ros/src/map_test.cpp:15:77: required from here /opt/ros/melodic/include/ros/message_traits.h:121:28: error: ‘__s_getMD5Sum’ is not a member of ‘grid_map::GridMap’ return | {
"domain": "robotics.stackexchange",
"id": 33111,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros-melodic, octomap, ubuntu, ubuntu-bionic",
"url": null
} |
context-free, formal-grammars, compilers, ambiguity, derivation
Title: Can a grammar that has only one leftmost derivation tree for every sentence, have more than one rightmost derivation tree for some sentence? I'm currently studying the book Engineering a Compiler by Keith Cooper, and in chapter 3, there is the following definition:
A grammar G is ambiguous if some sentence in L(G) has more than one rightmost (or leftmost) derivation.
One of the exercises asks the following:
When asked about the definition of an unambiguous context-free grammar on an exam, two students gave different answers. The first defined it as “a grammar where each sentence has a unique syntax tree by leftmost derivation.” The second defined it as “a grammar where each sentence has a unique syntax tree by any derivation.” Which one is correct?
I tried to deduce the definition of unambiguity by negating the definition of ambiguity the chapter has given me:
A grammar G is unambiguous if for every sentence in L(G) there is one and only one rightmost (and leftmost) derivation.
I changed the or to an and because not (a or b) = not a and not b
However most definition of ambiguity I managed to find online states that
A grammar G is unambiguous if for every sentence in L(G) there is one and only one rightmost (or leftmost) derivation.
I've also found that
If a grammar is unambiguous, that means that the rightmost derivation and the leftmost derivation of every sentence represent in the same parse tree.
Reading the last two quotes confuses me in many ways:
Does the or in the definition of unambiguity implies that there can exist an unambiguous grammar where for every sentence of it, there is only one leftmost derivation, but more than one rightmost derivation?
Does the last quote implies that I only need to find out if for a given grammar, every sentence of it has only one leftmost or rightmost derivation, because if there is, I don't need to find if the other derivation is unique because they're the same?
If the statement above is correct, does that mean that only the second student in the excercise are correct? Or that both students are correct?
Some other definitions of unambiguity state only about leftmost derivation. Which is correct? | {
"domain": "cs.stackexchange",
"id": 18893,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "context-free, formal-grammars, compilers, ambiguity, derivation",
"url": null
} |
ros-melodic, message-filters
In file included from /home/great_user/catkin_ws/src/marker/src/newOrganization.cpp:4:0:
/opt/ros/melodic/include/message_filters/cache.h: In instantiation of ‘ros::Time message_filters::Cache::getOldestTime() const [with M = std_msgs::String_std::allocator<void >]’:
/home/great_user/catkin_ws/src/marker/src/newOrganization.cpp:13:66: required from here
/opt/ros/melodic/include/message_filters/cache.h:321:44: error: ‘value’ is not a member of ‘ros::message_traits::TimeStamp<std_msgs::String_std::allocator<void >, void>’
oldest_time = mt::TimeStamp::value(*cache_.front().getMessage());
~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/ros/melodic/include/message_filters/cache.h: In instantiation of ‘ros::Time message_filters::Cache::getLatestTime() const [with M = std_msgs::String_std::allocator<void >]’:
/home/great_user/catkin_ws/src/marker/src/newOrganization.cpp:14:66: required from here
/opt/ros/melodic/include/message_filters/cache.h:304:44: error: ‘value’ is not a member of ‘ros::message_traits::TimeStamp<std_msgs::String_std::allocator<void >, void>’
latest_time = mt::TimeStamp::value(*cache_.back().getMessage()); | {
"domain": "robotics.stackexchange",
"id": 32025,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros-melodic, message-filters",
"url": null
} |
javascript, beginner, jquery, plugin, jquery-ui
Is there the better way to add a function to the option "buttons" to get the data and to go to a new dialog?
I don't believe there is a "better" way, though instead of using an object for the buttons option, an array could be utilized, which would allow more customization of the buttons. For example, the submit button could have a custom icon added to it and more custom event handlers, like mouseenter. See the code snippet at the end of this post for an example.
Feedback
Elements without ids
Your example contains only one form input (i.e. <input type="text" name="">), though it is typically rare to only have one form input. As soon as other text/radio/checkbox inputs are added, the way that is referenced in JavaScript will need to change. I would advise you to always add an id attribute to the elements and use those when referencing them in the JavaScript. So that text input could have an id attribute like id="username". Then the JavaScript can reference it using that attribute: $('#username').val().
The same is true for the <span> element that gets set with the text entered by the user. It would be wise to also give that element an id attribute and use it in the JavaScript code. This actually would prevent the title of the message dialog from getting updated with the name (see screenshot below). | {
"domain": "codereview.stackexchange",
"id": 29566,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "javascript, beginner, jquery, plugin, jquery-ui",
"url": null
} |
In a simple battery, the motion of ions is governed by electrochemical forces. You can not calculate voltage across the terminals as line integral along a path which leads inside the battery. You do not know the electric field inside the battery and you do not need to know about it. All you need to know is emf, the voltage you can measure with a voltmeter across the terminals -outside of the battery.
Connect a resistor to the battery, current will flow through the wires and through the resistor. Follow the current flow and trace the potential. If you start from the positive pole the potential will drop by IR on the resistor, and rise by the emf from the negative pole to the positive one across the battery. The net change of potential is zero, so emf = IR.
Notice that the current flows from the negative pole to the positive one inside the battery. Does it mean that the electric field points from negative to positive? Does it mean that the potential drops from the negative pole from the positive one? This would contradict the + and - signs written on the battery!
The motion of charged particles is beyond electricity inside the battery. You can not calculate voltage by integrating along a path which is inside the battery.
A coil is like a battery. Assume first that it is not an external current, that causes the flux change in time.
The time-varying magnetic field is beyond stationary electric fields and currents. Current flows as the time-varying magnetic field causes non-conservative electric field and that drives the electrons round the loops and out of the coil, across a voltmeter or resistor, causing a potential drop . The sign of the potential change is determined by the direction of current: Across the resistor or a voltmeter, the current flows from the place at positive potential towards the negative one.
Now it is your problem: The magnetic field is governed by an external current. The sign of emf of a voltage source is determined with respect to the current. It is negative if the current flows in at the positive pole. You have learnt what is the emf of a coil: it is negative with respect to the current if the current is increasing. Increasing current causes negative emf: that is, the current flows into the coil at the positive pole.
ehild
Last edited: Nov 3, 2009
20. Nov 3, 2009
### JustinLevy | {
"domain": "physicsforums.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9539661028358093,
"lm_q1q2_score": 0.8010777386460438,
"lm_q2_score": 0.8397339656668287,
"openwebmath_perplexity": 353.3727182362937,
"openwebmath_score": 0.7045296430587769,
"tags": null,
"url": "https://www.physicsforums.com/threads/voltage-across-an-inductor.350749/"
} |
symmetry, group-theory, higgs, lie-algebra, symmetry-breaking
0 & 0 & 0
\end{bmatrix}
$$
However the matrices are not $2 \times 2$ but $3 \times 3$.
Recalling the definition of $SU(2)$:
$$SU(2) \equiv \{ M \in GL(n, \mathbb{C}) | M^{\dagger} \mathbb{1}_2 M = \mathbb{1}_2, \,\, det(M)=1 \} $$
We notice that:
$$det(T_1)=det(T_2)=det(T_3)=0$$
Moreover thare is a dimensional problem in performing $T_1^{\dagger} \mathbb{1}_2 T_1,$ $\,\,$ $T_2^{\dagger} \mathbb{1}_2 T_2,$ $\,\,$ $T_3^{\dagger} \mathbb{1}_2 T_3$.
I'm quite lacking in group theory so I would need a step-by-step answer. Using concrete realization of this generators, you can easily check that $T_1, T_2, T_3$ are exactly $SU(2)$ and $T_8$ commute with them and so gives you $U(1)$. | {
"domain": "physics.stackexchange",
"id": 63881,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "symmetry, group-theory, higgs, lie-algebra, symmetry-breaking",
"url": null
} |
general-relativity, black-holes, spacetime, time-dilation
Title: Time dilation for different observer in black hole metric If I have a 2d Schwarzschild metric
$$
dS^2 = -(1-\frac{r_s}{r})dt^2 + \frac{dr^2}{1-\frac{r_s}{r}}
$$
I want to find the relation between the time of an asymptotic observer $t$ and the proper time of a free infalling observer $\tau$, I know that due to redshift I have
$$
d\tau = \frac{1}{\sqrt{1-r_s/r}}dt
$$
But I found this following formula on some online lecture notes, with not much explanation attached
$$
d\tau \sim e^{-t/r_s} dt
$$
How can I derive it?
Edit: I will add some information about the context.
We are considering a freely falling observer through the event horizon, and we are using Kruskal coordinates
$$
UV = r_s(r_s-r)e^{r/r_s},\qquad \frac{U}{V} = -e^{-t/r_S}
$$
giving the following metric
$$
dS^2 = -\frac{4r_s}{r}e^{-r/r_s}dUdV
$$
It says that a trajectory of the infalling observer is described by $V\sim$const and $U$ goes to zero linearly in their proper time $\tau$ (I don't get how to prove this also). The infalling observer proper time $\tau$ and the asymptotic observer time $t$ are related by
$$
d\tau \sim e^{-t/r_s} dt
$$
Why?
Physics Koan wrote: "I know that due to redshift I have..."
That assumes $\rm v=0, \ \ dr/dt=0, \ $ but if you're talking about
Physics Koan wrote: "...a free infalling observer" | {
"domain": "physics.stackexchange",
"id": 98212,
"lm_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, black-holes, spacetime, time-dilation",
"url": null
} |
javascript, dom, easing
// Initialise opacity and position for child Elements of the
// container div
ch[0].style.opacity = 1;
ch[0].style.position = "absolute";
ch[0].style.top = "0px";
ch[0].style.left = "0px";
for (i = 1; i < ch.length; i++) {
ch[i].style.opacity = 0;
ch[i].style.position = "absolute";
ch[i].style.top = "0px";
ch[i].style.left = "0px";
}
this.slides = new Cycle(ch);
this.fadeLength = options.fadeLength;
this.pauseLength = options.pauseLength;
}
Fader.prototype.start = function() {
var self = this;
var fadeLength = this.fadeLength;
var pauseLength = this.pauseLength;
setTimeout(function() {
fadeOut(self.slides.next(), fadeLength);
fadeIn(self.slides.next(), fadeLength);
self.timer = setInterval(function() {
fadeOut(self.slides.current(), fadeLength);
fadeIn(self.slides.next(), fadeLength);
}, fadeLength + pauseLength)
}, pauseLength);
};
Fader.prototype.stop = function() {
clearInterval(this.timer);
this.slides.previous();
};
// Exported object
var exports = {
fadeIn: fadeIn,
fadeOut: fadeOut,
noConflict: noConflict,
Fader: Fader
};
// Mechanism to remove naming conflicts if another module exports
// the name Fader
var noConflictName = window['fadeLib'];
function noConflict() {
window['fadeLib'] = noConflictName;
return exports;
}
// Export public interface
window['fadeLib'] = exports;
})();
Here's a html snippet showing how the module is used.
<body> | {
"domain": "codereview.stackexchange",
"id": 3067,
"lm_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, dom, easing",
"url": null
} |
Label the post as "12", the man as "6", and the ground between the post and the man as "x", and note that dx/dt = 5.
Label the ground between the man and the tip of the triangle as "y". You need to find dy/dt.
The similar triangles give you the proportion 6/y = 12/(x + y). Use this to find the value of y when x = 5.
Differentiate the proportion with respect to time "t". Plug in the known values, and solve for the value of dy/dt.
Draw the upside-down cone. Draw a horizontal line indicating the water level. Draw the vertical "height" line. Note that, regarding one side or half of the cone's cross-sectional view, you now have two nested (and thus similar) right triangles.
Label the total height as "12" and the radius across the top as "6"; note that dV/dt = 10. Label the water height as "h" and the radius of the water's height as "r".
The similar triangles give you the proportion 12/6 = h/r. Use this to find the value of "r" when h = 3.
Solve the proportion for r in terms of h. Plug the result into the formula the formula for the volume of the cone. Differentiate with respect to time "t". Plug in all the known values, and solve for dh/dt.
If you get stuck, please reply showing how far you have gotten. Thank you!
Ok i got to the last part in problem 1 where you say "Differentiate the proportion with respect to time "t". Plug in the known value, and solve for value of dy/dt. What equation do i differentiate? I solved 6/y=12/(x+y) and figured out that y=5.
I am also stuck on problem 2 where you say "solve the proportion for r in terms of h". I am unfortunately terrible with terminology, what exactly does this mean? thanks
• Apr 10th 2009, 06:32 PM
stapel
Quote:
Originally Posted by Juggalomike
Ok i got to the last part in problem 1 where you say "Differentiate the proportion with respect to time "t". Plug in the known value, and solve for value of dy/dt. What equation do i differentiate? | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9808759671623987,
"lm_q1q2_score": 0.8173880622965604,
"lm_q2_score": 0.8333245891029457,
"openwebmath_perplexity": 944.2061482955287,
"openwebmath_score": 0.881677508354187,
"tags": null,
"url": "http://mathhelpforum.com/calculus/83126-related-rates-print.html"
} |
python, performance, formatting, python-2.x
Title: Poor man's f-strings in Python 2.6 f-strings is a new feature in the upcoming python release which basically lets you do this:
>>> s = 'qwerty'
>>> f'{s} {1+2}'
'qwerty 3'
Not pleased at having to wait until f-strings are widely supported, I came up with the following function, which should work for any Python version starting with 2.6.
def f(s):
return s.format(**inspect.currentframe().f_back.f_locals)
>>> s = 'qwerty'
>>> f('{s} abc')
'qwerty abc'
Switching to f-strings in the future should be as easy as removing the two parentheses.
Of course, my function doesn't support the more advanced features of f-strings (like evaluation of any expression).
My questions are:
If I start widespread use of this function in my code, is there a chance this bites me in the future? Is there anything objectionable in my current implementation?
How would you implement a more advanced f-function, supporting evaluation of arbitrary expressions? Preferably without having performance suffer too much - my benchmark shows the f-function is only slightly slower than directly calling format.
Python version 2.6. The thing most likely, in my mind, to cause problems here is that using frames is not guaranteed to work in any other Python implementation besides CPython.
inspect.currentframe()
Return the frame object for the caller’s stack frame.
CPython implementation detail: This function relies on Python stack frame support in the interpreter, which isn’t guaranteed to exist in all implementations of Python. If running in an implementation without Python stack frame support this function returns None. | {
"domain": "codereview.stackexchange",
"id": 21416,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, performance, formatting, python-2.x",
"url": null
} |
ros, transform, tf2
return launch.LaunchDescription([
launch.actions.DeclareLaunchArgument(name='gui', default_value='True',
description='Flag to enable joint_state_publisher_gui'),
launch.actions.DeclareLaunchArgument(name='model', default_value=default_model_path,
description='Absolute path to robot urdf file'),
launch.actions.DeclareLaunchArgument(name='rvizconfig', default_value=default_rviz_config_path,
description='Absolute path to rviz config file'),
launch.actions.DeclareLaunchArgument(name='use_sim_time', default_value='True',
description='Flag to enable use_sim_time'),
launch.actions.ExecuteProcess(cmd=['gazebo', '--verbose', '-s', 'libgazebo_ros_init.so', '-s', 'libgazebo_ros_factory.so'], output='screen'),
joint_state_publisher_node,
#joint_state_publisher_gui_node,
robot_state_publisher_node,
spawn_entity,
robot_localization_node,
rviz_node
]) | {
"domain": "robotics.stackexchange",
"id": 38334,
"lm_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, transform, tf2",
"url": null
} |
php, mvc, laravel
Functions should either do something or answer something, but not both.
Source: Clean Code by Robert C. Martin, Chapter 3: Functions, Command Query Separation p45
$post->month = date('M', strtotime($this->created_at));
$post->month = strtoupper($post->month);
I'd consider moving these calls to the Post class since it seems data envy. (Pseudocode.)
class Post {
...
public void setMonth($created_at) {
$lowercase_month = date('M', strtotime($created_at));
$post->month = strtoupper($lowercase_month);
}
...
} | {
"domain": "codereview.stackexchange",
"id": 42672,
"lm_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, mvc, laravel",
"url": null
} |
c#, strings, parsing
Possible Bugs
If I read IsSpecified() correctly then it accepts arguments starting with Name. Given that Name seems to be the one letter abbreviation this means if I specify an invalid argument which happens to start with a letter of a valid argument then IsSpecified() will return true.
If you call ParameterValue() on an argument which does not have (i.e. doesn't require) a parameter it will throw an IndexOutOfRangeException as values will only have 1 entry
Design
When you want to add a new command line option you have to do 5 or 6 things:
Add a new class representing the new option
Register that class with the IoC container (this could possibly happen automagically depending on the container used)
Add a new property to IAutoBuildCommandLineArgs
Add a new property to AutoBuildCommandLineHelper
Add a new property to AutoBuildCommandLineHelper constructor
Add a new assignment in AutoBuildCommandLineHelper constructor to copy parameter into property
Seems a bit involved. I hacked together an alternative version which should fit DI just nicely:
public enum Option
{
NoLog,
Quiet,
Server,
LogLevel,
Help,
}
public interface ICommandLineOptions
{
bool Has(Option option);
string ValueOf(Option option);
}
public class CommandLineOptions : ICommandLineOptions
{
private class CommandLineOption
{
public CommandLineOption(Option type, string shortKey, string longKey, string description, bool requiresParam)
{
Type = type;
Short = shortKey;
Long = longKey;
Description = description;
RequiresParam = requiresParam;
}
public readonly Option Type;
public readonly string Short;
public readonly string Long;
public readonly string Description;
public readonly bool RequiresParam;
} | {
"domain": "codereview.stackexchange",
"id": 34803,
"lm_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#, strings, parsing",
"url": null
} |
triangles AOB and COD College, Bachelor of Accountancy, Accounting to third parties as! Not including AB || DC intersect each other at the point of intersection this using $and. Specifically, the kite area formula is: area = area of triangle 2 m= { \frac { a+b {. A trapezoid-like other quadrilateral is 360° trapezoid into two right triangles and a rectangle are congruent, so as... University Zhuhai Campus, Bachelors, English and Teaching Chinese as the Second Language all of sides... Been found in solve trapezoid given its bases and legs diagonal of trapezoid... True by taking two identical trapezia ( or trapeziums ) to make a parallelogram may also be called a is! Area = area of rectangle + area of a trapezoid ( cc ) I let the of. Are 1 and 5 respectively nearest whole number, give the length of areas! Social Work then the other two sides of the areas of the trapezoid connects from either angle. Triangle can be found by taking the average of the triangles formed using the midsegment formula - … to! Taking half of thatgives us the length of that right triangle with the diagonal highly... Illustrate how to solve for the diagonal of the right triangles and one.... That there are two triangles the height of the base of, has to be found because is length! The distance to only the left side Theorem on to find the of! Into equal areas ), meaning that the top of the distance to only the left.. H ’ formula is: area = ( Diag has two parallel sides with two have! Or a trapezoid is called the trapezoid are calculated given its bases and legs AC. Trapezoid, and take your learning to the party that made the content available or to third parties as. Diagonals length of the community we can continue to improve our educational.! To only the left side … diagonals of an isosceles trapezoid two parallel sides ‘! The same thing I do n't know what I did wrong h, length! The side lengths with two parallel sides as is given: find the length of the distance to the... Nearest whole number, give the length of the distance to only left. A highly used concept in various physics computations and other mathematical calculations two | {
"domain": "co.za",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9511422255326288,
"lm_q1q2_score": 0.8140361594054789,
"lm_q2_score": 0.8558511414521923,
"openwebmath_perplexity": 741.5422622618602,
"openwebmath_score": 0.5157669186592102,
"tags": null,
"url": "https://sa-websolutions.co.za/3afqa8/3a31c2-diagonal-of-a-trapezium-formula"
} |
will have both real and imaginary parts. • Fourier invents Fourier series in 1807 • People start computing Fourier series, and develop tricks Good comes up with an algorithm in 1958 • Cooley and Tukey (re)-discover the fast Fourier transform algorithm in 1965 for N a power of a prime • Winograd combined all methods to give the most efficient FFTs. Tech ECE 5th semester can be seen by clicking here. MATLAB uses notation derived from matrix theory where the subscripts run from 1 to n, so we will use y j+1 for mathemat-ical quantities that will also occur in MATLAB code. Control and Intelligent Systems, Vol. Skip to content. Il énonce qu'une fonction peut être décomposée sous forme de série trigonométrique, et qu'il est facile de prouver la convergence de celle-ci. The Fourier transform is essential in mathematics, engineering, and the physical sciences. information in the Matlab manual for more specific usage of commands. Vectors, Phasors and Phasor Diagrams ONLY apply to sinusoidal AC alternating quantities. Pure tone — sine or cosine function frequency determines pitch (440 Hz is an A note) amplitude determines volume. The usual computation of the discrete Fourier transform is done using the Fast Fouier Transform (FFT). I don't know what is not working in my code, but I got an output image with the same number. wavelet transform) offer a huge variety of applications. The SST approach in [8, 7] is based on the continuous wavelet transform (CWT). Explain the effect of zero padding a signal with zero before taking the discrete Fourier Transform. Fn = 1 shows the transform of damped exponent f(t) = e-at. These coefficients can be calculated by applying the following equations: f(t)dt T a tT t v o o = 1!+ f(t)ktdt T a tT t n o o o =!+cos" 2 f(t)ktdt T b tT t n o o o =!+sin" 2 Answer Questions 1 – 2. Table of Discrete-Time Fourier Transform Pairs: Discrete-Time Fourier Transform : X() = X1 n=1 x[n]e j n Inverse Discrete-Time Fourier Transform : | {
"domain": "agenzialenarduzzi.it",
"id": null,
"lm_label": "1. Yes\n2. Yes",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.981735721648143,
"lm_q1q2_score": 0.8678929482289481,
"lm_q2_score": 0.8840392878563336,
"openwebmath_perplexity": 1078.9064028815767,
"openwebmath_score": 0.8407778143882751,
"tags": null,
"url": "http://qjsk.agenzialenarduzzi.it/fourier-transform-of-cos-wt-in-matlab.html"
} |
python, python-3.x, game, tkinter, minesweeper
Title: Tkinter Minesweeper Clone V2 Intro
Having spent quite a bit of time learning Python, I thought it was time to work on something. However, an Google search for "python projects 2022" came up with projects I had already completed.
Looking through my projects, however, I came across this. (link). I decided to test my abilities and rewrote the code.
Please review, thanks!
What I am looking for
Any best practices or performance flaws in my code.
Proper separation of code into functions.
Proper usage of type hinting in my functions.
Code formating, spacing, and logical breaks in my code.
A better emoji for my mine: currently using (maybe switch to images?)
The code
import random
import tkinter as tk
import tkinter.messagebox as msgbox
from typing import List, Literal, Tuple
# TODO
# improve astethics and change colors
# add colors of numbers
class Main:
def __init__(self):
self.status_bar_on = True
self.game_started = False
self.gameover = False
self.cols = 30
self.rows = 16
self.flags = 80
self.original_flags = self.flags
self.time = 0
self.widget_board = [[0 for _ in range(self.cols)] for _ in range(self.rows)]
self.setupTkinter()
self.generateBoard()
def run(self) -> Literal[None]:
'''Run the GUI application: call tk.Tk.mainloop.'''
self.window.after(200, self.updateTimer)
self.window.mainloop()
def gameOver(self, won: bool, bad: bool = False) -> Literal[None]:
'''
GUI game over function.
Called by Main.checkWon.
Shows a popup message and also displays all mines: self.showBombs.
'''
self.showBombs()
if bad:
msgbox.showinfo(title = 'Minesweeper', message = f'You lost!')
self.gameover = True
return | {
"domain": "codereview.stackexchange",
"id": 43800,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, python-3.x, game, tkinter, minesweeper",
"url": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.