text stringlengths 49 10.4k | source dict |
|---|---|
matlab, fft, interpolation, resampling, hardware
Is a correct approximation?
What kind of errors can occur?
This is my first time I approach to the FFT, and I have a civil engineer background, so is my first time with signal analysis, never studied Signal Theory before.
My interest for the FFT is to define the best low pass filter (example apply a Butterworth but I don’t know how to choose the filter order and cutoff frequency.
I don't have enough reputation to post more than 2 links sorry for that.
filename= uigetfile ('.txt');
fileID = fopen (filename);
logmpu6050 =csvread(filename);
fclose (fileID);
%Starting creating the specific Vectors
%Record Time in millisecond
time=logmpu6050(:,1);
%The x y z are converted to m/s^2
confactor=19.6/32768;
ax=logmpu6050(:,2);
confactor=19.6/32768;
ax=ax*confactor;
ay=logmpu6050(:,3);
ay=ay*confactor;
az=logmpu6050(:,4);
az=az*confactor;
%Define the sample rate subtracting from Sampletime i+1 Sampletime i
n=length(time);
for i = 1:n-1
samplerate(i) = time(i+1)-time(i);
end;
%I try to define the best frequency for "resample" function based on mode and median value
%I will not use average to avoid conditioning due to extreme value
f1=mode(samplerate);
f2=median(samplerate);
x1= sin(2*pi*f1*time);
x2= sin(2*pi*f2*time);
plot(time,x1,'.');
figure
plot(time,x2,'.'); | {
"domain": "dsp.stackexchange",
"id": 4826,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "matlab, fft, interpolation, resampling, hardware",
"url": null
} |
11) $$lim_{x \to 0}\frac{5}{1−e^{1/x}}$$
$$x$$ $$\frac{5}{1−e^{1/x}}$$ $$x$$ $$\frac{5}{1−e^{1/x}}$$ -0.1 a. 0.1 e. -0.01 b. 0.01 f. -0.001 c. 0.001 g. -0.0001 d. 0.0001 h.
12) $$lim_{z \to 0}\frac{z−1}{z^2(z+3)}$$
$$z$$ $$\frac{z−1}{z^2(z+3)}$$ $$z$$ $$\frac{z−1}{z^2(z+3)}$$ -0.1 a. 0.1 e. -0.01 b. 0.01 f. -0.001 c. 0.001 g. -0.0001 d. 0.0001 h.
Solution: a. −37.931934; b. −3377.9264; c. −333,777.93; d. −33,337,778; e. −29.032258; f. −3289.0365; g. −332,889.04; h. −33,328,889 $$\lim_{x \to 0}\frac{z−1}{z^2(z+3)}=−∞$$
13) $$lim_{t \to 0^+}\frac{cost}{t}$$
$$t) \(\frac{cost}{t}$$ 0.1 a. 0.01 b. 0.001 c. 0.0001 d.
14) $$lim_{x \to 2}\frac{1−\frac{2}{x}}{x^2−4}$$ | {
"domain": "libretexts.org",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.990440598959895,
"lm_q1q2_score": 0.8074393617146093,
"lm_q2_score": 0.8152324960856175,
"openwebmath_perplexity": 408.5510906027908,
"openwebmath_score": 0.8519446849822998,
"tags": null,
"url": "http://math.libretexts.org/TextMaps/Calculus_Textmaps/Map%3A_Calculus_(OpenStax)/Calculus_I/Chapter_2%3A_Limits/2.2%3A_The_Limit_of_a_Function"
} |
python, object-oriented, python-2.x, error-handling, exception
Title: Python exception handling class - Getting as much details printed I'm trying to write a Exception Handling class in Python so that I can re-use. If you have any ideas on how I can improve this to output more detailed information I would appreciate it:
class EHandle:
@staticmethod
def printit():
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
print(exc_type, fname, exc_tb.tb_lineno)
frm = inspect.trace()[-1]
mod = inspect.getmodule(frm[0])
modname = mod.__name__ if mod else frm[1]
print 'Thrown from', modname
And I call the class and method like below:
try:
ggg()
runafunction()
except:
EHandle.printit()
sys.exit() Python's built-in exception traceback gives us:
Traceback (most recent call last):
File "D:/code/python/error.py", line 43, in <module>
error()
File "D:/code/python/error.py", line 28, in error
another_level()
File "D:/code/python/error.py", line 31, in another_level
return tuple()[0]
IndexError: tuple index out of range
Where your code gives us:
(<type 'exceptions.IndexError'>, 'error.py', 39)
Thrown from __main__ | {
"domain": "codereview.stackexchange",
"id": 19682,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, object-oriented, python-2.x, error-handling, exception",
"url": null
} |
inorganic-chemistry
Title: How can potassium hydroxide be prepared from available potassium chloride and quick lime I live in a small town where Potassium hydroxide is not readily available. (I need above for preparing liquid soap.) But Potassium chloride ($\ce{KCl}$) and Quick Lime ($\ce{CaO}$) are available as fertilizer and White-wash ingredients respectively. Can $\ce{KOH}$ be prepared from above ingredients? What will be reaction conditions? Mixing $\ce{KCl + CaO}$, or $\ce{KCl + Ca(OH)2}$, will never produce pure $\ce{KOH}$ without $\ce{Ca(OH)2}$. And this Ca(OH)2 will prevent soap from being synthesized out of oil, as $\ce{(Ca(OH)2}$s destroy soap in case a little bit of soap has been synthesized. The only way of producing $\ce{KOH}$ out of $\ce{CaO}$ or $\ce{Ca(OH)2}$ is to mix it with potassium carbonate $\ce{K2CO3}$. Of course $\ce{Ca(OH)2}$ is not very soluble in water. But $\ce{CaCO3}$ is still more insoluble. So the following reaction is possible :$$\ce{Ca(OH)2 + K2CO3 -> 2 KOH + CaCO3(s)}$$ And the insoluble $\ce{CaCO3}$ can be filtrated to produce a KOH solution | {
"domain": "chemistry.stackexchange",
"id": 14924,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "inorganic-chemistry",
"url": null
} |
There is already a very good and complete answer from d_b, let me just add a comment to elucidate the possible (erroneous in this case) reasoning by which one could try to forget about gravity.
First, consider one block hanging from the spring in equilibrium. Assume that we provide it with the vertical speed $$v$$ without any other block sticking to it, so it moves up alone. What height above the initial position will it reach in such a case? Writing energy conservation (for detailed explanation look at d_b's answer, it is quite the same here - only I choose to measure height relative to the initial position of the block for reasons which will become clear shortly), we get:
$$\frac{m v^2}{2} + \frac{m^2 g^2}{2 k} = m g h + \frac{k (h-\frac{mg}{k})^2}{2}$$
Let us play a little with this equation. Open the square in the RHS and observe that $$mgh$$ cancels:
$$m g h + \frac{k (h-\frac{mg}{k})^2}{2} = mgh + \frac{k(h^2 + \frac{m^2g^2}{k^2} - \frac{2mgh}{k})}{2} = \frac{kh^2}{2} + \frac{m^2 g^2}{2k}$$
Plugging it back to the energy conservation, we observe that $$\frac{m^2 g^2}{2k}$$ cancels as well, and we are left with
$$\frac{m v^2}{2} = \frac{kh^2}{2}$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9559813463747182,
"lm_q1q2_score": 0.8511046750447819,
"lm_q2_score": 0.8902942283051332,
"openwebmath_perplexity": 513.1419705121123,
"openwebmath_score": 0.7946702241897583,
"tags": null,
"url": "https://physics.stackexchange.com/questions/680196/college-board-problem-conservation-of-momentum-conservation-of-energy-in-a-s"
} |
quantum-gate, quantum-state
Title: Create a 3-Qubit circuit given the state? I am trying to implement a 3-qubit circuit given the state. I have been given for example : |w> = x*|010> + y*<101>. How can I reverse engineer to create the desired state. As I am confused about the approach towards the process. I tried initial dab, but this was more of trial and error rather than calculated approach. I would appreciate some resources or derivation.
q = QuantumRegister(3)
c = ClassicalRegister(2)
qcirc = QuantumCircuit(q, c)
# Put the first qubit into a superposition
qcirc.h(q[0])
# Apply the first controlled-not gate
qcirc.cx(q[0], q[1])
# Apply the rotation gate to the second qubit
angle = np.arccos(np.sqrt(3)/4)
qcirc.p(angle, q[1])
# Apply the second controlled-not gate
qcirc.cx(q[0], q[2]) | {
"domain": "quantumcomputing.stackexchange",
"id": 4511,
"lm_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-gate, quantum-state",
"url": null
} |
regular-languages, finite-automata, regular-expressions, pumping-lemma
So, is really the regex equal to $\mathcal{L}$? or am I pumping wrong? You are making a classical mistake in applying the pumping lemma. The pumping lemma states that each word $w$ of length at least $N$ in the language (where $N$ is the number of states in the minimal DFA for the language) can be decomposed as $w = xyz$, where $|xy| \leq N$, $|y| \geq 1$, and $xy^i z$ is in the language for all $i$. You don't get to choose this partition! The lemma just states that there is some partition. Taking as an example your word $a^3 b^t$, since $N = 6$ (indeed, the minimal DFA for the language has $6$ states), we can always choose $x = a^3$ and $y = b$, and then $xy^i z = a^3 b^{t+i-1}$ which is always in the language (since $t \geq 3$).
When you use the pumping lemma to prove that a language is not regular, you don't know $N$, and so you have to start by taking $N$ to be arbitrary, and run the proof from there. What you are in effect showing is that for each $N$, there is no DFA accepting the language with at most $N$ states. | {
"domain": "cs.stackexchange",
"id": 1338,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "regular-languages, finite-automata, regular-expressions, pumping-lemma",
"url": null
} |
fourier-transform, image-processing, algorithms, reconstruction
for i1=i:i+4,
for j1=j:j+4,
object(i1,j1) = blank;
end;
end;
end;
end;
nf2=flops;
% Chris Henze's ramp function: (Biology)
disp('generating the ramp');
a1 = linspace(0,32,32); % create linear ramp, pg 168 MATLAB
hf = [a1 fliplr(a1(1:32))]; % flip left-to-right, pg 77 MATLAB
H = hf .* hamming(64)'; % Hamming funct, pg 168 MATLAB
nf3=flops;
disp('Using Hamming Window N =64');
% projecting the data points. The projections are
% 64 angles X 16 rays per angle.
disp('Projecting the object');
% The factor=1.15 in the denominator requires some explanation.
% Ideally this should be just 1/sqrt(2). This factor,
% 1/sqrt(2), is the worst case at a rotation of 45 degrees where
% the object always fits inside a square whose edge dimension is
% the largest dimension of the original object. Pragmatically,
% this factor 1.15 has been put in the denominator so that rays
% always fit within the object. When the rays fall outside of the
% object, although the result should be near zero, a numerical
% error results. If 1.15 is changed to 1.0 this program will not
% run. An alternate technique may work if the uneven object fits
% into a circle instead of a square, where the largest object
% dimension becomes the diameter of the circle.
tw=1/(1.15*sqrt(2));
% Calculate the forward projections: Kak & Slaney pgs. 49-56
% This is where the CM5 does not parallelize well, but we can
% use the Paragon to parallelize this section by assigning
% rows(angles) to each cpu(node).
for x=x_min:x_max,
for y=y_min:y_max,
sum=0.0;
for i=1:angles, | {
"domain": "dsp.stackexchange",
"id": 5458,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "fourier-transform, image-processing, algorithms, reconstruction",
"url": null
} |
forces, classical-mechanics, friction, torque
For me, if the force exerted on the tire by the ground is in the direction of motion, static friction will point backwards, opposing the eventual relative motion
If you gun the engine and the tire spins (or if you're on ice or something with minimal friction), it spins in a way where the bottom of the wheel moves backward (to the rear of the car) and the top of the wheel moves forward.
Friction creates forces that oppose relative motion. Since the wheel "wants" to move backward, that means that the friction force (on the tire) points forward. The relative motion we are talking about isn't between the car and the ground, it's between the bottom of the tire and the ground. | {
"domain": "physics.stackexchange",
"id": 63735,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "forces, classical-mechanics, friction, torque",
"url": null
} |
aqueous-solution, solubility
Title: Definition of "soluble" How to define "soluble" in chemistry?
For example, in 1:1 v/v, benzene does not mix with water, i.e. insoluble. Common sense.
However, in an analytical procedure, it called for making a "saturated" aqueous solution of benzene, which is about 1.5 g/L. So, benzene actually has some solubility in water.
So, my question is, is there an official definition of "soluble"? We consider if a solute is completely spread out through the solvent in the maximum possible extent, we consider the solute to be dissolved in the solvent. We can identify a solution by a few characteristics:
Solutions are uniform and have no precipitation or coagulated mass in it.
Solutions are clear, no granules or anything.
Solutions exhibit the phase of the solvent. | {
"domain": "chemistry.stackexchange",
"id": 7929,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "aqueous-solution, solubility",
"url": null
} |
javascript, jquery, validation
$('#beleggingsForm').validate({
rules: {
oorspronkelijkeBedrag: {
required: function(element) {
var rauwAanvullendBedrag = $.trim($('#aanvullendBedrag').val());
var aanvullendBedrag = rauwAanvullendBedrag.length > 0 ? parseInt(rauwAanvullendBedrag, 10) : 0;
return aanvullendBedrag === 0;
},
groterdan: {
param: $('#oorspronkelijkeBedrag').data('rule-groterdan'),
depends: function(element) {
var rauwOorspronkelijkeBedrag = $.trim($('#oorspronkelijkeBedrag').val());
var oorspronkelijkeBedrag = rauwOorspronkelijkeBedrag.length > 0 ? parseInt(rauwOorspronkelijkeBedrag, 10) : 0;
var rauwAanvullendBedrag = $.trim($('#aanvullendBedrag').val());
var aanvullendBedrag = rauwAanvullendBedrag.length > 0 ? parseInt(rauwAanvullendBedrag, 10) : 0;
return oorspronkelijkeBedrag !== 0 || aanvullendBedrag === 0;
}
}
},
aanvullendBedrag: {
required: function(element) {
var rauwOorspronkelijkeBedrag = $.trim($('#oorspronkelijkeBedrag').val());
var oorspronkelijkeBedrag = rauwOorspronkelijkeBedrag.length > 0 ? parseInt(rauwOorspronkelijkeBedrag, 10) : 0;
return oorspronkelijkeBedrag === 0;
},
groterdan: { | {
"domain": "codereview.stackexchange",
"id": 29438,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "javascript, jquery, validation",
"url": null
} |
bioinformatics, sequence-analysis, sequence-alignment
Title: How to interpret Percent identity matrix created by Clustal Omega? I did a multiple sequence alignment using Clustal omega. checked similarity for 3 protein sequences : aspartyl aminopeptidase [Homo sapiens], aminopeptidase P (APP) [Plasmodium falciparum 3D7], yeast aminopeptidase (S000001586)APE1. I got Percent identity matrix as
Percent Identity Matrix - created by Clustal2.1
1: PF3D7_1454400 100.00 16.18 20.35
2: gi|5902181|gb|AAD01211.2| 16.18 100.00 29.66
3: S000001586 20.35 29.66 100.00
My doubts:
I would like to know how to interpret this matrix result
Coming back to sequence alignments results, when I click on 'Show colors', the alignment summary is colored in 4 colors - red, green, blue and pink. Can anyone help me in decoding the color reference of alignment summary?
Thanks Gene-1 Gene-2 Gene-3
Gene-1 100.00 16.18 20.35
Gene-2 16.18 100.00 29.66
Gene-3 20.35 29.66 100.00
Gene-1 and Gene-1 have 100% similarity (and all the other diagonal elements). Gene-1 and Gene-2 have 16.15% similarity, and so on. Therefore the matrix is symmetric M(i,j) = M(j,i).
You can also show just the upper triangular part of this matrix and that would be sufficient.
Gene-1 Gene-2 Gene-3
Gene-1 100.00 16.18 20.35
Gene-2 100.00 29.66
Gene-3 100.00
The colours basically denote the type (molecular nature) of residue. Have a look at this and this. | {
"domain": "biology.stackexchange",
"id": 5550,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "bioinformatics, sequence-analysis, sequence-alignment",
"url": null
} |
Linking of mathematics to construction and engineering. Advanced Engineering Mathematics, E. Part 1: Arithmetic Sequences. At most colleges, chemistry is a two-semester sequence of general chemistry lecture and lab. Mathematics scope and sequence chart. This recursive definition requires understanding another sequence known as the sequence of first differences. It has been given in a physics manner, but it just requires manipulation of Taylor series to get the result, which is what i can't figure out. Decision-Making using Financial Ratios. SEQUENCES AND SERIES 179 In the sequence of primes 2,3,5,7,…, we find that there is no formula for the nth prime. 3 Arithmetic progressions 219 29. A sequence is a set of values which are in a particular order. Let (an,bn) be a sequence in R2, it doesnt seem sufficient that one of. DME - 306 Basic Electronics Engineering 03 00 30 20 50 100 150 Practical Subjects 1. teachers, have culminated in the advanced scientific calculator, the CASIO fx-991 ES PLUS, with substantial mathematical capabilities and extensive use of natural displays of mathematical notation. In mathematics one requires the further step of a proof, that is, a logical sequence of assertions, starting from known facts and ending at the desired statement. 1 Rolle’s theorem 2. 2 Set theory 2. Sequence and Pattern. If you think the materials are useful kindly buy these legally from publishers. Besides the sequence MATH 3321-MATH 4321 or the sequence MATH 3335 and (MATH 4335 or MATH 4334), a second sequence must be part of the second major. Arithmetic Progression example : ExamSolutions Maths Revision : OCR C2 June 2013 Q6 (i) - youtube Video. Many of these systems are deterministic and are modeled using differential equations. A youtube Calculus Workbook (Part I) Linear Algebra II. I like to explain why arithmetic and geometric progressions are so ubiquitous. Life Sciences. For example, 2+4+6+8+ is a series. two-course biology sequence or a two-course chemistry sequence to fulfill the lab science requirements. Since 2008 this mathematics lecture is o ered for the master courses computer science, mechatronics and electrical engineering. To continue the sequence, we look for the previous two terms and add them together. Note: Courses are listed in a recommended sequence, and may be interchanged among semesters to accommodate the | {
"domain": "davideferraridgs.it",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9833429609670702,
"lm_q1q2_score": 0.8016531365774067,
"lm_q2_score": 0.8152324960856177,
"openwebmath_perplexity": 1787.8691751599813,
"openwebmath_score": 0.46664801239967346,
"tags": null,
"url": "http://davideferraridgs.it/ibjy/sequence-and-series-pdf-engineering-mathematics.html"
} |
performance, strings, linux, assembly, amd64
(I use my own strlen function which only modifies rcx) For style and formatting, your asm is pretty good except for label names. Correctly indented, and some intro comments about register usage. But missing comments about even the major steps of the algorithm on any of the instructions or labels.
It would also help to leave a blank line after the end of a loop, so it's easier to see that later code isn't going to jump back into it. It's a good place to put a comment about what invariants are now true, or what the next code does.
As other answers point out, your algorithm is doing way too much work, using malloc/free (and in asm, effectively alloca) and copying your data twice, instead of just figuring out how far to memmove it.
Beyond that, you have multiple other major and minor implementation details that could be more efficient.
(Important background reading: https://agner.org/optimize/ has lots of important micro-optimization stuff, some of which I'm going to point out specifically. If you don't know what micro-uops (uops) are, go read Agner's asm optimization guide and micro-architecture guide. Also this SO Q&A and/or some of the links from my answer. Also a good idea to use compiler-generated asm as a starting-point for your hand-written asm, because compilers generally get the small details right, and might lay out the branching nicely. (If not you can try [[likely]] somewhere and try again).)
Also, not using SIMD means you can at best check 1 byte at a time, not 16 or 32. SSE2 is baseline for x86-64, so any string processing like this should be using SIMD unless you expect strings to be tiny, like less than 8 bytes or so. (Or as a baby-steps learning exercise just to write correct scalar code, not useful for performance.) With some loop unrolling, scalar could possibly check 2 bytes per clock cycle, but branching on a SIMD compare takes more work. Still a big speedup available. | {
"domain": "codereview.stackexchange",
"id": 43808,
"lm_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, strings, linux, assembly, amd64",
"url": null
} |
homework-and-exercises, newtonian-mechanics, momentum, energy-conservation, conservation-laws
does the momentum along $x$ axis is conserved?
The momentum along $x$ axis is given by:
$$p_x(\theta) = mv(\theta) + M\frac{L}{2}\omega(\theta).$$
Assuming that the sleeve is steady at the beginning (i.e. $v(0) = 0$), then:
$$p_x(\theta) = p_x(0)= M\frac{L}{2}\omega_0.$$
At $\theta = \overline\theta$, we have that $\omega(\overline\theta) = 0$, and thus:
$$v(\overline\theta) = \frac{ML}{2m}\omega_0.$$
The last equation can help me to find $\overline\theta$.
However... is the assumption on the momentum right? The only external force is the gravity which acts only along the $y$ axis.
But if this is true for the second system (with sleeve), then is the momentum along $x$ conserved also in the simpler case (first system with no sleeve)?
I also know that for the presence of the gravity, the angular moment is not conserved in both cases. | {
"domain": "physics.stackexchange",
"id": 43172,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "homework-and-exercises, newtonian-mechanics, momentum, energy-conservation, conservation-laws",
"url": null
} |
java, programming-challenge
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int size = in.nextInt();
TriangularArray theArray = new TriangularArray(size);
theArray.acceptArray(in);
theArray.displayArray();
theArray.findMaximum();
}
} Storage
A Map is most useful when the key values are not in a sequence,
but sparse, with smaller and bigger gaps between key values.
In this example, the key corresponds to a row of the triangle,
taking on values from 0 to size, and using all values in the range.
An array would be a more natural choice for storage,
in this example an int[][].
Note that a hash map has some storage overhead.
Also, accessing array elements is simpler to write than .get(...) and .put(...) calls.
Encapsulation
This is a bit unfortunate:
TriangularArray theArray = new TriangularArray(size);
theArray.acceptArray(in);
theArray.displayArray();
theArray.findMaximum();
Since findMaximum will modify the underlying storage,
if you call theArray.findMaximum() one more time,
it will produce different output,
which is unexpected.
It's best when you can call a method multiple times and get the same result consistently.
Unless of course it is by design that the call manipulates state,
for example in an iterator.
The name "findMaximum" doesn't hint at manipulating state,
which is misleading.
In fact, findMaximum is designed for one-time use.
It would be better to rewrite this in a way that the state manipulation becomes obvious.
Or throw an exception if the method is called a second time.
Or encapsulate the logic in a way that calling findMaximum repeatedly would produce the same result consistently.
I would also recommend to make findMaximum return the maximum instead of printing text.
Pointless statements
This variable is unused (and poorly named):
int someInt;
The map.put(i, currArray) statement at the end is unnecessary: | {
"domain": "codereview.stackexchange",
"id": 18474,
"lm_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, programming-challenge",
"url": null
} |
# Find the remainder when $10^{400}$ is divided by 199?
I am trying to solve a problem
Find the remainder when the $10^{400}$ is divided by 199?
I tried it by breaking $10^{400}$ to $1000^{133}*10$ .
And when 1000 is divided by 199 remainder is 5.
So finally we have to find a remainder of :
$5^{133}*10$
But from here I could not find anything so that it can be reduced to smaller numbers.
How can I achieve this?
Is there is any special defined way to solve this type of problem where denominator is a big prime number?
• $10^{400}=1000^{133}\times10$, not $1000^{333}\times10$. – Gerry Myerson Oct 9 '12 at 4:53
• A standard beginning (for prime moduli) is to use the fact that if $p$ does not divide $a$, then $a^{p-1}\equiv 1\pmod{p}$. Thus $10^{198}\equiv 1\pmod{199}$. It follows that $10^{396}\equiv 1\pmod{199}$ and therefore $10^{400}\equiv 10^4\pmod{199}$. Now we have to calculate. In this case, there is a further shortcut, since $1000=(5)(199)+5\equiv 5\pmod{199}$. – André Nicolas Oct 9 '12 at 5:24
• – Martin Sleziak Jun 17 '16 at 8:22
You can use Fermat's little theorem. It states that if $n$ is prime then $a^n$ has the same remainder as $a$ when divided by $n$.
So, $10^{400} = 10^2 (10^{199})^2$. Since $10^{199}$ has remainder $10$ when divided by $199$, the remainder is therefore the same as the remainder of $10^4$ when divided by $199$. $10^4 = 10000 = 50*199 + 50$, so the remainder is $50$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9799765604649332,
"lm_q1q2_score": 0.8329518292152459,
"lm_q2_score": 0.849971175657575,
"openwebmath_perplexity": 186.07111671434032,
"openwebmath_score": 0.7323861718177795,
"tags": null,
"url": "https://math.stackexchange.com/questions/209656/find-the-remainder-when-10400-is-divided-by-199"
} |
ros, parallel, callbacks
class contains:
def __init__(self):
'''
Initalize Data
'''
self.AOE = Aggent_Occupancy_Entropy()
self.agents = self.AOE.agents
self.x_min_dist = self.AOE.x_min_dist #distribtuion limits
self.x_max_dist = self.AOE.x_max_dist
self.y_min_dist = self.AOE.y_min_dist
self.y_max_dist = self.AOE.y_max_dist
self.delta = self.AOE.delta
self.all_positions_tuple = self.AOE.all_positions_tuple
self.center_dict = {}
self.dim_x = 0
self.dim_y = 0
self.ent_list = [0]*self.agents
for i in range(0, self.agents):
name = 'agent%s' % (i + 1)
self.center_dict[name] = 0.0
'''
Subscribers and publisher
'''
self.agent_dictionary = {}
self.contains_dict = {}
for i in range(0, self.agents):
name = 'agent%s' % (i + 1)
self.agent_dictionary[name] = [0, 0]
rospy.Subscriber('/' + name, IndividualPositions, self.individual_callback, queue_size=1, buff_size=2**24)
def individual_callback(self, msg):
'''
DO CALCULATION
'''
def main():
while not rospy.is_shutdown():
'''
DO STUFF/PUBLISH DATA
'''
if __name__ == '__main__':
rospy.init_node('contains')
C = contains()
C.main() | {
"domain": "robotics.stackexchange",
"id": 28015,
"lm_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, parallel, callbacks",
"url": null
} |
java, multithreading, console, socket, chat
dataReceiver = new DataReceiver(this);
dataSender = new DataSender(this);
So you create a DataReceiver and a DataSender and give them both the SocketEnhancer reference? Let's see how you use that in the classes then.
new InputStreamReader(socketEnhancer.getSocket().getInputStream())
and
socketEnhancer.getSocket().getOutputStream()
You send the entire socketEnhancer only so that you can use the getSocket method on it once to create the OutputStream. It is much better to give them the InputStream / OutputStream directly. This is what is called Tell, Don't Ask!
When possible, don't give your classes an object they can ask about something, give them what they need directly.
public class DataSender implements Runnable {
Scanner scanner = new Scanner(System.in);
...
I would recommend moving the Scanner to your main method, and letting your main method call a method on your SocketEnhancer object whenever it wants to send a message. The SocketEnhancer can then call a method on dataSender to perform the sending.
Overall, I have to say that your code is quite clean and easy to read. Good job. | {
"domain": "codereview.stackexchange",
"id": 8364,
"lm_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, multithreading, console, socket, chat",
"url": null
} |
Kudos [?]: 99319 [0], given: 11010
Re: If r and s are positive integers, can the fraction r/s be expressed as [#permalink]
Show Tags
05 May 2014, 02:31
halloanupam wrote:
But it has been said the 'decimal with finite number of non-zero digits'. Now if we take 2/50 then it will be 0.04, which means its a finite decimal but definitely it does not have all the non-zero digits after decimal point. So, can anybody explain?
0.04 has finite number of non-zero digits: 4 is not followed by any non-zero digit.
_________________
Math Expert
Joined: 02 Sep 2009
Posts: 37560
Followers: 7393
Kudos [?]: 99319 [0], given: 11010
Re: If r and s are positive integers, can the fraction r/s be expressed as [#permalink]
Show Tags
05 May 2014, 02:35
russ9 wrote:
Hi Bunuel,
Speaking from a prime perspective, I could factor "100" into prime factors and since I get 2^2 and 5^2, that should suffice in coming up with the right answer, correct? I don't need to pull up every single factors - right?
If the denominator had ANY other primes then it would NOT be a terminating decimal. Is that correct?
Not entirely. The denominator can have some other primes as well but if those primes can be reduced the fraction still would be terminating. For example, consider fraction 3/6. The denominator has 3 in it, but it ca be reduced to get 3/6=1/2=0.5.
_________________
Intern
Joined: 11 Oct 2012
Posts: 43
GMAT 1: 610 Q42 V32
Followers: 1
Kudos [?]: 8 [0], given: 74
Re: If r and s are positive integers, can the fraction r/s be expressed as [#permalink]
Show Tags | {
"domain": "gmatclub.com",
"id": null,
"lm_label": "1. Yes\n2. Yes\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 1,
"lm_q1q2_score": 0.8558511451289037,
"lm_q2_score": 0.8558511451289037,
"openwebmath_perplexity": 1704.6135320707817,
"openwebmath_score": 0.8141879439353943,
"tags": null,
"url": "https://gmatclub.com/forum/if-r-and-s-are-positive-integers-can-the-fraction-r-s-be-expressed-as-141000.html?fl=similar"
} |
performance, c, programming-challenge, bitwise
while(--i) {
int maskBits = 0;
for(j=0;j<N;j++) {
if(i%n[j]==0)
maskBits |= (1 << j);
}
if (maskBits == 0)
continue;
k=i;
while (k>0) {p[k%10]++; k/=10;}
for(j=1;j<10;j++) if(p[j]>0) {k=j; p[j]--; break;}
for(j=0;j<10;j++) while (p[j]>0) {k=10*k+j; p[j]--;}
mask[k] |= maskBits;
}
This ran about 5-10% faster than the previous version. | {
"domain": "codereview.stackexchange",
"id": 16203,
"lm_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, programming-challenge, bitwise",
"url": null
} |
kinematics, spring
Title: Uniform circular motion of a mass on a spring I'm trying to understand the following problem: A mass is attached to a spring and is set in uniform circular motion. We need to solve for how much the string is stretched, given the frequency of rotation, the unstretched length of the spring, the spring constant, and the mass of the object.
I would set up this problem like so (ignoring the directionality of the spring force):
$$F_s = kx = ma_c = m\frac{v^2}{r}=m\frac{(2\pi rf)^2}{r}=mr(2\pi f)^2$$
so
$$kx = mr(2\pi f)^2$$
where k is the spring constant, m is the mass, r is the radius of curvature, f is the frequency, and x is the amount by which the spring is stretched.
Speed (v) is $2 \pi r\over T$ where T is period and $\frac{1}{T} = f$.
So then, since the radius of curvature is the unstretched length of the spring plus the amount it's stretched by, I'd substitute $r = r_0 + x$ where $r_0$ is the unstretched length of the spring. Then, we can solve for x, which gives
$$x = \frac{r_0(2\pi f)^2}{\frac{k}{m} - (2\pi f)^2}$$
As far as I can tell, this is the mathematically correct answer. However, this of course diverges at
$$f = \frac{1}{2\pi}\sqrt{\frac{k}{m}}$$
which doesn't make physical sense. Furthermore, its answer approaches $r_0$ for values greater than the divergent f. I don't understand this behavior at all.
What would make intuitive sense is for the spring to be stretched more and more as the frequency gets larger. It won't be a linear relationship, but it shouldn't be this mess. | {
"domain": "physics.stackexchange",
"id": 45001,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "kinematics, spring",
"url": null
} |
By the union axiom again, the set $\bigcup \left\{\bigcup \{(Y')^{X'} : Y' \in 2^Y\} : X' \in 2^X\right\}$ exists. It remains to show that this set is the set of all partial functions from $X$ to $Y$. Let $f$ be an element of this set. Then by the union axiom, this means $f \in S$ for some $S \in \left\{\bigcup \{(Y')^{X'} : Y' \in 2^Y\} : X' \in 2^X\right\}$. By the replacement axiom, $S = \bigcup \{(Y')^{X'} : Y' \in 2^Y\}$ for some $X' \subseteq X$. Thus $f \in \bigcup \{(Y')^{X'} : Y' \in 2^Y\}$ for some $X' \subseteq X$. By the union axiom, this means $f \in S'$ for some $S' \in \{(Y')^{X'} : Y' \in 2^Y\}$. By the replacement axiom, $S' = (Y')^{X'}$ for some $Y' \subseteq Y$. Thus $f \in (Y')^{X'}$ for some $Y' \subseteq Y$ and $X' \subseteq X$. This means $f$ is a function from $X'$ to $Y'$, which means it is a partial function from $X$ to $Y$. This shows that every element of $\bigcup \left\{\bigcup \{(Y')^{X'} : Y' \in 2^Y\} : X' \in 2^X\right\}$ is a partial function from $X$ to $Y$. | {
"domain": "wordpress.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9669140254249554,
"lm_q1q2_score": 0.8036438640423504,
"lm_q2_score": 0.8311430415844384,
"openwebmath_perplexity": 96.66982541140824,
"openwebmath_score": 0.9872211217880249,
"tags": null,
"url": "https://taoanalysis.wordpress.com/latest-posts/"
} |
Writing the matrix $A$ relative to this basis is done by computing $A\vec{v}_1$ and expressing it in terms of $\vec{v}_1$ and $\vec{v}_2$ and then doing the same for $A\vec{v}_2$.
In matrix language, $T\vec{v}_1$ corresponds to $A\begin{bmatrix}1\\0\end{bmatrix}$. On the other hand, $T\vec{v}_1 = T\cos(t) = \cos(t)''+7\cos(t)' +4\cos(t) = 3\cos(t) -7\sin(t) = \begin{bmatrix}3\\-7\end{bmatrix}$
So, the matrix $A$ should have the property that $A\begin{bmatrix}1\\0\end{bmatrix} = \begin{bmatrix} 3\\-7\end{bmatrix}$. This forces $A$ to have the form $A = \begin{bmatrix} 3 & *\\-7 & *\end{bmatrix}$.
Can you take it from here?
-
$\bf Hint:$ First determine where $T$ sends the basis $\{\cos(t),\sin(t)\}$. Then write the images as a linear combination of the basis and consider the matrix that has as columns the coefficients of the linear combination.
- | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9854964169008471,
"lm_q1q2_score": 0.8190884935354591,
"lm_q2_score": 0.8311430457670241,
"openwebmath_perplexity": 196.0412058336982,
"openwebmath_score": 0.9135502576828003,
"tags": null,
"url": "http://math.stackexchange.com/questions/125513/linear-algebra-linear-transformations"
} |
java, benchmarking
Title: Performance testing app in Java (Release 2.0) I have greatly improved and expanded my my performance testing app
New features include:
Builder for type safe creation of a Measurer instances
Performs 10 runs of each procedure (default), or any number of runs a user chooses, and then calculates the average for each procedure
Provides more comprehensive comparison statistics. Minimum and maximum measurements are also output
The averages can be compared against the fastest procedure too (by default, they are still compared against the worst performer). Enum ReferencedProcedure is introduced for convenient customizing
measurer.compare() now accepts any number of arguments equal to or greater than two
Provides two types of defenses against the "warm-up" issue. A user may choose from the following WarmUpDefender constants: RESTLESS_POINTER (default) and WARM_UP_RUNS_DISCARDER. NONE is also available.
Tweaks:
NanoProcessingResult class – gone. nanoProcessor.process() now returns a regular array (I mapped it to an array anyway)
ComparisonLoggingIntermediary – gone. What with varargs, it no longer serves the app well
Qualification:
I tried to "separate my concerns" and add SLF4J support. The logging doesn't work, though! But let's imagine it does. I know this site is not about fixing code that doesn't work so I don't ask you anything on that. I guess the code itself is fine, but my configuration is faulty (I hate configurations!). If so, it's a client's job to configure it anyway (not my problem if they can't configure their logging) | {
"domain": "codereview.stackexchange",
"id": 44781,
"lm_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, benchmarking",
"url": null
} |
quantum-mechanics, density-operator
No experiment “local” to the subsystem (meaning: no observable of the form $\hat A=\hat A_{\text{sub}}\otimes I$) can tell the difference. Indeed this can be viewed as basis for tracing out those degrees of freedom in the first place, start from $\langle A\rangle =\operatorname {Tr} \rho \hat A$ and use this to find an expression $\langle A\rangle=\operatorname {Tr} \rho_{\text{sub}} \hat A_{\text{sub}}.$
But you can witness the difference if you can correlate with the rest of the supersystem.
A quick example
A good example to keep in mind is the delayed choice quantum eraser experiment. Recall that this consists of
photons pass through a dual slit experiment
those slits are outfitted with plates that rotate their polarizations 45°, so that the polarization difference is 90° between the two slits and we see a sum of two overlapping bell-shaped curves for the intensity on the screen, and
we generate the photons as entangled pairs, the initial polarization is entangled with the polarization of another photon which spins round and round in a long coil of fiber-optic cable. | {
"domain": "physics.stackexchange",
"id": 86146,
"lm_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, density-operator",
"url": null
} |
ros, computer-vision, raspberry-pi, cameras, monocular
Title: ROS Webcam Stream Really Slow I am trying to stream the images from my camera to a VM via ROS. Here is my setup:
Raspberry Pi 3B+ with Picamera v2. It is running ROS Noetic with cv_camera_node
An Ubuntu 20.04.1 VM with ROS Noetic. I am reviewing the live stream using rosrun rqt_image_view rqt_image_view | {
"domain": "robotics.stackexchange",
"id": 2333,
"lm_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, computer-vision, raspberry-pi, cameras, monocular",
"url": null
} |
mechanical-engineering, pressure, motors, torque
$$\begin{alignat}{2}
F &= \text{load on the screw} &&= 1400\text{ N} \\
d_m &= \text{mean diameter} &&= 0.01\text{ m} \\
\mu &= \text{coefficient of friction} &&= 0.2 \\
l &= \text{lead} &&= 0.002\text{ m}
\end{alignat}$$
$$
\text{Torque} = \frac{Fd_{m}}{2} \left( \frac{l+ \pi \mu d_{m}}{ \left( \pi d_{m}- \mu l \right)} \right)
$$
As a side note I also used the formula with the lead angle and angle of friction to be sure of my results for which I used:
$$\begin{alignat}{2}
\phi &= \text{angle of friction} &&= 11.3° \\
\lambda &= \text{lead angle} &&= 3.6433°
\end{alignat}$$
$$\text{Torque} = \frac{Fd_{m}}{2} tan(\Phi + \lambda)$$
for a total result of 1.86 Nm of torque (from both formulae!)
Well that's all nice and gives an answer that I like (a torque of 1.9 Nm is quite common for steppers).
But the fact that I like it doesn't mean that it's correct!
What makes me suspicious is that 1400 N of force is more or less what's needed to hold up a 140 kg man (please bear with me on that... I'm trying to use some "everyday experience" to get to a correct answer) and I can extrude the clay from the cartridge with my bare hand... I'm sure I'm not able to put 140 kg on that!
So what I'm asking is essentially if I followed the right path in tackling this problem. I'm unable to post a comment as I don't yet have 50 reputation! | {
"domain": "engineering.stackexchange",
"id": 1792,
"lm_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, pressure, motors, torque",
"url": null
} |
machine-learning, dataset
Title: What does it mean that an hypotesis is consistent? I am studying concept learning, and I am focusing on the concept of consistency for an hypotesis.
Consider an Hypotesis $h$, I have understood that it is consistent with a training set $D$ iff $h(x)=c(x)$ where $c(x)$ is the concept and this has to be verified for every sample $x$ in $D$.
For example consider the following training set:
and the following hypotesis:
$h_1=<?,?,?,Strong,?,?>$
I have that this is not consistent with D because for the example $3$ in $D$ we have $h(x)!=c(x)$.
I don't understand why this hypotesis is not consistent.
Infact, consider the following hypotesis:
$h=<Sunny,Warm,?,Strong,?,?>$
this is consistent with $D$ because for each example in $D$ we have $h(x)=c(x)$.
But why the first hypotesis $h_1$ is not consistent while the second,$h$, is consistent?
Can somebody please explain this to me? I'm not especially familiar with this but from the example provided we can deduce that:
An hypothesis is a partial assignment of values to the features. That is, by "applying the hypothesis" we obtain a subset of instances for which the features satisfy the hypothesis.
An hypothesis is consistent with the data if the target variable (called "concept" apparently, here EnjoySport in the example) has the same value for any instance in the subset obtained by applying it. | {
"domain": "datascience.stackexchange",
"id": 7924,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "machine-learning, dataset",
"url": null
} |
python, python-3.x, programming-challenge, strings, balanced-delimiters
for match in re.findall(pattern, S):
S.replace(match, '')
if not checkSubstring(match):
return False
return checkSubstring(S)
if __name__ == '__main__':
tests = list(BRACKETS.keys())
tests.extend(list(BRACKETS.values()))
tests += [
'a',
'(]',
'((((',
'({[<',
')}]>({[<',
'}{',
'(())',
'()[{]}',
'abc',
'(<[{a}s]>d)f',
'<as>df',
'()[{}]',
'(){}[]'
]
for test in tests:
print(test, ':', hasClosedBrackets(test))
Output
( : False
[ : False
{ : False
< : False
) : False
] : False
} : False
> : False
a : True
(] : False
(((( : False
({[< : False
)}]>({[< : False
}{ : False
(()) : False
()[{]} : False
abc : True
(<[{a}s]>d)f : True
<as>df : True
()[{}] : True
(){}[] : True Here's one opportunity to save cycles. The patterns for the brackets are getting compiled every time hasClosedBrackets is called.
Something like this could be added right after BRACKETS is defined:
brackets_compiled = {
(o, c): re.compile(r"(?<=\{}).+?(?=\{})".format(o, c)) for o, c in BRACKETS.items()
}
Then the following three lines can be modified:
From:
for (o, c) in BRACKETS.items():
pattern = r'(?<=\{}).+?(?=\{})'.format(o, c)
for match in re.findall(pattern, S): | {
"domain": "codereview.stackexchange",
"id": 43057,
"lm_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, programming-challenge, strings, balanced-delimiters",
"url": null
} |
python, pandas, python-3.x, groupby
You who are more versed in these issues, perhaps you can help me perform this operation.
Thank you so much! You can do this by making use of shift to create different groups based on consecutive values of the states column, after which you can use groupby to add the values in the values column:
(
df
.assign(
# create groups by checking if value is different from previous value
group = lambda x: (x["states"] != x["states"].shift()).cumsum()
)
# group by the states and group columns
.groupby(["states", "group"])
# sum the values in the values column
.agg({"values": "sum"})
.reset_index()
# select the columns needed in the final output
.loc[:, ["group", "values"]]
) | {
"domain": "datascience.stackexchange",
"id": 11551,
"lm_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, pandas, python-3.x, groupby",
"url": null
} |
quantum-mechanics
Wave-function of the form $\Psi(\vec{r}, m_s, t)$, also known as spin-orbital, arises as follows.
There is a postulate of QM which says that the state space $H$ of a system, composed of $n$ subsystems each associated with its own space $H_{i}$, is the tensor product of this spaces,
\begin{equation}
H = H_{1} \otimes H_{1} \otimes \dotsm \otimes H_{n} \, .
\end{equation}
The notion of a system composed of subsystems in the postulate above is not to be take literally: the state space can be written as a tensor product of state spaces which are not even associated with real physical systems.
For instance, we can subdivide electron with position in space and spin system into 2 subsystems: electron only with position in space and electron only with spin.
Taking spin into account the state space for a particle is the tensor product of
\begin{equation}
H = H_{\text{space}} \otimes H_{\text{spin}} \, ,
\end{equation}
where $H_{\text{space}}$ is a state space spanned by eigenvectors $\ket{r}$ of the position operator
\begin{equation}
\widehat{\vec{R}} \ket{\vec{r}} = \vec{r} \ket{\vec{r}} \, ,
\end{equation}
and $H_{\text{spin}}$ is a state space spanned by eigenvectors $\ket{m_{s}}$ of a spin component operator conventionally chosen to be $\widehat{S}_{z}$
\begin{equation}
\widehat{S}_{z} \ket{m_{s}} = m_{s} \hbar \ket{m_{s}} \, .
\end{equation} | {
"domain": "physics.stackexchange",
"id": 15028,
"lm_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",
"url": null
} |
jupiter, venus
Brightness of Venus and Jupiter
First, let's just confirm that Venus is indeed brighter. If you look up the Apparent Magnitude system of Wikipedia, you see a description of how astronomers measure visible brightnesses of astronomical objects (and coincidentally enough, this system was created by a Greek). In this system, smaller and more negative numbers indicate brighter objects. From the table on that page, we can see that the apparent magnitude of Venus varies from $-4.89$ at its brightest to $-3.82$ at its dimmest (this variation is caused by the different configurations of Earth, Venus, Sun positions). For Jupiter, we see that at its brightest it has an apparent magnitude of $-2.94$ and a minimum of $-1.61$. Clearly, even at its brightest, Jupiter is far outshone by Venus at its dimmest. Note that none of this takes into account light pollution or other atmospheric effects which would have been negligible to the Greeks and Babylonians anyway. So we can say emphatically yes that Venus is distinctly brighter than Jupiter, but importantly, we note that Jupiter is still brighter than every other star in the sky $-$ the brightest being Sirius with a magnitude of $-1.47$.
Confusion about Venus
Okay, the Greeks and Babylonians were sitting around looking at these planets and wondering what they were. Likely they started thinking they were big, great deities and started attributing gods to them. I can't say this is a certainty, but one possible reason Venus didn't get the top god was that initially the Greeks and Babylonians weren't even sure Venus was a planet like the rest of the planets were. Because Venus is so close to the Sun, we only ever see it at sunrise and sunset. Otherwise, it is in the sky during the day and dwarfed by the brightness of the Sun. This meant that it took the ancient peoples a long time before they even realized the bright object they saw in the evening was the same as the bright object they saw in the morning. To quote Wikipedia on this: | {
"domain": "astronomy.stackexchange",
"id": 2078,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "jupiter, venus",
"url": null
} |
Eigenvalue Inequalities for Hermitian Matrices
The eigenvalues of Hermitian matrices satisfy a wide variety of inequalities. We present some of the most useful and explain their implications. Proofs are omitted, but as Parlett (1998) notes, the proofs of the Courant–Fischer, Weyl, and Cauchy results are all consequences of the elementary fact that if the sum of the dimensions of two subspaces of $\mathbb{C}^n$ exceeds $n$ then the subspaces have a nontrivial intersection.
The eigenvalues of a Hermitian matrix $A\in\mathbb{C}^{n\times n}$ are real and we order them $\lambda_n\le \lambda_{n-1} \le \cdots \le \lambda_1$. Note that in some references, such as Horn and Johnson (2013), the reverse ordering is used, with $\lambda_n$ the largest eigenvalue. When it is necessary to specify what matrix $\lambda_k$ is an eigenvalue of we write $\lambda_k(A)$: the $k$th largest eigenvalue of $A$. All the following results also hold for symmetric matrices over $\mathbb{R}^{n\times n}$.
The function $f(x) = x^*Ax/x^*x$ is the quadratic form $x^*Ax$ for $A$ evaluated on the unit sphere, since $f(x) = f(x/\|x\|_2)$. As $A$ is Hermitian it has a spectral decomposition $A = Q\Lambda Q^*$, where $Q$ is unitary and $\Lambda = \mathrm{diag}(\lambda_i)$. Then | {
"domain": "nhigham.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9943580928375232,
"lm_q1q2_score": 0.8566774873014341,
"lm_q2_score": 0.8615382058759129,
"openwebmath_perplexity": 324.5997061624111,
"openwebmath_score": 0.9866310358047485,
"tags": null,
"url": "https://nhigham.com/2021/03/09/eigenvalue-inequalities-for-hermitian-matrices/?replytocom=25185"
} |
formal-grammars, undecidability, decision-problem, halting-problem, turing-completeness
An example of a language that isn't semi-decidable, and whose complement isn't semi-decidable either is the set of programs in a Turing-complete programming language that take an argument and return true for all arguments. This is the halting problem. For a language that isn't semi-decidable, (b) doesn't apply: it is impossible to write a function that returns true for all programs that terminate on all arguments and loops forever (or returns false) on all programs that loop on at least one input. | {
"domain": "cs.stackexchange",
"id": 1777,
"lm_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-grammars, undecidability, decision-problem, halting-problem, turing-completeness",
"url": null
} |
= \cases{ -2n & if n < 0, \cr 2n+1 & if n\geq0. We do not need to find the formula of the composite function, as we can evaluate the result directly: $$f(g(f(0))) = f(g(1)) = f(2) = -5$$. By definition of composition of functions, we have \[g(f(a_1))=g(f(a_2)).$ In this case, we find $$f^{-1}(\{3\})=\{5\}$$. Given $$f :{A}\to{B}$$ and $$g :{B}\to{C}$$, if both $$f$$ and $$g$$ are one-to-one, then $$g\circ f$$ is also one-to-one. Example – What is the composite of the relations and where is a relation from to with and is a relation from to with ? Therefore, we can find the inverse function $$f^{-1}$$ by following these steps: Example $$\PageIndex{1}\label{invfcn-01}$$. Featured on Meta “Question closed” notifications experiment results and graduation For more information contact us at info@libretexts.org or check out our status page at https://status.libretexts.org. This makes the notation $$g^{-1}(3)$$ meaningless. When A and B are subsets of the Real Numbers we can graph the relationship. Discrete Mathematics And Its Applications Chapter 2 Notes 2.6 Matrices Lecture Slides By Adil Aslam mailto:adilaslam5959@gmail.com 2. Combining Relation: Suppose R is a relation from set A to B and S is a relation from set B to C, the combination of both the relations is the relation which consists of ordered pairs (a,c) where a Є A and c Є C and there exist an element b Є B for which (a,b) Є R and (b,c) Є S. Example: The directed graph of relation R = | {
"domain": "ecdl.pl",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9664104953173166,
"lm_q1q2_score": 0.8307880674619875,
"lm_q2_score": 0.8596637469145054,
"openwebmath_perplexity": 573.0364218870329,
"openwebmath_score": 0.8222871422767639,
"tags": null,
"url": "http://pomyslzanimwrzucisz.ecdl.pl/bni-arizona-wvuf/3756aa-define-composition-and-inverse-relation-with-example-in-discrete-mathematics"
} |
textbook-and-exercises, pauli-gates, bloch-sphere, linear-algebra, state-tomography
Title: Why can any density operator be written this way? (quantum tomography) From page 24 of the thesis "Random Quantum States and Operators", where $(A,B)$ is the Hilbert-Schmidt inner product:
\begin{aligned}
\rho &=\left(\frac{1}{\sqrt{2}} I, \rho\right) \frac{1}{\sqrt{2}} I+\left(\frac{1}{\sqrt{2}} X, \rho\right) \frac{1}{\sqrt{2}} X+\left(\frac{1}{\sqrt{2}} Y, \rho\right) \frac{1}{\sqrt{2}} Y+\left(\frac{1}{\sqrt{2}} Z, \rho\right) \frac{1}{\sqrt{2}} Z \\
&=\frac{(I, \rho) I+(X, \rho) X+(Y, \rho) Y+(Z, \rho) Z}{2} \\
&=\frac{I+\operatorname{tr}(X \rho) X+\operatorname{tr}(Y \rho) Y+\operatorname{tr}(Z \rho) Z}{2}
\end{aligned}
This is used for explaining quantum tomography. Can someone please explain each step clearly? I have pretty basic QC and linear algebra knowledge. From linear algebra, if $v_1, \dots, v_n$ is a basis of the vector space $V$ then every vector $v\in V$ can be written as a linear combination
$$
v = a_1 v_1 + \dots + a_n v_n\tag1
$$ | {
"domain": "quantumcomputing.stackexchange",
"id": 2513,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "textbook-and-exercises, pauli-gates, bloch-sphere, linear-algebra, state-tomography",
"url": null
} |
plant-physiology
Title: Would a plant survive if it was watered using hard-water? Hard water is water with high mineral/salt content. I'm told that a potted plant watered with a salt solution dries out sooner or later. Is this true?
If so, would a plant survive if watered using hard-water? It would depend on the content of the hard-water. If the water contained heavier metals like lead or radioactive elements like tritium (Hydrogen-3), the plant would most likely die. Most land plants cannot survive when watered with massive amounts of salt water as the salt would absorb the water from the leaves. | {
"domain": "biology.stackexchange",
"id": 6355,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "plant-physiology",
"url": null
} |
newtonian-mechanics, friction, drag, oscillators, dissipation
Title: What is the physical interpretation of the linear coefficient in this ODE for projectile motion? For the second order ODE governing the position of a projectile subject to air resistance
$$ m\frac{d^2x}{dt^2} +k\frac{dx}{dt}+mg=0 \quad k>0, \> x(0)=0, \> x'(0)=V>0 $$
a non-dimensionalization can me made so that the system is then
$$ \frac{d^2X}{d\tau^2} +\beta\frac{dX}{d\tau}+1=0 \quad k>0 $$
for non-dimensional variables $X,\tau$. It turns out $ \beta=\frac{kV}{mg}$. What is the physical interpretation of $\beta$? I was inclined to say that it is the terminal velocity, but examining the ODE shows that terminal velocity is actually $\frac{mg}{k}$. I know that $\beta$ is the ratio between the the resistance it feels when fired and the total downward force.
So the question remains: What is $\beta$? You almost answered it on your own!
Essentially it's the ratio of the viscous force to the gravitational force. As $\beta \rightarrow 0$, the gravitational force dominates and the damping due to air friction is very small. Likewise, as $\beta \rightarrow \infty$, the air friction dominates the solution.
This isn't really all that illustrative physically, but it doesn't always have to be. What it does allow you do to is use only $\beta$ to determine trends. For example, if $\beta = 0.5$, the solution is the same whether you are on Mars, or under water on Earth, or your mass is huge or small, etc.. It's a similiarity parameter that reduces the number of variables in your problem from 4 ($k$, $V$, $m$, $g$) to a single variable, $\beta$. | {
"domain": "physics.stackexchange",
"id": 16615,
"lm_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, friction, drag, oscillators, dissipation",
"url": null
} |
The number of $0$-element subsets of $0$-element set is $1$. Indeed, the only empty subset of $\emptyset$ is $\emptyset$. :-)
There is only one way to choose $0$ objects from any sized set - To not choose. That makes as much sense if the set itself is empty as if the set has multiple objects.
• See my comment to fleablood's answer - it applies to yours, too. – Federico Poloni Jan 18 '17 at 13:15
• Um "to not choose" $\ne$ "to choose nothing". If you actually "not choose", then you're not choosing, so it's not a way of choosing $0$ objects from the set. – user21820 Jan 19 '17 at 11:41
By definition, $0! = 1$. Think of it like this: how many ways can we arrange no objects? Easy - one way, the way that arranges no objects.
• See my comment to fleablood's answer - it applies to yours, too. – Federico Poloni Jan 18 '17 at 13:16
Note also that $0! = 1$, for good reasons: it's convenient to define the empty product to be the identity, because then we get $$\prod_{x \in A} x \times \prod_{y \in B} y = \prod_{z \in A \cup B} z$$ for disjoint $A, B$ even when $A = \emptyset$.
• It's not MERELY "convenient". As the example in my answer shows, it is sometimes necessary for the correctness of standard formulas. – Michael Hardy Jan 17 '17 at 22:43
Other answers correctly address the first part of your question. For the second, the number of ways to choose one blue candy is $\binom{0}{1} = 0$: the number of ways to choose one item from an empty set. You don't evaluate that with the formula for the binomial coefficients. Use it for the numerator and you get the correct $0$ answer. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9777138099151277,
"lm_q1q2_score": 0.8270896014510997,
"lm_q2_score": 0.8459424353665381,
"openwebmath_perplexity": 451.07874918234245,
"openwebmath_score": 0.83139967918396,
"tags": null,
"url": "https://math.stackexchange.com/questions/2102195/picking-zero-out-of-zero-elements/2102295"
} |
homework-and-exercises, thermodynamics, ideal-gas, adiabatic
Title: Work Done by an Adiabatic Expansion I am given the information that a parcel of air expands adiabatically (no exchange of heat between parcel and its surroundings) to five times its original volume, and its initial temperature is 20° C. Using this information, how can I determine the amount of work done by the parcel on its surroundings?
I know that $dq = 0$, and that $du + dW = dq = 0$, but I don't know what to do with this information. $dW = pdV$, which seems like it should be helpful, but I don't know what to do for the pressure. More clues? :-)
This is harder then the isobaric process because now the pressure is a function of volume. You need to write the pressure as a function of volume, then integrate it from the initial to final volume. For some clues see the Wikipedia article on adiabatic expansion. Although the question doesn't say so, you'll need to assume the expansion is reversible as the question can't be answered otherwise. | {
"domain": "physics.stackexchange",
"id": 25372,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "homework-and-exercises, thermodynamics, ideal-gas, adiabatic",
"url": null
} |
python, bigdata, beginner, education
Title: What is most likely the bare minimum knowledge one has to have to become data scientist? I am a Python developer but I want to become a data scientist.
My Question:
At its core what is the bare minimum I need to have to make this transition? I know it cannot simply be that I need to learn Numpy and Pandas.
My Thoughts:
I am hoping to frame my question with the following three perspectives in mind and am trying to answer what is essentially needed for each category:
Technical: Analytics
Technical: Computer Science
Non-Technical: Soft Skills
Any help would be appreciated. :) From personal experience (so take into consider that I might not be representative although I'm probably not that far away too) the people that approached me with a job offer for
Data Scientist
did so because:
1) Considerable knowledge in one or more programming language typically used for data analysis. In my case Python.
2) Knowledge in applied mathematics (usually they don't even care about the base field). You just have to know how to interpret data and take valid conclusions from it (as a starting point at least).
3) Past experience with libraries such as numpy, scipy, scikit-learn (very relevant), scikit-image (if you are going to do image analysis also), pandas.
4) Past experience with data visualization libraries such as matplotlib, seaborn, Chaco, ggplot, pyQtGraph, Bokeh, etc.
5) Knowledge about regression techniques, clustering, and classification.
6) Valid extras depending on the field are typical applied mathematics in space estimation, image analysis and processing and computer vision, 3D visualization .
7) If you already have experience in building scientific software solutions using those programming languages, it might be a great advantage.
With point 7) in mind you might consider looking at PyQt5 and wxPython. | {
"domain": "datascience.stackexchange",
"id": 772,
"lm_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, bigdata, beginner, education",
"url": null
} |
backpropagation
However, this philosophy is broken several times, for instance in writing $a=f(z)$ instead of $f(z)=a$, or in using weight matrices that are indexed for matrix-vector multiplication, that is, the usual right-to-left direction $(z^{(3)})^T=\theta^{(2)} (a^{(2)})^T$, which following the philosophy should be written as $a^{(2)}(\theta^{(2)})^T=z^{(3)}$.
But then again the philosophy gets reversed in formulas like
$$
\delta^{(l)} = \delta^{(l + 1)}\,\Theta^{(l)}\,f'\left( a^{(l)} \right)
$$
which clearly is right-to-left, which suggests that the gradients $δ^{(l)}$ are row vectors and the argument vectors like $a^{(l)}$ are column vectors.
In short, it's a mess. | {
"domain": "ai.stackexchange",
"id": 3586,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "backpropagation",
"url": null
} |
number-formats
When he writes, "in other words", this means Prof. Knuth explained it to me in two ways and I still do not understand it.
Yes: in the sentence “[...] we can write its bits in the form $x = (\alpha01^a10^b)_2$; in other words, $x$ consists of some [...]”, the form of $x$ is described in two ways: (1) in notation, and (2) in words.
Longer explanation with context:
What is a 2-adic integer?
Although some people (IMO incorrectly) describe The Art of Computer Programming as a reference book, in fact it is written to teach, so one cannot look up a random page or section and expect to understand it in isolation.
In this case, the “$2$-adic integers” mentioned here are first briefly described on page 2 of Fascicle 1 (page 134 when part of Volume 4A), where it is said:
Negative integers are to be thought of in this connection as infinite-precision numbers in two’s complement notation, having infinitely many $1$s at the left; for example, $−5$ is $(\dots1111011)_2$. Such infinite-precision numbers are a special case of 2-adic integers, which are discussed in exercise 4.1–31, and in fact the operators $\&$, $|$, $\oplus$ make perfect sense when they are applied to arbitrary 2-adic numbers.
This may be enough context for what is in the question here, but to understand this more completely, it would be best to look up (as mentioned) Exercise 31 of section 4.1 (Positional Number Systems), which is on page 213 of Volume 2. The exercise covers three-fourths of a page and is very instructive, but let me just quote part of it: | {
"domain": "cs.stackexchange",
"id": 12568,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "number-formats",
"url": null
} |
beginner, html, css
*,*:before,*:after { box-sizing: border-box; }
.mainHeader {
background: rgb(255,0,0);
padding: 12px;
}
.mainHeader h1,h2,h3 {
text-align: center;
color: rgb(255,255,255);
font-family: "Lato";
}
.mainHeader h1 {
font-size: 24px;
font-weight: bold;
color: rgb(0,0,0);
}
.mainHeader h2 {
font-size: 20px;
margin-bottom: 2px;
}
.mainHeader h3 {
font-style: italic;
}
.mainArticle {
box-shadow: 1px 1px 9px #888888;
padding: 12px;
margin: 24px auto;
width: 90%;
}
.mainArticle h1 {
font: 24px "Lato";
font-weight: bold;
}
.mainArticle h2 {
color: rgb(0,0,0);
text-align: left;
}
.mainArticle ul {
padding: 0;
display: inline;
}
.mainArticle ul li{
margin-left: 22px;
font-family: "Lato";
list-style-type: square;
}
.mainFooter {
border-top: 1px solid rgb(0,0,0);
text-align: center;
padding: 12px;
width: 100%;
background: rgb(255,0,0);
font-family: "Lato";
color: rgb(255,255,255);
}
.mainNavigation a:not(.current) {
opacity: 0.5;
}
.mainNavigation ul {
padding: 0;
display: table;
margin: 15.5px auto;
}
.mainNavigation p {
position: absolute;
font-family: "Lato";
color: rgb(255,255,255);
font-weight: bold;
top: 60px;
left: 6px;
}
.mainNavigation ul li {
float: left;
margin-right: 5px;
} | {
"domain": "codereview.stackexchange",
"id": 12861,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "beginner, html, css",
"url": null
} |
genetics, bioinformatics, microbiology, sequence-analysis, primer
Title: Which is the reference 16S rRNA? Recently, I've stumbled upon a fact, which hasn't bothered me for many years. The fact is that all universal 16S primers are written as "[FR][0-9]+" (in regex notation), that is they have a position with respect to a reference. I've read through many papers, wherein these primers were introduced, and most of the time the authors say nothing but "E. coli 16S". Anyway, in one case I've found that it is in fact the reference K12 E. coli. But the problem is that it has 7 distinct rRNA operons: rrnA, rrnB, rrnC, rrnD, rrnE, rrnF, rrnG. Do you have a reference showing a particular operon used for the 16S position notation?
Edit
Figure 2. Hypervariable regions within the 16S rRNA gene in Pseudomonas . The plotted line reflects fluctuations in variability amongst aligned 16S rRNA gene sequences of 79 Pseudomonas type strains... (Bodilis et al., 2012) As you correctly point out, designing an optimal primer pair for 16S-rRNA sequencing is a tricky affair because even the less-variable regions are not same between different strains and species. Sambo et al (2018) have even developed a bioinformatics software for optimal design of primers for 16S-rRNA sequencing for multiple bacteria.
We propose here a computational method for optimizing the choice of
primer sets, based on multi-objective optimization, which
simultaneously: 1) maximizes efficiency and specificity of target
amplification; 2) maximizes the number of different bacterial 16S
sequences matched by at least one primer; 3) minimizes the differences
in the number of primers matching each bacterial 16S sequence. Our
algorithm can be applied to any desired amplicon length without
affecting computational performance.
There is diversity in the 16S-rRNA genes within the same species i.e. the different copies are not exact duplicates (Větrovský & Baldrian, 2013).
Větrovský & Baldrian (2013) | {
"domain": "biology.stackexchange",
"id": 9576,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "genetics, bioinformatics, microbiology, sequence-analysis, primer",
"url": null
} |
radio-telescope
Title: Why are radio telescopes often built into natural depressions? Radio telescopes are often built into sink holes or natural depressions in the landscape.* This is opposed to optical telescopes which are usually placed on mountains to avoid as much atmosphere as they can.
So why natural depressions? Is it easier to build them in a hole, less interference from local emissions, or something else?
*Or at least the well known ones like former Arecibo Observatory and Five-hundred-meter Aperture Spherical Telescope Depressions are ideal for extremely large single-dish telescopes like Arecibo and FAST for several reasons, but the single greatest advantage is structural. These instruments are several hundred meters in diameter and therefore require delicate support systems to maintain their shape and avoid collapse. You could certainly try and build a freestanding dish, but it would be even harder than it already is. The karst depression FAST was built in, Dawodang, is close to spherical, like the telescope, making building the support structure comparatively easy (Zhu et al. 2018).
Besides the structural benefits unique for these large dishes, building a telescope in such a depression provides natural shielding from radio frequency interference. Some radio telescopes built on flat ground, like those at the Green Bank Observatory, are similarly protected by the surrounding hills (as well as, in Green Bank's case, a large radio quiet zone). Both Arecibo and FAST benefit from walls of their depressions -- one reason Arecibo's current site is considered promising for the telescope's possible successor, regardless of configuration (Anish Roshi et al. 2021).
Finally, depressions provide drainage. Water can flow to the center of the natural bowl and, particularly in karst topography, subsequently seep into the ground -- one advantage they have over other types of depressions, like craters or mine pits. While karst is permeable, it isn't fragile, so you don't have to sacrifice stability for the sake of drainage.
Basically, the structural advantages of depressions are applicable just to these extremely large telescopes, but there are side benefits, albeit ones which other, smaller radio telescopes not located in depressions can achieve in other ways. | {
"domain": "astronomy.stackexchange",
"id": 7008,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "radio-telescope",
"url": null
} |
python, image, ascii-art
jjjjjjjfftffjfjjjjjjjjjjffft//fffjjfftttfjjjt//tfjfffjjrrjffjjrrrrxxuU*B0f\()}?-](nbB#kkkhhhkkkkkkkkbbbbbbbbbbbbbbbbbbkhkdddbkhkkbbkkkkkbbbbbkkkkbbbkhhkbbkWBdXrxOa#hQUYzvccccvuuuuunuuuvvunnnnnnnnnnnxxxnnnxrrxxnxxrjjjrxnnnnxxxxrrrrrjfjrxxrrxxxxjjrxxrjrrffjjjjjrrrxxxrjfjxxrxxxrjjrrjxxxrjjjjjjjjjjjjjjj
ffttffffffffffffjjjjjfff//tt//tfffffft////tft//ttfffffrrrjjrxxxrrnnncC#BQt(11[--[tUo$Mkhhhkbbbbkkkkkkbbkkkkkkkkkkkkkkkkkbbbbkkkkbbbkkkkkkbbbbkkkkbbbbbkkdba&$pcfrZo#kQJUXcvvunxnuunnxxxxnnxxxxxxxxnuuunnnnnnrrxnnnxxxxxxxxnnuunxnnnnxxrrrrrrrxxxxxxrrxrrrrnuuuunnnnnnnnuunrjrnnnxxnnxxxxxxxxxrrrjjjrrjjjjjjj
tt/tttftttffffffftttttff//////ttttttffffffffjjfffffffjrxnuuuuuuvvuuuUm&BQft|{]__[r0#B*bkhkkbddbkhhkkbkkkkkkkkkkkkkkkkkbbbkkkkkbbbbkkkkkkkkkkkkkkkkkbbbkkbbh&$pcjnq#MkLYYzvunnnnnuuvuunnuuuunnuuuunnuunnnnxrrrnuvvuuuvcvvuuvvuunuuvccvuuvvvvuuuuuuuuvvunxrxnuuunnnuvunxxnnnnnnuunxxxnnxrrrrrxxxrjjrxnnnnxxxxx
fttt//////ttfffjjtttjjjffjxxxrjjjjfjrrxxnunnnnuuuxjjrxnuunxnuvvvuvuvQb#az||)[--?1vqM%obbkhhkkkkkkkkkkkkkkkbbbbbbkkkkkkkkkkkkhhkkkkkkkbbbbbbbkkkkkkkkbbkkkkkW$bUnuZoWhCXzccvuvuuunnvvvunuvvuuuvuxrxuvunuunxrrrxnuuuuunnnnuvvuxrrrxnuuuuuuuuuvvvvvvvvvvvunxxxnnnnxxxxxxnnnnnnnuuunnxrxnnnxxnuunxxuvcvuuvuuuvvv | {
"domain": "codereview.stackexchange",
"id": 43626,
"lm_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, ascii-art",
"url": null
} |
quantum-mechanics, quantum-field-theory, thermal-radiation
When I attempt to follow how the author got $I(\omega) = \dfrac{1}{V} \dfrac{dE(\omega)}{d \omega} = \dfrac{\hbar}{\pi^2} \dfrac{\omega^3}{e^{\hbar \omega \beta} - 1}$, I get
$$I(\omega) = \dfrac{1}{V} \dfrac{\hbar L^3}{\pi^2} \dfrac{\omega^3}{e^{\hbar \omega \beta} - 1}$$
What happens here with the $V$ and the $L^3$? We know that $L$ is the size of the "box" (as the author describes it), and I'm guessing that $V$ is volume (of phase space, as the author implies). So since we take the continuum limit, $L \to \infty$, the size of the "box" is growing to infinity; and if $V$ is the volume of phase space, I'm assuming that this volume also grows to infinity? And so, based on my best attempt at inferring what's going on here, it seems that $V$ and $L$ cancel out due the "box" becoming infinitely large? But, from a mathematical point of view, would this not result in the indeterminate form $\dfrac{\infty}{\infty}$, since both $L$ and $V$ blow-up to infinity?
I would greatly appreciate it if people could please take the time to clarify this. $V$ is the volume of the box, $V=L^3$. It cancels out, as you say. | {
"domain": "physics.stackexchange",
"id": 59356,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-mechanics, quantum-field-theory, thermal-radiation",
"url": null
} |
reference-request, pl.programming-languages, type-theory, dependent-type, typed-lambda-calculus
Title: Proof techniques for showing that dependent type checking is decidable I'm in a situation where I need to show that typechecking is decidable for a dependently-typed calculus I'm working on. So far, I've been able to prove that the system is strongly normalizing, and thus that definitional equality is decidable.
In many references I read, the decidability of typechecking is listed as a corollary of strong normalization, and I believe it in those cases, but I'm wondering how one goes about actually showing this.
In particular, I'm stuck on the following:
Just because well typed terms are strongly normalizing, doesn't mean that the algorithm won't loop forever on non-well typed inputs
Since logical relations are usually used to show strong normalization, there's not a convenient decreasing metric as we progress typechecking terms. So even if my type rules are syntax directed, there's no guarantee that applying the rules will eventually terminate. | {
"domain": "cstheory.stackexchange",
"id": 4479,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "reference-request, pl.programming-languages, type-theory, dependent-type, typed-lambda-calculus",
"url": null
} |
\le m_1} \frac{1}{m_2}$$ and the first term is $$\zeta(4)+\zeta(3,1),$$ while the second term is $$\zeta(2,2)+\zeta(2,1,1).$$ These add up to $3\zeta(4)$ by Granville-Zagier. | {
"domain": "mathoverflow.net",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9820137910906878,
"lm_q1q2_score": 0.8246303331627589,
"lm_q2_score": 0.839733963661418,
"openwebmath_perplexity": 610.7063240209214,
"openwebmath_score": 0.8738951683044434,
"tags": null,
"url": "https://mathoverflow.net/questions/272492/iterated-harmonic-numbers-vs-riemann-zeta"
} |
c, arduino
void loop()
{
byte numberOneFirstDigit_state = digitalRead(numberOneFirstDigitButton);
byte numberOneSecondDigit_state = digitalRead(numberOneSecondDigitButton);
byte numberTwoFirstDigit_state = digitalRead(numberTwoFirstDigitButton);
byte numberTwoSecondDigit_state = digitalRead(numberTwoSecondDigitButton);
if(numberOneSecondDigit_state == LOW && numberOneFirstDigit_state == LOW && numberTwoSecondDigit_state == LOW && numberTwoFirstDigit_state == LOW)
{
digitalWrite(numberOneFirstDigit , LOW);
digitalWrite(numberOneSecondDigit , LOW);
digitalWrite(numberTwoFirstDigit , LOW);
digitalWrite(numberTwoSecondDigit , LOW);
digitalWrite(sumFirstDigit , LOW);
digitalWrite(sumSecondDigit , LOW);
digitalWrite(carryDigit , LOW);
}
else if(numberOneSecondDigit_state == LOW && numberOneFirstDigit_state == LOW && numberTwoSecondDigit_state == LOW && numberTwoFirstDigit_state == HIGH)
{
digitalWrite(numberOneFirstDigit , LOW);
digitalWrite(numberOneSecondDigit , LOW);
digitalWrite(numberTwoFirstDigit , HIGH);
digitalWrite(numberTwoSecondDigit , LOW);
digitalWrite(sumFirstDigit , HIGH);
digitalWrite(sumSecondDigit , LOW);
digitalWrite(carryDigit , LOW);
}
else if(numberOneSecondDigit_state == LOW && numberOneFirstDigit_state == LOW && numberTwoSecondDigit_state == HIGH && numberTwoFirstDigit_state == LOW)
{
digitalWrite(numberOneFirstDigit , LOW);
digitalWrite(numberOneSecondDigit , LOW);
digitalWrite(numberTwoFirstDigit , LOW); | {
"domain": "codereview.stackexchange",
"id": 44041,
"lm_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, arduino",
"url": null
} |
roslaunch, ros-melodic
<launch>
<node name="pub" pkg="rostopic" type="rostopic" args="pub /foo std_msgs/Float64 0.5 -r 1" />
<node name="foobar" pkg="topic_tools" type="transform" args="/foo /bar std_msgs/Float64 'm' --wait-for-start"/>
</launch> | {
"domain": "robotics.stackexchange",
"id": 34775,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "roslaunch, ros-melodic",
"url": null
} |
context-free, regular-expressions, parsers
Title: fixed point in regular expressions I've posted this question first on StackOverflow but this section seems more suited for this kind of questions.
Also I'm not trying to simply solve this exercise (it is a "parsing" exercise, once I'll figure out the regular expression I'll derive the equivalent Finite Automaton that accepts the language generated by the grammar), but instead I'm trying to understand the methodology to derive regular expressions (if they exists, from context-free grammars)
I have this productions of a context free grammar (axiom S, e is the empty word)
S->AS|b|A
A->abA|Ab|e
I have to figure out a regular expression (if exists) that generates a language equivalent to the one generated by that grammar.
So far i wrote that
L(S)=L(A)L(S) + b + L(A) = L(A)*(L(A) + b) (by Arden Rule)
L(A)=(ab)*(L(A)b+e)
I've tried the method of finding the fixed point (I'd like more info about that since seems I can't get the hang of it
for A: 0 -> e -> (ab)*(b+e) -> (ab)*[(ab)*(b+e)](b+e) | {
"domain": "cs.stackexchange",
"id": 4894,
"lm_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, regular-expressions, parsers",
"url": null
} |
is the sum of the interior angles of a triangle equal to 180? Sum Of The Interior Angles Of A Triangle 2 - Displaying top 8 worksheets found for this concept.. You can do this. Step-by-step explanation: Sum of interior angles of a polygon=180. Exterior angle is defined as the angle formed between a side of triangle and an adjacent side extending outward. Maybe it's a piece you'd been looking for on and off for a while. In a triangle, the exterior angle is always equal to the sum of the interior opposite angle. Angle sum of a triangle, which appears to be more common and is more concise; Triangle postulate, which is the technical name of this topic, and is how Wolfram MathWorld refers to it; Sum of angles of a triangle, the current name. [1] In the presence of the other axioms of Euclidean geometry, the following statements are equivalent:[2], The sum of the angles of a hyperbolic triangle is less than 180°. It is also possible to calculate the measure of each angle if the polygon is regular by dividing the sum by the number of sides. Proof 2 uses the exterior angle theorem. Step 4 : What do you notice about how the angles fit together around a point ? It follows that a 180-degree rotation is a half-circle. Interior Angles of a Triangle Rule. "},{"@type":"Question","acceptedAnswer":{"@type":"Answer","text":"180°Triangle/Sum of interior angles\u003ca href='https://aahanaledlights.com/qa/question-why-is-the-sum-of-interior-angles-of-a-triangle-180.html#qa-what-is-the-sum-of-the-interior-angle-of-a-triangle'\u003eread more\u003c/a\u003e"},"name":"🗯What is the sum of the interior angle of a triangle? Angles between adjacent sides of a triangle are referred to as interior angles in Euclidean and other geometries. Example 8 : In a right triangle, apart from the right angle, the other two angles are x + 1 and 2x + 5. find the angles of the triangle. This | {
"domain": "marthlab.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.974821163419856,
"lm_q1q2_score": 0.8708169248870756,
"lm_q2_score": 0.8933094167058151,
"openwebmath_perplexity": 438.1732006133894,
"openwebmath_score": 0.4591764509677887,
"tags": null,
"url": "http://www.marthlab.com/vym-dividend-mjmfxq/kz3l1j3.php?7e3bed=sum-of-interior-angles-of-a-triangle"
} |
javascript, reinventing-the-wheel, ecmascript-6, event-handling, callback
function Emitter() {
//constructor
this.eventHandlers = {};
}
/**
* Emit an event
* @param event string
* @param arg1...argN - any arguments to be sent to callback functions
*/
Emitter.prototype.emit = function(event) {
const args = Array.from(arguments).slice(1);
if (this.eventHandlers.hasOwnProperty(event)) {
let indexesToRemove = [];
for (const index in this.eventHandlers[event]) {
const handler = this.eventHandlers[event][index];
handler.callback.apply(null, args);
if (handler.hasOwnProperty('once')) {
indexesToRemove.push(index);
}
}
if (indexesToRemove.length) {
for(const index in indexesToRemove) {
this.eventHandlers[event].splice(index, 1);
}
}
}
};
/**
* Register a callback for an event
* @param event
* @param callback
*/
Emitter.prototype.on = function(event, callback) {
addHandler.call(this, event, {callback: callback});
}; | {
"domain": "codereview.stackexchange",
"id": 31577,
"lm_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, reinventing-the-wheel, ecmascript-6, event-handling, callback",
"url": null
} |
photons
Title: How can a single photon or electron create a small visible dot on a photosensitive plate? The photon or electron is just one subatomic particle, but if it hits the film and creates a dot visible to the human eye (btw, modern technology can do this), then the dot must be a collection of millions of atoms or molecules on the screen that have been transformed via chemical reactions triggered by that single photon or electron.
How exactly can it happen?
(Presumably the photon hits just one atom in the photosensitive plate (as in a double slit experiment), thus changing only that one single atom, a happening that is still microscopic and invisible to the human eye.)
Edit: If I rephrase the question and say "a few photons", they are still completely microscopic and my question will be the same.
but if it hits the film and creates a dot visible
I guess that You think of a classical film made from
silver halide crystals in gelatin?
Your assumption is quite good, only the "atom" is not
the right thing.
Research on the most sensitive films showed that about
4 absorbed photons are needed to transform one silver halide
crystal into the "latent" picture form.
This form is a electron trapped in some crystal imperfection,
called a "trap" (trace amounts of sulfide are important for this)
This "latent" sensiticed crystal then is preferably reduced
to silver when the film is immersed into the developer,
a catalytic effect.
Crystals without this trapped electrons will not be reduced,
at least not within the usual temperature and time used
for that development.
What is important here, this "development" (reaction with a
reducing chemical) is a amplifying process,
reducing millions of silver atoms (the whole crystal)
induced by one of that trapped electrons.
PS
The geiger counter tube and the photomultiplier mentioned in the
comments above are good examples for similar action, because
both contain "built in" amplifiers, but physical, whereas the
photographic film was chemically amplified. | {
"domain": "physics.stackexchange",
"id": 19225,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "photons",
"url": null
} |
CB
• August 28th 2010, 01:43 AM
caramelcake
Thank you CaptainBlack! But I have tried using the quadratic formula and can't seem to continue:
(I got a latex error so forgive my handwriting)
http://picpanda.com/images/zz33rm40rio1zxj1j.png
Does this mean that my answer should contain a surd?
• August 28th 2010, 02:09 AM
Educated
How did you get (m^2 - 16m) inside the square root? Shouldn't it be just M^2?
$x = \dfrac{4+m\pm\sqrt{(-4-m)^2 - 4 * 1 * (4+2m)}}{2}$
This is what I got:
$x = \dfrac{4+m\pm\sqrt{16 + m^2 + 8m - 16-8m}}{2}$
$x = \dfrac{4+m\pm\sqrt{m^2}}{2}$
$x = \dfrac{4+m+m}{2} = 2+m$
$x = \dfrac{4+m-m}{2} = 2$
Therefore the line will always hit the parabola at point 2, and also the point 2 + gradient.
• August 28th 2010, 03:17 AM
caramelcake
Thank you Educated! I have finished this sum now.
@CaptainBlack
Why isn't the textbook answer right then?
Taking $x$ to be $2 + m$,
$y = m (2 + m) - 4 - 2m$
$y = 2m + m^2 - 4 - 2m$
$y = m^2 -4$
Hence the coordinates of point B are $(2 + m, m^2 -4)$
• August 28th 2010, 07:31 AM
CaptainBlack
Quote: | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9770226254066621,
"lm_q1q2_score": 0.8183736596292795,
"lm_q2_score": 0.8376199673867852,
"openwebmath_perplexity": 507.00799736470213,
"openwebmath_score": 0.8238255381584167,
"tags": null,
"url": "http://mathhelpforum.com/geometry/154580-line-intercepting-curve-print.html"
} |
qiskit, quantum-algorithms, circuit-construction, hhl-algorithm
Title: How to effectively compute eigenvalue rotation in HHL In the HHL algorithm, how do you efficiently do the $\lambda-$controlled rotation on the ancillary qubit ? It seems to me after reading around some answers that this can be done in two steps :
First, we map $|\lambda\rangle\mapsto |\frac{1}{\pi}\arcsin(\frac{C}{\lambda})\rangle$, defining $|\frac{1}{\pi}\arcsin(\frac{C}{\lambda})\rangle$ to be a binary representation $|\frac{1}{\pi}\arcsin(\frac{C}{\lambda})\rangle$ with $m$ qubits.
Then perform a controlled rotation $U_y(|\theta\rangle \otimes |0\rangle)\mapsto |\theta\rangle \otimes \big(\cos(\theta)|0\rangle + \sin{(\theta})|1\rangle\big)$ where $U_y$ is simply
$$
U_y(|\theta\rangle \otimes |0\rangle) = \prod_{j=1}^m (I^{\otimes^m}\otimes R_y(2\pi\theta_j/2^j))
$$
i.e. a sequence of controlled rotations where we successively halve the angle of rotation conditionally of the digits of the binary representation of $\theta$.
My question is the following how can one implement efficiently the first step in an environment such as Qiskit ? There is a new approach that will be merged soon in qiskit terra (here for the PR) that uses polynomial approximation to compute $\arcsin(C/\lambda)$, and asymptotically this would be the efficient implementation.
In practice if you are solving a $2\times 2$ matrix or a very small system it would be better to hard code the rotations.
The theory and error analyses of this approach are explained in Section VI of this paper. | {
"domain": "quantumcomputing.stackexchange",
"id": 2223,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "qiskit, quantum-algorithms, circuit-construction, hhl-algorithm",
"url": null
} |
# double sum
#### jacks
##### Well-known member
Let $f(m,n) = 3m+n+(m+n)^2.$ Then value of $\displaystyle \sum_{n=0}^{\infty}\;\; \sum_{m=0}^{\infty}2^{-f(m,n)}=$
#### Krizalid
##### Active member
Take a look at $f(n,m).$
#### CaptainBlack
##### Well-known member
Let $f(m,n) = 3m+n+(m+n)^2.$ Then value of $\displaystyle \sum_{n=0}^{\infty}\;\; \sum_{m=0}^{\infty}2^{-f(m,n)}=$
Might I ask where this question comes from?
The sum converges very quickly and can be evaluated numerically with 4 terms of each summation (it is $$\approx 1.33333$$, which is very suggestive ... ) to good accuracy.
CB
(why the previous calc got the wrong answer I still have no idea)
Last edited:
#### Opalg
##### MHB Oldtimer
Staff member
I hope Krizalid will not object if I add a bit to his very helpful suggestion. In problems like this, my advice is always to start by looking at what happens for small values of the variables. In this case, if you make a table of the values of $f(m,n)$ for small values of $m$ and $n$, it looks like this:
$$\begin{array}{cc}&\;\;\;\;n \\ \rlap{m} & \begin{array}{c|cccc} &0&1&2&3 \\ \hline 0&0&2&6&12 \\ 1&4&8&14&. \\ 2&10&16&.&. \\ 3&18&.&.&. \end{array} \end{array}$$ | {
"domain": "mathhelpboards.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9683812345563902,
"lm_q1q2_score": 0.8191947874461815,
"lm_q2_score": 0.8459424431344437,
"openwebmath_perplexity": 889.2294679929049,
"openwebmath_score": 0.7838066816329956,
"tags": null,
"url": "https://mathhelpboards.com/threads/double-sum.960/"
} |
python, performance, programming-challenge, computational-geometry
def coprime(m, n):
"""Return True iff m and n are coprime."""
return gcd(m, n) == 1
def all_primitive_triples():
"""Generate all primitive Pythagorean triples, together with a lower
bound on the perimeter for which all triples have been generated
so far.
"""
for m in count(1):
for n in range(1, m):
if (m + n) % 2 and coprime(m, n):
a = m * m - n * n
b = 2 * m * n
yield a, b, m * m + n * n, 2 * m * (m + 1)
def problem75(limit=1500000):
"""Return the number of values of L <= limit such that there is
exactly one integer-sided right-angled triangle with perimeter
L.
"""
triangles = Counter()
for a, b, c, q in all_primitive_triples():
if q > limit:
break
p = a + b + c
for i in range(p, limit + 1, p):
triangles[i] += 1
return sum(n == 1 for n in triangles.values())
This solves the Project Euler problem in a more reasonable amount of time:
>>> timeit(problem75, number=1)
2.164217948913574 | {
"domain": "codereview.stackexchange",
"id": 3658,
"lm_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, programming-challenge, computational-geometry",
"url": null
} |
algorithms, dynamic-programming
Title: Is there an efficient way to solve this problem? Given a series of n numbers, I need an algorithm that runs in worst case O(n*k) to figure out how many arrangements of those n numbers will give me a score of exactly k.
Note that the series does not contain duplicate elements.
The score of a series of numbers is calculated by the number of smaller numbers an element in the series has before it.
For example, The score of the below series would be:
series = [5,3,6]
5 has no smaller number before it, so 0
3 has no smaller number before it, so 0
6 has 2 smaller numbers before it (5,3) so 2
Adding all of this, we get a total score for the series as 2.
What I have tried to do:
I have tried to find all possible arrangements of the series -> (n! many arrangements)
and count the ones that have a score of k.
But this has a worst case time complexity of O(n!). Any help/ideas will be much appreciated. Thanks! Note that the values contained in the series are not important, and you can consider those values are exactly $1, 2, …, n$ (because only relative order is important).
Denote $A(n, k)$ the number of arrangements of $n$ values to reach score $k$.
Given an arrangement of $n$ values of score $k$, if you add the value $n+1$, you can:
put it in first position and not change the score;
put it in second position and add one to the score;
…
put it in last position and add $n$ to the score.
Considering all this, we get the induction formula:
$$A(n+1, k) = \sum\limits_{i = 0}^n A(n, k - i)$$
The base cases are:
$A(1, 0) = 1$;
$A(n, k) = 0$ if $k < 0$. | {
"domain": "cs.stackexchange",
"id": 20560,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "algorithms, dynamic-programming",
"url": null
} |
c, assembly, virtual-machine
if (opcode_exec(vm))
{
return;
}
}
}
main.c:
#include <stdio.h>
#include "toyvm.h"
static size_t getFileSize(FILE* file)
{
long int original_cursor = ftell(file);
fseek(file, 0L, SEEK_END);
size_t size = ftell(file);
fseek(file, original_cursor, SEEK_SET);
return size;
}
int main(int argc, const char * argv[]) {
if (argc != 2)
{
puts("Usage: toy FILE.brick\n");
return 0;
}
FILE* file = fopen(argv[1], "r");
size_t file_size = getFileSize(file);
TOYVM vm;
InitializeVM(&vm, 10000, 5000);
fread(vm.memory, 1, file_size, file);
fclose(file);
RunVM(&vm);
if (vm.cpu.status.BAD_ACCESS
|| vm.cpu.status.BAD_INSTRUCTION
|| vm.cpu.status.INVALID_REGISTER_INDEX
|| vm.cpu.status.STACK_OVERFLOW
|| vm.cpu.status.STACK_UNDERFLOW)
{
PrintStatus(&vm);
}
}
Also, you can find the FizzBuzz program for ToyVM here; run as toy fizzbuzz.brick.
Please, tell me anything that comes to mind. I see some things that may help you improve your code.
Don't leak memory
The code for InitializeVM allocate memory for the vm->memory member. Every allocation should have a corresponding free, so I would suggest adding this function to the interface and then calling it at the end of main:
void DestroyVM(TOYVM* vm) {
free(vm->memory);
} | {
"domain": "codereview.stackexchange",
"id": 18947,
"lm_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, assembly, virtual-machine",
"url": null
} |
thermodynamics, energy, home-experiment
Additionally, what power rating could I go down to if I were to increase the time to boil by 50%?
As above, if 2000 Watt nominal input gives an ~= 45 minutes to boiling, and the target was < 1 hour, then you'd expect an increase in time to boiling by a factor of 1.5 to 90 minutes to require ABOUT 2000 x 45/90 = 1000 Watts electrical input if thermal losses are able to be scaled down proportionally. With "normal" cooking energy sources adding insulation is problematic but with induction heating adding another towel wrapper and a layer of padding on top is actually feasible. If losses cannot be scaled down then see above calculations for assumed losses and recalculate accordingly. | {
"domain": "physics.stackexchange",
"id": 23114,
"lm_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, energy, home-experiment",
"url": null
} |
forces, classical-mechanics
$$t_1+t_2=dm a+dm g cos(\phi)$$ where $\phi$ is the angle of the rope with respect to gravity. Again, if $dm=0$ then the tension is constant along the rope, i.e. the rope "compensates" its tension at all points along the rope itself. If the rope is not massless, then the part of the rope "on the top" has to compensate for the weight of the rope "on the bottom" and the $dm g cos(\phi)$ part would not be zero, making the problem harder: that's why we usually neglect the rope's mass.
This all means that in the example we discussed before, along rope 1 $T_1$ is constant and along rope 2 $T_2$ is constant but in general $T_1$ is different than $T_2$ because the ball's gravity acts differently on the two parts. But because the rope is massless, finding the tension of each rope at the point where it touches the ball is the same as finding the tension of the rope at all points because the tension is constant! | {
"domain": "physics.stackexchange",
"id": 75196,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "forces, classical-mechanics",
"url": null
} |
python, beginner, pygame, fractals
Then the algae example becomes:
evaluate_lsystem(A, {A: [A, B], B: [A]}, 4)
In the snowflake example, there is persistent shared state (the position and heading of the turtle). When you have persistent shared state it makes sense to define a class, something like this:
class Turtle:
"""A drawing context with a position and a heading."""
angle = 0
x = 0
y = WINDOW_SIZE[1]*3/4
def forward(self, distance):
"""Move forward by distance."""
start = [self.x, self.y]
self.x += distance * cos(self.angle)
self.y += distance * sin(self.angle)
end = [self.x, self.y ]
pygame.draw.line(window, LINE_COLOR, start, end, LINE_WIDTH)
def turn(self, angle):
"""Turn left by angle."""
self.angle += angle
and then:
turtle = Turtle()
forward = lambda: turtle.forward(1)
left = lambda: turtle.turn(pi/3)
right = lambda: turtle.turn(-pi/3)
initial = lambda: None
rules = {
initial: [forward, right, right, forward, right, right, forward],
forward: [forward, left, forward, right, right, forward, left, forward],
}
evaluate_lsystem(initial, rules, 5) | {
"domain": "codereview.stackexchange",
"id": 20186,
"lm_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, pygame, fractals",
"url": null
} |
c#, performance, animation, xna, monogame
public bool Enabled
{
get { return enabled_; }
}
public Vector2 EmitterLocation
{
get { return emitter_location_; }
set
{
enabled_ = true;
emitter_location_ = value;
}
}
private Particle GenerateNewParticle()
{
Texture2D texture = active_textures_[random_.Next(active_textures_.Count)];
Vector2 position = emitter_location_;
Vector2 velocity = new Vector2(
(float)(random_.NextDouble() * spread_factor_),
(float)(random_.NextDouble() * spread_factor_));
float angle = 0;
float angularVelocity = (float)(random_.NextDouble() * 5);
Color color = list_of_colors_[random_.Next(list_of_colors_.Count())];
float size = (float)random_.NextDouble();
int ttl = 15 + random_.Next(30);
return new Particle(texture, position, velocity, angle, angularVelocity, color, size, ttl);
}
public void StopEmitting()
{
LinkedListNode<Particle> p = particles_.Last;
while (p != null)
{
fading_particles_.AddLast(p.Value);
particles_.RemoveLast();
p = p.Previous;
}
enabled_ = false;
}
public void Update(GameTime gameTime)
{
if (enabled_)
{
for (int i = 0; i < density_; i++)
{
particles_.AddLast(GenerateNewParticle());
}
}
LinkedListNode<Particle> p = particles_.Last;
while (p != null)
{
LinkedListNode<Particle> p_prev = p.Previous;
Particle particle = p.Value;
particle.Update(gameTime);
if (particle.TTL <= 0)
{
fading_particles_.AddLast(particle);
particles_.Remove(p);
}
p = p_prev;
} | {
"domain": "codereview.stackexchange",
"id": 7615,
"lm_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, animation, xna, monogame",
"url": null
} |
square radian.The abbreviation for steradian is the three-dimensional equivalent of the angle!, which is not a plane international system of units two different circles, not on a?! Can I obtain the size of the two-dimensional angle arcminutes would be can... Covers a complete sphere, which is not a plane > Antenna & Wave Propagation Q. 4 pi steradians of solid angle system of units: a sphere by definition ) 4 steradians celestial covers. Square radians ( steradians ) its area is simply 4π out ll those digits to a?. To the geometry, how many steradians account for circumference of a sphere with radius of 1 ca... Few discussions of solid angle of one steradian entire sphere has a 1 meter radius is comprised of between... A circumference of a unit sphere with radius of 1 covers 41253 square degrees this becomes 41,253 or in degrees. 2Πr and when we divide by r, we get 2π radians likewise, a is... Others have noted we ’ re dealing with the celestial sphere covers 41253 square this... Sphere 's center is raised a plane equivalent of the spherical object in steradians if I the... Volume and surface area of 2.5 square arcminutes would be how can obtain! Apply degrees to a sphere square miles circles, not on a sphere I think you looking... Sphere: a sphere plotted on the definition of steradians is 4π 4π in! The notion of a sphere says above ( I refuse to type out those. | {
"domain": "shukunegi.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9793540656452214,
"lm_q1q2_score": 0.8182341908183411,
"lm_q2_score": 0.8354835289107309,
"openwebmath_perplexity": 1875.7777519416447,
"openwebmath_score": 0.7406566739082336,
"tags": null,
"url": "http://shukunegi.com/georgia-hall-jwyd/page.php?341f42=st-paul-school-agra-admission-2020-21"
} |
1. If $k$ is even, say $k=2\ell$, then the monomial $f(x)=x^{2^\ell+1}$ works. This is because this polynomial is the relative norm map $N:\mathbb{F}_{2^k}\rightarrow\mathbb{F}_{2^\ell}$. We also see directly that $f(x)\in \mathbb{F}_{2^\ell}$ for all $x\in \mathbb{F}_{2^k}$ from the calculation $$f(x)^{2^\ell}=x^{2^\ell(2^\ell+1)}=x^{2^{2\ell}+2^\ell}=x^{2^k}\cdot x^{2^\ell}= x\cdot x^{2^\ell}=f(x),$$ and the claim follows because this intermediate field consists precisely of the solutions of $y^{2^\ell}=y$. Using this identity we also get the claim as $$tr(f(x))=\sum_{i=0}^{2\ell}f(x)^{2^i}=\sum_{i=0}^{\ell}(f(x)^{2^i}+f(x)^{2^{i+\ell}}) =\sum_{i=0}^{\ell}(f(x)+f(x)^{2^\ell})^{2^i}=\sum_{i=0}^\ell0=0.$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9770226287518852,
"lm_q1q2_score": 0.8284836846333584,
"lm_q2_score": 0.8479677545357568,
"openwebmath_perplexity": 219.45359484144095,
"openwebmath_score": 0.9578136205673218,
"tags": null,
"url": "http://math.stackexchange.com/questions/167802/polynomial-over-characteristic-two-finite-field-of-odd-degree-with-certain-image"
} |
electromagnetism, electrostatics, fourier-transform, dipole, magnetostatics
$$
(This can be shown starting from the Taylor expansion of $|\mathbf{r} - \mathbf{r}'|^{-1}$ about $\mathbf{r}$; see Zangwill §4.1.1 for the details.) From this, it follows that
$$
\phi(\mathbf{r}) = (-i)^n Q_{i_1 \dots i_n} k_{i_1} \dots k_{i_n} \tilde{\phi}_\text{mono}(\mathbf{k}).
$$
Note that the "primitive" multipole tensors are not the same as you might find in other contexts; for example, $Q_{ij}$ as defined above is not trace-free.
Similarly, the vector potential's Fourier transform can be found by noting that $\mathbf{A}_\text{dip} = (\mathbf{\mu} \times \nabla) \phi_\text{mono}(\mathbf{r})$, with the result that
$$
\tilde{\mathbf{A}}_\text{dip} = i (\pmb{\mu} \times \mathbf{k}) \tilde{\phi}_\text{mono}(\mathbf{k})
$$
I don't think that there's an intuitive physical reason that this is true like there is for the electric dipole. Mathematically, it stems from the fact that $\phi_\text{mono}(\mathbf{r})$ is (proportional to) the Green's function for the Laplacian operator, and you have both $\nabla^2 \phi \propto \rho$ and $\nabla^2 \mathbf{A} \propto \mathbf{J}$. Zangwill has the gory details for the higher-order magnetic moments as well; see §11.4.1 of that book for those. | {
"domain": "physics.stackexchange",
"id": 68203,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "electromagnetism, electrostatics, fourier-transform, dipole, magnetostatics",
"url": null
} |
Simulate repeated rolls of a 7-sided die with a 6-sided die
What is the most efficient way to simulate a 7-sided die with a 6-sided die? I've put some thought into it but I'm not sure I get somewhere specifically.
To create a 7-sided die we can use a rejection technique. 3-bits give uniform 1-8 and we need uniform 1-7 which means that we have to reject 1/8 i.e. 12.5% rejection probability.
To create $n * 7$-sided die rolls we need $\lceil log_2( 7^n ) \rceil$ bits. This means that our rejection probability is $p_r(n)=1-\frac{7^n}{2^{\lceil log_2( 7^n ) \rceil}}$.
It turns out that the rejection probability varies wildly but for $n=26$ we get $p_r(26) = 1 - \frac{7^{26}}{2^{\lceil log_2(7^{26}) \rceil}} = 1-\frac{7^{26}}{2^{73}} \approx 0.6\%$ rejection probability which is quite good. This means that we can generate with good odds 26 7-die rolls out of 73 bits.
Similarly, if we throw a fair die $n$ times we get number from $0...(6^n-1)$ which gives us $\lfloor log_2(6^{n}) \rfloor$ bits by rejecting everything which is above $2^{\lfloor log_2(6^{n}) \rfloor}$. Consequently the rejection probability is $p_r(n)=1-\frac{2^{\lfloor log_2( 6^{n} ) \rfloor}}{6^n}$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9796676514063881,
"lm_q1q2_score": 0.8184961945828259,
"lm_q2_score": 0.8354835371034368,
"openwebmath_perplexity": 1289.6711281389273,
"openwebmath_score": 0.8984300494194031,
"tags": null,
"url": "http://math.stackexchange.com/questions/901222/simulate-repeated-rolls-of-a-7-sided-die-with-a-6-sided-die"
} |
By comparison test we have $$\frac{n^{3/2}(\log (n))^2}{n^2}= \frac{(\log (n))^2}{n^{1/2}} =\left(\frac{\log (n)}{n^{1/4}}\right)^2=\left(4\frac{\log (n^{1/4})}{n^{1/4}}\right)^2\to 0$$ that is for n large enough we have
$$\frac{(\log (n))^2}{n^2}<\frac{1}{n^{3/2}}$$
the convergence follow by Riemann series. see more general here On convergence of Bertrand series $\sum\limits_{n=2}^{\infty} \frac{1}{n^{\alpha}\ln^{\beta}(n)}$ where $\alpha, \beta \in \mathbb{R}$
• The down voter here have serious mind trouble – Guy Fsone Feb 10 '18 at 10:53
• I agree. Their behaviour disgusts me. +1 to compensate – user370967 Feb 10 '18 at 11:38
• @Math_QED I am totally surprise how did someone just vote this like. I decided to pôst this answer because of the serious lengthy comment this post. – Guy Fsone Feb 10 '18 at 11:47
• @math.stackexchange.com/q/2643893 i am facing similar trouble here. – Guy Fsone Feb 10 '18 at 11:49
As a side note, since all the convergence tests have been sufficiently laid out, your series is the second derivative of the Riemann zeta function:
$$\zeta(s)=\sum_{n=1}^\infty\frac1{n^s}$$
$$\zeta'(s)=\sum_{n=1}^\infty\frac{-\ln(n)}{n^s}$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9822877051854724,
"lm_q1q2_score": 0.8164215971616052,
"lm_q2_score": 0.8311430478583168,
"openwebmath_perplexity": 714.2318559553147,
"openwebmath_score": 0.8303858041763306,
"tags": null,
"url": "https://math.stackexchange.com/questions/1793655/how-to-prove-that-sum-n-1-infty-frac-log-n2n2-converges"
} |
# $\epsilon - N$ proof of $\sqrt{4n^2+n} - 2n \rightarrow \frac{1}{4}$
I have the following proof for $$\lim_{n\rightarrow\infty} \sqrt{4n^2+n} - 2n = \frac{1}{4}$$ and was wondering if it was correct. Note that $$\sqrt{4n^2+n} - 2n = \frac{n}{\sqrt{4n^2+n} + 2n}$$. $$\left|\frac{n}{\sqrt{4n^2+n} + 2n} - \frac{1}{4}\right| \\ = \left|\frac{2n - \sqrt{4n^2+n}}{4(\sqrt{4n^2+n} + 2n)}\right|=\left|\frac{\sqrt{4n^2+n} - 2n}{4(\sqrt{4n^2+n} + 2n)}\right|\\ = \left|\frac{n}{4(\sqrt{4n^2+n} + 2n)^2}\right| \leq \left|\frac{n}{4(4n)^2}\right| = \left|\frac{n}{64n^2}\right| \\ = \left|\frac{1}{64n}\right| < \epsilon \\ \implies n>\frac{1}{64\epsilon}$$
• Seems quite right, though the final implication must be in the other direction.
– user65203
Aug 6, 2019 at 13:30
• It's wrong, for the reason Yves gave. Aug 6, 2019 at 13:34
• Did you finish this problem @user100000001? Sep 20, 2020 at 18:48 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9905874115238967,
"lm_q1q2_score": 0.8920534751195758,
"lm_q2_score": 0.9005297914570319,
"openwebmath_perplexity": 268.4520331385752,
"openwebmath_score": 0.8707136511802673,
"tags": null,
"url": "https://math.stackexchange.com/questions/3315160/epsilon-n-proof-of-sqrt4n2n-2n-rightarrow-frac14"
} |
lo.logic, turing-machines, program-verification
Title: Program transformation using partial functions which preserve partial correctness Much work has been done demonstrating that certain program transformations preserve particular properties. That is, for any program $P$ which has property $\alpha$, show that $P$ transformed under transformation $T$ still has property $\alpha$.
I'm interested in a transformation which replaces every usage of function $f$ in $P$ with partial function $g$, where $g$ is a restriction of $f$ (meaning that $g(x) = y \implies f(x) = y$). It seems intuitively obvious that this transformation, while not necessarily preserving totatlity, preserves partial correctness. Yet I cannot find a standard proof or reference on this or even mention of this seemingly elemental fact.
Can anyone help me out? A reference, a proof, a different formalism? I imagine that you can prove this straight from the operational
semantics using the standard operational precongruence (assuming that
you have a sequential language). Some of the relevant techniques
have been collected in Operationally-based theories of program equivalence by
Andy Pitts.
If you have a Hoare logic of partial correctness for the language you are interested
in, you can probably
establish a meta-theorem to the effect that for all programs $M$, all
models $\xi, \xi'$ such that $\xi$ is less defined than $\xi'$, and
all formulae $A, B$, we have
$\xi \models \{A\} M \{B\}$ implies $\xi' \models\{A\} M \{B\}$. Proving such
a meta-theorem typically boils down to the operational reasoning
mentioned above.
Such questions come up all the time in proving observational and
descriptive completeness of Hoare logics. As Neel points out in
an answer to your other question, domain theory is based upon
related ideas. | {
"domain": "cstheory.stackexchange",
"id": 2284,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "lo.logic, turing-machines, program-verification",
"url": null
} |
electric-circuits, electricity, electric-current
Title: AC Current and Forward Movement Okay - maybe not the most advanced question, but one I have not seen a satisfactory answer to.
DC current is easy to understand. The current and electronics flow unidirectional, and you can understand how by connecting a circuit, a flow goes from the source to the recipient end of the circuit, and by passing through some form of resistance (say a filament on a light bulb), generates heat.
As for AC current, I get it. Once the circuit is on, the electrons pass back & forth. I understand that concept. What I do not understand is how the circuit ever gets created in the first place. Bear with me:
If ultimately, the current is flowing back and forth, how does it ever move forward from the source to the end-point of the circuit in the first place? I have heard of a golf-ball in a pipe analogy to explain how an AC circuit works... but what no one explains is how the current flows when first putting all the golf balls into the pipe in the first place (as an analogy).
Are the electrons already there (i.e. - a component of the material over which current flows)... but even then, if the current oscillates back-and-forth, how does it ever move forward to create a circuit?
The only analogy I thought of that might explain this is that the current itself (the flow of electricity) moves unidirectional, but the electrons oscillate. So an analogy in that case might be that the current is a river, while the electrons are fish swimming back and forth?
Apologies in advance for such a naive question, but this I have never been able to get a sufficient explanation for this. When an AC circuit is closed, the electric field moves through the wire at practically the speed of light. Since wires are conductors, there is approximately 1 free electron per atom of the conductor (usually copper), so there are always an ENORMOUS number of free electrons available to be accelerated by that electric field. The drift speed of each electron is very slow, even under the influence of the alternating electric field in an AC circuit, so the electrons are "sloshing" back and forth through a very small distance about a fixed point in the wire. | {
"domain": "physics.stackexchange",
"id": 52505,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "electric-circuits, electricity, electric-current",
"url": null
} |
phylogenetics, bash, data-download, gff3
Title: How to wget a gff from NCBI database? Say I want to use wget to download a gff file for the X chromosome of release 5.57 of the Drosophila melanogaster genome. The NCBI page with the gff file for just this is here.
However, I do not see any way to directly wget the gff from this page. What I can do is click "Send to" at the top, select File, and change the Format dropdown to GFF3, and finally click 'Create File', and the gff file downloads onto my computer.
But then I lose the ability to use the -a flag to log the download details, I can't download the gff using wget from a remote server directly but instead I need to download it locally and then upload it, etc. Is there any way to use wget to download gff files from NCBI programmatically instead of having to download it manually from the website? my suggestion would be to go via the assembly page.
For your example link, I would
Click the link to the BioProject: PRJNA164
On the right side, under "Related information" choose the assembly
On the assembly page, under "Access the data" on the right side, I would choose "FTP directory for RefSeq assembly"
Once in the RefSeq folder, copy the link to the *_genomic.gff.gz and use wget.
wget https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/001/215/GCF_000001215.4_Release_6_plus_ISO1_MT/GCF_000001215.4_Release_6_plus_ISO1_MT_genomic.gff.gz
Edit: The initial question requested an older versions, which can be found in RefSeq's archive of prior releases. For this specific Drosophila assembly chromosome X, the version 5 can be found at https://ftp.ncbi.nlm.nih.gov/genomes/archive/old_refseq/Drosophila_melanogaster/RELEASE_5/CHR_X/NC_004354.gff | {
"domain": "bioinformatics.stackexchange",
"id": 2309,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "phylogenetics, bash, data-download, gff3",
"url": null
} |
python, game, python-3.x, simon-says
I also find that the tinted colors are too close to the idle ones (except for green). You should use colors that are more distinct so the player can better see which one is next in the sequence.
Lastly, I feel that running self.master.mainloop() or even having the root created outside the class does not allow for much customization, I would keep things internal and provide a method to launch the game (that will run self.master.mainloop().
Proposed improvements
import tkinter as tk
import random
from functools import partial | {
"domain": "codereview.stackexchange",
"id": 21213,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, game, python-3.x, simon-says",
"url": null
} |
react.js, game-of-life, jsx, cellular-automata
if (originalArray[i][j]){
if(amountOfNeighbours < 2 || amountOfNeighbours > 3){
arrayToPass[i][j] = false;
}else{
arrayToPass[i][j] = true;
}
}else{
if(amountOfNeighbours === 3){
arrayToPass[i][j] = true;
}
}
}
}
console.timeEnd('forloopz');
this.setState({
fullGrid: arrayToPass,
});
}
onIntervalChange = (ev) => {
this.intervalTime = ev.target.value;
this.autoPlay();
}
render() {
return (
<div>
<button onClick={this.play}>Play</button>
<button onClick={this.autoPlay}>AutoPlay</button>
<button onClick={this.stop}>Stop AutoPlay</button>
<IntervalSlider intervalTime={this.state.intervalTime} change={this.onIntervalChange}/>
{this.state.fullGrid.map((element, ind) => {
return(
<div key={ind}>
{element.map((el, i) => {
let boxClass = el ? 'checked' : 'unchecked';
let boxID = i + '_' + ind;
return <Box id={boxID} key={boxID} className={boxClass} x={ind} y={i} onClick={this.clickHandler}/>
})}
</div>
)
})}
</div>
)
}
}
ReactDOM.render(<App />, document.getElementById('root')); | {
"domain": "codereview.stackexchange",
"id": 31167,
"lm_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, game-of-life, jsx, cellular-automata",
"url": null
} |
special-relativity, spacetime, coordinate-systems, differentiation
In Relativity, however, the absolute speed is finite and non-zero. There's only room for one speed to be absolute (lest they all be absolute), so infinity must give way. Therefore, under a change to a moving frame, infinite speed may transform to a fast but finite speed.
To best understand this, you should step back for a broader perspective.
Space-Time Geometries, Classified By Which Speed Is The Absolute Speed
Consider the different ways of combining spatial geometry with time into a single chrono-geometry for "space-time" that leaves the following invariant:
$$β dt^2 - α dx^2, \hspace 1em dt \frac{∂}{∂t} + dx \frac{∂}{∂x}, \hspace 1em β \left(\frac{∂}{∂x}\right)^2 - α \left(\frac{∂}{∂t}\right)^2,$$
for different settings of the parameters $α$ and $β$. We'll confine our attention to combining the time dimension $t$ with just one spatial dimension $x$, because that's all we'll need in most of what follows.
In the cases where $αβ ≥ 0$, this gives us a geometry with an absolute speed. We can write it as a quantity in units of length per unit time $ᴄ = \sqrt{β/α}$, or as a quantity rendered in marathoner's units of time per unit length $ᴐ = \sqrt{α/β}$. Included in this are the cases $ᴄ = ∞$ (or $ᴐ = 0$), when $α = 0$ and $β ≠ 0$, where the absolute speed is infinite; and $ᴄ = 0$ (or $ᴐ = ∞$), when $α ≠ 0$ and $β = 0$ where the absolute speed is zero. Otherwise, $αβ > 0$ and the absolute speed is both finite and non-zero and is what is otherwise known as "(in vacuum) light speed". | {
"domain": "physics.stackexchange",
"id": 97177,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "special-relativity, spacetime, coordinate-systems, differentiation",
"url": null
} |
organic-chemistry, reaction-mechanism, hydrocarbons, c-c-addition
Title: Why do more substituted alkenes undergo epoxidation, but the less substituted alkenes undergo hydrogenation? We know that, in case of a choice, catalytic hydrogenation will hydrogenate the less substituted alkene, because the less substituted alkene is less stable. But, we also know that, in case of a choice, peroxyacids perform epoxidation of the more substituted alkenes, because the latter are more electron-rich (i.e. more nucleophilic) (details)
In one case, we are favoring the stability of the pi bond. But in another case, we are prioritizing the nucleophilicity of the pi bond. Why is this so?
I believe this definitely has something to do with their respective mechanisms, which I've studied from Libretexts (hydrogenation and epoxidation). The only difference I see is that in hydrogenation, the pi bond first attaches to the catalyst surface, and then a hydrogen atom (already attached to that surface) is transferred to the pi bond. But, in epoxidation, the alkene directly attacks the electrophilic $\ce{-OH}$ group of the peroxy acid. So, this explains the need for more nucleophilicity in the latter case, but how does this explain the need for less stability in the former case? Or is this direction of reasoning entirely wrong? As you already know, the alkene has to approach the catalyst surface in the first step. For optimum adsorption, the molecule must be able to orient itself parallel to the surface of the metal. Less number of substituents promote this.
The activated hydrogen is in the form of $\ce{Pt-H}$ or $\ce{Pd-H}$ bonds on the surface of metal particles, and hindered alkenes can't approach the $\ce{M-H}$ bonds easily.
Source
Epoxidation on the other hand is free from any such need for to attach to the surface. So we simply consider nucleophilicity. | {
"domain": "chemistry.stackexchange",
"id": 9811,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "organic-chemistry, reaction-mechanism, hydrocarbons, c-c-addition",
"url": null
} |
20
Stirling's approximation for $n!$ states for some constants $c_1,c_2$ $c_1 n^{n+\frac{1}{2}}e^{-n} \leq n! \leq c_2 n^{n+\frac{1}{2}}e^{-n}.$ What are the tightest asymptotic bounds that can be placed on $n!$ $?$ $n! = \Omega(n^n) \text{ and } n! = \mathcal{O}(n^{n+\frac{1}{2}})$ ... $n! =\Theta((\frac{n}{e})^{n+\frac{1}{2}})$ $n! =\Theta(n^{n+\frac{1}{2}}2^{-n})$
21
Given the following pseudocode for function $\text{printx()}$ below, how many times is $x$ printed if we execute $\text{printx(5)}?$ void printx(int n) { if(n==0){ printf(“x”); } for(int i=0;i<=n-1;++i){ printx(n-1); } } $625$ $256$ $120$ $24$ $5$
22
A formula is said to be a $3$-CF-formula if it is a conjunction (i.e., an AND) of clauses, and each clause has at most $3$ literals. Analogously, a formula is said to be a $3$-DF-formula if it is a disjunction (i.e., an OR) of clauses of at most $3$ literals each. Define the ... $\text{3-DF-SAT}$ is NP-complete Neither $\text{3-CF-SAT}$ nor $\text{3-DF-SAT}$ are in P
23 | {
"domain": "gateoverflow.in",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9873750510899382,
"lm_q1q2_score": 0.8206499114070428,
"lm_q2_score": 0.8311430499496096,
"openwebmath_perplexity": 212.37273834772608,
"openwebmath_score": 0.6895525455474854,
"tags": null,
"url": "https://gateoverflow.in/tag/tifr2019"
} |
computability, turing-machines, undecidability
Title: Decidability of Turing Machines with input of fixed length I'm learning about undecidability, and found this question:
Is this language decidable, make a proof:
L = { M : machine M halts for every input of length not exceeding 100 }
Update: This is translated from an exam paper some years ago, and I'm quite sure it means that machine M should halt for every input with length from 0 to 100, and that it is no constraints on the tape size.
Update2: The solution given below, and hence the origin of this post, is for an variant of this question with fixed number of steps and input. Sorry for the confusion.
I came to the conclusion that this is an undecidable language.
My logic is as follows: Lets say for the sake of contradiction that it is possible to construct a machine $M_R$, that takes as input an arbitrary input $(M,x)$, and reduces this to $M'$. $M'$ has the property so that $(M,x) \in M_{HALT}$ iff $M' \in L$, this means that $M$ halts on all $x$ of input with maximum length of 100.
Then run $M$ on $x$, if it halts then accept.
And shows that $M_R$ decides the halting problem, and in hence a contradiction and proves that his is not decidable.
But in the solution it is written that this question is decidable: | {
"domain": "cs.stackexchange",
"id": 2138,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "computability, turing-machines, undecidability",
"url": null
} |
electromagnetism, magnetic-fields, frequency, resonance
The interesting thing in this case is that 15 Hz is right in the middle of that awkward frequency range which is too fast to count, but too low to hear.
So how do you measure a frequency in this awkward range? If you have some simple lab equipment it becomes easy. For example, just shine a light on a photodiode and arrange it so that the edge of the vibrating object gets in the light path and casts a shadow. Then look at the photodiode signal on an oscilloscope and you'll see the vibrations at 15 Hz. (Interestingly, an ordinary TV camera would be a bad choice here because they take about 30 discrete frames a second, so 15 Hz is right around the Nyquist frequency and aliasing would make it impossible to tell if it were 13 Hz or 17 Hz, for example.)
But what if you don't have an oscilloscope, or video camera or anything like that? I think you would still be able to measure the resonance frequency by hand, you'd just have to be inventive. For example, you can try to excite the vibrations using subharmonics. If you give your string of magnets a sudden shove 3 times a second, for example, then your 3 Hz excitation signal has harmonics at 6 Hz, 9 Hz, 12 Hz, 15 Hz..., because it's not sinusoidal. So if you're able to show that you get a strong resonance at 3 Hz, but not at 2.9 Hz or 3.1 Hz, then you know that the resonant frequency is one of those harmonics. If you repeat that process with some different subharmonic (e.g. 5 Hz), then you can quickly narrow down the possibilities for the resonant frequency. | {
"domain": "physics.stackexchange",
"id": 608,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "electromagnetism, magnetic-fields, frequency, resonance",
"url": null
} |
java
I'd use:
statKeyPricingMap.keySet().stream()
.map(statKey -> {
BookPriceStats bookingPriceStat = new BookPriceStats();
bookingPriceStat.setBookStatKey(statKey);
bookingPriceStat.setPrices(statKeyPricingMap.get(statKey));
})
.collect(Collector.toList());
Algorithm
Regarding the algorithm, and if we do not change the business objects' model, the way I'd go about it is:
First, have either extract the logic to create a StatKey to another method, or to the StatKey itself, to remove logic from getBookPriceStats.
As a rule of thumb, if you are using a lambda with multiple expressions inside it, you are doing something wrong. It would probably be more readable to extract logic to another method.
Also, I'd use a map as such:
Map<Long, Set<Price>> bookIdToPricesMap
So that you just iterate over the whole prices set once.
Then, just by iterating over the books set, you already have all the information you need to create the list of BookPriceStats. | {
"domain": "codereview.stackexchange",
"id": 41814,
"lm_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
} |
python, python-3.x, object-oriented, web-scraping
from bs4 import BeautifulSoup
from bs4.element import SoupStrainer, Tag
from requests import Session
BASE_URL = 'https://www.nature.com'
SEARCH_STRAINER = SoupStrainer('ul', class_='app-article-list-row')
ARTICLE_STRAINER = SoupStrainer('div', id='Abs1-content')
class Article(NamedTuple):
title: str
authors: tuple[str, ...]
article_type: str
date: date
url: str
description: Optional[str]
@classmethod
def from_tag(cls, tag: Tag) -> 'Article':
anchor = tag.find('a', class_='c-card__link')
authors = tuple(
span.text
for span in tag.find('span', itemprop='name')
)
article_type = tag.find('span', class_='c-meta__type').text
article_date = date.fromisoformat(
tag.find('time')['datetime']
)
description = tag.find('div', itemprop='description')
return cls(
title=anchor.text,
url=urljoin(BASE_URL, anchor['href']),
authors=authors,
article_type=article_type,
date=article_date,
description=description and description.text.strip(),
)
@property
def id(self) -> str:
return self.url.rsplit('/', 1)[1]
def get_abstract(session: Session, url: str) -> str:
with session.get(
url=url,
headers={'Accept': 'text/html'},
) as resp:
resp.raise_for_status()
html = resp.text
doc = BeautifulSoup(markup=html, features='html.parser', parse_only=ARTICLE_STRAINER)
return doc.text | {
"domain": "codereview.stackexchange",
"id": 42900,
"lm_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, object-oriented, web-scraping",
"url": null
} |
javascript, jquery
Title: Creating lists and sublists dynamically I'm working on a simple little one page website for giving a presentation and I have some working code now, but I'm thinking there has to be a more elegant way of doing this. I would describe myself, at best, as a "dabbler" in JavaScript at this point; I'm much more comfortable with statically-typed languages and am doing this as a learning exercise.
Here's my JSFiddle showing what I am doing.
In my "real" site, the PageContent object is coming from an AJAX POST response (via an instance of node.js). I've included all of that code to make it easier to understand what is going on (any suggestions on how to restructure that server-side code would also be appreciated). If I have the time, I'll probably read these "points" from a config file or something else, but for now, a switch statement fits my needs.
The segment of this that makes me the most uneasy is this:
$('#pageContent').append('<li id="' + i + '">' + mp.main);
if (mp.subPoints.length > 0){
$('li#'+i).append('<ul>');
$.each(mp.subPoints, function(index, sp){
$('li#'+i+' ul').append('<li>' + sp + '</li>');
});
$('li#'+i).append('</ul>');
}
$('#pageContent').append('</li>'); | {
"domain": "codereview.stackexchange",
"id": 4950,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "javascript, jquery",
"url": null
} |
navigation, rviz, turtlebot2, turtlebot, kobuki
Title: What coordinate frame does rviz set the 2D Nav Goal in?
Hello,
I've got a Turtlebot 2 in ROS Groovy, and I've been learning about navigation. One thing that confuses me is what happens internally in rviz when I press the "2D Nav Goal" button after running roslaunch turtlebot_rviz_launchers view_navigation.launch as done in the tutorial at:
http://ros.org/wiki/turtlebot_navigation/Tutorials/Autonomously%20navigate%20in%20a%20known%20map
I know that it sends a goal to the navfn component in the move_base node (I think), but my question is, what reference is it using when I click the screen? IE, if I click on an X,Y point on the screen, what is it passing to move_base? Am I telling the robot to move some distance relative to its base_link? Or am I sending it to a fixed point on its local or global costmap?
Thanks in advance!
Originally posted by BlitherPants on ROS Answers with karma: 504 on 2013-07-25
Post score: 2
Hi.
In RVIZ you can choose the "fixed frame", it's always the first item in the display list. The goal, initial pose or any other message will be send in the frame that you have selected there. By default it is /map.
Regards,
Originally posted by Mario Garzon with karma: 802 on 2013-07-26
This answer was ACCEPTED on the original site
Post score: 2
Original comments
Comment by BlitherPants on 2013-07-26:
So if I understand correctly, what gets sent to move_base is an X,Y destination relative to the global costmap?
Comment by Mario Garzon on 2013-08-08:
Well it is actually an full 3D pose (position and orientation) with respect to the /map reference frame. | {
"domain": "robotics.stackexchange",
"id": 15050,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "navigation, rviz, turtlebot2, turtlebot, kobuki",
"url": null
} |
# Newton's cradle problem
1. Aug 11, 2014
### Dinheiro
1. The problem statement, all variables and given/known data
An executive toy consists of three suspended steel balls of masses M, n and m arranged in order with their centres in a horizontal line. The ball of mass M is drawn aside in their common plane until its centre has been raised by h and is then released. if M ≠ m and all collisions are elastic, how must n be chosen so that the ball of mass m rises to the gratest possible height? What is that height? (Neglect multiple collisions)
2. Relevant equations
velocity after a perfectly elastic collision
v2' = (m2 - m1)v2/(m1+m2) + 2m1v1/(m1+m2)
3. The attempt at a solution
After releasing M, its vellocity immediately before the first collision is
$V = \sqrt{2gh}$
Then, M collides with n, and n's velocity immediately after collision is
$v = \frac{2M}{M+n}\sqrt{2gh}$
Analogously, m's velocity immediately after n colides
$u = \frac{2n}{n+m}\frac{2M}{M+n}\sqrt{2gh}$
m shall rises H
$mu^{2}/2 = mgH$
$H = 16h\frac{M^{2}n^{2}}{(M+n)^{2}(m+n)^{2}}$
How am I supposed to maximize H from it? What should be done to solve it?
Last edited: Aug 11, 2014
2. Aug 11, 2014
### TSny
Looks good so far. You have found H as a function of n. Are you familiar with using calculus to find the maximum of a function?
3. Aug 12, 2014
### Dinheiro | {
"domain": "physicsforums.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9805806523850543,
"lm_q1q2_score": 0.821353924133932,
"lm_q2_score": 0.8376199572530448,
"openwebmath_perplexity": 1467.1420356515462,
"openwebmath_score": 0.7059246301651001,
"tags": null,
"url": "https://www.physicsforums.com/threads/newtons-cradle-problem.765625/"
} |
console, file-system, linux, shell, fish-shell
function umount_all
set blocks (lsblk -l -o PKNAME,PATH,MOUNTPOINT | grep "^$argv[1] ")
for block_ in $blocks
set block (echo "$block_" | grep -Po "/[^ ]+")
if set -q block[2]
sudo umount "$block[1]"
end
end
end
function load_passwords
set mounts (pdev $argv[1])
if test $status != 0
return 1
end
set drive (lsblk -o NAME,PATH | grep "^$mounts[2] " | grep -Po "/[^ ]+")
echo "PATH : $mounts[3]" | grep "$drive"
echo "MOUNT: $mounts[4]"
pmount $argv[1] $argv[2] $mounts[3] $mounts[4]
if test $status != 0
return 1
end
keepass &
read -P "Eject drive? [Y/n] " -l input
echo "$input" | grep -Poi "(^\$)|(^y)" >> /dev/null
if test $status = 1
return
end
umount_all "$mounts[2]"
udisksctl power-off -b $drive
lsblk -o UUID | grep "^$argv[1]\$" >> /dev/null
if test $status = 1
return
end
echo "Failed to power off drive"
return 1
end
function passwords
load_passwords {redacted} /path/to/mountpoint
end
Concerns
If not a fan of using a for loop to echo each value in a list to 'return' a list.
Is there a cleaner way to do this?
for mount in $mounts
echo $mount
end
I'm not a fan of names like $argv[1] rather than $uuid as they make the code harder to understand. Is there a clean way to specify these?
The code feels unreadable, it's why I've written such a thorough description here.
I can see myself forgetting all this nuance and coming back to this in a year and go, which idiot wrote this?! | {
"domain": "codereview.stackexchange",
"id": 38701,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "console, file-system, linux, shell, fish-shell",
"url": null
} |
javascript, array, google-apps-script, google-sheets
{'base':'Q', 'letters':'\u0051\u24C6\uFF31\uA756\uA758\u024A'},
{'base':'R', 'letters':'\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782'},
{'base':'S', 'letters':'\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784'},
{'base':'T', 'letters':'\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786'},
{'base':'Thor','letters':'\u00DE'},
{'base':'TZ','letters':'\uA728'}, | {
"domain": "codereview.stackexchange",
"id": 43514,
"lm_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, array, google-apps-script, google-sheets",
"url": null
} |
c, stack
Just declare (and rename the fields) as
typedef struct stack {
int* storage_array;
size_t size;
size_t capacity;
} stack;
That way, you don't have to write always struct stack* st; stack* st will do nicely.
Since pop, push, etc., belong to the stack, I suggest you add the stack_ prefix to all the relevant stack operations: stack_pop, stack_push, etc. This is in order to avoid possible name clashes in projects where a programmer wants to use, say, priority queue functions that have similar names.
Advice 3
I suggest you arrange your stack as a header file with all the function declarations, and an implementation file including the header file and providing the function definitions.
Advice 4
You can easily extend your design to resize the storage array in order to allow (virtually) any number of int elements in your stack: on push, if the storage array is already filled, extend the storage array capacity by a factor \$q > 1\$. That way, the running time complexity of push will remain amortized \$\Theta(1)\$ regardless the fact that on full storage array you have to run the operation in \$\Theta(N)\$.
Alternative implementation
All in all, I had this in mind:
cstack.h
#ifndef COM_YOURCOMPANY_UTIL_STACK_H
#define COM_YOURCOMPANY_UTIL_STACK_H
typedef struct stack {
int* storage_array;
size_t size;
size_t capacity;
} stack;
stack* stack_creat();
void stack_push(stack*, int);
int stack_pop(stack*);
int stack_empty(stack*);
int stack_peek(stack*);
void stack_print(stack*);
#endif
cstack.c
#include "cstack.h"
#include <stdlib.h>
static const MINIMUM_STORAGE_ARRAY_CAPACITY = 4;
stack* stack_creat() {
stack* s = (stack*)malloc(sizeof(*s));
if ((s->storage_array =
calloc(MINIMUM_STORAGE_ARRAY_CAPACITY,
sizeof(int))) == NULL) { | {
"domain": "codereview.stackexchange",
"id": 43212,
"lm_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, stack",
"url": null
} |
quantum-mechanics, operators, hydrogen, orbitals, laplace-runge-lenz-vector
Finally, the relation $$\mathbf{F}^2 = 2 m H (\mathbf{L}^2 +\mathbf{1})+m^2 \alpha^2 \tag{2}\label{eq2}$$ is obtained after a somewhat lengthy calculation. | {
"domain": "physics.stackexchange",
"id": 93500,
"lm_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, operators, hydrogen, orbitals, laplace-runge-lenz-vector",
"url": null
} |
quantum-field-theory, particle-physics, quantum-electrodynamics, scattering-cross-section
Title: Why does $2\to 2$ scattering cross-section have $E_{CM}^2$ in denominator? For $2\to 2$ scattering with equal masses we have
$$\left(\frac{d\sigma}{d\Omega}\right)_{CM} = \frac{1}{64 \pi^2 E_{CM}^2} |\mathcal{M}|^2.$$
(Schwartz's QFT eq. 5.33) Can we make the general statement that total cross section increases as $E_{CM}$ decreases for scattering processes? I'm guessing not because $\mathcal{M}$ may have a complicated dependence on energy/momenta.
As an example, take the case of $e^+e^-\to \mu^+\mu^-$. With $m_e = 0$ we have
$$\frac{d\sigma}{d\Omega} = \frac{\alpha^2}{4 E_{CM}^2} \sqrt{1-m_{\mu}^2/E_{\mu}^2} \left(1+ m_{\mu}^2/E_{\mu}^2 + (1- m_{\mu}^2/E_{\mu}^2)\cos^2\theta\right)$$
in the c.o.m frame (Schwartz 13.78). Here it's pretty clear that total cross section increases as energy decreases.
But I would think that particles scatter more when they are given more energy? The limiting case of course being zero velocity $\to $ zero scattering. I would appreciate any intuition on the relation between $E_{CM}$ and total cross section.
Can we make the general statement that total cross section increases
as $E_{CM}$ decreases for scattering processes? | {
"domain": "physics.stackexchange",
"id": 44056,
"lm_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, quantum-electrodynamics, scattering-cross-section",
"url": null
} |
entanglement, textbook-and-exercises, locc-operation
$|Ψ⟩=(U⊗V)(|\alpha⟩⊗|\beta⟩)$
$= (U|\alpha⟩⊗V|\beta⟩)$
which seems to be a product state(hence a contradiction) as $U|\alpha⟩$ and $V|\beta⟩$ are vectors but I'm not sure if this is correct? For part (a), you can certainly manually construct a unitary that for which $U|\phi\rangle = |\psi\rangle$ (though there may be a more elegant proof of this fact). For example, suppose $|\phi\rangle = W|0\rangle$ for some unitary $W$ and define $U' = UW$ then we have
$$
U'|0\rangle = |\psi\rangle \tag{1}
$$
This means that $U'$ can be any unitary whose first column is $|\psi\rangle$. You can always find one such unitary by completing the remaining columns of $U'$ using a Gram-Schmidt procedure.
For part (b), this can be shown using the Schmidt decomposition: Given a bipartite $|\Psi\rangle$ defined over two $d$-dimensional systems, you can always write
$$
|\Psi\rangle = \sum_{i=1}^d c_i |u_i\rangle \otimes |v_i\rangle \tag{2}
$$
where $\{|u_i\rangle\}_{i=1}^d$ and $\{|v_i\rangle\}_{i=1}^d$ are orthonormal sets. A separable state can only have one term in this sum ("Schmidt rank 1"), e.g.
$$
|\Psi_{sep}\rangle = |\alpha\rangle \otimes |\beta \rangle \tag{3}
$$
while entangled states are defined as those which have more than one term, e.g.
$$ | {
"domain": "quantumcomputing.stackexchange",
"id": 3755,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "entanglement, textbook-and-exercises, locc-operation",
"url": null
} |
quantum-mechanics, quantum-field-theory, weak-interaction, cp-violation
It was naturally to identify $K_{1}$ with short-lived specie $K_{S}$ of kaons and $K_{2}$ with long-lived $K_{L}$. This identification means that we state that the full hamiltonian which describes meson interaction is $CP$-invariant, so eigenstates of hamiltonian are CP-odd or CP-even. However, it was experimentally shown that process $K_{L} \to 2 \pi$ exist, which shows that there is CP violation mixing of $K_{1,2}$:
$$
K_{S} = \frac{K_{1}+\epsilon K_{2}}{\sqrt{1 + |\epsilon|^{2}}}, \quad K_{L} = \frac{K_{2} + \epsilon K_{1}}{\sqrt{1 + |\epsilon|^{2}}}
$$
The reason of such mixing is presence of nondiagonal elements in mass matrix for $K^{0}, \bar{K}^{0}$. These nondiagonal elements violate CP symmetry, but undirectly: we only have that physical states aren't eigenstates of CP violation. Undirect CP violation predicts nonzero relation
$$
\tag 1 \frac{A(K_{L} \to \pi^{+} \pi^{-})}{A(K_{S} \to \pi^{+} \pi^{-})} = \frac{A(K_{L} \to \pi^{0} \pi^{0})}{A(K_{S} \to \pi^{0} \pi^{0})} = \epsilon
$$ | {
"domain": "physics.stackexchange",
"id": 28414,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-mechanics, quantum-field-theory, weak-interaction, cp-violation",
"url": null
} |
# What is the name of this method?
Orion1
## Homework Statement
Integrate:
$$\int \frac{1}{x^3 - 27} dx$$
## Homework Equations
$$\int \frac{1}{x^3 - 27} dx$$
$$\frac{1}{x^3 - 27} = \frac{1}{(x - 3)(x^2 + 3x + 9)} = \frac{A}{x - 3} + \frac{Bx + C}{x^2 + 3x + 9}$$
$$1 = A(x^2 + 3x + 9) + (Bx + C)(x - 3)$$
## The Attempt at a Solution
The first step involves factoring and splitting the denominator with some method:
$$\frac{1}{x^3 - 27} = \frac{1}{(x - 3)(x^2 + 3x + 9)} = \frac{A}{x - 3} + \frac{Bx + C}{x^2 + 3x + 9}$$
What is the name of this method?
The next step involves normalizing the equation:
$$1 = A(x^2 + 3x + 9) + (Bx + C)(x - 3)$$
How was the coefficients of B and C derived and solved?
The solution only states that:
$$A = \frac{1}{27}$$
$$0 = \frac{1}{27} + B$$
$$1 = \frac{1}{3} + 3C$$
And:
$B = -\frac{1}{27}$ and $C = -\frac{2}{9}$
I can see how the $A$ coefficient was derived from the x-axis zero intercept, however, it is not entirely clear to me how these other coefficients were derived and solved?
Reference:
http://www.scienceforums.net/index.php?app=core&module=attach§ion=attach&attach_id=4008
Last edited: | {
"domain": "physicsforums.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9805806484125338,
"lm_q1q2_score": 0.8234268844134746,
"lm_q2_score": 0.8397339736884711,
"openwebmath_perplexity": 674.0867960665402,
"openwebmath_score": 0.7535949945449829,
"tags": null,
"url": "https://www.physicsforums.com/threads/what-is-the-name-of-this-method.638135/"
} |
macos-mountain-lion, osx
Title: Issues about Installing ROS on Mountain Lion
Hi, I'm trying to install ROS on Mac OSX 10.8.1, following electric Homebrew Installation. And after fixing(hopefully) the boost lib problem, new one comes:
[ rosmake ] Generating Install Script using rosdep then executing. This may take a minute, you will be prompted for permissions. . .
[ rosmake ] rosdep install failed: unrecognized version: 10.8.1
Traceback (most recent call last):
File "/usr/local/bin/rosinstall", line 16, in
sys.exit(not rosinstall_main(sys.argv))
File "/Library/Python/2.7/site-packages/rosinstall/rosinstall_cli.py", line 228, in rosinstall_main
options.catkinpp)
File "/Library/Python/2.7/site-packages/rosinstall/rosinstall_cmd.py", line 100, in cmd_generate_ros_files
subprocess.check_call("source %s && rosmake ros%s --rosdep-install%s" % (os.path.join(path, 'setup.sh'), ros_comm_insert, rosdep_yes_insert), shell=True, executable='/bin/bash')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 511, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'source /Users/Klinux/ros/setup.sh && rosmake ros ros_comm --rosdep-install' returned non-zero exit status 1
I searched on google but didn't get any results, so could anybody help me out of this?
Thanks a lot... | {
"domain": "robotics.stackexchange",
"id": 10895,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "macos-mountain-lion, osx",
"url": null
} |
heisenberg-uncertainty-principle, measurements, quantum-computer, scaling
1) just waiting the computer to spit more numbers.
2) making it bigger, scaling the amount of transistors, or faster, higher clock, lower threshold,etc..
But we don't scale precision by changing threshold in runtime, "by software", and QC would seem to do something like that, because as computation is done by the measurement itself, and not by any classical abstraction so prediction would depends of the precision we ask by software, as if we could change microprocessor to use 3.3v, 1.8v, or 0.00001v in Runtime depending on the input numbers!, if so where will they go the noise and uncertainty? I think this is the answer, pointed out by PeterShor.
Here an ironic summary from Scott Aaronson (emphasis added) | {
"domain": "physics.stackexchange",
"id": 16251,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "heisenberg-uncertainty-principle, measurements, quantum-computer, scaling",
"url": null
} |
As $y-1<\lfloor y\rfloor\le y$, we find that for $y\ge1$ $$\tag1y^2-y-1<\lfloor y\lfloor y\rfloor\rfloor\le y^2$$ whereas for $y<0$, we have $$\tag2y^2-y-1>\lfloor y\lfloor y\rfloor\rfloor\ge y^2$$ Finally, for $0\le y<1$, we clearly have $\lfloor y\lfloor y\rfloor \rfloor=0$ Thus we cannot have $\lfloor y\lfloor y\rfloor\rfloor=5$ with $y\le -\sqrt 5$ (right hand side of $(2)$), nor with $-2\le y<0$ (left hand side of $(2)$), nor with $0\le y<1$, nor with $1\le y<\sqrt 5$ (right hand side of $(1)$), nor with $y\ge 3$ (left hand side of $(1)$). In other words, $-\sqrt 5< y <-2$ or $\sqrt 5\le y<3$. Then $\lfloor y\rfloor =-3$ or $\lfloor y\rfloor=2$.
In the first case, $$-3y-1<\lfloor -3y\rfloor=\lfloor y\lfloor y\rfloor \rfloor \le -3y,$$ so that we need $y\ge -\frac 53$, which contardicts $y<-2$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9808759604539052,
"lm_q1q2_score": 0.806465544528272,
"lm_q2_score": 0.822189121808099,
"openwebmath_perplexity": 312.32718138679013,
"openwebmath_score": 0.9778703451156616,
"tags": null,
"url": "https://math.stackexchange.com/questions/1962599/hints-to-find-solution-of-left-lfloor-dfracx100-left-lfloor-dfracx"
} |
c++, performance
for(int i=j+1;i<count;++i)
binom[i] = binom[i-1]*((count-1)-i+1)*1.0/i*prob/(1-prob);
for(int i=j-1;i>=0;--i)
binom[i] = binom[i+1]*(i+1)*1.0/((count-1)-i)*(1-prob)/prob;
double sum = 0;
for(int i=0;i<count;++i) sum += binom[i];
for(int i=0;i<count;++i) binom[i] /= sum;
sum = 0;
for(int i=1;i<count;++i) sum += d[i]*binom[i];
summ[j] = sum;
if(j%1000==0)// just to make the process faster and check progress
cout<<count-1<<'\t'<<j<<endl;
}
cout<<"writing to file "<<endl;
fout.open(output_file_string.c_str());
for(int i=1;i<count;i++) fout<<c[i]<<'\t'<<summ[i]<<endl;
fout.close();
delete [] c;
c = NULL;
delete [] d;
d = NULL;
delete [] binom;
binom = NULL;
delete [] summ;
summ = NULL;
}
int main()
{
convolute();
return 0;
} | {
"domain": "codereview.stackexchange",
"id": 26257,
"lm_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",
"url": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.