text:
# Change Background Color of Code Block for org-mode LaTeX export

I'm inserting code fragments in an org-mode document like this:

#+CAPTION: My Caption
#+NAME: fig:figure_name
#+BEGIN_SRC a_language
My code ...
#+END_SRC

In PDF LaTeX export, the code blocks are not easily distinguished from the main text. Ideally, I would like to have a bounding box and/or a light gray background, similar to how Stack Exchange sets apart snippets of code. I've tried changing the LaTeX background color org-mode option, but it didn't seem to do what I want. Is there any easy way to accomplish this?

• Thanks for asking this, this question reminded me, that I had to figure out how this works. :)
– jue
Feb 25, 2020 at 20:41

This is a solution using latex package lstlisting instead of minted
(lstlisting is not so powerful as minted but does not need a whole python stack).

You need to put following lisp code into your Emacs init.el (or try it in *scratch* buffer like I did.

(setq org-latex-listings t)

These lines load the latex packages listings and color and advice org mode to export code block using the listings latex package.

After that you can write your code block that way:

#+CAPTION: Caption, my caption!
#+ATTR_LATEX: :options frame=single,backgroundcolor=\color{lightgray}
#+BEGIN_SRC C :results output :exports both
int i, x = 10;
for(i = 0; i < x; i++)
printf("%d ",i);
printf(" ~ %d\n", x);
#+END_SRC

Notice the extra line of
#+ATTR_LATEX: :options frame=single,backgroundcolor=\color{lightgray},
which defines a frame around the source code and a background color.

Above settings should produce following lines (among others) in the resulting .tex file:

...
\usepackage{color}
\usepackage{listings}
...
\lstset{language=C,label= ,caption={Caption, my caption!},captionpos=b,numbers=none,frame=single backgroundcolor=\color{lightgray}}
\begin{lstlisting}
int i, x = 10;
for(i = 0; i < x; i++)
printf("%d ",i);
printf(" ~ %d\n", x);
\end{lstlisting}

Remark: in older Org-Versions (v8 and older) #+ATTR_LATEX uses another syntax. Space () instead of = is used. The #+ATTR_LATEX needs to be changed slightly. Read more at the question org ignores attr latex

Note: here is another solution, using minted: https://stackoverflow.com/a/60396939


text:
# Difference between revisions of "2005 AMC 10B Problems/Problem 20"

## Problem

What is the average (mean) of all -digit numbers that can be formed by using each of the digits 1, 3, 5, 7, 8 and exactly once?

$\mathrm{(A)}48000\qquad\mathrm{(B)}49999.5\qquad\mathrm{(C)}53332.8\qquad\mathrm{(D)}55555\qquad\mathrm{(E)}56432.8$

## Solution

We first look at how many times each number will appear in each slot. If we fix a number in a slot, then there are $4! = 24$ ways to arrange the other numbers, so each number appears in each spot $24$ times. Therefore, the sum of all such numbers is $24 \times (1+3+5+7+8) \times (11111) = 24 \times 24 \times 11111 = 6399936$ Since there are $5! = 120$ such numbers, we divide $6399936 \div 120$ to get $\boxed{\mathrm{(C)}53332.8}$

format: plain


text:
# 過端午玩第五《第五人格》 端午節活動歡樂展開

.

.

.

.

.

.

.

.

.

.

## 173 thoughts on “過端午玩第五《第五人格》 端午節活動歡樂展開”

1. Hello, i think that i saw you visited my site so i came to â€œreturn the favorâ€.I’m attempting to find things to improve my website!I suppose its ok to use a few of your ideas!!|


text:
# Singular currents in graphene

Amongst the many extraordinary properties of graphene, its giant diamagnetic response at zero doping, predicted in the 1950s, had to this day not been measured directly. By controlling the doping of a nearly defect-free graphene sheet and using ultra-sensitive giant magnetoresistance sensors, physicists have for the first time demonstrated this magnetic singularity.

Electrons in a magnetic field follow circular orbits, generating a magnetic moment that opposes the magnetic field. This effect gives rise, in its quantum version, to the well-known Landau diamagnetism of conducting materials. This orbital magnetism has long been known to depend on the specific crystalline and electronic structure of the material considered. It has more recently been noted that the electronic wavefunction acquires a phase in the course of the electron’s motion. This phase, of geometrical origin, called the Berry phase, reflects the crystal symmetries, and affects the sign of the magnetic response.

In the case of graphene, the electronic structure possesses a remarkable feature, the Dirac point, where two cone-shaped energy bands meet, where the electrons behave as if their mass were zero. As early as 1956, a diamagnetic divergent orbital response was predicted when the chemical potential coincides with the Dirac point energy, i.e. when the lower band is completely filled with electrons and the upper band completely empty (figure). This prediction is surprising, since the electron density is minimal precisely at this Dirac point. The response can be understood considering the p Berry phase of graphene, which causes a negative orbital response, thus opposing the magnetic field and hence diamagnetic. Moreover, this phase also enters in the quantization of the Landau energy levels, leading to a level at the Dirac point energy, thus creating a non-zero density of states at this point. The first experimental evidence of this magnetic singularity has just been provided by a collaboration between physicists from the Laboratoire de Physique des Solides in Orsay (LPS, CNRS/Université Paris-Saclay), using an ultrasensitive measurement of the magnetization of a practically defect-free crystalline flake of graphene a few microns in size, and controlling the electron density around the Dirac point with an electrostatic field. This study is published in the journal Science. See also the News and Views (in French) published on the CNRS website.

Figure. (Left) Schematic of the two cone-shaped bands at the Dirac point: the electronic energy E is shown as a function of the vector characterizing momentum. The shaded areas indicate the electron filling, which defines the chemical potential (μ). When μ = μDD energy at the Dirac point), the lower band is completely filled and the upper band completely empty. The blue curve represents the diamagnetic peak of the orbital magnetic moment (Morb) measured when μ = μD. (Right) Schematic of the experimental setup that detected the diamagnetic anomaly in graphene at the Dirac point. The graphene sheet is protected by two layers of boron nitride (hBN) and placed on an alumina substrate. The arrows represent the exciting magnetic field (red), the orbital response of the electrons (blue) and the fields detected by the giant magnetoresistance sensors (green). The potential Vg is applied to a grid to control the chemical potential.

The measurement device consists of a pair of giant magnetoresistance (GMR) sensors fabricated at the SPEC laboratory (CEA/CNRS) which feature an extremely high sensitivity to the magnetic field generated by the orbital current loops induced in the graphene, all the while being insensitive to the magnetic field perpendicular to the graphene plane that generates those loops (figure). An electrostatic gate electrode, placed above the sample, controlled graphene’s chemical potential. The high susceptibility of graphene‘s magnetic response to doping was exploited by modulating the gate voltage periodically with time, and detecting the synchronous GMR signal. This achieved an optimal discrimination of the sought-after magnetic signal from the spurious noises of the experiment: the accuracy obtained is better than one millionth of the earth’s magnetic field. In addition, indeed, as the gate voltage was changed to bring the chemical potential in the range of the Dirac point, a diamagnetic peak was detected at the Dirac point, in agreement with theory. With increasing magnetic field, the peak width increases and periodic oscillations appear on both sides of the Dirac point, corresponding to de Haas-van Alphen oscillations, which are the signatures of other Landau energy levels.

These results open a whole new field of investigation of orbital currents in graphene and in two-dimensional topological materials. They offer a new tool to explore correlated electronic states generated by the combined effect of Coulomb interactions, strain and moiré potentials.

Reference
Detection of graphene’s divergent orbital diamagnetism at the Dirac point
J. Vallejo, N.J. Wu, C. Fermon, M. Pannetier-Lecoeur, T. Wakamura, K. Watanabe, T. Tanigushi, T.Pellegrin, A. Bernard, S. Daddinounou, V. Bouchiat, S. Guéron, M. Ferrier, G. Montambaux, H. Bouchiat
Science, 2021, 21, 10178-10185
doi: 10.1126/science.abf9396
Open Access repository: arXiv

News & Views from CNRS

Contact
Hélène Bouchiat


text:
# Superfluidity: separation of quantised vortices in a vortex tangle

