text stringlengths 49 10.4k | source dict |
|---|---|
and Daisies. The terms of the Fibonacci series are 0,1,1,2,3,5,8,13,21,34…. | More generally, in the base b representation, the number of digits in Fn is asymptotic to 1 The last is an identity for doubling n; other identities of this type are. Fibonacci numbers are named after Italian mathematician Leonardo of Pisa, later known as Fibonacci. V5 Problem 21. F [57] In symbols: This is done by dividing the sums adding to n + 1 in a different way, this time by the location of the first 2. i n ) + In order for any programming student to implement, it is just needed to follow the definition and implement a recursive function. x F {\displaystyle \log _{\varphi }(x)=\ln(x)/\ln(\varphi )=\log _{10}(x)/\log _{10}(\varphi ). The divisibility of Fibonacci numbers by a prime p is related to the Legendre symbol The Fibonacci numbers, denoted fₙ, are the numbers that form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones.The first two numbers are defined to be 0, 1.So, for n>1, we have: F for all n, but they only represent triangle sides when n > 2. {\displaystyle F_{n}=F_{n-1}+F_{n-2}} φ The ratio of consecutive terms in this sequence shows the same convergence towards the golden ratio. Moreover, since An Am = An+m for any square matrix A, the following identities can be derived (they are obtained from two different coefficients of the matrix product, and one may easily deduce the second one from the first one by changing n into n + 1), These last two identities provide a way to compute Fibonacci numbers recursively in O(log(n)) arithmetic operations and in time O(M(n) log(n)), where M(n) is the time for the multiplication of two numbers of n digits. The formula to calculate the Fibonacci numbers using the Golden Ratio is: X n = | {
"domain": "cooperspur.com",
"id": null,
"lm_label": "1. Yes\n2. Yes",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446440948806,
"lm_q1q2_score": 0.8092379729515932,
"lm_q2_score": 0.8311430436757312,
"openwebmath_perplexity": 522.5811326968872,
"openwebmath_score": 0.7941237092018127,
"tags": null,
"url": "https://cooperspur.com/6bfsk9/archive.php?abf666=nth-fibonacci-number-formula"
} |
c#, multithreading
#endregion
#region Nested types
private class ParallelProducerEnumerator<U> : IEnumerator<U>
{
#region Fields
private readonly List<Thread> producerThreads;
int threadsStillEnumerating;
private bool producersStarted = false;
private readonly BlockingCollection<U> cachedItems;
private U currentItem;
#endregion
#region Constructors
public ParallelProducerEnumerator(int maxItemsToCache, IEnumerable<U>[] slowEnumerables)
{
this.cachedItems = new BlockingCollection<U>(maxItemsToCache);
this.producerThreads = new List<Thread>();
this.threadsStillEnumerating = slowEnumerables.Length;
// this variable will be captured by all of the thread methods
foreach (var slowEnumerable in slowEnumerables)
{
// to avoid a reference to the iterator variable being captured
var enumerableToCapture = slowEnumerable;
var thread = new Thread(() => ProducerMethod(enumerableToCapture));
this.producerThreads.Add(thread);
}
}
#endregion
#region Properties
public U Current
{
get { return this.currentItem; }
}
object System.Collections.IEnumerator.Current
{
get { return this.Current; }
}
#endregion
#region Methods
private void ProducerMethod(IEnumerable<U> enumerable)
{
foreach (var item in enumerable)
{
this.cachedItems.Add(item);
}
int postDecrementValue = Interlocked.Decrement(ref this.threadsStillEnumerating);
if (postDecrementValue == 0)
{
cachedItems.CompleteAdding();
}
}
public bool MoveNext()
{
if (!producersStarted)
{
producersStarted = true;
foreach (var thread in producerThreads)
{
thread.Start();
}
}
if (!cachedItems.TryTake(out this.currentItem, Timeout.Infinite))
return false;
return true;
} | {
"domain": "codereview.stackexchange",
"id": 2060,
"lm_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#, multithreading",
"url": null
} |
# Trigonometric integrals involving tangent
So I came across a problem after answering the integral. The problem was:
$$\int\tan^3(3x)dx$$. This is to be integrated. This is how I did it:
\begin{align}\int\tan^2(3x)\tan(3x)dx&=\int(\sec^2-1)\tan(3x)dx\\ &=\int(\sec(3x)\sec(3x)\tan(3x))dx-\int\tan(3x)dx\\ &=\frac{\sec^2(3x)}{6}-\frac{1}{3}\ln|\cos3x|\end{align}
But the case is; my answer is incorrect after I checked online. The answer was:
$$\frac{\sec^2(3x)}{6}-\frac{1}{3}\ln|\sec3x|$$. How did it turn out to be sec inside of the natural log if the value to integrate is a $$\tan(3x)$$. Any suggestion. Thanks in advance.
• The derivative of $\cos(3x)$ is $\mathbb{-}3\sin(3x)$. You missed that minus sign, which can go into the $\ln$ and turn your $\cos(3x)$ into $\sec(3x)$. – user647486 Mar 24 '19 at 11:27 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9790357579585025,
"lm_q1q2_score": 0.8027049021884263,
"lm_q2_score": 0.8198933447152497,
"openwebmath_perplexity": 1030.944945297576,
"openwebmath_score": 0.9469088315963745,
"tags": null,
"url": "https://math.stackexchange.com/questions/3160414/trigonometric-integrals-involving-tangent"
} |
sorting, go
func main() {
A := []int{31, 41, 59, 26, 41, 58}
fmt.Println("Unsorted array: ", A)
fmt.Println("Increasing sort array: ", SelectionSort(A, "increasing"))
fmt.Println("Decreasing sort array: ", SelectionSort(A, "decreasing"))
} There are a few things I would point out as being poor go style. The two different nesting loops is where I would start:
for i := range A {
for j := i + 1; j < len(A); j++ {
The outer loop does a index-only range on the A slice, which in itself is not a problem, but logically it is for i := 0; i < len(A); i++ {. Again, this is not really a problem, other than the fact that you are looping the indexes of the slice. The problem is that in your inner loop, you make that index-loop obvious with the full-syntax loop.
I would be tempted to use a full loop for the outer loop so that the index functions on i and j are obvious.
The other thing I would suggest is that you supply a function for the S parameter, instead of a string.
While mentioning parameters, it is not common practice to use upper-case parameter names. These parameters are never exported, so should be lower-case initial, and mixedCase for multi-word names.
If you supply a function for the sort order, then your sort function is improved as well. Consider:
func SelectionSort(data []int, ordered func(int, int) bool) []int {
for i := 0; i < len(data); i++ {
for j := i + 1; j < len(data); j++ {
if !ordered(data[i], data[j]) {
data[i], data[j] = data[j], data[i]
}
}
}
return data
}
Now, you can call that code with something like:
increasing := func(a, b int) bool {
return a <= b
}
decreasing := func(a, b int) bool {
return a > b
} | {
"domain": "codereview.stackexchange",
"id": 18087,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "sorting, go",
"url": null
} |
c++
My testing has found this to be correct (maybe not the best but correct) solution. But I am not sure about it. Are there any possibilities in which this code fails. Also what would be a better solution at my level? Okay, first up, I'm a bit rusty with C++, so I apologize if this isn't formatted correctly.
But, the first thing that leaps out is "Single Responsibility Principle". Aka - each function should be responsible for one thing and have one reason to change.
Or in short: don't write everything in your Main().
What is your Main() doing, at a high level? It's:
Grabbing inputs for how many people and what bills they have
It's setting up the register (with no bills in it)
It's looping through each person
It's checking how that person impacts the current register
It's outputting the success/failure of the venture.
Awesome! So... what should your main look like in an abstract sense?
main()
{
int patronCount = GetPatronCount();
int[] billAmounts = GetBillAmounts();
int[] register = SetUpRegister();
for (i = 0; i < patronCount; i++)
{
bool wasAbleToMakeChange = MakeChangeForPatron(register, billAmounts[i]);
if (!wasAbleToMakeChange)
{
// code to return out with failure
}
}
// code to return success
} | {
"domain": "codereview.stackexchange",
"id": 38325,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++",
"url": null
} |
python, youtube
Title: Crawling through a YouTube channel via the YouTube API This code uses the YouTube API for crawling through a YouTube channel, parsing responses and syncing the channel videos with a local directory.
Can this be optimised or improved?
import subprocess
import os
import urllib.request as urlreq
import urllib.parse as urlparse
import simplejson as json
playlistIds = []
titles = []
def getPlaylistId():
data = {}
data['maxResults'] = '50'
data['channelId'] = 'UCtESv1e7ntJaLJYKIO1FoYw' # Put the channelId of channel you want to Sync to.
data['part'] = 'snippet'
data['key'] = 'AIzaSyAngcF6oKnyEbhk3KyL9Wz1OhSi28JjbzE'
requestValues = urlparse.urlencode(data)
request = "https://www.googleapis.com/youtube/v3/playlists?" + requestValues
string = urlreq.urlopen(request).read().decode('utf-8')
items = json.loads(string)['items']
for item in items:
playlistIds.append(item['id'])
titles.append(item['snippet']['title'])
def download():
for ids,title in zip(playlistIds,titles):
url = "https://www.youtube.com/playlist?list=" + ids
if not os.path.exists(title):
os.makedirs(title)
os.chdir("./" + title)
url_down = "youtube-dl -o '%(title)s' " + url
subprocess.call(url_down, shell=True)
os.chdir("..") | {
"domain": "codereview.stackexchange",
"id": 19681,
"lm_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, youtube",
"url": null
} |
For any positive $a$, $b$ and $x$ you have
$$\log_b(x) = \frac{\log_a(x)}{\log_a(b)}$$
so you can define the logarithm to any base $b$ once you've defined it for a single base $a$.
Pick your favourite base (many people like $a=10$, but computer scientists tend to prefer $a=2$ and mathematicians prefer $a=e$) and then the logarithm to base $b$ is the logarithm to base $a$, multiplied by $1/\log_a(b)$.
The OP asked "How does $\log_a(x)=\log_b(x)\log_a(b)$ demonstrate that all logs are multiples of each other?" not "How do you prove that $\log_a(x)=\log_b(x)\log_a(b)$?" – Chris Taylor Jan 18 '12 at 14:30 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9825575152637948,
"lm_q1q2_score": 0.8230097819425212,
"lm_q2_score": 0.8376199552262967,
"openwebmath_perplexity": 130.45372817174865,
"openwebmath_score": 0.9721981287002563,
"tags": null,
"url": "http://math.stackexchange.com/questions/100128/are-all-logarithms-multiple-of-each-other"
} |
error-correction
Title: A 32x32 matrix with the best rank * span_weight Answers must contain a 32x32 matrix (or smaller). An answer is better if its matrix has a higher product of rank and span weight.
In "Subsystem codes with spatially local generators". Sergey Bravyi proves that you can turn a bit matrix into a local planar subsystem code that has the following properties:
The number of stored logical qubits is the rank of the matrix
The distance of the code is the "span weight" of the matrix. The span weight is the minimum non-zero Hamming weight in the column span or row span of the matrix (e.g. if you can xor rows together to get a row with only a few 1s, the distance will be bad).
Unfortunately, the paper doesn't give any examples of these matrices that achieve good numbers. It just gives an asymptotic proof that families of $n \times n$ matrices exist where the rank and the span weight are both $O(n)$. I want actual examples of good matrices.
Here's a 12x12 matrix ("." means 0, "1" means 1) that has rank 6 and span weight 4:
1......11111
.1....1.1111
..1...11.111
...1..111.11
....1.1111.1
.....111111.
.111111.....
1.1111.1....
11.111..1...
111.11...1..
1111.1....1.
11111......1
This matrix has a score of 6*4 = 24. This is a bad score. How high can we get the score, limited to matrices of size at most 32x32?
Here is code I wrote that you can use to analyze a matrix. I have not extensively tested it:
import numpy as np | {
"domain": "quantumcomputing.stackexchange",
"id": 4847,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "error-correction",
"url": null
} |
# $\int_0^\infty \frac{\log(x)}{x^2+\alpha^2}$ using residues
I'm trying to find $\int_0^\infty \frac{\log(x)}{x^2+\alpha^2}dx$ where $\alpha>0$ is real. My approach was to take an integral along the real line from $1/R$ to $R$, around the circle counterclockwise to $-R$, along the real line to $-1/R$, and then around the circle clockwise to $1/R$. I have encountered 2 problems with this:
1. This path encloses one pole, at $z=\alpha i$. I found the residue at $z=\alpha i$ to be $\frac{\ln(\alpha)+i\pi/2}{2\alpha i}$. However, this gives me that $\int_0^\infty \frac{\log(x)}{x^2+\alpha^2}dx=\frac{\pi(\ln(\alpha)+i\pi/2)}{2\alpha}$. Since I have a real function integrated over the real line, there cannot be an imaginary part. Where did I go wrong? (Also, doing a few examples, the correct answer seems to be $\frac{\pi\ln(\alpha)}{2\alpha}$, the same as I have but without the imaginary part.)
2. At first chose my path so instead of going all the way around the upper semicircle, it only went 3/4 of the way around, as I wanted to avoid anything that might go wrong with the discontinuity of $\log(x)$ at the negative real axis. When I do this, though, I get a different answer than before (the denominator of the fraction is $\alpha(1-e^{3\pi i/4})$ instead of $2\alpha$. What am I doing wrong that gives me different answers? | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9833429609670702,
"lm_q1q2_score": 0.8236676988952621,
"lm_q2_score": 0.8376199673867852,
"openwebmath_perplexity": 188.96801340016916,
"openwebmath_score": 0.9639318585395813,
"tags": null,
"url": "https://math.stackexchange.com/questions/1375028/int-0-infty-frac-logxx2-alpha2-using-residues"
} |
solutions. The initial table listed in problem description is a table of probabilities p(1), p(2), , p(20). Total Number of ways = 2 5 = 32. The point is that the order of events doesn't affect with respect to conditional probability. MIDTERM 2 solutions and Histogram. The incubation periods of a random sample of 7 HIV infected individuals is given below (in years): 12. Advanced Techniques. A Problem With Pearls. Normal distribution probability : Statistics S1 Edexcel June 2013 Q6 (b) : ExamSolutions - youtube Video. The probability mass function of is but and Therefore, the probability mass function can be written as which is the probability mass function of a Bernoulli random variable. Then, n(E) = 2. Rolling the Dice. The empirical probability of three consecutive female births is. 1, Median 22. ) For a different problem, allow every one of n people to place an even bet on the color of his hat. In the Options dialog box, select the Show Iteration Results check box to see the values of each trial solution, and then click OK. Most of the problems require very little mathematical background to solve. Problem Solving: Find a Pattern What Is It? Finding a Pattern is a strategy in which students look for patterns in the data in order to solve the problem. The probability (chance) is a value from the interval 0;1> or in percentage (0% to 100%) expressing the occurrence of some event. P (A n B) = A and B = A x B P (A u B) = A or B = A + B. DISCRETE PROBABILITY DISTRIBUTIONS 27. Miracle Mountain. Geometric Probability. Life or Death? The Emperor's Proposition. We want to generate a random number between 100 and 499. The probability of a success, denoted by p, remains constant from trial to trial and repeated trials are independent. Probability Questions and answers PDF with solutions. Probability MCQ Questions and answers with easy and logical explanations. Please do not email me completed problem sets. Multiplying by multiples of 10. John has a special die that has one side with a six, two sides with twos and three sides with ones. At any particular time period, both outcomes cannot be achieved together so […]. Solution of exercise 1. This is a beta distribution. We want to generate a random number between 100 | {
"domain": "mexproject.it",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9854964203086181,
"lm_q1q2_score": 0.864750244018912,
"lm_q2_score": 0.8774767986961401,
"openwebmath_perplexity": 589.712825578324,
"openwebmath_score": 0.7061757445335388,
"tags": null,
"url": "http://mexproject.it/zcjm/probability-problems-and-solutions.html"
} |
javascript, performance, ecmascript-6, dom
Example
Note that element ids have been prepended with El as I do not know what other code or markup you have.
The code size has be reduce by half meaning its is easier to maintain and read.
Money is handled correctly and rounded up to favour the tip (a cent per person max)
const CURRENCY = ["en-US", {style: "currency", currency: "USD"}];
const setElClass = (el, cName, show = true) => el.classList[show ? "add" : "remove"](cName);
numberOfPeopleEl.addEventListener("input", () => {
numberOfPeopleLabelEl.textContent = numberOfPeopleEl.value > 1 ? "people" : "lone wolf";
});
calculateButtonEl.addEventListener('click', () => {
var tip = serviceQualityEl.value;
const bill = billAmountEl.value;
const people = numberOfPeopleEl.value;
setElClass(billAmountAlertEl, "alert--show", isNaN(bill));
setElClass(tipPercentageAlertEl, "alert--show", isNaN(tip));
if (!isNaN(bill) && !isNaN(tip)) {
tip = Math.ceil(Math.round(bill * 100) / 100 * tip / people); // in cents per person
tipAmountEl.textContent = (tip / 100).toLocaleString(...CURRENCY);
setElClass(eachEl, "people-count--show", people > 1);
tipAmountContainerEl.classList.add("tip-amounts--show");
cashRegisterSoundEl.volume = 0.05;
cashRegisterSoundEl.play();
}
});
You will also need the following CSS rules.
.alert--show { display : inline }
.people-count--show { display : inline }
.tip-amounts--show { display : block } | {
"domain": "codereview.stackexchange",
"id": 33320,
"lm_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, performance, ecmascript-6, dom",
"url": null
} |
performance, regex, swift, swift3
The flatMap version may be more "swifty", but it could be less efficient. I would use it until profiling shows that it is a performance bottleneck and the other version is actually more efficient.
Some of the same things apply to the second function. But this has some much bigger issues.
The first is an efficiency issue. You run the regex repeatedly on the string after the first match, even though the first call already returns all matches. Also the part of the string after the match is repeatedly added to the array just to be removed again.
The second one is that you can't use the string's character count in the ranges for the regex matching. The foundation string APIs are based on UTF-16 while a Swift character can consist of multiple UTF-16 code points. Try sticking strings with emoji into your function to see it produce wrong results. The pragmatic solution would be to use NSString instead of the Swift String in there.
Also the calculation of the firstIndex value seems off. It easily produces indices which are way outside of the original string. I am doing a dangerous thing here and assume that it is supposed to be the index of the StringPart in the original string. To calculate this we also need to pass the firstIndex of the part we are currently analysing to the split function and we get this:
func splitNumbers(searchText: String, pattern: String, patternIndex: Int, firstIndex: Int = 0) -> [StringPart] {
let regex = try! NSRegularExpression(pattern: pattern, options: [])
let s = searchText as NSString
let matches = regex.matches(in: s as String, options: [], range: NSRange(location: 0, length: s.length)) | {
"domain": "codereview.stackexchange",
"id": 22319,
"lm_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, regex, swift, swift3",
"url": null
} |
quantum-mechanics, homework-and-exercises, schroedinger-equation, harmonic-oscillator
Now
\begin{equation}
\hat{a}^\dagger\hat{a} \left| n \right\rangle = \hat{a}^\dagger \sqrt{n} \left| n - 1 \right\rangle = \sqrt{n} \sqrt{n} \left| n \right\rangle = n \left| n \right\rangle ,
\end{equation}
so conclude that the eigenvalue of a number operator, $\hat{N}$, is just $n$, so if we now apply Hamiltonian in the Schroedinger equation, get
\begin{equation}
\hat{H} \psi = E \psi ,
\end{equation}
\begin{equation}
E_n = \hbar \omega \left(n + \frac{1}{2} \right) ,
\end{equation}
which is exactly the result you were looking for.
Answer 2:
First of all you should remember that the general aim of solving an eigenvalue problem is to find a set of eigenvectors, but not a single eigenvector. In your case, equation should be modified to
\begin{equation}
\frac{d^2 \psi_n}{dx^2} + \left[(2n + 1) - \varepsilon^2\right]\psi_n = 0 ,
\end{equation}
where $\psi_n$ are eigenvectors (eigenfunctions) that correspond to eigenvalues $E_n$. Try to think a little bit and explain physical meaning of having many energy eigenvalues in quantum mechanics.
Now return to the general theory of eigenvalue equations. Although I have never met the equation you wrote, I cannot find any place it can be wrong apart from the one just pointed out. Though, I don't see how far can you go from it.
Answer 3:
Hermite polynomials are usually beyond standard quantum mechanics courses. If you know Legendre, Chebyshev and/or other polynomials, you may guess that Hermite polynomials are derived as solution to some differential equation, and this does not contradict to the definition of $\psi$. | {
"domain": "physics.stackexchange",
"id": 7465,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-mechanics, homework-and-exercises, schroedinger-equation, harmonic-oscillator",
"url": null
} |
quantum-field-theory, group-theory, group-representations
Title: Action of the Lorentz group on scalar fields The Lorentz groups act on the scalar fields as:
$\phi'(x)=\phi(\Lambda^{-1} x)$
The conditions for an action of a group on a set are that the identity does nothing and that
$(g_1g_2)s=g_1(g_2s)$. This second condition is not fulfilled because of the inverse on $\Lambda$. What is then the action of the Lorentz group on the scalar fields? Denote by $g_1\phi$ the field transformed by the action of $\Lambda_1$ : $$(g_1\phi)(x) = \phi(\Lambda_1^{-1}(x))$$ Similarly $g_2$ has action $$(g_2\psi)(x) = \psi(\Lambda_2^{-1}(x))$$ Substitute $g_1\phi$ for $\psi$ $$(g_2g_1\phi)(x) = (g_1\phi)(\Lambda_2^{-1}(x)) = \phi(\Lambda_1^{-1}\Lambda_2^{-1}(x)) = \phi((\Lambda_2\Lambda_1)^{-1}(x)) $$ So the group action looks correct. | {
"domain": "physics.stackexchange",
"id": 5830,
"lm_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, group-theory, group-representations",
"url": null
} |
c
Title: A simple command line linear interpolator in C I'm trying to become more familiar with C (been working through the MIT Practical Programming in C course and K&R) so decided to write a simple command-line linear interpolator. You can feed it a vector (where missing values are represented by 0n) and it should print an interpolated vector. Any comments on style etc are much appreciated.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NULLA "0n"
#define NULLF -1000
#define MAXLEN 1000
int main(int argc, char * argv[])
{
if(argc < 2)
{
printf("missing vector for interpolation\n");
return 1;
}
if(argc - 1 > MAXLEN)
{
printf("vector is too long\n");
return 2;
}
float start, end, delta; //bound values and change for interpolation
int num_nulls = 0; //number of nulls in a given interpolation range
float filled[MAXLEN]; //vector where we will put our values
int i, j; //indices, for argv[] and filled[] vectors, correspondingly
//we want all values in filled to be initalized to zero, to avoid junk vals
for(j = 0; j < MAXLEN; j++)
filled[j] = 0.;
//let's go through any initial nulls, which just get put back in
//to the vector, since we can't interpolate (no starting/ending values yet)
for(i = 1, j = 0; i < argc && strcmp(argv[i], NULLA) == 0; i++)
filled[j++] = NULLF; | {
"domain": "codereview.stackexchange",
"id": 9117,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c",
"url": null
} |
c, console, to-do-list, markdown
static bool todo_list_add(StringList *todo_list, char **strings, size_t n)
{
char *new_todo = todo_build_from_strings(strings, n);
if (new_todo != NULL && string_list_append(todo_list, new_todo)) {
return true;
}
free(new_todo);
return false;
}
static bool todo_list_edit(StringList *todo_list, size_t i, char **strings, size_t n)
{
StringBuffer join_buf;
string_buffer_init(&join_buf);
if ( ! string_buffer_append_strings(&join_buf, strings, n, ' ')) {
string_buffer_free(&join_buf);
return false;
}
char *todo = string_list_get(todo_list, i);
size_t todo_len = strlen(todo);
StringBuffer todo_buf = {
.length = todo_len,
.capacity = todo_len + 1,
.string = todo
};
bool ret = false;
size_t middle_slash_i = is_replace_pattern(join_buf.string, join_buf.length);
if (middle_slash_i > 0) {
join_buf.string[middle_slash_i] = '\0';
join_buf.string[join_buf.length - 1] = '\0';
const char *sub = join_buf.string + 1;
const char *rep = join_buf.string + middle_slash_i + 1; | {
"domain": "codereview.stackexchange",
"id": 32432,
"lm_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, console, to-do-list, markdown",
"url": null
} |
image-processing, filters, computer-vision, convolution, kernel
The vertical part of the separable filter is:
$$
\mathbf{v_2} = 1/4\begin{bmatrix}1\\2\\1\end{bmatrix}
$$
not
$$
\mathbf{v_1} = 1/2\begin{bmatrix}-1\\0\\1\end{bmatrix}.
$$
You can see this by defining:
$$
\mathbf{h}= 1/2\begin{bmatrix}-1&0&1\end{bmatrix}
$$
and looking at
$$ \mathbf{K_1} = \mathbf{v_1} \mathbf{h} = \begin{bmatrix} 1/4 & 0 & -1/4\\
0 & 0 & 0\\
-1/4 & 0 & 1/4
\end{bmatrix}$$
and
$$ \mathbf{K_2} = \mathbf{v_2} \mathbf{h}= \begin{bmatrix} -1/8 & 0 & 1/8\\
-1/4 & 0 & 1/4\\
-1/8 & 0 & 1/8
\end{bmatrix}$$
You can see this effect in the image I included in your question: the vertical edges are highlighted, but the horizontal ones disappear. This is because the $\mathbf{v_2}$ filter is a low-pass filter, not enhancing edges. | {
"domain": "dsp.stackexchange",
"id": 7044,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "image-processing, filters, computer-vision, convolution, kernel",
"url": null
} |
We must take the derivative with finesse, and that means we use the chain rule. Note that $$f = g \circ h$$, where $$h(x) = Ax-b$$ and $$g(u) = (1/2) \|u\|^2$$. The derivatives of $$h$$ and $$g$$ are $$h'(x) = A$$ and $$g'(u) = u^T$$. So by the chain rule $$f'(x) = g'(h(x)) h'(x) = (Ax-b)^T A.$$ The gradient of $$f$$ is $$\nabla f(x) = f'(x)^T = A^T(Ax-b).$$
• Thanks for the answer. Where did the transpose in $g'(u) = u^T$ come from? – The Pointer Jan 14 '20 at 6:43
• If $F:\mathbb R^n \to \mathbb R^m$ is differentiable at $x$, then $F'(x)$ is an $m \times n$ matrix. So, since $g:\mathbb R^n \to \mathbb R$, we see that $g'(u)$ is a $1 \times n$ matrix (a row vector). – littleO Jan 14 '20 at 6:56
• Thank you for the clarification. – The Pointer Jan 14 '20 at 7:30 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9875683518909607,
"lm_q1q2_score": 0.818633739012555,
"lm_q2_score": 0.8289388146603365,
"openwebmath_perplexity": 320.7036025939608,
"openwebmath_score": 0.9997535347938538,
"tags": null,
"url": "https://math.stackexchange.com/questions/3508373/taking-the-gradient-of-f-mathbfx-frac12-mathbfa-mathbfx-ma"
} |
homework-and-exercises, gravity, mathematical-physics, topology, vector-fields
What can we say about the critical points of $U(x,y)$? Specifically, can we show that the number of critical points is always $\leq n$?
Remark: By critical point, I mean the usual definition in vector calculus, that is a place where both partial derivatives are zero. Take 4 points arranged in a square. The middle of the square is a critical point by symmetry, and the midpoint of the four sides of the square would be a critical point just for the two vertices it joins together, ignoring the other two. But the other two are little more than twice as far away, so eight times weaker force, so if you bring the point closer to the center of the square by an amount about 1/8 of the way to the other side, you will cancel out the force from the far pair from the force on the near pair. So there are 5 critical points for four points on a square, and this holds for all sufficiently fast-falling-off forces.
Using squares-of-squares, I believe it is easy to establish that the number of critical points is generically $n^2$. I believe it is a difficult and interesting mathematical problem to establish any sort of nontrivial bound on the number of critical points. The trivial bound is from the order of the polynomial equation you get, and it's absurdly large---- it grows like $2^n$.
EDIT: The correct growth rate
The answer for a general configuration is almost certainly N+C critical points (this should be an upper bound and a lower bound for two different C's --- I didn't prove it, but I have a, perhaps crappy, heuristic). For the case of polygons, there are N+1 critical points. For squares where the corners are expanded to squares, and so on fractally, the number of critical points is N+C where C is a small explicit constant. The same for poygons of polygons.
I found a nifty way of analyzing the problem, and getting some good estimates, but I want to know how good the mathematicians are at this before telling the answer. Perhaps you can ask this question on MathOverflow? | {
"domain": "physics.stackexchange",
"id": 1825,
"lm_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, gravity, mathematical-physics, topology, vector-fields",
"url": null
} |
acid-base, equilibrium
Assuming :${[\ce{OH-}]=[\ce{CH3COOH}]}$, ${[\ce{CH3COO-}]=[\ce{CH3COOK}]_0}$
Substiute $K_\mathrm{a}\ and\ [\ce{CH3COO^-}]$ in the equilibrium equation and solve for $[\ce{OH-}]$.
$$[\ce{OH-}] = 5.27\times{10^{-6}} , \mathrm{pOH}=5.278 , \mathrm{pH}=8.72$$ | {
"domain": "chemistry.stackexchange",
"id": 10937,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "acid-base, equilibrium",
"url": null
} |
electromagnetism, electrostatics, simulations, molecular-dynamics
Title: Molecular simulations of proteins: how good an approximation is electrostatics? This question has to do with molecular dynamics simulation of molecules, especially proteins, using software such as GROMACS.
This type of software uses empirical force fields (eg AMBER) and some constraints on covalent bond length and geometry; the simulation proceeds in steps of typically a few femtoseconds and can cover tens to hundreds of nanoseconds at a time.
The forces considered here are pure electrostatics; there is no magnetic or coupled electric-magnetic component. Of course since there are electric charges in the simulation (eg polar groups, molecular dipoles, ...), and they move, and moving charges produce magnetic fields which exert force on other moving charges, the simulation is going to miss some things.
The question is: how good of an approximation is electrostatics in this context?
This is about developing some intuition and good order of magnitude estimates, not about any kind of precision. I think the pieces of this are: How large are the charges? and How fast do they move? (due to thermal motion, or when transitioning between stable conformations) and consequently: How strong is the resulting magnetic field, and what is the ratio of electrostatic force between charges to the magnetic force between moving charges?
As a biologist, the kinds of proteins I would be interested in especially as model systems are voltage-sensing domains (VSDs) of transmembrane proteins, and tubulin/microtubules. Both of these have large conformational changes between different states, and have mobile subunits with large dipoles. Looking up VSDs, it seems the distance of movement between states can be 10-40 A (1 and 2), the macrodipoles of subunits of the protein can be 20-25 Debye (3), and the motion time scale is nanoseconds to milliseconds (4 and 5). The magnetic field of a moving charge can be obtained from the expression of the Liénard–Wiechert potential and it can be expressed as a function of the corresponding electric field as
$$
{\bf B}({\bf r},t) = \frac{{\bf n}(t_r)}{c} \times {\bf E}({\bf r},t)
$$ | {
"domain": "physics.stackexchange",
"id": 63170,
"lm_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, simulations, molecular-dynamics",
"url": null
} |
# Integral of periodic function over the length of the period is the same everywhere
I am stuck on a question that involves the intergral of a periodic function. The question is phrased as follows:
Definition. A function is periodic with period $a$ if $f(x)=f(x+a)$ for all $x$.
Question. If $f$ is continuous and periodic with period $a$, then show that $$\int_{0}^{a}f(t)dt=\int_{b}^{b+a}f(t)dt$$ for all $b\in \mathbb{R}$.
I understand the equality, but I am having trouble showing that it is true for all $b$. I've tried writing it in different forms such as $F(a)=F(b+a)-F(b)$. This led me to the following, though I am not sure how this shows the equality is true for all $b$,
$$\int_{0}^{a}f(t)dt-\int_{b}^{b+a}f(t)dt=0$$ $$=F(a)-F(0)-F(b+a)-F(b)$$ $$=(F(b+a)-F(a))-F(b)$$ $$=\int_{a}^{b+a}f(t)dt-\int_{0}^{b+a}f(t)dt=0$$
So, this leaves me with
$$\int_{a}^{b+a}f(t)dt-\int_{0}^{b+a}f(t)dt=\int_{0}^{a}f(t)dt-\int_{b}^{b+a}f(t)dt$$
I feel I am close, and I've made myself a diagram of a sine function to visualize what each of the above integrals might describe, but the power to explain the above equality evades me. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9808759615719875,
"lm_q1q2_score": 0.8606958845355384,
"lm_q2_score": 0.877476784277755,
"openwebmath_perplexity": 219.76854088854688,
"openwebmath_score": 0.9384185075759888,
"tags": null,
"url": "https://math.stackexchange.com/questions/98409/integral-of-periodic-function-over-the-length-of-the-period-is-the-same-everywhe?noredirect=1"
} |
python
servicestatus {
host_name=deep-thought
service_description=Application Netbackup Version
modified_attributes=0
check_command=check_windows_nrpe!check_netbackup!6.5!6
check_period=24x7
notification_period=24x7
check_interval=60.000000
retry_interval=5.000000
event_handler=
has_been_checked=1
should_be_scheduled=1
check_execution_time=0.563
check_latency=2.887
check_type=0
current_state=0
last_hard_state=0
last_event_id=557354
current_event_id=557367
current_problem_id=0
last_problem_id=260970
current_attempt=1
max_attempts=3
state_type=1
last_state_change=1372696479
last_hard_state_change=1372696148
last_time_ok=1399011262
last_time_warning=0
last_time_unknown=0
last_time_critical=1372696455
plugin_output=Netbackup Not Installed!
long_plugin_output=
performance_data=
last_check=1399011262
next_check=1399014862
check_options=0
current_notification_number=0
current_notification_id=0
last_notification=0
next_notification=0
no_more_notifications=0
notifications_enabled=1
active_checks_enabled=1
passive_checks_enabled=1
event_handler_enabled=1
problem_has_been_acknowledged=0
acknowledgement_type=0
flap_detection_enabled=1
failure_prediction_enabled=1
process_performance_data=1
obsess_over_service=1
last_update=1399014558
is_flapping=0
percent_state_change=0.00
scheduled_downtime_depth=0
} | {
"domain": "codereview.stackexchange",
"id": 7381,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python",
"url": null
} |
astrophysics, laser, plasma-physics, ionization-energy
Title: Electron density Saha Ionization Equation Saha-Boltzmann equation describes the ratio of number densities between any two consecutive ionization states and its product with the number electron density i.e.
$$n_e\frac{n_{i+1}}{n_{i}}$$
Here, $n_e$ is the electron number density, $n_{i+1}$ is the number density in $i+1$ ionization state and $n_i$ is the number density in the $i$ ionization state. My question is regarding the factor $n_e$. Which electron density is this actually? Is it the electron density produced as a result of ionization from $i$ state to $i+1$?
Which electron density is this actually?
The electron density in the Saha equation is the total electron number density. It does not really matter from where the electrons arose for the equation purposes, it's just the total electron density.
Is it the electron density produced as a result of ionization from $i$ state to $i + 1$?
Perhaps or perhaps not. Again, this is not the issue so much as $n_{e}$ corresponds to the total electron number density. | {
"domain": "physics.stackexchange",
"id": 55865,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "astrophysics, laser, plasma-physics, ionization-energy",
"url": null
} |
cc.complexity-theory, asymptotics
In short, is there some kind of topological framework that handles manipulations over these functions? Indeed, they are not functions, but asymptotic representations or quantities instead. It's a different type of mathematical objects, with its own arithmetic and topology. That's a nice list! Unfortunately, I think the function $n\left(\log(n)^{\log\log(n)}\right)$ is not in your list. Yet it grows faster than $n\log(n)$ and slower than $n^{1+\varepsilon}$. Similarly, the function $n\left(\log\log(n)^{\log\log\log(n)}\right)$ is not in there, yet it grows faster than $n\log\log(n)$ but slower than $n\log(n)^{\varepsilon}$.
For inspiration, check out comment 52 on This blog of Scott Aaronson, where he reflects on half-exponential functions, among other things. He considers a classification not unlike your own, and proves that it does not capture all asymptotic growth rates. I like your idea, and I hope you learn something from that blog post. | {
"domain": "cstheory.stackexchange",
"id": 4674,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "cc.complexity-theory, asymptotics",
"url": null
} |
filter-design, delay
This is an all digital nulling loop that can null down to the rms power level of your signal (at which point it can no longer estimate the cancellation coeeficient). The bold lines shown in green represent complex signals:The 50 Hz PLL is a NCO with sine/cosine outputs, the multiplier following it is a full complex multiplier (essentially a vector modulator providing complete control of amplitude or phase), the multiplier after the second BPF is essentially a quadrature down-converter providing a measure of the amplitude and phase of the residual. | {
"domain": "dsp.stackexchange",
"id": 9016,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "filter-design, delay",
"url": null
} |
The book shows the answer as: $ln\frac{2^{11/5}x^9}{y^8}$
I understand how the $x^6$ turns into $x^9$, but how does the $4$ in $\frac{3}{2}ln4x^6$ turn into $2^{11/5}$?
$\frac{3}{2}\ln(4x^6) - \frac{4}{5}\ln(2y^{10})$
$\ln(4x^6)^{\frac{3}{2}} - \ln(2y^{10})^{\frac{4}{5}}$
$\ln\left(\frac{(4x^6)^{\frac{3}{2}}}{(2y^{10})^{\f rac{4}{5}}}\right)$
Now simplify
3. Originally Posted by Ineedhelpwithlogs
3) Find the inverse function of:
$f(x) = \frac{3x}{x-3}$
When I do the math, it shows that the inverse function is exactly the same as the original function? How is that possible?
I would appreciate it greatly if you could answer the questions above step-by-step.
Thanks
$y = f(x) = \frac{3x}{x-3}$
swap x and y and then solve for y
$x = \frac{3y}{y-3}$
$(y-3)x = 3y$
$yx-3x = 3y$
$-3x = 3y-yx$
$-3x = y(3-x)$
Can you solve for y?
4. Originally Posted by pickslides
$\frac{3}{2}\ln(4x^6) - \frac{4}{5}\ln(2y^{10})$ | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9585377272885904,
"lm_q1q2_score": 0.8008424928054155,
"lm_q2_score": 0.8354835391516133,
"openwebmath_perplexity": 269.97153791462983,
"openwebmath_score": 0.9210744500160217,
"tags": null,
"url": "http://mathhelpforum.com/algebra/126497-need-help-logarithm-inverse-function.html"
} |
1. Is this an actual phenomenon or did I violate some sort of rule?
2. What are the implications of this?
• Why do you think these give different answers? Both seem to give $\frac {1+\sqrt 5}2$. Note that, if the value exists at all, it is clearly $>0$ so we can discard non-positive roots. – lulu Jan 1 '19 at 19:18
• But those solutions are extraneous and therefore discarded, regardless of how many there are. The only correct solution is the golden ratio, as pointed out. – KM101 Jan 1 '19 at 19:25
• @S.Cramer True but each time you square you pick up an "extra" solution which must be discarded. Here the fact that any value for this expression would have to exceed $1$ lets us discard the irrelevant values. – lulu Jan 1 '19 at 19:25
• Because $\sqrt{1+{\sqrt{1+…}}}$ is clearly positive. Any non-positive solution obtained is the solution to the new polynomial constructed, not the original nested radicals. – KM101 Jan 1 '19 at 19:29
• @S.Cramer The problem is that squaring "loses" signs. Study my example of $\sqrt x = x-1$. That only has a single real solution (easy to see) but squaring also picks up the real solution to $\sqrt x = 1-x$. – lulu Jan 1 '19 at 19:30
Every time you square this you add extraneous solutions which arise from taking the negative value of some of the square roots. The use of $$x$$ implies that the pattern is recurrent, but the quartic arising from squaring twice corresponds to the four possible choices for the square roots you have removed. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9572778048911611,
"lm_q1q2_score": 0.8155555099382751,
"lm_q2_score": 0.8519528038477824,
"openwebmath_perplexity": 423.75161294977715,
"openwebmath_score": 0.9992896914482117,
"tags": null,
"url": "https://math.stackexchange.com/questions/3058785/does-a-given-infinite-nested-radical-have-infinitely-many-solutions/3059069"
} |
quantum-mechanics, schroedinger-equation, hamiltonian-formalism, perturbation-theory
\begin{equation}
\lambda f_1\approx \lambda g_1
\end{equation}
So we must have $f_1=g _1$ (since we can make $\lambda$ arbitrarily small). You can continue the process iteratively to show that you can equate coefficients of a Taylor expansion to all orders. | {
"domain": "physics.stackexchange",
"id": 13982,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-mechanics, schroedinger-equation, hamiltonian-formalism, perturbation-theory",
"url": null
} |
c#, strings
/// <summary>
/// The number of elements in the collection.
/// </summary>
private readonly int count;
/// <summary>
/// Initializes a new instance of the <see cref="StringCollection"/> class that contains
/// the specified strings, where the strings are in lexicographic order.
/// </summary>
/// <param name="strings">
/// The collection of strings that are in the new <see cref="StringCollection"/>, in
/// lexicographic order.
/// </param>
/// <exception cref="ArgumentNullException">
/// <paramref name="strings"/> is <c>null</c>.
/// </exception>
/// <exception cref="ArgumentException">
/// An item in <paramref name="strings"/> is <c>null</c>.
/// </exception>
public StringCollection(IEnumerable<string> strings)
{
if (strings == null)
{
throw new ArgumentNullException("strings");
}
var register = new Dictionary<State, State>(new StateComparer());
using (var enumerator = strings.GetEnumerator())
{
if (!enumerator.MoveNext())
{
return;
}
if (enumerator.Current == null)
{
throw new ArgumentException("strings cannot contain null", "strings");
}
if (string.IsNullOrEmpty(enumerator.Current))
{
this.initialState = new FinalState();
}
else
{
this.initialState = new State();
AddSuffix(this.initialState, enumerator.Current.ToCharArray());
}
this.count = 1;
while (enumerator.MoveNext())
{
var word = enumerator.Current;
if (word == null)
{
throw new ArgumentException("strings cannot contain null", "strings");
} | {
"domain": "codereview.stackexchange",
"id": 8556,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c#, strings",
"url": null
} |
astrophysics, astronomy, stars, galaxies, milky-way
Thus when we look around us, the stars nearby are hugely dominated by Pop I stars by about 200:1 (here my definition is that Pop II stars are metal-poor; we cannot tell the age of a star by just looking at it!). Extrapolation of this using estimates of the density distribution of metal-poor stars suggests that halo population II contributes only a few percent of the stellar mass of the Galaxy. In turn, this suggests the formation epoch of population II stars lasted much less than 1 billion years. I'm trying to pin this number down a bit better, but the interpretation is confused by what is classified as Pop II, what metallicity cut-off is used, and also by the possibility that our Galaxy halo might include populations due to a number of merger and accretion events, not all of which are metal-poor. Finally there is the question of the bulge. Roughly 20-25% of the stellar mass is here and it probably formed rapidly (about billion years) at the beginning of the Galaxy. For the reasons I discussed above, such a period of intense star formation means that the ISM was enriched and most bulge stars have high metallicity. | {
"domain": "physics.stackexchange",
"id": 17976,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "astrophysics, astronomy, stars, galaxies, milky-way",
"url": null
} |
thermodynamics, soft-question, phase-transition, chaos-theory, critical-phenomena
Title: Understanding this metaphor involving e-mails, chaos and phase transitions I asked this question on the English Stack Exchange and people advised to try get the answer here. I can’t get the idea of metaphor in the last sentence of the following quote:
Instead, email operates more like chaos theory: at some point the time/energy required crosses a critical threshold, an unpredictable, invisible boundary. It undergoes a phase transition, like ice changing to water and then to steam. The parameters change and the effects explode, cascading across the rest of your workflow with mounting consequences. As somebody who works in the field of chaos theory (for whatever that’s worth), I confirm Dmckee’s assessment: There is no reasonable relation to any concepts from chaos theory.
There is, however, an attempt in your quote to relate this to the phenomenon of criticality – which is not chaos theory, but like chaos theory is related to the field of complex systems.
Applied to e-mails, the concept of criticality can be summarised as follows:
Let $φ$ be the average number of e-mails sent as a consequence of a given e-mail.
If $φ<1$ and there is no mechanism (other than other e-mails) causing people to sent e-mails, e-mails will eventually die out.
If $φ>1$, there is an exponentially growing cascade of e-mails and we will eventually drown in them.
Therefore, there is a critical point at $φ=1$ separating the two phases described above and marking a phase transition.
However, I cannot see any reasonable connection of the above concept to your quote. The time a given person spends on e-mails does not affect $φ$ in general and thus there is no critical point to cross when increasing the time you spend on e-mails. Moreover, this is neither unpredictable nor invisible nor is there a cascade involving the rest of one’s workflow.
Finally, I fail to see any other way to apply the concept of criticality to e-mails. | {
"domain": "physics.stackexchange",
"id": 28057,
"lm_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, soft-question, phase-transition, chaos-theory, critical-phenomena",
"url": null
} |
Anyway if the above equations looks insane then please solve it yourself, your way. I could have drifted into some very complicated path.
• @Peter: But the subsequent equations 21 and 22 make it seem difficult to integrate the given information about the semi-axes into that approach. – joriki Jul 22 '11 at 14:21
• I was hoping this would involve using an eccentric anomaly but seems you guys have solved without :) – Alice Jul 22 '11 at 16:59
Let the points be $P_1(x_1, y_1)$ and $P_2(x_2, y_2)$, assumed to lie on an ellipse of semiaxes $a$ and $b$ with the $a$ axis making angle $\alpha$ to the $x$ axis.
Following @joriki, we rotate the points $P_i$ by $-\alpha$ into points
$$Q_i(x_i \cos(\alpha) + y_i \sin(\alpha), y_i \cos(\alpha) - x_i \sin(\alpha)).$$
We then rescale them by $(1/a, 1/b)$ to the points
$$R_i(\frac{x_i \cos(\alpha) + y_i \sin(\alpha)}{a}, \frac{y_i \cos(\alpha) - x_i \sin(\alpha)}{b}).$$
These operations convert the ellipse into a unit circle and the points form a chord of that circle. Let us now translate the midpoint of the chord to the origin: this is done by subtracting $(R_1 + R_2)/2$ (shown as $M$ in the figure) from each of $R_i$, giving points
$$S_1 = (R_1 - R_2)/2, \quad S_2 = (R_2 - R_1)/2 = -S_1$$
each of length $c$. Half the length of that chord is | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9766692339078752,
"lm_q1q2_score": 0.8138825001641988,
"lm_q2_score": 0.8333246015211008,
"openwebmath_perplexity": 628.2376138023106,
"openwebmath_score": 0.727946400642395,
"tags": null,
"url": "https://math.stackexchange.com/questions/53093/how-to-find-the-center-of-an-ellipse"
} |
spectroscopy, experimental-technique, signal-processing, noise
Title: Noise reduction approaches in optical spectral measurement I am using an optical spectrometer to measure some surfaces in the visible, and since the signal is quite noisy I wondering what would be the best way to reduce the noise.
In particular, are there some computational solutions to characterize the noise and then filter it, as it is used in signal processing (e.g. something like the optimum filtering)? The most common noise filter used in spectroscopy is the Savitzky-Golay algorithm. It requires equally spaced data on the x-axis. SG is basically a least squares polynomial fit to the data with the center point being replaced by the calculated result. The filter can be generated by partially solving the least matrix equation with the final computation being a convolution of the smoothing function with the data. See the original paper by SG. Be aware there are a couple of mistakes in it. To understand the fine details of SG smoothing see Willson and Polo, J. Opt. Soc. Am., V71 (1981), p599. SG filters can also generate derivative spectra. | {
"domain": "physics.stackexchange",
"id": 55400,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "spectroscopy, experimental-technique, signal-processing, noise",
"url": null
} |
So we must have $\frac{x\sqrt{2}}{\sqrt{3}}+ \frac{y}{\sqrt{2}}= 0$ and $\frac{x\sqrt{2}}{\sqrt{3}}+ \frac{y}{\sqrt{2}}= 0$, the equation of the two straight line asymptotes. Solving for y, we have $y= \pm\frac{2}{\sqrt{3}}x$ as Archie Meade says.
5. Originally Posted by Archie Meade
$\displaystyle\frac{2x^2}{3}-\frac{y^2}{2}=1\Rightarrow\ y^2=\frac{4x^2}{3}-2\Rightarrow\ y=\pm\frac{\sqrt{4x^2-6}}{\sqrt{3}}$
$\Rightarrow\ y=\displaystyle\pm\frac{x\sqrt{4-\frac{6}{x^2}}}{\sqrt{3}}$
and as $x\rightarrow\infty$, this is $\displaystyle\ y=\pm\frac{2x}{\sqrt{3}}$
Technically, the generalised binomial theorem should be used to find this limit.
6. Hello, Joker37!
$\text{Find the asymptotes for the hyperbola: }\:\dfrac{2x^2}{3} - \dfrac{y^2}{2}\:=\:1$
We're expected to be familiar with this fact:
Given the hyperbola: . $\dfrac{x^2}{a^2} - \dfrac{y^2}{b^2} \:=\:1$, the asymptotes are: . $y \;=\;\pm\dfrac{b}{a}x$ | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9755769071055402,
"lm_q1q2_score": 0.8021087311356557,
"lm_q2_score": 0.8221891327004133,
"openwebmath_perplexity": 14353.243569736958,
"openwebmath_score": 0.940919816493988,
"tags": null,
"url": "http://mathhelpforum.com/pre-calculus/166668-asymptotes-hyperbolas.html"
} |
javascript, jquery, json, ecmascript-6, quiz
$('main').html(`
<section>
<h3>Quiz completed! Points earned: <strong>${points}/${maxPoints} (${pointsPercent}%)</strong></h3>
<p class="huge-font m-y-sm">${jsonResultsData.results[resultGroupIndex].title}</p>
<div class="img-container-medium"><img src="${jsonResultsData.results[resultGroupIndex].img}" alt="Result image"></div>
<p class="p-b-md">${jsonResultsData.results[resultGroupIndex].message}</p>
</section>
`);
})
.fail(() => {
alert('Your result is not available at the moment! Please try again later.');
});
}
I use global variables and all my functions have global scope because, in my HTML file, I have this:
<button id="next-btn" onclick="nextButtonClicked()">Submit</button>
Since my HTML button references the function nextButtonClicked(), that function has to have global scope. This function eventually ends up calling all the other functions and also needs to use the global variables, so I have also given them global scope.
However, I’m not sure if this is the best way to go about solving this problem. Also, I’m wondering if it would be a good idea to use namespaces and how.
Moreover, the only ES6 features I’m using are arrow functions, let and const. Are there other ES6 features that I can incorporate? Your Questions
However, I am not sure if [having the function nextButtonClicked() in the global scope] is the best way to go about solving this problem. | {
"domain": "codereview.stackexchange",
"id": 29780,
"lm_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, json, ecmascript-6, quiz",
"url": null
} |
# Making Friends around a Circular Table
I have $n$ people seated around a circular table, initially in arbitrary order. At each step, I choose two people and switch their seats. What is the minimum number of steps required such that every person has sat either to the right or to the left of everyone else?
To be specific, we consider two different cases:
1. You can only switch people who are sitting next to each other.
2. You can switch any two people, no matter where they are on the table.
The small cases are relatively simple: if we denote the answer in case 1 and 2 for a given value of $n$ as $f(n)$ and $g(n)$ respectively, then we have $f(x)=g(x)=0$ for $x=1, 2, 3$, $f(4)=g(4)=1$. I’m not sure how I would generalize to larger values, though.
(I initially claimed that $f(5)=g(5)=2$, but corrected it based on @Ryan’s comment).
If you’re interested, this question came up in a conversation with my friends when we were trying to figure out the best way for a large party of people during dinner to all get to know each other.
Edit: The table below compares the current best known value for case 2, $g(n)$, to the theoretical lower bound $\lceil{\frac{1}{8}n(n-3)}\rceil$ for a range of values of $n$. Solutions up to $n=14$ are known to be optimal, in large part due to the work of Andrew Szymczak and PeterKošinár.
The moves corresponding to the current best value are found below. Each ordered pair $(i, j)$ indicates that we switch the people in seats $(i, j)$ with each other, with the seats being labeled from $1 \ldots n$ consecutively around the table. | {
"domain": "mathzsolution.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9763105335255603,
"lm_q1q2_score": 0.8027119108056582,
"lm_q2_score": 0.8221891327004133,
"openwebmath_perplexity": 393.18322915846085,
"openwebmath_score": 0.669754147529602,
"tags": null,
"url": "https://mathzsolution.com/making-friends-around-a-circular-table/"
} |
quantum-field-theory, quantum-chromodynamics, lie-algebra, gluons
Title: What is the QCD gluon field (mathematically)? In QCD, the gluon field is described as $A^a_\mu$. In the covariant derivative for the Lagrangian, it is multiplied by the Gell-Mann $SU(3)$ generator matrices $\lambda_a$ ($a=1..8$) as $\lambda_aA^a_\mu$. My question is, what is the mathematical structure of $A_\mu$ (for a given a)? Since $\mu=0..3$, it must have 4 components (I'm assuming $\mu$ does not mean $A(x_\mu)$), but the $\lambda$'s are $3\times 3$ matrices. Since $\lambda$ is a 3x3 matrix, and $A_\mu$ is a 1x4 vector, how can the two be "multiplied" together?
Is each element of $A_\mu$ a $3\times 3$ matrix? If not, then what? Or does the notation $\lambda_aA^a_\mu$ mean something other than normal matrix multiplication is going on in this case?
What is the mathematical structure of $\lambda_aA^a_\mu$ (like, a 1x4 vector, or 3x3 matrix, or a 1x4 vector of 3x3 matrices)?
What does an element of $A_\mu$ represent physically? $A$ is a $4$-vector taking values in $3 \times 3$ matrices. More precisely, it's a dual $4$-vector taking values in the Lie algebras $su(3)$, which is an 8-dimensional subspace of the 9-dimensional space of $3\times 3$ matrices.
If you pick coordinates $x^\mu$ on spacetime, you get a basis $dx^\mu$ for the dual vectors and you can expand $A = \sum_\mu A_\mu \otimes dx^\mu$. Each component $A_\mu$ lives in $su(3)$, i.e., is a $3\times 3$ matrix. | {
"domain": "physics.stackexchange",
"id": 67994,
"lm_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, quantum-chromodynamics, lie-algebra, gluons",
"url": null
} |
algorithms
Title: Optimal stacking of bricks I need an algorithm to optimally stack a set of bricks in a 2D plane so that the resulting wall is as vertically short as possible. Bricks are defined as a pair of integers $(x_1, x_2)$ corresponding to the horizontal span of $\textit{width} = x_2 - x_1$ and are of equal height. Bricks cannot be translated left or right, they are only allowed to "fall" in place vertically from their original horizontal position. This is conceptually similar to a game of Tetris where instead of moving bricks, the player decides the order in which they fall.
For example, in the following figure, arrangement A is the worst possible while B and C are equally optimal. The numbers inside the bricks indicate a possible stacking order.
Bricks can number in the thousands so exhaustive evaluation of all possible permutations is not conceivable. Consider a graph whose vertices are the intervals, and whose edges correspond to intersecting intervals. This is an example of an interval graph.
In a solution, all intervals on a given row of the solution are non-intersecting. Therefore, if we color each interval according to the line it is on, we get a valid coloring of the graph. Conversely, given a valid coloring of the graph, we get a solution to your problem whose height is the number of different colors: simply drop all intervals colored 1, then all intervals colored 2, and so on.
In other words, your problem is reducible to interval graph coloring, which can be solved efficiently. | {
"domain": "cs.stackexchange",
"id": 19139,
"lm_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",
"url": null
} |
meteorology, atmosphere, thermodynamics, radiosounding
Title: Pressure of condensation of an air parcel If a parcel of air ascends adiabatically, would condensation be reached at the lifting condensation level (LCL) or the level of free condensation (LFC)? The lifting condensation level (LCL) is the level at which a rising particle reaches 100 % relative humidity by adiabatic cooling.
Please have a look at Wikipedia: LCL and LFC (level of free convection!). | {
"domain": "earthscience.stackexchange",
"id": 267,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "meteorology, atmosphere, thermodynamics, radiosounding",
"url": null
} |
java, strings, array
System.out.println("Both strings of characters are equivilent.");
else
System.out.println("Different");
}
} This is where the Arrays utility class comes in handy. You can use it to sort the character arrays underlying both strings and then compare the sorted character arrays:
public static boolean equivalent(String s1, String s2) {
char[] chars1 = s1.toCharArray();
char[] chars2 = s2.toCharArray(); | {
"domain": "codereview.stackexchange",
"id": 10769,
"lm_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, strings, array",
"url": null
} |
robotic-arm, ros, ubuntu
Originally posted by ahendrix with karma: 47576 on 2014-10-28
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by Alice63 on 2014-10-29:
Thanks.It helped me a lot indeed.But is there a way can installing ros on the armhf version of Ubuntu.
Comment by ahendrix on 2014-10-29:
The instructions for installing an armhf version of Ubuntu on your board will depend on which board you're using.
Comment by Alice63 on 2014-10-30:
If I use the armel version of ubuntu go on.Can I install ros from source on arm according to this page http://wiki.ros.org/groovy/Installation/Source
Comment by ahendrix on 2014-10-30:
It's possible to do a from-source build on armel, but it takes a few days to run the compilation, and there will be packages like PCL that can't be compiled because some boards don't have enough RAM.
Comment by ahendrix on 2014-10-30:
Your time will be better spent finding and installing an armhf version of Ubuntu or Linaro. | {
"domain": "robotics.stackexchange",
"id": 19865,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "robotic-arm, ros, ubuntu",
"url": null
} |
quantum-mechanics, quantum-spin, conventions, lie-algebra
Title: The order of Pauli matrices Is there any special reason why Pauli matrices are:
$\sigma _1=\left(
\begin{array}{cc}
0 & 1 \\
1 & 0 \\
\end{array}
\right)$, $\sigma _2=\left(
\begin{array}{cc}
0 & -i \\
i & 0 \\
\end{array}
\right)$, $\sigma _3=\left(
\begin{array}{cc}
1 & 0 \\
0 & -1 \\
\end{array}
\right)$
and not for example
$\sigma _1=\left(
\begin{array}{cc}
0 & -i \\
i & 0 \\
\end{array}
\right)$, $\sigma _2=\left(
\begin{array}{cc}
0 & 1 \\
1 & 0 \\
\end{array}
\right)$, $\sigma _3=\left(
\begin{array}{cc}
1 & 0 \\
0 & -1 \\
\end{array}
\right)$ ?
Will the reason be applicable to Gell-Mann matrices ? Under the convention that $1 \leftrightarrow x, 2 \leftrightarrow y, 3 \leftrightarrow z$, the ordering we have ties to the actions performed about $x, y, z$ axes.
In the context of Pauli's work, $σ_k$ represents the observable corresponding to spin along the $k^{\text{th}}$ coordinate axis in three-dimensional Euclidean space $\mathbb{R}^3$.
Also, the Bloch sphere rotations follow that $\exp(i\sigma_{k}\theta)$ rotates the sphere by $\theta/2$ about $k^{\text{th}}$ axis. | {
"domain": "physics.stackexchange",
"id": 67747,
"lm_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-spin, conventions, lie-algebra",
"url": null
} |
general-relativity, differential-geometry, differentiation, covariance
}$ coincides with the ordinary one $\left( 0,\mathbf{a}\right) $.
And vice versa, $DU^{\mu}=0$ means that $U^{\mu}$ is constant in the
locally-internal frame although it does imply that it is constant in any
other frame, in fact $dU^{\mu}=\delta U^{\mu}$ implies that a free-fall
trajectory is actually a parallel translation in GR, which (for an external
observer) looks like the action of gravitational forces. | {
"domain": "physics.stackexchange",
"id": 5869,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "general-relativity, differential-geometry, differentiation, covariance",
"url": null
} |
The Second Conjecture
The above discussion shows that a complete solution to the three conjectures hinges on the resolution of the second conjecture. A partial resolution came in 1986 [6]. In that paper, it was shown that under V = L, conjecture II is true.
The complete solution of the second conjecture is given in a paper of Balogh [5] in 2001. The path to Balogh’s proof is through a conjecture of M. E. Rudin identified as Conjecture 9.
Rudin’s Conjecture 9. There exists a normal P-space $X$ such that some uncountable increasing open cover of $X$ cannot be shrunk.
Conjecture 9 was part of a set of 14 conjectures stated in [14]. It is also discussed in [7]. In [6], conjecture 9 was shown to be equivalent to Morita’s second conjecture. In [5], Balogh used his technique for constructing a Dowker space of cardinality continuum to obtain a space as described in conjecture 9.
The resolution of conjecture II is considered to be one of Balogh greatest hits [3].
Abundance of Non-Normal Products
One immediate observation from Morita’s conjecture I is that existence of non-normal products is wide spread. Conjecture I indicates that every normal non-discrete space $X$ is paired with some normal space $Y$ such that their product is not normal. So every normal non-discrete space forms a non-normal product with some normal space. Given any normal non-discrete space (no matter how nice it is or how exotic it is), it can always be paired with another normal space (sometimes paired with itself) for a non-normal product. | {
"domain": "wordpress.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9843363499098282,
"lm_q1q2_score": 0.8366575264457774,
"lm_q2_score": 0.8499711775577736,
"openwebmath_perplexity": 148.87961063114636,
"openwebmath_score": 0.9994206428527832,
"tags": null,
"url": "https://dantopology.wordpress.com/tag/point-set-topology/"
} |
c++, c++11, socket
A simple client of this API might look something like:
main.cpp
#include "socket.h"
#include "socketset.h"
#include <memory>
#include <iostream>
#include <algorithm>
int main(){
std::vector<std::shared_ptr<Socket>> sockets;
auto listen_socket = std::make_shared<ListenSocket>(33333);
SocketSet ss;
ss.add_socket(std::static_pointer_cast<Socket>(listen_socket));
while (true){
if (ss.poll(500)){
while (auto sock = ss.get_next()){
try {
if(sock->has_error) {
throw std::runtime_error("bad poll");
}
if(sock == listen_socket){
auto ds = std::make_shared<DataSocket>(listen_socket->accept());
ss.add_socket(ds);
sockets.push_back(std::static_pointer_cast<Socket>(ds));
} else {
auto s = std::static_pointer_cast<DataSocket>(sock);
char buf[5];
s->recv(buf, 4);
buf[5] = '\0';
std::cout << buf << std::endl;
}
} catch (const std::runtime_error &e){
ss.remove_socket(sock);
sockets.erase(std::remove_if(sockets.begin(), sockets.end(), [sock](std::shared_ptr<Socket> s){
return s == sock;
}));
}
}
}
}
} | {
"domain": "codereview.stackexchange",
"id": 21145,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, c++11, socket",
"url": null
} |
python, performance, simulation, scipy
Title: Epidemic simulation The purpose of this code is to simulate epidemics across a population. There are 625 (pop) individuals at random locations. The epidemic parameters are infectious period (inf_period), trans (transmissibility of the disease - essentially virulence), susc (the susceptibility of each individual to the disease), and eps (epislon, the probability of an individual becoming infectious randomly, not due to contact with an infectious person). The argument 'reps' is the number of times to simulate one set of epidemic parameters - that is, one set of [susc, trans, inf_period, eps].
In this example, there are 24 possible combinations of parameter values, and we want 400 reps per combination, so 24*400 = 9600 runs. Those values cannot change. To make this code faster, how can the number of loops be reduced (I've heard those are slow)?
This has many loops and if statements, and to run the full version will take roughly 2.5 days. How can it be made more efficient in terms of time? I know that may be vague, so if there's a way I can clarify please let me know! I should also mention I have access to a GPU.
import numpy as np
from scipy import spatial
import json
def fun(susc, trans, inf_period, eps, reps, pop):
epi_list = []
count_list = []
new_susc = []
new_trans = []
new_inf_period = []
new_eps = []
count = 0
epi_file = "file1.json"
count_file = "file2.json"
with open(epi_file, 'w') as f, open(count_file, 'w') as h: | {
"domain": "codereview.stackexchange",
"id": 23419,
"lm_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, simulation, scipy",
"url": null
} |
quantum-mechanics, electromagnetism, speed-of-light, photons
Title: Can a force stop a Photon since Photons have momentum and What does momentum mean when talking about massless particles? Momentum measures how hard it is to stop an object. While Photons are massless they still have relativistic mass and energy. My question is can something stop photons other than being absorbed by something?
What does momentum mean when talking about massless particles? Your question is not quite accurate, this because you thinking of Photon as a classical particle (solid ball), but it's not, photon (same as other particles) are quantum particles, thus you should consider particle-wave duality, in other hand, because photon has no mass, it can't move at any speed other than speed of light (In vacuum), otherwise it will not exist.
Finlay, the momentum of massless particle, can be thought of as "amount of motion" , or even more directly, it is related actually not to speed of photon (like in classical physics) but to wave length by the following famous De Broglie relation:
$$ p=\frac{h}{\lambda}$$
Thus there is no sense of saying "stopping a photon" in vacuum, it can exist only in motion and strictly at speed of light, or "absorbed" fully or partially, what will change it's energy/momentum, but not it's speed!
P.S
The situation is more complicated for photons in some media, anyway one can slow down and maybe "even freeze" them. | {
"domain": "physics.stackexchange",
"id": 8707,
"lm_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, electromagnetism, speed-of-light, photons",
"url": null
} |
navigation, ros-kinetic, ubuntu, robot-localization, ubuntu-xenial
So i get it that problem is with my workspace. I deleted my build and devel folders, then istalled the package again, but still having the same isssue. i see something about deleting the workspace and creating new, but i am not sure ho to do that. Also if i do that, will my other packages and data be removed? OR what could be the alternative to use this package and clean my workspace?
Comment by mgruhler on 2019-09-27:\
deleted my build and devel folders, then istalled the package again
What do you mean by that? Did you apt-get install the package ros-kinetic-robot-localization again? Or did you clone it from scratch?
Call find <YOUR_WORKSPACE> -name robot_localization and delete this package when you find it. Then remove the build and devel folder, recompile your workspace, source it again and check. Also, make sure that you haven't chained other workspaces.
If anything I say above is not clear, please exactly state what you don't understand and also what you have tried (i.e. the commands). Also post the relevant outputs.
Please do all that by editing your OP.
Comment by mgruhler on 2019-09-30:
@enthusiast.australia so is your question solved now? If yes, you can post this as an answer and accept that.
Actually, what you describe above is exactly what I was referring to with cleaning your workspace. I should have been more explicit about the single steps, probably...
You shouldn't have to do that again. So basically what you did was to newly set up your workspace chaining and recompile everything.
Comment by Tom Moore on 2019-11-18:
Did you figure this issue out?
From the edited OP:
Update: Apparently this worked for
me...
First try, source
/opt/ros/kinetic/setup.bash, then
roslaunch robot_localization
ekf_template.launch. If it work? If
so, then need to catkin clean the
workspace, source
/opt/ros/kinetic/setup.bash, catkin
build workspace, then workspace cd
devel then source setup.bash file. | {
"domain": "robotics.stackexchange",
"id": 33791,
"lm_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, ros-kinetic, ubuntu, robot-localization, ubuntu-xenial",
"url": null
} |
electromagnetism, electricity, magnetic-fields, electric-current
Title: Electromagnetic induction - How is the polarity of an uncoiled wire determined? Using the right-hand rule, we can determine the solenoid's polarity. So when we move a magnet towards a solenoid devoid of a current, the current flows so as to make the nearest side of the solenoid repel the magnet (because the field of a current always acts against the field inducing it). I understand how this works with solenoids, but this also seems to work with non-solenoid wires!
Take the diagram I drew up here. Since I haven't experimented this out, I just assumed it this way. Does it make sense that the current (and the resultant field of the wire) is induced this way if the bar magnet's N-pole is moved downwards relative to the wire? Yes or no, explain how the polarity is determined in the wire? Because the resulting current would depend on it? Where is the "N-pole" of the wire? The magnetic field is a solenoidal vector field, thus its force lines do not have the beginning and the ending.
Regarding the magnets, their magnetic force lines are closed inside them. The magnetic poles of the magnet are the areas where these lines densely exit this object. The same is valid for solenoid as it is an electric magnet.
Strait-forward current (in a wire) produces just a circular magnetic field around itself (no matter how this current is generated). Thus, it's quite difficult to select any area where the magnetic field lines leave the wire more densely. Thus, I would say that an isolated wire doesn't have magnetic pole. | {
"domain": "physics.stackexchange",
"id": 65332,
"lm_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, electricity, magnetic-fields, electric-current",
"url": null
} |
So in general, if I give you a polynomial of two variables, which can be written down-- it's degree n in both x and y. Let's just keep these indexes away from the matrix index. I give you this such polynomial, and I go away and I sample it and make a matrix X, then X, by looking at each term individually like I did there, will have low rank mathematically, with epsilon equals zero. This will have, at most, m squared rank, and if m is 3 or 4 or 10, it possibly could be low because this X could be a large matrix. OK.
So what Reade did for the Hilbert matrix was said, OK, well look at that guy. That guy looks like it's sampling a function. It looks like it's sampling the function 1 over x plus y minus 1. So he said to himself, well, that x, if I look at the Hilbert matrix, then that is sampling a function. It happens to not be a polynomial. It happens to be this function.
But that's OK because sampling polynomials, integers, gives me low rank exactly. Maybe sampling smooth functions, functions like this, can be well approximated by polynomials and therefore have low numerical rank. And that's what he did in this case. So he tried to find a p, a polynomial approximation to f. In particular, he looked at exactly this kind of approximation. So he has some numbers here so that things get dissolved later. And he tried to find a p that did this kind of approximation. So this approximates f.
And then he would develop a low-rank approximation to X by sampling p. So he would say, OK, well if I let y be a sampling of p, then from the fact that f is a good approximation to p, y is a good approximation to X. And so this has finite rank. He wrote down that this must hold. And the epsilon comes out here because these factors were chosen just right. The divide by n was chosen so that the epsilon came out just there. OK? | {
"domain": "mit.edu",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9898303440461105,
"lm_q1q2_score": 0.8527766569715394,
"lm_q2_score": 0.8615382040983515,
"openwebmath_perplexity": 398.4738235841221,
"openwebmath_score": 0.7443466186523438,
"tags": null,
"url": "https://ocw.mit.edu/courses/mathematics/18-065-matrix-methods-in-data-analysis-signal-processing-and-machine-learning-spring-2018/video-lectures/lecture-17-rapidly-decreasing-singular-values/"
} |
javascript, performance
0PcHzDz9sJgqLSoG5BWbwhRf08ZkzPy1tgcrn14WUEh5QkrEx8i++iD5yZOqr8vHHb7u9rBljEIC7YAHe1avocrtAWCmhHGcNgPxHJFJjJRJS9fXhAapc2fOw16/HO3ZsmmwyNbjq78eDuwioH35AxuPBnkikWmqt51uxGM7ISAm8nIQGnLVr0V98cc/MVgR3kklU2cpVmU0XcEZGsGpr0bBQGq1jxrJQjnOXoiqTiTVr8Hp7p0+tQmA3NKAGBiq+LbfpAcpxQEo8raulp3VW2TZKCFRBKV/4yC0jIjo6sFavvqcXAh98gLKsuwiU21RC4No2Rqms1J43aI+O4oXDFYBumVgdHUQPHrx9yUzTrOXLqe7tRYVCFTbKbepIhNzwMK7W/bIN0rlUSnvRaEkhXxAXCHR0UFsEF+J+CigCK1dS88knqGi0ZKvcpqquxh4bc9uNycpCRurJWZZx7lh5eNMm6g4exExx1HQ2OyWJ8Lp1zDx0CFf | {
"domain": "codereview.stackexchange",
"id": 2380,
"lm_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, performance",
"url": null
} |
So the conventional assumption that multiplication and division are operations of equal status and are carried out from left to right does make a difference in these cases and changes the result. This may be what is feeding your intuition that there is a potential problem with order.
• I don't understand what you are trying to say. How is this any different than with addition and subtraction? If you interpret $a-b+c$ as $a-(b+c)$ then you get a different answer. But you shouldn't do that, so what? See also my answer. Mar 4, 2019 at 13:29
• @MarcvanLeeuwen You are right that it is essentially the same and also that you shouldn't do it - but the fact is that people do get these things confused. If you use BIDMAS (brackets, indices, division, multiplication, addition, subtraction) as a rule, applied without proper procedural knowledge, as I have seen in English Primary Schools, then in your example you would get the second, wrong, answer by doing the addition first and the subtraction afterwards. Mar 4, 2019 at 17:06
Because division is the inverse of multiplication, that is: $$X \div Y =X\cdot \frac 1Y$$
So you have: $$56\cdot 100 \cdot \frac18 =56\cdot\frac18\cdot100$$ Which is obvious.
• While it is true that "division is the inverse of multiplication" the emphasis should be on what follows from it: That division is equivalent to multiplication with the inverse and can be replaced by it. Feb 18, 2019 at 8:14
Swap the first two factors which is definitely allowed: 100 × 56 ÷ 8.
Now put parentheses around part of it: 100 × (56 ÷ 8).
Again, swap: (56 ÷ 8) × 100.
Take off the parentheses: 56 ÷ 8 × 100.
And there you go! transforming one into the other using only multiplicative commutation (plus the fact that one of the factors commutated can be a product, not just a simple value). | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446440948805,
"lm_q1q2_score": 0.8388320650263343,
"lm_q2_score": 0.861538211208597,
"openwebmath_perplexity": 427.00217653259944,
"openwebmath_score": 0.8882524967193604,
"tags": null,
"url": "https://math.stackexchange.com/questions/3117260/how-is-rearranging-56-times-100-div-8-into-56-div-8-times-100-allowed-by-the/3117265"
} |
• Thanks. Little-O is apt for comparing $2^n$ with $2^{2n}$ – sanjeev mk Feb 16 '14 at 5:44
Remember that $O$ is an upper bound.
$2^n = O(2^{2n})$, but $4^n = 2^{2n} \ne O(2^n)$. I.e., $2^{2n}$ is not within a constant factor of $2^n$.
The statement:
If $f(n)=O(g(n))$ then for large $n$ , $f(n)$ would grow as fast as $g(n)$.
is incorrect, and that's probably where your confusion is. Taking from Raphael's answer in How does one know which notation of time complexity analysis to use? :
$f \in \cal{O}(g)$ means that $f$ grows at most as fast as $g$...
Note "at most as fast," not "as fast." If you want "as fast," you're probably looking for $\Theta$; taking from Raphael's answer again:
$f \in \Theta(g)$ means that $f$ grows about as fast as $g$...
but as you've already probably guessed, $2^n \notin \Theta(2^{2n})$. For $2^n \in \Theta(2^{2n})$ to be true, $2^{2n}$ would itself have to be $\cal{O}$$(2^n)$, which I think you can see is clearly not the case.
• Thanks Dennis. From Raphael's answer and especially about $<$ being stricter than $<=$ , it is clear that $2^n = o(2^{2n})$ , because $2^n$ for all positive constants $c$ will be strictly smaller than $c *\space 2^{2n}$ – sanjeev mk Feb 16 '14 at 5:46 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9748211575679041,
"lm_q1q2_score": 0.8123424385615514,
"lm_q2_score": 0.8333245870332531,
"openwebmath_perplexity": 355.88155601549016,
"openwebmath_score": 0.9534617066383362,
"tags": null,
"url": "https://cs.stackexchange.com/questions/21675/big-o-relation-between-2n-and-22n/21677"
} |
java, javascript, css, spring, spring-mvc
model.put("question", q);
model.put("authorized", (user != null));
return "question";
}
}
RegistrationController:
package com.sstu.StackCanary.controllers;
import com.sstu.StackCanary.domain.Role;
import com.sstu.StackCanary.domain.User;
import com.sstu.StackCanary.repositories.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import java.util.Collections;
import java.util.Map;
@Controller
public class RegistrationController {
@Autowired
private UserRepository userRepository;
@GetMapping("/registration")
public String main(Map<String, Object> model) {
return "registration";
}
@PostMapping("/registration")
public String registerUser(User user, Map<String, Object> model) {
if (userWithThisUsernameAlreadyExists(user)) {
model.put("userWithThisUsernameAlreadyExistsMessage", "User with this username already exists.");
return "registration";
}
user.setActive(true);
user.setRoles(Collections.singleton(Role.USER));
userRepository.save(user);
return "redirect:/login";
}
private boolean userWithThisUsernameAlreadyExists(User u) {
return userRepository.findByUsername(u.getUsername()) != null;
}
}
VotesController:
package com.sstu.StackCanary.controllers; | {
"domain": "codereview.stackexchange",
"id": 38424,
"lm_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, javascript, css, spring, spring-mvc",
"url": null
} |
quantum-mechanics, quantum-information, quantum-entanglement
Title: Is this entanglement of formation identity true? Let a tripartite system be given with pure state $\rho_{ABC}$. My adviser said that the entanglement of formation satisfies the identity
$${E_F}_{A(BC)}^2={E_F}_{AB}^2+{E_F}_{AC}^2$$
Where ${E_F}_{A(BC)}$ is the entanglement of formation considering the bipartite state with parts $A$ and $B+C$.
He further said that ${E_F}_{A(BC)}^2=S_A^2$ the Von-Neumman entropy, and that because of that if we know ${E_F}_{AB}$ we get ${E_F}_{AC}$ by means of
$${E_F}_{AC}^2=S_B^2-{E_F}_{AB}^2.$$
Now is this identity true? He couldn't point me the specific reference, and I've tried searching and found none.
That ${E_F}_{A(BC)}=S_A$ is obvious because the entanglement of formation reduces to the entanglement entropy for pure states. Since $\rho_{ABC}$ is pure, considered a bipartite state between $A$ and $B+C$ it is pure, and the entanglement of formation is the entropy.
My doubt is about the very first identity. If it is true, why is it the case? No. A counterexample is the tripartite GHZ state $|000\rangle+|111\rangle$. | {
"domain": "physics.stackexchange",
"id": 54818,
"lm_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-information, quantum-entanglement",
"url": null
} |
performance, c, cython, radix-sort
typedef int (* CmpFuncC)(const void *, const void *);
typedef uint8_t (* RadixKeyFuncC)(void *item, size_t byte_offset);
typedef struct RadixPartitionTableC
{
size_t counts[RADIX];
size_t prefix_sums[RADIX + 1];
size_t shifted_sums[RADIX + 1];
} RadixPartitionTableC;
void table_clear(RadixPartitionTableC *table)
{
memset(table->counts, 0, sizeof(size_t) * RADIX);
memset(table->prefix_sums, 0, sizeof(size_t) * (RADIX + 1));
memset(table->shifted_sums, 0, sizeof(size_t) * (RADIX + 1));
}
void item_swap(void *items, size_t a, size_t b, size_t size)
{
uint8_t *a_ptr = (uint8_t *)items + (a * size);
uint8_t *b_ptr = (uint8_t *)items + (b * size);
uint8_t tmp;
for(size_t i = 0; i < size; i++)
{
tmp = a_ptr[i];
a_ptr[i] = b_ptr[i];
b_ptr[i] = tmp;
}
} | {
"domain": "codereview.stackexchange",
"id": 43799,
"lm_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, cython, radix-sort",
"url": null
} |
If you restrict yourself to changes of this kind that don't change any real coefficients to complex coefficients, you'll achieve all real coefficient polynomials with the same roots this way.
** Note - For quintics and higher, we may not be able to factorise to simple algebraically expressed roots, because not all 5th and higher order polynomials allow for neat expressions of their roots this way. But - even if inexpressible - the roots do exist, the limitation is in our ability to calculate them exactly, or write them concisely, not in their existence. The same method will work and be valid, and the same other types of polynomials will have identical complex (or real) roots. We just wouldn't be able to calculate or write the linear expressions, transformative equations, or roots, neatly, in the same way.
• please learn to use MathJax – qwr Jun 7 '19 at 14:03
• This answer should really be upvoted – klutt Jun 9 '19 at 18:57
Arthur answered your question very nicely, but I'd like to tell you a much more general result that might pique your interest in a field of math called "algebraic geometry". So – if we are working in an algebraically closed field, say the complex numbers $$\mathbb{C}$$, then every polynomial in one variable splits completely into linear factors. As the other answers say, this is enough to show that one variable complex polynomials are uniquely determined by their roots, up to multiplicity and multiplication by a constant: if the roots of a polynomial $$p(t)$$ are some complex numbers $$\lambda_1,...,\lambda_k\in\mathbb{C}$$, then that polynomial must be $$\lambda(t-\lambda_1)^{l_1}...(t-\lambda_k)^{l_k}$$ for some non-zero complex number $$\lambda$$ and some non-zero natural numbers $$l_1,...l_k$$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9724147193720649,
"lm_q1q2_score": 0.844859942495807,
"lm_q2_score": 0.8688267728417087,
"openwebmath_perplexity": 221.77604056815792,
"openwebmath_score": 0.8442171812057495,
"tags": null,
"url": "https://math.stackexchange.com/questions/3253240/are-polynomials-with-the-same-roots-identical"
} |
reference-request
*Teached is a form that isn't taught anywhere and is no part of STANDARD ENGLISH. But it sometimes appears –
and offers some examples of it appearing by mistake in American newspaper articles.
The en.wiktionary entry for teached labels it as “nonstandard, colloquial, dialectal” and offers some dialectal examples.
In short, use taught, not teached. But note that rather than referring to a robot “replaying a collection of taught poses”, more often one refers to it “replaying a collection of learned poses”, making the viewpoint that of the taught instead of of the teacher. | {
"domain": "robotics.stackexchange",
"id": 604,
"lm_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",
"url": null
} |
acid-base
Title: Defining general acidic strength The $K_\mathrm{a}$ or $K_\mathrm{b}$ values provide an idea of how likely a specific step is to happen.
However, how do you specify one acid just being stronger than another, as in the case of $\ce{H2CO3}$ $(\mathrm{p}K_\mathrm{a1} = 3.6,$ but $\mathrm{p}K_\mathrm{a2} = 10.32)$ and phenol $(\mathrm{p}K_\mathrm{a} = 9.95)?$ How do you compare them? According to the Brønsted-Lowry acid base theory, an acid is a compound that releases a $\ce{H+}$ ion to give a conjugate base. For most acids, this reaction exists in a dynamic equilibrium. The equilibrium constant of this reaction is what defines $K_\mathrm{a}$. Generally more stable the product, the more of the forward reaction takes place.
Using this last statement, when comparing two compounds, we can say that if the conjugate base of one compound is more stable, it would mean that the value of its $K_\mathrm{a}$ would be greater. This implies its $\mathrm{p}K_\mathrm{a}$ would be less, meaning that the compound would be more acidic than the other.
For example, taking the case of two compounds, $\ce{HCOOH}$ and $\ce{C6H5-OH}$: Here formate ion would have resonance via oxygen whereas phenoxide ion would have resonance via carbon. This makes phenol less acidic than formic acid.
$\mathrm{p}K_\mathrm{a} \ {\text{ of phenol} = 10.0}$
$\mathrm{p}K_\mathrm{a} \ {\text{ of formic acid} = 3.75}$
Now, if we consider polyprotic acids, we can only consider one hydrogen at a time. Successive $K_\mathrm{a}$s decrease in magnitudes of very large orders. | {
"domain": "chemistry.stackexchange",
"id": 14133,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "acid-base",
"url": null
} |
ros
Failed to load entry point 'stop': librclpy_common.so: cannot open shared object file: No such file or directory
The C extension '/opt/ros/dashing/lib/python3.6/site-packages/rclpy/_rclpy.cpython-36m-x86_64-linux-gnu.so' failed to be imported while being present on the system. Please refer to 'https://index.ros.org/doc/ros2/Troubleshooting/Installation-Troubleshooting/#import-failing-even-with-library-present-on-the-system' for possible solutions
Failed to load entry point 'get': librclpy_common.so: cannot open shared object file: No such file or directory
The C extension '/opt/ros/dashing/lib/python3.6/site-packages/rclpy/_rclpy.cpython-36m-x86_64-linux-gnu.so' failed to be imported while being present on the system. Please refer to 'https://index.ros.org/doc/ros2/Troubleshooting/Installation-Troubleshooting/#import-failing-even-with-library-present-on-the-system' for possible solutions
Failed to load entry point 'list': librclpy_common.so: cannot open shared object file: No such file or directory
The C extension '/opt/ros/dashing/lib/python3.6/site-packages/rclpy/_rclpy.cpython-36m-x86_64-linux-gnu.so' failed to be imported while being present on the system. Please refer to 'https://index.ros.org/doc/ros2/Troubleshooting/Installation-Troubleshooting/#import-failing-even-with-library-present-on-the-system' for possible solutions
Failed to load entry point 'nodes': librclpy_common.so: cannot open shared object file: No such file or directory | {
"domain": "robotics.stackexchange",
"id": 35799,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros",
"url": null
} |
optics, non-linear-optics
More to the point, the habit of thinking about optics exclusively in terms of monochromatic light very often makes you lose sight, completely, of the time-domain aspect of the system; this gets you some powerful tools, but it also filters out useful information. HHG does not afford us this luxury: we have to think constantly in terms of the time-domain behaviour of light, and this brings to the surface a number of interesting features that are just completely lost by working with monochromatic light or in the frequency domain. Optical self-torque is an excellent example of this.
(And, since I'm in shameless-plug mode: this other recent paper (arXiv) is a similar example, where the time-domain perspective on multi-colour combinations, as developed in HHG for the 'bicircular' fields used to produce circularly-polarized harmonics, helped us uncover a completely new optical singularity with cool new symmetries $-$ and, in the process, to break the results that sparked this previous question. And this, again, plays nicely with HHG and its conservation laws (arXiv).) | {
"domain": "physics.stackexchange",
"id": 59310,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "optics, non-linear-optics",
"url": null
} |
ruby
file.readlines.each should be file.each_line, which will do the same thing (iterate over all the lines) without building an array (and reading the whole file into memory) first. Also instead of keeping track of the line_number manually, you should just use each_with_index. Though actually if you want to append to the end of the array, you actually shouldn't use an index at all, but use << or push instead (if you want the indices to start at 1, you can just insert a nil element first).
That being said if all you want is to read the file into an array, you could just do lines = file.readlines without any loop (or possible [nil] + file.readlines, so that it keeps starting at 1, but I'd rather add 1 to the line number when printing instead of copying the whole array).
Further you can use the methods File.readlines or File.foreach instead of File.open + File#readlines or File.open + File#each_line respectively.
Then when you iterate over lines you should use each_with_index rather than each_index, so you don't have to do lines[i] to get at the value.
As a last note, it's unnecessary to call to_s on an object in #{} - ruby does that automatically.
However the whole approach seems needlessly complicated to me. I don't see why you need to build up an array at all. I'd just iterate over the lines once and output them directly. This in addition to being much shorter also has the advantage, that the program runs in O(1) space (assuming the maximum line length is constant) rather than reading the whole file into memory.
File.foreach('grepFile.txt').each_with_index do |line, i|
puts "line #{i}: #{line}" if line =~ /bleh/
end
And of course instead of 'grepFile.txt' and /bleh/, you should be using ARGV[1] and Regexp.new(ARGV[0]), as it makes no sense to hardcode these values. | {
"domain": "codereview.stackexchange",
"id": 41010,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ruby",
"url": null
} |
-
Hint: if $f$ has continuous second derivatives then you can use Taylor's theorem. – Chris Taylor Mar 22 '12 at 8:27
Apply L'Hospital's rule to differentiate numerator and denominator with respect to $h$: \begin{align*} \lim_{h \to 0} \frac{f(x+h) + f(x-h) - 2f(x)}{h^2} &= \lim_{h \to 0} \frac{f'(x+h) - f'(x-h)}{2h} = f''(x). \end{align*} (Add and subtract $f'(x)$ in the numerator to see the second equality.) Similarly, \begin{align*} \lim_{h \to 0} \frac{f(x+h) - f(x) - f'(x)h}{h^2}\, & = \lim_{h \to 0} \frac{f'(x+h) - f'(x)}{2h} = \frac{1}{2} f''(x). \end{align*}
-
By the way, this proof shows that you do not need continuity of the second derivative, you only need its existence at the point $x$. – Nick Strehlke Mar 22 '12 at 9:36
As always, very good answer Nick! – Daniel Montealegre Mar 22 '12 at 19:39
A further proof of this finite difference approximation is as follows. This avoids the use of L'Hopital's rule, but relies upon continuity of second derivatives. The trick is to use Taylor's theorem.
$$f(x+h) = f(x) + f'(x)h + f''(\xi) h^2/2$$ $$f(x-h) = f(x) - f'(x)h + f''(\xi) h^2/2$$
for some $\xi$ between $(x, x+h)$. Now take the difference and let $h$ tend to zero. By continuity, we will obtain the second derivative.
- | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9833429604789206,
"lm_q1q2_score": 0.8039561080176961,
"lm_q2_score": 0.817574478416099,
"openwebmath_perplexity": 267.91003749835215,
"openwebmath_score": 0.9986758232116699,
"tags": null,
"url": "http://math.stackexchange.com/questions/123206/expressions-for-the-second-derivative"
} |
c#, form, session
public void backgroundReset_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
Session newsession = (Session)e.Result;
if (newsession.ID == null)
{
// No session - revert to emergency support page
pageControl1.SelectedIndex = 5;
}
else
{
// Assign the new session to our session field, and navigate to the "work done" page
_currentSession = newsession;
pageControl1.SelectedIndex = 3;
}
}
Session
class Session
{
#region Fields
private string _username;
private string _pcname;
private int? _id; // the ? allows it to be nullable ... to make checking easier
private string _server;
#endregion
#region Properties
public string UserName
{
get { return _username; }
set { _username = value; }
}
public string PCName
{
get { return _pcname; }
set { _pcname = value; }
}
public int? ID
{
get { return _id; }
set { _id = value; }
}
public string ServerName
{
get { return _server; }
set { _server = value; }
}
#endregion
public Session()
{
// When a session is instantiated, retrieve the details immediately:
PCName = Environment.MachineName;
UserName = WindowsIdentity.GetCurrent().Name.Split('\\')[1];
SessionHelper.GetSession(this);
}
public Session Reset()
{
SessionHelper.Reset(this);
return this;
}
}
One of my main concerns with this is my use of a SessionHelper class; is this necessary? I originally had all my methods in Session, but at the time it seemed sensible to separate the concept of a Session and the methods performed on the session in some way:
static class SessionHelper
{
public static string AppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
private static string AppDataCitrix = AppData + "\\Citrix\\SelfService\\"; | {
"domain": "codereview.stackexchange",
"id": 18170,
"lm_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#, form, session",
"url": null
} |
mathematical-physics, conservation-laws, symmetry, noethers-theorem
Title: Conservation Laws and Symmetry The toughest of topics in physics, like Quantum Mechanics, Relativity, String theory, can be explained in layman words and many have done so. Though there is no substitute to the understanding a theory in all it's mathematical detail, the idea can more or less be driven home. However, I seem not to be able to find such an explanation for Noether's theorem.
I've tried my hand at Group Theory and found quite perplexing. I've got stuck with generators, and this and that ....
So here is my question. Is it possible to explain without using heavy mathematics, why a conservation law arises from a symmetry under some transformation?
I'm in school, so my "heavy" might not be the same as yours.
Thanks. A helpful yet elementary answer may do the trick, If you are familiar with the Euler-Lagrange equation then it will be straight forward and you can skip ahead a little. If not then you have to accept that there is an equation in physics that generalises classical mechanics called the Euler-Lagrange equation. For a particle moving in one dimension under a conservative force it is written,
\begin{equation}
\frac{d}{dt}\bigg(\frac{\partial T}{\partial \dot x}\bigg)+\frac{\partial V}{\partial x}=0
\end{equation}
Where $T$ is the kinetic energy of the system and $V$ is the potential energy, $x$ is the particles position and $\dot x=\frac {d}{dt}x$ is the velocity of the particle. We define the momentum of the particle to be,
\begin{equation}
p:=\frac{\partial T}{\partial \dot x}
\end{equation}
And you will note that we can now write the Euler-Lagrange equation as,
\begin{equation}
\frac{d}{dt}(p)+\frac{\partial V}{\partial x}=0
\end{equation} | {
"domain": "physics.stackexchange",
"id": 24331,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "mathematical-physics, conservation-laws, symmetry, noethers-theorem",
"url": null
} |
momentum, conservation-laws, ideal-gas, bernoulli-equation
Where does this equation and reasoning come from? As your system is cooling, its energy is not conserved and Bernoulli does not apply. However from 1-d Euler
$$
\rho \left(\frac{\partial v}{\partial t}+ v \frac{\partial v}{\partial x}\right)= -\frac{\partial P}{\partial x}
$$
and 1-d mass conservation
$$
\frac {\partial \rho} {\partial t}+ \frac{\partial \rho v}{\partial x}=0
$$
we find the momentum conservation law
$$
\frac{\partial \rho v}{\partial t}+ \frac{\partial}{\partial x}\left(\rho v^2+P\right)=0,
$$
so in steady flow we have $\rho v^2+P=const$. This is true for strictly 1-d flow even if heat energy is being added or lost. It appears at first to in conflict with Bernoulli (which holds in the flow is isentropic) but in Bernoulli the speed changes because the pipe changes area, so the Bernoulli flow is not strictly 1-d.
In a pipe with a slowly varying area the momentum law becomes
$$
A\frac{\partial \rho v}{\partial t}+ \frac{\partial\rho v^2 A}{\partial x}= -A \frac{\partial P }{\partial x}.
$$ | {
"domain": "physics.stackexchange",
"id": 85011,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "momentum, conservation-laws, ideal-gas, bernoulli-equation",
"url": null
} |
c++, c++11, file-system, c++14, boost
/// extension("var/file.cpp...abc..", 4) -> "..abc.."
///
////////////////////////////////////////////////////////////////////////////////
inline path extension( const path& path_, int dots = 0 ) {
// Get the filename to ensure that some edge cases are dealt with. E.g.:
// path{"/var/foo.bar/baz.txt"}.filename() -> path{"baz.txt"}
auto filename = path_.filename();
const auto& native = filename.native(); // Returns const std::wstring& | {
"domain": "codereview.stackexchange",
"id": 10356,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, c++11, file-system, c++14, boost",
"url": null
} |
Find all School-related info fast with the new School-Specific MBA Forum
It is currently 30 Aug 2015, 00:00
### GMAT Club Daily Prep
#### Thank you for using the timer - this advanced tool can estimate your performance and suggest more practice questions. We have subscribed you to Daily Prep Questions via email.
Customized
for You
we will pick new questions that match your level based on your Timer History
Track
every week, we’ll send you an estimated GMAT score based on your performance
Practice
Pays
we will pick new questions that match your level based on your Timer History
# Events & Promotions
###### Events & Promotions in June
Open Detailed Calendar
# To find the units digit of a large number?
Author Message
TAGS:
Director
Joined: 29 Nov 2012
Posts: 926
Followers: 12
Kudos [?]: 528 [0], given: 543
To find the units digit of a large number? [#permalink] 03 Jul 2013, 21:58
1
This post was
BOOKMARKED
So if we are given a question what is the units digit of $$777^{777}$$
we find the pattern for 7 (7,9,3,1)
then we divide $$\frac{777}{4}$$ and the remainder is 1 so the units digit is $$7^1$$ which is 7?
Is this correct?
_________________
Click +1 Kudos if my post helped...
Amazing Free video explanation for all Quant questions from OG 13 and much more http://www.gmatquantum.com/og13th/
GMAT Prep software What if scenarios gmat-prep-software-analysis-and-what-if-scenarios-146146.html
Director
Joined: 24 Aug 2009
Posts: 507
Schools: Harvard, Columbia, Stern, Booth, LSB,
Followers: 10
Kudos [?]: 489 [0], given: 241
Re: To find the units digit of a large number? [#permalink] 03 Jul 2013, 22:08
fozzzy wrote:
So if we are given a question what is the units digit of $$777^{777}$$
we find the pattern for 7 (7,9,3,1) | {
"domain": "gmatclub.com",
"id": null,
"lm_label": "1. Yes\n2. Yes\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9738443862008362,
"lm_q1q2_score": 0.882293101771475,
"lm_q2_score": 0.9059898216525935,
"openwebmath_perplexity": 2334.657257537312,
"openwebmath_score": 0.32343626022338867,
"tags": null,
"url": "http://gmatclub.com/forum/to-find-the-units-digit-of-a-large-number-155363.html"
} |
javascript, php
/*
Short class that just simplifies access to those 2 classes before
PARAMS:
newMessageServerURL - string - URL of file, which saves and validates the message
longPollServerURL - string - URL of server file, which acts as long poll server
lastIdGetURL - string - URL of txt file, where last message id is saved
messageReceivedCallback - function - callback to get called when new message is received, it is called with 4 params: id of the message, time when the message was sent as unix timestamp, nickname of the person who sent it, message text itself
sentMessageCallback - function - function to handle response from server (ok / wrongFormat / noName / ... status etc... (that depends on how you make your server))
*/
function ServerCommunicator(newMessageServerURL, longPollServerURL, lastIdGetURL, messageReceivedCallback, sentMessageCallback) {
var longPoll = new ChatLongPoll(longPollServerURL, lastIdGetURL, messageReceivedCallback);
var sendMessage = new ChatSendMessage(newMessageServerURL, sentMessageCallback);
this.sendMessage = sendMessage.sendMessage;
this.startLongPoll = longPoll.startLongPoll;
} | {
"domain": "codereview.stackexchange",
"id": 7277,
"lm_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, php",
"url": null
} |
"Joey"
Nov 2015
Middle of Nowhere,AR
22×3×37 Posts
Quote:
Originally Posted by VBCurtis What happens to the new denominator if you multiply those factors out? Does the radical disappear like it does in your first two methods?
It doesn't
I wasn't thinking this through very well. We had just did some trig stuff where we canceled out denominators in a different way that seemed similar but really wasn't
2018-10-12, 14:44 #53
masser
Jul 2003
26×33 Posts
Quote:
Originally Posted by jvang However, what happens if we multiply by the denominator itself:$\dfrac{x-1}{\sqrt{x}+1} \cdot \dfrac{\sqrt{x}+1}{\sqrt{x}+1}$I was thinking that this is worth looking into (cancel out the denominator), but now that I've typed it out it looks much less intuitive... It's pretty wrong, isn't it
It's not wrong. It's just not very useful. But it's good to be in the habit of trying different things and seeing what works. | {
"domain": "mersenneforum.org",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9867771782476948,
"lm_q1q2_score": 0.806763825853428,
"lm_q2_score": 0.8175744673038222,
"openwebmath_perplexity": 770.9991926692378,
"openwebmath_score": 0.842481791973114,
"tags": null,
"url": "https://mersenneforum.org/showthread.php?s=01bbaa5b10cd39681b8953ac5c272476&t=23577&page=5"
} |
thermodynamics, free-energy, entropy
Title: How can -G/T and -A/T be thought of as 'disguised' entropies? I understand that entropy is defined as $\mathrm{d}S=\mathrm{d}q/T$ for a reversible change but I fail to see why $-G/T$ and $-A/T$ can be thought of as 'disguised' entropies. This is a question on my problem sheet at university and my tutor has hinted: "You need to think about the total entropy change for a process". The fundamental equation of (chemical) thermodynamics $\ce{\Delta G} = \Delta H – {T\Delta S}$ may be divided by (-T):
$$\ce{-\frac{\Delta G}{T}} = -\frac{\Delta H_{sys}}{T} + {\Delta S}_{sys}$$
In this equation $\frac{\Delta H_{sys}}{T}$ is the entropy change of the system by “heat” exchange with the surroundings, hence $\frac{\Delta H_{sys}}{T} = -\Delta S_{surroundings}$. On this basis, the above equation may be identified as:
$$\Delta S_{total} ={\Delta S_{surroundings} + \Delta S}_{sys}$$
$\Delta S_{sys}$ and $\Delta S_{surroundings}$ strive mutually to a maximum of $\Delta S_{total}$.
$\ce{\Delta G}$ is a disguised entropy change, because $\ce{\Delta H}$ is intrinsically an entropy change too, as explained above. | {
"domain": "chemistry.stackexchange",
"id": 8588,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "thermodynamics, free-energy, entropy",
"url": null
} |
ros, imu, transforms
Title: TF is broken when using robot_localization package with only IMU sensor, how to assure that the measured velocity is the one from the robot? Im using thisrobot_lokalization robot_localization package for the linear velocity. As only sensor input in my case is IMU. I configure the parameters and set the frames as follow
map_frame: map
odom_frame: odom
base_link_frame: /thrbot/base_link
world_frame: odom
The launch file is the following one
<launch>
<node pkg="robot_localization" type="ekf_localization_node" name="ekf_se" clear_params="true">
<rosparam command="load" file="$(find robot_localization)/params/ekf_template.yaml" />
<param name="odom_used" value="false"/>
</node>
<node pkg="tf" type="static_transform_publisher" name="base_link_to_imu" args="0 0 0 0 0 0 /thrbot/base_link /thrbot/imu_link 100" />
</launch>
The robot base_link frame is thrbot/base_link the IMU is thrbot/imu_link
Here is the photo of the TF without using the package . But when using the package my TF is broken as can see from the photo here . Any help how to fix the TF and correctly use the package with IMU as only sensor input?
To fix the TF i change the configure the parameters in ekf_template.yaml as follow
odom_frame: odom
base_link_frame: /thrbot/base_footprint
world_frame: odom | {
"domain": "robotics.stackexchange",
"id": 2428,
"lm_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, imu, transforms",
"url": null
} |
entanglement, information-theory, entropy
\begin{align} \log(\rho_A\otimes\rho_B)&=\sum_{lk}\log(\lambda_l \chi_k)|l\rangle\langle l|_A\otimes |k\rangle\langle k|_B \\ &=\sum_{lk}\log\lambda_l|l\rangle\langle l|_A\otimes |k\rangle\langle k|_B+\sum_{lk}\log\chi_k|l\rangle\langle l|_A\otimes |k\rangle\langle k|_B \\ &= \log\rho_A\otimes 1_B+1_A\otimes\log\rho_B \end{align}
where I've made use of the completeness relations on $A$ and $B$. Now, if $\rho_{AB}=\rho_A\otimes\rho_B$ then we have simply $$ S(\rho_{AB})\le -\text{tr}(\rho_A\log\rho_A\otimes\rho_B)-\text{tr}(\rho_A\otimes\rho_B\log\rho_B)=S(\rho_A)+S(\rho_B).$$ But what if $\rho_{AB}$ is not separable? You are very close. | {
"domain": "quantumcomputing.stackexchange",
"id": 2969,
"lm_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, information-theory, entropy",
"url": null
} |
c#, networking, server, tcp, client
Console.WriteLine();
}
}
public static void Rickroll(MessageReceivedEventArgs e)
{
e.Client.SendMessage("never gunna let you down");
}
private static void Server_ClientDisconnected(object sender, ClientToggleEventArgs e)
{
Console.WriteLine("Client Disconnected: " + e.ConnectedClient.ConnectAddress);
}
private static void Server_MessageReceived(object sender, MessageReceivedEventArgs e)
{
Console.WriteLine("Received Message: " + e.Client.ConnectAddress + " : " + e.Message);
var toRespond = Reverse(e.Message);
Console.WriteLine("Returning Message: " + toRespond);
e.Client.SendMessage(toRespond);
}
public static string Reverse(string s)
{
var charArray = s.ToCharArray();
Array.Reverse(charArray);
return new string(charArray);
}
private static void Server_ClientConnected(object sender, ClientToggleEventArgs e)
{
Console.WriteLine("Client Connected: " + e.ConnectedClient.ConnectAddress);
}
}
Example Usage Client-Side
public class Program
{
static Client client;
static void Main(string[] args)
{
failedToConnect:;
Console.Write("Enter the IP address to connect to:\n> ");
var ip = Console.ReadLine();
invalidPort:;
Console.Write("Enter the port to connect to:\n> ");
var portString = Console.ReadLine();
Console.WriteLine();
if (int.TryParse(portString, out var port))
{
try
{
client = new Client(ip, port);
if (client.FailedConnect)
{
Console.WriteLine("Failed to connect!");
goto failedToConnect;
}
client.MessageReceived += Client_MessageReceived;
Console.WriteLine("Client connected."); | {
"domain": "codereview.stackexchange",
"id": 30953,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c#, networking, server, tcp, client",
"url": null
} |
c#, winforms
public event EventHandler ItemAdded;
public event EventHandler ItemRemoved;
/// <summary>
/// Sets or Gets alternate color for the listview rows.
/// </summary>
public Color AlternateColor { get; set; }
/// <summary>
/// Sets or Gets DateTimeFormat for sorting columns that contain DateTime.
/// </summary>
public string DateTimeFormat { set; get; }
public EnhancedListView()
{
AlternateColor = Color.Empty;
lvwColumnSorter = new ListViewColumnSorter();
this.ListViewItemSorter = lvwColumnSorter;
ItemAdded += ItemAddedToLV;
ItemRemoved += ItemRemovedFromLV;
//Activate double buffering
this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
//Enable the OnNotifyMessage event so we get a chance to filter out
// Windows messages before they get to the form's WndProc
this.SetStyle(ControlStyles.EnableNotifyMessage, true);
InitializeComponent();
}
protected override void InitLayout()
{
lvwColumnSorter.timeFormat = DateTimeFormat;
base.InitLayout();
}
protected override void OnPaint(PaintEventArgs e)
{
lvwColumnSorter.timeFormat = DateTimeFormat;
base.OnPaint(e);
}
protected override void OnNotifyMessage(Message m)
{
//Filter out the WM_ERASEBKGND message
if (m.Msg != 0x14)
{
base.OnNotifyMessage(m);
}
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m); | {
"domain": "codereview.stackexchange",
"id": 6280,
"lm_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#, winforms",
"url": null
} |
\begin{align*} \theta &= \cos^{-1}\left(\frac{(\textbf{p}_3-\textbf{p}_2)\cdot(\textbf{p}_1-\textbf{p}_2)}{||\textbf{p}_3-\textbf{p}_2||\text{ }||\textbf{p}_1-\textbf{p}_2||}\right)\\ &= \cos^{-1}\left(\frac{(x_3-x_2)(x_1-x_2)+(y_3-y_2)(y_1-y_2)}{\sqrt{(x_3-x_2)^2+(y_3-y_2)^2}\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}}\right) \end{align*} | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9814534354878828,
"lm_q1q2_score": 0.8069403467715635,
"lm_q2_score": 0.8221891305219504,
"openwebmath_perplexity": 191.50991788609917,
"openwebmath_score": 0.9865438938140869,
"tags": null,
"url": "https://math.stackexchange.com/questions/4085167/finding-the-angle-between-two-lines-meeting-at-one-point"
} |
histogram
Title: 'Combed' Histograms I have two FLIR Blackfly cameras that are identical outside of one being color and the other being mono. I set the ADC of both to 10 bit, and save the images in 16 bit. This results in the combed histograms shown below (or at least I believe this is the cause...). The strangest bit is how the different color channels are interleaved where they overlap. Is there a way to mitigate and/or prevent this issue?
Edit:
Including a sample image and corresponding histogram (channel 2). Note, the image had to be cropped and limited to a single channel to fit within data size constraints. This might be hardware / software specific.
You can reproduce this kind of artifact with a "simple window" that tries to map a narrow range of the original scale to a wider range. Each individual pixel is described by an integer, which, once it goes through the linear mapping transformation gets transposed to a different bin.
An extreme example would be trying to map the range 0..1 to the range 0..7 with both ranges originating from natural numbers. There is nothing else in the range 0..1 except 0 and 1. Consequently, there is nothing to map to 1,2,3,4,5,6. If you tried to map 0..3 to 0..99, you would again only fill 4 bins of the wide range.
You can "simulate" this condition over any image by trying a similar narrow->wide mapping: | {
"domain": "dsp.stackexchange",
"id": 8912,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "histogram",
"url": null
} |
As the number of samples increases, the result gets accurate. Also, the coefficient in the exponential’s power affects the accuracy of the result too, but this is not the main case.
• Ok I'm dumb I just figured out why; an issue with my code. The x(i) vector in my code contains the samples from -inf to +inf but i goes from 1 to half the samples, so it's only summing up half the samples, which obviously gives half the energy. I feel so stupid rn haha thank you for your help – Kevin KZ Mar 26 at 15:33
• @Kevin KZ That is okay, no problem. – Karakoncolos Mar 26 at 16:18 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9715639694252315,
"lm_q1q2_score": 0.8441207799152708,
"lm_q2_score": 0.8688267643505193,
"openwebmath_perplexity": 995.9032540970792,
"openwebmath_score": 0.8759253621101379,
"tags": null,
"url": "https://dsp.stackexchange.com/questions/74060/different-values-when-calculating-signals-energy-by-hand-vs-matlab"
} |
algorithms, algorithm-analysis
Title: Is there any other way of getting a function from this piece of code? I have this pseudocode
function mysterious(N):
count = 0
for i = 0 to N:
if (i mod 3 == 0):
count = count + i
return count
The problem ask for the expression that returns this function using N or in terms of N
The best I have done is $\sum\limits_{i=0}^n i \bmod 3$
Is there any better way to express the function of this code?
I know the code returns the sum of the numbers divisible by 3 Hint: Use the formula
$$ \sum_{i=1}^k i = \frac{k(k+1)}{2}. $$
You can consider first the case that $N$ is a multiple of $3$.
Further hint: Use the formula
$$ \sum_{i=1}^k 3i = 3\frac{k(k+1)}{2}. $$
When $N$ is a multiple of $3$, a good choice of $k$ is $N/3$. More generally, you should choose $k = \lfloor N/3 \rfloor$. | {
"domain": "cs.stackexchange",
"id": 4361,
"lm_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, algorithm-analysis",
"url": null
} |
As an example, let's see how many trailing zeros $$16!$$ (expressed in the usual base $$10$$) has in base $$b = 12$$. We have that $$b = 2^2\cdot 3$$, so $$p_1 = 2$$, $$p_2 = 3$$, and $$e_1 = 2$$, $$e_2 = 1$$. Now, we can compute $$m_1 = \left\lfloor \frac{1}{2}\sum_{s=1}^\infty \left\lfloor\frac{16}{2^s}\right\rfloor\right\rfloor = \left\lfloor \frac{8+4+2+1}{2}\right\rfloor = 7$$ $$m_2 = \left\lfloor \frac{1}{1}\sum_{s=1}^\infty \left\lfloor\frac{16}{3^s}\right\rfloor\right\rfloor = 5 + 1 = 6$$ so $$16!$$ (again, in decimal) has $$m = \min\{7,6\} = 6$$ trailing zeros when expressed in base $$12$$. We can check this in WolframAlpha, which tells us that $$(16!)_{10} = 241ab88000000_{12}$$ indeed has $$6$$ trailing zeros. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9893474910447999,
"lm_q1q2_score": 0.8156793447233917,
"lm_q2_score": 0.824461932846258,
"openwebmath_perplexity": 64.85913171519023,
"openwebmath_score": 0.9305016398429871,
"tags": null,
"url": "https://math.stackexchange.com/questions/1573011/is-there-a-way-to-find-the-number-of-trailing-zeroes-in-a-factorial-with-a-certa"
} |
Finding midpoint becomes easy by taking the average of the x coordinates and simultaneously taking the average of the y coordinates. $x_A = 3,~~ y_A = -4,~~ x_B = -1,~~ y_B = 3$~. Everybody needs a calculator at some point, get the ease of calculating anything from the source of calculator-online.net. To calculate the midpoint of a line segment with endpoints (x1, y1) and (x2, y2), you ought to use midpoint formula: $$M = \left( \frac{x_1 + x_2}{2} , \frac{y_1 + y_2}{2} \right)$$. Graph the function, parametric equations, polar equation, or sequence. Find the midpoint M between $\left( \frac{1}{2}, \frac{5}{3} \right)$ and $\left( -\frac{4}{3}, –2\right)$. You can readily find the midpoint in exactly within the same way along with integers and fractions, it does not matter whether they’re improper fractions, common fractions or decimal fractions. For a range of 4-8, this is 4, Very next, you have to find the upper class limit. Use our simple midpoint calculator to get the midpoint of the line! It is possible to divide a line segment into ‘n’ equal parts, where 'n' is any natural number and segmentation is of two types namely, internal and external. Calculator find the coordinates of point p which divides the line joining two Entered points A and B internally or externally, in a specified ratio m and n. Coordinates of point is a set of values that is used to determine the position of a point in a three dimensional Cartesian coordinate. To draw a horizontal line, perform the following steps. All the 3D vectors can be represented in 3 dimensional space by a directed line segment, which has a starting point and an ending point. The outcomes will provides you with the coordinates of the midpoint, Now, you have to draw a line between a midpoint and its opposite corner, You ought to repeat the same for at least one other midpoint and corner pair, or also both for | {
"domain": "in.ua",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9711290922181331,
"lm_q1q2_score": 0.8254317399185965,
"lm_q2_score": 0.8499711794579723,
"openwebmath_perplexity": 261.727370370578,
"openwebmath_score": 0.6447291374206543,
"tags": null,
"url": "https://tux.in.ua/site/viewtopic.php?54c82a=directed-line-segment-calculator"
} |
electric-circuits, electrical-engineering, linear-systems
The DEs for this system are somewhat long. I'll choose an RLC circuit to express my point.
In terms of $F\to V$, (using $x\to q$)
$$V_R=R \frac{dq}{dt},\ \ V_L=L\frac{d^2 q}{dt^2},\ \ V_C=\frac{q}C$$
Now, using $F\to I$, (using $x\to \phi$)
$$I_R=\frac{1}R\frac{d\phi}{dt},\ \ I_L=\frac{\phi}{L},\ \ I_C=C\frac{d^2 \phi}{dt^2}$$
The $x\to q$ was fine, because motion of charge is current, and that's the basis for all electrical systems. But, the $x\to \phi$ is inconceivable. The magnetic flux, how $\phi$ changes, induced emf, etc. are needed for inductors. Yeah, but how can they be applied to resistors or capacitors?
With this framework for writing the differential equations, it seems as if magnetic flux is the clockwork behind the working of such a system.
This horror made me think that the $F\to I$ analog (using $\phi$) is just another abstract mathematical construct for writing differential equations. Am I right? Is it reasonable at all? I think there is something wrong with your mapping.
Looking at http://lpsa.swarthmore.edu/Analogs/ElectricalMechanicalAnalogs.html , I see the following table:
This is inconsistent with the mapping you are showing.
I can understand this table - I can't understand yours. I think an error crept in - which would reasonably explain your confusion.
Looking forward to comments! | {
"domain": "physics.stackexchange",
"id": 15274,
"lm_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, electrical-engineering, linear-systems",
"url": null
} |
nuclear-physics, neutrons, strong-force, carrier-particles, pions
Title: What is the force carrier for neutrons in fission? Say I have a neutron capture event, leading to a fission reaction in which a few neutrons are expelled. These neutrons inherit a certain momentum from this fission reaction.
How do these neutrons obtain that momentum? Is there some kind of electromagnetic interaction between the nucleus and the neutron’s dipole moment? Or are there different interactions at play here? The short answer is that the force carriers are mostly pions, but the details get quite complicated.
In physics we know about four fundamental interactions: the strong force, the electromagnetic force, the weak force, and gravitation. The neutron participates in all of them, but feebly. Its gravitational mass is small, it has no electric charge, and its magnetic moment is smaller than the magnetic moment of the electron by approximately the ratio of the electron and neutron masses --- that kills the long-range $1/r^2$ forces. The strong and weak forces are both contact interactions with finite range, but the strong force is ... stronger. So when a neutron is near enough to a nucleus to undergo scattering, including only the strong interaction is usually a pretty good approximation.
Microscopically, the strong interaction is an interaction between color charges, mediated by gluons. However at the low energies involved in nuclear fission, quarks and gluons are not the degrees of freedom which give the most parsimonious explanations of what's happening in QCD. Instead, the QCD vacuum condenses into color singlet states like the proton and neutron, which interact by exchanging color-singlet mesons like the pion, the rho, the omega, and others. These mesons effectively give the nucleons a set of Yukawa interaction potentials which are exponential in the meson masses, so the lightest meson (the pion) contributes the most to the interaction except at very short distances. | {
"domain": "physics.stackexchange",
"id": 47668,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "nuclear-physics, neutrons, strong-force, carrier-particles, pions",
"url": null
} |
urdf, turtlebot
Title: Turtlebot + PhantomX Arm
Hi,
I've just been experimenting with attaching a model (xacro.urdf) of a phantomx arm pincher to the top of the current turtlebot2 model.
In this instance I thought I would just try and add:
<!-- Phantomx Arm -->
<xacro:include filename="$(find phantomx_arm_description)/urdf/phantomx.xacro"/>
To the turtlebot_library.urdf.xacro file within the turtlebot_description package found in opt/ros.......
I edited the phantomx arm urdf to include a joint which links the top plate of the turtlebot to the base plate of the phantomx arm:
<!-- joints -->
<joint name="${prefix}arm_base_joint" type="fixed">
<origin xyz="${M_SCALE*0} ${M_SCALE*0} ${M_SCALE*0}" rpy="${0} ${0} ${0}" />
<parent link="plate_top_link" />
<child link="${prefix}arm_base_link"/>
<axis xyz="0 1 0" />
<limit lower="-2.617" upper="2.617" effort="0" velocity="0.785" />
</joint> | {
"domain": "robotics.stackexchange",
"id": 16631,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "urdf, turtlebot",
"url": null
} |
# Verifying the outputs of 'Solve'
I got a solution for the equation
Simplify[Solve[
1/(2 q r (-1 + c1 M s1)) (-a q + M q + b c1 q s0 + a c1 M q s1 -
c1 M^2 q s1 -
c2 M r s1 + \[Sqrt](4 q r (-1 + c1 M s1) (b (cp + c2 s0) +
c2 (a - M) M s1) + (b c1 q s0 - c1 M^2 q s1 +
a q (-1 + c1 M s1) + M (q - c2 r s1))^2)) == 0 , M ]]
which is $\left\{\left\{M\to \frac{1}{2} \left(a-\frac{\sqrt{a^2 \text{c2} \text{s1}+4 b (\text{c2} \text{s0}+\text{cp})}}{\sqrt{\text{c2}} \sqrt{\text{s1}}}\right)\right\},\left\{M\to \frac{1}{2} \left(\frac{\sqrt{a^2 \text{c2} \text{s1}+4 b (\text{c2} \text{s0}+\text{cp})}}{\sqrt{\text{c2}} \sqrt{\text{s1}}}+a\right)\right\}\right\}$
But then when I plug that expression into the original lefthand side of the equation I do not get zero | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9597620550745211,
"lm_q1q2_score": 0.8195530532750891,
"lm_q2_score": 0.8539127473751341,
"openwebmath_perplexity": 1771.7736322605629,
"openwebmath_score": 0.2582782804965973,
"tags": null,
"url": "https://mathematica.stackexchange.com/questions/113535/verifying-the-outputs-of-solve"
} |
symmetry, metric-tensor, field-theory, action, variational-calculus
$$\frac{\delta F^{\mu}{}_{\nu}(x)}{\delta F^{\alpha}{}_{\beta}(y)}
~=~\frac{1}{2}\left( \delta^{\mu}_{\alpha}\delta_{\nu}^{\beta} - g_{\alpha\nu}(x)g^{\mu\beta}(x)\right)\delta^n(x-y).\tag{A'} $$ | {
"domain": "physics.stackexchange",
"id": 47493,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "symmetry, metric-tensor, field-theory, action, variational-calculus",
"url": null
} |
ros, rplidar
Title: How to know the history about rplidar wiki
How to get the edit history about rplidar?
Originally posted by kint on ROS Answers with karma: 53 on 2018-07-31
Post score: 0
MoinMoin displays editing history of pages on the Revision History page, which you can access for wiki/rplidar here: wiki/action/info/rplidar?action=info.
Originally posted by gvdhoorn with karma: 86574 on 2018-07-31
This answer was ACCEPTED on the original site
Post score: 0 | {
"domain": "robotics.stackexchange",
"id": 31418,
"lm_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, rplidar",
"url": null
} |
# How do I graph this?
I am just a high school student, so please excuse me if this question sound silly to you.
How do I graph this : $$\dfrac{9}{x} - \dfrac{4}{y} = 8$$
I could do trial and error, but is there a more systematic way that I can use to graph this equation.
• Can you solve for $y$ ? – dmtri Mar 9 '19 at 11:11
• Please explain what you mean by "graph this equation." Do you mean get it into a form so you can use a graphing calculator or program to show the graph, or do you mean graph it manually without a calculator, or do you mean something else? Could calculus methods such as intervals where the graph increases or decreases be used? How about end behavior? Could/should you use the transformation of a standard graph using translations and expansions? – Rory Daulton Mar 9 '19 at 11:32
I'll assume you want to graph that equation without a graphing calculator or graphing program, and that you want to use only pre-calculus techniques.
So we want to transform the equation into something resembling one of the "standard equations" that we have seen before. First, we simplify the equation by removing the fractions and moving all terms to one side of the equation.
$$\frac 9x - \frac 4y = 8$$ $$\left(\frac 9x - \frac 4y\right)xy = 8xy$$ $$9y - 4x = 8xy$$ $$8xy + 4x - 9y = 0$$
That left side looks factorable. We'll make the first coefficient into one.
$$\frac 18(8xy + 4x - 9y)= \frac 18\cdot 0$$ $$xy + \frac 12x - \frac 98y = 0$$
Now that looks much like factoring a polynomial. We see that we can split the $$\frac 12$$ and the $$-\frac 98$$ by making the left side into the product of two binomials. But first we need to add the appropriate constant term. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. Yes\n2. Yes",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9390248225478307,
"lm_q1q2_score": 0.8054655494040014,
"lm_q2_score": 0.8577681122619883,
"openwebmath_perplexity": 115.39007581359655,
"openwebmath_score": 0.804904580116272,
"tags": null,
"url": "https://math.stackexchange.com/questions/3141004/how-do-i-graph-this"
} |
audio, digital-communications, c++, feedback
Title: DSP using audio IO from PC using C++ This is my first question on dsp. I am looking for something very simple here and I am sure there are libraries that will do pitch recognition and FFT but my requirement is very simple.
I have a PC and I am using the audio input for analog signal feedback and output for controlling the device. I am using windows as the OS.
I want to ensure that I have full control on the audio output and no other program or the OS will stream sounds into the same channel.
I want to output precisely at a known time interval
I want to check if the feedback matches with what is expected of the device.
Any snippet of code or an article to do the same will be useful. I can provide more details if there is something missing in my question. The best performance you will be able to squeeze out of a PC is with an audio interface that supports ASIO.
To be able to get near 10ms of total delay (input and output) you will also need a very fast machine. Not only in terms of CPU but more importantly in terms of memory performance.
On top of this delay, you are going to have to add the delay in processing your signal and generating the output signal.
1ms (total delay (?) ) on the hardware you are describing is unrealistic.
The way ASIO works will handle issues #1,#2. I am still not really sure what you mean by #3. If you want to use the PC to drive a device with some signal and collect the response of the device to that signal then that is relatively easily achievable with an ASIO enabled audio interface too.
Hope this helps. | {
"domain": "dsp.stackexchange",
"id": 6309,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "audio, digital-communications, c++, feedback",
"url": null
} |
c#, object-oriented, multithreading, static
if (string.IsNullOrEmpty(className))
logMessage.Append(String.Format("[{0}] [{1}] {2} {3}", DateTime.Now.ToString(), logLevel.ToString(), message, extraMessage) + Environment.NewLine);
else
logMessage.Append(String.Format("[{0}] [{1}] <{2}> {3} {4}", DateTime.Now.ToString(), logLevel.ToString(), className, message, extraMessage) + Environment.NewLine); | {
"domain": "codereview.stackexchange",
"id": 17373,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c#, object-oriented, multithreading, static",
"url": null
} |
experimental-chemistry, home-experiment, safety, combustion
Both propane and butane give off $\pu{105 kcal/mol}$ of oxygen, so they should perform equivalently in a spud gun. The article goes on to note that, of common fuels, only hydrogen ($\pu{119 kcal/mol}$ of oxygen) and acetylene ($\pu{120 kcal/mol}$ of oxygen) produce significantly more energy under these conditions than other fuels.
Now going back to your first question, if you know the volume of your chamber, you can back-calculate the correct amount of air (oxygen) and butane. | {
"domain": "chemistry.stackexchange",
"id": 3821,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "experimental-chemistry, home-experiment, safety, combustion",
"url": null
} |
Now, integrate the left-hand side $\mathrm{dy}$ and the right-hand side $\mathrm{dx}$:
$\iff \int \frac{1}{y} \mathrm{dy} = \int \mathrm{dx}$
$\iff \ln | y | = x + C$
Remember to add the constant of integration, but we only need one.
Raise both sides by $e$ to cancel the $\ln$:
$\iff y = \pm {e}^{x + C}$
Now, pulling the $C$ out front:
$\iff y = \pm C {e}^{x}$
Since $C$ can be either positive or negative, we don't really need the $\pm$:
$\iff y = C {e}^{x}$
So there is our general solution: Any constant multiple of ${e}^{x}$ is a solution to the differential equation, which makes sense.
Was this helpful? Let the contributor know!
##### Just asked! See more
• 9 minutes ago
• 9 minutes ago
• 10 minutes ago
• 13 minutes ago
• A minute ago
• A minute ago
• 3 minutes ago
• 5 minutes ago
• 7 minutes ago
• 8 minutes ago
• 9 minutes ago
• 9 minutes ago
• 10 minutes ago
• 13 minutes ago | {
"domain": "socratic.org",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9871787857334058,
"lm_q1q2_score": 0.8024453740228804,
"lm_q2_score": 0.8128673201042492,
"openwebmath_perplexity": 798.3927081817036,
"openwebmath_score": 0.8837807774543762,
"tags": null,
"url": "https://socratic.org/questions/what-is-a-solution-to-the-differential-equation-dy-dx-y"
} |
transform, e.g, L(f; s) = F(s). Using only Table 4.1 and the time-shifting property, determine the Laplace transform of the signals in Fig. Q: Find the output voltage of the clipper circuit below. Properties of Laplace Transform –Cont’d 2. Shifting Property (Shift Theorem) Lap {e^(at)f(t)} = F(s-a) Example 4 Lap {e^(3t)f(t)} = F(s-3) Property 5. P4.1-3. Next: Analysis of LTI Systems Up: No Title Previous: Properties of Laplace Transform Laplace Transform of Typical Signals, Moreover, due to time shifting property, we have u(t), , Due to the property of time domain integration, we have Applying the s-domain differentiation property to the above, we have 5. Featured on Meta Feedback post: New moderator reinstatement and appeal process revisions And I think you're starting to see a pattern here. It should be emphasized that shifting the signal left in time as defined by f ( t + t 0) u ( t + t 0) ; t 0 > 0 , in general, violates signal causality so that the one-sided Laplace transform can not be (a) x()tt=δ()4 (b) xu()tt=()4 u,Ret s ()←→ L ()s > 1 0 u,Re4 1 4 1 4 1 t … Table of Laplace Transform Properties. Solving differential equation by the Laplace transform. Linear af1(t)+bf2(r) aF1(s)+bF1(s) 2. Browse other questions tagged integration definite-integrals laplace-transform or ask your own question. Analysis of electrical and electronic circuits. Property 3 The Laplace transform satisfies a number of properties that are useful in a wide range of applications. *Response times vary by subject and question complexity. sadas ℒ= 1 (18) K. Webb ESE 499. Laplace Transform of Differential Equation. The Laplace transform of an impulse function is one. In this tutorial, we state most fundamental properties of the transform. Laplace Transform of Typical Signals. The second shifting theorem is a useful tool when faced with the challenge of taking the Laplace transform | {
"domain": "paleoreise.de",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9669140254249554,
"lm_q1q2_score": 0.8078407500369642,
"lm_q2_score": 0.8354835371034368,
"openwebmath_perplexity": 1467.8309732500663,
"openwebmath_score": 0.726850152015686,
"tags": null,
"url": "http://paleoreise.de/diggy-meaning-kqkxufj/sl72n.php?e2775b=shifting-property-of-laplace-transform"
} |
• An interesting case of a function which is not in $L^1(\mathbb R)$, but the improper Riemann integral is defined! – Yiorgos S. Smyrlis Dec 10 '13 at 21:49
• Can you explain why we have $\int_{-\infty}^\infty\frac{\sin(x)}{x}\,\mathrm{d}x =\frac1{2i}\int_U\frac{e^{iz}}{z}\,\mathrm{d}z-\frac1{2i}\int_L\frac{e^{-iz}}{z}\,\mathrm{d}z$? – principal-ideal-domain Sep 2 '15 at 12:18
• Euler's Formula implies \begin{align}\int_{-\infty-i}^{\infty-i}\frac{\sin(z)}z\,\mathrm{d}z &=\frac1{2i}\int_{-\infty-i}^{\infty-i}\frac{e^{iz}-e^{-iz}}z\,\mathrm{d}z\\ &=\frac1{2i}\int_{-\infty-i}^{\infty-i}\frac{e^{iz}}z\,\mathrm{d}z -\frac1{2i}\int_{-\infty-i}^{\infty-i}\frac{e^{-iz}}z\,\mathrm{d}z\end{align} Then we include the large semicircular contours to close each contour; one in the upper half-plane for the first, since $e^{iz}$ decays quickly there, and the lower half-plane for the second, since $e^{-iz}$ decays quickly there. – robjohn Sep 2 '15 at 17:30 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9857180635575532,
"lm_q1q2_score": 0.8012579917651649,
"lm_q2_score": 0.8128673110375457,
"openwebmath_perplexity": 302.03848694734535,
"openwebmath_score": 0.9720042943954468,
"tags": null,
"url": "https://math.stackexchange.com/questions/594641/computing-int-infty-infty-frac-sin-xx-mathrmdx-with-residue-calc"
} |
c++, object-oriented, classes
}
return false;
}
void getdiagonalmoves(bool turn,int row,int col){
int a,b;
if(turn){
a = row;
b = col;
if (a != 0 && b != 0){
for (;;){
a-=1;
b-=1;
if (board[a][b] > 0) break;
if (board[a][b] < 0 || a == 0 || b == 0){
pseudomoves.push_back(push(row,col,a,b));
break;
}
if(!board[a][b])pseudomoves.push_back(push(row,col,a,b));
}
}
a = row;
b = col;
if (a != 0 && b != 7){
for (;;){
a-=1;
b+=1;
if (board[a][b] > 0) break;
if (board[a][b] < 0 || a == 0 || b == 7){
pseudomoves.push_back(push(row,col,a,b));
break;
}
if(!board[a][b])pseudomoves.push_back(push(row,col,a,b)); | {
"domain": "codereview.stackexchange",
"id": 39176,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, object-oriented, classes",
"url": null
} |
acid-base, ph, titration
Title: What does 0.12 N mean on a bottle of sulfuric acid? I just bought a bottle of sulfuric acid in order to simulate acid rain for an experiment. I was wondering what $0.12\:\mathrm{N}$ on the bottle means. I need a simplified version of the explanation as I'm currently a freshman in high school taking biology, I have never taken a chemistry course before. I've read that the $\mathrm{N}$ means normal, but the explanation included a ton of jargon that I couldn't understand.
The time in question: does the $0.12\:\mathrm{N}$ mean concentration, as in $12\%$ concentration?
How would you guys suggest making simulated acid rain with this? My guess is that I would keep titrating the sulfuric acid into the water until the $\mathrm{pH}$ gets to my preferred $\mathrm{pH}$. 0.12N is indeed 0.12 normal. In short, there are 0.12 moles of hydrogen ions per liter. Since this is sulfuric acid, it is 0.06 moles of sulfuric acid per liter.
0.12 moles of hydrogen ions per liter would give a pH just less than 1. To obtain a pH near 3, you would need to dilute 1 mL of this solution to 100 mL. For a pH of 4, dilute 1 mL to 1000 mL. | {
"domain": "chemistry.stackexchange",
"id": 10240,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "acid-base, ph, titration",
"url": null
} |
c++
//one extra for the node at the end
cout << head->data << endl;
}
}
to the for loops above. Is there anything else I should keep in mind? I'm following the Stanford CS linked list basics and problem set. This is C++, not C. Therefore, your linked list class should contain the methods for operating on the list, and it shouldn't expose implementation details like nodes. For traversing the list, provide iterators. You should also make it a template so that it can be used with any type
That's the general picture. More specifically:
If you insist on traversing with a dedicated function for it, make it take a function (or functor!) so that anything can be done with the nodes.
You've not created any mechanism for deleting the nodes. Your class should do that in its destructor.
You're not doing a lot of error checking that you should be. That's not as relevant when you turn it into a class, but making sure head isn't null is very important. You're doing that in traverse now, but length also needs it.
To summarise, if the user of your class sees a single pointer, you can be sure you're doing it wrong. | {
"domain": "codereview.stackexchange",
"id": 1350,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++",
"url": null
} |
fluid-dynamics, atmospheric-science, vortex
Since the velocity needs to go to zero between the radius of maximum wind and $r=0$, there is a significant shear (meaning large velocity gradient). Such a shear flow in the eye may fuel turbulence according to the turbulence kinetic energy equation, look at the "shear production" term. Turbulent diffusion in turn is a mechanism by which vorticity might be homogenised inside the eye.
This argument is hand-wavy because although the shear production term in the TKE equation is (empirically) almost always positive in the atmosphere, it is impossible to tell whether this will be the case here since we don't know the sign of the eddy correlation term. Also, there are many other terms in the TKE equation that could potentially cancel out the effects of shear production.
More formally, we can do the following: in addition to the gradient wind balance (1) which holds in the horizontal, there is (again to good approximation) a hydrostatic balance in the vertical between gravity and the vertical pressure gradient:
$$ -\frac{1}{\rho}\frac{\partial p}{\partial z}-g=0 \tag 4$$. | {
"domain": "physics.stackexchange",
"id": 33163,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "fluid-dynamics, atmospheric-science, vortex",
"url": null
} |
fluid-dynamics, terminology, atmospheric-science
Title: In fluid dynamics does $u_x-v_y$ have a name? I have come across the quantity:
$$\frac{\partial u}{\partial x}-\frac{\partial v}{\partial y}$$
of the two dimensional velocity field $(u,v)$. Does this quantity have a name or is it related to any quantity with a name? This quantity is called the Stretching deformation. The reference (1) given below says the following about it:
Stretching deformation, $D^{(1)}$, is a measure of the deformation of a fluid element due to compression in one direction and simultaneous dilation in a direction orthogonal (90 degrees) to it.
Here by deformation it seems to be referring directly to a change in shape rather then also including changes in areas. This is because the quantity above is zero when the shape is kept the same but the area varied.
Reference
(1) Mak, M. 2011. Atmospheric Dynamics. Cambridge: Cambridge University Press (page 50 Link to Google Books) | {
"domain": "physics.stackexchange",
"id": 32587,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "fluid-dynamics, terminology, atmospheric-science",
"url": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.