text stringlengths 49 10.4k | source dict |
|---|---|
c, linked-list
I think the remove function needs the most work. I did post that function on this site, however I think I needed to include the whole implementation to get the best feedback. Will this work on an embedded system? Several problems I see:
accList_allocate
accList_allocate doesn't do what you probably think. It creates a new accList, yes, but this new one will not be visible to the caller (and thus, will be lost as memory leakage). If you want to initialize the pointer passed to it, use a pointer-to-pointer:
void accList_allocate(struct accList **outList) //allocate and initialize to NULL values
{
struct accList* theList = Malloc(sizeof(struct accList));
theList->head = NULL;
theList->tail = NULL;
theList->size = 0;
*outList = theList;
}
Also, you should really check the return value of Malloc. Especially on embedded systems, there's a real possibility of running out of memory. Let the caller handle the error, but tell him that something's wrong.
appendToEnd
Same as with accList_allocate, check Malloc's return value and return some kind of error code if it's NULL. What you're writing there is library code that should always handle errors gracefully and let the caller decide whether to crash and burn or recover and try again.
removeData
Please refer to my answer in your other thread. | {
"domain": "codereview.stackexchange",
"id": 1964,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c, linked-list",
"url": null
} |
php
parse_request_url takes the requested url (e.g. domain.com/this/is/my/request) and checks to see if a controller exists with that name (can be in directories or file). Generally this is very good code, but I try to be thorough when reviewing so I've listed every minor point that I could think of.
It looks like you write OO code in other places, but you chose to make your bootstrap procedural. Believe it or not there are benefits to an OO bootsrap! You can define methods for different parts of the system that you want to bring up. There will always be some procedural code required to call the bootstrap, but it could look more like this:
$bootstrap = new Bootstrap();
$bootstrap->initializeAutoload();
$bootstrap->initializeErrorReporting();
$bootstrap->initializeRouter();
As GordonM said, use spl_autoload_register.
You are tightly bound to the config class by your static calls to it. This makes it hard to test your bootstrap. It is understandable in the bootstrap as you have only just brought the autoload up. Keep reading and at the end I'll tell you what I recommend on that.
Personally I don't like the error control operator @. I find it hard to understand what will happen when your server redirect url is not defined. This is very minor, but I would use:
if (isset($_SERVER['REDIRECT_URL']))
{
$url_object = $router->parse_request_url($_SERVER['REDIRECT_URL']);
}
else
{
$url_object = $router->parse_request_url('');
}
$namespace and $class are misleading to me, I would rewrite those:
$class_name = '\baremvc\controllers\\' . $url_object->Controller;
$controller = new $class_name; | {
"domain": "codereview.stackexchange",
"id": 1156,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "php",
"url": null
} |
of reference, and motions over the surface. Landing on slope b 13 of 21. Chapter 10 Dynamics of Rotational Motion 10. Now you will learn how to solve problems that have bodies that consist of many particles For this type of problem you will have to use kinematics of a rigid body instead of kinematic of a particle. Mass moments of inertia have units of dimension ML 2 ([mass] × [length] 2). In this module, we will examine Torque and Moment of Inertia (the rotational analogs of force and mass) and Newton's Second Law for Rotation. In which case is the torque due to the force about the rotation axis biggest? A. • A mechanical system with a rotating wheel of mass m w (uniform mass distribution). In general, the quest of physics is to develop descriptions of the natural world that correspond closely to actual observations. AP Momentum MC. Start studying 1 KINEMATICS AND DYNAMICS-KHAN ACADEMY. It includes curriculum, curriculum support material, reference material, and pedagogical and physics education research inspired content. For each rotation of the wheel, the car travel a distance equal to the circumference of the wheel. Khan Academy (KA) is one of the world's most popular open educational resources (OER), with more than 57 million registered users and 15 million monthly site visits as of May 2016. Learn vocabulary, terms, and more with flashcards, games, and other study tools. Learn AP Physics. Videos below this point are in-class lectures. As a result, exposure may be prolonged. Kinematics of Rotational Motion • Observe the kinematics of rotational motion. 01T Physics I, Fall 2004. Although most of the time the Ferris wheel is operating, it has a constant angular velocity, when it stops and starts it has to speed up or slow down. Khan Academy Physics 288,731 views. Now let’s please shift the focus (yours and mine) toward the destination. 4 Torque 10. Oscillation & Simple Harmonic Motion. Rotational dynamics and torque may sound like big words, but you probably have some knowledge of them already without even knowing it! Check out the quiz and worksheet to see what you understand. 3 - Rotational Energy and Momentum Gyroscope Investigation Lab IB Angular Momentum Lab IB Group Quiz 8. The Nitrogen Cycle. Khan Academy--youtube lectures on virtually any topic MIT lectures--youtube lectures by Walter | {
"domain": "ac-immacolata.it",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9648551556203814,
"lm_q1q2_score": 0.8102216422533263,
"lm_q2_score": 0.8397339616560072,
"openwebmath_perplexity": 1507.9404399834234,
"openwebmath_score": 0.4129481315612793,
"tags": null,
"url": "http://ac-immacolata.it/nmxv/rotational-dynamics-khan-academy.html"
} |
# Eigenvectors of orthogonal transformations
Let $T : \mathbb R^n \to \mathbb R^n$ be a dot product-preserving transformation, and let $v_1$, $v_2$ be eigenvectors with eigenvalues $\lambda_1$, $\lambda_2$. If $\lambda_1 \neq \lambda_2$, can we conclude $v_1 \cdot v_2 = 0$?
Here is some partial progress:
First, note that if $v$ is any eigenvector with eigenvalue $\lambda$, then $$||v||^2 = v \cdot v = Tv \cdot Tv = \lambda v \cdot \lambda v = \lambda^2 ||v||^2.$$ Since $v \neq 0$, we deduce $\lambda^2 = 1$. Hence $\lambda = \pm 1$.
Since $\lambda_1 \neq \lambda_2$ implies, WLOG, $\lambda_1 = 1$ and $\lambda_2 = -1$, we have $$v_1 \cdot v_2 = Tv_1 \cdot Tv_2 = \lambda_1 v_1 \cdot \lambda_2 v_2 = \lambda_1 \lambda_2 (v_1 \cdot v_2) = -(v_1 \cdot v_2),$$ so $v_1 \cdot v_2 = 0$.
But there's no way this is that simple... | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9871787872422174,
"lm_q1q2_score": 0.8161123504842484,
"lm_q2_score": 0.8267117983401363,
"openwebmath_perplexity": 225.18426306473756,
"openwebmath_score": 0.9704775810241699,
"tags": null,
"url": "https://math.stackexchange.com/questions/1699798/eigenvectors-of-orthogonal-transformations"
} |
c++, performance
clock_t begin_time = clock();
vector <double> res = dist(x1, x2, y1, y2,cutoff);
cout << float(clock() - begin_time) / CLOCKS_PER_SEC<<endl;
cout << accumulate(res.begin(), res.end(), 0.0) /res.size() << endl;
begin_time = clock();
res=all_dist(x1, x2, y1, y2);
cout << float(clock() - begin_time) / CLOCKS_PER_SEC << endl;
vector <double> res2;
for (int i = 0; i < res.size(); ++i)
if (res[i] < cutoff)
res2.push_back(res[i]);
cout << accumulate(res2.begin(), res2.end(), 0.0) / res2.size() << endl;
} | {
"domain": "codereview.stackexchange",
"id": 36328,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, performance",
"url": null
} |
Working out the intersection points of the three lines, we can see that the intersection of $y = y_1(x)$ and $y = y_2(x)$ occurs at $x = -2$ and the intersection of $y = y_2(x)$ and $y = y_3(x)$ occurs at $x = 3.$ Let
• $x = x_1$ at the tangent point with $y = y_1(x)$;
• $x = x_2$ the tangent point with $y = y_2(x)$; and
• $x = x_3$ the tangent point with $y = y_3(x).$
Due to the $y$-coordinates and slopes at the intersection points, it is clear that $x_1 < -2 < x_2 < 3 < x_3$; moreover, $-2$ is midway between $x_1$ and $x_2$ and $3$ is midway between $x_2$ and $x_3.$ It follows that $$x_3 - x_1 = 2\left(\frac{x_3 + x_2}2 - \frac{x_2 + x_1}2\right) = 2(3 - (-2)) = 10.$$
The tangency condition implies that $f'(x_1) = y_1'(x) = -4$ and $f'(x_3) = y_3'(x) = 6.$ But $f'(x) = 2ax + b,$ so $20a = 2a(x_3 - x_1) = f'(x_3) - f'(x_1) = 10,$ and therefore $a = \frac12.$ It is then a relatively straightforward exercise to find the other two coefficients. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9843363494503271,
"lm_q1q2_score": 0.8733077265915363,
"lm_q2_score": 0.8872045892435128,
"openwebmath_perplexity": 287.7911885171946,
"openwebmath_score": 0.832466721534729,
"tags": null,
"url": "https://math.stackexchange.com/questions/2772749/finding-coefficients-in-polynomial-given-three-tangents"
} |
Boolean algebra. 0 and 1. In mathematics and mathematical logic, Boolean algebra is the branch of algebra in which the values of the variables are the truth values true and false, usually denoted 1 and 0, respectively. Rules of Boolean Algebra Table 4-1 lists 12 basic rules that are useful in manipulating and simplifying Boolean expressions. Best of Luck.. You can view Result with Detail Solution of each question after completion of the test. Rule in Boolean Algebra. It is also called as Binary Algebra or logical Algebra. Boolean logic (or Boolean algebra) minimization generally follows a Karnaugh map approach, also known as a Veitch diagram, K-map, or KV-map. Active 6 years, 3 months ago. Boolean Algebra & Minimization Online Test : SET 1. Boolean Algebra Laws and Rules. A basic understanding of this system is indispensable to the study and … In this example, we created a circuit for the function F = A + A’.B with two gates. All possible logic operations for two variables are investigated and from that, the most useful logic gates used in the design of digital systems are determined. Boolean Algebra Laws Boolean Minimization Example. $\endgroup$ – Jean Marie Sep 23 '19 at 18:13. add a comment | 2 Answers Active Oldest Votes. 7. The following two approaches can be used for simplification of a Boolean expression: Algebraic method (using Boolean algebra rules) Karnaugh map method; Representation of K-map: With n-variable Karnaugh-map, there are 2 n cells. The K-map simplification technique is simpler and less error-prone compared to the method of solving the logical expressions using Boolean laws. Before continuing with this section, you should make sure you are familiar with the following topics: Boolean Algebra; Basic Gates and Functions Although any of these methods can be employed using pen and paper, it is far easier (and more productive) to implement searching algorithms on a … Shannon [7] showed how the Boolean algebra can be used in … Boolean algebra minimization. Number representations and computer arithmetic (fixed and floating-point). The book’s validity depends on 3 boolean … Boolean Algebra and Reduction Techniques. On the bright side, all of our constraints are now represented by a boolean algebra variable. When implementing a Boolean function in | {
"domain": "mitchell-lp.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9793540716711547,
"lm_q1q2_score": 0.8264721085951245,
"lm_q2_score": 0.843895106480586,
"openwebmath_perplexity": 813.6576156168722,
"openwebmath_score": 0.6313974261283875,
"tags": null,
"url": "https://mitchell-lp.com/football-kits-tex/099a2d-boolean-algebra-minimization"
} |
information-theory
Title: Information theory vs system theory ( commented in Determining linearity, causality, memory, and time invariability from a picture of the signal) I have seen this question :
At the comment asked about :
Is this "information theory" or "systems theory"? – The Photon
So i liked to know why this comment asked? Why the system theory vs information theory
I am newbie about this topic and asked here for better saving time and ...
Thanks for your attention. Yes that's most probably a typo; it's the system theory which deals with the concept of linearity, causality, etc.
Linear system theory deals with characterisations of systems in terms of its input-output relationship through applied signals. It describes how to compute the output in time and frequency domains as well as characterises systems according to their properties such as linearity, stability, causality etc.
Information theory deals with quantification of information (called as the entropy) contained within a source according to either its observed output (via statistical computation) or to its descriptive model (via probabiitistic computation). | {
"domain": "dsp.stackexchange",
"id": 8204,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "information-theory",
"url": null
} |
classical-mechanics
&= C_x [(v_x'+v_x)+R(\omega'+\omega)] \\
&= C_x [g_x' + g_x]
\end{align*}
where I have inserted the equations for the change in $v_x$ and $\omega$ in terms of $C_x$, as well as defining $g_x=v_x+R\omega$ as the $x$-velocity of the point
on the sphere which is in contact with the wall.
In order for $\Delta K$ to be zero, there are only two possibilities:
either $C_x=0$, in which case we have a smooth hard collision,
or $g_x'=-g_x$, in which case the velocity at the point of impact is reversed (and we can derive the equation for $C_x$ given earlier).
In Lyklema's paper (if you can get hold of it) you'll see that the analogous equation in 3D is $|\mathbf{g}_\perp'|^2=|\mathbf{g}_\perp|^2$,
where $\mathbf{g}_\perp$ is that part of the vector $\mathbf{g}$ which is perpendicular to the normal to the surfaces in contact. (The derivation is for two colliding spheres, but it can easily be adapted to one sphere colliding with another massive, huge, sphere, which acts like a wall). This leaves open the possibility of conserving energy by rotating $\mathbf{g}_\perp$ through some arbitrary angle in the plane of contact to give $\mathbf{g}_\perp'$. However, it is hard to argue that this makes physical sense, without ascribing some exotic properties to the surfaces (chirality). The non-chiral option is to make the angle $180^\circ$ giving $\mathbf{g}_\perp'=-\mathbf{g}_\perp$.
To be honest, in many places this reversal of the velocities at contact is often taken to be the defining property of the perfectly rough sphere model; the detailed justification involves a fair bit of work. | {
"domain": "physics.stackexchange",
"id": 53202,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "classical-mechanics",
"url": null
} |
quantum-gate, pauli-gates, bloch-sphere
A state corresponds to a pair of complex numbers modulo multiplication by a scalar. Write it as some $[\alpha:\beta]\equiv(\alpha,\beta)\mathbb{C}\in\mathbb{CP}^1$ (the notation comes from projective geometry). Almost all of these can be represented as $[1:z]$ for some $z\in\mathbb{C}$. The remaining point becomes the point at infinity.
Via the stereographic projection, we map $[1:z]$ to
$$\left( \frac{2z}{1+|z|^2}, \frac{1-|z|^2}{1+|z|^2}\right)\in S^2,$$
where in saying that this is an element of $S^2\subset\mathbb{R}^3$ I'm splitting the first component in its real and imaginary parts.
To fix ideas, this mapping sends
$$[1:0]\to (0,0,1), \qquad [1:\infty]\equiv [0:1]\to (0,0,-1),\\
[1:\pm 1]\to (\pm 1,0,0), \qquad [1:\pm i]\to (0,\pm1,0).$$
You can picture this mapping as taking the complex plane, and "bending it" downwards in a way that keeps the complex origin $(0,0)$ fixed, while everything else bends below it until it wraps into a sphere. The origin becomes the north pole of the sphere, while the point at infinity is sent to the south pole. | {
"domain": "quantumcomputing.stackexchange",
"id": 3678,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-gate, pauli-gates, bloch-sphere",
"url": null
} |
javascript, sorting
Title: A package for sort algorithms - v2 Looking for general feedback and praise. This is for learning an not implementation as I would expect the built is sort algos to be much faster.
Addressed issues here:
A package for sort algorithms
/***************************************************************************************************
**ALGORITHMS
***************************************************************************************************/
// self used to hold client or server side global
(function (self) {
"use strict";
// holds (Pub)lic properties
var Pub = {},
// holds (Priv)ate properties
Priv = {},
// holds "imported" library properties
$A;
(function manageGlobal() {
// Priv.g holds the single global variable, used to hold all packages
Priv.g = '$A';
if (self[Priv.g] && self[Priv.g].pack && self[Priv.g].pack.utility) {
self[Priv.g].pack.algo = true;
$A = self[Priv.g];
} else {
throw new Error("algo requires utility module");
}
}());
Pub.swap = function (arr, i, j) {
var temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}; | {
"domain": "codereview.stackexchange",
"id": 5728,
"lm_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, sorting",
"url": null
} |
you can use the center of the image as the center of rotation and use the technique you just learned to shift that point back to where it started off. It is also known as rotational inertia. Clockwise & Counterclockwise Rotation of a matrix using Numpy Library. That way, regardless of the direction the sprite is facing in 2D the bullet will move in a direction away from the face of the sprite. A rotation is a circular movement of an object around a center (or point) of rotation. T = k * theta. We can easily verify that this is 90 degrees by remembering that cosine of 90 is 0, and sine of 90 is 1. reduce (self[, left, right, return_indices]) Reduce this rotation with the provided rotation groups. Rotations Date_____ Period____ Graph the image of the figure using the transformation given. There are 2π radians per revolution, and so the initial angular velocity is: ω 1 = 400. It will mostly be a rectangle. For 2D Planar simulations, your geometry exists in the XY plane and the Z-axis is oriented out of the computer screen (see image below) If you use the right-hand thumb rule, you'll find that, counter-clockwise (CCW) rotation is +ve and clockwise (CW) rotation is -ve. – Rotation to coincide the shifted axis with Z axis •R 1: Rotation around X such that the axis lies on the XZ plane. Combining translation and rotation. Import your 2D CAD drawings in DXF format Input values from equations, sliders and DDE links to MATLAB and Excel Simulate non-linear or user events using a built-in formula language Design linkages with pin joints, slots, motors, springs, and dampers Create bodies and specify its mass properties, initial velocity, electrostatic charge, etc. Note that translations and rotations do not commute! If the operations are applied successively, each is transformed to. However, since the two vectors are on the X-Y plane, this rotation axis would cause rotation only on the X-Y plane, so the axis is always parallel to the Z-axis. Rotations in two dimensions: Life is simple in 2D. A positive rotation is counterclockwise and a negative rotation is clockwise. For example, in 2-space n = 2, a rotation by angle θ has | {
"domain": "audio-upgrade.pl",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9822876992225169,
"lm_q1q2_score": 0.8206851953639296,
"lm_q2_score": 0.8354835309589074,
"openwebmath_perplexity": 643.2726873535121,
"openwebmath_score": 0.6907839775085449,
"tags": null,
"url": "http://audio-upgrade.pl/rotation-2d-formula.html"
} |
(This is quite similar to and inspired by Donald Splutterwit's answer.)
Using $$1 < x \le y \quad \Longrightarrow \quad \frac{y}{x} \le \frac{y-1}{x-1}$$ it follows that for $1 \le k \le n$ $$\frac{n}{k} \le \frac{n-1}{k-1} \le \frac{n-2}{k-2} \le \dots \le \frac{n-(k-1)}{k-(k-1)} = n-k+1$$ and therefore $$\binom{n}{k} = \frac{n}{k} \cdot \frac{n-1}{k-1} \cdot \frac{n-2}{k-2} \cdots \frac{n-(k-1)}{k-(k-1)} \le (n-k+1)^k \, .$$ and this holds for $k=0$ as well.
Your idea to show that $${n\choose k}\le(\frac{en}{k})^k \le (n-k+1)^k$$ cannot work because the second inequality does not hold for $k = n$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9808759657647961,
"lm_q1q2_score": 0.8064655553052342,
"lm_q2_score": 0.8221891283434876,
"openwebmath_perplexity": 530.9613911406841,
"openwebmath_score": 0.992379903793335,
"tags": null,
"url": "https://math.stackexchange.com/questions/2401543/inequality-involving-kth-root-of-n-choose-k/2401666"
} |
one-to-one) if each element of the codomain has at most one element of the domain that maps to it. Source: Lecture 10, Slide 82. Integers The set$\mathbb{Z} = \left\{ ..., -2, -1, 0, 1, 2, ... \right\}$is the set of all the integers. Source: Lecture 00, Slide 22. Irational number An irrational number is a number that is not rational. Source: Lecture 02, Slide 49. ## K k-colorable An undirected graph$G=(V,E)$is k-colorable iff the nodes in$V$can be assigned one of$k$different colors such that no two nodes of the same color are joined by an edge. Source: Lecture 06, Slide 62. ## L Lemma A lemma is a smaller result proven specifically as a stepping stone towards a larger result. Source: Lecture 01, Slide 63. Length (Cycle) The length of a cycle is the number of edges in that cycle. Source: Lecture 06, Slide 13. Length (Path) The length of a path is the number of edges it contains, which is one less than the number of nodes in the path. Source: Lecture 06, Slide 9. Logical Operator A logical operator is an operator that takes in some number of bits and produces a new bit as output. Source: Lecture 01, Slide 47. Loop Invariants "If P is true before we perform an action, it is true after we perform an action." Source: Lecture 03, Slide 54. ## M Mapping If f is a function from A to B, we say that f is a mapping from A to B. Source: Lecture 10, Slide 68. Mathematical Proof An argument that demonstrates why a mathematical statement is true. Source: Lecture 01, Slide 7. ## N Natural numbers The set$\mathbb{N} = \left\{0, 1, 2, 3 ... \right\}$is the set of all the natural numbers. Source: Lecture 00, Slide 22. Natural Numbers Cardinality Theorem:$|\mathbb{N}| = |\mathbb{N}^2|$. Source: Lecture 11, Slide 21. Theorem:$|\mathbb{N}| \neq | {
"domain": "stanford.edu",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9817357237856482,
"lm_q1q2_score": 0.8071724454190093,
"lm_q2_score": 0.822189134878876,
"openwebmath_perplexity": 3511.866585323594,
"openwebmath_score": 0.9998413324356079,
"tags": null,
"url": "http://web.stanford.edu/class/cs103/reference/"
} |
c++, performance, c++11, benchmarking
Or, if you don't mind removing the element from the map completely, you could just use erase:
inline void ScopeTimerStaticCore::clearTimingForNamedScope(const ScopeTimer::ScopeSignature& scopeName) {
ScopesTiming& instance = getScopesTimingStaticInstance();
instance.erase(scopeName);
}
I also notice that these functions would get a lot shorter and simpler to read if you put their definitions in-line into the class body of ScopeTimerStaticCore. In this case you could omit the keyword inline and the qualification of the parameter type:
void clearTimingForNamedScope(const ScopeSignature& scopeName) {
ScopesTiming& instance = getScopesTimingStaticInstance();
instance.erase(scopeName);
}
(Assuming that ScopeTimerStaticCore contains a member typedef using ScopeSignature = ScopeTimer::ScopeSignature;, I guess. It probably should — or vice versa.) | {
"domain": "codereview.stackexchange",
"id": 33237,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, performance, c++11, benchmarking",
"url": null
} |
machine-learning, python, cost-function
This means 15% chance of being a cat, 10% chance of being a dog and 75% chance of being a bird. Now, notice that this means your algorithm will still consider the input as a bird, so in terms of classification, sure the output would be correct... but it would not be as correct as it had predicted 100% chance of a bird.
So, the intuition is that the logloss measures how far away you are from perfection, where perfection would be identifying the correct label with a 100% chance and the incorrect labels with a 0% chance.
Final word of advice: Do NOT be afraid of math, you will really need to get the grasp of it at some point, do not let the sum terms intimidate you, after all they just represent loops in programming.
UPDATE
Let's dive into the math, specially to demystify it.
The logloss formula is given by
$$ LogLoss = - \frac{1}{n} \sum\limits_{i=1}^n [y_i \cdot log(\hat{y_i}) + (1-y_i) \cdot log(1-\hat{y_i}) ] $$
Where
$n$ represents the number of examples, in our case i will use 2 examples.
$y_i$ represents the correct answer for example $i$
$\hat{y}_i$ represents our prediction for example $i$
So, for our example we have two examples, (remember that the examples are denoted by $y_i$) which are
[0, 1, 0] # Example 1: This means the correct answer is dog
[1, 0, 0] # Example 2: This means the correct answer is cat
Now, let's go for our predictions, remember that the predictions are denoted by $\hat{y}$ let's say they are
[0.1, 0.6, 0.3]
[0.85, 0.05, 0.1] | {
"domain": "datascience.stackexchange",
"id": 4378,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "machine-learning, python, cost-function",
"url": null
} |
newtonian-mechanics, classical-mechanics, fluid-statics, buoyancy
or, if we define the height of the object in oil and in water as $s_\text{oil}=h_w-h_T$ and $s_\text{water}=h_T+H-h_w$ respectively, we get
$$f_\text{water}-f_\text{oil}=(\rho_\text{water}gs_\text{water}+\rho_\text{oil}gs_\text{oil})A$$
Note that these two terms are in fact the weights of the water and oil displaced,
$$f_\text{water}-f_\text{oil}=w_\text{water}+w_\text{oil}$$
but that does not mean the oil pushes directly upwards on the objects. | {
"domain": "physics.stackexchange",
"id": 77446,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "newtonian-mechanics, classical-mechanics, fluid-statics, buoyancy",
"url": null
} |
[The use of Quiet suppresses a lack-of-convergence warning due to the prevention of recursive subdivision with MaxRecursion -> 0. It could also be achieved by effectively turning off convergence checking with the option PrecisionGoal -> -1.]
Update: Apparently someone doesn't get it....
OK, there are two sources of confusion I can imagine. Without feedback, it's only a guess. One is that NIntegrate[] is misunderstood. The other is that the mathematics of the Gauss rule is misunderstood; although this is not a mathematics site per se, perhaps a brief explanation would be helpful.
First, NIntegrate[f[x], {x, a, b}] recursively subdivides the interval and resamples the subintervals until the error estimate is less than a certain goal. So (A), comparing a low-order approximation such as a five-point Gauss rule with NIntegrate[] as if they are equivalent approximations is not fair. And (B), if the NIntegrate[] result is being treated as (very close to) the exact value, comparing a low-order approximation with it is useful only for estimating the error; the OP's gauss is in fact correct, not wrong, although it has a large error on the piecewise example. The large error is due to the mathematics, should not be surprising based on theory, and follows from a particular analysis of the example. Soooo... | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9653811581728097,
"lm_q1q2_score": 0.8065600627059605,
"lm_q2_score": 0.8354835350552604,
"openwebmath_perplexity": 1788.2937681379135,
"openwebmath_score": 0.46974101662635803,
"tags": null,
"url": "https://mathematica.stackexchange.com/questions/127015/why-gauss-legendre-rule-gives-wrong-result-for-piecewise-polynomial-function"
} |
c#, linked-list
public Word()
{
_linkedObject = new LinkedObject<Sentence>(this);
}
public string Value
{
get { return _linkedObject.Value; }
set { _linkedObject.Value = value; }
}
public WordPrevious
{
get { return _linkedObject.Previous.Value; }
set { _linkedObject.Previous = value._linkedObject; }
}
public Word Next
{
get { return _linkedObject.Next.Value; }
set { _linkedObject.Next = value._linkedObject; }
}
public IEnumerable<Word> Before
{
get { return _linkedObject.Before.Select(x => x.Value); }
}
public IEnumerable<Word> After
{
get { return _linkedObject.After.Select(x => x.Value); }
}
}
Example (I use a loop to create the real chain):
var foo = new LinkedObject<string>
{
Value = "foo",
Next = new LinkedObject<string>
{
Value = "bar",
Next = new LinkedObject<string>() { Value = "baz" }
}
};
// foo, bar, baz
foo.Next.Remove(); // foo, baz Rule your own Find extension method instead of redoing it all over again.
public static LinkedListNode<T> Find<T>(this LinkedList<T> list, Predicate<T> pred)
{
var node = list.First;
while (node != null)
{
if (pred(node.Value))
{
return node;
}
node = node.Next;
}
return null;
} | {
"domain": "codereview.stackexchange",
"id": 18450,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c#, linked-list",
"url": null
} |
\begin{align} \int_1^\infty \frac{\sqrt{x-1}}{(x+1)^2} dx &= \int_1^\infty \frac{\sqrt{2} (u-1)^{\frac{1}{2}}}{4u^2} 2 du \\ &= \frac{1}{\sqrt{2}} \int_1^\infty u^{-2} (u-1)^\frac{1}{2} du \end{align} Now let $u = \frac{1}{t}$, so that $du = \frac{-1}{t^2} dt$. Continuing. \begin{align} \phantom{\int_1^\infty \frac{\sqrt{x-1}}{(x+1)^2} dx} &= \frac{1}{\sqrt{2}} \int_0^1 t^2 (1-t)^\frac{1}{2} \frac{1}{\sqrt{t}} \frac{1}{t^2} dt \\ &= \frac{1}{\sqrt{2}} \int_0^1 t^{\frac{-1}{2}} (1-t)^\frac{1}{2} dt \\ &= \frac{1}{\sqrt{2}} \int_0^1 t^{\frac{1}{2}-1} (1-t)^{\frac{3}{2} - 1} dt \\ &= \frac{1}{\sqrt{2}} B ( \frac{1}{2} . \frac{3}{2} ) \\ &= \frac{\Gamma(\frac{1}{2}) \Gamma(\frac{3}{2})} {\sqrt{2}\Gamma(2)} \\ &= | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9848109520836026,
"lm_q1q2_score": 0.8520821508171078,
"lm_q2_score": 0.8652240808393984,
"openwebmath_perplexity": 289.02061330389927,
"openwebmath_score": 1.000000238418579,
"tags": null,
"url": "https://math.stackexchange.com/questions/1526717/evaluate-int-1-infty-frac-sqrtx-1x-12-mathrmdx/1526750"
} |
Math Help - Integral - partial fractions?
1. Integral - partial fractions?
$\int \frac{dx}{4x^{2/3}-4x^{1/3}-3}$
$u=x^{1/3} \text{ }du=\tfrac{1}{3}x^{-2/3} \text{ }x=u^3$
$=\int\frac{x^{-2/3}*3du}{(2u+1)(2u-3)}$
$=3\int\frac{du}{u^2(2u+1)(2u-3)}$
Am I going about this the right way? I ask because when I use partial fractions, I am getting 2 different values for A.
2. Originally Posted by symstar
$\int \frac{dx}{4x^{2/3}-4x^{1/3}-3}$
$u=x^{1/3} \text{ }du=\tfrac{1}{3}x^{-2/3} \text{ }x=u^3$
$=\int\frac{x^{-2/3}*3du}{(2u+1)(2u-3)}$
$=3\int\frac{du}{u^2(2u+1)(2u-3)}$
Am I going about this the right way? I ask because when I use partial fractions, I am getting 2 different values for A.
you are ok so far
so you must be making a mistake with the partial fractions part. what did you get?
3. Originally Posted by symstar
$\int\frac{du}{u^2(2u+1)(2u-3)}$
Put $u=\frac1z$ and your integral becomes $-\int{\frac{z^{2}}{(2+z)( 2-3z)}\,dz},$ hence | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9802808765013518,
"lm_q1q2_score": 0.85851722708877,
"lm_q2_score": 0.8757869786798663,
"openwebmath_perplexity": 1219.5319643804598,
"openwebmath_score": 0.9905178546905518,
"tags": null,
"url": "http://mathhelpforum.com/calculus/49549-integral-partial-fractions.html"
} |
Kudos [?]: 62 [0], given: 2
Schools: Booth, Stern, Haas
Re: Graphic approach to problems with inequalities [#permalink]
### Show Tags
07 Mar 2009, 05:40
walker wrote:
Hi all! My friend, Tarek, PM me and asked me to show how to use the graphic approach to problem with inequalities. I really love such approach because it is not only fast one after training, but also reliable. So, I try to illustrate how to use it.
1) If $$(x/y)>2$$, is $$3x+2y<18?$$
(1) $$x-y$$ is less than $$2$$
(2) $$y-x$$ is less than $$2$$
1. First of all, we draw x/y>2. x/y=2 - is a boundary. (see figure 1). we should note that if one of the variables is negative and other is positive, x/y will be always negative and less than 2. Therefore, our set of x,y that satisfied x/y>2 lies between line x/y=2 and x-axis.
How do we find which area should be shaded? In first step you defined that set of x and y lies between line x/y=2 and x-axis. Thanks
Kudos [?]: 62 [0], given: 2
CEO
Joined: 17 Nov 2007
Posts: 3584
Kudos [?]: 4584 [0], given: 360
Concentration: Entrepreneurship, Other
Schools: Chicago (Booth) - Class of 2011
GMAT 1: 750 Q50 V40
Re: Graphic approach to problems with inequalities [#permalink]
### Show Tags
07 Mar 2009, 09:24
kbulse wrote:
How do we find which area should be shaded? In first step you defined that set of x and y lies between line x/y=2 and x-axis. Thanks | {
"domain": "gmatclub.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9713473240548128,
"lm_q1q2_score": 0.8051874891633298,
"lm_q2_score": 0.8289388040954683,
"openwebmath_perplexity": 5393.123912518315,
"openwebmath_score": 0.5411089658737183,
"tags": null,
"url": "https://gmatclub.com/forum/graphic-approach-to-problems-with-inequalities-68037.html?fl=similar"
} |
electromagnetism, optics, classical-electrodynamics
Title: Does the direction of propagation of the natural light is perpendicular to the direction of electric and magnetic field making up natural light? I know that the direction of propagation of the wave(light) is perpendicular to the direction of electric and magnetic field in the situation of plane waves. And I want to know the relation between the direction of propagation and field in the situation of natural light. Your text is rather muddled, but to answer the question: the Poynting vector is normally in the direction of propagation, which is to say the E and B fields are perpendicular to the direction of prop. This is always true in a vacuum, but it turns out that in various materials, the Poynting vector can be off-axis. | {
"domain": "physics.stackexchange",
"id": 26487,
"lm_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, optics, classical-electrodynamics",
"url": null
} |
general-relativity, computational-physics, fluid-statics, equilibrium
Plot of $\mathrm{Log}_{10} \tilde{p}$, for the same $\gamma = \frac{4}{3}$:
Apparently, the pressure never get to 0! Unless I made a mistake with my Mathematica programming (I have strong confidence there isn't any), I can't find the outer radius with $\tilde{p} = 0$! How can I find $R = r_{\text{max}}$?? Should I use some pressure cutoff at an arbitrary value? Using a cutoff like $\tilde{p}_{\min} = 0.0001$ is very arbitrary and can give any radius, so what's going on here?
EDIT: About the Mathematica coding of this numerical integration, you can see some of the details here:
https://mathematica.stackexchange.com/questions/288315/how-to-remove-an-apparent-singularity-in-ndsolve
EDIT 2: Here's an example of the Mass-Radius relation curve: The TOV equations in their original form $\{p'(r),m'(r)\}$ have some problems reagarding their numerical implementation as discussed in this question: The integration domain is not known at the beginning of numerical ODE integration and determining the stellar radius $R$ as $p(R)=0$ is for some EoS problematic. Additionally the system in $\{p'(r),m'(r)\}$ is very stiff and not very well conditioned. This has been known in literature for a long while and there is an -- in my opinion perfect solution -- a reformulation of the equations put forward in
L. Lindblom, Phase transitions and the mass-radius curves of
relativistic stars, Phys. Rev. D 58.2 (1998) 024008, arXiv:
gr-qc/9802072 [gr-qc],
and discussed in for example
S. Postnikov, Topics in the Physics and Astrophysics of Neutron
Stars, Electronic Dissertation, Ohio University, 2010,
M. J. Steil, Structure of slowly rotating magnetized neutron stars in
a perturbative approach, Masters Thesis, TU Darmstadt, 2017. | {
"domain": "physics.stackexchange",
"id": 96531,
"lm_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, computational-physics, fluid-statics, equilibrium",
"url": null
} |
sensors, distance-measurement
Title: How to measure height of water I am trying to measure the height [level] of the water in a box that goes from -3°C (saltwater) with water and 150°C dry. Objects will be placed inside the box but will not take up the whole area.
I need a sensor that is robust enough to go through those temperatures and measure accurately. I was thinking of using a float switch on a worm gear, but the motor couldn't stand the heat...
What other methods/sensors are there? I also have a clear tube that runs outside of the tank meant for visually inspecting the height of the water.
Can I use a ultrasound sensor to measure water level? is a closely related question but focuses upon ultrasound. That won't work for my particular case because the contents of the box are effectively unknown. And capacitive techniques won't work either as the box will be grounded. I didn't understand quite clearly what you want, but it sounds definitely like ultrasound. Although you mention that it probably won't work, I would still try it first. Another possibility would be to use radioactive material (gamma-source). But it might be difficult to get this stuff. The radioactive type is used for measurement of fill height in bottles. Though I don't know how they do it exactly.
I recommend to contact companies, which build bottle filling machines. They probably have ready to use solutions.
Concerning the laser: Any laser should be able to do this. The cheapest should be the best suited. You don't need a high quality beam.
If this doesn't help you, please make a drawing, to make your question more understandable. | {
"domain": "engineering.stackexchange",
"id": 1081,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "sensors, distance-measurement",
"url": null
} |
particle-physics, nuclear-physics
Title: Nuclear shadowing effect I am reading some texts which mention the nuclear shadowing effect (NSE). However, they don't explain explicitly what is NSE. So my questions are as follows:
What is the NSE?
What is its origin? The expression of cross section for lepton-nucleon collision has term specifying the finite extent of charge distribution of nucleon.
When expressed in terms of lorentz invariant kinematic variables like x and $Q^2$, this term is referred to as 'Structure Function, $F_2$'. This is an experimentally measurable quantity. We measure it for nucleon as well as nuclei collision with lepton (say, electron).
We have a very good model to find various parameters(e.g. cross section, number of participating nucleons etc) of nucleus-nucleus(AA) collision called as Glauber Model.
The basic assumption of this model is that AA collisions could be build up from nucleon-nucleon(pp) collisions. If this is to be true, we expect that
$Nuclear\; Ratio, R= \frac{{F_2}^{nuclei}/A}{{F_2}^{nucleon}}=1 $
where A is mass number of nuclei and ${F_2}^{nuclei}$ and ${F_2}^{nucleon}$ are experimentally measured values of structure functions of nuclei and nucleons respectively.
But we find out that Nuclear Ratio, R is not 1, but varies with x for a constant $Q^2$ as follows
For low x values, it implies that we get lower lepton-nuclei collision cross section than what we would have expected from scaled up lepton-nucleon collision cross section.
This is as if, the central nucleons of nuclei are being shielded due to surface nucleons. This is called Shadowing Effect.
Shadowing is caused by 'multiple scattering' of quark pair produced from the virtual photon emitted by the lepton. I do not understand this part well.
There are various models to explain shadowing:
Vector meson dominance
Parton recombination
Glauber-like rescattering
Gribov inelastic shadowing
References: | {
"domain": "physics.stackexchange",
"id": 48382,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "particle-physics, nuclear-physics",
"url": null
} |
optimization
Title: Optimal points of $f(x,y)=x^2 + y^2 + \beta xy + x + 2y$ I am self-learning basic optimization theory and algorithms from "An Introduction to Optimization" by Chong and Zak. I would like someone to verify my solution to this problem, on finding the minimizer/maximizer of a function of two variables, or any tips/hint to proceed ahead.
For each value of the scalar $\beta$, find the set of all stationary points of the following two variables $x$ and $y$
$$f(x,y) = x^2 + y^2 + \beta xy + x + 2y$$
Which of those stationary points are local minima? Which are global minima and why? Does this function have a global maximum for some value of $\beta$. | {
"domain": "datascience.stackexchange",
"id": 9511,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "optimization",
"url": null
} |
ros, arbotix
Title: Using a map on RVIZ
Hi,I follow the book Ros By Example.I use the method mentioned in this book to generating a map with the XV_11 laser scanner.And it seems that the my_map.pgm is 4.1MByte, and when I load this map,RVIZ becomes lagging.And warnnings show upon the terminal:
1、Control loop missed its desired rate:3.0 HZ,it actually takkes 1.3193s
2、Map update missed its desired rate:3.0 HZ,it actually takes 25.098s
Why? I just changed the test_map.pgm with my_map.pgm.Using test_map.pgm is OK and works really well.Maybe it is because my_map.pgm is too big?(test_map.pgm is only 300KB)
So are there any ways to cut the .pgm file to a small size or just filter the white areas?(the scanned mapmy_map.pgmis 2048x2048,I think it is too large)
PS:I tried set the update_frequency in local_costmap_params.yaml to 1HZ,reduce theheight width to 3.0*3.0,reduce the controller_frequency in base_local_planner_params.yaml to 1HZ,but these didn't work.
paste my distro:I run ros Hydro on a Vmware machine(Mem:3G,Cpucores:2),the host is I5-3230M RAM:8G 64bits Lenovo Y400
Originally posted by little_bob on ROS Answers with karma: 88 on 2017-05-13
Post score: 0
OK,guys.I actually solved this problem by this way: I open this my_map.pgm with PhotoShop.Then I aborted the none-blank areas,reduce it to 574x544pixels(300kb).And then,everything works fine after this.So,the reason is the map is too large for the Vmware machine to afford it.Should I close this question to show it solved?
Originally posted by little_bob with karma: 88 on 2017-05-14
This answer was ACCEPTED on the original site
Post score: 1 | {
"domain": "robotics.stackexchange",
"id": 27887,
"lm_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, arbotix",
"url": null
} |
• This needs a tweaking. We need $f(1)=1$ but with this you have $f(1)=2+1=3$... – JP McCarthy Oct 15 '14 at 18:09
• No it's a typo, it should have been $f(i)=2i-1 \pmod{(2^n-1)}$ – Marc Bogaerts Oct 15 '14 at 18:13
• I had something like this and failed to implement it as easily as you. I think what happened was that I had a piecewise definition mod something and didn't quite realise I could do it in one go and do my mod stuff later. I am very happy with my answer but to be honest yours is just way more straightforward so I am compelled to give you plus one! – JP McCarthy Oct 15 '14 at 18:18
• Very fair! I had the luck to program the stuff and to see what really happens without the mod. Then I went to see what exactly went on 'at the end' of the orbit. I haven't looked at the arbitrary case yet but it could be very interesting. – Marc Bogaerts Oct 15 '14 at 18:36
• I kind of like this answer but, however, there is something bothering me. How can you have $\pmod{(2^n-1)}$ if your indexes go to $2^n$? I mean, you're mapping $2^n$ numbers into $2^n-1$... or do I miss something? – A. Breust Oct 16 '14 at 7:20
Let the card positions be given by $i\in\{0\}\cup[2^n-1]$.
Define an invertible map $x:\{0\}\cup[2^n-1]\rightarrow [0,1]$ by $$x(i)=\frac{i}{2^n-1}.$$
Now you can show that where $\sigma$ is your riffle shuffle, that | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9835969636371975,
"lm_q1q2_score": 0.8280171446936977,
"lm_q2_score": 0.8418256412990658,
"openwebmath_perplexity": 353.5720837167391,
"openwebmath_score": 0.8535659909248352,
"tags": null,
"url": "https://math.stackexchange.com/questions/974921/how-many-perfect-shuffles-are-needed-to-go-back-to-initial-state/975310"
} |
c++, windows, embedded
return TRUE; // return TRUE unless you set the focus to a control
}
void CSysLat_SoftwareDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else if ((nID & 0xFFF0) == SC_MINIMIZE)
{
nid.cbSize = sizeof(NOTIFYICONDATA);
nid.hWnd = m_hWnd;
nid.uID = 100;
nid.uVersion = NOTIFYICON_VERSION;
nid.uCallbackMessage = WM_STMESSAGE;
nid.hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
strcpy_s(nid.szTip, "SysLat");
nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
Shell_NotifyIcon(NIM_ADD, &nid); | {
"domain": "codereview.stackexchange",
"id": 40674,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, windows, embedded",
"url": null
} |
python, performance, beginner, csv
try:
user_value = user[4]
except IndexError:
user_value = "Missing"
output_writer.writerow([vm[2], user[2], user_value, os_name])
input_file_vms.close()
input_file_users.close()
OSFile.close()
output_merge.close() | {
"domain": "codereview.stackexchange",
"id": 16728,
"lm_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, beginner, csv",
"url": null
} |
haskell, roman-numerals
{-
Subtractive Rules, from Wikipedia
I placed before V or X indicates one less, so four is IV (one less than five) and nine is IX (one less than ten)
X placed before L or C indicates ten less, so forty is XL (ten less than fifty) and ninety is XC (ten less than a hundred)
C placed before D or M indicates a hundred less, so four hundred is CD (a hundred less than five hundred) and nine hundred is CM (a hundred less than a thousand)
-} Parens
When you call a function you do not need to place the argument in parens:
Instead of: readNumerals(line)
Use: readNumerals line
Error Handling
In Haskell we use types like Either or Maybe to indicate errors. Instead of:
let nums = readNumerals(line)
if errorNum `elem` mums
then ...some error...
else ...
You should define readNumerals to have this type:
readNumerals :: String -> Maybe [Numeral]
and write:
case readNumerals line of
Nothing -> ... some error ...
Just ns -> ... parse was valid, numerals are in `ns` ...
data Numeral
The data structure Numeral has many fields which are redundant. For instance, if n is a Numeral and numeralValue n is 1, then it will always be the case that numeralSymbol n will be I and subRules n will be ['V','X']. So there's no point storing these in the record - you can just implement these as functions:
subRules :: Numeral -> [Char]
subRules n = case numeralValue n of
1 -> ['V','X']
5 -> []
10 -> ['L', 'C']
...
This allows you to eliminate the subRules field from the record.
Make Numeral an ADT
In fact, Numeral doesn't even need any fields. Here's a simpler way to implement Numeral:
data Numeral = I | V | X | L | C deriving (Show, Eq) | {
"domain": "codereview.stackexchange",
"id": 19908,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "haskell, roman-numerals",
"url": null
} |
electromagnetism, optics, fourier-transform, signal-processing
Title: What is a "Fourier transform limited pulse"? I have some doubts about the definiton of a Fourier transform limited pulse. For example if I consider a generic pulse:
$$E(z,t)=\frac{1}{\sqrt{2\pi}}\int_{-\infty}^{+\infty}A(\omega)e^{i(-\beta(\omega)z+\omega t)}d\omega$$
Defining:
$S(\omega,z)=|\mathscr{F}[E(z,t)]_{\omega,z}|^{2}$
$\Delta \omega(z)$ as the range of frequencies which correspond at half height of $S(\omega,z)$ for a fixed $z$ (pulse bandwith).
$\tau_{p}$ (the duration of the pulse) as the range of time which correspond at half height of $|E(z,t)|^2$ at fixed $z$. I'm considering a pulse inside a dispersive medium so its duration depends on the $z$ you are at.
Done these definitions, is it right to say that a pulse is Fourier limited if $$\Delta \omega(z)\tau(z)=\alpha$$ for each $z$, where $\alpha$ is a number which changes according to the type of pulse (Gaussian, ecc...)?
I'm considering a pulse inside a dispersive medium so its duration depends on the z you are. | {
"domain": "physics.stackexchange",
"id": 55052,
"lm_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, optics, fourier-transform, signal-processing",
"url": null
} |
machine-learning, neural-network, deep-learning, regression, cnn
Title: How should continuous outputs be in convolutional neural network? I have labeled faces images (label is the age -continuous value-) dataset and I want to construct a Convolutional Neural Network model to predict the age of a person.
I have the following questions.
How the label i.e. the age must be encoded ?
Which activation function to use ? Convolutional networks can be used for regression tasks too. The difference corresponds to the output layers of the dense networks. In classification tasks you use sigmoid or softmax depending on your task. In regression tasks you can simply use linear activation function as the non-linearity of the last layers. Consequently, if you have the ages as the outputs of your network and if they are in a same scale as the inputs you can simply use them as they are right now. | {
"domain": "datascience.stackexchange",
"id": 4661,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "machine-learning, neural-network, deep-learning, regression, cnn",
"url": null
} |
• To apply the constant rank theorem the rank needs to be ... constant. What if $D_pf$ fails to have rank $n$ at points inside every neighborhood of $p$? – Umberto P. Mar 1 at 8:45
• @UmbertoP. Good point. Then let's assume that $D_pf=n$ in a neighborhood of $p$. I will edit my question accordingly. – stressed out Mar 1 at 8:46
• I pretty much thought the same thing. It's all right. – Sou Mar 1 at 8:47
• @UmbertoP. By the way, I just remembered that if $\mathrm{rank}D_p f = n$ then at least in some neighborhood $\mathrm{rank}D_p f \geq n$. Isn't this true? Because I can find an invertible $n\times n$ minor in the matrix and if its determinant is non-zero, I still have some space to wiggle before it gets $0$? – stressed out Mar 1 at 8:52
• Well, you have to assume $f$ is $C^1$ anyway, and then your last comment applies. – Amitai Yuval Mar 1 at 9:16
I don't think you need all that. The differential $$Df_p$$ is injective, and the question is how to measure this injectivity and transfer that to $$f(x) -f(p)$$ which is only approximated by $$Df$$ near $$p$$. Here is one way: | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9820137916170774,
"lm_q1q2_score": 0.8266843976864927,
"lm_q2_score": 0.8418256492357358,
"openwebmath_perplexity": 157.23655281950042,
"openwebmath_score": 0.9101402163505554,
"tags": null,
"url": "https://math.stackexchange.com/questions/3131179/let-f-u-subseteq-mathbbrn-to-mathbbrm-be-c1-s-t-n-leq-m-u"
} |
electromagnetism, electrons, quantum-spin, magnetic-moment
Title: Are the electrons spin and his magnetic dipole moment unambiguously connected? Is the angle between the spin orientation and the magnetic dipole orientation for all electrons and under all circumstances the same? The angle is the same as long as you consider a free electron. Then they are parallel:
$\vec{\mu}_\mathrm{elec}=-g_\mathrm{elec}\mu_\mathrm{Bohr}\frac{\vec{S}}{\hbar}$
with $g_\mathrm{elec}\approx 2$ (neclecting effects from quantum electro dynamics).
But when dealing with bound electrons (e.g. in an atom), where the electron also has some orbital angular momentum $\vec{l}$ things get more complicated and you have to consider the different contributions (weighting with g-factor) of the different angular momenta (including the spin). | {
"domain": "physics.stackexchange",
"id": 20944,
"lm_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, electrons, quantum-spin, magnetic-moment",
"url": null
} |
ros
ros-noetic-diagnostics:amd64 (1.10.4-1focal.20210922.195736), ros-noetic-rosnode:amd64 (1.15.13-1focal.20210922.184725), ros-noetic-rqt-controller-manager:amd64 (0.19.5-1focal.20210922.184720), ros-noetic-rqt-gui-py:amd64 (0.5.2-1focal.20210922.181802), ros-noetic-image-transport-plugins:amd64 (1.14.0-1focal.20210922.205929), ros-noetic-rqt-msg:amd64 (0.4.10-1focal.20210922.190710), ros-noetic-position-controllers:amd64 (0.19.0-1focal.20210922.190720), python3-rosdep-modules:amd64 (0.21.0-1), ros-noetic-rqt-moveit:amd64 (0.5.10-1focal.20210922.193744), ros-noetic-rqt-graph:amd64 (0.4.14-1focal.20210922.185000), ros-noetic-rqt-robot-plugins:amd64 (0.5.8-1focal.20210922.212333), ros-noetic-clear-costmap-recovery:amd64 (1.17.1-1focal.20210922.204228), ros-noetic-dynamixel-sdk:amd64 (3.7.51-4focal.20210922.181516), ros-noetic-rqt-nav-view:amd64 (0.5.7-1focal.20210922.194433), | {
"domain": "robotics.stackexchange",
"id": 37100,
"lm_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
} |
rosbag
Title: Rosbag record to different path?
Hi all,
Is there any way to record rosbag data to a different location than the default location?
I am getting the following error:
[ERROR] [1460470166.869390414]: Less than 1GB of space free on disk with corridorlocalization_2016-04-12-16-00-06.bag.active. Disabling recording.
[ WARN] [1460470167.370142337]: Not logging message because logging disabled. Most likely cause is a full disk.
Is it possible to record rosbag data to a pen drive?
Thanks
Originally posted by DanThe on ROS Answers with karma: 47 on 2016-04-12
Post score: 0
The rosbag wiki has the information. Assuming your pen drive is at /mnt/pen you can use either the -o or -O flag:
rosbag record -o /mnt/pen/ /chatter
rosbag record -O /mnt/pen/test.bag /chatter
The first case with lower-case -o will output a bag file with the timestamp at the location you specify. The second case with upper-case -O will output a bag file simply named test.bag at the location you specify (without the timestamp on the filename).
Originally posted by Thomas D with karma: 4347 on 2016-04-12
This answer was ACCEPTED on the original site
Post score: 2
Original comments
Comment by DanThe on 2016-04-14:
Thanks for your answer! | {
"domain": "robotics.stackexchange",
"id": 24359,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "rosbag",
"url": null
} |
rosnode, ros-indigo
Title: Rosnode ping rosout does not work on remote machine
I have two PCs, PC1 is the robot computer, which is the master, PC2 is my workstation. Both uses ubuntu 14.4 indigo.
On PC2, I am connected to the network and able to do
rostopic list
but when I do rosnode ping rosout it gave me an error:
rosnode: node is [/rosout]
pinging /rosout with a timeout of 3.0s
ERROR: Unknown host [dhcp-59-208] for node [/rosout]
when I run rosnode info i get the following
$ rosnode info /rosout
--------------------------------------------------------------------------------
Node [/rosout]
Publications:
* /rosout_agg [rosgraph_msgs/Log]
Subscriptions:
* /rosout [rosgraph_msgs/Log]
Services:
* /rosout/set_logger_level
* /rosout/get_loggers
contacting node http://dhcp-59-208:47096/ ...
ERROR: Communication with node[http://dhcp-59-208:47096/] failed!
So on my PC2 I have the following environments:
ROS_IP=192.168.1.100
ROS_HOSTNAME=192.168.1.100
ROS_MASTER_URI=http://192.168.1.11:11311
PC1:
ROS_IP=192.168.1.100
ROS_HOSTNAME=192.168.100
ROS_MASTER_URI=http://localhost:11311 | {
"domain": "robotics.stackexchange",
"id": 30761,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "rosnode, ros-indigo",
"url": null
} |
evolution, botany, photosynthesis, speculative, chloroplasts
Title: Why do plants have green leaves and not red? I know plants are green due to chlorophyll.
Surely it would be more beneficial for plants to be red than green as by being green they reflect green light and do not absorb it even though green light has more energy than red light.
Is there no alternative to chlorophyll? Or is it something else? Surely it would be even more beneficial for plants to be black instead of red or green, from an energy absorption point of view. And Solar cells are indeed pretty dark.
But, as Rory indicated, higher energy photons will only produce heat. This is because the chemical reactions powered by photosynthesis require only a certain amount of energy, and any excessive amount delivered by higher-energy photons cannot be simply used for another reaction1 but will yield heat. I don't know how much trouble that actually causes, but there is another point:
As explained, what determines the efficiency of solar energy conversion is not the energy per photon, but the amount of photons available. So you should take a look at the sunlight spectrum: | {
"domain": "biology.stackexchange",
"id": 11738,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "evolution, botany, photosynthesis, speculative, chloroplasts",
"url": null
} |
c#, linq
foreach (var author in authors)
{
var authorNode = CreateNode(author, a => a.Name);
foreach (var book in author.Books)
{
authorNode.Nodes.Add(CreateNode(book, b => b.Name));
}
treeView.Nodes.Add(authorNode);
} | {
"domain": "codereview.stackexchange",
"id": 750,
"lm_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#, linq",
"url": null
} |
a)f(x)=1 / (x^2+1)
d)f(x)={1 / (x^3+x)}^5
f)h(x)=x-(x^2)
For each of the above functions from a) through h) how do you determine if it is even,odd,or neither??
a)
$f(x) = \frac{1}{x^2 + 1}$
$f(-x) = \frac{1}{(-x)^2 + 1}$
$f(-x) = \frac{1}{x^2 + 1} = f(x)$
so this function is even.
d)
$f(x) = \left ( \frac{1}{x^3 + x} \right ) ^5$
$f(-x) = \left ( \frac{1}{(-x)^3 + (-x)} \right ) ^5$
$f(-x) = \left ( \frac{1}{-x^3 - x} \right ) ^5$
$f(-x) = \left ( \frac{-1}{x^3 + x} \right ) ^5$
$f(-x) = (-1)^5 \left ( \frac{1}{x^3 + x} \right ) ^5$
$f(-x) = - \left ( \frac{1}{x^3 + x} \right ) ^5 = -f(x)$
so this function is odd.
f)
$h(x) = x - x^2$
$h(-x) = (-x) - (-x)^2$
$h(-x) = -x + x^2$
which is equal to neither h(x) nor -h(x). So this function is neither even, nor odd.
-Dan | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9893474910448,
"lm_q1q2_score": 0.8369310259982126,
"lm_q2_score": 0.8459424353665382,
"openwebmath_perplexity": 927.6955699431063,
"openwebmath_score": 0.7173530459403992,
"tags": null,
"url": "http://mathhelpforum.com/pre-calculus/25399-even-odd-neither.html"
} |
errors, pacbio, software-installation, blasr
cp -aL /usr/include/bzlib.h /Users/cr517/Documents/pitchfork/staging/libbzip2-1.0.6/include
cp -aL /usr/lib/libbz2.* /Users/cr517/Documents/pitchfork/staging/libbzip2-1.0.6/lib
ln -sfn libbz2.dylib.1.0 /Users/cr517/Documents/pitchfork/staging/libbzip2-1.0.6/lib/libbz2.dylib.1
ln -sfn libbz2.dylib.1 /Users/cr517/Documents/pitchfork/staging/libbzip2-1.0.6/lib/libbz2.dylib
sed -e "s@^prefix=.*@prefix=/tmp/pitchfork@" bzip2.pc > /Users/cr517/Documents/pitchfork/staging/libbzip2-1.0.6/lib/pkgconfig/bzip2.pc
cd /Users/cr517/Documents/pitchfork/staging/libbzip2-1.0.6 && tar cf - * | tar xf - -C /tmp/pitchfork
find /Users/cr517/Documents/pitchfork/staging/libbzip2-1.0.6 ! -type d|awk -F '/Users/cr517/Documents/pitchfork/staging/libbzip2-1.0.6/' '{print $2}' > /tmp/pitchfork/var/pkg/libbzip2-1.0.6
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C ports/thirdparty/boost do-install
/Users/cr517/Documents/pitchfork/bin/pitchfork fetch --url https://prdownloads.sourceforge.net/boost/boost_1_60_0.tar.gz | {
"domain": "bioinformatics.stackexchange",
"id": 399,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "errors, pacbio, software-installation, blasr",
"url": null
} |
The only fancy thing that happened is in the second last line, where I used the formula for the Gaussian integral (see multivariate section)
Update. To expand upon my comment below, to note that the above idea actually with a little bit more care actually yields a proof of the Minkowski determinant inequality, by equivalently establishing log-concavity of the determinant. The key point to observe is \begin{eqnarray} \exp(-x^T((1-\lambda)A+\lambda)x) &=& [\exp(-x^TAx)]^{1-\lambda}[\exp(-x^TBx)]^\lambda\\\\ \int\exp(-x^T((1-\lambda)A+\lambda)x)dx &=& \int [\exp(-x^TAx)]^{1-\lambda}[\exp(-x^TBx)]^\lambda\ dx\\\\ &\stackrel{\text{Hölder}}{\le}& \left(\int\exp(-x^TAx)dx \right)^{1-\lambda}\left(\int \exp(-x^TBx)dx \right)^\lambda. \end{eqnarray} Now invoke the Gaussian integral as above to conclude \begin{equation*} \det((1-\lambda)A+\lambda B) \ge \det(A)^{1-\lambda}\det(B)^\lambda, \end{equation*} from which we can easily conclude $\det(A+B)^{1/n} \ge \det(A)^{1/n}+\det(B)^{1/n}$. | {
"domain": "mathoverflow.net",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9859363746096915,
"lm_q1q2_score": 0.8216050385373651,
"lm_q2_score": 0.8333246035907933,
"openwebmath_perplexity": 218.6506590117626,
"openwebmath_score": 0.9629952907562256,
"tags": null,
"url": "https://mathoverflow.net/questions/65424/determinant-of-sum-of-positive-definite-matrices"
} |
kilograms). Step 2 (E-step): using current values of $$\mu_k, \pi_k, \sigma_k$$ evaluate responsibilities $$r_{nk}$$ (posterior distribution) for each component and data point. In our particular case, we can assume $$z$$ to be a categorical distribution representing $$K$$ underlying distributions. However, we cannot add components indefinitely because we risk to overfit the training data (a validation set can be used to avoid this issue). Singularities. You read that right! Here is an idea, what if we use multiple Gaussians as part of the mixture? How can we find the parameters of a GMM if we do not have a unique ML estimator? The ML estimate of the variance can be calculated with a similar procedure, starting from the log-likelihood and differentiating with respect to $$\sigma$$, then setting the derivative to zero and isolating the target variable: Fitting unimodal distributions. A specific weight $$\pi_{k}$$ represents the probability of the $$k$$-th component $$p(z_{k}=1 \vert \boldsymbol{\theta})$$. We can assume that each data point $$x_{n}$$ has been produced by a latent variable $$z$$ and express this causal relation as $$z \rightarrow x$$. The BIC criterion can be used to select the number of components in a Gaussian Mixture in an efficient way. The univariate Gaussian defines a distribution over a single random variable, but in many problems we have multiple random variables thus we need a version of the Gaussian which is able to deal with this multivariate case. Ein häufiger Spezialfall von Mischverteilungen sind sogenannte Gaußsche Mischmodelle (gaussian mixture models, kurz: GMMs).Dabei sind die Dichtefunktionen , …, die der Normalverteilung mit potenziell verschiedenen Mittelwerten , …, und Standardabweichungen , …, (beziehungsweise Mittelwertvektoren und Kovarianzmatrizen im -dimensionalen | {
"domain": "asticonnv.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9697854138058636,
"lm_q1q2_score": 0.8038927611494614,
"lm_q2_score": 0.8289388040954683,
"openwebmath_perplexity": 847.464946574805,
"openwebmath_score": 0.7184094786643982,
"tags": null,
"url": "http://mail.asticonnv.com/w7esgz/b3a71c-gaussian-mixture-model-code"
} |
c#, image, winforms, graphics, genetic-algorithm
this.OpenImageButton.Click += new System.EventHandler(this.OpenImage);
//
// openFileDialog1
//
this.openFileDialog1.FileName = "openFileDialog1";
this.openFileDialog1.Filter = "JPEG Files (*.jpg)|*.jpg|PNG Files (*.png)|*.png|BMP Files (*.bmp)|*.bmp|All file" +
"s (*.*)|*.*";
this.openFileDialog1.Title = "Select an Image File";
//
// pictureBox2
//
this.pictureBox2.Location = new System.Drawing.Point(256, 0);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(255, 255);
this.pictureBox2.TabIndex = 2;
this.pictureBox2.TabStop = false;
//
// CreateGenePool
//
this.CreateGenePool.Location = new System.Drawing.Point(256, 261);
this.CreateGenePool.Name = "CreateGenePool";
this.CreateGenePool.Size = new System.Drawing.Size(124, 23);
this.CreateGenePool.TabIndex = 3;
this.CreateGenePool.Text = "Create Gene Pool";
this.CreateGenePool.UseVisualStyleBackColor = true;
this.CreateGenePool.Click += new System.EventHandler(this.CreateGenePool_Click);
//
// Step
//
this.Step.Location = new System.Drawing.Point(386, 261);
this.Step.Name = "Step";
this.Step.Size = new System.Drawing.Size(38, 23);
this.Step.TabIndex = 4;
this.Step.Text = "Step";
this.Step.UseVisualStyleBackColor = true;
this.Step.Click += new System.EventHandler(this.Step_Click);
//
// progressBar1
// | {
"domain": "codereview.stackexchange",
"id": 33349,
"lm_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#, image, winforms, graphics, genetic-algorithm",
"url": null
} |
waves
Title: How does a tranverse wave propagate? Sound waves can be understood as particles hitting each other and to conserve momentum the vibration travels in air. Each particle transfering it's momentum to the other until it reaches our ears. Atleast we can think of a mental picture of why they propagate. But what about transverse waves? Like for instance when you jerk a rope or a slinky? Can somebody give me an intuitive reason for the propagation of these waves or better (if possible) a simple mathematical model? You pull a small piece of a rope up, and as that piece goes up it pulls the piece adjacent to it up and as that piece goes up... When you move your hand back to it's original position you're applying a force to the piece again and it pulls the adjacent piece down, etc... Model of displacement as a function of position and time: $y(x,t) = y_{max} sin(kx-\omega t)$ where $k=2\pi/\lambda$ and $\omega = 2\pi/T$ where $\lambda$ is wavelength and $\omega$ is angular frequency. | {
"domain": "physics.stackexchange",
"id": 29997,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "waves",
"url": null
} |
java, beginner
int num1 = scan.nextInt();
int num2 = scan.nextInt();
int num3 = scan.nextInt();
There's nothing wrong with that.
Certainly they are all numbers.
But think about what you'll be using them for.
In some ways they're not as convenient as they could be.
Every text since
Euclid
has used alpha, beta, ... ok some have used a, b, c.
Let's go with that when defining three ints.
In many languages, including java, it is conventional
for booleans and predicates to start with is.
(Or "has" / "have" for plural.)
I will follow that here.
Also, we should report fatal error immediately upon
noticing any negative numbers.
It is reasonable for the rest of the code to be
able to safely assume it is working with non-negative
lengths.
Finally, to simplify matters, I am going to enforce
monotonicity. The user is free to enter figures in any order,
but by the time we've validated them we will have
a <= b && b <= c.
In some languages we might rely on sorted();
here we can ask ArrayList to .sort().
Ok, time for some math.
It seems like you'd want to establish this one first,
as absent the triangle inequality the others just don't make sense.
I choose to define these in the positive,
as humans do a better job reasoning in that way.
It avoids the infamous double negative.
boolean isValid = a >= 0 && b >= 0 && c >= 0;
boolean isTriangle = c <= a + b; | {
"domain": "codereview.stackexchange",
"id": 44491,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "java, beginner",
"url": null
} |
What you calculated is the standard determinant multiplied by all the row scalings of your first step. To 'fix' it, you have to multiply it by their inverses.
Note: One comment says that doing the row operation alters your matrix and hence your determinant. Keep in mind that this holds for the scaling row operation, but not when linearly combining two rows. In that case, your matrix also 'changes' but the determinant does not. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9693241956308277,
"lm_q1q2_score": 0.8139744508138838,
"lm_q2_score": 0.8397339656668287,
"openwebmath_perplexity": 277.2476324462024,
"openwebmath_score": 0.8777163624763489,
"tags": null,
"url": "https://math.stackexchange.com/questions/380570/different-form-of-determinant-does-it-make-mine-wrong"
} |
5. Originally Posted by starswept
Hi, I'm having a hard time understanding how to determine where a function is not differentiable
Basically there are two conditions that one looks for in deciding if a function is differentiable.
The first is that the function must be continuous at the point!
The second is not that easily stated. But is essence it is that the graph of the function must be smooth at the point. If you graph f(x)=|x-1|, then even though it is continuous at x=1, you will see a sharp turn at x=1. Therefore, the function is not differentiable at x=1: it cannot have a tangent there.
6. Originally Posted by starswept
Hi, I'm having a hard time understanding how to determine where a function is not differentiable (the question keeps coming up in my homework though sadly, it didn't in the lesson!) I understand that a point where the function is not differentiable means the derivative does not exist there. However, how can I tell, based off either a graph or equation, when a point isn't differentiable?
For example, I'm currently doing this question:
Sketch the graph of f(x) = |x^2 - 1|
a) For what values of x is f not differentiable?
b) Find a formula for f1 and sketch the graph of f1
c) Find f1 at -2, 0, and 3.
Any help is greatly appreciated!
f(x)=|x-1||x+1| is not differentiable at x=-1 and x=1
7. Originally Posted by Plato
The second is not that easily stated. But is essence it is that the graph of the function must be smooth at the point. If you graph f(x)=|x-1|.
Which means the right and left derivatives are the same. | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9808759604539051,
"lm_q1q2_score": 0.8468800746808756,
"lm_q2_score": 0.8633916099737806,
"openwebmath_perplexity": 236.5204142932903,
"openwebmath_score": 0.9058037996292114,
"tags": null,
"url": "http://mathhelpforum.com/calculus/16859-differentiable-points.html"
} |
c++, algorithm, c++14, hashcode
/*
The 64 fractional parts of the cuberoots of the first 64 prime numbers.
*/
const __uint64 fractional_cuberoots[64]{
0x428a2f98d728ae22, 0x7137449123ef65cd, 0xb5c0fbcfec4d3b2f, 0xe9b5dba58189dbbc, 0x3956c25bf348b538,
0x59f111f1b605d019, 0x923f82a4af194f9b, 0xab1c5ed5da6d8118, 0xd807aa98a3030242, 0x12835b0145706fbe,
0x243185be4ee4b28c, 0x550c7dc3d5ffb4e2, 0x72be5d74f27b896f, 0x80deb1fe3b1696b1, 0x9bdc06a725c71235,
0xc19bf174cf692694, 0xe49b69c19ef14ad2, 0xefbe4786384f25e3, 0x0fc19dc68b8cd5b5, 0x240ca1cc77ac9c65,
0x2de92c6f592b0275, 0x4a7484aa6ea6e483, 0x5cb0a9dcbd41fbd4, 0x76f988da831153b5, 0x983e5152ee66dfab,
0xa831c66d2db43210, 0xb00327c898fb213f, 0xbf597fc7beef0ee4, 0xc6e00bf33da88fc2, 0xd5a79147930aa725, | {
"domain": "codereview.stackexchange",
"id": 24499,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, algorithm, c++14, hashcode",
"url": null
} |
Now if you recall the MacLaurin Series for \displaystyle \begin{align*} \cos{(t)} = \sum_{n = 0}^{\infty} \frac{(-1)^n}{(2n)!}\,t^{2n} = 1 - \frac{t^2}{2} + \frac{t^4}{4!} - \frac{t^6}{6!} + \dots \end{align*} you should be able to manipulate it to get the series you are after...
4. ## Re: expanding f(x) into the maclaurin series
Originally Posted by Prove It
Now if you recall the MacLaurin Series for \displaystyle \begin{align*} \cos{(t)} = \sum_{n = 0}^{\infty} \frac{(-1)^n}{(2n)!}\,t^{2n} = 1 - \frac{t^2}{2} + \frac{t^4}{4!} - \frac{t^6}{6!} + \dots \end{align*} you should be able to manipulate it to get the series you are after...
I have $1 - \frac{6x^2}{2!} + \frac{96x^4}{4!} - \frac{1536x^6}{6!} + ...$ but I cannot figure out how to manipulate that into a series similar to the Maclaurin Series Expansion of $cos(x)$.
Thoughts?
5. ## Re: expanding f(x) into the maclaurin series
$\dfrac{7}{8} + \dfrac{3}{8}\sum_{n\ge 0} \dfrac{(-1)^n}{(2n)!}(4x)^{2n}$
6. ## Re: expanding f(x) into the maclaurin series | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.983085090202311,
"lm_q1q2_score": 0.8082818819673742,
"lm_q2_score": 0.8221891370573388,
"openwebmath_perplexity": 619.9413053481375,
"openwebmath_score": 1.0000087022781372,
"tags": null,
"url": "http://mathhelpforum.com/calculus/223015-expanding-f-x-into-maclaurin-series.html"
} |
noise, image-processing, parameter-estimation, maximum-likelihood-estimation
Assuming we have single channel image. So we pack all give images into a tensor tI with dimensions: numRows * numCols * numRealizations.
We calculate the mean per pixel (Averaging on the 3rd dimension) and then subtract each image from the calculated average image.
Then we're left with many realizations of the noise (Well, noise and the left over from the estimated mean error).
Method 2
Estimate the STD in the 3rd dimension per pixel. Them average all numRows * numPixels estimations.
Method 3
Just as method 2. But since the property which obeys to linear operations is the Variance calculate the variance along the 3rd dimension, average it over all pixels and then take the sqrt() of the average Variance.
Summary
Here is a graph showing the estimated noise STD as a function of the number of realizations: | {
"domain": "dsp.stackexchange",
"id": 7953,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "noise, image-processing, parameter-estimation, maximum-likelihood-estimation",
"url": null
} |
c++, performance, algorithm, linked-list
Passing a pointer to a pointer. You can simplify this by passing a reference.
void push(struct Node** head_ref, int new_data)
In C++ you don't need to use struct keyword when using struct types.
void push(struct Node** head_ref, int new_data)
A better declaration would have been:
void push(Node*& head_ref, int new_data)
C++ you should always use new (rather than the malloc family).
/* allocate node */
struct Node* new_node =
(struct Node*) malloc(sizeof(struct Node));
There are two reasons for this:
If your code combines both C and C++ memory allocation you need to track which is which and use the correct de-allocation method. Thus it is best to simply use one allocation method then you always know how to deallocate it.
Using new calls the constructor to initialize the object.
Remember this line from your class declaration.
Node* next = NULL;
This is not going to happen if you call malloc() you must use new to get that to happen.
Its also simpler to write:
Node* new_node = new Node{new_data, *head_ref};
Your find returns the nth index of the list. But your index is 1 based. Most C based languages use a zero based index. But if I pass 0 to find() this function will recurse for ever.
In recursive funtions always check for the end of the recursion first. So as the first check in find you should check that the list pointer is not nullptr.
This is not modified.
int count = 1;
So this should be a constexpt. The whole point of using a named type is to make the code more expressive. A better name would help the code be more expressive.
Don't leave redundant code commented out. Delete it.
//if count equal too n return node->data
Source control system allow you to keep older versions of the code around
It is now easy to install git on all machines learn to use it.
Use better indentation
if(count == n)
return head->value; | {
"domain": "codereview.stackexchange",
"id": 37798,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, performance, algorithm, linked-list",
"url": null
} |
java, programming-challenge, matrix, chess
For me the most important part is readability. Does this code seem readable to you? A few suggestions:
Represent a point (x,y) with an object. It can be in fact exactly what you implemented for ObstacleLocation. There is nothing in this class particular to an obstacle, so it's not a good name anyway. If you rename and make it mutable, you can use it also for the queen's location (just remember to create a copy when passing it to goXXX functions). This could also be used directly instead of creating an object in obstracleExists.
You can combine some of the ifs, IMO it would improve readability a lot. For example:
if (0 == queen.y || 0 == queen.x || obstacleLocations.contains(queen)) {
break;
}
Functional programming: instead of having all goXXX methods, you could have a single method and pass the a function to do the move, and another function to check if the position is valid. Example of moving S:
queensAttack += countMoves(queen, q -> q.y--, q -> q.y != 0 && !obstacleLocations.contains(q));
Note that you wouldn't need to pass obstacleLocations and boardSize. | {
"domain": "codereview.stackexchange",
"id": 29327,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "java, programming-challenge, matrix, chess",
"url": null
} |
are all 0. Define scalar matrix. Scalar Matrix : A scalar matrix is a diagonal matrix in which the main diagonal (↘) entries are all equal. скалярная матрица, f pranc. Solution : The product of any matrix by the scalar 0 is the null matrix i.e., 0.A=0 2. Scalar multiplication: to multiply a matrix A by a scalar r, one multiplies each entry of A by r. Zero matrix O: all entries are zeros. Magnet Matrix Calculator. Matrix is an important topic in mathematics. This matrix is typically (but not necessarily) full. Stack Exchange network consists of 176 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share … Diagonal elements, specified as a matrix. stemming. 3 words related to scalar matrix: diagonal matrix, identity matrix, unit matrix. All of the scalar values along the main diagonal (top-left to bottom-right) have the value one, while all other values are zero. What are synonyms for scalar matrix? Great code. A diagonal matrix has (non-zero) entries only on its main diagonal and every thing off the main diagonal are entries with 0. How to convert diagonal elements of a matrix in R into missing values? Write a Program in Java to input a 2-D square matrix and check whether it is a Scalar Matrix or not. Example: 5 0 0 0 0 5 0 0 0 0 5 0 0 0 0 5 Scalar matrix can also be written in form of n * I, where n is any real number and I is the identity matrix. Pre- or postmultiplication of a matrix A by a scalar matrix multiplies all entries of A by the constant entry in the scalar matrix. scalar matrix vok. — Page 36, Deep Learning, 2016. An identity matrix is a matrix that does not change any vector when we multiply that vector by that matrix. a diagonal matrix in which all of the diagonal elements are equal. A square matrix with 1's along the main diagonal and zeros everywhere else, is called an identity matrix. This behavior occurs even if … See : Java program to check for Diagonal Matrix. [x + 2 0 y − 3 4 ] = [4 0 0 4 ] GPU Arrays Accelerate code | {
"domain": "netposition-international.com",
"id": null,
"lm_label": "1. Yes\n2. Yes\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9901401426598159,
"lm_q1q2_score": 0.8957308162454254,
"lm_q2_score": 0.9046505415276079,
"openwebmath_perplexity": 769.1851159820291,
"openwebmath_score": 0.7704491019248962,
"tags": null,
"url": "https://netposition-international.com/50jfrs/1e0451-diagonal-matrix-and-scalar-matrix"
} |
electromagnetism, optics, waves, visible-light, reflection
The closest I have gotten to obtaining the first equation is by making use of the continuity of the tangential component at the first interface. So we have the following:
$$ \hat{\textbf{z}} \times (\textbf{E}_1 - \textbf{E}) = 0$$
where $\textbf{E} = \textbf{e}_{inc} + \textbf{e}_{ref}$ and $\textbf{E}$ is the field inside the anisotropic material. Then we can solve for the $x$ and $y$ component of $\textbf{E}$ at $z = 0$ to obtain
$$ \textbf{e}_{x} = (-a_s \sin \psi - r_s \sin \psi - a_p \cos \theta_{inc} \cos \psi + r_p \cos \theta_{inc} \cos \psi) \exp[i k_0 n_1 ( x \cos \psi + y \sin \psi)]$$
$$ \textbf{e}_{y} = (a_s \cos \psi + r_s \cos \psi - a_p \cos \theta_{inc} \sin \psi + r_p \cos \theta_{inc} \sin \psi) \exp[i k_0 n_1 ( x \cos \psi + y \sin \psi)]$$
But now there is all this junk at the beginning. Not to mention these contain $k_0 n_1$ while the former has $q$ and this doesn't address the $\textbf{e}_{x}$ component. | {
"domain": "physics.stackexchange",
"id": 86844,
"lm_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, optics, waves, visible-light, reflection",
"url": null
} |
Last edited:
#### Bacterius
##### Well-known member
MHB Math Helper
[JUSTIFY]Okay, this is hurting my brain so I'll conservatively assert that:
1. If the two limits are the same, you are correct that this says absolutely nothing about the existence of the derivative at $x = a$, so if the limits are the same this is as far as this method will take you.
2. If the two limits are different, then for most well-behaved functions the derivative does not exist at that point, however there are may exist crazy analytical functions which are continuous while their derivative isn't, and vice versa, so it may not be a sufficient condition to show the existence of $f'(a)$.[/JUSTIFY]
Last edited:
#### Jameson
Staff member
This is a really good question.
[Rest of post deleted due to a mistake. Updated thought can be found in my later post]
#### caffeinemachine
##### Well-known member
MHB Math Scholar
Hey Jameson! I think what you said is not entirely correct.
This is a really good question.
In order for a function of one variable, $f(x)$, to be differentiable at a point $a$, then it must be be continuous at $a$ and the following limit must exist ...
I think the thing in bold is redundant. The continuity of $f$ at $a$ follows from the differentiability of $f$ at $a$.
2) Just knowing that the above limit exists is not enough to say that $f(x)$ is differentiable at $a$. ...
I think knowing that the limit exists equivalent to $f$ being differentiable at $a$. That is by definition of differentiability at a point. Moreover, strictly, we should not say that $f(x)$ is differentiable at $a$ but simply say that $f$ is differentiable at $a$.
Please correct me if I am wrong or if I have misinterpretted your response.
#### caffeinemachine
##### Well-known member
MHB Math Scholar
I know this is probably a dumb question
This is not a dumb question at all. | {
"domain": "mathhelpboards.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9465966732132748,
"lm_q1q2_score": 0.8613149540995223,
"lm_q2_score": 0.9099070158103778,
"openwebmath_perplexity": 249.94956744422095,
"openwebmath_score": 0.9249218106269836,
"tags": null,
"url": "https://mathhelpboards.com/threads/understanding-limits.6134/"
} |
and getting the appropriate expressions for $\mu, ~ \sigma$ and C in terms of $\mu_1, ~ \mu_2, ~ \sigma_1$ and $\sigma_2$. Note that $e^C$ becomes part of the normalising constant.
It's simple to show and get the expressions but tedious to type out.
$-\frac{(x - \mu_1)^2}{2\sigma^2_1} - \frac{(x - \mu_2)^2}{2\sigma^2_2}$
$= \frac{-\sigma^2_2(x - \mu_1)^2 - \sigma^2_1 (x - \mu_2)^2}{2 \sigma_1^2 \sigma^2}$
$= \frac{ -\sigma^2_2 x^2 + 2\sigma_2^2 \mu_1 x - \mu_1^2 \sigma_2^2 -\sigma^2_1 x^2 + 2\sigma_1^2 \mu_2 x - \mu_2^2 \sigma_1^2}{2 \sigma_1^2 \sigma^2}$
$= \frac{ -(\sigma_1^2 + \sigma_2^2) x^2 + 2(\sigma_2^2 \mu_1 + \sigma_1^2 \mu_2) x - (\mu_1^2 \sigma_2^2 + \mu_2^2 \sigma_1^2)}{2 \sigma_1^2 \sigma^2}$ | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9740426405416756,
"lm_q1q2_score": 0.856326431138068,
"lm_q2_score": 0.8791467595934565,
"openwebmath_perplexity": 503.01167627082714,
"openwebmath_score": 0.8949968814849854,
"tags": null,
"url": "http://mathhelpforum.com/advanced-statistics/38179-product-two-normal-distributions.html"
} |
digital-communications, ofdm, equalization, matrix
As known, the signal $y$ has now the length of of $D+N+L$. However, the useful signal has the length of $N$ which is equivalent to $s(k)$
What I am asking about is the toeplitz matrix $H$ equivalent into $y$ after removing the delays $L$ and cyclic prefix $D$? In other words, If I can write the $y$ in matlab as y = y(D+1:end-L+1); whose length becomes $N$ now, how can I write $H$ equivalent into this part ? What you mean might be circulant matrix instead of toeplitz matrix. See section 3.4.4 in https://web.stanford.edu/~dntse/Chapters_PDF/Fundamentals_Wireless_Communication_chapter3.pdf about how the circular convolution in OFDM is represented by matrix operations (eq 3.130 onwards).
First, in almost all standard OFDM systems, you can assume $D \le L$. The cyclic prefix will be less than or equal to maximum multi-path delay, so as long as $D \le L$, the linear convolution $x * h$ gets converted circular convolution of $x$ and $h$.
When $y_c = H x_{cp}(k)$, you only need to take $N$ original elements for $x$. $H$ is size $N \times N$. This is because you have already re-written the circular convolution in matrix form. Each row of $H$ will do dot-product with $x$ to generate $y_c[n]$. Like that there will be $N$ values of $y_c$ corresponding to each row of $H$.
$y$ is of length $N+L +D-1$. As you correctly mentioned $y_c = y(D+1:D+N)$.
Equivalent $H$ (size $N \times N$):
h(0) 0 0 ... h(L-1) h(L-2) .. h(1) | {
"domain": "dsp.stackexchange",
"id": 8483,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "digital-communications, ofdm, equalization, matrix",
"url": null
} |
# The number of triples that sum to a constant
Problem:
How many triples are there of the form $$(x_0,x_1, x_2)$$ where $$x_0 \in I$$, $$x_1 \in I$$, $$x_2\in I$$ $$x_0 \geq 0$$, $$x_1 >= 0$$, $$x_2 >= 0$$ and $$n = x_0 + x_1 + x_2$$ where $$n \in I$$?
Let $$c(n)$$ be the number of tuples we can have for a given $$n$$. For $$n = 0$$, the only valid triple is $$(0,0,0)$$, hence $$c(0) = 1$$.
For $$c(1) = 3$$, the set of valid triples is: $$(0,0,1 ), (0,1,0), (0,0,1)$$ Hence $$c(1) = 3$$.
For $$c(2) = 6$$, the set of valid triples is: $$(1,0,1 ), (0,1,1 ), (0,0,2 ), (1,1,0), (0,2,0), (0,0,2)$$ Hence $$c(2) = 6$$.
Using the information on this URL:
How many $k-$dimensional non-negative integer arrays $(x_1,\cdots,x_k)$ satisfies $x_1+x_2+\cdots+x_k\le n$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9805806478450309,
"lm_q1q2_score": 0.8554069586892646,
"lm_q2_score": 0.8723473796562744,
"openwebmath_perplexity": 121.15298584555288,
"openwebmath_score": 0.9377309679985046,
"tags": null,
"url": "https://math.stackexchange.com/questions/3291437/the-number-of-triples-that-sum-to-a-constant?noredirect=1"
} |
homework-and-exercises, forces, vectors, linear-algebra, equilibrium
Title: Minimum number of non-coplanar forces required to keep an object in equilibrium
The minimum number of non-coplanar forces that can keep a particle in equilibrium is:
(a) 1
(b) 2
(c) 3
(d) 4 | {
"domain": "physics.stackexchange",
"id": 87050,
"lm_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, forces, vectors, linear-algebra, equilibrium",
"url": null
} |
exoplanet, gravitational-lensing
Also, there will be other effects that will completely dominate any lensing going on.
Edit to emphasize the size argument
In this image you can see a small source in red, and the resulting lensed image in green. Note that the increase in brightness is purely an effect of the size of the lensed image, not more flux per area. If we assume that the blue circle is the size of the star, we can see that any lensing happening while the planet transits its star will simply stretch parts of a bright uniform background into other parts of the same bright uniform background. Of course, the extent of the lensed image here is greatly exaggerated in order to be able to show any lensing features at all. With a planet in front of a star you would not even get multiple images. | {
"domain": "astronomy.stackexchange",
"id": 2324,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "exoplanet, gravitational-lensing",
"url": null
} |
We have: $$a = \frac{(r-1)^3}{6}, \quad b=\frac{3(r-1)^2-6(r-1)^3}{6}, \quad \frac{-6+6r-9(r-1)^2+11(r-1)^3}{6}, \quad \frac{12-6r+6(r-1)^2-6(r-1)^3}{6}.$$ It follows that the constant term $d$ is ALWAYS an integer, namely $$2-r+(r-1)^2-(r-1)^3=(r-1)^0-(r-1)^1+(r-1)^2-(r-1)^3.$$ Incidentally, you'll now have an idea of the general formula for calculating $d$, up to any degree.
17. Let $r,s$ be a two-term sequence (where $r\neq s$). PROVE that:
• if $f(n)=an+b$ is its linear model, then $a+b=r$;
• if $f(n)=an^2+bn+c$ is its quadratic model, then $a+b+c=r$.
18. Useful for checking if our polynomial model is right.
19. Let $r,s,t$ be a three-term sequence (where $2s\neq r+t$). PROVE that:
• if $f(n)=an^2+bn+c$ is its quadratic model, then $a+b+c=r$;
• if $f(n)=an^3+bn^2+cn+d$ is its cubic model, then $a+b+c+d=r$.
20. Useful for checking if our polynomial model is right. | {
"domain": "fridaymath.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9884918516137419,
"lm_q1q2_score": 0.8300701786202895,
"lm_q2_score": 0.8397339616560072,
"openwebmath_perplexity": 164.44658734299773,
"openwebmath_score": 0.9064411520957947,
"tags": null,
"url": "https://fridaymath.com/proofs/randomquestions.html"
} |
solving the linearized set of algebraic equa-tions that result from discretizing a set of PDEs. solve ( that’s the linear algebra solver of numpy ) is HERE. Python makes this sort of problem very easy to solve: one can simply use Scipy's interface to ODEPACK, an optimized Fortran package for solving ordinary differential equations. Solving systems of linear equations must make use of appropriate software. Solve Equations in Python The following tutorials are an introduction to solving linear and nonlinear equations with Python. DSolve can give solutions that include Inactive sums and integrals that cannot be carried out explicitly. lstsq () with the ones computed using the QR decomposition: from numpy import * # generating a random overdetermined system A = random. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you. Step 1: Write your equations in the form of [A] {x} = {b}, where A is a matrix of all the coefficients, x is a vector of variables and b is a vector of R. Edit: As pointed out by @anderstood, FindRoot can't be used to decisively say if there are no solutions for a set a equations as it depends on the starting values of variables. Python program to solve the quadratic equation : In this python programming tutorial, we will learn how to solve a quadratic equation. Solve Linear Equations Using linsolve. In the differential equation system, $$pS(t)$$ must be replaced by $$p(t)S(t)$$, and in this case we get a differential equation system with a term that is discontinuous. Attempt to solve the problem:. Using python or matlab with the following parameters: Constants Um = 0. Convert the third order linear equation below into a system of 3 first order equation using (a) the usual substitutions, and (b) substitutions in the reverse order: x 1 = y″, x 2 = y′, x 3 = y. Even though linear equations can be quite problematic to handle some times, it is not hard to get a clear view of the geometry involved. import cmath. Table of contents: 1) Example 1: Basic Application of solve () Function in R. For the field of | {
"domain": "martinezgebaeudereinigungkoeln.de",
"id": null,
"lm_label": "1. Yes\n2. Yes",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9518632234212403,
"lm_q1q2_score": 0.8032727162840214,
"lm_q2_score": 0.843895106480586,
"openwebmath_perplexity": 457.9827500926302,
"openwebmath_score": 0.5354330539703369,
"tags": null,
"url": "http://martinezgebaeudereinigungkoeln.de/solve-system-of-equations-python.html"
} |
c#, game, community-challenge, rock-paper-scissors
The flipside of this out-of-context quote, is that when it is quality code, you do care about these things. | {
"domain": "codereview.stackexchange",
"id": 6614,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c#, game, community-challenge, rock-paper-scissors",
"url": null
} |
ros, navigation, robot-localization
Originally posted by nparker2020 on ROS Answers with karma: 16 on 2021-11-04
Post score: 0
Original comments
Comment by gvdhoorn on 2021-11-04:
Odom is not a small message, but perhaps you're seeing Nagel's algorithm at work.
However, the timing between each message is not evenly distributed at all.
how did you measure dT? By looking at message arrival times, or the stamps?
Comment by nparker2020 on 2021-11-04:
Thanks for the reply. Yes, I assumed originally that Nagel's could be at work. I set the odom0_nodelay value to true in an effort the address that.
I was calculating dT upon receipt (arrival time). I see now that the stamps might tell another story. I will run a test looking at the stamps and reply back.
Comment by nparker2020 on 2021-11-04:
Wow. OK. Comparing the stamps in the header yields exactly what I would expect. Each odometry message is delivered in 1/freq. increments. Any advice in addressing this massive delay in message delivery?
EDIT: After looking over the docs and other forum threads, I added a TransportHints with tcpNoDelay() set to the subscribe call for the /odometry/filtered message. This completely resolved my issue. Thank you!
Comment by gvdhoorn on 2021-11-04:
Good to hear you got it resolved.
ANSWER:
The answer to this issue, provided by gvdhoorn (Thanks again!), was to disable Nagel's algorithm for the /odometry/filtered topic.
In order to do this, I added a ros::TransportHints to the subscribe call on the /odometry/filtered topic:
ros::TransportHints transportConfig;
transportConfig.tcpNoDelay();
ros::Subscriber sub = n.subscribe("/odometry/filtered", 1000, <callback>, transportConfig);
Originally posted by nparker2020 with karma: 16 on 2021-11-04
This answer was ACCEPTED on the original site
Post score: 0 | {
"domain": "robotics.stackexchange",
"id": 37088,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros, navigation, robot-localization",
"url": null
} |
python, python-3.x
Title: Reversing a String in Python I have a simple function that takes a string and reverses it:
def reverse(string):
begin = 0
end = len(string) - 1
strlist = [i for i in string]
while(begin < end):
temp = strlist[begin]
strlist[begin] = strlist[end]
strlist[end] = temp
begin += 1
end -= 1
return ''.join(strlist)
print reverse('flash')
I know it's only a simple function but I'm keen to see where my thought process could be improved (even in such a simple context) for future projects. Well, this is technically a way to invalidate your function, but either the built in slicing operator or the reversed function would do this for you in one line:
"flash"[::-1]
>>> "hsalf"
The slice operator takes three parameters, where it starts and ends, but also what step to take as it increments. You could pass in 2 to get every second letter, but you can also pass in a negative value to start at the end and work backwards, hence reversing your string.
The reversed function can take any iterator and return it in reverse as a generator object. This means that it wont strictly print properly, ie. this is what you would get when printing it:
reversed("flash")
>>> <reversed object at 0x0000000002F50898>
But calling join with it will give the result you need:
''.join(reversed("flash"))
>>> "hsalf"
Note that as erip points out this can have trouble with unicode characters in Python 2. In 3 all strings are unicode, but not before then. So reversing non unicode strings actually messes up the byte order, causing erratic behaviour like this:
>>> print("mañana"[::-1])
ana±am
To safely avoid this in 2, make sure to declare it as unicode with a u before the string u"mañana". This will make either method work fine. Alternatively from __future__ import unicode_literals will make all strings unicode like they are in Python 3. | {
"domain": "codereview.stackexchange",
"id": 15414,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, python-3.x",
"url": null
} |
comparative-review, file, perl
9999
1212
1313
1414
1515 IMHO, the best way is the second example, but with some improvements:
#!/usr/bin/perl
use strict;
use warnings;
open my $fh, '<', 'DUMP' or die $!;
while(<$fh>) {
print $_;
print "\n" unless $. % 4;
}
There're no needs to temporary store in an array, and use the $. variable instead of a counter.
$. contains the current line number for the last filehandle accessed, see perlvar
If you want a separte function that returns the chunck:
#!/usr/bin/perl
use strict;
use warnings;
sub getChunck {
my $file = shift;
my @chunck;
open my $fh, '<', $file or die "Unable to open '$file': $!";
while(<$fh>) {
push @chunck, $_;
push @chunck, "\n" unless $. % 4;
}
return @chunck;
}
my @chunck = getChunck('DUMP'); | {
"domain": "codereview.stackexchange",
"id": 25651,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "comparative-review, file, perl",
"url": null
} |
food, nutrition, energy-metabolism
Title: What are the bare minimum nutrients required to survive as a human? I am trying to determine the bare minimum nutritional requirements to survive as a human, ignoring energy (caloric) requirements. Another way to ask this question is: What elements can humans not live without? I am not inquiring solely about what nutrients are needed, but also their approximate amounts.
Imagine pills that a person can take that covers all their base nutritional needs and that after taking this pill the person can eat whatever they want to meet their caloric requirements. Hypothetically, this pill could have some amount (how much?) fat, carbohydrates, protein, fiber, minerals, and vitamins, and the person could subsequently eat any other food to meet their caloric requirements knowing their nutritional needs would already be otherwise met. Lets ignore the possibility of the person suffering from health issues due to eating too much of any specific food to meet their caloric requirements (e.g., taking the magic pills and then eating only butter).
A person in this situation could think "Ok I've got most of my bases covered, now I just need to ingest another 1000 calories of (almost) anything I want).
What nutrients are absolutely necessary for humans to survive indefinitely, and how much of these nutrients are required?
I am hoping for a complete list with approximate amounts (e.g., 20g fat, 20g carbohydrates, 1mg Vitamin X, .05mg Vitamin Y, 10mg mineral X). Essential nutrients include (NutrientsReview):
Water
9 amino acids: histidine, isoleucine, leucine, lysine, methionine,
phenylalanine, tryptophan, threonine, valine
2 fatty acids (alpha linolenic and linoleic acid)
Vitamins: A, B1, B2, B3, B5, B6, folic acid, biotin, B12, C,
D, E and K (and choline, which is considered a vitamin-like substance)
Minerals: calcium, chromium, chloride, copper, iodine, iron,
manganese, molybdenum, phosphorus, potassium, selenium, sodium, zinc | {
"domain": "biology.stackexchange",
"id": 9763,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "food, nutrition, energy-metabolism",
"url": null
} |
python, object-oriented, design-patterns, abstract-factory
Title: Factory / Builder Design Pattern in Python Situation: I have implemented a factory design pattern in Python as below. There are different screens which have different configurations. One can register the screen in the factory and get the screen in case correct configuration is passed to respective factory class method.
Question: I am wondering if this is a clean solution as each screen class (Screen1, Screen2, ..) has a main-method which calls in a specific order the respective private class methods. Is there a better/cleaner way to handle the main methods in each class? Is it cleaner to implement a combination of factory and builder design pattern?
Highly appreciate any comments and improvements!!
Code:
import numpy as np
import pandas as pd
from abc import ABCMeta, abstractmethod
df = pd.DataFrame({"ident": ["A1", "A2", "B3", "B4"], "other_col": np.random.randint(1, 6, 4)})
class IScreens(metaclass=ABCMeta):
@abstractmethod
def main(self):
pass
class Screen1(IScreens):
def __init__(self, data, config):
self.data = data
self.batch = config["cfg1"]
def __get_letter(self):
self.data["campaign"] = self.data[self.batch].str[:1]
return self.data
def __get_number(self):
self.data["num"] = self.data[self.batch].str[1:]
return self.data
def __some_other_stuff(self):
self.data["other_stuff"] = self.data["num"].astype(int) * 100 / 2
return self.data
def main(self):
self.data = self.__get_letter()
self.data = self.__get_number()
self.data = self.__some_other_stuff()
# some more processing steps follow | {
"domain": "codereview.stackexchange",
"id": 40934,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, object-oriented, design-patterns, abstract-factory",
"url": null
} |
c++, beginner, game, tic-tac-toe
In gameover you could check diagonal after row and column check
for (int i = 0; i < 3; i++)
if (rows[i] > 2 || rows[i] < -2 || columns[i] > 2 || columns[i] < -2)
return true;
if (diagonal > 2 || diagonal < -2 || anti_diagonal > 2 || anti_diagonal < -2)
return true;
return false; | {
"domain": "codereview.stackexchange",
"id": 44232,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, beginner, game, tic-tac-toe",
"url": null
} |
special-relativity, spacetime, metric-tensor
Title: Definition of spacetime interval We know that a spacetime vector $x:= (\vec{x}, ct)$, where $c$ is the speed of light. Why is the interval $I$ in spacetime defined as
$$ I=-(\Delta t)^2 + \frac{1}{c^2}\left[ (\Delta x)^2+(\Delta y)^2+(\Delta z)^2 \right] ?$$
More concretely,
(1) Why is $I$ defined in terms of squared components (without the square root)? If it were $I^2$ then it'd be more clear.
(2) Why does division by $c^2$ happen in $I$? What is $c^2 I$ then?
Would appreciate some insights.
I have written the answer with the following expression in mind as the expression for interval: $\Delta t^2 - \dfrac{1}{c^2}(\Delta x^2 + \Delta y^2 + \Delta z^2)$. In my experience, this is a rather common form of interval than the one stated by the OP. Whenever I write something like "the form you mentioned", it really means to refer to the above-stated expression. | {
"domain": "physics.stackexchange",
"id": 36688,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "special-relativity, spacetime, metric-tensor",
"url": null
} |
physical-chemistry, quantum-chemistry, electronic-configuration
"A closed shell has zero orbital angular momentum because all the
individual orbital angular momenta sum to zero. Therefore, when
working out term symbols, we need consider only the electrons of the
unfilled shell."
So, a configuration like $[\text{He}]1s^2$ or $[\text{He}]1s^2 2p^6 $ should have $L = 0$, right? The first presents $L = 0$ for sure, since $l = 0$ for $s$ orbitals and applying the Clebsch-Gordan series we obtain $0$. Doing the same for the second configuration, on the other hand, I obtain values other than $0$.
Could someone explain to me better? One way of looking at this is to consider that if $L = 1$ (for example), then there must be a state with $M_L = -1$ (because $M_L$ ranges from $-L$ to $L$ in integer steps).
However, $M_L$ is not obtained by a Clebsch–Gordan series: instead, it's just a simple addition of the individual $m_l$'s of each electron. That is:
$$M_L = m_{l,1} + m_{l,2} + m_{l,3} + m_{l,4} + m_{l,5} + m_{l,6}$$
and for a p subshell, the allowed values of $m_l$ are $-1$, $0$, $+1$ (there are two of each). So $M_L$ for a full p subshell must be $0$, and it's then a contradiction to have $L \neq 0$ as that would imply that $M_L$ can have a nonzero value.
This is basically a manifestation of the Pauli exclusion principle, because it is precisely that which forces the sum of $m_l$'s to be zero. If you read around in Atkins, it will mention how certain term symbols are forbidden due to the Pauli exclusion principle. This is a similar case. | {
"domain": "chemistry.stackexchange",
"id": 15886,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "physical-chemistry, quantum-chemistry, electronic-configuration",
"url": null
} |
graph-isomorphism
Title: Is anyone aware of a counter-example to the Dharwadker-Tevet Graph Isomorphism algorithm? At http://www.dharwadker.org/tevet/isomorphism/, there is a presentation of an algorithm for determining if two graphs are isomorphic. Given a number of shall we say, "interesting" claims by A Dharwadker, I am not inclined to believe it.
In my investigation, I find that the algorithm will definitely produce the correct answer and tell you that two graphs are not isomorphic when in fact that is correct. However, it is not clear that the algorithm will consistently tell you if two graphs are isomorphic when they actually are. The "proof" of their result leaves something to be desired.
However, I am not aware of a counter-example. Before I start writing software to test out the algorithm, I thought I would see if anyone was already aware of a counter-example.
Someone requested a synopsis of the algorithm. I will do what I can here, but to really understand it, you should visit http://www.dharwadker.org/tevet/isomorphism/.
There are two phases to the algorithm: A "signature" phase and a sorting phase. The first "signature" phase (this is my term for their process; they call it generating the "sign matrix") effectively sorts vertices into different equivalence classes. The second phase first orders vertices according to their equivalence class, and then applies a sort procedure within equivalence classes to establish an isomorphism between the two graphs. Interestingly, they do not claim to establish a canonical form for the graphs - instead, one graph is used as a kind of template for the second.
The signature phase is actually quite interesting, and I would not do it justice here by attempting to paraphrase it. If you want further details, I recommend following the link to examine his signature phase. The generated "sign matrix" certainly retains all information about the original graph and then establishes a bit more information. After collecting the signatures, they ignore the original matrix since the signatures contain the entire information about the original matrix. Suffice to say that the signature performs some operation that applies to each edge related to the vertex and then they collects the multiset of elements for a vertex to establish an equivalence class for the vertex. | {
"domain": "cstheory.stackexchange",
"id": 3344,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "graph-isomorphism",
"url": null
} |
# last N digits
##### Well-known member
Prove that the last 6 digits of 7^10000 is 000001
#### Klaas van Aarsen
##### MHB Seeker
Staff member
Prove that the last 6 digits of 7^10000 is 000001
$\begin{array}{} 7^4 &=& 2401 &\equiv& 1 \pmod{400} \\ 7^{100} &=& (7^4)^{25} &=& (400k+1)^{25} &=& ...\ +\ 25 \cdot 400k + 1 &\equiv& 1 \pmod{10000} \\ 7^{10000} &=& (7^{100})^{100} &=& (10000m + 1)^{100} &=& ...\ +\ 100\cdot 10000m + 1 &\equiv& 1 \pmod{1000000} \\ \blacksquare \end{array}$
##### Well-known member
$\begin{array}{} 7^4 &=& 2401 &\equiv& 1 \pmod{400} \\ 7^{100} &=& (7^4)^{25} &=& (400k+1)^{25} &=& ...\ +\ 25 \cdot 400k + 1 &\equiv& 1 \pmod{10000} \\ 7^{10000} &=& (7^{100})^{100} &=& (10000m + 1)^{100} &=& ...\ +\ 100\cdot 10000m + 1 &\equiv& 1 \pmod{1000000} \\ \blacksquare \end{array}$
neater than my solution. I shall post mine one week later so that others can post
##### Well-known member
here is my solution
we know 7^4 = 2401
so 7^10000 = (2401)^2500
now 2401^2500 = (2400+1)^2500 | {
"domain": "mathhelpboards.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9626731158685838,
"lm_q1q2_score": 0.8201520656810722,
"lm_q2_score": 0.851952809486198,
"openwebmath_perplexity": 2617.596651277417,
"openwebmath_score": 0.4150587022304535,
"tags": null,
"url": "https://mathhelpboards.com/threads/last-n-digits.7652/"
} |
pcl, catkin, ros-groovy
example2.cpp:(.text._ZN3pcl6detail11FieldMapperINS_8PointXYZEEclINS_6fields1yEEEvv[void pcl::detail::FieldMapper<pcl::PointXYZ>::operator()<pcl::fields::y>()]+0x1a1): undefined reference to `pcl::console::print(pcl::console::VERBOSITY_LEVEL, char const*, ...)'
CMakeFiles/example2.dir/src/example2.cpp.o: In function `void pcl::detail::FieldMapper<pcl::PointXYZ>::operator()<pcl::fields::z>()':
example2.cpp:(.text._ZN3pcl6detail11FieldMapperINS_8PointXYZEEclINS_6fields1zEEEvv[void pcl::detail::FieldMapper<pcl::PointXYZ>::operator()<pcl::fields::z>()]+0x1a1): undefined reference to `pcl::console::print(pcl::console::VERBOSITY_LEVEL, char const*, ...)'
CMakeFiles/example2.dir/src/example2.cpp.o:(.rodata._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[vtable for pcl::search::OrganizedNeighbor<pcl::PointXYZ>]+0x48): undefined reference to `pcl::search::OrganizedNeighbor<pcl::PointXYZ>::nearestKSearch(pcl::PointXYZ const&, int, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&) const' | {
"domain": "robotics.stackexchange",
"id": 16245,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "pcl, catkin, ros-groovy",
"url": null
} |
Yes I figured it out. Thanks!
Okay, so I have my matrix in in the basis of |1> and |2> as (1,0)
(0 1)
Sorry I am not sure how to write matrices on this forum. I am wondering how would I apply the change of basis to get them into the basis of the eigenkets of A? Since the eigenkets is just |1> and |2> wouldn't they be the same basis?
kuruman
Homework Helper
Gold Member
To write matrices and other math expressions, click on the LaTeX link, bottom left and to the right of the question mark.
Constructing the matrix in the eigenket representation, $|V_1>$, $|V_2>$, use the same procedure. The ijth element is $A_{ij}=<V_i|A|V_j>$. If you do it correctly, you will see something that should have been obvious in retrospect.
So if my eigenket is |1> and |2> then would my result not be the same? Or is my eigenkets not |1> and |2>
Orodruin
Staff Emeritus
Homework Helper
Gold Member
|1> is the eigenvector and 1 is the eigenvalue for A|1> and |2> is the eigenket and -1 is the eigenvector for A|2>.
I believe you have a slight, but important misunderstanding. There is no such thing as an eigenvector of A|1> or an eigenvector of A|2>. Instead, A|1> = |1> means that |1> is an eigenvector of A with eigenvalue 1 and similarly |2> is an eigenvector of A with eigenvalue -1.
A is an operator from a 2D space to a 2D space. As such it should be represented by a 2x2 matrix, not a column or row matrix. | {
"domain": "physicsforums.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9669140187510509,
"lm_q1q2_score": 0.8199119148818986,
"lm_q2_score": 0.8479677602988601,
"openwebmath_perplexity": 610.3057921802115,
"openwebmath_score": 0.8993744850158691,
"tags": null,
"url": "https://www.physicsforums.com/threads/eigenketes-and-eigenvalues-of-operators.956279/"
} |
# Doubt about substitution in$\int_{-1}^{1}\sqrt{1+x^2}dx$
I've tried this substitution in this integral
$$\int_{-1}^{1}\sqrt{1+x^2}dx$$
Let $x^2=t$, so $x=\sqrt{t}$ and $dx=\frac{1}{2\sqrt{t}}dt$. So we have
$$\frac{1}{2}\int_{1}^{1}\sqrt{\frac{1+t}{t}}dt=0$$
Which is obviously wrong. I know that this integral can be done with integration by parts or hyperbolic substitution, I want to know why this happens. My idea is that $x^2$ isn't always invertible, it is only on $[0, +\infty)$, and that causes this problem with the interval of integration.
Am I right? Thanks for your time.
• $x= \pm \sqrt t$ – John Lou Oct 20 '17 at 18:51
• Trig sub. Enjoy. – Randall Oct 20 '17 at 18:51
• i would use $$x=\tan(t)$$ – Dr. Sonnhard Graubner Oct 20 '17 at 18:52
• First see that you function is even on a symmetric domain so break your integral in two – Guy Fsone Oct 20 '17 at 18:53
• I think the OP is not asking how to do it, but why his method fails. – velut luna Oct 20 '17 at 18:56
Error, When you set this $x^2=t$, so $x=\sqrt{t}$ it is wrong because $$-1\le x \le 1$$ that is $x=\sqrt{t}$ is not only positive but can be $x= -\sqrt{t}$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9780517501236462,
"lm_q1q2_score": 0.8497575390882547,
"lm_q2_score": 0.8688267660487572,
"openwebmath_perplexity": 166.78486508017176,
"openwebmath_score": 0.9013466238975525,
"tags": null,
"url": "https://math.stackexchange.com/questions/2481863/doubt-about-substitution-in-int-11-sqrt1x2dx"
} |
Since $$^{2n}x \ge \mathrm{e}^{-1}$$ for all $$0 < x < \mathrm{e}^{-\mathrm{e}}$$, we have $$I_4(n) := \int_{\frac35\mathrm{e}^{-\mathrm{e}}}^{\mathrm{e}^{-\mathrm{e}}} \frac{1}{^{2n}x}\mathrm{d} x \le \int_{\frac35\mathrm{e}^{-\mathrm{e}}}^{\mathrm{e}^{-\mathrm{e}}} \frac{1}{x^{x^{1/\mathrm{e}}}}\mathrm{d} x < 0.0715.$$
One can use Mathematical Induction to prove that $$^{2n} x \ge \frac34$$ for all $$0 < x < \frac35 \mathrm{e}^{-\mathrm{e}}$$. We have $$I_5(n) := \int_0^{\frac35 \mathrm{e}^{-\mathrm{e}}} \frac{1}{^{2n}x}\mathrm{d} x \le \int_0^{\frac35 \mathrm{e}^{-\mathrm{e}}} \frac{1}{x^{x^{3/4}}}\mathrm{d} x < 0.0485.$$
Thus, $$I(n) = I_1(n) + I_2(n) + I_3(n) + I_4(n) + I_5(n) < 2$$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9848109543125689,
"lm_q1q2_score": 0.8269792080970275,
"lm_q2_score": 0.8397339656668287,
"openwebmath_perplexity": 592.8333646866685,
"openwebmath_score": 0.9738123416900635,
"tags": null,
"url": "https://math.stackexchange.com/questions/4382978/is-each-of-int-0-infty-fracdxxx-int-0-infty-fracdxxxxx-int"
} |
organic-chemistry, aromatic-compounds, hybridization
Title: Hybridisation of carbon atom in cyclopentadienyl anion How do I figure out the hybridisation of the carbon with the negative charge?
One logic is that it is an $\mathrm{sp^3}$ carbon because there are 3 sigma bonds and 1 lone pair around it.
Another reasoning, though, is that it is $\mathrm{sp^2}$; we don't count the lone pair, because it is in conjugation with the double bonds.
What is the correct explanation? It entirely depends on what that electron pair is doing.
If the lone pair is hanging out by itself in its own orbital, then the carbon is probably sp3 hybridized, as greater hybridization is typically more stable. This is what you'll see on an alcohol or an amine lone pair. Those lone pairs aren't really interacting with anything else in the molecule, hence the "standard" logic of the rule you invoke.
However, in certain compounds you're able to stabilize the system further by delocalizing the electron pair. In this sort of case, the sp3 hybridized lone pair orbital is not able to participate in the delocalization, and thus will be higher in energy than an electron pair that is in the remaining p orbital of an sp2 hybridized carbon. This is the sort of thing you see with amide groups, where the "lone pair" on the nitrogen is sp2-like, which allows the electron pair to delocalize into the carbonyl, allowing for resonance stabilization.
Note that delocalization is not always going to happen. You can potentially draw up examples where delocalization would decrease the stability of the compound. For example, 1,4-Dihydropyrazines would be anti-aromatic if both lone pairs from each nitrogen were to participate in the ring system. This is highly disfavorable, and the molecule contorts itself to avoid it, putting the nitrogens into sp3 (pyramidal) hybridization, except where it needs to be planar to conjugate with an exocyclic double bond. | {
"domain": "chemistry.stackexchange",
"id": 4889,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "organic-chemistry, aromatic-compounds, hybridization",
"url": null
} |
Denote $r_0 = tr(A) = a+d$ and similarly let $r_j = tr(R_j)$, where $R_j$'s are the matrices obtained by repeated squareroots as in B.. By proposition B. again, we must have $r_j\in\mathbb Z$ and satisfy the recurrence $$r_{j+1}^2 = r_j + 2 \implies r_{j+1} = \pm \sqrt{r_j + 2}$$ Since $r_{j+1}\in\mathbb Z$ clearly $r_j\geq -2$ for each $j$.
For $r_0=2$, corresponding to $A=\begin{pmatrix} 2 & 1\\ -1 & 0\end{pmatrix}$, we have seen at the start of the answer that it is an exceptional matrix.
For $r_0 = -2,0,1$, we get $r_1 = 0, \pm \sqrt{2}, \pm \sqrt{3}$ respectively. $r_1=0$ in turn gives $r_2 = \pm \sqrt{2}$, so all of them contradicts $r_j\in\mathbb Z$.
For $r_0 > 2$, then $r_1^2 > 4$. Since $r_j > -2$ we must have $r_1>2$ again, so by induction $r_j > 2$ for all $j$. The sequence of $r_{j+1} = \sqrt{r_j+2}$ becomes smaller than $3$ for some sufficiently large $m$, then $2 < r_m < 3$ results in $$r_{m+1}^2 = r_m + 2 \implies 4 < r_{m+1}^2 < 5$$ which contradicts the fact that $r_{m+1}\in\mathbb Z$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9850429116504951,
"lm_q1q2_score": 0.8430501129914817,
"lm_q2_score": 0.8558511543206819,
"openwebmath_perplexity": 176.19978707873526,
"openwebmath_score": 0.9992186427116394,
"tags": null,
"url": "https://math.stackexchange.com/questions/2843910/square-matrix-with-rational-coefficients-having-k-th-root"
} |
c#, performance, cache, antlr, rubberduck
return new HashSet<QualifiedContext<VBParser.AmbiguousIdentifierContext>>(result);
}
private HashSet<QualifiedContext<VBParser.AmbiguousIdentifierContext>> GetAssignments()
{
var result = new List<QualifiedContext<VBParser.AmbiguousIdentifierContext>>();
foreach (var module in _parseResult)
{
var HashSetener = new VariableAssignmentListener(module.QualifiedName);
result.AddRange(module.ParseTree
.GetContexts<VariableAssignmentListener, VBParser.AmbiguousIdentifierContext>(HashSetener)
.Where(identifier => !IsConstant(identifier.Context) && !IsJoinedAssignemntDeclaration(identifier.Context)));
}
return new HashSet<QualifiedContext<VBParser.AmbiguousIdentifierContext>>(result);
}
private HashSet<QualifiedContext<VBParser.AmbiguousIdentifierContext>> GetIdentifierUsages(IEnumerable<QualifiedContext<VBParser.AmbiguousIdentifierContext>> assignments)
{
var result = new List<QualifiedContext<VBParser.AmbiguousIdentifierContext>>();
foreach (var module in _parseResult)
{
var listener = new VariableReferencesListener(module.QualifiedName);
var usages = module.ParseTree.GetContexts<VariableReferencesListener, VBParser.AmbiguousIdentifierContext>(listener);
result.AddRange(usages.Where(usage => assignments.Any(assignment => !usage.Equals(assignment))));
}
return new HashSet<QualifiedContext<VBParser.AmbiguousIdentifierContext>>(result);
}
private static bool IsConstant(VBParser.AmbiguousIdentifierContext context)
{
return context.Parent.Parent.GetType() == typeof(VBParser.ConstSubStmtContext);
} | {
"domain": "codereview.stackexchange",
"id": 12416,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c#, performance, cache, antlr, rubberduck",
"url": null
} |
javascript
// Need result in this format to send to the database
// [ { "objectid": "111", "contacts": [ { "isdelete": "1", "contactid": "1", "associationid": "1968397" } ] } ]
// [ { "objectid": "222", "contacts": [ { "isdelete": "1", "contactid": "1", "associationid": "1968398" }, { "isdelete": "1", "contactid": "2", "associationid": "1968399" } ] } ]
// [ { "objectid": "333", "contacts": [ { "isdelete": "1", "contactid": "2", "associationid": "1968401" }, { "isdelete": "1", "contactid": "1", "associationid": "19684034" } ] } ] If I understand everything correctly, then this can be done easier. The code can be formatted in different ways. But the main thing is that there is less action. So:
we split the data into parts
then through reduce we form a common array of objects
parse data for object (including objectid)
check globalLkupRemoveContactReviewer if we should add something
to save space, we form a child object once
if we have an object with this objectid - update it otherwise create it
const globalLkupRemoveContactReviewer = [
{ objectid: 555, userid: '1', associationid: '1948874' },
{ objectid: 555, userid: '2', associationid: '1950833' },
]; | {
"domain": "codereview.stackexchange",
"id": 44453,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "javascript",
"url": null
} |
# Possible Jordan Canonical Forms: Intuition
As I was reviewing linear algebra before I head off to grad school in the fall, I came across a question about Jordan Canonical Forms. It reads: "Suppose that A is a square complex matrix with characteristic polynomial $$c_A(x) = (x−1)^4(x+ 3)^5$$. Assume also that $$A−I$$ has nullity 4 and $$A+3I$$ has nullity 1, where $$I$$ is the identity matrix of the same size as $$A$$. Find, with justification, all possible Jordan canonical forms of $$A$$, and give the minimal polynomial for each." | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9888419713825142,
"lm_q1q2_score": 0.8084519545936919,
"lm_q2_score": 0.8175744739711883,
"openwebmath_perplexity": 114.88583256261047,
"openwebmath_score": 0.9931345582008362,
"tags": null,
"url": "https://math.stackexchange.com/questions/3305131/possible-jordan-canonical-forms-intuition"
} |
# Does $\sum_{n\geq 2} \frac{\ln(1+n)}{\ln(n)}-1$ converge/diverge?
How would you prove convergence/divergence of the following series?
$$\sum_{n\geq 2}\left( \dfrac{\ln(1+n)}{\ln(n)}-1\right)$$
I'm interested in more ways of proving convergence/divergence for this series.
My thoughts
$$\dfrac{\ln(1+n)}{\ln(n)}=\frac{\ln(n(1+\dfrac{1}{n})}{\ln(n)} =\frac{\ln(n)+\ln(1+\frac{1}{n})}{\ln(n)} =1+\frac{\ln(1+\frac{1}{n})}{\ln(n)}$$
then
$$\dfrac{\ln(1+n)}{\ln(n)}-1=\frac{\ln(1+\frac{1}{n})}{\ln(n)}$$
note that $\ln(1+\frac 1n)=\frac 1n+o(\frac 1n)$ then $\ln(1+\frac 1n)\sim \frac 1n$ thus $u_n-1\sim \frac 1{n\ln(n)}$
or the serie $\dfrac{1}{n\ln(n)}$ divergent by Bertrand's test
the sum up $\sum_{n\geq 2} \dfrac{\ln(1+n)}{\ln(n)}-1$ divergent | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9811668728630677,
"lm_q1q2_score": 0.8067047423710978,
"lm_q2_score": 0.822189134878876,
"openwebmath_perplexity": 709.4823761139843,
"openwebmath_score": 0.967735767364502,
"tags": null,
"url": "https://math.stackexchange.com/questions/1445503/does-sum-n-geq-2-frac-ln1n-lnn-1-converge-diverge"
} |
quantum-mechanics, quantum-information, quantum-computer, superposition
Title: Is QC with Superpositioned Quantum Gates any different than normal Quantum Computation? This might be more appropriate for theoretical CS stackexchange, but it feels sufficiently low level to be relevant here.
Consider the following thought experiment:
I have a Quantum FPGA, it is a Quantum Computer, whose gates themselves can be controlled programmatically.
For example: Suppose I can have a gate object G which can be in a superposition of being a 1 Qubit Pauli X or a 1 Qubit Hadamard gate. The gate object could then be superpositioned into:
$$a_0 \left| P_x \right> + a_1 \left| H \right>$$
So when I apply this gate to a single Qubit $Q = Q_0 \left| 0 \right>+ Q_1 \left| 1 \right>$
The resulting state is
$$ a_0 \left| P_x Q \right> + a_1 \left|H Q \right>$$
$$ a_0 \left| \left( Q_1 \left| 0 \right> + Q_0 \left| y \right> \right) \right> +a_1 \left| \left( \frac{Q_0 + Q_1}{\sqrt{2}} \left| 0 \right> + \frac{Q_0 - Q_1}{\sqrt{2}}\left| y \right> \right) \right> $$
As far sampling the Qubit goes, this state looks identical to perhaps some other composition of concrete gates, but at a high level, it may be possible to determine for example the nature of $G$, in which case, the Qubit collapses to a smaller superposition.
So my question:
Is Quantum Computation with Concrete Gates Equivalent in its computational power to Quantum Computation with Superpositioned Gates?
Obviously they must be equivalent up to Polynomial time differences, simply because the first is capable of simulating any quantum system including the latter in polynomial time. But do we know for fact that the latter class, isn't say polynomially faster?
Something to note here (and switching to matrix notation).
The system is initialized with qubits $A,Q$ of the form: | {
"domain": "physics.stackexchange",
"id": 29779,
"lm_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-computer, superposition",
"url": null
} |
- 6 years, 3 months ago
Yes, checking only for certain value $x$ doesn't mean we can determine whether the sum converges or diverges.
- 6 years, 3 months ago
Using the same logic, one could incorrectly conclude that $\displaystyle\sum_{n = 0}^{\infty}\dfrac{1}{2n+1}$ converges.
- 6 years, 3 months ago
i think that is divergen which use GF and taylor series
- 6 years, 3 months ago
Would you mind to show your solution, Kak Uzu? (Soal Adhel loh hehe ^^)
- 6 years, 3 months ago | {
"domain": "brilliant.org",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.979354068055595,
"lm_q1q2_score": 0.8074401394418087,
"lm_q2_score": 0.8244619242200082,
"openwebmath_perplexity": 359.13452823007,
"openwebmath_score": 0.9817647337913513,
"tags": null,
"url": "https://brilliant.org/discussions/thread/diverges-or-converges-r/"
} |
backpropagation, theory, linear-algebra
because
$$\frac{\partial \mathbf{z^{(k+1)}}}{\partial \mathbf{a}^{(k)}} = \dfrac{\partial\left((\mathbf{W}^{(k)})^T \mathbf{a}^{(k)} + \mathbf{b}^{(k)}\right)}{\partial \mathbf{a}^{(k)}}=\dfrac{\partial\left((\mathbf{W}^{(k)})^T \mathbf{a}^{(k)}\right)}{\partial \mathbf{a}^{(k)}} + \dfrac{\partial\mathbf{b}^{(k)}}{\partial \mathbf{a}^{(k)}}$$
and $\dfrac{\partial\mathbf{b}^{(k)}}{\partial \mathbf{a}^{(k)}}=0$ since $\mathbf{b}^{(k)}$ doesn't depend on $\mathbf{a}^{(k)}.$
Thus
$$\dfrac{\partial\left((\mathbf{W}^{(k)})^T \mathbf{a}^{(k)}\right)}{\partial \mathbf{a}^{(k)}} = \dfrac{\partial \mathbf{a}^{(k)}}{\partial \mathbf{a}^{(k)}} \mathbf{W}^{(k)} = \mathbf{W}^{(k)}.$$
by vector-by-vector (eight and seventh row, last column identities, respectively) | {
"domain": "datascience.stackexchange",
"id": 1636,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "backpropagation, theory, linear-algebra",
"url": null
} |
November 5th, 2019, 05:47 AM #2 Math Team Joined: Jul 2011 From: Texas Posts: 3,093 Thanks: 1675 $s$ is displacement from equilibrium $a=-ks$ $\dfrac{dv}{dt} = -ks$ $\dfrac{dv}{dt} \cdot \dfrac{dt}{ds} = -\dfrac{ks}{v}$ $\dfrac{dv}{ds} = -\dfrac{ks}{v}$ $v \, dv = -ks \, ds$ $\dfrac{v^2}{2} = -\dfrac{ks^2}{2} + C_1$ $v^2 = -ks^2 + C_2$ when $s=5$, $v=0$ $\implies C_2=25k$ $v^2 = k(25-s^2)$ when $s=0$, $v=10 \implies k=4$ Had the mass of the sphere been given, an easier solution path could be found using conservation of energy. Thanks from topsquark and Chemist116 Last edited by skeeter; November 5th, 2019 at 06:31 AM.
November 5th, 2019, 07:31 AM #3 Math Team Joined: Jul 2011 From: Texas Posts: 3,093 Thanks: 1675 One final note ... the author of this problem used the equation $a = -ks$, which was a bit misleading at first. The actual equation should be $F = -ks \implies ma = -ks \implies a = -\dfrac{k}{m} \cdot s$ $F$ is the restoring force when an object is displaced from equilibrium, acting opposite in direction to the object's displacement. ... he/she just replaced the constant $\dfrac{k}{m}$ with a $k$ Thanks from topsquark and Chemist116
November 7th, 2019, 12:53 AM #4
Senior Member | {
"domain": "mymathforum.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9688561676667173,
"lm_q1q2_score": 0.8156079762068269,
"lm_q2_score": 0.8418256532040707,
"openwebmath_perplexity": 954.4220339483282,
"openwebmath_score": 0.7868483066558838,
"tags": null,
"url": "http://mymathforum.com/physics/347393-how-do-i-find-constant-oscillation-given-sphere-motion.html"
} |
In $2x^3- 3x^2+ a+ 1= 0$, there are either one or two sign changes depending upon whether a+ 1 is positive or negative. If a< 1, so that a+ 1 is negative, the signs are "+, -, -" so there is one sign change and exactly one positive root. If a> 1, so that a+ 1 is positive, the signs are "+, -, +" so there are two sign changes and two positive roots or none.
For negative roots, replace x with -x and do the same. $2(-x)^3- 3(-x)^2+ a+ 1= -2x^3- 3x^2+ a+ 1= 0$. Now, if a+ 1> 0, there is one sign change so the original equation has exactly one negative root. If a+1< 0, there are no sign changes so the original equation has no negative roots.
Thus, we can say that if a> -1, there is one negative root and either 0 or 2 positive roots. If a<-1, there is one positive root and no negative roots.
Of course, if a= 1, the equation is $2x^3- 3x^2= x^2(2x- 3)= 0$ which has x= 0 as a double root and x= 3/2 as a positve root. | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9871787838473909,
"lm_q1q2_score": 0.8070921771135088,
"lm_q2_score": 0.8175744761936437,
"openwebmath_perplexity": 304.43713948662395,
"openwebmath_score": 0.8184946179389954,
"tags": null,
"url": "http://mathhelpforum.com/pre-calculus/167169-finding-number-roots-third-grade-eqautions.html"
} |
ros-melodic
Title: Installing ros-melodic-desktop uninstalls python3-catkin-pkg
See relevant GitHub tracking ticket with more info and steps here.
I am attempting to build a ROS2 package that uses ROS1 bridge (rosbag2_bag_v2) in a GitHub Actions CI pipeline. I am able to install the dependencies for ROS1 which include python3-catkin-pkg. However, when I run apt-get install ros-melodic-desktop, it automatically removes python3-catkin-pkg:
The following packages will be REMOVED:
python3-catkin-pkg python3-rosdep python3-rosdep-modules python3-rosdistro
python3-rospkg
Is there a reason this occurs and is it possible to install a ROS1 distro without removing python3-catkin-pkg
Originally posted by piraka9011 on ROS Answers with karma: 32 on 2020-03-04
Post score: 0
Is there a reason this occurs
ROS1 / catkin_make uses python-catkin-pkg to parse package.xml.
In ROS2 / colcon python3-catkin-pkg is used.
These 2 packages conflict as they install the same scripts.
The libraries can be installed side by side since some modules packages have been created:
python3-catkin-pkg-modules and python-catkin-pkg: https://github.com/ros-infrastructure/catkin_pkg/pull/157
is it possible to install a ROS1 distro without removing python3-catkin-pkg | {
"domain": "robotics.stackexchange",
"id": 34540,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros-melodic",
"url": null
} |
the-moon, declination, precession, space-geometry
\end{align}$$
Hopefully, I haven't messed up a minus sign somewhere while transcribing all those equations. ;)
Finally, here are some actual results. Using the value for $\varepsilon$ mentioned earlier, | {
"domain": "astronomy.stackexchange",
"id": 6014,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "the-moon, declination, precession, space-geometry",
"url": null
} |
• $m/n = 2$, and thus $x = 4/5 = 0.8$
• $m/n = 7/3$, and thus $x = 2^7 / 5^3 = 1.024$ and $1/x = 0.9765625$
• $m/n = 65/28$, and thus $x = 2^{65}/5^{28} = 0.99035\ldots$
-
Can you justify your first sentence? Also, is a number like $2^{m_1}5^{m_2}/2^{n_1}5^{n_2}$ also possible? – user103828 May 5 '14 at 9:03
Yes, but you can cancel things out. e.g. $8/10$ works, but it's the same number as $4/5$. – Hurkyl May 5 '14 at 10:18
The number could also be of the form $2^m 5^n$, $5^m / 2^m$, or $1 / (2^m 5^m)$. The first and the third options are not close to $1$. But I think the second option should be included. – Goos May 5 '14 at 18:48
@Goos: Remember we're looking for a pair ($x$, $1/x$); if $x=5^m/2^n$, then $1/x$ is of the form my post is looking for. However, I've been wondering if continued fractions would find a different set of approximations for $\ln 2 / \ln 5$, but not enough to grind through the algebra to see. – Hurkyl May 5 '14 at 20:27 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9867771809697151,
"lm_q1q2_score": 0.8367552379565454,
"lm_q2_score": 0.8479677622198947,
"openwebmath_perplexity": 225.36322147773234,
"openwebmath_score": 0.9175000786781311,
"tags": null,
"url": "http://math.stackexchange.com/questions/781218/numbers-whose-self-and-reciprocal-are-finitely-decimally-expressable-that-are-cl"
} |
slam, navigation, odometry, visual-odometry, static-transform-publisher
<param name="imu0_remove_gravitational_acceleration" value="true"/>
<param name="print_diagnostics" value="true"/>
<!-- ======== ADVANCED PARAMETERS ======== -->
<param name="odom0_queue_size" value="2"/>
<param name="imu0_queue_size" value="10"/>
<param name="odom0_pose_rejection_threshold" value="0.1"/>
<param name="odom0_twist_rejection_threshold" value="0"/>
<param name="imu0_pose_rejection_threshold" value="0.5"/>
<param name="imu0_twist_rejection_threshold" value="0"/>
<param name="imu0_linear_acceleration_rejection_threshold" value="0.1"/>
<param name="debug" value="false"/>
<param name="debug_out_file" value="debug_ekf_localization.txt"/> | {
"domain": "robotics.stackexchange",
"id": 23090,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "slam, navigation, odometry, visual-odometry, static-transform-publisher",
"url": null
} |
c#, linq, properties
<field name="UniversalID"/>
<field name="UniversalIDType"/>
</datatype>
</field>
<field name="OrganizationIdentifier"/>
</datatype>
</field>
<field name="Errors">
<group type="ProblemCollection">
<e value="MSH-6 (ReceivingFacility) : Invalid value: zz1001. Reason: No user assigned to this facility." path="MSH/ReceivingFacility/NamespaceID" type="problem" HL7ErrorCode="z3" HL7ErrorCodeFullDescription="Table value not found" SegmentID="Msh" SegmentSequence="" FieldPosition="6" FieldRepetition="1" ComponentNumber="" SubComponentNumber="" Severity="E"/>
</group>
</field>
</segment>
<field name="Errors">
<group type="ProblemCollection">
<e value="MSH-6 (ReceivingFacility) : Invalid value: ML1001. Reason: No user assigned to this facility." path="MSH/ReceivingFacility/NamespaceID" type="problem" HL7ErrorCode="zzz" HL7ErrorCodeFullDescription="Table value not found" SegmentID="Msh" SegmentSequence="" FieldPosition="6" FieldRepetition="1" ComponentNumber="" SubComponentNumber="" Severity="E"/>
</group>
</field>
<field name="Warnings">
<group type="ProblemCollection"> | {
"domain": "codereview.stackexchange",
"id": 8823,
"lm_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#, linq, properties",
"url": null
} |
fasta, python
And got to extract only the unique names with this:
lines_seen = set()
outfile = open('species2.txt', "w")
for line in open("species.txt", "r"):
if line not in lines_seen: # not a duplicate
outfile.write(line)
lines_seen.add(line)
outfile.close()
(Can I merge those two scripts together?)
Now, my genus names look like this:
Arthrobacter
Achromobacter
Delftia
....
I tried automating my script to get the Entrez data, but it gives me the 'Supplied id parameter is empty' message
My code looks like this:
from Bio import Entrez
Entrez.email = "example@example.org"
for line in open("species2.txt", "r"):
searchterm = "(terminase large subunit AND viruses[Organism]) AND" +line+ "AND refseq[Filter]"
searchResultHandle = Entrez.esearch(db="protein", term=searchterm, retmax=1000)
searchResult = Entrez.read(searchResultHandle)
ids = searchResult["IdList"]
handle = Entrez.efetch(db="protein", id=ids, rettype="fasta", retmode="text")
record = handle.read()
out_handle = open('terminase_large_'+str(line[:-1])+'.fasta', 'w')
out_handle.write(record.rstrip('\n'))
Can someone help me with it? Splitting into multiple files and changing the IDs can be easily done:
perl -pe 'if(/>/){/\[(.*?)\]\s*$/; $_="> $1\n"}' file.fa |
awk '(/^>/){name=$2} {print >> name".fa"}' | {
"domain": "bioinformatics.stackexchange",
"id": 188,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "fasta, python",
"url": null
} |
bond, quantum-chemistry, molecular-orbital-theory
This is why the energy levels of $E_+$ and $E_-$ are not symmetrical with respect to the energy level of $E_\text{1s}$.
Intuitive Explanation
The intuitive explanation goes along the following line: Imagine two hydrogen nuclei that slowly get closer to each other, and at some point start mixing their orbitals. Now, one very important interaction is the coulomb force between those two nuclei, which gets larger the closer the nuclei come together. As a consequence of this, the energies of the molecular orbitals get shifted upwards, which is what creates the asymmetric image that we have for these energy levels.
Basically, you have two positively charged nuclei getting closer to each other. Now you have two options: | {
"domain": "chemistry.stackexchange",
"id": 16689,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "bond, quantum-chemistry, molecular-orbital-theory",
"url": null
} |
delphi, graphics
function TweakColor(const AColor: TColor; const ADiff: Integer): TColor;
var
R, G, B: Byte;
D: Integer;
Dir: Integer;
begin
R:= GetRValue(AColor);
G:= GetGValue(AColor);
B:= GetBValue(AColor);
D:= (R + G + B) div 3; //D = average difference of all 3 color channels
if D >= (256 div 2) then begin //If average is a lighter color...
Dir:= -ADiff; //Make the color darker
end else begin //If average is a darker color...
Dir:= ADiff; //Make the color lighter
end;
R:= IntRange(R + Dir, 0, 255);
G:= IntRange(G + Dir, 0, 255);
B:= IntRange(B + Dir, 0, 255);
Result:= RGB(R, G, B);
end;
Example Usage:
Canvas.Font.Color:= TweakColor(Canvas.Font.Color, 50); I think that your algorithm is overly simplistic. To illustrate its problems, try running the Stack Snippet in this answer, in which I have translated your TweakColor() function into JavaScript for demonstration purposes.
It has three significant flaws, in my opinion: | {
"domain": "codereview.stackexchange",
"id": 10876,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "delphi, graphics",
"url": null
} |
crystals
In the case of $\text{KAl(SO}_4)_2\cdot12\text{H}_2\text{O}$, the solubility at high temperatures (near boiling) is very high (see Solubilities of Inorganic and Organic Compounds by Atherton Seidell). You mention the solution at the bottom was "warm enough to be uncomfortable to the touch", which is probably in the regime of very high solubility, so it is overwhelmingly likely that this is the mechanism.
Stir it (magnetically or otherwise), or try using a smaller thermal gradient, and it should probably be better.
Halocline formation | {
"domain": "physics.stackexchange",
"id": 13440,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "crystals",
"url": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.