It is often quoted (see https://doi.org/10.1016/j.piutam.2013.09.008) that the separation $\delta$ between quantised vortices in a vortex tangle in a superfluid is approximately

$$\delta \approx L^{-1/2}$$

where $\delta$ is the separation between the quantised vortices and $L = \frac{\Lambda}{V}$ is the vortex line density.

Where does this approximation come from? How can it be derived?

My initial thoughts are to use the Onsager-Feynman rule $n = \frac{2\Omega}{\kappa}$ where $n$ is the number of vortex lines per unit area, $\Omega$ is the angular velocity and $\kappa$ is the quantum of circulation. But beyond that I am unsure.

• Dimensional analysis? What are the other scales in the problem? – Ryan Thorngren Apr 13 '18 at 17:02
• I could use dimensional analysis, but I'd like to derive this algebraically e.g., by using the geometry of the vortex tangle. What do you mean by "other scales" in the problem? JG – Jack G Apr 13 '18 at 17:12
• If you slice the tangle with a plane, the question is whether this plane intersects each tangle an O(1) number of times. If so, then the formula follows. The only way this could fail is if other length scales (maybe like typical extrinsic curvature of the vortex loops) enter the game. – Ryan Thorngren Apr 13 '18 at 17:18
• Let's assume a basic model where there's no other length scales. What is O(1)? – Jack G Apr 13 '18 at 17:33
• Order 1. That is, a constant that doesn't change much as we vary system parameters. Then the formula just follows from a scaling argument. The danger is that even in a simple model, length scales like typical extrinsic curvature can appear seeming out of nowhere (but are really reflecting some microscopic length scale). By the way above I mean the slice intersects a single loop an O(1) number of times. – Ryan Thorngren Apr 13 '18 at 17:55

Q: "Where does this approximation come from?"

I couldn't find a free link for the originator's work, but here's the PayWall:

"Three-dimensional vortex dynamics in superfluid $^4$He: Homogeneous superfluid turbulence", by K. W. Schwarz, in Phys. Rev. B 38, 2398 – Published 1 August 1988

See also Andrew Baggaley's WikiDot page: "Quantum Turbulence (old)" and it's link: "Non-linear Dynamics Lab", and his new version of that webpage: "Quantum Turbulence".

Q: "How can it be derived?"

See: "Vortex density spectrum of quantum turbulence" (The .PDF at arXiv seems corrupted, try here.), by Roche, or "Velocity Statistics Distinguish Quantum Turbulence from Classical Turbulence" by Paoletti or "Coherent vortex structures in quantum turbulence", by Baggaley, page 2:

"The Biot–Savart interactions of vortex lines over length scales larger than the average inter-vortex distance $ℓ ≈ L^{−1/2}$ has induced the same Kolmogorov energy spectrum $E(k) ∼ k^{−5/3}$ (for $k ≪ k_ℓ = 2π/ℓ$) which is observed in ordinary turbulence. The Kolmogorov spectrum was also observed in experiments with turbulent super-fluid helium, and in calculations performed with both the vortex filament mode and the Gross–Pitaevskii equation".

Each of those works contain numerous formulas and references. Unfortunately I don't have time to MathJax all the details ATM. I can revisit this in a few hours if needed.

A further reference is the "Quantum Turbulence" section of "Vortex filament method as a tool for computational visualization of quantum turbulence", by Risto Hänninen and Andrew W. Baggaley, page 4:

"Counterflow Turbulence

The earliest experimental studies of QT were reported in a series of groundbreaking papers by Vinen in the 1950s. In these experiments, turbulence was generated by applying a thermal counterflow, in which the normal and superfluid components flow in opposite directions. This is easily created by applying a thermal gradient, e.g., by heating the fluid at one end. The most common diagnostic to measure is the vortex line density, $L=Λ/V$, where $Λ$ is the total length of the quantized vortices and $V$ is the volume of the system; from this, one can compute the typical separation between vortices, the inter vortex spacing $ℓ≈L^{−1/2}$. This can readily be measured experimentally using second sound, and higher harmonics can probe the structure of the tangle. Numerical simulations have played a crucial role in visualizing the structure of counterflow turbulence and probing the nature of this unique form of turbulence; indeed, it has no classical analog. Some of the very earliest studies using the VFM were performed by Schwarz; however, computational limitations forced him to perform an unphysical vortex mixing procedure. A more recent study by Adachi et al. made use of modern computational power and studied the dependence of the steady-state vortex line density on the heat flux of the counterflow. Within the parameter range of the study, there was good agreement with experimental results, vindicating the use of the VFM for counterflow turbulence."

Again, the quoted text contains references to papers where further information on the derivations can be found.

• Thank you very much for the additional references. They've helped a lot! – Jack G Apr 21 '18 at 10:48


text:
# Area Bounded by Polar Curves

I am answering sample exams for my Calculus class and my attention was caught by the following item.

Set-up the definite integral or sum of definite integrals equal to the area of the region above the polar axis, inside the limaçon $r = 3 + 2 \sin \theta$ and outside the lemniscate $r^2 = 32 \cos 2\theta$ given that the two curves intersect at $(4,\frac{\pi}{6})$.

At first, I thought that the area is given by $$\dfrac{1}{2} \int_{\frac{\pi}{6}}^{\frac{5\pi}{6}}{[(3 + 2\sin \theta)^2 - (32 \cos 2\theta)] \mathrm{d}\theta}$$ but I know that the area of the lemniscate is tricky so I may have given a smaller area.

My question is this: How do you know the limits of integration for lemniscates? (I know that the limits of integration for the area of the lemniscate alone is from $-\frac{\pi}{4}$ to $\frac{\pi}{4}$, but how about for small portions of the curve?)

I'll appreciate any help. Thank you so much.

-

There was lemniscate trouble, as you feared. Up to $\theta=\frac{\pi}{4}$, everything was fine. But from $\frac{\pi}{4}$ and for quite a while (up to $\frac{3\pi}{4}$), $\cos 2\theta$ is negative, so $r^2$ is negative and there is no curve. The integral doesn't know and doesn't care: it cheerfully "adds up" these negatives, giving the wrong answer.

So for the limaçon part, if you do things in your style, you will have to break up the limaçon integral into two integrals, $\frac{\pi}{6}$ to $\frac{\pi}{4}$ and then $\frac{3\pi}{4}$ to $\frac{5\pi}{6}$.

Since the integrals for the lemniscate and the limaçon are over different intervals, we cannot express their difference as a single integral.

What I would do is to use the symmetry, take the right-half of the region and multiply the resulting area by $2$. The limaçon part to be subtracted uses the integral from $\frac{\pi}{6}$ to $\frac{\pi}{4}$.

So there is $\frac{1}{2}$ as in your formula, but ultimately we multiply by $2$, so our area is $$\int_{\pi/6}^{\pi/2}(3+2\sin \theta)^2\,d\theta-\int_{\pi/6}^{\pi/4}32\cos 2\theta\,d\theta.$$

More pleasant, fewer minus signs to worry about!

-
Would you say I got it when I said the limits of integration has something to do with the polar tangents? –  Gelo Jacamile Aug 6 '12 at 12:53
@GeloJacamile: First please note I had a typo (corrected) in the displayed integral, for the limaçon we start at $\pi/6$. We do have that the line $\theta=\frac{\pi}{4}$ is tangent to the curve, but the real issue is that there is no curve, but $r^2$ is still meaningful to the integral. –  André Nicolas Aug 6 '12 at 13:06
Thank you. This really helped. –  Gelo Jacamile Aug 7 '12 at 7:27


text:
## categories – Is it possible to attach a page to a category similar to how we attach media to a post?

Question

No, media is attached to posts/pages using the post_parent column. This works because media is actually a post of type attachment in the database.

Categories however are not posts, and the way you would attach them is by assigning the page to that category.

This leads us to a contradiction, how do you attach a page to a category without attaching it to a category?

I’m sure that your original problem is solvable but this is not the solution.

0
1 month 2021-12-06T10:22:18-05:00 0 Answers 0 views 0


text:
# How do I do basic hypothesis testing in a Bayesian framework?

This seems like it should be a widely-answered, but I've spent a lot of time searching and reading textbooks and have not been able to figure it out.

Let's say I give my exciting new treatment pill to a random sample of N people and a placebo pill to a random sample of M people. A of the N people die and B of the M people die. I'd like to know the probability that more people die taking the placebo than the treatment.

Currently I do:

> data <- matrix(c(A,B,N-A,M-B), nrow=2)
> chisq.test(data, correct=FALSE)

and look at the p-value (which I realize isn't actually the answer to my question, but that's frequentists for you). And if I want to know the interval there's a 95% chance the actual value is in, I just do:

> pbar = A/N; se = sqrt(pbar * (1-pbar)/N); e = qnorm(.975)*se; pbar + c(-e, e)

But I want the Bayesian equivalents. Now I know I can compute a Beta distribution with a uniform prior and then use Monte Carlo sampling to figure out the answers, but that seems hackish and inefficient. What's the more direct way to compute the answer?

-
Note that in this specific example the p-value is all you need, provided you ignore your prior information about the two death rates. The Bayesian Hypothesis basically gives you a different way to choose the significance level. –  probabilityislogic Jan 5 '13 at 13:22
Given your question is about life/death type of information, I would have thought taking a representative sample is way more important than bayes vs frequentist differences. Random sampling does not gaurantee you this in the specific case. This is part of that prior information I was talking about, where you control for known causes/differences between the people who survive and the people who die (age is usually an obvious example). –  probabilityislogic Jan 5 '13 at 14:01

Well you could calculate the bivariate beta distribution of the posteriors of the 2 parameters (independent assumption seems reasonable), then find the distribution of the difference and see what the area greater than 0 is (or less than depending on the direction of interest).

Personally I think it would be more efficient (at least for me compared to looking up and remembering how to compute the distribution of the difference) to generate a bunch of observations from each of the beta posteriors, pair them up, and see what proportion have the one value in each pair being greater. Yes it is a bit hackish, but you make that sound like a bad thing when I don't think it is.

-

To take the second question first - what is a 95% credibility interval (no longer a confidence interval, now we are in the Bayesian world) for the probability that a person receiving the treatment will die (this seems to be the "actual value" you are calculating a confidence interval for in your line of code starting > pbar = A/N;).

As you seem to be aware, Laplace favoured using a uniform prior distribution (with p taking a value in [0,1]) for this sort of problem with proportions. A uniform distribution over [0,1] is a beta(1,1) distribution, which has the advantage of being a conjugate prior distribution for p; ie once you modify the distribution based on your observation, the resulting posterior distribution will have the same form as the prior - a beta distribution of some sort. Any textbook will show that this means the posterior distribution for p will be beta (A+1, N-A+1). From here you can just use this distribution as the basis for calculating your credibility interval - there is no need to use monte carlo techniques so long as you have access to tables or software that can calculate the relevant values from the beta distribution.

This will generally give you similar results to your frequentist approach relying on the central limit theorem for the distribution of pbar to approximate normal, as in your code snippet. See for example:

> options(digits=3)
> A <- 100
> N <- 10000
>
> # Frequentist approach, using approximation to Normal:
> pbar = A/N; se = sqrt(pbar * (1-pbar)/N); e = qnorm(.975)*se; pbar + c(-e, e)
[1] 0.00805 0.01195
>
> # Bayesian approach, with uniform prior:
> qbeta(c(0.025, 0.975), A+1, N-A+1)
[1] 0.00823 0.01215

Now, things are a little more complicated if you're really interested in the difference (not in what your one line snipped had) ie you want the posterior distribution and hence a credibility interval for the difference in probability of dying between the treatment and control populations, but the principles are the same. As you suggest and Greg Snow says in his answer, if you can't be bothered calculating the exact posterior distribution of the difference between the propostions why not use simulation? Certainly there's less paperwork involved; and it has the advantage of being easily extendible to more complex comparisons of the estimated posterior distributions of independent parameters:

> A <- 100
> N <- 10000
> B <- 200
> M <- 10000
> sim <- rbeta(10000, B+1, M-B+1) - rbeta(10000, A+1, N-A+1)
> quantile(sim, c(0.025, 0.975))
2.5%  97.5%
0.0067 0.0134
> plot(density(sim), bty="l", main="Posterior distribution of difference\nbetween the proportions")
> abline(v=quantile(sim, c(0.025, 0.975)), lty=2)

Your first question was about hypothesis testing. Typically choosing between two hypotheses is done by comparing the posterior and prior odds ratios of the two hypothesis ie by calculating the Bayes factor:

$\frac{P(H_0|z)/P(H_1|z)}{P(H_0)/P(H_1)}$

where z is the observed data.

From here it gets a little complicated. Exactly how the two hypotheses are formulated is important - in a case such as yours it will generally be necessary to have $H_1$ indicating the treatment proportion is more than a specified amount different than the original - because under the prior distribution of the continuous random variable p the chance of any exact equivalence of the two is zero (a problem with "sharp" hypotheses). I'd consult a text to see how this plays out, but hopefully this was enough to get you started.

-
Good Q&A on hypothesis testing here: stats.stackexchange.com/questions/31679/… –  Peter Ellis Jan 5 '13 at 1:51
Note that if you read the OP's question carefully/pedantically, their hypothesis is actually discrete and so is their parameter space as the question asks about whether more people in the population would die from taking the placebo. –  probabilityislogic Jan 5 '13 at 13:54
Sorry if I wasn't clear, bit I do want to calculate the answer exactly, not simulate it. –  aaronsw Jan 5 '13 at 15:27
@aaronsw you've got too many questions for 1 question I think. I see your 3 questions as: what is a credibility region for a point estimate of the proportion of people with the treatment who die (which is what you have done the frequentist confidence interval for, and I've given that); what is a credibility region for the difference between the treatment and control proportions (which reduces to the distribution of one Beta distributed random variable minus another Beta distributed random variable - if you want the exact distribution it will be complex); and how to do the hypothesis test. –  Peter Ellis Jan 5 '13 at 17:15
@probabilityislogic good point; but it also depends on how 'population' is being used. If it is meant to include people not yet born you might say that it is still infinite, or at least very large and unknown number? –  Peter Ellis Jan 5 '13 at 17:19


