text stringlengths 49 10.4k | source dict |
|---|---|
c#, sql, ado.net
public DataView DisplayHealthIndicator(DateTime startDate, DateTime endDate)
{
string queryString = "[marlin].[support_retrieve_workflow_history]";
using (SqlConnection connection = new SqlConnection(GetConnectionString()))
{
using (var cmd = new SqlCommand(queryString, connection))
{
connection.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("date_from", startDate.Date);
cmd.Parameters.AddWithValue("date_to", endDate.Date);
var reader = cmd.ExecuteReader();
var dt = new DataTable();
dt.Load(reader);
connection.Close();
return dt.DefaultView;
}
}
}
}
} I believe it's much better to use some ORM together with LINQ, rather than writing raw SQL. It means more errors are checked at compile time, it will help you avoid some common mistakes and it will make your code much shorter.
I would also always use parametrized SQL queries and never concatenate them by hand. You do use them most of the time, and in the one case where you don't, there is no danger of SQL injection, because the parameter is an integer, but I still think it's better to use parameters everywhere. (I think it may also make your query faster thanks to caching, but I'm not completely sure about that.)
Also, you shouldn't throw Exception, you should create a custom class that inherits from Exception. And, if possible, include the original exception as inner exception, to make debugging the original source of the error easier. | {
"domain": "codereview.stackexchange",
"id": 2192,
"lm_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#, sql, ado.net",
"url": null
} |
ros2, roslaunch
Declare the launch argument, then use the launch argument in a build-path statement to include my parameterized launch file:
launch_desc.add_action( launch.actions.DeclareLaunchArgument('hardware', default_value='hardware') )
launch_desc.add_action( IncludeLaunchDescription(PythonLaunchDescriptionSource([ThisLaunchFileDir(),'/',LaunchConfiguration('hardware'), '.launch.py'])) )
Originally posted by guru_florida with karma: 280 on 2019-12-31
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by relffok on 2020-01-02:
Thanks for your answer. I did know the possibility using an array. Unfortunately I need to access the arguments as a string type because the LaunchConfiguration element can only be read by launch action functions and I want to use them with other functions as well.
I can't believe that this is not possible yet because I feel its a very basic and handy action to use.
Comment by KenYN on 2020-06-04:
It appears that Foxy has had the feature added.
Comment by Yanray47 on 2021-04-07:
Is there a good way to get the argument value? Thank you!
Comment by William on 2022-03-14:
@relffok I know this is an old issue, but someone bumped it from another place, and it might help others for me to clarify. Using a substitution is the only way to access the value of the launch argument. You can't just convert it to a string, as it requires the context to be evaluated. If this is confusing, then you might want to stick with xml based launch files as it is more natural to adhere to this restriction there. The Python API is really meant to help implement the markup based frontends like YAML and XML, and so it is declarative rather than imperative.
Hope this helps, and sorry that it's confusing. Others have proposed a more imperative version of the Python API for launch, but that doesn't exist at the moment. | {
"domain": "robotics.stackexchange",
"id": 34199,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros2, roslaunch",
"url": null
} |
mechanical-engineering
\begin{equation}
\mathcal{F} = PL (\cos(\beta) - \cos(\beta_0)) -
mgL(\sin(\beta) - \sin(\beta_0))
\end{equation}
I believe I have made a mistake in the definition of the position vectors $\mathbf{r}_p$ and/or $\mathbf{r}_{mg}$, but I can't find my mistake. $\vec{g}=(0,-g)$
$\frac{d\vec{r}_{mg}}{d\beta}=L(-\sin\beta, \cos \beta)$.
$\vec{g}.\frac{d\vec{r}_{mg}}{d\beta}=-gL\cos \beta$.
$\mathcal{F}=-W_E= \underline{+} m\int \vec{g}.\frac{d\vec{r}_{mg}}{d\beta} d\beta $ | {
"domain": "engineering.stackexchange",
"id": 5302,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "mechanical-engineering",
"url": null
} |
# Set Difference is Subset
## Theorem
Set difference is a subset of the first set:
$S \setminus T \subseteq S$
## Proof 1
$\displaystyle x \in S \setminus T$ $\leadsto$ $\displaystyle x \in S \land x \notin T$ Definition of Set Difference $\displaystyle$ $\leadsto$ $\displaystyle x \in S$ Rule of Simplification
The result follows from the definition of subset.
$\blacksquare$
## Proof 2
$\displaystyle S \setminus T$ $=$ $\displaystyle S \cap \complement_S \left({T}\right)$ Set Difference as Intersection with Relative Complement $\displaystyle$ $\subseteq$ $\displaystyle S$ Intersection is Subset
$\blacksquare$ | {
"domain": "proofwiki.org",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.982013793196246,
"lm_q1q2_score": 0.8266844029128371,
"lm_q2_score": 0.8418256532040708,
"openwebmath_perplexity": 728.0134181551512,
"openwebmath_score": 0.7593274116516113,
"tags": null,
"url": "https://proofwiki.org/wiki/Set_Difference_is_Subset"
} |
gazebo, urdf, ros-kinetic
Title: Panda falls down in gazebo after spawning
Hello,
I'm following ROS_Control tutorial and adapting all the instructions for panda robot.
I have generated the Gazebo compatible of URDF of panda from Moveot setup assistance and i'm editing it as per the ROS_Control_tutorial. After getting spawned in Gazebo robot falls down on the floor.
Update:-
After creating the fixed joint between world and the base link robot is bolted to the world frame.
but the new problem is now the robot oscillates automatically once it is spawned to gazebo(robot arm moves front and back, then robot arm from link 1 and above falls down on the ground).
I have already tried to adjust the p-i-d controlling gain(initially set them to 0 and then manipulated) but no luck
any suggestions on this??
Below is the URDF file i'm using, I have already tried changing gravity of links and added friction and damping for the joints but no luck.
<?xml version="1.0" ?>
<!-- =================================================================================== -->
<!-- | This document was autogenerated by xacro from /opt/ros/kinetic/share/franka_description/robots/panda_arm_hand.urdf.xacro | -->
<!-- | EDITING THIS FILE BY HAND IS NOT RECOMMENDED | -->
<!-- =================================================================================== -->
<robot name="panda" xmlns:xacro="http://www.ros.org/wiki/xacro"> | {
"domain": "robotics.stackexchange",
"id": 32092,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "gazebo, urdf, ros-kinetic",
"url": null
} |
kobuki
Title: How do I run and control more than one Turtlebot in a single simulation gazebo / Ros
I found no .cpp file or .h. I've tried every way but can not find how to make a smooth and efficient way to each turtlebot own your odometer.
I have lost months trying to edit the xml / launch in several ways but in the end do not get anywhere. And I see that is a very common question.
Please be clear. If not understood my question is: How do I run and control more than one Turtlebot in a single simulation gazebo / Ros.
(Ros hydro)
Originally posted by ThiagoHMBezerra on ROS Answers with karma: 13 on 2015-01-23
Post score: 1
I'm not sure what the real solution is (such that gazebo will directly publish odometry and tf for multiple robots), but I put together a hacky solution which was usable for me. Check out the two launch files in rosh_turtlebot_demo for how to startup gazebo and spawn two robots, and publish_odom.py for publishing odometry and tf.
The key is subscribing to gazebo/model_states and republishing the odom/tf data.
Originally posted by Dan Lazewatsky with karma: 9115 on 2015-01-26
This answer was ACCEPTED on the original site
Post score: 2
Original comments
Comment by ThiagoHMBezerra on 2015-01-27:\
Perfect, really was that I needed. I made some changes to be able to work with my project. Thank you very much.
PS: I will not need it but at some script "r = Rand ()" (I think that's it) is returning error.
Solved! | {
"domain": "robotics.stackexchange",
"id": 20672,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "kobuki",
"url": null
} |
tensorflow, rnn
Title: Training LSTM Recurrent Network in TensorFlow I have trained RNN's before "by hand" using basic tools like Numpy or BLAS, but I am having trouble getting a simple RNN to converge in TF. Full Code
I tried standard things like adjusting the learning rate, the momentum, and adding noise to the gradient, but I am concerned that I don't understand what TF is doing underneath.
In a couple tutorials, it appeared that in TF you train the networks like Echo State Networks where the hidden state is evolved on random interconnections to train up a reservoir, then you use a linear (or non-linear) transformation to map the hidden state onto your labels.
I examined the gradients that Tensorflow uses to train, and it appears that it is training the internal state transition matrices as one would expect if using "Back-Propagation Through Time", which I can't tell if it is trying to use.
Can you help me understand what I am doing/understanding incorrectly with regards to training RNN's in TF?
cell_layer = tf.contrib.rnn.BasicLSTMCell(state_size, state_is_tuple=True)
cell = tf.contrib.rnn.MultiRNNCell([cell_layer]*1)
x, y_ = tf.placeholder(tf.float32, shape=(batch_size,1)), tf.placeholder(tf.float32, shape=(batch_size,1))
outputs, states = tf.nn.dynamic_rnn(cell, tf.expand_dims(x, -1), dtype=tf.float32)# init_state)
W = tf.Variable(tf.random_uniform((state_size, 1), -1.0, 1.0))
b = tf.Variable(tf.random_uniform((1, 1), -1.0, 1.0))
y = tf.matmul(tf.reshape(outputs, (-1, state_size)), W) + b | {
"domain": "datascience.stackexchange",
"id": 1702,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "tensorflow, rnn",
"url": null
} |
ros, ros2, ros-noetic, ubuntu-20.04
Title: Can we install ROS 1 and ROS 2 in the same system running on Ubuntu 20.04? I am using ROS Noetic on my machine running on Ubuntu 20.04. But I want to migrate to ROS 2. Can I install ROS 2 along with ROS 1 on the same machine? If I did, what and how will be the causes? Yes, we can install ROS and ROS 2 in the same system. Just make sure you source the right version of setup.bash:
source /opt/ros/<ros_distro>/setup.bash
Also, make sure to install the correct ROS 2 distro for your ubuntu platform. In your case, that's Foxy Fitzroy (for Ubuntu 20.04).
If you install correctly, everything will be fine since all the relevant packages are installed at different locations.
ROS 1 /opt/ros/noetic/
ROS 2 /opt/ros/foxy/ (EOL May 2023) | {
"domain": "robotics.stackexchange",
"id": 38528,
"lm_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, ros2, ros-noetic, ubuntu-20.04",
"url": null
} |
Is there a way of adding two vectors in polar form without first having to convert them to cartesian or complex form?
• You can do it by solving triangles (more specifically, half the parallellogram of the parallellogram rule can be solved as SAS) if you really want to. But in the general case, converting to Cartesian is the easy way through. (Especially once you move to 3D!) – hmakholm left over Monica Jul 18 '15 at 14:37
• @HenningMakholm I found this question quite interesting, actually, especially when it appeared that (in 2D) it might be more computationally efficient not to use the standard conversion to Cartesian coordinates when adding vectors in polar form. I may want to run some benchmarks on some code I work with. – David K Jul 18 '15 at 16:13
• Essentially no. You will find alternative formulas that look different, but they actually boil down to conversions to and fro, possibly via trigonometric identities. The global computational cost will be similar. Why this question ? – Yves Daoust Jul 18 '15 at 17:02
• I am using polars for sprite movement, and wish to change trajectories with simply adding vectors. I was thinking maybe there was a way to achieve less overhead, by avoiding the conversion to and from. – lash Jul 18 '15 at 17:39
• @YvesDaoust I think what we're discovering (see Henning Makholm's answer, or Dr. MV's) is that indeed you can can add the vectors without converting anything to Cartesian coordinates, not even implicitly. You can do it with just one cosine, a square root, and an arc cosine--where the cosine could be viewed as one Cartesian coordinate in a rotated system, and that's as close as these methods come to doing any Cartesian conversion. Depending on the application, this might be hard for Cartesian conversion to beat even with clever amortization of costs. – David K Jul 19 '15 at 0:29 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9835969698879861,
"lm_q1q2_score": 0.8300526715684259,
"lm_q2_score": 0.8438951084436076,
"openwebmath_perplexity": 370.69903438309274,
"openwebmath_score": 0.9871770739555359,
"tags": null,
"url": "https://math.stackexchange.com/questions/1365622/adding-two-polar-vectors"
} |
beginner, ruby, numerical-methods
It's pretty long for a Ruby method, but some of the methods in the other implementation seemed too specific to keep around in the global scope (and the Array mixin also seemed a little heavy-handed).
Edit: as @jQweirdy mentioned in the comments, this could also be solved with a class, but I was hesitant to add a class just for one method. But there are a few things here, that might be generically useful for Polynomial class. So here's an example:
class Polynomial
attr_reader :coefficients
def initialize(*coefficients)
@coefficients = coefficients
end
def evaluate(x)
coefficients.zip(ordinals).reduce(0) do |sum, (n, i)|
sum += n * x ** i
end
end
def derivative
@derivative ||= begin
derivatives = coefficients.zip(ordinals)[0...-1].map { |n, i| n * i }
self.class.new(*derivatives)
end
end
def order
coefficients.count - 1
end
def ordinals
(0..order).to_a.reverse
end
def newton_raphson_approximation(iterations = 1, initial = -1)
iterations.times.reduce(initial) do |x, _|
x -= evaluate(x).fdiv(derivative.evaluate(x))
end
end
end | {
"domain": "codereview.stackexchange",
"id": 17010,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "beginner, ruby, numerical-methods",
"url": null
} |
# Power Series Representation of Functions, Taylor Series
I'm having some issues trying to understand Taylor Series, Power Series as a representation of a Function, integrate of a Power Series and how it all works (or should work) together. I have a question example where I can't understand how to proceed. Here it is:
Consider the function $f(x) = \sum_{k=1}^\infty \frac{(-1)^k(k+1)}{5^kk!}(x-3)^k$ to any value of x.
1. Find the Taylor Serie of $\int f(x)dx$ at $x = 3$
-- It is given a power series, how am I supposed to integrate it and evaluate at x = 3? Don't you need the function this series is represanting to evaluate it and find the taylor series? How do I even integrate this series?
2. Write $I = \int_0^3f(x)dx$ as a sum of a numerical serie.
-- This one I almost have no idea what it is referring to. Is it the same integral as the first part but evaluated inside 0 and 3?
Thanks to all.
• Perhaps your textbook has a result about "integrate term-by-term" for a power series. – GEdgar Jan 10 '18 at 1:38
• I strongly suspect that your text, probably in the same section as this problem, has the result that $\int \sum a_nx^n dx= \sum \int a_n x^n dx= \sum\frac{1}{n+1}a_nx^{n+1}$. – user247327 Jan 10 '18 at 1:42
Someone else can give a more detailed answer. Here's a quick explanation
1. The Taylor series around the point $x=3$ does not mean evaluating the function at $x=3$, but rather a local approximation for $f(x)$ for values of $x$ that are close to $3$. This is a function of $x$, not a single number. What the question is asking, in simpler terms: | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9481545304202038,
"lm_q1q2_score": 0.8203661320765322,
"lm_q2_score": 0.8652240808393984,
"openwebmath_perplexity": 130.4963096228428,
"openwebmath_score": 0.9533476829528809,
"tags": null,
"url": "https://math.stackexchange.com/questions/2599062/power-series-representation-of-functions-taylor-series"
} |
# Getting everyone to meet everyone else
There are 25 students in a class who sit in five rows of five. Each week they sit in a different order.
After a number of weeks every student has sat next to every other student, next meaning side by side, one behind the other, or sitting diagonally together. What is the fewest number of weeks in which this can happen?
The case for 16 students sitting in four rows of four has been dealt with at:
https://puzzling.stackexchange.com/questions/83720/my-sixteen-friendly-students?noredirect=1#comment243063_83720
• What are your thoughts on the problem? – Servaes May 8 '19 at 12:58
• @Servaes: Far more difficult than it seems! – Bernardo Recamán Santos May 8 '19 at 13:02
• Each student must sit together with $24$ other students, so $\tfrac{24\times25}{2}=300$ pairs must be made. Each day a total of $$\frac{8\times9+3\times4+5\times12}{2}=72,$$ pairs are made, which shows that we will need at least $5$ weeks for every student to have sat next to every other student. In $5$ weeks a total of $5\times72=360$ pairs are made, so this gives quite a bit of leeway to make the necessary $300$ pairs. A bit of trial and error would go a long way? Perhaps some affine transformations will do the trick? – Servaes May 8 '19 at 13:03
• @Servaes Why did you delete your answer? I checked your solution, it worked! – Mike Earnest May 9 '19 at 1:14
• @MikeEarnest Ha! It was late last night, I was tinkering with it a bit more in an attempt to get it down to six weeks (to no avail), and then reverted to the wrong configuration, apparently, so I believed I made a mistake. Thanks for checking :) I'll recheck it for myself as well later today. – Servaes May 9 '19 at 11:21
It can be done in 5 weeks: | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9845754497285467,
"lm_q1q2_score": 0.8072468477700204,
"lm_q2_score": 0.8198933337131077,
"openwebmath_perplexity": 72.95437766835308,
"openwebmath_score": 0.2769103944301605,
"tags": null,
"url": "https://math.stackexchange.com/questions/3218384/getting-everyone-to-meet-everyone-else/3218950"
} |
homework-and-exercises, supersymmetry, quantum-gravity, cpt-symmetry
Title: Decomposing the $\mathcal{N} = 4$ massless graviton supermultiplet I'm trying to solve the following exercise:
Construct the physical states of the $\mathcal{N} = 4$ massless graviton supermultiplet, starting from a Clifford vacuum of helicity $λ_0 = 0$.
Decompose the $\mathcal{N} = 4$ massless graviton supermultiplet into a direct sum of
$\mathcal{N} = 1$ massless supermultiplets: how many $\mathcal{N} = 1$ graviton, gravitino, vector and chiral multiplets does the $\mathcal{N} = 4$ graviton multiplet
contain? | {
"domain": "physics.stackexchange",
"id": 66719,
"lm_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, supersymmetry, quantum-gravity, cpt-symmetry",
"url": null
} |
image-processing, matlab, computer-vision, object-recognition, 3d
Title: 3d CT segmentation It's my first attempt at 3D analysis.
I am trying to segment a 3D CT data.
My case study is very simple: trying to segment circular objects in my data.
Do you have any suggestions on how to achieve the 3 steps:
1. First of all I would like to visualize my data in 3D
2. Then segment by value, e.g. all voxels whose value is between 800 and 1200 and visualize it
3. Than find shape properties in 3D
The way I visualize the data now is :
id = find ( D < 1200 & D > 800);
[ x , y , z ] = ind2sub( id , size(D) ) ;
plot3(x,y,z,'.')
Do you have suggestions for a better way?
I heard about the isosurface functions but don't know how to use it for this.
Thanks. Mathematica 9 features completely integrated Image3D objects. Visualization is cool and snappy (as expected), and many segmentation functions accept 3D images (Binarize, ChanVeseBinarize, ClusteringComponents, MorphologicalComponents, etc.).
As for measuring properties, ComponentMeasurements would be the function to go to; but as of version 9 it does not accept 3D images. So while waiting for the future version, you are on your own with your point 3. It's not always complicated, for example below I compute the centroid of the segmented shapes: | {
"domain": "dsp.stackexchange",
"id": 1034,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "image-processing, matlab, computer-vision, object-recognition, 3d",
"url": null
} |
I think we can always get $$n$$ for any abelian group by finding the invariant factors.
According to GAP, the group is $$\Bbb Z_{180}\times \Bbb Z_{30}$$ and, of course, not cyclic.
gap> G:=DirectProduct(CyclicGroup(6) , DirectProduct(CyclicGroup(20), CyclicGroup(45)));
<pc group of size 5400 with 8 generators>
gap> StructureDescription(G);
"C180 x C30"
gap> IsCyclic(G);
false
gap> | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9863631651194372,
"lm_q1q2_score": 0.8534251646282537,
"lm_q2_score": 0.8652240825770432,
"openwebmath_perplexity": 202.56521248017205,
"openwebmath_score": 0.8640196919441223,
"tags": null,
"url": "https://math.stackexchange.com/questions/3198820/find-the-smallest-n-in-mathbbn-such-that-the-group-is-isomorphic-to-the-di"
} |
homework-and-exercises, quantum-field-theory, fermions, anticommutator, hilbert-space
which is the final result.
A motivation for doing this kind of manipulation could be, for example, to order each term in such a way that the destruction operators are on the right side.
In this particular case one obtain
$$a_j a_i a_k^+ a_l^+ = a_k^+ a_l^+ a_j a_i - \delta_{jl} a_k^+ a_i + \delta_{il} a_k^+ a_j + \delta_{jk} a_l^+ a_i - \delta_{ik}a_l^+ a_j +\delta_{ik}\delta_{jl} - \delta_{jk}\delta_{il}$$
This is called "normal order". Note that, when the operator acts on the vacuum state, only the last two addenda survives. | {
"domain": "physics.stackexchange",
"id": 21269,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "homework-and-exercises, quantum-field-theory, fermions, anticommutator, hilbert-space",
"url": null
} |
organic-chemistry, experimental-chemistry, purification
On larger scales, chromatography becomes challenging and time consuming. Carefully designed work ups, crystallisations, and precipitations can give pure material with incredibly low ppm values of residual metal.
The key question is always whether the material is clean enough for the next step. Often, the easiest and most efficient option is to filter through Celite, evaporate, and carry on as it only really matters whether your final step is clean (for example if you do a Buchwald and a subsequent Boc deprotection, it can be significantly easier to clean the material up after the second step wheee you can make use of a strongly basic centre). | {
"domain": "chemistry.stackexchange",
"id": 15703,
"lm_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, experimental-chemistry, purification",
"url": null
} |
quantum-mechanics, hilbert-space, quantum-information, quantum-entanglement, quantum-states
Title: Two states have the same Schmidt coefficients across every bipartition. Can they be mapped to each other by a product of single-site unitaries? I have two states, $|\psi\rangle$ and $|\phi\rangle$. I have in mind that they live on a length $L$ spin chain with finite local Hilbert space dimension.
I know that for every Schmidt decomposition bipartitioning the system into a region $A$ and a region $B$, the following is true:
$$|\psi\rangle = \sum_{i=1}^n \lambda_i|a_i\rangle|b_i\rangle $$
$$|\phi\rangle = \sum_{i=1}^n \lambda_i|a'_i\rangle|b'_i\rangle $$
That is, while the states are not necessarily equal, their Schmidt coefficients are equal across every cut in physical space. The Schmidt coefficients may depend on the choice of cut. I imagine that all of my cuts are in physical space, but I do allow regions $A$ and $B$ to contain sites that are not contiguous; for example, $A$ could contain all even sites and $B$ can contain all odd sites.
Given this, am I guaranteed that there exists a unitary that is a tensor product of single-site unitaries, $U = \otimes_{i=1}^L U_i$, such that $ U|\psi\rangle = |\phi\rangle$? | {
"domain": "physics.stackexchange",
"id": 98998,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-mechanics, hilbert-space, quantum-information, quantum-entanglement, quantum-states",
"url": null
} |
optimization, algorithm, c, mergesort
I have 2 questions:
How can I make this implementation more optimal (best possible performance)?
When handling arrays of large lengths (1000000), what causes a segmentation fault?
NOTE: I tried the function using array randomly generated of length 1000 and it worked.
Suspect that segmentation fault on large arrays occurs because the list1[] and list2[] ran out of space. With the recursive calls, code is heavily using the stack space. Use malloc() and free() for large arrays instead of VLA[]
Memory allocation could be reduced. Via recursion, this takes > 2n (maybe 4n) memory space. At worst it should be 2n.
Use size_t rather than int for a integer type that can handle all array indexes.
// void mergesort (int* list, int len)
void mergesort (int* list, size_t len)
Cope with 0 length.
// if(len == 1) return;
if(len <= 1) return; | {
"domain": "codereview.stackexchange",
"id": 11674,
"lm_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, algorithm, c, mergesort",
"url": null
} |
electrostatics, electric-fields, potential, gauss-law
It's straightforward to show that $\Phi_{x=-a} =- \Phi_{x=a}$ and $\Phi_{z=-d} =- \Phi_{z=d}$. Hence:
$$\Phi_{y = b} + \Phi_{y = c} = 0.$$
I am going to talk in a coordinate system with a vertical $y$-axis.
If the sum of the fluxes through the sides of the cube (through faces $x=a,x=-a,z=d,z=-d$) is zero, then it should follow that the sum of the flux through the top and bottom of the cube ($y=b,y=c$) should also be zero.
However, it is not the case that the total flux through the sides is zero. At all points on the side of the cube, the electric field is pointing outwards, not inwards. Therefore the total flux must be positive. This means that the sum of the fluxes through the top and bottom of the cube can be negative to make the total flux zero.
That is to say that $\Phi_{y = b} + \Phi_{y = c} < 0$ so $\eta(s)$ is not constant.
Furthermore, say we didn't know that the flux out the sides was positive, it will still be clear that the sum of the flux of the top and bottom surfaces is not zero: the area of the top and bottom faces is the same since it is a cube, but the electric field decays with distance from the charge at the origin so it is less at the top $y=c$ surface than it is at the bottom $y=d$ surface. Therefore the flux flowing in at the bottom is greater than the flux flowing out at the top, hence their sum is negative, not zero.
Here is a diagram of the situation. The red arrows are roughly what the electric field looks like at each of the corners of the cube (note that they are not to scale though - I drew them myself). | {
"domain": "physics.stackexchange",
"id": 67380,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "electrostatics, electric-fields, potential, gauss-law",
"url": null
} |
slam, navigation, ros-kinetic, rtabmap, pointcloud
A screenshot of the problems:
Note the y error on left with superposed left and right images. On right the grid is 1 meter, frustums of both cameras are shown for reference (looking upward as there is no optical rotation).
EDIT2:
When I tested the bag, I didn't see problem with the number of disparities. See doc of StereoBM. Note that the number of disparities will create a border without disparity values of the same size on the left of the image. On images of 200 pixels width and StereoBM/NumDisparities set to 128, you will have more than half of the image without disparity values. This can create empty clouds if no disparity can be computed for the other half. Thus number of disparities should be lowered for small images. Last note, if you are trying to map a white wall (textureless surface), disparity will be null, causing also an empty cloud. The recent code should not add to PCL visualizer an empty cloud, so the pcl error would not appear anymore.
Originally posted by matlabbe with karma: 6409 on 2018-03-14
This answer was ACCEPTED on the original site
Post score: 2 | {
"domain": "robotics.stackexchange",
"id": 30315,
"lm_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, ros-kinetic, rtabmap, pointcloud",
"url": null
} |
electromagnetic-radiation, visible-light, photons
Title: What do photons look like? We have many theories that advocate the particle nature of light. But have we ever observed photons physically?
If so: what do they look like? How big are they?
If not: why not? Is it because they move at the speed of light? "We have many theories that advocate the particle nature of light". Let me first re-word that statement to make it more accurate:
We have a wide-ranging and mathematically elegant framework called quantum mechanics, and when applied to electromagnetic phenomena it yields the photon model.
"But have we ever observed photons physically? What do they look like?"
The answer to this is that every observation involving light or other electromagnetic radiation is correctly treated by the photon model. But some observations could also be handled by other models such as classical electromagnetism. So to ask your question more precisely, it could be phrased "which observations support the photon model above other possible models?" We have to ask it this way because we observe pretty much everything by observing its effects. Even when you touch a hard surface with your finger, what you sense is the effect of the surface on your finger. And when you see something, what you sense is the response of the light receptors in your eye.
An example of an effect which strongly suggests the photon model is the photoelectric effect. Here the behaviour of the electrons in a metal in response to light is hard to make sense of using other models, but the photon model makes sense of it quite readily. So in this kind of experiment one is observing the effects of photons. And, as I just remarked, observing the effects is all one can ever hope for.
There is a kind of light detector called photomultiplier tube which uses the photo-electric effect, and when you shine light on the detector, what is observed is a series of short electrical pulses, rather than a continuous current. This indicates the energy is arriving at the detector in short pulses---in other words, photons. More sophisticated experiments using atoms have been used to map out the spatial distribution of a light field in great detail. In these experiments, one is detecting the shape of the region of space occupied by the photons. | {
"domain": "physics.stackexchange",
"id": 82834,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "electromagnetic-radiation, visible-light, photons",
"url": null
} |
javascript, beginner, html, css, dom
.r134,
r134 a {
color: #FF8000
}
.b134,
.b134 a {
background-color: #FF8000
}
.r135,
r135 a {
color: #EE7600
}
.b135,
.b135 a {
background-color: #EE7600
}
.r136,
r136 a {
color: #EE6A50
}
.b136,
.b136 a {
background-color: #EE6A50
}
.r137,
r137 a {
color: #EE5C42
}
.b137,
.b137 a {
background-color: #EE5C42
}
.r138,
r138 a {
color: #FF6347
}
.b138,
.b138 a {
background-color: #FF6347
}
.r139,
r139 a {
color: #FF6103
}
.b139,
.b139 a {
background-color: #FF6103
}
.r140,
r140 a {
color: #32CD32
}
.b140,
.b140 a {
background-color: #32CD32
}
.r141,
r141 a {
color: #00C957
}
.b141,
.b141 a {
background-color: #00C957
}
.r142,
r142 a {
color: #43CD80
}
.b142,
.b142 a {
background-color: #43CD80
}
.r143,
r143 a {
color: #00C78C
}
.b143,
.b143 a {
background-color: #00C78C
}
.r144,
r144 a {
color: #1ABC9C
}
.b144,
.b144 a {
background-color: #1ABC9C
}
.r145,
r145 a {
color: #20B2AA
}
.b145,
.b145 a {
background-color: #20B2AA
}
.r146,
r146 a {
color: #03A89E
}
.b146,
.b146 a {
background-color: #03A89E
}
.r147,
r147 a {
color: #00C5CD
} | {
"domain": "codereview.stackexchange",
"id": 33871,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "javascript, beginner, html, css, dom",
"url": null
} |
quantum-gate, quantum-state, entanglement, information-theory, entropy
$$
U=\sum_{j=1}^rR_j\otimes S_j\tag6
$$
for some single-qubit operators $R_j$ and $S_j$ acting on a qubit in partition $A$ and $B$, respectively and orthogonal with respect to Hilbert-Schmidt inner product (see e.g. $6.4.2$ in Nielsen's PhD thesis or this paper for more details on operator variant of Schmidt decomposition). Then $U|\phi\rangle$ may be written as
$$
\begin{align}
|\phi'\rangle=U|\phi\rangle&=\sum_{i=1}^m\sum_{j=1}^r\lambda_iR_j|i\rangle S_j|i'\rangle \\
&= \sum_{k=1}^{mr}\mu_k|k''\rangle|k'''\rangle
\end{align}\tag7
$$
so$^1$ $|\phi'\rangle$ has Schmidt rank at most $mr$.
Now, $R_j$ and $S_j$ belong to the complex vector space of operators on $\mathbb{C}^2$ which is four dimensional. Therefore, for a two-qubit gate $r\le 4$. We conclude that a two qubit gate can increase the log Schmidt rank by at most two.
Linear bound on von Neumann entropy
Therefore, by $(5)$ the final von Neumann entropy $S_f$ of entanglement between the two partitions after running a circuit with $Md$ cross-partition two-qubit gates can be bounded above as
$$
S_f\le 2Md.\tag8
$$
Even though $(8)$ is not as tight as $Md$, it is still asymptotically linear. | {
"domain": "quantumcomputing.stackexchange",
"id": 3347,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-gate, quantum-state, entanglement, information-theory, entropy",
"url": null
} |
expansion
Title: How do we know the expansion of the universe is not centered around our position? It is my understanding that the red shift of galaxies in whatever direction we look shows the universe is expanding in every direction around us. That could be explained in two ways:
A (accepted): The universe is expanding in every point, like the stretched surface of a balloon, and therefore it's expansion looks the same whatever is your position as an observer.
B (unlikely): Earth is somehow at the center of the universe, who is expanding from this point.
I am not contesting A, but I am curious about how B was discarded although we only ever have been able to observe the universe from Earth or it's vicinity for a (astronomicaly speaking) brief period of time (and therefore a relatively small portion of space even though our solar system and galaxy, etc are also moving). Is there some positive reason to think we are not at the center of the universe, or is it more of a "it would be very unlikely that we just happen to be at the center of the expansion" type of reasoning? Things are observed to recede with velocity $\vec v$ proportional to their separation $\vec x$ from us,
$$\vec v=H\vec x,\tag{1}\label{1}$$
where $H$ is a constant (the Hubble rate).
This relationship is special, because consider an observer at the position $\vec x^\prime$ elsewhere in the Universe. Equation \eqref{1} implies that their velocity relative to us is $\vec v^\prime=H\vec x^\prime$. Hence, from their perspective, an object at separation $\vec x-\vec x^\prime$ from them ($\vec x$ from us) recedes with velocity
$$\vec v-\vec v^\prime = H\vec x-H\vec x^\prime=H(\vec x-\vec x^\prime)\tag{2}\label{2}$$
from them. By comparing equations \eqref{1} and \eqref{2}, it is evident that they see the exact same cosmic expansion as we do! | {
"domain": "astronomy.stackexchange",
"id": 6888,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "expansion",
"url": null
} |
fasta, bed, file-formats, format-conversion
Title: How to convert FASTA to BED I have a FASTA file:
> Sequence_1
GCAATGCAAGGAAGTGATGGCGGAAATAGCGTTAGATGTATGTGTAGCGGTCCC...
> Sequence_2
GCAATGCAAGGAAGTGATGGCGGAAATAGCGTTAGATGTATGTGTAGCGGTCCC....
....
I want to generate a BED file for each sequence like:
Sequence_1 0 1500
Sequence_2 0 1700
The BED regions will simply be the size of the sequences.
Q: I did that before with a one-line command. I don't remember what that is, it was on Biostars. I can't find the post now. What's the simplest way to do the conversion? We have many excellent answers! This will be an excellent reference for future users.
I found what exactly what I was asking in my question:
https://www.biostars.org/p/191052/
$ pip install pyfaidx
$ faidx --transform bed test.fasta > test.bed
This is the one-line command I was asking. The other answers also work, but I want to accept my own answer. | {
"domain": "bioinformatics.stackexchange",
"id": 11,
"lm_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, bed, file-formats, format-conversion",
"url": null
} |
performance, c, compression
struct bio {
enum bio_mode mode;
...
};
Compilers can use this information, for example if you write a switch (mode) {...} statement and you forget to handle all possible modes, the compiler will warn about this.
Also change functions that take int mode as a parameter to enum bio_mode mode.
Use standard types where possible
Use the standard fixed width integer types from <stdint.h> instead of inventing your own names. So instead of uint32, use uint32_t, and instead of uchar, use uint8_t.
There is no need to assert() that the size of uint32_t is 32 bits.
Reorder struct bio to be more compact
On most 64-bit architectures, the layout of struct bio is suboptimal, because pointers and size_t have a 64-bit alignment, while ints have 32-bit alignment. I suggest the following:
struct bio {
enum bio_mode mode;
uint32_t b;
uint8_t *ptr;
size_t c;
};
Make ptr uint32_t *
Since you are casting ptr to uint32_t * in many places, it makes more sense to store it directly as that type, and only cast it once in bio_open(). I also recommend you take a void * in bio_open(), so there is no need for the caller to do any casting.
struct bio {
enum bio_mode mode;
uint32_t b;
uint32_t *ptr;
size_t c;
};
static void bio_open(struct bio *bio, void *ptr, int mode)
{
...
bio->ptr = ptr;
...
} | {
"domain": "codereview.stackexchange",
"id": 37346,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "performance, c, compression",
"url": null
} |
The set of solutions to a nonhomogeneous linear differential equation form an affine space. (The underlying vector space is the set of solutions to the associated homogeneous equation.)
• True, but this perfectly covered by teaching affine subspaces of vector spaces: here the set of solution is an affine subspace of the vector space of $C^k$ functions where $k$ is the order of the equation. I would not confuse the direction of an affine subspace and the "underlying" vector space that "naturally" contains the affine space being considered. – Benoît Kloeckner Apr 3 '15 at 7:58
• The space of $C^k$ functions is so large as to be practically useless for intuition in this situation. – Alexander Woo Apr 3 '15 at 18:20
• I have barely seen any geometrical intuition related to the affine structure of the set of solutions of linear differential equations. It seems more about the algebraic aspects of it, and then the addition and scalar multiplication in $C^k$ are pretty clear. And again, I agree that the direction (aka set of solution of the associated homogenous equation) is of prime importance, but this example stills perfectly fits into the "affine subspaces of vector spaces" point of view. – Benoît Kloeckner Apr 3 '15 at 21:02
In a vector space, you have an origin, addition of vectors, and scalar multiplication. Using a vector space structure to study something conveys the impression that the origin, addition, and scalar multiplication are actually meaningful things about the object of study.
But sometimes that simply isn't true. And when it isn't, it's handy to have a way to apply linear algebra without giving the misleading impression that certain things are meaningful when they are not.
"Forgetting" information is actually a pretty important thing in mathematics. For example, the whole field of differential geometry got started as a way to study what properties of a shape were intrinsic to a shape, and what properties were accidents of how they were drawn in Euclidean space. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9780517450056273,
"lm_q1q2_score": 0.8085669107196771,
"lm_q2_score": 0.8267117919359419,
"openwebmath_perplexity": 404.33049534723756,
"openwebmath_score": 0.7455641031265259,
"tags": null,
"url": "https://matheducators.stackexchange.com/questions/7778/should-we-teach-abstract-affine-spaces"
} |
ros-kinetic
Original comments
Comment by pnambiar on 2018-02-16:
Thanks for the response. It is infact RGB images from monocular camera (1920 X 1080) and we are using a NVIDIA jetson TX2 as the master. We are currently doing some processing onboard and would like to publish the output images at about 6- 15 fps using a wireless network. Is that doable?
Comment by gvdhoorn on 2018-02-16:
Well, the calculation is as follows: (1920x1080)x4x6~=47.5MB/s. For 15 fps it would be approx 118MB/s. That is just the bandwidth for the image stream, not including any messaging / protocol or API overhead. Remember that sensor_msgs/Image is in essence a raw, 32bit, uncompressed frame.
Comment by pnambiar on 2018-02-16:
max data rate of 54 mbps is what we have for this wireless access point (https://dl.ubnt.com/datasheets/picostationm/picom2hp_DS.pdf). So compressing the image and reducing the rate are the two options available I guess?
Comment by gvdhoorn on 2018-02-16:
I believe so. 54mbs is 5.4MB/s in the absolute best case and only one way (simplex). You could take a look at image_proc/resize and some of the image transport options (like theora, or imagezero_transport).
Comment by pnambiar on 2018-02-16:
Thanks for the suggestions. I will definitely take a look at it.
Comment by pnambiar on 2018-02-21:
@gvdhoorn I have everything working with image transport theora. Now, the bottle neck is compression. For a stream of 640 X 480, frame rate reduces to 20fps from 30fps on a Nvidia Jetson TX2
For high res imagery (1920 X 1080) it reduces to 3fps from 30fps. Are there better compression packages?
Comment by gvdhoorn on 2018-02-21:
Did you try the imagezero_transport? CPU usage should be much lower - but compression ratios are also probably not as good as theora. | {
"domain": "robotics.stackexchange",
"id": 30054,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros-kinetic",
"url": null
} |
image-processing, python, opencv, homography
Title: OpenCV warpPerspective implementation I've implemented the least squares method to find the homomorphic image to fix the rotation and projection in an image.
Now I'm trying to implement the OpenCV warpPerspective method in order to "fix" my image, my python implementation is like:
def fix_image(img, t):
new_image_map = {}
minx, miny = img.shape[0], img.shape[1]
maxx, maxy = 0, 0
for i in range(img.shape[0]):
for j in range(img.shape[1]):
xy = np.array([i, j, 1], np.float64)
uv = np.matmul(t, xy)
uv = uv / uv[2]
minx = min(minx, uv[0])
maxx = max(maxx, uv[0])
miny = min(miny, uv[1])
maxy = max(maxy, uv[1])
new_image_map[int(uv[0]), int(uv[1])] = (i, j)
minx, miny = int(minx), int(miny)
maxx, maxy = int(maxx), int(maxy)
final_img = np.zeros((maxx - minx + 1, maxy - miny + 1)) \
if len(img.shape) == 2 else np.zeros((maxx - minx + 1, maxy - miny + 1, img.shape[2]))
for k, v in new_image_map.items():
final_img[k[0] - minx, k[1] - miny] = img[v]
return final_img
I know that I still need to interpolate the empty points but the problem is that the shape is not right, I'm checking the results by comparing with the actual OpenCV implementation.
dst = cv2.warpPerspective(storm_img, tr, (1448, 1456)) | {
"domain": "dsp.stackexchange",
"id": 12504,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "image-processing, python, opencv, homography",
"url": null
} |
c, linked-list
struct list_node * list_createnode (unsigned int size);
void list_setnode (struct list_node *, void * data, unsigned int size);
struct list_node * list_get (struct list_node *, int offset);
struct list_node * list_getfront (struct list_node *);
struct list_node * list_getback (struct list_node *);
struct list_node * list_putbefore (struct list_node *, unsigned int size);
struct list_node * list_putafter (struct list_node *, unsigned int size);
struct list_node * list_splitbefore (struct list_node *);
struct list_node * list_splitafter (struct list_node *);
struct list_node * list_freeforwards (struct list_node *);
void list_freebackwards (struct list_node *);
void list_free (struct list_node *);
void list_remove (struct list_node *);
unsigned int list_size (struct list_node *);
unsigned int list_countbackwards (struct list_node *);
unsigned int list_countforwards (struct list_node *);
// returns the node at which the traversal stopped (may be null)
struct list_node * list_traverse (struct list_node *, int (*callback)(void *));
struct list_node * list_traversebackwards (struct list_node *, int (*callback)(void *));
struct list_node * list_traverseforwards (struct list_node *, int (*callback)(void *)); | {
"domain": "codereview.stackexchange",
"id": 4062,
"lm_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
} |
rosinstall
Originally posted by Mohammedism with karma: 32 on 2018-01-13
This answer was ACCEPTED on the original site
Post score: 1 | {
"domain": "robotics.stackexchange",
"id": 29740,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "rosinstall",
"url": null
} |
java, mysql
public void executeUpdate(String query) {
try {
Statement statement = connection.createStatement();
statement.executeUpdate(query);
} catch (SQLException e) {
e.printStackTrace();
}
}
public boolean execute(String query) {
boolean result = false;
try {
Statement statement = connection.createStatement();
result = statement.execute(query);
} catch (SQLException e) {
e.printStackTrace();
}
return result;
}
public ResultSet executeQuery(String query) {
ResultSet result = null;
try {
Statement statement = connection.createStatement();
result = statement.executeQuery(query);
} catch (SQLException e) {
e.printStackTrace();
}
return result;
}
public void disconnect() {
try {
if (connection != null) {
connection.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
} Code Smells
Remember the DRY and KISS principles of programming.
Here are some other resources with good info on general programming principles.
3 Key Software Principles You Must Understand
The Principles of Good Programming
As a maintainer or reviewer of anyone's code (our own or someone elses), when examining code we look for code smells. These give general indications of programming practices which are less than ideal. When we find code smells, it's a good clue that we need to look more closely and consider why the code smells.
There are a few obvious code smells, mostly pointed out by others already:
Ambiguous Naming Convention
Re-purposing Existing Names
Repetitive Code Patterns
Improper Use of Exceptions
Failure to Release Resources
Lack of Comments | {
"domain": "codereview.stackexchange",
"id": 12367,
"lm_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, mysql",
"url": null
} |
forces, work, definition, power, calculus
But I wanted a proper proof not involving differentials! The work $W$ is not equal to $F\cdot x$ generally. The correct form is
$$W=\int F \cdot dx$$
So $dW=F\cdot dx$ and $P=\dfrac{dW}{dt}=F\cdot\dfrac{dx}{dt}=F\cdot v$ | {
"domain": "physics.stackexchange",
"id": 41811,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "forces, work, definition, power, calculus",
"url": null
} |
algorithms, decision-problem
Title: Do all algorithms aim to solve decision problems? An algorithm is a “unambiguous specification of how to solve a class of problems... calculation, data processing and automated reasoning tasks” Are the class of problems an algorithm can solve more abstractly considered decision problems? Is the ultimate reason for a calculation, data processing or automated reasoning to solve a higher decision problem?
Thank you and forgive my ignorance. There is a class of problems called decision problems that have an yes/no answer. These problems can be further be classified in decidable, where we have a way to solve them, or undecidable, for which there cannot be or has not been yet discovered a way to solve them.
However, there is another set of problems where we are not interested in a yes/no answer, but rather in a more specific solution. For example, there are optimisation problems, where we are searching for the best value according to some parameters, or counting problems, where we are interested in counting the number of instances where certain property occurs.
To sum it up, decision problems are a specific class of problems, a subset of which can be solved by algorithms. However, algorithms can be used to solve problems in other classes.
Now, given an algorithm for a specific problem, one can solve multiple problems equivalent to the original one (there are ways of "translating" a problem in the terms of another one, and having a solution to one problem means having a solution for all such problems). | {
"domain": "cs.stackexchange",
"id": 10511,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "algorithms, decision-problem",
"url": null
} |
slam, navigation, kinect, rviz, hector-slam
Originally posted by Stefan Kohlbrecher with karma: 24361 on 2012-05-13
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by DanielAkaAhboon on 2012-05-14:
Thanks for the advice. Previously I tried using the RGB-D-SLAM, however the CPU requirements is too high for the PC104 that is given by the school for this project.Will an IMU stablize the mapping so that it would not drift out too much?
Comment by Stefan Kohlbrecher on 2012-05-15:
Low cost MEMS accelerometers are very noisy and of not much use for estimating translational velocities or positions, so there's not immediate, easy gain to get from them. How large is your scenario and how many features does it have?
Comment by DanielAkaAhboon on 2012-05-16:
Sorry, as a beginner, I don't really get what you meant by scenario and features.. If you are referring to the area that I'm suppose to map, it is a classroom. As for the IMU I'm given CH Robotics UM6 IMU.
Comment by Stefan Kohlbrecher on 2012-05-17:
I meant the general shape and size of the scenario you´re looking at, as well as the amount of unique features (corners, furniture etc. as opposed to just a blank wall) that appears in the Kinect data. For your combination of hardware the problem is very challenging though.
Comment by Andreluizfc on 2018-01-04:
@Stefan I want to do the Mapping with the R200 camera. Do you think that should be good for Hector_mapping? Or should I use GMapping?
Comment by Stefan Kohlbrecher on 2018-01-05:
I think gmapping or cartographer will be better suited for the R200 (for the "fake 2D LIDAR" approach, using Visual SLAM methods would be another option). | {
"domain": "robotics.stackexchange",
"id": 9378,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "slam, navigation, kinect, rviz, hector-slam",
"url": null
} |
optimization, scala, project-euler, fibonacci-sequence
Title: Better way of calculating Project Euler #2 (Fibonacci sequence)
Even Fibonacci numbers
Problem 2
Each new term in the Fibonacci sequence is generated by adding the
previous two terms. By starting with 1 and 2, the first 10 terms will
be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not
exceed four million, find the sum of the even-valued terms.
object Problem_2 extends App {
def fibLoop():Long =
{
var x = 1L
var y = 2L
var sum = 0L
var swap = 0L
while (x < 4000000)
{
if (x % 2 ==0) sum += x
swap = x
x = y
y = swap + x
}
sum
}
def fib:Int = {
lazy val fs: Stream[Int] = 0 #:: 1 #:: fs.zip(fs.tail).map(p => p._1 + p._2)
fs.view.takeWhile(_ <= 4000000).filter(_ % 2 == 0).sum
}
val t1 = System.nanoTime()
val res = fibLoop
val t2 = (System.nanoTime() - t1 )/1000
println(s"The result is: $res time taken $t2 ms ")
}
Is there a more functional way of calculating the Fibonacci sequence and taking the sum of the even values below 4 million?
Is the imperative method 1000x faster? No iteration is required to calculate this result.
Every third Fibonacci number is even. The Fibonacci numbers can be expressed in closed form as:
Fib(n) = 1/sqrt(5) * (phi^n - psi'^n)
where
phi = (1 + sqrt(5) / 2)
and
psi = (1 - sqrt(5) / 2) | {
"domain": "codereview.stackexchange",
"id": 4881,
"lm_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, scala, project-euler, fibonacci-sequence",
"url": null
} |
c++, c++11, game
Title: A Simple Console Based Keno/Lottery Game in C++ Earlier this week I provided this answer to the Original Poster of the question. Since I've already shown that I am not a C++ Guru, I have made the changes I suggested and I'm posting them for review. My question is what alternative Standard Template Library constructs I could have used to implement this. In case you aren't aware, copying is a major form of flattery.
The Basics of the game are:
The user creates a balance of credits to play the game.
Per game round the user enters a bet.
The user then has the choice of either picking between 5 and 10
numbers between 1 and 60 or allowing the computer to pick between 5
and 10 numbers between 1 and 60.
Each game round is scored based on the number of picks and the number
of matches of those picks. Winnings are applied to the balance, bets
reduce the balance.
A zero balance prevents game play and allows the user to add credits.
The goals I had when writing this alternate solution are:
Break the one file solution into multiple header and source files to
provide better object oriented programming and reuse.
Replace all C programming language constructs with C++ programming.
Improve the readability and maintainability of the code.
Follow the Single Responsibility Principle.
Follow the DRY programming Principle.
Follow the KISS principle.
Reduce the number of lines of code in the solution. | {
"domain": "codereview.stackexchange",
"id": 28894,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, c++11, game",
"url": null
} |
homework-and-exercises, general-relativity, differential-geometry, tensor-calculus, vector-fields
Title: Formula for curl in polar coordinates using covariant differentiation For the plane in polar coordinates $(r,\theta)$ with metric $$ds^2=dr^2+r^2d\theta^2,$$
the curl on a vector field $v^a\partial_a$ is given by the rank-2 antisymmetric tensor $\nabla_av_b-\nabla_bv_a$. This tensor has only one independent & non-zero component:
$$\nabla_rv_\theta-\nabla_\theta v_r=\partial_rv_\theta - \Gamma_{r\theta}^av_a -\partial_\theta v_r +\Gamma^a_{\theta r}v^a=\partial_rv_\theta-\partial_\theta v_r$$
since $\Gamma^a_{\theta r} = \Gamma^a_{r \theta }$. Expressed in contravariant vector components, $$\nabla_rv_\theta-\nabla_\theta v_r=\partial_r (g_{\theta a}v^a)-\partial_\theta (g_{rb}v^b)=\partial_r(r^2v^\theta)-\partial_\theta(v^r)=2rv^\theta+r^2\partial_rv^\theta-\partial_\theta v^r$$
I am trying to compare this to the formula for curl in vector calculus: | {
"domain": "physics.stackexchange",
"id": 81979,
"lm_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, general-relativity, differential-geometry, tensor-calculus, vector-fields",
"url": null
} |
from Latin, and it means half or partly (like in words such as semi-permanent, semi-formal, semifinals). product of inertia of area = moment of inertia of area (moment of inertia of area) product of inertia of mass = moment of inertia (moment of inertia) product of inertia of volume = moment of inertia of volume (moment of inertia of volume) proof = 0. Using the small angle approximation SINθ ≈ θ, this equation is approximately. and parallel to the base, is A. Force, given by Eq. With a solid disk, the mass is spread out. The Following Section consists of Strength of Materials Questions on Physics. The Brick Solid block adds to the attached frame a solid element with geometry, inertia, and color. The speed at which the points in a rotating object transcribe a circle is known as angular velocity, and a change in that speed is known as angular acceleration. The moment of inertia of a body is a measure of the resistance the body offers to any change in its angular velocity. The moment of inertia of a point mass is. The moment of inertia about an axis is a measurement of how difficult it is to accelerate the body about that axis. Processing. ) The more inertia a body has, the harder it is to change its linear motion. A playground carousel is free to rotate about its center on frictionless bearings, and air resistance is negligible. The formula for the moment of inertia of a ring created by two overlapping circles is similar. If you're unsure about what deflection actually is, click here for a deflection definition Below is a concise beam deflection table that shows how to calculate the maximum deflection in. If an object rotates 90 degrees, all the points in an object, save those on the axis of rotation, transcribe a quarter of a circle. By Gerson Washiski Barbosa. moment of inertia; Trig Graphs, Angles, and Circles; Radian and Degrees; LZ 7. Define following terms 1. (C) Maximum at quarter points (D) Varies with slope Answer: Option B Question No. Informally, it is the "average" of all points of. the axis of rotation, therefore the moment of inertia has been reduced and the skater | {
"domain": "waverestaurant.it",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9793540716711547,
"lm_q1q2_score": 0.8400586861717086,
"lm_q2_score": 0.8577681049901037,
"openwebmath_perplexity": 559.2652028811257,
"openwebmath_score": 0.6779171228408813,
"tags": null,
"url": "http://waverestaurant.it/hbaw/moment-of-inertia-of-quarter-circle.html"
} |
beginner, erlang
,6883,6885,6887,6889,6891,6893,6895,6897,6899,6901,6903,6905,6907,6909,6911,6913,6915,6917,6919,6921,6923,6925,6927,6929,6931,6933,6935,6937,6939,6941,6943,6945,6947,6949,6951,6953,6955,6957,6959,6961,6963,6965,6967,6969,6971,6973,6975,6977,6979,6981,6983,6985,6987,6989,6991,6993,6995,6997,6999,7001,7003,7005,7007,7009,7011,7013,7015,7017,7019,7021,7023,7025,7027,7029,7031,7033,7035,7037,7039,7041,7043,7045,7047,7049,7051,7053,7055,7057,7059,7061,7063,7065,7067,7069,7071,7073,7075,7077,7079,7081 | {
"domain": "codereview.stackexchange",
"id": 2685,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "beginner, erlang",
"url": null
} |
Let $f(x)=x^k,$ where $k>1$ or $k<0$.
Thus, $f$ is a convex function and since $(11,7,5)\succ(9,8,6),$ by Karamata we obtain: $$f(11)+f(7)+f(5)>f(9)+f(8)+f(6).$$
Also, for $0<k<1$ we see that $f$ is a concave function.
Thus, by Karamata again $$f(11)+f(7)+f(5)<f(9)+f(8)+f(6).$$ Thus, it remains to check, what happens for $k\in\{0,1\}$.
Another elemenatary solution, using that $x$ is supposed to be a natural number. It even uses a technique the OP considered:
The equation is equivalent to
$$\left(\frac{5}{11}\right)^x + \left(\frac{7}{11}\right)^x +\left(\frac{11}{11}\right)^x = \left(\frac{6}{11}\right)^x +\left(\frac{8}{11}\right)^x +\left(\frac{9}{11}\right)^x$$
All terms are positive and the left hand side contains a summand 1 in the form of $\left(\frac{11}{11}\right)^x$.
From the terms on the right hand side, $\left(\frac{9}{11}\right)^x$ is the biggest, but it will of course still decrease for increasing $x$. Using a calculator will show you that $\left(\frac{9}{11}\right)^6 < \frac13$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9693241965169939,
"lm_q1q2_score": 0.8139744515580275,
"lm_q2_score": 0.8397339656668286,
"openwebmath_perplexity": 150.68527036910146,
"openwebmath_score": 0.9557837247848511,
"tags": null,
"url": "https://math.stackexchange.com/questions/2840394/find-the-number-of-natural-solutions-of-5x7x11x-6x8x9x"
} |
homework-and-exercises, electrostatics, coulombs-law
Title: Coulomb's law and electric field intensity
here is question and solution
I can't understand why R_x= 4a_z
please explain it detail! ;-( The electric field from any single line charge always points directly away from the line charge, is proportional to the linear charge density, and falls off like $\frac{1}{r}$
In your problem, at any point of interest, you will have an electric field vector that has a component on the y-z plane from the line charge on the x axis, and a component on the x-z plane from the line charge on the y axis.
The total magnitude will be $E=\sqrt{E_{yz}^2 + E_{xz}^2}$ | {
"domain": "physics.stackexchange",
"id": 29757,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "homework-and-exercises, electrostatics, coulombs-law",
"url": null
} |
javascript, cryptography, hash-map
};
sha256TOOLS.maj = function maj(x,y,z){
return (x & y) ^ (x & z) ^ (y & z);
};
sha256TOOLS.sigma0 = function sigma0(x){
return this.rotr(2,x) ^ this.rotr(13,x) ^ this.rotr(22,x);
};
sha256TOOLS.sigma1 = function sigma1(x){
return this.rotr(6,x) ^ this.rotr(11,x) ^ this.rotr(25,x);
};
sha256TOOLS.omega0 = function omega0(x){
return this.rotr(7,x) ^ this.rotr(18,x) ^ (x >>> 3);
};
sha256TOOLS.omega1 = function omega1(x){
return this.rotr(17,x) ^ this.rotr(19,x) ^ (x >>> 10);
};
sha256TOOLS.mod = function mod(a,b){
var temp = a % b;
while(temp < 0){
temp += b;
}
return temp;
};
var sha256 = (sha256 || function sha256(string){
//copy constant values and initial hashes
var H = sha256TOOLS.h.slice();
var K = sha256TOOLS.k.slice(); | {
"domain": "codereview.stackexchange",
"id": 36918,
"lm_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, cryptography, hash-map",
"url": null
} |
Actual definition of irrational number says that an irrational number is any real number that cannot be expressed as a ratio of integers. So your first line is infact wrong.
• Not necessarily true - see my answer. – Bill Dubuque Jun 7 '14 at 15:07
• @BillDubuque see this.Also i can be wrong, just clarify it – RE60K Jun 7 '14 at 15:08
• Definitions are conventions. Wikipedia chose one (the most elementary one). As I mentioned in my answer, that convention is not universal. – Bill Dubuque Jun 7 '14 at 15:18
• @BillDubuque it is a good point to be noted – RE60K Jun 7 '14 at 15:19
Several previous comments and answers apply, but no one yet seems to have mentioned Gaussian Integers, (see http://en.wikipedia.org/wiki/Gaussian_integer) - complex numbers whose real and imaginary parts are both (real) integers. By this definition, i is a Gaussian Integer. the concept extends to Gaussian Rationals (see http://en.wikipedia.org/wiki/Gaussian_rational), so that i is also a Gaussian Rational.
• But this is employing a different convention, namely the convention of referring to the elements of the fraction field of a a domain $\,D\,$ as $\,D$-rational. By that convention, any number can be considered "rational" relative to an appropriate domain (e.g. often used to distinguish such rationals from higher degree algebraic numbers over $\,D).\ \$ – Bill Dubuque Jun 7 '14 at 16:03
• @BillDubuque Well the issue in the OP question is one of mixing conventions, i.e. using terms that normally describe real numbers to create a confusion about an imaginary number: my answer is simply pointing out that there is a convention which does address rationality in the complex numbers. – Tom Collinge Jun 7 '14 at 16:12 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9755769134963331,
"lm_q1q2_score": 0.8423049117091556,
"lm_q2_score": 0.863391599428538,
"openwebmath_perplexity": 509.4399300996516,
"openwebmath_score": 0.8349810242652893,
"tags": null,
"url": "https://math.stackexchange.com/questions/823970/is-i-irrational/823981"
} |
structural-analysis
Title: Why/how normal shear stress is zero in thin-walled beams? Please explain how the normal shear stress (shear stress normal to the cuve, C, defining the cross-section of a thin-walled beam) is zero. I have attached a screenshot from a book which says that the outer surfaces of the beam are stress free. This cannot be true except in very special cases. Right?
Now consider the following image. Here axis $1$ is the axial direction of the beam, and axes $2$ and $3$ define the cross-section of the beam. For the normal shear stress to be zero in the member $A$ of the cross-section, the shear stress $\sigma_{21}$ should be zero on the lateral face $1$ which is possible only if there is no axial force on the lateral face $1$. Am I right? We don't know what equation 1.5 says in your book, but the statement "the outer surfaces are stress free" is nonsense, unless the book is only talking about some particular component of the stress.
The stress distribution on the outer surface of any component has to be in equilibrium with the external forces on that surface. That doesn't mean the stress must be zero. The simplest example I can think of is a rod under tension. The axial stress at the surface is the same as everywhere else in the rod.
In the diagram in the book, the stress component $\tau_n$ will be zero at the surface if there is no pressure load on the surface at that position along the beam. Otherwise, it will not be zero.
The book says it is assumed that "$\tau_n$ is zero through the wall thickness." That is an assumption, and it is only an approximation. In fact, for a uniform beam there is a parabolic variation of $\tau_n$ through the thickness. This can be ignored for a slender beam (which is thin relative to its length) because it is small compared with the other stress components, but it is not zero. For a thick beam, this shear stress component is included in the beam formulation. | {
"domain": "engineering.stackexchange",
"id": 2652,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "structural-analysis",
"url": null
} |
# Probability based on a percentage
We have a group of 15 people, 7 men and 8 women.
Randomly selecting 5 people, what's the probability to pick 3 men and 2 women? What's the probability to pick at least 1 man?
I tried solving the first question like this: $${7 \choose 3} = \frac{7!}{(7-3)!3!} = 35$$ and $${8 \choose 2} = \frac{8!}{(8-2)!2!} = 28$$,
so the probability should be $$\frac 1{980}$$.
But I'm stuck on the second question, how should I proceed?
• Hint: Converse probability: 1 minus the probability picking no man/5 woman. – callculus Apr 15 at 14:25
• Thank you, so if I'm not mistaken the probability to pick 5 women is (8!/[(8-5)!5!]) = 1/56, so the probability to pick at least one man is 55/56? – sdds Apr 15 at 14:36
• @sds No, you just have to divide your result (product) by the number of ways to pick 5 people. See my answer. – callculus Apr 15 at 14:39
• All right, I think I get it now. So I get to 56/3003 ≈1.86, which I then subtract from 100, getting ≈ 98.13% as the probability to pick at least one man. – sdds Apr 15 at 14:47
• Your calculation is right. I have a different rounding. $0.98135...\approx 98.14\%$. Here is the rule: If the number you are rounding is followed by $\color{blue}5$, 6, 7, 8, or 9, round the number up. In your case 3 is followed by $\color{blue}5$. – callculus Apr 15 at 14:52 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9919380072800831,
"lm_q1q2_score": 0.8308670732660222,
"lm_q2_score": 0.8376199592797929,
"openwebmath_perplexity": 341.07492077968243,
"openwebmath_score": 0.8403331637382507,
"tags": null,
"url": "https://math.stackexchange.com/questions/3188745/probability-based-on-a-percentage"
} |
algorithms, graph-traversal
Title: Different topologically sorted order based on DFS vertex ordering The algorithm for topological sort, in CLRS goes as follows :
call DFS(G) to compute finishing times v.f for each vertex v
as each vertex is finished, insert it onto the front of a linked list
return the linked list of vertices
Let's we have a directed graph, as in the figure here:
If we start DFS from arbitrary vertices, we get different topological orders -- for instance, if the top level DFS loop goes through vertex b first, then d, then i and finally a, one possible ordering of finishing times (largest to smallest) is :
(a), (i), (d,h,l,k,j), (b,c,f,e,g)
where each grouped term within the parenthesis indicates one iteration of DFS from the starting vertex.
If the vertices are taken in a different order, say a first, then d, and then i, the order of finishing times becomes:
(i), (d,h,l,k,j), (a,b,c,f,e,g).
If these were to indicate valid orders of events, how can they both be valid topological orders? The sorting algorithm does not mention any specific order of vertices to use in DFS. A topological ordering of a DAG $G$ is any ordering $v_1,\ldots,v_n$ of the vertices in which $(v_i,v_j) \in G$ implies $v_i \leq v_j$. That is, if there is an edge from $x$ to $y$, then $x$ must precede $y$ in the ordering (assuming $x \neq y$). A DAG can have many topological orderings. For example, the empty DAG on $n$ vertices has $n!$ topological orderings. In contrast, a path $v_1 \to v_2 \to \cdots \to v_n$ has a unique topological ordering. | {
"domain": "cs.stackexchange",
"id": 11512,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "algorithms, graph-traversal",
"url": null
} |
lisp, scheme, racket
Title: Scheme/Racket: idiomatic infix math evaluator Inspired by xkcd and a couple of praising blog posts, I decided to try out Lisp. It seemed that the best-supported dialect was Racket, itself a variant of Scheme, so I went with that and wrote an infix mathematical expression parser to get familiar with the basic concepts.
That was a mind-bending experience considering I never did functional programming. Not having mutable variables (or not using them, anyways) and having to use recursion instead of loops was a little hard for my imperative mind.
Anyways, I came up with this. My goal was to parse infix mathematical expressions with correct precedence and parentheses. It supports additions, subtractions, multiplications and divisions. It works, but it's probably full of hints that I'm new at this, and I would like to know which parts could have been made more idiomatic.
#lang racket
;; usage: (reduce (tokenize))
;; tokenizing function
(define (tokenize)
(define (-tokenize-operator first)
(cond
([equal? first #\+] (list + (read-char)))
([equal? first #\-] (list - (read-char)))
([equal? first #\*] (list * (read-char)))
([equal? first #\/] (list / (read-char)))))
(define (-tokenize-number first)
(define (--char->number char)
(let ([ascii-zero (char->integer #\0)])
(- (char->integer char) ascii-zero)))
(define (--read-number initial)
(let ([char (read-char)])
(if (char-numeric? char)
(--read-number (+ (--char->number char) (* initial 10)))
(list initial char))))
(if (char-numeric? first)
(--read-number (--char->number first))
'())) | {
"domain": "codereview.stackexchange",
"id": 3657,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "lisp, scheme, racket",
"url": null
} |
that eccentricity is calculated for the obtained projection. I = 3 [I cm + M d^2] =3 [ML^2 / 2+ M d^2]. Write the equation for polar moment of inertia with respect to apex of triangle. Then this moment of inertia is transferred about the axis passing through the centroid of the given section, using theorem of parallel axis. The moment of inertia $$I_x$$ about the $$x$$-axis for the region $$R$$ is the limit of the sum of moments of inertia of the regions $$R_{ij}$$ about the $$x$$-axis. For a homogenous bar of length L and mass M, the moment of inertia about center of mass is (1/3)ML^2. The concept of a moment of inertia is important in many design and analysis problems encountered in mechanical and civil engineering. CENTER OF GRAVITY, CENTROID AND MOMENT OF INERTIA. The moment of inertia of two or more particles about an axis of rotation is given by the sum of the moment of inertia of the individual particles about the same axis of rotation. 2) A precast concrete floor beam has the cross section shown below. apex angle in the neighborhood of 34°. it is first necessary to consider the rotational moment. Adding moments of inertia 3. The moment of inertia of the triangle is not half that of the square. But I don't know how to do that. The moment of inertia must be specified with respect to a chosen axis of rotation. A triangle cannot have more than one right angle or one obtuse angle, since the sum of all three angles is equal to the sum of two right angles, which is 180° or, in radians, π. I am unable to find it. Ball hits rod angular momentum example. Moment of inertia of a circular section can be calculated by using either radius or diameter of a circular section around centroidal x-axis or y-axis. The moment of inertia of a triangle of base b and altitude h with respect to a centroidal axis parallel to its base would be bh3/12 bh3/18 bh3/24 bh3/36 The CG of a triangle lies at the point of intersection of diagonals | {
"domain": "carlacasciari.it",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9901401449874105,
"lm_q1q2_score": 0.8654589603563371,
"lm_q2_score": 0.8740772351648677,
"openwebmath_perplexity": 395.8218896476916,
"openwebmath_score": 0.6235755681991577,
"tags": null,
"url": "http://carlacasciari.it/moment-of-inertia-of-triangle-about-apex.html"
} |
organic-chemistry, hydrocarbons, amines, phenols, organic-reduction
Title: Out of the given reagents, find the ones to be used to convert benzene to p-aminophenol
$\ce{Br2/FeBr3}$
$\ce{CH3Cl/AlCl3}$
$\ce{KMnO4}$
$\ce{HNO3/H2SO4}$
$\ce{NBS}$/hv
$\ce{NaOH}$
$\ce{Sn/HCl}$
$\ce{NH4SH}$
$\ce{NaBH4}$
I'm able to get the amino group onto the ring by using 4 and 7.
But I have no idea how to get $\ce{-OH}$ in para position (also specify the order). I am not happy with the idea of trying to convert a bromobenzene into a phenol using sodium hydroxide. Normally an aryl halide is very inert to nucelophiles, the nitro group will increase the rate but it will not make much difference.
What I would do is to do the following
Nitrate benzene with a mixture of nitric and sulfuric acids to form nitrobenzene
Reduce the nitrobenzene with tin in acid.
To do the synthesis I would want to use nitrous acid and allow the diazonium salt to decompose forming the phenol.
I would nitrate under very gentle conditions to form a mixture of nitrophenols. After separation I would then go to the next step.
I would reduce again with tin in hydrochloric acid to form the target molecule.
I think that a fault exists in the question, I suspect it is an exam question and that the person who wrote the question did a bad job of the question writing. | {
"domain": "chemistry.stackexchange",
"id": 10217,
"lm_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, hydrocarbons, amines, phenols, organic-reduction",
"url": null
} |
so minimizing $\|A - X\|$ is equivalent to maximizing $\mathrm{tr}(A^tX)$. (In particular, the objective function to optimize is linear and not quadratic)
• Is there any special properties of- $\mathcal{GL}_n(\mathbb{R})$? – Rajat Oct 13 '15 at 10:16
• @Rajada : You mean why I want the given input matrix to be invertible? Actually I am not sure this is essential. One could think of the distance from any matrix. However, I am indeed more interested in finding information about the distance of linear automorphisms of $\mathbb{R}^n$, and care less about non-invertible transformations. – Asaf Shachar Oct 13 '15 at 12:17
• @Rajada: I found one possible reason for focusing upon invertible matrices only - this is because I hope for a unique minimizer. I am interested in properties of the minimizer function (like is it smooth?). I have edited the question to stress these points. – Asaf Shachar Oct 13 '15 at 12:33
• Note: the answer coincides with the orthogonal matrix in (either) polar decomposition of $A$. – Ben Grossmann Dec 11 '16 at 17:09
Let us prove Omnomnomnom's suspicion. Fix $A \in M_n(\mathbb{R})$. Following the OP's observation, we want to maximize the linear functional $\varphi \colon M_n(\mathbb{R}) \rightarrow \mathbb{R}$ given by $\varphi(X) = \mathrm{tr}(A^tX)$ subject to the constraint $X^t X = I$. First, let us assume that $A$ is a diagonal matrix with non-negative entries on the diagonal. Then, given an orthogonal $X$ we have | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9830850862376966,
"lm_q1q2_score": 0.8255299380542973,
"lm_q2_score": 0.8397339656668287,
"openwebmath_perplexity": 180.94866278825077,
"openwebmath_score": 0.978649377822876,
"tags": null,
"url": "https://math.stackexchange.com/questions/1477855/distance-of-a-matrix-from-the-orthogonal-group"
} |
ros, python, catkin, rostest, add-dependencies
add_rostest(tests/my_test.test DEPENDENCIES ${my_msgs_EXPORTED_TARGETS})
endif()
I think that should work, but I haven't tried it myself.
Originally posted by William with karma: 17335 on 2015-11-06
This answer was ACCEPTED on the original site
Post score: 0 | {
"domain": "robotics.stackexchange",
"id": 22922,
"lm_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, python, catkin, rostest, add-dependencies",
"url": null
} |
Since you have gotten results through squaring, you should also check to see if any of the results are extraneous. Also, even though you have gotten the solutions from one cycle, there are not all the solutions.
#### karush
##### Well-known member
Re: 2costheta+2sintheta=sqrt6
I was lazy I looked at graph on W|A and saw only 2 solutions.
Actually not how to seek find more posibilities
#### MarkFL
Staff member
Re: 2costheta+2sintheta=sqrt6
$2\cos{\theta}+2\sin{\theta}=\sqrt{6}$
$\displaystyle\cos{\theta}+\sin{\theta}=\frac{ \sqrt{6} }{2}$
$\displaystyle(\cos{\theta}+\sin{\theta})^2=\frac{3}{2}$
$\displaystyle\cos^2{\theta}+2cos\theta\sin\theta+\sin{\theta}^2=\frac{3}{2}$
$\displaystyle\sin{2\theta}=\frac{1}{2} \Rightarrow \theta=\frac{\pi}{12}=15^o$
the other answer is $75^o$ but don't know how you get it.
To get the other solution, consider the identity:
$$\displaystyle \sin(\pi-x)=\sin(x)$$
#### Deveno
##### Well-known member
MHB Math Scholar
Re: 2costheta+2sintheta=sqrt6
There are TWO points on the unit circle where $y = \sin \phi = \dfrac{1}{2}$.
One is the point $(\frac{\sqrt{3}}{2},\frac{1}{2})$ and one is the point $(\frac{-\sqrt{3}}{2},\frac{1}{2})$.
The first corresponds to the value you found: | {
"domain": "mathhelpboards.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9817357179075082,
"lm_q1q2_score": 0.8094037169443609,
"lm_q2_score": 0.8244619220634456,
"openwebmath_perplexity": 3812.1770923134154,
"openwebmath_score": 0.8688463568687439,
"tags": null,
"url": "https://mathhelpboards.com/threads/trigonometric-equation-2cos-%CE%B8-2sin-%CE%B8-%E2%88%9A-6.7835/#post-36190"
} |
c++, performance, algorithm
Also note the change to unsigned char, so if we have an input that's negative when viewed as a char, we don't try to index outside the table.
Encapsulation
Taking the next step from the last point, I'd rather hide the implementation of the translation a bit more by wrapping it up into a class. For example, something like this might be usable:
class formatter {
class xlat_table {
static const int table_size = std::numeric_limits<unsigned char>::max();
std::array<char, table_size> table;
public:
xlat_table() {
for (int i = 0; i < table_size; i++)
if (std::isalpha(i))
table[i] = std::tolower(i);
else if (std::isdigit(i))
table[i] = i;
else table[i] = ' ';
}
char operator[](size_t n) { return table[n]; }
};
static xlat_table table;
public:
void operator()(std::string &rawString) {
transform(
rawString.begin(),
rawString.end(),
rawString.begin(),
[this](unsigned char c) { return table[c]; });
}
};
formatter::xlat_table formatter::table; | {
"domain": "codereview.stackexchange",
"id": 19882,
"lm_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",
"url": null
} |
• Depends on what you mean by “calculate the cardinality”. For example, if each $\alpha_l$ is $2$, and $\lambda=\aleph_0$, then the product has cardinality $2^{\aleph_0}$, but we don’t know which cardinal that is in ZFC. Oct 10 '19 at 0:36
• The cardinalityh of $P^2(\omega)$ (the power set of the power set of $\omega$) is $2^{\mathfrak{c}}$, with $\mathfrak{c}=2^{\aleph_0}$. With GCH, this would be $\aleph_2$, so I think you would get $\aleph_3$ for the cardinality of the set of choice functions. But without GCH, then who knows? Oct 10 '19 at 0:40
• In a general case is it possible to describe the product as being in bijection with some expression involving the sets and its powersets? Oct 10 '19 at 0:42
• Why would the set of choice functions of $P^2(\omega)\setminus\emptyset$ have a bijection with $P^3(\omega)$? Oct 10 '19 at 0:44
• Or otherwise, why would it be $\aleph_3$ assuming GCH? Oct 10 '19 at 0:52
We know that $$P(\omega)$$ has $$2^{\aleph_0}=\mathfrak{c}$$ elements; and that $$P^2(\omega)$$ has $$2^{\mathfrak{c}}$$ elements.
For simplicity, say $$\mathfrak{d}=2^{\mathfrak{c}}$$, and let $$X=P^2(\omega)\setminus\varnothing$$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9861513869353992,
"lm_q1q2_score": 0.8239132549356833,
"lm_q2_score": 0.8354835432479661,
"openwebmath_perplexity": 120.9247717725712,
"openwebmath_score": 0.9426740407943726,
"tags": null,
"url": "https://math.stackexchange.com/questions/3387569/cardinality-of-an-arbitrary-cartesian-product"
} |
= cos(n! +2…nl) = cos(n(! +2…l)); all integers l =) Only frequencies up to 2… make sense 21. Spectrum from Fourier Series Plot a for Full-Wave Rectified Sinusoid F 0 1 / T 0 d Z 0 2SF 0 ( 4 1) 2 2 k a k S a k. The cosine form is also called the Harmonic form Fourier series or Polar form Fourier series. Fourier series of a constant function f(x)=1 converges to an odd periodic extension of this function, which is a square wave. Fourier Analysis for Periodic Functions. The values of a, a, and a, are [3] TT 1 1 - +n 2 -n 8. The construct of the Fourier series is given by. A Fourier cosine series has df∕dx = 0 at x = 0, and the Fourier sine series has f(x = 0) = 0. Bravely applying the usual formulae for the Fourier sine series to the delta function, we find that for 0 x 1, In other words, if the function f(x) above happens to be the delta function, then b n = 2 sin(n t). An aperiodic signal cannot be represented using fourier series because the definition of fourier series is the summation of one or more (possibly infinite) sine wave to represent a periodicsignal. #Fourier Series Coefficients #The following function returns the fourier coefficients,'a0/2', 'An' & 'Bn' # #User needs to provide the following arguments: # #l=periodicity of the function f which is to be approximated by Fourier Series #n=no. Digitize low-frequency waves from the function generator, sine, triangle, and square. Plotting partial sums of Fourier sine series. For example the wave in Figure 1, is a sum of the three sine waves shown in Figure. So that's 1 sine x, 0, sine 2x's then 4 over pi sine 3x's, but with this guy there's a 3, 0 sine 4x's, sine 5x comes in over 5, and so on. Author name; Kyle Forinash; Wolfgang Christian. In the processing of audio signals (although it can be used for radio waves, light waves, seismic waves, and | {
"domain": "lenzibroker.it",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9890130580170846,
"lm_q1q2_score": 0.8425924459609024,
"lm_q2_score": 0.8519528019683105,
"openwebmath_perplexity": 454.35232047223553,
"openwebmath_score": 0.9073277711868286,
"tags": null,
"url": "http://lenzibroker.it/fourier-series-of-sine-wave.html"
} |
ros, ros-melodic, ros-control, ubuntu, diff-drive-controller
</launch>
rubble_control.yaml
rubble_joint_publisher:
type: "joint_state_controller/JointStateController"
publish_rate: 50
rubble_velocity_controller:
type: "diff_drive_controller/DiffDriveController"
left_wheel: 'wheel_left_joint'
right_wheel: 'wheel_right_joint'
publish_rate: 50
pose_covariance_diagonal: [0.001, 0.001, 1000000.0, 1000000.0, 1000000.0, 0.03]
twist_covariance_diagonal: [0.001, 0.001, 0.001, 1000000.0, 1000000.0, 0.03]
cmd_vel_timeout: 0.25
# Odometry fused with IMU is published by robot_localization, so
# no need to publish a TF based on encoders alone.
enable_odom_tf: false
# Wheel separation and radius multipliers
wheel_separation_multiplier: 1.5 # default: 1.0
wheel_radius_multiplier : 1.0 # default: 1.0
# Velocity and acceleration limits
# Whenever a min_* is unspecified, default to -max_*
linear:
x:
has_velocity_limits : true
max_velocity : 2.0 # m/s
has_acceleration_limits: true
max_acceleration : 20.0 # m/s^2
angular:
z:
has_velocity_limits : true
max_velocity : 2.0 # m/s
has_acceleration_limits: true
max_acceleration : 25.0 # rad/s^2
localization.yaml
odom_frame: odom
base_link_frame: base_link
world_frame: odom
two_d_mode: true
frequency: 50
odom0: rubble_velocity_controller/odom
odom0_config: [false, false, false,
false, false, false,
true, true, true,
false, false, true,
false, false, false]
odom0_differential: false
odom0_queue_size: 10 | {
"domain": "robotics.stackexchange",
"id": 31670,
"lm_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, ros-melodic, ros-control, ubuntu, diff-drive-controller",
"url": null
} |
This simplifies to: .$\displaystyle 89S\;=\;\frac{9}{10}F_1 + \frac{1}{10}F_2$
Since $\displaystyle F_1 = F_2 = 1$, we have: .$\displaystyle 89S\;=\;\frac{9}{10}(1) + \frac{1}{10}(1) \;=\;1$
Therefore: .$\displaystyle S\;=\;\frac{1}{89}$ . . . ta-DAA!
9. Here are some facts.
1)The divine proportion is called "the most irrational number" meaning it is the most difficult to approximate with rationals (you need countinued fractions to prove this).
2)Let $\displaystyle d=\gcd(a,b)$ then $\displaystyle \gcd(F(a),F(b))=F(d)$ (another proof to your original problem because two consectutive number are coprime).
3)Every number is expressable as a sum of distinct fibonacci number non of which are adjacent.
Here's an algebraic proof of: $\displaystyle \lim_{n\to\infty}\frac{F_{n+1}}{F_n}\:=\:\phi$
You must be familiar with the Binet function for Fibonacci numbers:
. . . $\displaystyle [1]\;\;F_n\;=\;\frac{(1 + \sqrt{5})^n - (1 - \sqrt{5})^n}{2^n\sqrt{5}}$
and you must know that: $\displaystyle [2]\text{ If }|r| < 1\text{, then }\lim_{n\to\infty} r^n\: = \;0$ | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9820137874059599,
"lm_q1q2_score": 0.8772421629273606,
"lm_q2_score": 0.8933094159957173,
"openwebmath_perplexity": 1881.2424747708912,
"openwebmath_score": 0.8473930358886719,
"tags": null,
"url": "http://mathhelpforum.com/number-theory/3129-fibonacci-s-sequence.html"
} |
swift, a-star
Use a where-clause instead of filter to loop through all successors that are not contained in bestPlan.states. Using filter is good, but this is what where is for.
The way you construct newPlan isn't very elegant. You could consider adding an append function to Plan for adding a successor. | {
"domain": "codereview.stackexchange",
"id": 20275,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "swift, a-star",
"url": null
} |
thermodynamics
Title: Do you use internal energy or enthalpy to calculate energy required to boil water from saturated liquid to saturated vapor The water stream is heated in a boiler, at some constant pressure.
When entering the boiler, the water flow is in a saturated liquid state. After heating the outflow fluid has become saturated vapor.
My question is if I want to calculate how much heating energy is needed, do I use
$$Qb = Ug - Uf$$
or
$$Qb = hg - hf$$
U is Internal Energy, h is enthalpy, and f and g refer to saturated liquid and saturated gas Use enthalpy. $Q_b$ is then $h_{fg}$ from the steam tables. $h_{fg}$ is the latent heat of vaporization, the heat required per unit mass to convert the mass from saturated liquid to saturated vapor.
Specific enthalpy and specific internal energy are related by
$$h=u+pv$$
Hope this helps. | {
"domain": "physics.stackexchange",
"id": 72663,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "thermodynamics",
"url": null
} |
python, performance
def rstretch__index(values: list[int], length: int) -> list[int]:
return [
bisect.bisect(values, i) - 1
for i in range(length)
]
def nsum2(candidates: list[int], target: int) -> Iterator[tuple[int, ...]]:
def inner(terms: tuple[int, ...], curr_sum: int, lo: int, hi: int) -> Iterator[tuple[int, ...]]:
for i in range(lo, hi):
v = candidates[i]
curr = curr_sum + v
c = target - curr
if amounts[c] and i <= high_index[c]:
yield terms + (c,)
yield from inner(terms + (v,), curr, i + 1, high_index[target - curr])
amounts = [0] * (target + 1)
for c in candidates:
if c <= target:
amounts[c] += 1
candidates = [i for i, c in enumerate(amounts) if c]
high_index = rstretch__index(candidates, target + 1)
if amounts[target]:
yield (target,)
yield from inner((), 0, 0, len(candidates))
def test_peil2(candidates: list[int], target: int) -> list[tuple[int, ...]]:
return list(nsum2(candidates, target))
def nsum3(candidates: list[int], target: int) -> Iterator[tuple[int, ...]]:
amounts = [0] * (target + 1)
for c in candidates:
if c <= target:
amounts[c] += 1
candidates = [i for i, c in enumerate(amounts) if c]
high_index = rstretch__index(candidates, target + 1) | {
"domain": "codereview.stackexchange",
"id": 45489,
"lm_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",
"url": null
} |
Complete the singular value decomposition $$\mathbf{A} = \left[ \begin{array}{rrr} 1 & -2 & -2 \\ -6 & 3 & -6 \\ \end{array} \right] = % U \left[ \begin{array}{rrr} 0 & d \\ 1 & d \\ \end{array} \right] % S \left[ \begin{array}{ccc} 9 & 0 & 0 \\ 0 & f & g \\ \end{array} \right] % V \frac{1}{3} \left[ \begin{array}{rrr} -2 & 1 & 3a \\ 1 & -2 & 3b \\ 2 & -2 & 3c \end{array} \right]^{*} %$$
Observations: the matrix has full row rank, and a column rank defect of 1. This is an underdetermined system.
## Tools
The Fundamental Theorem of Linear Algebra
A matrix $\mathbf{A} \in \mathbb{C}^{m\times n}_{\rho}$ induces for fundamental subspaces: \begin{align} % \mathbf{C}^{n} &= \color{blue}{\mathcal{R} \left( \mathbf{A}^{*} \right)} \oplus \color{red}{\mathcal{N} \left( \mathbf{A} \right)} \\ % \mathbf{C}^{m} &= \color{blue}{\mathcal{R} \left( \mathbf{A} \right)} \oplus \color{red} {\mathcal{N} \left( \mathbf{A}^{*} \right)} % \end{align}
Because the matrix $\mathbf{A}$ has full row rank, we have a trivial null space: $$\color{red}{\mathcal{N} \left( \mathbf{A} \right)} = \mathbf{0}$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9770226314280634,
"lm_q1q2_score": 0.8284836850257772,
"lm_q2_score": 0.8479677526147223,
"openwebmath_perplexity": 605.802643025912,
"openwebmath_score": 1.0000097751617432,
"tags": null,
"url": "https://math.stackexchange.com/questions/2297706/finding-singular-value-of-an-svd"
} |
c, parsing, shell
int IBQplain(int pos, char *str, int offset) {
char ch;
if (pos == offset)
return 0; // Not within quotes
int escaped = 0;
for (ch = str[offset]; ch; ch = str[++offset]) {
if (!escaped) {
switch (str[offset]) {
'\'': return IBQsingle(pos, str, offset + 1);
'"': return IBQdouble(pos, str, offset + 1);
'\\': escaped = 1
} else {
escaped = 0;
}
if (pos == offset)
return escaped; // Not within quotes, but may be single-escaped
}
}
}
*/
/* Helper function that spawns processes */
int spawn_proc(int in, int out, struct command *cmd) {
pid_t pid;
fflush(NULL);
pid = fork();
if (pid == 0) {
if (in != 0) {
if (dup2(in, 0) < 0)
err_syserr("dup2() failed on stdin for %s: ", cmd->argv[0]);
close(in);
}
if (out != 1) {
if (dup2(out, 1) < 0)
err_syserr("dup2() failed on stdout for %s: ", cmd->argv[0]);
close(out);
}
fprintf(stderr, "%d: executing %s\n", (int) getpid(), cmd->argv[0]);
execvp(cmd->argv[0], cmd->argv);
err_syserr("failed to execute %s: ", cmd->argv[0]);
}
else if (pid < 0) {
err_syserr("fork failed: ");
} else {
/* printf("** we are the parent ***"); */
}
return pid;
} | {
"domain": "codereview.stackexchange",
"id": 19756,
"lm_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, parsing, shell",
"url": null
} |
slam
Title: Error term formulation in Graph SLAM (conceptual doubt) I am reading A Tutorial on Graph-Based SLAM.Grisetti, Kummerle, Stachniss & Burgard
On page 5, the error function is introduced as follows
$$e_{ij}(x_i, x_j) = z_{ij} - \hat{z}_{ij}(xi, xj)$$
here $z_{ij}$ is the mean of virtual measurement and $\hat{z}_{ij}(x_i, x_j)$ is the prediction of the virtual measurement. The following image supplements the description
The Algorithm 1 (on page 6), requires $e_{ij}$ as input. My doubt is regarding the calculation of $e_{ij}$. I need both $z_{ij}$ and $\hat{z}_{ij}$ to calculate $e_{ij}$
The evaluation of $\hat{z}_{ij}$ is dependent on the robot poses $x_i$ and $x_j$.
In turn, these robot poses $x_i, x_j$ (as well as $z_{ij}$) are calculated using $z_{raw}$ (incrementally with Odometry?) and to calculate $\hat{z}_{ij}$ we are again going to (indirectly) use $z_{raw}$. And that does not make sense because then $e_{ij}=0$?
Surely, I'm missing something about how $z_{ij}$ and $\hat{z}_{ij}$ differ!
Kindly help me resolve the above doubt! Any concrete example of $z_{ij}$ and $\hat{z}_{ij}$ are appreciated. Good question. That is quite confusing in the beginning.
Let's say you have an observation of a relative pose zij between two positions(or nodes) from your wheel odometry.
Then, you accumulate the relative poses to create the trajectory of your robot. From the accumulated trajectory you can extract zij_hat.
Given obesrvation and prediction, the error function is | {
"domain": "robotics.stackexchange",
"id": 1957,
"lm_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",
"url": null
} |
c++, template-meta-programming, c++98
If you want a C++98 compliant negative exponent you can use:
template<long long exponent>
struct pow_2{
static double value(){
if (exponent == 0) {
return 1;
}
else if (exponent > 0) {
double half = pow_2<exponent/2>::value();
return (1<<(exponent&1))*half*half;
}
return 1 / pow_2<-exponent>::value();
};
};
But be aware that the same caveat for non-integer const initialisation still applies so it's not hugely useful in TMP for example.
If we accept use C++11 you can simplify and generalize to:
// Tail call optimization will transform this into the equivalent
// loop
constexpr int64_t ipow_p(int64_t base, int exp, int64_t ans = 1) {
return exp < 1 ?
ans : ipow_p(base*base, exp/2, (exp % 2) ? ans*base : ans);
}
constexpr double ipow(int base, int exp){
return exp > 0 ? ipow_p(base, exp) : 1.0 / ipow_p(base, -exp);
}
This is usable in a constant (TMP) context thanks to the constexpr qualifier and At -O2 the call will be expanded to a constant. | {
"domain": "codereview.stackexchange",
"id": 30720,
"lm_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++, template-meta-programming, c++98",
"url": null
} |
python, neural-network, audio-recognition
You can use a phonetic dictionary for converting your text files into sequence of phonemes. e.g play -> P L EY
If you have phoneme boundary marked data e.g. in audio file file1.wav 0.1s to 0.5s phoneme x and 0.5s to 0.9s is phoneme y. Now you have You can use a NN to learn the mapping between phoneme labels and speech signal (400 data points as output and phoneme label of these 400 points as input).
But there are many things that affect the pronunciation. Some of them are listed below:
Context: 'to' and 'go' have the same phoneme 'o' but have very different pronunciations.
Pitch: Female speakers usually have higher pitch than male speakers.
Speaking rate: Speaking rate varies across speakers. It also depends on speaking mode while reading a text we tend to have less number of pauses as compared to conversations.
length_of_output_phoneme: The length of wav file to generate
So in the end input to your NN will look something like this
[left_context, phoneme, right_context, specking_rate, pitch, length_of_output_phoneme] and output will be corresponding speech signal. You can either use MFCC features or raw wav data as NN output. There are many other factors that affect the pronunciation.
If you don't have time marked data. You can use Hidden Markov model HMM for speech synthesis. A separate model will be learned for each phoneme. Input for HMM will be text files (sequence of phonemes) and output will be specch signal. These learned models can be used for generating speech data later.
Some speech synthesis resources are listed below:
1) CMU festvox
2) wavenet
3) Deep Learning in Speech Synthesis
The biggest challenge will be to make it sound like human voice.
Edit 1: Some of the problems with "whenever you see this alphabet, pronounce it like this" are listed below
1) context: From the above to and go example which pronunciation of 'o' will be used | {
"domain": "datascience.stackexchange",
"id": 1580,
"lm_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, neural-network, audio-recognition",
"url": null
} |
electromagnetism, classical-electrodynamics, maxwell-equations, integration
$\def\l{\left}\def\r{\right}$
$\def\pd{\partial}$
$\def\eps{\varepsilon}$
$\def\ph{\varphi}$ | {
"domain": "physics.stackexchange",
"id": 14484,
"lm_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, classical-electrodynamics, maxwell-equations, integration",
"url": null
} |
+0
# Piecewise functions
+1
337
18
+683
i struggle with piecewise functions as the way we are supposed to write the domain, range, int. of increase and decrease confuses me....
do we write it with curly braces or like interval notation,,,,and also what if you have an open circle and a closed circle on the x same x axis or two closed circles on the x axis (wouldn't that just not be a function)
thank you s o so soooosososososo much <3
if anyone can help me with these ill be eternally grateful
Oct 29, 2019
edited by Nirvana Oct 29, 2019
#1
+8873
+3
We put one open curly brace beside the "pieces" of the piecewise function, for example:
$$f(x)=\begin{cases} x+2 & \text{if}&x> 2 \\ x^2 &\text{if}& -3< x\leq 2 \\ 9 &\text{if}& x\leq-3 \end{cases}$$
This is the way to show the pieces of a piecewise function.
On the other hand, domains and ranges (and, of course, intervals) can be expressed in interval notation.
An interval is a set of values or numbers - not a set of expressions or functions.
E.g., the interval [0, 5) is every number between 0 and 5, including 0 and excluding 5.
And by looking at the graph for this function:
We can see:
The domain is: _ (-∞, ∞) The range is: [0, ∞) The intervals of decrease are: (-3, 0) ← This means the function is decreasing for all x values in the interval (-3, 0) For instance, when x = -1, the function is decreasing. The intervals of increase are: (0, 2) and (2, ∞)
All of those are intervals expressed in interval notation.
(At the points where x = 2 and x = -3 , the slope is undefined, and so the function is neither increasing nor decreasing, and so we do not include those values in the intervals of increase or decrease.)
If the graph passes the vertical line test, then it is a function. | {
"domain": "0calc.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9799765616345254,
"lm_q1q2_score": 0.8101581814160883,
"lm_q2_score": 0.8267117940706734,
"openwebmath_perplexity": 5382.3631552852985,
"openwebmath_score": 0.8067015409469604,
"tags": null,
"url": "https://web2.0calc.com/questions/piecewise-functions_3"
} |
python, python-3.x, chess
board.py
from typing_extensions import TypedDict
import Pieces as p
import numpy as np
class Coordinate(TypedDict):
x: int
y: int
class Board():
def __init__(self):
self.board = np.full((8, 8), p.Piece("", -1, -1), dtype=p.Piece)
self.setBoard()
def setBoard(self):
""""Initialise the board by creating and placing all pieces for both colours"""
colours = ["black", "white"]
for i in range(8):
self.board[1][i] = p.Pawn("black", i, 1)
self.board[6][i] = p.Pawn("white", i, 6)
for j in (0, 1):
pos = j * 7
for i in (0, 7):
self.board[pos][i] = p.Rook(colours[j], i, pos)
for i in (1, 6):
self.board[pos][i] = p.Knight(colours[j], i, pos)
for i in (2, 5):
self.board[pos][i] = p.Bishop(colours[j], i, pos)
self.board[pos][3] = p.Queen(colours[j], 3, pos)
self.board[pos][4] = p.King(colours[j], 4, pos)
def display(self):
"""Print the board with borders"""
print("-" * len(self.board) * 3)
for i in range(len(self.board)):
print('|' + '|'.join(map(str, self.board[i])) + '|')
print("-" * len(self.board) * 3 + '-') | {
"domain": "codereview.stackexchange",
"id": 41994,
"lm_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, chess",
"url": null
} |
integer-programming
Title: From CNF to ILP? Can we transform a CNF to ILP without introducing new variables?
My question can be seen as a follow up to Express boolean logic operations in zero-one integer linear programming (ILP) as the solution proposed in that post introduces additional variables.
Also, my current understanding is that each 0 value in the truth table is represented by one linear inequality. This means that if my boolean function is of 16 input variables and balanced, there will be 2^15 linear inequalities so is there a way to reduce the number of inequalities? No. Usually (for most functions / CNF formulas) you'll need additional variables. Linear inequalities form a convex space. If the set of solutions such that $f(x)=1$ is not convex, you'll need additional variables.
The exact number of additional variables and inequalities required depends on the function / on the CNF formula. | {
"domain": "cs.stackexchange",
"id": 8401,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "integer-programming",
"url": null
} |
observational-astronomy, galaxy, data-analysis, spectra, python
Do I have to shift my galaxy spectra for all radii to the
rest-wavelength frame, or can I somehow do it all in advance, since
the redshift for all radii should be the same.
In general, you do not want to shift the galaxy spectrum (unless perhaps the FCQ algorithm requires it). The redshift of the individual spectra is one of the things you are trying to measure, after all.
The redshift for all radii will almost certainly not be the same, since the redshift at any given radius is the sum of the galaxy's redshift (Hubble flow + peculiar velocity of the galaxy) and the mean rotation velocity of the stars at that radius. Some galaxies ("slow rotators") may have almost no rotation, but NGC 4697 is a "fast rotator", and I believe the rotation velocity will reach $\sim \pm 100$ km/s at a radius of 10 arcsec away from the galaxy nucleus along the major axis. | {
"domain": "astronomy.stackexchange",
"id": 5667,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "observational-astronomy, galaxy, data-analysis, spectra, python",
"url": null
} |
homework-and-exercises, heat
Title: Temperature in a calorimeter
A closed calorimeter of negligible water equivalent contains 1kg ice at 0 degree Celsius. 1kg of steam at 100 degrees Celsius is pumped into it. Find the resultant temperature of the mixture. | {
"domain": "physics.stackexchange",
"id": 8428,
"lm_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, heat",
"url": null
} |
objective-c, ios
SceneDetail represents the data that's unique to each scene, that for instance is causing the coffee scene to require 2 cells, and so on. As I have an incomplete understanding of the application it's possible that some type of polymorphism on Scene would be appropriate. The Scene name could be an internal ID that you translate to something human readable, or just something human readable to begin with, such as "Coffee". A consequence of having the scenes and transportation options represented as relationships means that we can greatly simplify the table view code by relying on the collection behavior in the relationship, instead of checking if (sceneTwo != nil) and so on. We should order the relationships so that they will be represented by NSOrderedSet instances and the model will preserve the sorting for us. We can start to refactor our table view methods to take advantage of this.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
NSUInteger numberOfScenes = [planDate.scenes count];
return numberOfScenes + 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSInteger rows = 0;
if (section == 0) {
rows = 1;
}
else if (section == 1) {
rows = 2;
}
else if (section == [self transportSection]) {
rows = [planDate.transportOptions count];
}
else {
Scene *sceneForSection = [self sceneForSection:section];
rows = [sceneForSection.sceneDetails count]; //scene details contains info displayed in rows
}
return rows;
}
- (Scene *)sceneForSection:(NSInteger)section
{
Scene *sceneForSection = planDate.scenes[section - 2];
return sceneForSection;
}
- (NSInteger)transportSection
{
return ([planDate.scenes count] + 2);
} | {
"domain": "codereview.stackexchange",
"id": 4384,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "objective-c, ios",
"url": null
} |
to a partial differential equation. Use of Semicolon (;) in MATLAB. Hello Faisal, the natural logarithm in math ln(x) is expressed in matlab by the function log(x). Learn more about ln. Many programming errors are caused by using a row vector where a column vector is required, and vice versa. %System with good phase and gain margins but low stability margin % kja 070510 aminit; % % Nyquist plot % w=0. Maclaurin series are fast approximations of functions, and they offer more accurate function approximations than just linear ones. It is slightly different from the one obtained using MATLAB program. When I try to use the ln functionality in matlab (natural lograithm. 005:10; Ln=0. Length of vector. Welch Labs 3,901,987 views. MATLAB Commands - 1 MATLAB Commands and Functions Dr. /install on the install file. com for info. You can plot the data in a 2-D or 3-D view using either a linear or a logarithmic scale. There are several ways to compute xls in Matlab. 用微信扫描二维码 分享至好友和朋友圈. The log function operates element-wise on arrays. There is also a student version of Matlab that students may purchase if they wish to work from home. The command figure brings up a new graphics window. 1 Recall the formula for conversion of logarithms: log b (x) = ln(x) ⁄ ln(b). Renewed efforts to eliminate malaria have highlighted the potential to interrupt human-to-mosquito transmission — a process mediated by gametocyte kinetics in human hosts. Natural logarithm - MATLAB log. i hope this might help u in ur problem. Matlab wurde Ende der 1970er Jahre von Cleve Moler an der Universität New Mexico entwickelt, um den Studenten die Fortran-Bibliotheken LINPACK und EISPACK für lineare Algebra von einer Kommandozeile aus ohne Programmierkenntnisse in Fortran zugänglich zu machen. For negative and complex numbers z = u + i*w, the complex logarithm log(z) returns. Cac | {
"domain": "new-design-center.it",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9334308147331958,
"lm_q1q2_score": 0.8041863110937596,
"lm_q2_score": 0.8615382076534742,
"openwebmath_perplexity": 1246.51345888803,
"openwebmath_score": 0.6243621706962585,
"tags": null,
"url": "http://uaor.new-design-center.it/matlab-ln.html"
} |
object-oriented, game, c++17, cmake
void Othello::Model::InvertCell(Coordinate coordinate) {
auto [row, column] = coordinate;
auto& cell = board_.at(row).at(column);
Color curr_color = cell.color;
if (curr_color == EMPTY) {
throw std::logic_error("You are trying to invert a cell that is empty.");
}
else {
Color new_color = (curr_color == BLACK) ? WHITE : BLACK;
cell.color = new_color;
}
}
void Othello::Model::Init(int board_size, std::string black_name, std::string white_name) {
black_ = new Player(std::move(black_name), BLACK);
white_ = new Player(std::move(white_name), WHITE);
board_ = std::vector<std::vector<Cell>>(board_size, std::vector<Cell>(board_size));
board_size_ = board_size;
active_player_ = black_; // BLACK goes first by default
}
Color Othello::Model::GetCellColor(Coordinate coordinate) const {
auto [row, column] = coordinate;
auto cell = board_.at(row).at(column);
return cell.color;
}
int Othello::Model::GetBoardSize() const {
return board_size_;
}
bool Othello::Model::IsGameOver() const {
return !CanMove(black_) && !CanMove(white_);
} | {
"domain": "codereview.stackexchange",
"id": 45274,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "object-oriented, game, c++17, cmake",
"url": null
} |
programming-languages, semantics
Also of interest might be Ometa.
This dissertation focuses on experimentation in computer science. In particular,
I will show that new programming languages and constructs designed specifically to
support experimentation can substantially simplify the jobs of researchers and programmers alike.
I present work that addresses two very different kinds of experimentation. The first
aims to help programming language researchers experiment with their ideas, by making it easier for them to prototype new programming languages and extensions to existing languages. The other investigates experimentation as a programming paradigm, by
enabling programs themselves to experiment with different actions and possibilities—
in other words, it is an attempt to provide language support for what if...? or possible
worlds reasoning.
Alex Warth's dissertation demonstrates using an Ometa to define significantly new semantics (transactional semantics via worlds) in JavaScript+Ometa. | {
"domain": "cs.stackexchange",
"id": 182,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "programming-languages, semantics",
"url": null
} |
I am so sorry...thereafter what to do and how to complete this problem, I don't know. If any one can solve, I am so grateful to them or discuss some other method to complete this problem.
-
(+1) for showing work. Let me/us know if the edited question accurately reflects the work that you have done. – The Chaz 2.0 Apr 3 '12 at 4:57
@The Chaz! thank you for your reply. – gandhi Apr 3 '12 at 4:58
There are infinite number of such pairs. One more, in addition to what you already have are $t_{39}$ and $t_{44}$. – Salech Alhasov Apr 3 '12 at 4:59
Here is what I did: One can convince himself that: $$t_{n+1}+t_{\frac{n(n+3)}{2}}=t_{\frac{n(n+3)}{2}+1}$$ Now, maybe should we look at the following difference: $$t_{\frac{n(n+3)}{2}}-t_{n+1}=\frac{n^2(n+3)^2}{4}$$ And all we left is to search for triangle numbers less than $1000$, for which: $\frac{n^2(n+3)^2}{4}$ is triangle number. Hm. – Salech Alhasov Apr 3 '12 at 5:43
35 solutions, but no general formula, can be found at oeis.org/A185129. Actually, that just gives what you are calling $u(u+1)/2$; $v(v+1)/2$ is given at oeis.org/A185128; if you check the crossrefs you'll also find $x(x+1)/2,w(w+1)/2,u,v,x$ and $w$. – Gerry Myerson Apr 3 '12 at 5:58
There are infinitely many solutions. I'll first give infinitely many, and then talk about describing the set of all solutions. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9908743636887528,
"lm_q1q2_score": 0.8213742205134699,
"lm_q2_score": 0.8289388146603365,
"openwebmath_perplexity": 326.1692085262787,
"openwebmath_score": 0.9844160079956055,
"tags": null,
"url": "http://math.stackexchange.com/questions/127514/finding-pairs-of-triangular-numbers-whose-sum-and-difference-is-triangular"
} |
ros, ros-melodic, topic, publisher
Title: When exactly is a connect callback of a publisher called?
Hi all,
I would like to know when precisely the connect_cb is being invoked, specified in
Publisher ros::NodeHandle::advertise(const std::string & topic,
uint32_t queue_size,
const SubscriberStatusCallback & connect_cb,
const SubscriberStatusCallback & disconnect_cb = SubscriberStatusCallback(),
const VoidConstPtr & tracked_object = VoidConstPtr(),
bool latch = false
) | {
"domain": "robotics.stackexchange",
"id": 33917,
"lm_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, ros-melodic, topic, publisher",
"url": null
} |
c#, wpf
Title: Open/Close Principle in front GUI element I'm working over project for my studies. It's a simple program about brewing coffee. I'm thinking about solution for showing single parameter in GUI.
I have a source brew parameter class:
public abstract class CoffeeParam { /* It's empty */ }
public class CoffeeParam<T> : CoffeeParam, INotifyPropertyChanged
{
public string ParamName { get => _paramName; set { _paramName = value; InvokePropertyChanged(); } }
public T Value { get => _value; set { _value = value; InvokePropertyChanged(); } }
public string ParamUnit { get => _paramUnit; set { _paramUnit = value; InvokePropertyChanged(); } }
private bool IsDescription { get => _isDescription; set { _isDescription = value; InvokePropertyChanged(); } }
private bool _isDescription;
private T _value;
private string _paramName;
private string _paramUnit;
#region PropertyChanged
private void InvokePropertyChanged([CallerMemberName]string propName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName));
}
public event PropertyChangedEventHandler PropertyChanged;
#endregion
}
And the GUI class, where I try to reveal the type of CoffeeParam:
public class MyUserControl1 : UserControl
{
public MyUserContro1(CoffeeParam coffeeParam)
{
Control cntr = null;
if (coffeeParam is CoffeeParam<double>)
{
// creating controls for double input
} else if (coffeeParam is CoffeeParam<int>)
{
// creating controls for int input
}
// rest of init code
}
} | {
"domain": "codereview.stackexchange",
"id": 28559,
"lm_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#, wpf",
"url": null
} |
agi, turing-completeness
Title: Why expect AGI from non-Turing complete AI paradigms? As far as I can tell, all the successful AI paradigms are not Turing complete.
On the other hand, the human mind is Turing complete.
Why would we expect any of these AI paradigms to give us human level intelligence (AGI) if the former is not Turing complete while the latter is?
On the other hand, the human mind is Turing complete.
This is a common confusion about what "Turing completeness" entails. The human brain is not Turing complete, as it is not infinite and doesn't operate on well defined rules (that we have totally cataloged). It might be equal to a linear bounded automaton. Turing completeness applies to rule sets, not the machines that run them. It's commonly applied to languages. Less technically, some people will say "Turing complete" to mean that it can do arbitrary or human-like computation, but this is not the true definition link.
To your question:
Why would we expect any of these AI paradigms to give us human level intelligence (AGI) if the former is not Turing complete while the latter is?
Assuming you're using the lay definition of Turing completeness, current AI algorithms are nowhere near close to what the human brain can do, and everyone in AI that I know understands that radical, as of yet unknown, advances in order to truly approximate the human mind. | {
"domain": "ai.stackexchange",
"id": 3577,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "agi, turing-completeness",
"url": null
} |
c#, .net, json
HttpResponseMessage response = client.PostAsync(uri, new StringContent(xml, Encoding.UTF8, request_header_type)).Result;
An awful lot of objects have been instantiated here in order to get my JSON converted into XML to be passed to the web service. Can anyone suggest any improvements or potential problems? Use camelCase to name local variables instead of words separated by underscores. Although there are no guidelines for them it is common practice among C# programmers.
You should always call XmlWriter.Create to get XmlWriter instead of creating XmlTextWriter.
StringWriter, XmlWriter and any other writer implement IDisposable and thus should be used within using section:
using (var stringWriter = new StringWriter())
using (var xmlTextWriter = XmlWriter.Create(stringWriter))
{
// ... do your stuff that requires stringWriter and xmlTextWriter
}
You should try to avoid .Result for async operation. Try to mark your method with async and use await for client.PostAsync.
Creation of XML looks awful... I suggest to extract your request XML template into XML document with kind of placeholders like:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">
<soap:Body>
<FUNC_NAME xmlns="http://tempurl.org">
XML_PARAMETERS
</FUNC_NAME>
</soap:Body>
</soap:Envelope>
Then in your code just read this file to string with File.ReadAllText and replace FUNC_NAME and XML_PARAMETERS with string.Replace with real values. | {
"domain": "codereview.stackexchange",
"id": 26736,
"lm_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#, .net, json",
"url": null
} |
homework-and-exercises, group-theory
My question is: what is the symmetry group of the whole system? Intuitively it should be some kind of composition between $S_2$ and $G$, but which one? If I understand your question correctly, you have two systems $A$ and $B$, on both of which a symmetry group $G$ acts, so we have mappings
$$G\times A\to A,\ \ \ (g,a)\mapsto ga$$
and
$$G\times B\to B,\ \ \ (g,b)\mapsto gb$$
If the composed system is $A\times B$, then it symmetry group obviously includes $G\times G$ by $(g,h)(a,b) = (ga, hb)$. We have an additional symmetry:
$$S_2\times (A\times B)\to A\times B,\ \ \ (\sigma, (a,b))\mapsto (b,a)$$
where $\sigma$ is the generator of $S_2$. Now what happens with the composition?
$$\sigma(g,h)(a,b) = (hb,ga)$$
while
$$(g,h)\sigma(a,t) = (gb,ha)$$
If we define the automorphism $\phi_\sigma$ of $G\times G$ by $\phi_\sigma(g,h) = (h,g)$, then we have
$$(g,h)\sigma(a,b) = (gb,ha) = \sigma\phi_\sigma(g,h)(a,b)$$
showing that your full symmetry group is (or rather contains) the semidirect product
$$(G\times G)\rtimes_\phi S_2$$
In the quantum mechanical context, $A$ and $B$ are vector spaces, and the combined system is something like $A\otimes B$, on which we also have the action of $G\times G$ and of $S_2$ and the final result is the same. | {
"domain": "physics.stackexchange",
"id": 22688,
"lm_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, group-theory",
"url": null
} |
# Conditional Probability of rainfall
1. Apr 26, 2012
### TranscendArcu
1. The problem statement, all variables and given/known data
3. The attempt at a solution
a) P(Pickwick has no umbrella | it rains) = $\frac{\frac{1}{3}\frac{1}{3}}{\frac{1}{2}} = \frac{2}{9}$, which is the answer according to my answer key.
b) For part b we have:
There is a rain forecast which means he will bring the umbrella. The probability that it won't rain is 1/3.
There is a non-rain forecast which means he brings the umbrella with a probability of 1/3 and it will not rain with a prob of 2/3.
P(Pickwick has umbrella | no rain) = $\frac{1}{3} + \frac{1}{3}\frac{2}{3} = \frac{5}{9}$. But the answer is apparently 5/12. What have I done incorrectly here?
2. Apr 26, 2012
### MaxManus
I got the same as you at b) and I cant see why it is not correct.That's no guarantee for that you are correct though
3. Apr 26, 2012
### Ray Vickson | {
"domain": "physicsforums.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9683812299938006,
"lm_q1q2_score": 0.8706922757050444,
"lm_q2_score": 0.899121388082479,
"openwebmath_perplexity": 2026.3370598951503,
"openwebmath_score": 0.6860119700431824,
"tags": null,
"url": "https://www.physicsforums.com/threads/conditional-probability-of-rainfall.600498/"
} |
quantum-field-theory, quantum-chromodynamics, group-representations, lie-algebra
I guess this formula is well-known.
It is of great use here, because it relates the traces of your kind to the traces in fundamental representation, which are easily computed by the argument Joshua provides.
Take $U=\prod_i \exp(t^a\alpha_a^i)$, for $\alpha_a^i$ an arbitrary set of numbers ($i=1..3$, for example). Then $Ad_U=\prod_i \exp(ad(t^a)\alpha_a^i)$. Now I expand our formula in powers of $\alpha$, and I want to examine the $\alpha_{a}^1\alpha_{b}^2\alpha_{c}^3$ term ($\alpha^i=t^a\alpha^i_a)$:
$$
Tr(ad(\alpha^1)ad(\alpha^2)ad(\alpha^3))=Tr(\alpha^1\alpha^2\alpha^3)Tr(I)-Tr(I)Tr(\alpha^3\alpha^2\alpha^1).
$$
Now, $Tr(t^at^bt^c)$ is trivially (by the formula for the product $t_at_b$) equal to $\frac{1}{4}\left(d^{abc}+if^{abc}\right)$, while $Tr (I)=N$. So finally we get (in your notation):
$$
Tr(t^a_G t^b_G t^c_G)=\frac{N}{2}if^{abc}.
$$
You can compare it with your book. Yes, I know that it is not what you wanted, but in this way (and following Joshua answer for the traces in fundamental rep) you can get any desired trace. Since you have the homework tag, I leave the case of four generators as an exercise. | {
"domain": "physics.stackexchange",
"id": 7504,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-field-theory, quantum-chromodynamics, group-representations, lie-algebra",
"url": null
} |
Just to make sure our definition of matrix representation is the same: Let $\alpha = (a_1, \ldots, a_k)$ be a basis for $V$, and let $T: V \rightarrow V$ be a linear map. Then matrix representation $[T]_{\alpha}$ is defined as follows: $$[T]_{\alpha} = \begin{bmatrix} [T(a_1)]_{\alpha} & \ldots & [T(a_k)]_{\alpha} \end{bmatrix}$$
The matrix representation obeys the following formula: for every $v \in V$, $[T(v)]_{\alpha} = [T]_{\alpha} [v]_{\alpha}$, where $[v]_{\alpha}$ is the coordinate vector of $v$ with respect to the basis $\alpha$.
So now, to answer your question, it's true that $[T]_{\alpha}$ is a $4 \times 4$ matrix in your example, but you don't multiply it onto the $2 \times 2$ matrices; you multiply it onto the $2 \times 2$ matrices after they have been converted into column vectors via the coordinate mapping. Since $2 \times 2$ matrices form a $4$-dimensional space, then this coordinate mapping turns a $2 \times 2$ matrix into an element of $\mathbb{R}^4$.
• How does coordinate mapping work? The rows all extend downward to become one long column? Can all matrices with $n$ elements be multiplied by any matrix with $n$ columns? – CodyBugstein Oct 11 '12 at 23:35
• What confused me is how $[T]_\alpha$ could be square. But one needs to remember that the columns are in vector notation too (not in matrix notation!), so they are actually not $k \times k$ but $k^2 \times 1$ and so in the end $[T]_\alpha$ is $k^2 \times k^2$. – philmcole Apr 10 '18 at 21:20 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9780517475646369,
"lm_q1q2_score": 0.8514891830755662,
"lm_q2_score": 0.8705972717658209,
"openwebmath_perplexity": 188.9674514807904,
"openwebmath_score": 0.883613646030426,
"tags": null,
"url": "https://math.stackexchange.com/questions/211341/representation-of-a-matrix-transformation"
} |
javascript, array, html, css, sudoku
Title: Partial Sudoku Verifier To practice my JavaScript for future employment, I've decided to take up the challenge of writing a javascript sudoku verifier. This code only verify's one of the nine 3x3 blocks there are. I would like feedback on this portion of the code, so I can continue my development with more knowledge and more efficient code. Also, any feedback on my HTML/CSS is warmly welcome. I'm using a fullscreen chrome browser for development, so the #middle centers the box on my screen, but it might not on yours.
You will have to click on full page -> to view the CSS correctly.
function checkAnswer() {
//reset each time button is clicked
document.getElementById('correct').style.display = 'none';
document.getElementById('incorrect').style.display = 'none';
//add each input into 2D array
let first_row = document.getElementsByClassName('row1');
let second_row = document.getElementsByClassName('row2');
let third_row = document.getElementsByClassName('row3');
let sudoku = [
[first_row[0].value, first_row[1].value, first_row[2].value],
[second_row[0].value, second_row[1].value, second_row[2].value],
[third_row[0].value, third_row[1].value, third_row[2].value]
]
//check if each number is unique in the 2D array
for (let i = 0; i < sudoku.length; i++) {
for (let j = 0; j < sudoku[i].length; j++) {
if(!isUnique(sudoku[i][j], sudoku)) {
document.getElementById('incorrect').style.display = 'block';
return;
}
}
}
document.getElementById('correct').style.display = 'block';
} | {
"domain": "codereview.stackexchange",
"id": 34669,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "javascript, array, html, css, sudoku",
"url": null
} |
experimental-realization, terminology-and-notation, quantum-state
In general I'm referring to experimental cases where in practice there is an always-on-but-sometimes-weak coupling between two two-state systems, producing a ground quadruplet.
My question is: in experiments such as these, are 2·qubit and d=4 qudit (a) strictly distinguishable beasts, or (b) theoretical idealizations which are more or less adequate depending on practical considerations? For theoretical purposes, I would say that describing two qubits either as exactly that, two qubits ($\mathbb{C}^2\otimes\mathbb{C}^2$), or as a single $d=4$ spin, ($\mathbb{C}^4$) are essentially equivalent, assuming you have universal control over the whole Hilbert space, because it means you can do whatever you want. The distinction is usually most applicable when you separate the two qubits over some distance, and cannot easily implement a key gate in the universal set (i.e. the two-qubit interaction). But here, you're explicitly stating that that interaction is present. So, the theory claims it makes no difference; you can always do anything you want.
I expect that in practice (although I'm not an experimentalist), the difference comes down to the error mechanisms, which will be different between what you might actually describe as 3 different settings: two qubits $\mathbb{C}^2\otimes\mathbb{C}^2$, a single spin $\mathbb{C}^4$, or the Hilbert space structure implied by the two-qubit interaction you mentioned, $\mathbb{C}\oplus\mathbb{C}^3$. The energy levels in each case are quite different, which will affect the relaxation properties, and presumably more general interactions with the environment as well. | {
"domain": "quantumcomputing.stackexchange",
"id": 134,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "experimental-realization, terminology-and-notation, quantum-state",
"url": null
} |
performance, r
Title: Using R to transform Excel files to be combined I have 50+ excel files that I need to transform (and eventually combine) to use in analyses. I’ve written a code that transforms them into the format I need, but it is extremely slow for files with high species counts (the transformed output will have > 2 million rows). My first question: is there a way to speed up my function? My second question: once all the files are combined, there will be many millions of lines of data. Will I be able to manipulate (e.g. subset, statistically analyze) the data in R? Can R (and/or my laptop) handle that much data? I’ve only used R with several thousand lines and a hundred or so columns before, so I don’t know what’s possible.
The first part of the code below is to produce a data frame resembling what my files look like. In reality, my files are larger (45rows, 12-21 columns) and they are not all the same (different number of columns, and the Habitat column is in different locations with different names), thus some of the strange code in the function. I could clean up each file so they are the same before I use my function, if that would be faster.
Sample data
library(dplyr)
#library(readxl) #this isn't used here, but this is what I use to load the data files. | {
"domain": "codereview.stackexchange",
"id": 31645,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "performance, r",
"url": null
} |
electrochemistry
Title: What's the name of this electrolysis device? I've seen it in a couple of videos, it's used to electrolyze water in 2 different containers at the same time to make a comparison and thus is very handy.
What is it called (besides just a hydrolizer)? It's a precipitator, also known as TDS indicator. | {
"domain": "chemistry.stackexchange",
"id": 192,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "electrochemistry",
"url": null
} |
quantum-mechanics, angular-momentum, representation-theory
Thus, acting with $L_\pm$ on $\vert \alpha, \beta\rangle$ increases the $L_z$ eigenvalue $Y_\beta$ by $\hbar$. Therefore, let's try to use $m$ instead of $\beta$ and set $Y_m = m \hbar$ (As you can see, even for the $L_z$ operator, the actual eigenvalue is not equal to the label, but carries a factor of $\hbar$!).
Now for the eigenvalue w.r.t. $\vec L^2$ we need to work a bit more. Check that
$$ L_+ L_- = L_x^2 + L_y^2 + \hbar L_z, \quad L_- L_+ = L_x^2 + L_y^2 - \hbar L_z, $$$$ \Rightarrow \; \vec L^2 = L_z^2 + \frac{1}{2} (L_+ L_- + L_- L_+)$$
Also, the $\vec L^2$ eigenvalue does not change under operation with $L_\pm$ due to $[\vec L^2, L_\pm] = 0$.
Now since $L_- = L_+^\dagger$, we have that
$$ \vert L_+ \vert \alpha, m\rangle \vert^2 = \langle \alpha, m \vert L_- L_+ \vert \alpha, m \rangle \geq 0$$
$$\vert L_- \vert \alpha, m \rangle \vert^2 = \langle \alpha, m \vert L_+ L_- \vert m, \alpha\rangle \geq 0 $$
On the other hand we can use the expression of $\vec L^2$ in terms of $L_z$ and $L_\pm$ to see that | {
"domain": "physics.stackexchange",
"id": 15269,
"lm_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, angular-momentum, representation-theory",
"url": null
} |
navigation, odometry, gmapping
then start anything else you need and then play your bagfile with the --clock option:
rosbag play [your_bagfile] --clock
As for the rosconsole logger question, you can use the rxconsole tool to set different log levels for different nodes and get more debug output.
Originally posted by Stefan Kohlbrecher with karma: 24361 on 2012-09-16
This answer was ACCEPTED on the original site
Post score: 2
Original comments
Comment by Flowers on 2012-09-16:
Short question: Do I have to set use_sim_time before recording the data - because if I follow your instructions still all the odom messages are dropped(rxconsole doesn't really help, seems to be some issue in /tf messagefilter - given codeline is just the output).
Comment by Harsh2308 on 2017-09-07:
I am facing the same problem and I am using the use_sim_time parameter correctly. I have added a static transform publisher between- base_link and map, & map and odom. This is what i run-
rosrun gmapping slam_gmapping scan:=base_scan _odom_frame:=odom _base_frame:=base_link _map_frame:=map | {
"domain": "robotics.stackexchange",
"id": 11032,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "navigation, odometry, gmapping",
"url": null
} |
ros, catkin, ros-kinetic
Title: Why is catkin trying to include a cmake file from a different workspace?
I used to have a catkin workspace called "cepton_ros" that I was doing some development in. Things went sideways so I deleted the whole folder to start afresh from the remote repo.
However, now when I trying building any other workspace with catkin_make, it fails with the following error:
CMake Error at /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
Could not find a package configuration file provided by "cepton_ros" with
any of the following names:
cepton_rosConfig.cmake
cepton_ros-config.cmake
Add the installation prefix of "cepton_ros" to CMAKE_PREFIX_PATH or set
"cepton_ros_DIR" to a directory containing one of the above files. If
"cepton_ros" provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
CMakeLists.txt:38 (find_package)
The "cepton_ros" folder no longer exists, and isn't even related to the other workspaces that I'm trying to build. Clearly I have somehow set the base ROS or catkin installation to look for this repository. How did I (likely) manage to do this? And how can I clear the settings to fix the problem? | {
"domain": "robotics.stackexchange",
"id": 34426,
"lm_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, catkin, ros-kinetic",
"url": null
} |
aerodynamics
Title: Optimize toy airplane from a cocktail-straw and two paper rings Thrown horizontally with small ring pointing forward (both rings oriented upwards at start). Both rings having same width (2.5 cm) and length 12.5 cm (small ring) and 2*12.5 cm (big ring). Paper fixed with small stripes of Scotch tape.
This toy flies OK, but tends to dive too much down (at the small ring tip).
Please help me understand aerodynamics of its flight and let me know any tips how to make this design better. Besides, how shall I best throw it (any upward angle to horizontal plane, hold it in the middle of the straw or with some offset, etc), how to balance it (I can wrap Scotch tape to make certain parts heavier, etc). Here's some basic information about normal airplanes.
There needs to be an upward-turning tendency, known as decalage.
You can accomplish this by putting a little upward bend in your straw.
Then, it needs to be slightly nose-heavy.
If it isn't, it will follow a scalloped up-down path, or even fly backwards.
If you get those right, it will find its natural speed and glide beautifully. | {
"domain": "physics.stackexchange",
"id": 73694,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "aerodynamics",
"url": null
} |
phylogenetics, statistics, 16rrna
The key is to define the tree structure for 16S
Define the tree structure for other genes
Background and tree stats The difference between Tree A and Tree B is referred to as 'balance'. Tree A is unbalanced, whilst Tree B is balanced and that is a formal description. I would personally use the term Tree A was "heavily paraphyletic", or "extensive paraphyly" - at a technical level that is accepted, I have used frequently. Equally I'd describe Tree B as a "singular monophyly". The statistical basis for tree balance is called the Colless value.
"Colless statistic". It's fairly easy to calculate. The reason it is not often used is because the tree needs to be phylogenetically robust (below). Not much importance is given to it because if a branch isn't robust thats a headache for this statistic (it can't tell the difference between robust and non-robust).
Difference between branches The statistical difference between taxa A and taxa B is measured by bootstrapping (I'm sure you know this), where >= 80% is bifurcation is robust.
Colless statistic might be used, but its fairly obvious, bootstrapping is needed and iqtree is best package for this operation.
The second more difficult part of the question is the delineation of a genus. The 5% threshold of 16S has always been seen as a guide. I have never seen it rigidly enforced and it creates a conflict with phylogenetic theory as your example points out. Telling what is and ain't a genus ... you are right that a key is the tree structure.
Tree structure and bootstrapping ...
A declared monophyly must be supported by a bootstrap > 80%
A declared paraphyly ... each paraphyletic branch must be supported by a bootstrap > 80%
16S versus other genes and tree structure
The tree structure needs confirming particularly as the bootstrap values 16S will often be low. The starting point is to consider the traditional MLST loci (I forget what they are but stuff like atpD, etc ...), build trees from them and : | {
"domain": "bioinformatics.stackexchange",
"id": 2578,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "phylogenetics, statistics, 16rrna",
"url": null
} |
organic-chemistry, stability, resonance, carbocation
Title: Stability of canonical forms
Which of the following ions is more stable? Use resonance to explain your answer.
When we have to compare stability of resonance structures we generally check for the following features in the resonance forms (in sequence):
Neutral molecule;
More covalent bonds;
Complete octet of all the atoms;
Less separation of opposite charges;
Positive charge (if any) on more electro positive atom and negative charge (if any) on more electronegative atom.
In the above problem:
Both the molecules are charged;
Both have same nuber of covalent bonds;
Both have the octet of one carbon atom incomplete (the positively charged one);
Both have positive charges on carbon atoms.
From all of these considerations the molecules should be equally stable. But the answer given in my book is (A).
What is that I can't figure out? It has been noted in the comments and I shall repeat that the premise of the question is already bogus. The question does not consider two different ions but two mesomeric depiction of the same ion. This is also evident by the mesomeric arrow between the two forms. Since mesomery strictly means that no geometrical change takes place, both depictions are identical in all aspects and have the same (resonance-influenced) energy. Thus, any book claiming that either of the two have a lower energy is wrong.
However, what is commonly done is to determine a more likely resonance structure. This is, for example, commonly used to explain the strongly stabilised nature of certain aromatic systems, e.g. when DMAP (4-N,N′-dimethylaminopyridine) is used as a carboxylic activating agent. We can attempt to do that for your structure, too. If we compare the two we see — of course — that a lot of features are identical. The principal differences are:
A has a trisubstituted double bond while B only as a disubstituted (and terminal) double bond
B has a secondary carbocation while A has a primary one (both, however, are allylic). | {
"domain": "chemistry.stackexchange",
"id": 16013,
"lm_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, stability, resonance, carbocation",
"url": null
} |
planet, solar-system, positional-astronomy, planetary-systems, alignment
Is this really true? I like to imagine that the planets are actually in weird alignment to each other, for example, maybe Venus is 50,000Km below earths bottom etc It is impossible to have the planets line up like in your image. This is done for illustration purposes only. If such an image was to scale, either the bodies would be extremely small and impossible to see, or the image would be extremely large and impractical to use.
For example, the Sun is about 1,392,000 km in diameter. The Earth is about 12,756 km in diameter (so roughly 110x smaller), and orbits at an average distance of roughly 149,600,000 km. If the Sun was a 40 cm ball, the Earth would be about 3.6 mm in diameter and located roughly 43 m away from the Sun-ball. At that same scale, Neptune is about 1,3 km away. (Before COVID, I regularly hosted “Solar System Walks” for the city of Montréal, and that was the size of my scale model.)
Now to get back to “lining up” planets… Let’s define a reference plane: the ECLIPTIC is the plane of Earth’s orbit around the Sun. All the other planets have orbits tilted with respect to that plane. For example, Mercury’s orbit is tilted 7° to the ecliptic, and Venus’ orbit 3.4°.
So there IS a point on a planet’s orbit where it lies on the same plane as the Earth—it’s called a NODE, and there’s an ASCENDING NODE, where the planet crosses from “below” (south of) the ecliptic to “above” (north of) it as well as a DESCENDING NODE where the planet goes from above to below.
HOWEVER…
1-The Earth is not necessarily in line with the Sun and the planet at that moment (explaining, for example, how the passage of Venus in front of the Sun is such a rare event [last ones were in 2004 and 2012; next ones will be in 2117 and 2125]);
2-Planets don’t [necessarily] cross the ecliptic plane as the same time as other planets; and | {
"domain": "astronomy.stackexchange",
"id": 5008,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "planet, solar-system, positional-astronomy, planetary-systems, alignment",
"url": null
} |
python, beginner, python-3.x
return partners, trends
check_partners_trends()
# Write to the report file
file.write("Report for company: " + name)
file.write("\nWKN: %s\tSymbol: %s\nISIN: %s\tSector: %s" % (wkn, symbol, isin, sector))
file.write("\n\nEvaluated: %s\nAt: %s\n\n\n" % (date, time)) # first \n for new line, second \n for one blank line
file.write(name + " is currently trading at: " + locale.currency(current_price, grouping=True))
file.write("\nEPS: %s\n\t--> The higher the better\nP/E: %s\nMarket capitalization: %s" % (eps, pe, locale.currency(market_cap, grouping=True)))
file.write("\n\nIt has the following partners: %s\nAnd is participating in the trend: %s" % (partners, trends))
print("\n__________")
print("Income Statement Analysis")
print("__________\n")
# Check income numbers
while True:
try:
total_revenue = float(input("Total Revenue: "))
gross_profit = float(input("Gross profit: "))
operating_expenses = float(input("Operating expenses: "))
cost_of_revenue = float(input("Cost of revenue: "))
net_income = float(input("Net income: "))
ebit = float(input("EBIT: "))
ebitda = float(input("EBITDA: "))
break
except ValueError:
print("please enter only numbers without comma and use . for decimals (e.g. 5.55 instead of 5,55")
continue
income_red_flags = 0 | {
"domain": "codereview.stackexchange",
"id": 39510,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, beginner, python-3.x",
"url": null
} |
c++, performance, c++17, machine-learning, numerical-methods
// Compute the cross entropy and optionally its derivative with respect to y_hat.
double cross_entropy(const int y, const double& y_hat, double* dy_hat=nullptr) {
const double ret = - (y * std::log(y_hat) + (1 - y) * std::log(1 - y_hat));
if (dy_hat) {
*dy_hat = (y / (1 - y_hat)) + ((1 - y) / y_hat);
}
return ret;
};
// Compute the dot product and optionally its derivative with respect to w.
template<int size>
double dot_product(const Vec<size>& w,
const Vec<size>& x,
Vec<size>* dw=nullptr) {
double ret = 0.0;
for (size_t i = 0; i < w.size(); ++i) {
ret += w[i] * x[i];
}
if (dw) {
*dw = x;
}
return ret;
} | {
"domain": "codereview.stackexchange",
"id": 38514,
"lm_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++17, machine-learning, numerical-methods",
"url": null
} |
taxonomy, history
Title: How many species did Carl Linnaeus classify? How many species did Carl Linnaeus (senior) classify? More than 13,000.
Plants: >9,000 names.
In Systema Naturae 10th edition, commonly taken as the starting point of modern taxonomy, Linnaeus is reported to have published around 6,000 plant names (I haven't counted, but Müller-Wille gives 5,900 and Stearn says "almost 6,000". The Wikipedia figure of 7,700 may come from a different edition of Systema Naturae).
However, that's just SN10. Luckily, a wonderful source has compiled the names from all of Linnaeus's work:
The Linnaean Plant Name Typification Project of the Natural History Museum says that Linnaeus published more than 9,000 valid plant names in his life (names that are still valid under current nomenclatural conventions), and they have many of them in a searchable database with references to where Linnaeus published them.
Animals: >4,200 names.
For SN10, different authors give 4,236 or 4,378 animal names. Stearn says "nearly 4,400", so perhaps he too was unsure. The total number Linnaues described in his life is probably higher, as he did write separate zoological publications like Fauna Svevica, but I couldn't find a source like the project bringing together all of his animal names.
Müller-Wille S. 2006. Linnaeus' herbarium cabinet: a piece of furniture and its function. Endeavour 30: 60–64.
Stearn WT. 1959. The Background of Linnaeus's Contributions to the Nomenclature and Methods of Systematic Biology.) | {
"domain": "biology.stackexchange",
"id": 1682,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "taxonomy, history",
"url": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.