text:
We know that a line consists of infinite number of points. When we draw a picture on a sheet of paper, we draw it such that it is at a fixed distance from a fixed point called the origin. The drawing is made up of many curves and straight line which consists of infinite number of points and each point is unique. The points with respect to the fixed origin can be represented in the form of ordered pairs (x, y), where x and y are real numbers.

How do we divide the plane into quadrants? How  do we plot the points in the coordinate plane? What are the positive and negative sides of coordinate axis? Let us study this in detail in the following sections.

## Cartesian Coordinates Definition

The points are represented on a number line or on a two dimensional graph sheet or in a three dimensional plane. The representation of points on the different planes are called cartesian planes which is named after the Greek Mathematician Descarte's Cartesian.

We know that the numbers are represented on the real number line. Therefore, the representation of points on the number line is called the one-dimensional plane.

Representation of points in ordered pairs (x, y) in graph sheets or checked sheets is called two dimensional planes. This contains a "Horizontal line" called x-axis and the "Vertical line" called the y-axis.

The two dimensional graph is divided into four parts, each one is called a quadrant, which is shown below. The following figure shows the different quadrants and the sign of the ordered pairs in each quadrant:

Representation of points in the form (x, y, z) in space is called the three dimensional planes. In the case of three dimensional plane, it is the intersection of three planes which are divided into 8 parts called octant.

## Cartesian Coordinate System Definition

In the cartesian coordinate system of two dimensions, we represent each point in the form of an ordered pair (x, y), where x is a point on the x-axis and y is the point on the y-axis.

The following graph shows the representation of the points (4,5), (6, 0) and (0, -3):

To plot the point (4, 5), we look for the number 4 on the x-axis and the number 5 on the y-axis. The point where these two lines from x and y axis meet is the required point (4, 5).

To locate the point (6, 0), we look for 6 on the x-axis. Since y is 0 on the entire x-axis, the point (6, 0) is the point 6 on the x-axis.

To locate the point (0, -3), we should know that the x-coordinate is zero on the y-axis. Hence, we locate -3 on the y-axis, which has its coordinate (0, -3) on the two dimensional coordinate plane.

## Cartesian Coordinate Graph

Coordinate means the pair of points which is located on the two dimensional plane. It contains the horizontal line called the x-axis and the vertical line called y-axis.

The point of intersection of the x and y-axis is called the origin whose coordinate is (0, 0).

X and Y axis are two real number lines which have the common origin 0. The real numbers to the right of 0 (on the x-axis) are positive and those which are on the left 0 (on the x-axis) are negative. Similarly, the numbers which are above 0 (on the y-axis) are positive and those which are below 0 (on the y-axis) are  negative.

The following figure shows the positive and negative real numbers on the x and y axis of the co-ordinate plane:

### Coordinates of Points on the x- and y-axis:

On the x-axis, y-coordinate is zero.
Hence, the coordinate form of the points on the x-axis is (x, 0).

On the y-axis, the x-coordinate is zero.
Hence, the coordinate form of the points on the y-axis is (0, y).

The following figure shows the points on the x and y axis:

### Location of Coordinates of the Form (x, y) on the Graph, where x $\neq$ 0 and y $\neq$ 0:

While locating the required points which are unique on the coordinate plane, we look for the corresponding real number on the x and y axis respectively. The intersection of the vertical line from the x-axis and the horizontal line from the y-axis is the required point in the coordinate plane.

The following figure shows the location of the points (3, 5), (-3, 5), (-4, -5) and (6, -4) which are in different quadrants.

The cartesian coordinate plane is divided into four quadrants as shown in the graph below:

The signs of the coordinates in each quadrants are as follows :

Let us identify the quadrant in which each of the following points are located:
• (5, -6) - Since x-coordinate is positive and y-coordinate is negative, the point will be in the fourth quadrant.
• (-2, 5) - Since x-coordinate is negative and y-coordinate is positive, the point will be in the second quadrant.
• (5, 5) - Since x-coordinate is positive and y-coordinate is positive, the point will be in the first quadrant.
• (-4, -7) - Since both x and y coordinates are negative, the point will be in the third quadrant.

## Cartesian Coordinate System Examples

Given below are some of the examples in cartesian coordinate system.

### Solved Examples

Question 1: Write the ordered pairs for each of the following:
1. x coordinate is 8 and the y coordinate is -4.
2. y coordinate is 4 and the x coordinate is -5.
3. The point which is in the second quadrant and is at a distance of 5 units from the x-axis and 5 units from the y-axis.
4. The point on the y-axis which is at a distance of 4 units from the origin lying on the negative side of the y-axis.
5. The point on the x-axis, which is at a distance of 3.5 units from the origin lying on the positive side of the x-axis.

Solution:
1. x coordinate is 8 and the y coordinate is -4.  Solution: (8, -4)
2. y coordinate is 4 and the x coordinate is -5. Solution: (-5, 4)
3. The point which is in the second quadrant and is at a distance of 5 units from the x-axis and 5 units from the y-axis. Solution: Since the point is in the second quadrant, the ordered pair should be ( -, + ). Therefore, (-5, 5).
4. The point on the y-axis which is at a distance of 4 units from the origin lying on the negative side of the y-axis. Solution: For any point on the y-axis, x-coordinate is 0. Therefore, the point is (0, -4).
5. The point on the x-axis, which is at a distance of 3.5 units from the origin lying on the positive side of the x-axis. Solution: The y-coordinate on the x-axis is 0. Therefore, the point on the x-axis is (3.5, 0).

Question 2: Identify the quadrant in which the following points are located:

1. (2, -1)
2. (8, 9)
3. (-2, -1)
4. (-3, 3)

Solution:
1. ( 2, -1)   According to the sign in each quadrant, the sign of the point (2, -1) is (+, -) which corresponds to 4th quadrant. Therefore, point will be in the 4th quadrant.
2. (8, 9) According to the sign in each quadrant, the sign of the point (8, 9) is (+, +) which corresponds to 1st quadrant. Therefore, the point will be in the 1st quadrant.
3. (-2, -1)
According to the sign in each quadrant, the sign of the point (-2, -1) is (-, -) which corresponds to 3rd quadrant. Therefore, the point will be in the 3rd quadrant.
4. (-3, 3)
According to the sign in each quadrant, the sign of the point (-3, 3) is (-, +) which corresponds to 2nd quadrant. Therefore, the point will be in the 2nd quadrant.

Question 3: Plot the points, A(1, 3), B(4, 3), C(5, 7) and D(8, 7) on the graph sheet and join the points to obtain the quadrilateral ABCD. Measure the length of each side of the quadrilateral. Write the special name of the quadrilateral.
Solution:

In the above graph we, observe that the sides AB = BC = 3 units and AB // BC. Also, AD = BC = 5 units and AD // BC.
Therefore, the above quadrilateral ABCD is a parallelogram.


text:
Browse Questions

# A thin hollow sphere of mass $'m'$ is completely filled with a liquid of mass $'m'$. When the Sphere rolls with a velocity $'c'$, kinetic energy of the system is (neglect friction):

$\begin {array} {1 1} (a)\;\frac{1}{2}\;mv^2 & \quad (b)\;mv^2 \\ (c)\;\frac{4}{3}\;mv^2 & \quad (d)\;\frac{4}{5}\;mv^2 \end {array}$
Can you answer this question?

$(c)\;\frac{4}{3}\;mv^2$
answered Nov 7, 2013 by


text:
# Week 2-3 - Functions & Limits

## Functions

• Deﬁnition: A function f is a rule that assigns to each element x in a set D exactly one element, called $f(x)$, in a set E.

• The set D is called the domain of the function.
• The number $f(x)$ is the value of f at x and is read “f of x”.
• The range of f is the set of all possible values of $f(x)$ as x varies throughout the domain.
• A symbol that represents an arbitrary number in the domain of a function f is called an independent variable. A symbol that represents a number in the range of f is called a dependent variable.
• Four ways to represent a functions

• verbally (by a description in words)
• numerically (by a table of values)
• visually (by a graph)
• algebraically (by an explicit formula)
• A catalog of essential functions

• linear function

• $f(x) = mx+b$
• polynomials

• $P(x)=a_{n}x^{n}+a_{n-1}x^{n-1}+a_{n-2}x^{n-2}+...+a_{2}x^{2}+a_{1}x^{1}+a_{0}$
• The domain of any polynomial is $\mathbb{R} = (-\infty, + \infty)$.
• If the leading coefficient $a_{n}\ne 0$, then the degree of the polynomial is n.
• n=2: quadratic function
• n=3: cubic function
• power function

• $f(x) = x^a$
• a = n, where n is a positive integer
• a = 1/n, where n is a positive integer. It’s a root function.
• a = -1: reciprocal function
• rational function

• A rational function f is a ratio of two polynomials:
• $f(x)=\frac{P(x)}{Q(x)}$, $\{Q(x)\ne0\}$
• $f(x)=\frac{2x^{4}-x^{2}+1}{x^{2}-4}$, $\{x|x \ne \pm 2\}$:
• algebraic function

• A function f is called an algebraic function if it can be constructed using algebraic operations (such as addition, subtraction, multiplication, division, and taking roots)
• trigonometric function

• $f(x)=\sin{x}$
• exponential function

• $f(x)=b^x$
• law of exponential function:
• $b^{x+y}=b^x+b^y$
• $b^{x-y}=\frac{b^x}{b^y}$
• $(b^{x})^{y}=b^{xy}$
• ${ab}^{x}=a^{x}b^{x}$
• logarithmic function

• $f(x)=\log_{b}{x}$

### Combinations of Functions

• $(f+g)(x)=f(x)+g(x)$
• $(f-g)(x)=f(x)-g(x)$
• $(fg)(x)=f(x)g(x)$, the domain of fg is $A \cap B$
• $(\frac{f}{g})(x)=\frac{f(x)}{g(x)}$, the domain of f/g is $\{x \in A \cap B\ |\ g(x) \ne 0\}$.
• $(f \circ g)(x) = f(g(x))$
• composition (or composite) of f and g, denoted by $f \circ g$ (“f circle g”).

### Inverse of Functions

• Definition:
• If a function maps every input to exactly one output, an inverse of that function maps every “output” to exactly one “input.”
• denoted by$f^{-1}$ , and read “f inverse”.
• to function $N=f(t)$, the inverse function will be $t=f^{-1}(N)$.

#### one-to-one functions

• A function is one-to-one if for every value in the range(f(x)), there is exactly one value in the domain(x).
• domain of $f^{-1}$ = range of $f$
• range of $f^{-1}$ = domain of $f$
• for example: $f(x)=x^3$ is a one-to-one function, $f(x)=x^2$ is not.

## Limits

• Definition:
• $\displaystyle\lim_{x \to a}{f(x)}=L$
• the limit of f(x), as x approaches a, equals L
• if we can make the values of f(x) arbitrarily close to L (as close to L as we like) by restricting x to be sufficiently close to a (on either side of a) but NOT equal to a.(This means that in finding the limit of f(x) as x approaches a, we never consider x = a.)

### Limit Laws

• Suppose that c is a constant and the limits $\displaystyle\lim_{x \to a}{f(x)}$ and $\displaystyle\lim_{x \to a}{g(x)}$ exist, Then:

1. $\displaystyle\lim_{x \to a}{[f(x)+g(x)]}=\lim_{x \to a}{f(x)}+\lim_{x \to a}{g(x)}$
2. $\displaystyle\lim_{x \to a}{[f(x)-g(x)]}=\lim_{x \to a}{f(x)}-\lim_{x \to a}{g(x)}$
3. $\displaystyle\lim_{x \to a}{cf(x)}=c\lim_{x \to a}{f(x)}$
4. $\displaystyle\lim_{x \to a}{[f(x)g(x)]}=\lim_{x \to a}{f(x)}\cdot \lim_{x \to a}{g(x)}$
5. $\displaystyle\lim_{x \to a}{\frac{f(x)}{g(x)}}=\frac{\displaystyle\lim_{x \to a}{f(x)}}{\displaystyle\lim_{x \to a}{g(x)}}$, if $\displaystyle\lim_{x \to a}{g(x)} \ne 0$
• These five laws can be stated verbally as follows:

1. Sum Law : The limit of a sum is the sum of the limits.
2. Difference Law : The limit of a difference is the difference of the limits.
3. Constant Multiple Law : The limit of a constant times a function is the constant times the limit of the function.
4. Product Law : The limit of a product is the product of the limits.
5. Quotient Law : The limit of a quotient is the quotient of the limits (provided that the limit of the denominator is not 0).

### Squeeze Theorem

• if $g(x) \le f(x) \le h(x)$ and $\displaystyle\lim_{x\to{a}}g(x) = \lim_{x\to{a}}h(x) = L$, then $\displaystyle\lim_{x\to{a}}f(x)=L$
• Sample: to prove $\displaystyle\lim_{x\to{0}}\frac{\sin(x)}{x}=1$
• we know:
• $\displaystyle\lim_{x\to{0}}\cos(x)=1=\lim_{x\to{0}}1$
• $\cos(x) \le \frac{\sin(x)}{x} \le 1$
• then:
• $\displaystyle\lim_{x\to{0}}\cos(x) \le \lim_{x\to{0}}\frac{\sin(x)}{x} \le 1$
• so:
• $\displaystyle\lim_{x\to{0}}\frac{\sin(x)}{x}=1$

### Continuity

• Definition 1:
• A function f is continuous at a number a, if $\displaystyle\lim_{x \to a}f(x)=f(a)$
• Notice that this Definition implicitly requires three things if f is continuous at a:
1. f(a) is defined (that is, a is in the domain of f)
2. $\displaystyle\lim_{x \to a}f(x)$ exists
3. $\displaystyle\lim_{x \to a}f(x) = f(a)$
• Definition 2:
• A function f is continuous from the right at a number a if $\displaystyle\lim_{x \to a^{+}}f(x) = f(a)$, and f is continuous from the left at a if $\displaystyle\lim_{x \to a^{-}}f(x) = f(a)$
• Definition 3:
• A function f is continuous on the interval (a, b), if for all points c so that a < c < b, f(x) is continuous at c.
• close intervals:
• To say "f(x) is continuous on the interval [a, b]", means:
• f(x) is continuous on the interval (a, b)
• $\displaystyle\lim_{x \to a^{+}}f(x) = f(a)$
• $\displaystyle\lim_{x \to b^{-}}f(x) = f(b)$

#### The Intermediate Value Theorem

• Suppose that f is continuous on the closed interval [a, b] and let N be any number between f(a) and f(b), where $f(a) \ne f(b)$. Then there exists a number c in [a, b] such that $f(c) = N$.
• For example: how to approximate root two?
• use function $f(x)=x^2-2$
• when $x=\sqrt{2}$, this function equals 0,
• so i just need to look for a positive value, that I can plug into this function to make it equals zero.
• We know that f(1)=-1<0 and f(2)=2>0. So base on The Intermediate Value Theorem, there must be a value in domain (1, 2) that exist c such that f(c) = 0.
• to continue calculating f(1.5)=0.25>0, we got $c \in (1, 1.5)$, then $c \in (1.4, 1.5)$ … then we are getting closer and closer to $\sqrt{2}$.

#### Fixed Point

• Definition
• A fixed point of a function f is a number c in its domain such that f(c) = c. (The function doesn’t move c; it stays fixed.)
• if f(x) continuous on [0,1], and $0 \le f(x) \le 1$, then there is an x in domain [0, 1], exist f(x) = x.
• To Prove:
• Assumption: g(x) = f(x) - x, so g(x) is continuous
• g(0) = f(0) - 0 >= 0
• g(1) = f(1) - 1 <= 1
• Base on the IVT(Intermediate Value Theorem), there must be an x such that g(x) = 0, which is f(x) = x.

### Infinity

• Definition

• $\displaystyle\lim_{x \to a}f(x) = \infty$ means that f(x) is as large as you like provides x is close enough to a.
• $\displaystyle\lim_{x \to \pi/2}\tan(x) = \infty$
• $\displaystyle\lim_{x \to \infty}f(x) = L$ means that f(x) is close enough to L provided x is large enough.
• $\displaystyle\lim_{x \to \infty}\tan^{-1}(x) = \frac{\pi}{2}$
• if $\displaystyle\lim_{x \to \infty}f(x) = L$ or $\displaystyle\lim_{x \to -\infty}f(x) = L$, then the line y = L is called a horizontal asymptote of the curve y = f(x) :
• Potential Infinity vs Actual Infinity (from Wikipedia)

• Actual Infinity is the idea that numbers, or some other type of mathematical object, can form an actual, completed totality;
• Such as the set of all natural numbers, an infinite sequence of rational numbers.
• Potential Infinity is a non-terminating process (such as “add 1 to the previous number”) produces an unending “infinite” sequence of results, but each individual result is finite and is achieved in a finite number of steps.
• Precise Definitions

• $\displaystyle\lim_{x \to a}f(x) = L$ means:
• for all $\epsilon > 0$, there is $\delta>0$,
• so that if $0 < |x - a| < \delta$ ($x \ne a$ and x in within $\delta$ of a), then $|f(x)-L| < \epsilon$ (f(x) is within $\epsilon$ of L).
• |x - a| is the distance from x to a and |f(x) - L| is the distance from f(x) to L.
• so $\displaystyle\lim_{x \to a}f(x) = L$ means that the distance between f(x) and L can be made arbitrarily small by requiring that the distance from x to a be sufficiently small (but not 0).
• For Example: $\displaystyle\lim_{x \to 2}x^2 = 4$
• Let’s say $\epsilon = 0.1$, that means $|f(x)-4| < 0.1$, 3.9 < f(x) < 4.1,
• Base on the definition, there should be a $\delta$, that $2 - \delta < x < 2 + \delta$ to satisfy the demand.
• Try $\delta = 0.01$. We got 1.99 < x < 2.01, 3.9601 < x^2 < 4.0401, 3.9 < f(x) < 4.1 which suit the demand.
• Another Example: $\displaystyle\lim_{x \to 10}2x = 20$
• Let $\epsilon > 0, \delta = \epsilon / 2$
• if $0<|x-10|<\delta$, then,
• $0<2|x-10|<2\delta=\epsilon$, and so,
• $0<|2x-20|<\epsilon$


text:
# Plane ConvexRecently Published Documents

110
(FIVE YEARS 14)

## H-INDEX

11
(FIVE YEARS 0)

2021 ◽
Vol 31 (5) ◽
Author(s):
Jonas Allemann ◽
Norbert Hungerbühler ◽
Micha Wasem
Keyword(s):

AbstractWe obtain a formula for the number of horizontal equilibria of a planar convex body K with respect to a center of mass O in terms of the winding number of the evolute of $$\partial K$$ ∂ K with respect to O. The formula extends to the case where O lies on the evolute of $$\partial K$$ ∂ K and a suitably modified version holds true for non-horizontal equilibria.

2021 ◽
Vol 11 (7) ◽
pp. 1838
Author(s):
Lucien Saviot
Keyword(s):

An extension of the Rayleigh–Ritz variational method to objects with superquadric and superellipsoid shapes and cylinders with cross-sections delimited by a superellipse is presented. It enables the quick calculation of the frequencies and displacements for shapes commonly observed in nano-objects. Original smooth shape variations between objects with plane, convex, and concave faces are presented. The validity of frequently used isotropic approximations for experimentally relevant vibrations is discussed. This extension is expected to facilitate the assignment of features observed with vibrational spectroscopies, in particular in the case of single-nanoparticle measurements.

2021 ◽
pp. 107257
Author(s):
Yude Li ◽
Zheng Li ◽
Mei Chen ◽
Jinglun Liu
Keyword(s):

2021 ◽
Vol 774 (1) ◽
pp. 012079
Author(s):
V Hidalgo ◽
X Escaler ◽
A Díaz ◽
X Luo ◽
S Simbaña ◽
...
Keyword(s):

Author(s):
Ferenc Fodor
Keyword(s):

AbstractEggleston (Approximation to plane convex curves. I. Dowker-type theorems. Proc. Lond. Math. Soc. 7, 351–377 (1957)) proved that in the Euclidean plane the best approximating convex n-gon to a convex disc K is always inscribed in K if we measure the distance by perimeter deviation. We prove that the analogue of Eggleston’s statement holds in the hyperbolic plane, and we give an example showing that it fails on the sphere.

2021 ◽
Vol 76 (2) ◽
Author(s):
Cen Liu ◽
Zhanjun Su
Keyword(s):

2020 ◽
Vol 63 (4) ◽
pp. 888-917
Author(s):
János Pach ◽
Bruce Reed ◽
Yelena Yuditsky
Keyword(s):

2020 ◽
Vol 299 ◽
pp. 1099-1103
Author(s):
Dmitry Kruchinin ◽
Yulia Aleshina ◽
Elena Farafontova

The problematic issues, associated with deformations of the outer surfaces of optical parts made of quartz glass, due to the process of cementing, are considered. The effect of the heat treatment temperature of optical assemblies, consisting of parts made of quartz glass and cementing with epoxy cements OK-72FT5 and OK-72FT15, on the deformation of external surfaces was experimentally established. The object of the study was plane-convex and plane-concave lenses made of quartz glass. It has been stated, that on cementing with optical epoxy cements OK72FT5 and OK72FT15 the external quartz glass surface deformations depend primarily on the heat treatment temperature. When cementing parts are made of quartz glass, increasing the polymerization temperature improves the performance characteristics of products and reduces changes in their optical characteristics.

2020 ◽
Vol 299 ◽
pp. 311-315
Author(s):
Dmitry Kruchinin ◽
Liana Garayshina ◽
Elena Farafontova
Keyword(s):

The problematic issues connected with the optical details deformations that arise during the temperature tests of cemented assemblies are considered. Climatic tests of optical devices after assembly result in a change of technical product characteristics. The research problem is to define how N and ∆N of surfaces of cemented optical assemblies are changing after the temperature testing. The research objects are plane convex lenses fabricated of LK7 (LZOS) glass brand and plane concave lenses - of TF7 (LZOS). Before cementing, the bounded surfaces cleaning by the hydromechanical method in the clean room has been purged. The temperature testing of samples is held at 22, 50 and 65 °C. The effect of temperature on a surface deformation of cemented optical assemblies is experimentally established. The comparison of effect of optical cements OK72FT5 and OK72FT15 on the optical surfaces deformation is carried out. In this paper we have compared the results of shape accuracy of the external surfaces of optical assemblies and the flat surfaces. Interferograms of lenses after heat treatment of optical assemblies are presented. It is determined that the cement polymerization temperature equals or higher than the test temperature.

2019 ◽
Vol 240 ◽
pp. 062018
Author(s):
V Hidalgo ◽
X Luo ◽
X Escaler ◽
E Valencia ◽
P Cruz
Keyword(s):


text:
A bimetallic cylindrical bar cross sectional area $1 \: m^2$ is made by bonding Steel (Young's modulus $= 210 \: GPa$) and Aluminium (Young's modulus =$70 \: GPa$) as shown in the figure. To maintain tensile axial strain of magnitude $10^{-6}$ in Steel bar and compressive axial strain of magnitude $10^{-6}$ in Aluminium bar, the magnitude of the required force $P$ (in $kN$) along the indicated direction is

1. $70$
2. $140$
3. $210$
4. $280$


text:
# Determinism, Indeterminism, and the nature of the laws of physics…

The laws of physics are causal, but this fact does not imply that they can be used to determine each and everything that you feel should be determinable using them, in each and every context in which they apply. What matters is the nature of the laws themselves. The laws of physics are not literally boundless; nothing in the universe is. They are logically bounded by the kind of abstractions they are.

Let’s take a concrete example.

Take a bottle, pour a little water and detergent in it, shake well, and have fun watching the Technicolor wonder which results. Bubbles form; they show resplendent colors. Then, some of them shrink, others grow, one or two of them eventually collapse, and the rest of the network of the similar bubbles adjusts itself. The process continues.

Looking at it in an idle way can be fun: those colorful tendrils of water sliding over those thin little surfaces, those fascinating hues and geometric patterns… That dynamics which unfolds at such a leisurely pace. … Just watching it all can make for a neat time-sink—at least for a while.

But merely having fun watching bubbles collapse is not physics. Physics proper begins with a lawful description of the many different aspects of the visually evident spectacle—be it the explanation as to how those unreal-looking colors come about, or be it an explanation of the mechanisms involved in their shrinkage or growth, and eventual collapse, … Or, a prediction of exactly which bubble is going to collapse next.

For now, consider the problem of determining, given a configuration of some bubbles at a certain time $t_0$, predicting exactly which bubble is going to collapse next, and why… To solve this problem, we have to study many different processes involved in the bubbles dynamics…

Theories do exist to predict various aspects of the bubble collapse process taken individually. Further it should also be possible to combine them together. The explanation involves such theories as: the Navier-Stokes equations, which govern the flow of soap water in the thin films, and of the motion of the air entrapped within each bubble; the phenomenon of film-breakage, which can involves either the particles-based approaches to modeling of fluids, or, if you insist on a continuum theory, then theories of crack initiatiation and growth in thin lamella/shells; the propagation of a film-breakage, and the propagation of the stress-strain waves associated with the process; and also, theories concerning how the collapse process gets preferentially localized to only one (or at most few) bubbles, which involves again, nonlinear theories from mechanics of materials, and material science.

All these are causal theories. It should also be possible to “throw them together” in a multi-physics simulation.

But even then, they still are not very useful in predicting which bubble in your particular setup is going to collapse next, and when, because not the combination of these theories, but even each theory involved is too complex.

The fact of the matter is, we cannot in practice predict precisely which bubble is going to collapse next.

The reason for our inability to predict, in this context, does not have to do just with the precision of the initial conditions. It’s also their vastness.

And, the known, causal, physical laws which tell us how a sensitive dependence on the smallest changes in the initial conditions deterministically leads to such huge changes in the outcomes, that using these laws to actually make a prediction squarely lies outside of our capacity to calculate.

Even simple (first- or second-order) variations to the initial conditions specified over a very small part of the network can have repercussions for the entire evolution, which is ultimately responsible for predicting which bubble is going to collapse next.

I mention this situation because it is amply illustrative of a special kind of problems which we encounter in physics today. The laws governing the system evolution are known. Yet, in practice, they cannot be applied for performing calculations in every given situation which falls under their purview. The reason for this circumstance is that the very paradigm of formulating physical laws falls short. Let me explain what I mean very briefly here.

All physical laws are essentially quantitative in nature, and can be thought of as “functions,” i.e., as mappings from a specific set of inputs to a specific set of outputs. Since the universe is lawful, given a certain set of values for the inputs, and the specific function (the law) which does the mapping, the output is  uniquely determined. Such a nature of the physical laws has come to be known as determinism. (At least that’s what the working physicist understands by the term “determinism.”) The initial conditions together with the governing equation completely determine the final outcome.

However, there are situations in which even if the laws themselves are deterministic, they still cannot practically be put to use in order to determine the outcomes. One such a situation is what we discussed above: the problem of predicting the next bubble which will collapse.

Where is the catch? It is in here:

When you say that a physical law performs a mapping from a set of input to the set of outputs, this description is actually vastly more general than what appears on the first sight.

Consider another example, the law of Newtonian gravity.

If you have only two bodies interacting gravitationally, i.e., if all other bodies in the universe can be ignored (because their influence on the two bodies is negligibly small in the problem as posed), then the set of the required input data is indeed very small. The system itself is simple because there is only one interaction going on—that between two bodies. The simplicity of the problem design lends a certain simplicity to the system behaviour: If you vary the set of input conditions slightly, then the output changes proportionately. In other words, the change in the output is proportionately small. The system configuration itself is simple enough to ensure that such a linear relation exists between the variations in the input, and the variations in the output. Therefore, in practice, even if you specify the input conditions somewhat loosely, your prediction does err, but not too much. Its error too remains bounded well enough that we can say that the description is deterministic. In other words, we can say that the system is deterministic, only because the input–output mapping is robust under minor changes to the input.

However, if you consider the N-body problem in all its generality, then the very size of the input set itself becomes big. Any two bodies from the N-bodies form a simple interacting pair. But the number of pairs is large, and worse, they all are coupled to each other through the positions of the bodies. Further, the nonlinearities involved in such a problem statement work to take away the robustness in the solution procedure. Not only is the size of the input set big, the end-solution too varies wildly with even a small variation in the input set. If you failed to specify even a single part of the input set to an adequate precision, then the predicted end-state can deterministically become very wildly different. The input–output mapping is deterministic—but it is not robust under minor changes to the input. A small change in the initial angle can lead to an object ending up either on this side of the Sun or that. Small changes produce big variations in predictions.

So, even if the mapping is known and is known to work (deterministically), you still cannot use this “knowledge” to actually perform the mapping from the input to the output, because the mapping is not robust to small variations in the input.

Ditto, for the soap bubbles collapse problem. If you change the initial configuration ever so slightly—e.g., if there was just a small air current in one setup and a more perfect stillness in another setup, it can lead to wildly different predictions as to which bubble will collapse next.

What holds for the N-body problem also holds for the bubble collapse process. The similarity is that these are complex systems. Their parts may be simple, and the physical laws governing such simple parts may be completely deterministic. Yet, there are a great many parts, and they all are coupled together such that a small change in one part—one interaction—gets multiplied and felt in all other parts, making the overall system fragile to small changes in the input specifications.

Let me add: What holds for the N-body problem or the bubble-collapse problems also holds for quantum-mechanical measurement processes. The latter too involves a large number of parts that are nonlinearly coupled to each other, and hence, forms a complex system. It is as futile to expect that you would be able to predict the exact time of the next atomic decay as it is to expect that you will be able to predict which bubble collapses next.

But all the above still does not mean that the laws themselves are indeterministic, or that, therefore, physical theories must be regarded as indeterministic. The complex systems may not be robust. But they still are composed from deterministically operating parts. It’s just that the configuration of these parts is far too complex.

It would be far too naive to think that it should be possible to make exact (non-probabilistic) predictions even in the context of systems that are nonlinear, and whose parts are coupled together in complex manner. It smacks of harboring irresponsible attitudes to take this naive expectation as the standard by which to judge physical theories, and since they don’t come up to your expectations, to jump to the conclusion that physical theories are indeterministic in nature. That’s what has happened to QM.

It should have been clear to the critic of the science that the truth-hood of an assertion (or a law, or a theory) is not subject to whether every complex manner in which it can be recombined with other theoretical elements leads to robust formulations or not. The truth-hood of an assertion is subject only to whether it by itself and in its own context corresponds to reality or not.

The error involved here is similar, in many ways, to expecting that if a substance is good for your health in a certain quantity, then it must be good in every quantity, or that if two medicines are without side-effects when taken individually, they must remain without any harmful effects even when taken in any combination—that there should be no interaction effects. It’s the same error, albeit couched in physicists’ and philosopher’s terms, that’s all.

… Too much emphasis on “math,” and too little an appreciation of the qualitative features, only helps in compounding the error.

A preliminary version of this post appeared as a comment on Roger Schlafly’s blog, here [^]. Schlafly has often wondered about the determinism vs. indeterminism issue on his blog, and often, seems to have taken positions similar to what I expressed here in this post.

The posting of this entry was motivated out of noticing certain remarks in Lee Smolin’s response to The Edge Question, 2013 edition [^], which I recently mentioned at my own blog, here [^].

A song I like:
(Marathi) “kaa re duraavaa, kaa re abolaa…”
Singer: Asha Bhosale


text:
# Online Cubing Competition May-June 2022, 3x3 2x2, OH, 4x4, 3BLD, Skewb, Pyra, Mega

#### fun at the joy

##### Member
I'll participate in all events.

#### Mr Cuber

##### Member
Enteredkyo
I saw that im aperantly signed up for 3x3 bld but confirming that I'm not going to do the 3x3 blindfolded thankyou

#### Shrek

##### Member
Greetings, Mr Luke.
I would like to participate in 3x3 and 2x2.

- Shrek

#### Travelingyoyokid

##### Member
I guess I’ll do 4 oh and Meg as well. Can you do 2x2 Blind?

#### Travelingyoyokid

##### Member
When will this start?

#### baseballjello67

##### Member
In June. Dates will be posted soon.

#### baseballjello67

##### Member
I guess I’ll do 4 oh and Meg as well. Can you do 2x2 Blind?
Entered new events. Ask Luke if he can do 2BLD

#### Luke Solves Cubes

##### Member
Important announcement!

All dates will be a week earlier than I announced earlier.

Also, 2BLD will be announced, post if you would like to do this event.

Registration closes the 23rd.

Prizes:
3x3, 2x2, Pyraminx
1st $10 2nd$8
3rd $5 Everything else: 1st$5
2nd $4 3rd$3

Also prizes MAY NOT be available as we are wanting to have TheCubicle sponsor the competition, but there is a chance that they cannot sponsor this comp.

A reminder, PM me your times please starting may 24th and ending June 3rd.
At june 4th, I will announce who makes it to the second rounds or finals and then those results are due by june 11th.

Last edited:

#### Travelingyoyokid

##### Member
Important announcement!

All dates will be a week earlier than I announced earlier.

Also, 2BLD will be announced, post if you would like to do this event.

Registration closes the 23th.

Prizes:
3x3, 2x2, Pyraminx
1st $10 2nd$8
3rd $5 Everything else: 1st$5
2nd $4 3rd$3

Also prizes MAY NOT be available as we are wanting to have TheCubicle sponsor the competition, but there is a chance that they cannot sponsor this comp.

A reminder, PM me your times please starting may 24th and ending June 3rd.
At june 4th, I will announce who makes it to the second rounds or finals and then those results are due by june 11th.
Do you have exact dates?

For what

#### Travelingyoyokid

##### Member
I guess I miss read. Are you going to have predetermined scrambles?

#### Luke Solves Cubes

##### Member
Yes I will post them the 23rd

#### Luke Solves Cubes

##### Member
Can I do everything but 3BLD?
also the "23th" doesn't exist I'm sorry it just bugs me so much
Even 2BLD?


text:
General solution to ODE [closed]

Considering the following ODE : find $f(x)$ such that $$\frac{\sigma^{2}}{2}\frac{d^2}{dx^2}f(x)+a(b-x)\frac{d}{dx}f(x)-(\rho+\lambda)f(x)=-\lambda g(x)$$ Where, $a,b,\rho,\lambda,\sigma\in(0,+\infty)$, and $f(x)$ and $g(x)$ are assumed to have enough "good properties" !

Using the Fourier transform, one specific solution could be found, but I am interested in finding a general solution. It would be great if some one could give me some ideas. Thanks for your time and consideration.

-

closed as too localized by Victor Protsak, Will Jagy, José Figueroa-O'Farrill, Yemon Choi, Harald Hanche-OlsenSep 12 '10 at 21:46

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

It's linear in $f$ –  Will Jagy Sep 12 '10 at 19:11
Hi Will, I am little confused by your comment, it would be great if you could clarify your comment for me –  Nameless Sep 12 '10 at 19:16
The difference of two solutions of an inhomogeneous linear equation is a solution of the corresponding homogeneous equation. –  Victor Protsak Sep 12 '10 at 19:41
Nameless, given the elementary nature of this question and your comments indicating lack of understanding of basic facts about linear ODEs, I suggest (a) reading a textbook on ODEs; (b) asking your teachers (if you are a student); (c) posting follow-up questions on other sites listed at the FAQ. Voting to close. –  Victor Protsak Sep 12 '10 at 20:32

Will + Victor noted the general solution is your particular solution plus the general solution of the corresponding homogeneous DE. And, note, that this homogeneous DE does not depend on $g$. According to Maple, the solution of that homogeneous DE is... $$f_\mathrm{homog} (x) = C_1 \mathrm{KummerM} \left(\frac{\rho + \lambda}{2 a},\frac{1}{2},\frac{a (b - x)^{2}}{\sigma^{2}}\right) + C_2 \mathrm{KummerU} \left(\frac{\rho + \lambda}{2 a},\frac{1}{2},\frac{a (b - x)^{2}}{\sigma^{2}}\right)$$


text:
Home » Uncategorized » Inequality 5(Vasile Cirtoaje)

# Inequality 5(Vasile Cirtoaje)

Problem:

If $\displaystyle a,b,c$ are non-negative numbers, prove that

$\displaystyle 3(a^2-a+1)(b^2-b+1)(c^2-c+1)\geq 1+abc+a^2b^2c^2$.

Solution:

From the identity

$\displaystyle 2(a^2-a+1)(b^2-b+1)=1+a^2b^2+(a-b)^{2}+(1-a)^{2}(1-b)^{2}$

follows the inequality

$\displaystyle 2(a^2-a+1)(b^2-b+1)\geq 1+a^2b^2$.

Thus, we only need to prove that

$\displaystyle 3(1+a^2b^2)(c^2-c+1)\geq 2(1+abc+a^2b^2c^2)$

which is equivalent to the quadratic in $\displaystyle c$ equation

$\displaystyle (3+a^2b^2)c^2-(3+2ab+3a^2b^2)c+1+3a^2b^2\geq 0$,

which is true since the discriminant $\displaystyle D$ is equal to $\displaystyle D=-3(1-ab)^{4}\leq 0$.

Equality occurs for $\displaystyle a=b=c=1$, Q.E.D.


text:
# Bijection from $\mathbb{R}$ to $\mathbb{R^2}$

Importantly, I am looking for a constructive proof (which does not rely on the Cantor–Bernstein–Schroeder theorem). Motivated by this discussion.

-
Here is something which might not work exactly, but should be on the right lines: represent pairs of real numbers as pairs of binary strings, then interleave them. (My caveat is because of non-uniqueness issues to do with $\sum_{n\geq 1} 2^{-n} = 2^0$ but one should be able to tweak the idea.) –  Yemon Choi Mar 31 '13 at 3:53
@Mark, if you want to suggest using a transcendence basis, how would that be constructive? It relies on the axiom of choice. –  Asaf Karagila Mar 31 '13 at 6:33
I assume by constructive, you mean just mean "without Cantor–Bernstein–Schroeder and without axiom of choice" (the former is actually provable without the later). But if you happen to mean constructive in the style of, say, Bishop's constructive math, then you need a homoemorphism between $\mathbb{R}$ and $\mathbb{R^2}$, of which none exists (or at least I recall having heard this, I don't know the proof off hand that there is none). This gives some insight into why this is a tricky problem. –  Jason Rute Mar 31 '13 at 8:16
@Jason, why does a Bishop-constructive bijection have to be a homeomorphism? (As for why the two are not homeomorphic in their usual topologies, removing a point from R disconnects it, but removing a point from R^2 does not.) –  Yemon Choi Mar 31 '13 at 8:40
Asaf, many constructive systems include the axiom of choice or large fragments thereof, so using the axiom of choice is not a very good test for non-constructiveness. –  François G. Dorais Mar 31 '13 at 13:47

Here is a bijection that uses the decimal (or binary, whatever) expansion of reals. (Even though I think the approach using continued fractions is more canonical.)

• Let $\alpha:\mathbb Z\times \mathbb Z\to \mathbb N$ and $\beta:[0,1)\times [0,1)\to [0,1)$ be bijections.
• Let $f:\mathbb R \to \mathbb Z \times [0,1)$ be the natural bijection $x\mapsto (\lfloor x\rfloor, x-\lfloor x\rfloor)$.
• Together, $f$, $\alpha$, $\beta$ will define bijections $$\mathbb R\times \mathbb R \to^f (\mathbb Z\times [0,1)) \times (\mathbb Z\times [0,1)) \simeq \mathbb Z^2 \times [0,1)^2 \to ^{\alpha,\beta} \mathbb Z \times [0,1) \to^{f^{-1}}\mathbb R$$

The main part is of course the definition of $\beta$. [EDIT: This is not my construction; I am not sure where I first read it. In his book on the real numbers, Oliver Deiser gives a very similar construction (blocking zeroes instead of nines) and calls this Julius König's trick. König's wikipedia page mentions it but omits the details.]

Represent each real number $x\in [0,1)$ as a sequence of DIGITS, where each DIGIT is either in $\{0,\ldots,8\}$ or is of the form $10*(10^k-1)+i$ with $k\ge 1$ and $i\in \{0,\ldots,8\}$ (i.e., in $\{90,\ldots, 98; 990,\ldots, 998; 9990,\ldots, 9998; \ldots\}$.

For example, the number 0.0129449956$\dots$ would be represented by $(0,1,2,94,4,995,6,\ldots)$.

Given a pair $(x,y)$, $\beta$ interleaves these two representations.

-
But is the greatest integer function constructive? After all, one may not constructively decide if a real number is equal to $5$ or slightly less. –  Joel David Hamkins Mar 31 '13 at 14:04
Probably not, depending on what you exactly is meant by "constructive". (As discussed above - if every constructive function is continuous, then there is no bijection.) Also depending on what you mean by "real number" - in my answer I implicitly define a real number to be a decimal representation without an infinite string of 9's. In this context (which is NOT the definition I usually use for real numbers), my answer is constructive. (Well, it needs some tweaking: For negative numbers I really should use $\lceil\cdot\rceil$.) –  Goldstern Mar 31 '13 at 18:11


text:
# How to speed up the VBA scraping process

I want to scrape 25000 addresses using Column A cell values as search strings. I'm using the following code, it is working fine but it's too slow to extract 25000 results. Is there any way to speed up the process, like opening multiple addresses at once or something else? I'm pretty new to VBA coding. Any help would be appreciated.

Sub pullAddresses()

Dim IE As Object
Dim Doc As HTMLDocument

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True

For introw = 2 To 10
searchstring = ThisWorkbook.Sheets("Sheet1").Range("A" & introw).Value

DoEvents
Loop

Set ht = IE.document

''Application.Wait (Now() + TimeValue("00:00:02"))

a = ht.getElementsByClassName("desktop-title-content")(0).innerText
b = ht.getElementsByClassName("desktop-title-subcontent")(0).innerText

ThisWorkbook.Sheets("Sheet1").Range("B" & introw).Value = a & ", " & b

Next

End Sub

• Since you don't need to interact with the web page - click on things, scroll etc. you don't need to load a full web browser just to grab the html content. A much faster method would be to use "MSXML2.serverXMLHTTP" to query the page - e.g. as I have done in this answer. Note for multiple requests it's better not to create a whole new serverXMLHTTP object each time (as I'm doing there) and you should just reuse the same one like you are doing in your question for IE Aug 22 '21 at 8:13
• @Greedo Why don't you make the comment into a full answer. Aug 22 '21 at 13:13
• Remember that even if your code loops through 25,000 rows and executes in milliseconds, you're still at the mercy of the internet and Google's servers if you're executing a search there. I'd be willing to wager that if you put some timers in your code, the vast majority of your execution time will be in the Do Until...Loop line of code. Unfortunately, you cannot parallelize the operation, since VBA doesn't support threading, either. Aug 22 '21 at 14:39
• Your best bet is to make asynchronous MSXML2.ServerXMLHTTP requests. Check out Retrieve data from eBird API and create multi-level hierarchy of locations. In my answer create a list of 50 servers. The code loop over the list checking the ready state of each server request. When a request was ready, the result would be processed and the server would be assigned a new request. This approach was 48 times faster then using a single synchronous request. Aug 25 '21 at 11:02


text:
# How to do batch inner product in Tensorflow?

I have two tensor a:[batch_size, dim] b:[batch_size, dim]. I want to do inner product for every pair in the batch, generating c:[batch_size, 1], where c[i,0]=a[i,:].T*b[i,:]. How?

There is no native .dot_product method. However, a dot product between two vectors is just element-wise multiply summed, so the following example works:

import tensorflow as tf

# Arbitrarity, we'll use placeholders and allow batch size to vary,
# but fix vector dimensions.
# You can change this as you see fit
a = tf.placeholder(tf.float32, shape=(None, 3))
b = tf.placeholder(tf.float32, shape=(None, 3))

c = tf.reduce_sum( tf.multiply( a, b ), 1, keep_dims=True )

with tf.Session() as session:
print( c.eval(
feed_dict={ a: [[1,2,3],[4,5,6]], b: [[2,3,4],[5,6,7]] }
) )

The output is:

[[ 20.]
[ 92.]]

Another option worth checking out is [tf.einsum][1] - it's essentially a simplified version of Einstein Notation.

Following along with Neil and dumkar's examples:

import tensorflow as tf

a = tf.placeholder(tf.float32, shape=(None, 3))
b = tf.placeholder(tf.float32, shape=(None, 3))

c = tf.einsum('ij,ij->i', a, b)

with tf.Session() as session:
print( c.eval(
feed_dict={ a: [[1,2,3],[4,5,6]], b: [[2,3,4],[5,6,7]] }
) )

The first argument to einsum is an equation representing the axes to be multiplied and summed over. The basic rules for an equation are:

1. Input-tensors are described by a comma-separated string of dimension-labels
2. Repeated labels indicate that the corresponding dimensions will be multiplied
3. The output-tensor is described by another string of dimension-labels representing corresponding inputs (or products)
4. Labels that are missing from the output string are summed over

In our case, ij,ij->i means that our inputs will be 2 matrices of equal shape (i,j), and our output will be a vector of shape (i,).

Once you get the hang of it, you'll find that einsum generalizes a huge number of other operations:

X = [[1, 2]]
Y = [[3, 4], [5, 6]]

einsum('ab->ba', X) == [[1],[2]]   # transpose
einsum('ab->a',  X) ==  [3]        # sum over last dimension
einsum('ab->',   X) ==   3         # sum over both dimensions

einsum('ab,bc->ac',  X, Y) == [[13,16]]          # matrix multiply
einsum('ab,bc->abc', X, Y) == [[[3,4],[10,12]]]  # multiply and broadcast

Unfortunately, einsum takes a pretty hefty performance hit when compared to a manual multiply+reduce. Where performance is critical, I'd definitely recommend sticking with Neil's solution.

Taking the diagonal of tf.tensordot also does what you want, if you set axis to e.g.

[[1], [1]]

I have adapted Neil Slater's example:

import tensorflow as tf

# Arbitrarity, we'll use placeholders and allow batch size to vary,
# but fix vector dimensions.
# You can change this as you see fit
a = tf.placeholder(tf.float32, shape=(None, 3))
b = tf.placeholder(tf.float32, shape=(None, 3))

c = tf.diag_part(tf.tensordot( a, b, axes=[[1],[1]]))

with tf.Session() as session:
print( c.eval(
feed_dict={ a: [[1,2,3],[4,5,6]], b: [[2,3,4],[5,6,7]] }
) )

which now also gives:

[ 20.  92.]

This might be suboptimal for large matrices though (see discussion here)

• The march of progress :-), I'm not sure which API version this was added in? I suggest expand your answer with a short example (perhaps based on mine, but it should be simpler, since it won't need the reduce_sum) – Neil Slater Jul 18 '17 at 11:44
• I added the example! Actually it also gives off-diagonal dot-products if you don't use tf.diag_part, so your answer will probably be faster. Not really sure in which API version tf.tensordot got introduced, but it might be long ago since it is also available in numpy. – dumkar Jul 18 '17 at 12:04
• Wouldn’t this take much more memory than the element-wise multiply and sum? – kbrose Nov 13 '17 at 16:30


text:
# Proof of extended supermartingale convergence theorem

There is a supermartingale convergence theorem which is often cited in texts which use Stochastic Approximation Theory and Reinforcement Learning, in particular the famous book "Neuro-dynamic Programming" the theorem is:

"Let $$Y_t, X_t, Z_t, t = 1,2,3,....$$ be three sequences of random variables and let $$\mathcal{F_t}$$ be sets of random variables such that $$\mathcal{F_t} \subset \mathcal{F_{t+1}}$$ for all t, suppose that:

(a) The random variables $$Y_t, X_t, Z_t$$ are nonnegative and are functions of the random variables in $$\mathcal{F}_t$$

(b) For each $$t$$ we have $$E[Y_{t+1}|\mathcal{F_t}] \leq Y_t - X_t +Z_t$$

(c) $$\sum_{t=0}^\infty Z_t \lt \infty$$

Then:

$$\sum_{t=0}^{\infty}X_t \lt \infty$$ and there exists a nonnegative random variable $$Y$$ such that $$Y_t \rightarrow Y$$ with probability 1."

The problem is, I can't find any proofs of this anywhere. Most texts on probability theory prove the standard Martingale Convergence Theorem but I feel this is a big step from that.

Can anyone direct me to a source which proves the above or write out a proof from the standard convergence theorem?

Here's one approach.

First notice that $$R_t: = Y_{t} + \sum_{i=1}^{t-1} X_i - \sum_{i=1}^{t-1} Z_i$$ is a supermartingale, since $$R_{t+1} - R_t = Y_{t+1} - Y_t + X_t - Z_t,$$ giving $$E(R_{t+1} - R_t | \mathcal{F}_t) = E (Y_{t+1} | \mathcal{F}_t) - Y_t + X_t - Z_t$$ which is less than or equal to $$0$$ with probability $$1$$, by (b).

Now, we don't have a fixed lower bound for the supermartingale $$R$$, so we can't apply the convergence theorem directly.

However, for any $$a>0$$, consider the stopping time $$\tau_a = \inf\{t: \sum_{i=1}^t Z_i>a\},$$ with $$\tau_a=\infty$$ if $$\sum_{i=1}^t Z_i\leq a$$ for all $$t$$.

We can define $$R^{(a)}(t):=R(t\wedge \tau_a)= \begin{cases} R_t&\text{ if }t<\tau_a\\ R_{\tau_a}&\text{ if }t\geq \tau_a \end{cases}.$$

$$R^{(a)}$$ is also a supermartingale for any $$a$$, and $$R^{(a)}(t)$$ is bounded below by $$-a$$.

So by the martingale convergence theorem, for any given $$a$$, $$R^{(a)}(t)$$ converges to some finite limit with probability $$1$$. By countable additivity, we get that with probability $$1$$, $$R^{(a)}(t)$$ converges to a finite limit for all $$a\in\mathbb{Z}$$.

But if $$\sum_{i=0}^\infty Z_i<\infty$$, which from (c) we assume happens with probability $$1$$, then for all large enough $$a\in\mathbb{Z}$$, we have $$\tau_a=\infty$$, and so $$R^{(a)}(t)=R(t)$$ for all $$t$$. Since we know $$R^{(a)}(t)$$ converges, we also get that $$R(t)$$ converges.

Finally, since $$R(t)$$ converges and $$\sum_{i=0}^{t-1} Z_i$$ converges, we also have that $$Y_t+\sum_{i=1}^{t-1} X_i$$ converges. Since $$\sum_{i=1}^{t-1} X_i$$ is non-decreasing in $$t$$, and $$Y_t$$ is non-negative for all $$t$$, the only way this can happen is if $$Y_t$$ and $$\sum_{i=1}^{t-1} X_i$$ both converge, as required.

• Thanks, excellent! After a little digging one other alternative way is to reference a super-martingale convergence theorem for the sum missing the $-X_t$ term to get convergence and then this forces the $\sum X_t$ to be finite A.S. – FourierFlux Apr 19 '20 at 7:10


text:
# Combinatorics Seminar

## Spectral graph theory and Finite Field Combinatorics

Alex McDonald (University of Rochester)

Thursday, April 23rd, 2020
11:00 AM - 12:00 PM
Zoom Meeting 797 681 224

The spectral gap theorem says that a $k$-regular graph on $n$ vertices can be approximated by a random graph with edge density $k/n$, where the error term is controlled by the second largest eigenvalue of the adjacency matrix. We discuss several applications of this theorem to various problems in arithmetic and geometric combinatorics in the finite field setting.

Event contact: jonathan dot pakianathan at rochester dot edu


text:
ElliottOti.com

# Ocaml implementation of zlib Inflate algorithm

## Posted on 29.12.07 Programming Ocaml Graphics OpenGL Projects

In between the social duties usual during this time of the year I’ve been trying to work on and off on GLCaml. I’ve had some feedback from the (not very large) user base over the past few months and it’s clear that some changes are needed.

For instance, the use of enumerations is a pain, because OpenGL mixes enumerations and integers willy-nilly, and having to convert back-and-forth in Ocaml is just not worth the hassle. Also, although the use of Bigarrays is in my opinion mostly unavoidable, I’m trying to minimize usage where it is not strictly necessary.

A couple of weeks ago, Jon Harrop mailed that he had gotten GL shaders to work, albeit with some difficulty and hand tweaking. I’m taking the opportunity to test shaders and related bindings more thoroughly, but this will take some time.

I think the next release of GLCaml will have some fairly major changes; some cosmetic, some fundamental. Basically GL constants (glenums in GLcaml) will become ints, and as a result GL_ALL_CAPS notation will have to become gl_lower_case notation. But before I release it I’d like to test it reasonably well. Revise and revamp the documentation, examples and website as well. This might take a month or so, depending on free time.

What does all this have to do with Zlib’s inflate algorithm? Nothing. But about a month ago I implemented an Ocaml-only implementation of Zlib’s inflate algorithm (RFC 1951). It’s not the first one: Extlib has one, but using it requires pulling in a lot of other stuff as well. I was writing a pure-Ocaml PNG decoder (mostly done but very buggy, will finish it when I have the time), and needed a simple zlib decoder.

So I wrote one. The source code is available (under the BSD licence). It’s pretty compact: about 250 lines of code, including comments. Usage is very simple: pass a string containing data compressed with the zlib deflate algorithm, and a string large enough to contain the decompressed data, and it returns the same string with the decompressed data. `uncompress -> string -> string -> string`. I added a small, simple example to uncompress gzipped files.

The code is based more or less on the specs, with a peek every now and then at Andrew Church’s tinflate.c when I got stuck on some ambiguity or other. It’s pretty compact - 200 lines of code - and pretty slow: gunzip beats it by a factor of 10 to 100. Maybe if I have time I’ll try and optimize it. First I have to find the time to finish the PNG decoder. And GLCaml, of course.

# Collision detection: triangle-triangle intersection

## Posted on 08.08.07 Programming Ocaml Graphics

Collision detection is an important part of any physical simulation. The basis is formed by the intersection of primitives, and the triangle-triangle intersection test is one of the most commonly used tests.

As described in the CGA FAQ:

Let the two triangles be $T_1$ and $T_2$. If $T_1$ lies strictly to one side of the plane containing $T_2$, or $T_2$ lies strictly to one side of the plane containing $T_1$, the triangles do not intersect. Otherwise, compute the line of intersection $L$ between the planes. Let $I_k = T_k cap L$, for $k = 1$ and $2$, denote the interval of intersections between the triangles and the line. Either interval may be empty. $T_1$ and $T_2$ intersect if and only if $I_1$ and $I_2$ overlap.

The Ocaml implementation of this test can be viewed online. Compiling with the command `ocamlopt graphics.cmxa unix.cmxa collision.ml -o collision ` produces the following program:

A quick comparison with the canonical implementation by Thomas Moeller shows that my straightforward Ocaml implementation runs roughly 5 times as slowly as Moeller’s implementation in C.

My implementation currently handles coplanar triangles rather erratically, so I will either have to add a special function to check and handle coplanar triangles, or possibly check triangle normals for parallelism and perturb one of the triangles slightly to bring it out of plane before applying the normal test.

# Bead on wire hoop demo

## Posted on 29.07.07 Programming Ocaml Graphics

Previously, I had written a simple 1d spring demo.. The next logical step was extension to three dimensions (wholly trivial) and the addition of constraints.

To start with, I begin with the canonical problem: a bead on a round frictionless wire hoop. (This is also equivalent to modeling the bob of a simple rigid pendulum). This is a path constraint. Movement is free along the path, but prohibited in any other direction. This can be represented by a constraint vector and a path. The constraint vector is the local radius of curvature and is perpendicular to the free path. The path represents all the positions in space a particle under that constraint may occupy.

For a bead on a hoop, the constraint vector is simply the radius of curvature, and for a hoop this is a vector of constant magnitude pointing towards the center of the hoop.

Any force acting on the bead produces an acceleration and over a period of time dt a displacement dx. This displacement causes the particle to travel in a straight line to x0, and (often) deviate from the path. So a vector can be constructed starting at the (deviated) position x0 along the constraint vector. This vector will intersect the path at a point x1. At this position a new velocity vector can be constructed tangent to the path (i.e. perpendicular to the constraint vector), with the same magnitude as the velocity vector at x0 (with, however, a different direction).

Source code can be viewed online. Compile with `ocamlopt unix.cmxa graphics.cmxa physics.ml -o physics` or `ocamlc unix.cma graphics.cma physics.ml -o physics`

# Simple 1d spring demo

## Posted on 21.07.07 Programming Ocaml Graphics

While playing around with a number of simple integrators I wrote a quick 1 dimensional spring demo. Four point spring unit masses are animated using various methods of evaluation (simple Euler, Newton-Stormer-Verlet, 4th order Runge-Kutta and a simple explicit Verlet integrator.

All four methods have the tendency to explode over time, although the Euler integrator does that the easiest. Somewhat to my surprise both Verlet integrators are more stable than the 4th order Runge Kutta integrator.

Source code can be viewed online. Compile with `ocamlopt unix.cmxa graphics.cmxa physics.ml -o physics ` or `ocamlc unix.cma graphics.cma physics.ml -o physics `

# Using OpenGL with native OCaml Graphics

## Posted on 12.02.07 Programming Ocaml Graphics OpenGL

I’ve always thought it would be nice if it were possible to use OpenGL calls in a window created with the Ocaml Graphics module. This would prevent the need to require external toolkits such as SDL or GLUT.

The Ocaml Graphics module is quite limited compared to SDL or GLUT, and also fills a slightly different niche, but it does come with a number of useful functions for drawing text, various graphics primitives, and for polling mouse and keyboard events. Simple standalone programs or demos can be created and distributed without requiring that the SDL or GLUT shared library be present on those systems.

To get an Ocaml window working with OpenGL I wrote a stub file in C and a few lines of ML code. When the test program is compiled and linked (download a gzipped tar file containing all necessary files here) it results in a program that runs as seen in the screenshot below.

The file win_stub.c and the few lines of ML code in the prologue of win_test.ml is all that is needed to use OpenGL within an Ocaml application. For the actual OpenGL bindings either GLCaml or lablgl will suffice.

Compiling:

For the provided examples, extract the files contained in glgraphics.tar.gz, and run make. Edit the makefile if necessary, to ensure that the line `CLIB=GL` is uncommented on Linux, and the line `CLIB=opengl32 gdi32` is uncommented if compiling on Windows with MinGW.

You need the file win_stub.c and the ML code contained in this section, specifically the function init_opengl () and the external functions init_gl’(), find_window() and swap_buffers (). Link the resultant executable with libGL.a on X11, opengl32.lib and gdi32.lib on Windows.

Usage:

• First set up your caml window with Graphics.open_graph ()
• Next, call the function init_gl ()
• After this you can (re)set the window title (if you set it previously it will be empty)
• Feel free to call any OpenGL calls you wish. lablgl, glcaml and camlgl may all be used.
• You may mix the Ocaml graphics functions with OpenGL.
• Call swap_buffers () any time you need to flip the contents of your back buffer to the screen.

How does it work?

The method used is similar, but not identical, on both Windows and X11. Ocaml does not expose the internals of the window (understandably, because they are highly platform-specific), so they have to be obtained via other means. On both X11 and Win32 you can obtain pointers to internal rendering surfaces of windows provided you can identify them by name. After opening the window with Graphics.open_graph (), the function init_opengl () has to be called. This function gives the current window a (hopefully) unique title Then C code is called which searches through all available windows for a window with that particular name, gets pointers to its internal structure (both Win32 and Xlib allow this) and sets it up for use as an OpenGL surface. This method works on Windows and X11; it may work on OS-X (with a little tweaking in the #defines) but I have not tested that.

# GLCaml moved to SourceForge

## Posted on 26.01.07 Programming Ocaml Graphics OpenGL

The GLCaml and SDLCaml bindings proved to be more popular than I had thought they would be, averaging a frenzied 2 downloads per day. (Really, people, restrain yourselves). Still, that’s been around 350 downloads since I first put it up in June ‘06.

So I’ve moved the project to glcaml.sourceforge.net. It’s now got its own website and project page. I’ve updated GLCaml to include support for OpenGL 2.1, which came out in August ‘06. The generated code has been cleaned up, and a minor bug fixed.

Why GLCaml instead of lablgl? Well, GLCaml consists of only three files (two, if you want to forego the .mli file), without any dependencies whatsoever, so you can drop them into whatever project you’re working on, and you’re ready to go. It supports OpenGL up to the latest version (2.1 at the moment), whereas lablgl only supports OpenGL 1.2. It’s a very thin wrapper, so it’s fast. The nomenclature is exactly the same as the native ‘C’ OpenGL API, so you can copy and paste code from books, tutorials and C/C++ projects without trouble.

Why not GLCaml? Well lablgl is elegant, typesafe, it’s been written by smarter people than I (you might want to take that into account before rushing to ship 50K copies of your GLCaml-powered 3D shooter), and it’s been around longer - thus better tested.

GLCaml had a companion library, SDLCaml, which was a similar compact binding to SDL (and in fact somewhat pre-dates GLCaml, since I’d worked on it on-and-off since April ‘06). I’ve decided not to make a separate project page for SDLCaml, but to leave it as a supported, optional library within the GLCaml project. I will continue to maintain and update it, but it won’t be as visible as GLCaml: I do think it’s incredibly handy, but the OCaml landscape is littered with good SDL bindings (like OcamlSDL and Jean-Christophe Filliatre’s ocamlsdl) and mine doesn’t add extremely much value, aside from being very compact.

# Ocaml bindings for OpenGL and SDL

## Posted on 30.06.06 Programming Ocaml Graphics OpenGL Projects

UPDATE: This project has moved to glcaml.sourceforge.net.

In the interests of reinventing the wheel where possible, I wrote OCaml bindings for the SDL libraries and OpenGL libraries over a couple of weekends.

The (automatically generated) OpenGL bindings cover OpenGL 1.1, 1.2, 1.3, 1.4, 1.5, 2.0 and most current non-platform-specific extensions. There are no dependencies whatsoever: the system opengl shared library is loaded dynamically, and the functions are called dynamically, so there is no need to link against import libraries.

The SDL bindings are fairly but not wholly complete; they are hand-written and functions are bound on an as-needed-by me basis. They are only dependent on the SDL main library and not on the mixer, ttf or image libraries. Because I wanted to have basic sound capabilities, the SDL_Audio modules are implemented, along with extra functions for panning and pitch shifting audio buffers.

This has been tested and works on Windows 2000, Windows XP, and Ubuntu Linux running on AMD64.
On Windows I use the mingw Ocaml compiler suite along with the msys shell; the source tarball contains makefiles that work as-is on the Windows mingw/msys port and under Linux. It will probably work as-is for the cygwin port of Ocaml, and will definitely need some tweaking to work under the Visual-C port.

# Cell Texture

## Posted on 12.05.06 Programming Ocaml Graphics

I saw this article on cellular textures and wrote an Ocaml cellular texture generator (source code, public domain).
Compile with
`ocamlc graphics.cma celltexture.ml -o cell`
or
`ocamlopt graphics.cmxa celltexture.ml -o cell`

The end result looks like this:

# Ocaml/GLFW silhouette demo

## Posted on 07.03.05 Programming Ocaml Graphics OpenGL

Adapted from the ObjectLine demo at frustum.org (great website, by the way), an example using Ocaml and GLFW to render a silhouette around an object (using the stencil buffer).


text:
Tough Physics integration problem dealing with kinematics.

lorenzosounds

1. Homework Statement

A train traveling at v0 = 22.0 m/s begins to brake by applying a velocity-dependent instantaneous acceleration a(v) = α /(v + u) m/s2, where α = – 23.0 m2/s3, v is the instantaneous velocity of the train, and u = 0.5 m/s. Determine the distance traveled by the train until it comes to a complete stop.

I know I need to integrate, but I don't know how to get to d(t).

2. Homework Equations

(v+u)dv = (α)dt

3. The Attempt at a Solution

-22v-11 = 23.0(dt) is where I'm at. I'm not sure how to integrate both sides. How do I get to v(t), so I can solve d(t)?

Related Introductory Physics Homework Help News on Phys.org

TSny

Homework Helper
Gold Member
2. Homework Equations [/b]
(v+u)dv = (α)dt
Hello, lorenzosounds. You'll need to eliminate time, t, in favor of distance, x. Can you express dt in terms of v and dx?

lorenzosounds

Hello, lorenzosounds. You'll need to eliminate time, t, in favor of distance, x. Can you express dt in terms of v and dx?

Would it be -(1/2v^2+0.5v)=-23.0t ?

TSny

Homework Helper
Gold Member
Would it be -(1/2v^2+0.5v)=-23.0t ?

No. If you integrate (v+u)dv = (α)dt, then the left side would be integrated from vo to v. So, vo as well as v would appear on the left side.

But, then you'll have to solve this for v as a function of t, which will get messy. After that you would have to integrate one more time to find the distance traveled.

There's an easier way. Instead of trying to get v as a function of t, try to get v as a function of x. Go back to (v+u)dv = (α)dt. Is there a way to express the differential dt in terms of dx? Hint: v = dx/dt.