text:
## February 4, 2015

### Lebesgue’s Universal Covering Problem

#### Posted by John Baez

Lebesgue’s universal covering problem is famously difficult, and a century old. So I’m happy to report some progress:

• John Baez, Karine Bagdasaryan and Philip Gibbs, Lebesgue’s universal covering problem.

But we’d like you to check our work! It will help if you’re good at programming. As far as the math goes, it’s just high-school geometry… carried to a fanatical level of intensity.

Here’s the story:

A subset of the plane has diameter 1 if the distance between any two points in this set is $\le 1$. You know what a circle of diameter 1 looks like. But an equilateral triangle with edges of length 1 also has diameter 1:

After all, two points in this triangle are farthest apart when they’re at two corners.

Note that this triangle doesn’t fit inside a circle of diameter 1:

There are lots of sets of diameter 1, so it’s interesting to look for a set that can contain them all.

In 1914, the famous mathematician Henri Lebesgue sent a letter to a pal named Pál. And in this letter he challenged Pál to find the convex set with smallest possible area such that every set of diameter 1 fits inside.

More precisely, he defined a universal covering to be a convex subset of the plane that can cover a translated, reflected and/or rotated version of every subset of the plane with diameter 1. And his challenge was to find the universal covering with the least area.

Pál worked on this problem, and 6 years later he published a paper on it. He found a very nice universal covering: a regular hexagon in which one can inscribe a circle of diameter 1. This has area

$\frac{\sqrt{3}}{2} = 0.86602540 \dots$

But he also found a universal covering with less area, by removing two triangles from this hexagon—for example, the triangles C1C2C3 and E1E2E3 here:

Our paper explains why you can remove these triangles, assuming the hexagon was a universal covering in the first place. The resulting universal covering has area

$2 - \frac{2}{\sqrt{3}} = 0.84529946 \dots$

In 1936, Sprague went on to prove that more area could be removed from another corner of Pál’s original hexagon, giving a universal covering of area

$0.8441377708435 \dots$

In 1992, Hansen took these reductions even further by removing two more pieces from Pál’s hexagon. Each piece is a thin sliver bounded by two straight lines and an arc. The first piece is tiny. The second is downright microscopic!

Hansen claimed the areas of these regions were $4 \cdot 10^{-11}$ and $6 \cdot 10^{-18}$. However, our paper redoes his calculation and shows that the second number is seriously wrong. The actual areas are $3.7507 \cdot 10^{-11}$ and $8.4460 \cdot 10^{-21}$.

Philip Gibbs has created a Java applet illustrating Hansen’s universal cover. I urge you to take a look! You can zoom in and see the regions he removed:

• Philip Gibbs, Lebesgue’s universal covering problem.

I find that my laptop, a Windows machine, makes it hard to view Java applets because they’re a security risk. I promise this one is safe! To be able to view it, I had to go to the “Search programs and files” window, find the “Configure Java” program, go to “Security”, and add

http://gcsealgebra.uk/lebesgue/hansen

to the “Exception Site List”. It’s easy once you know what to do.

And it’s worth it, because only the ability to zoom lets you get a sense of the puny slivers that Hansen removed! One is the region XE2T here, and the other is T′C3V:

You can use this picture to help you find these regions in Philip Gibbs’ applet. But this picture is not in scale! In fact the smaller region, T′C3V, has length $3.7 \cdot 10^{-7}$ and maximum width $1.4 \cdot 10^{-14}$, tapering down to a very sharp point.

That’s about a few atoms wide if you draw the whole hexagon on paper! And it’s about 30 million times longer than it is wide. This is the sort of thing you can only draw with the help of a computer.

Anyway, Hansen’s best universal covering had an area of

$0.844137708416 \dots$

This tiny improvement over Sprague’s work led Klee and Wagon to write:

it does seem safe to guess that progress on [this problem], which has been painfully slow in the past, may be even more painfully slow in the future.

However, our new universal covering removes about a million times more area than Hansen’s larger region: a whopping $2.233 \cdot 10^{-5}$. So, we get a universal covering with area

$0.844115376859 \dots$

The key is to slightly rotate the dodecagon shown in the above pictures, and then use the ideas of Pál and Sprague.

There’s a lot of room between our number and the best lower bound on this problem, due to Brass and Sharifi:

$0.832$

So, one way or another, we can expect a lot of progress now that computers are being brought to bear. Philip Gibbs has a heuristic computer calculation pointing toward a value of

$0.84408$

so perhaps that’s what we should shoot for.

Read our paper for the details! If you want to check our work, we’ll be glad to answer lots of detailed questions. We want to rotate the dodecagon by an amount that minimizes the area of the universal covering we get, so we use a program to compute the area for many choices of rotation angle:

• Philip Gibbs, Java program.

The program is not very long—please study it or write your own, in your own favorite language! The output is here:

• Philip Gibbs, Java program output.

and as explained at the end of our paper, the best rotation angle is about $1.3^\circ$.

Posted at February 4, 2015 1:23 AM UTC

TrackBack URL for this Entry:   http://golem.ph.utexas.edu/cgi-bin/MT-3.0/dxy-tb.fcgi/2801

### Re: Lebesgue’s Universal Covering Problem

Congratulations! What got you into this?

Posted by: Tom Leinster on February 4, 2015 2:34 AM | Permalink | Reply to this

### Re: Lebesgue’s Universal Covering Problem

I forget how I found out about this problem, but I blogged about it in December 2013 and Philip Gibbs got interested enough to tackle it with the help of a computer. He posted an article about it on the viXra:

full of new ideas. I decided it would be good to take a portion of his work and write proofs at a level of rigor suitable for publication in a good journal. Karine Bagdasaryan is an undergraduate math major at U. C. Riverside who wanted to do a project on geometry. So, we all teamed up and wrote this paper together!

Posted by: John Baez on February 4, 2015 4:26 AM | Permalink | Reply to this

### Re: Lebesgue’s Universal Covering Problem

Thanks. I thought when I read your post that I’d seen you write about his problem before; it must have been that Azimuth post.

It sounds like a great undergrad project. And this is the first time I’ve seen a viXra paper cited in a respectable context!

Posted by: Tom Leinster on February 4, 2015 12:26 PM | Permalink | Reply to this

### Re: Lebesgue’s Universal Covering Problem

It’s striking how elementary your proof is! That would seem to suggest that the large body of existing knowledge about convex geometry isn’t much use here.

The Lebesgue problem reminds me of a couple of other things: on the one hand, the Kakeya problem, and on the other, the Hadwiger containment theorem.

That’s not the same as the Hadwiger theorem (about valuations on convex sets) that I’ve mentioned many times here before. What Hadwiger’s containment theorem says is the following. Let $K$ and $L$ be compact convex subsets of the plane, with nonempty interiors. Suppose that

$\frac{area(K) + area(L)}{perimeter(K)\cdot perimeter(L)} \gt \frac{1}{2\pi}.$

Then either there exists a Euclidean motion of the plane that moves $K$ into the interior of $L$, or vice versa.

(The significance of the constant $1/2\pi$: it’s what the left-hand side is equal to if $K$ and $L$ are equal-sized disks.)

This doesn’t seem very closely related to the Lebesgue problem, but it’s a nice theorem anyway. I learned it from Klain and Rota’s little book Introduction to Geometric Probability.

One more stray thought. In Taking categories seriously, Lawvere argues that the radius of a metric space is a more functorial quantity than the diameter. Here the radius of a bounded space $X$ is defined to be

$inf \{r : X \subseteq B(a, r) \,\,for\,\,some\,\, a \in X\}.$

Perhaps Lawvere would argue that Lebesgue should have asked: what is the least possible area of a convex planar set containing an isometric copy of every planar set of radius $\leq 1$?

Posted by: Tom Leinster on February 4, 2015 5:29 PM | Permalink | Reply to this

### Re: Lebesgue’s Universal Covering Problem

I’m pretty sure the answer to that “should have asked” question is a unit disc.

Posted by: Jesse C. McKeown on February 4, 2015 6:26 PM | Permalink | Reply to this

### Re: Lebesgue’s Universal Covering Problem

Ha! Thanks. I should have thought before posting.

While I obviously regret suggesting that Bill would have argued something so transparently idiotic, this little episode probably supports his point. Radius is such a functorial quantity that the answer to the Lebesgue-type question becomes trivial. Diameter, on the other hand, makes the Lebesgue question highly nontrivial.

Posted by: Tom Leinster on February 4, 2015 6:54 PM | Permalink | Reply to this

### Re: Lebesgue’s Universal Covering Problem

Tom wrote:

I should have thought before posting.

Maybe not. It would have denied us several pleasures, Schadenfreude being just the basest.

It’s certainly interesting to think about how ‘radius’ differs from ‘diameter’. Sometimes you have to go against the tao of mathematics to come up with an easy-to-state but hard-to-solve problem. For example, it’s obviously going against the grain to ask if every large enough even number is the sum of two primes, since primes are for multiplying: you’d have to be perverse to try to build up numbers as sums of primes.

It’s fun when these problems reveal a ‘hidden tao’, like Fermat’s Last Theorem, which sounds like a silly thing to wonder about at first, but turns out to be a front for the Modularity Theorem (which is deeply connected to interesting things, though also somehow against the grain).

At the other extreme, some conjectures that go against the tao of mathematics could be ‘true, but for no good reason’ and thus unprovable. Conway has argued that problems related to the Collatz Conjecture may be examples.

In the case of the Lebesgue universal covering problem, which is not a yes-or-no conjecture, it could be instead that approaching the greatest lower bound leads to ever more work and nothing really elegant.

Hmm: I suppose we should ask if the greatest lower bound on areas of universal coverings is computable.

Philip Gibbs has found a nice way to estimate it, which unfortunately is not rigorous. He estimates it at $0.84408$. If so, our proof that it’s $\le 0.844115376859 \dots$ is not doing so bad.

Posted by: John Baez on February 4, 2015 10:03 PM | Permalink | Reply to this

### Re: Lebesgue’s Universal Covering Problem

the tao of mathematics … primes are for multiplying: you’d have to be perverse to try to build up numbers as sums of primes.

I seem to remember Terry Tao making some joke about the existence of geometric progressions in the primes. Perhaps he was announcing a proof that he could construct arbitrarily short ones.

Posted by: Tom Leinster on February 5, 2015 9:13 PM | Permalink | Reply to this

### Re: Lebesgue’s Universal Covering Problem

The Lebesgue problem reminds me of things like the Busemann–Petty problem. A common theme is that means of measurement with different dimensionalities (diameter v. area, or $n$-dimensional volume v. $(n-1)$-dimensional volume of cross-sections) tend not to be very closely related to each other.

Posted by: Mark Meckes on February 5, 2015 8:47 PM | Permalink | Reply to this

### Re: Lebesgue’s Universal Covering Problem

Tom wrote:

What got you into this?

I should add something rather obvious: this kind of problem, hard but not clearly connected to big general ideas, is exactly the opposite of the kind of math I used to advocate. It has nothing to do with $n$-categories, nothing to do with figuring out the laws of the universe, and it requires lots of hard work instead of easy ‘following the tao’. So it may seem weird that I got involved in this problem.

I’m definitely not foresaking my philosophy that a lot of the best math comes from cutting along the grain instead of against it, and following elegant abstractions wherever they naturally lead instead of trying to crack hard problems with brute force.

However, I find that if you stick too tightly to any philosophy, you run the risk of overdeveloping certain mental muscles and underdeveloping others, and also just not having as much fun as you otherwise could. I think we’ve all sometime had the fantasy of tackling a famous old problem… so why not try, once?

And in this case, success was vastly more likely than usual, since Philip Gibbs had done most of the hard work, and Karine and I mainly needed to fill small holes in the argument and make everything nice.

Posted by: John Baez on February 4, 2015 10:23 PM | Permalink | Reply to this

### Re: Lebesgue’s Universal Covering Problem

exactly the opposite of the kind of math I used to advocate.

Yes, that was more or less what was behind my question. I know that Baez gets involved in all sorts of things, but this one did surprise me slightly.

Just in case I’m giving off any negative vibes, I don’t even slightly disapprove! On the contrary, I’m impressed.

Posted by: Tom Leinster on February 5, 2015 5:54 PM | Permalink | Reply to this

### Re: Lebesgue’s Universal Covering Problem

Good news! We’ve gotten some extra confirmation of our results… and also of my poor typing abilities. Greg Egan wrote:

Brilliant stuff!

I reconstructed the geometry for your final cover in Mathematica, and I get the same results for area as a function of the angle σ as you do.

Using high-precision arithmetic (2000 digits working precision), I found a valid σ of:

1.294389444703601012°

giving an area for the cover of:

0.844115297128419059…

There are a couple of typos in the paper. In the second inequality on page 2, you give Sprague’s area as:

0.8441377708435

but I believe the correct value is:

0.844137708435

i.e. there’s a triple 7 in the paper where it should be just a double 7.

Also, when you quote your final bound on page 10, you go from:

0.8441153768593765

which I agree with, to:

0.844411538

where the double 4 has become a triple 4.

He gave me the Mathematica notebook where he did these calculations, and a printout that people can read without using the software:

I updated our paper to refer to these and thank Greg.

Posted by: John Baez on February 8, 2015 10:59 PM | Permalink | Reply to this

### Re: Lebesgue’s Universal Covering Problem

Our paper on this subject has now been published:

• John Baez, Karine Bagdasaryan and Philip Gibbs, The Lebesgue universal covering problem, Journal of Computational Geometry 16 (2015), 288-299.

The referees caught a number of mistakes, so if you ever got ahold of an earlier version of this paper, and if you care, please get the new one. The journal is open-access, so it’s free.

Posted by: John Baez on September 23, 2015 6:26 PM | Permalink | Reply to this

Post a New Comment


text:
# Expectation of the product of two discrete random variables.

Let $X_i, X_j$ be two random variables that can each assume the values $\zeta_1, ..., \zeta_m$. Then my book claims $E(X_iX_j) = \sum_{k = 1}^m\sum_{l = 1}^m\zeta_k\zeta_lP(X_i = \zeta_k \textrm{ and } X_j = \zeta_l$).

I don't get how they acquired this result. To my understanding $E(X_iX_j) = \sum_{k = 1}^m\sum_{l = 1}^m\zeta_k\zeta_lP(X_i X_j = \zeta_k\zeta_l)$. So why is $P(X_iX_j = \zeta_k\zeta_l) = (X_i = \zeta_k \textrm{ and } X_j = \zeta_l)$?

• Are they independent? – kimchi lover Nov 11 '17 at 13:42
• @kimchilover they are random variables taken from a sample without replacement, so I think they are dependent. – Pel de Pinda Nov 11 '17 at 13:50
• If they are drawn without replacement, they are in fact dependent. – Raskolnikov Nov 11 '17 at 13:53
• Independence is not relevant in this context. – drhab Nov 11 '17 at 13:55

We do have: $$\mathsf E(X_iX_j)=\sum_{z\in Z} z\mathsf P(X_iX_j=z)\tag1$$ where $Z:=\{\zeta_k\zeta_l\mid k,l\in\{1,\dots,m\}\}$

Every $z\in Z$ can be written as $z=\zeta_k\zeta_l$ for some pair $k,l\in\{1,\dots,m\}$ but this value must be encountered only once in the RHS of $(1)$.

According to your (wrong) understanding it can occur more than once.

The claim of your book is correct. There we also meet values $z=\zeta_k\zeta_l\in Z$ and they can occur more than once. However they are not multiplied by $\mathsf P(X_iX_j=z)$ but by $\mathsf P(X_i=\zeta_k\wedge X_j=\zeta_l)$.

Observe that for $z\in Z$: $$P(X_iX_j=z)=\sum_{\zeta_k\zeta_l=z} P(X_i=\zeta_k,X_j=\zeta_l)\tag2$$

If the RHS of $(2)$ is substituted in $(1)$ then we eventually will arrive at:$$\mathsf EX_iX_j=\sum_{k=1}^m\sum_{l=1}^m\zeta_k\zeta_l\mathsf P(X_i=\zeta_k\wedge X_j=\zeta_l)\tag3$$i.e. the claim of your book.

Your second formula is "double counting". Take for instance $X_1=B_1+1$ and $X_2=B_2+1$, with $B_1$ and $B_2$ both Bernoulli distributed with the same probability $p$ and independent from each other. Then

$$E(X_1X_2) = 1\cdot 1 \cdot P(X_1=1 \text{ and } X_2=1) + 1\cdot 2 P(X_1=1 \text{ and } X_2=2) \\ + 2\cdot 1 P(X_1=2 \text{ and } X_2=1) + 2\cdot 2 P(X_1=2 \text{ and } X_2=2) = (1-p)^2 + 4p(1-p)+4p^2$$

on the other hand, if your second formula were true you would have

$$E^*(X_1X_2) = 1\cdot 1 \cdot P(X_1 X_2=1) + 1\cdot 2 P(X_1 X_2=2) \\ + 2\cdot 1 P(X_1X_2=2) + 2\cdot 2 P(X_1 X_2=4) = (1-p)^2 + 8p(1-p)+4p^2$$

The middle terms have been double counted because $P(X_1 X_2=2)=P(X_1=1 \text{ and } X_2=2)+P(X_1=2 \text{ and } X_2=1)$. So the second formula is incorrect.

format: plain


text:
Question
(a) Show that a 30,000-line-per-centimeter grating will not produce a maximum for visible light. (b) What is the longest wavelength for which it does produce a first-order maximum? (c) What is the greatest number of lines per centimeter a diffraction grating can have and produce a complete second- order spectrum for visible light?
1. undefined
2. $333 \textrm{ nm}$
3. $7142 \textrm{ lines/cm}$
Solution Video


text:
# Integral: sqrt(a^2+x^2)

1. Jan 14, 2009

### subwaybusker

1. The problem statement, all variables and given/known data

integral: sqrt(x^2+1)

2. Relevant equations

3. The attempt at a solution

I tried using x=tan[y], dx=sec^2[y]dy

Integral:
sqrt(tan^2[y]+1)sec^2[y]dy
=sec^3[y]dy
=(tan^2[y]+1)(sec[y])dy
=(tan^2[y]sec[y]+sec[y])dy

and then i was stuck.

2. Jan 14, 2009

### rock.freak667

From

$$\int sec^3 y dy$$

Write it as

$$\int (secy) (sec^2y dy)$$

and then use integration by parts.

3. Jan 14, 2009

### Dick

I would write sec(y)^3 as dy/cos(y)^3=cos(y)dy/cos(y)^4=cos(y)*dy/(1-sin(y)^2)^2. Putting u=sin(y) that becomes du/(1-u^2)^2. Now use partial fractions.

4. Jan 15, 2009

### Gib Z

subwaybusker, Do you know about hyperbolic trig functions? I would let $x=\sinh u$.

5. Jan 15, 2009

### psykatic

Well, my way of approaching this integral would be,
$$\int \sqrt{x^2+1} . 1$$

So, now the above integral can be solved by using integral by parts, try doing it!

P.S: Here,$$u=\sqrt{x^2+1}$$ and v=1.

6. Jan 15, 2009

### Dick

Ok, so after an integration by parts, now you have to integrate x^2/sqrt(x^2+1). How is that a simplification? I think you are doing the parts integration wrong. You need to have u=sqrt(x^2+1) and v=x.

7. Jan 15, 2009

### psykatic

Nope, once you have,
$$\int \sqrt{x^2+1}. 1~ =~ x\sqrt{x^2+1}~-~\int \frac{x^2}{\sqrt{x^2+1}}$$

Add and subtract 1 in the numerator, that'll help you, I'd solve it further if you want!

Last edited: Jan 16, 2009
8. Jan 16, 2009

### Gib Z

Well, putting back in our differentails, which is a bad idea to forget, and evaluting the trivial integral, our integral I through your method is given by

$$I = \frac{(x^2+1)^{\frac{3}{2}}}{3} - I + \int \frac{1}{\sqrt{x^2+1}}} dx$$

So Now you have to integrate that last integral, which takes the same substitution as suggested earlier. This method is not the shortest way.

9. Jan 16, 2009

### psykatic

Well, Gibz thanks for making me realise my mistake! There shouldnt have been any integral before $$x.\sqrt{x^2+1}$$, my bad :sad:

Thats already integrated, going according to the rule it'd be:
$$\int u.v=~u\int v -\int \frac{\delta u}{\delta x} \int v$$

so, considering,$$u=\sqrt{x^2+1}$$ and v=1,

it'd be
$$x.\sqrt{x^2+1} -\int\frac{1}{2\sqrt(x^2+1)}.2x.x$$
where, 2 gets cancelled in the numerator and the denominator, and the sum continues..


text:
# Parameter references

This topic is 4898 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm a bit lost on registering C++ functions that take parameter references. I've tried references and handles, but neither seem to work. Consider the following C++ function:
template<class T>
static
void foo(T* arg)
{
*arg = 55;
}

Granted, this example only works for certain types of T. But I am having trouble registering this function. I've tried the following:
bool my_register(asIScriptEngine* engine)
{
if ( engine->RegisterGlobalBehaviour(asBEHAVE_BIT_SRL, "void f(uint &out)", asFUNCTIONPR(foo<unsigned long>, (unsigned long *), void), asCALL_CDECL) < 0)
return false;

return true;
}

The call to RegisterGlobalBehaviour returns -10. I've looked into the code, and it fails because it says that references require a "in". So, I tried other cases:
"void f(uint &inout)"
"void f(uint @+)"

And both fail. The only call that registers successfully, but doesn't operate correctly is:
"void f(uint &in)"

And it makes sense that this doesn't work (because of the evaulation and copy semantics). I know I'm likely overlooking something simple. My search of the forums and reading the documentation hasn't revealed a solution yet. So, how do I pass a parameter to a primitive type via a pointer?

##### Share on other sites
The asBEHAVE_BIT_SRL (>>) operator requires two operands. Also, the script operators only allow &in references, so you shouldn't try to alter the values. The engine may in some cases send the reference to the actual variable, but in others it may be to a different variable so you may get unexpected results and difficult to find bugs, if you did what you're trying to do.

If you want to alter the value of the parameter reference, you must use a normal function that allows &out, and &inout.

The following works:

void func(int &v){   v = 55;}engine->RegisterGlobalFunction("void func(&out)" asFUNCTION(func), asCALL_CDECL);

##### Share on other sites
Quote:
 Original post by WitchLordThe asBEHAVE_BIT_SRL (>>) operator requires two operands.

The above was a contrived example. I'm actually trying to get the input streams ported to the latest Angelscript version.
Quote:
 Original post by WitchLoardAlso, the script operators only allow &in references, so you shouldn't try to alter the values. The engine may in some cases send the reference to the actual variable, but in others it may be to a different variable so you may get unexpected results and difficult to find bugs, if you did what you're trying to do.

Indeed. So how do input streams work? The streams code is based on an older version of the Angelscript library, and in it I see the following:
template <class T>std::istream * ExtractOperator(std::istream * in, T * value){	*in >> *value;	return in;}

coupled with
RegisterBehavoir(engine, asBEHAVE_BIT_SRL, "instream & f(instream &, bool &)", ExtractOperator<bool>);

and the RegisterBehavoir() function is defined as:
template <class T>inline void RegisterBehavoir(asIScriptEngine * engine, asDWORD behaviour, const char * name, T func){	engine->RegisterObjectBehaviour(0, behaviour, name, asFunctionPtr(reinterpret_cast<void (*)()>(func)), asCALL_CDECL);}

So if the SRL operator only allows &in references, then how did the above code work? How can I register an input stream class and use the SRL operator as an extraction operator if I can only have &in references?

##### Share on other sites
I wrote this long answer trying to give you a solution, but when I finished I realized that I had completely missed the point of the true problem. I was focusing on the actual stream object, but forgot about the value that is extracted from the stream.

There is really no easy solution to this problem at the moment. Since only &in references are allowed, there is no way you can have the operator change the value of the operands unless the operands use shared memory.

I need to change the way the library handles this. The library must be able to allow operators change the value of the operands for this to work.

I'll finish version 2.4.0 first, and after that I'll give this problem top priority. I was planning on changing the way parameter references work anyway, since I'm not quite satisfied with the current solution.

I hope that I will be able to find a solution to this. But I not 100% sure that it is possible, without breaking other restrictions that are needed to keep the library safe.

##### Share on other sites
Could the stream be written to take a handle? It would then be possible for AngelScript to automatically create a handle to stack-based object and pass that to the function. Some sort of binding flag would have to be added to allow this conversion on specific functions, or the script could do the conversion-to-handle explicitly. Allowing it universally would probably cause problems.

##### Share on other sites
This is a really a rather difficult problem that Suudy discovered.

Some of the problems that I'm facing:

1. I cannot keep pointers on the stack while evaluating expressions. It's possible that they become invalid before they are used again.

2. Argument expressions for output references are evaluated after the function call, because of number 1. A returned reference, for example, must be used before the output parameters are evaluated.

3. I must keep operator precedence and order of evaluation, e.g. for >> the left operand must be evaluated before the right operand. This goes against rule number 2, if I allow output references for operators.

Allowing object handles doesn't solve this, although it might help in some situations. Primitives for example cannot use object handles, and somehow wrapping them in an object that support handles isn't really a good solution. For example, how would I wrap an object property of a primitive type, or an element in an array?

##### Share on other sites
I understand why the << operator can only accept in references, but I'm forced to wonder why the >> operator doesn't then only accept out references.

Quote:
 the script operators only allow &in references

Is this true for all operators? It would make sense if it were. Operator >> for streams is unigue in that it is the only operator that modifies it's right-hand side. Could it be a special case that is required to be registered with an out reference?

##### Share on other sites
We decided on a workaround for the output parameter references. Rather than rely on the SRL operator, we just defined a template member function overloaded for all the types we are interested. We just don't get the pretty chaining.

For example, we defined:
template<class T>bool mystream::get(T* val){  _stream >> *val;}

Where _stream is the wrapped input stream. We registered them as overloaded functions, one for each type:
engine->RegisterObjectMethod("ifstream", "bool get(bool &out)", asMETHODPR(asCIScriptStream, get<bool>, (bool*), bool),  asCALL_THISCALL);engine->RegisterObjectMethod("ifstream", "bool get(uint &out)", asMETHODPR(asCIScriptStream, get<unsigned long>, (unsigned long*), bool),  asCALL_THISCALL);

etc, etc, for each type we want.

This works fine for now, and in the end, we will likely just add the extraction operator rather than remove these functions.

Thanks for generating and supporting such a fantastic piece of software! I can't say enough about how much we appreciate what you've done. Our end-users love the ability to script their testbenchs, and with the huge variety of add-ons (the preprocessor being our favorite!), we are all very thrilled.

##### Share on other sites
Suudy:

I'm happy that you found a solution, even though it may not be exactly what you had in mind.

I'm also very happy that you enjoy the library so much. Please spread the word. [wink]

Deyja:

Quote:
Original post by Deyja
I understand why the << operator can only accept in references, but I'm forced to wonder why the >> operator doesn't then only accept out references.

Quote:
 the script operators only allow &in references

Is this true for all operators? It would make sense if it were. Operator >> for streams is unigue in that it is the only operator that modifies it's right-hand side. Could it be a special case that is required to be registered with an out reference?

The problem is that all operators only support &in. To AngelScript there is no difference between any of the overloaded operators, except their token and the precedence, e.g. << and >> is treated the exact same way. If I allow >> to be registered with an &out operands, I should allow all operators to do that. I won't make a special case just to support streams.

None of the default operators modify the operands (this is true for C++ as well). I'm also not too fond of the C++ streams. This is why I forgot about the possibility that someone would want to register operators that change the value of the operands.

Maybe I can solve this case by implementing member operators. The left hand operand would then by default be changeable, and I would just have to worry about the right hand operand. I'll have to think about this some more.

##### Share on other sites
Wouldn't the left hand side need to be changable already, to support ++ and += (etc)?

I understand why you don't want to make a special case. I hate them too. :D

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 9
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
634135
• Total Posts
3015754
×


text:
### Month: October 2017

Classical free particles (i.e. Klein-Gordon)

## Classical free particles (i.e. Klein-Gordon)

TL;DR – The extended Hamiltonian for a classical free particle is the classical version of the Klein-Gordon equation. After having seen the classical version of antiparticles we will see the classical version of the Klein-Gordon equation. This is the essentially the extended Hamiltonian for the free particle. Let’s look at the details. 1. Extended Hamiltonian for …

Classical antiparticles

## Classical antiparticles

TL;DR – Antiparticle states are those for which time is a decreasing function $t(s)$ of the trajectory parametrization instead of an increasing function (i.e. time and trajectory parametrization are anti-aligned). In a previous post we introduced the extended Hamiltonian equations. In the next few posts we will see that they allow us to create parallels …


text:
How do I ColorQuantize to a predetermined mosiac builder's pallet of limited choices?

If one is already working with a specific pallet of colors (say 9 colors of jelly bean in a mosaic) is there a good way to convert any image into those predetermined color choices? The ColorQuantize function makes its own color selections that when translated and "printed" in the predetermined pallet result in seeming poor art choices with both low contrast and erratic emphasis.

Color quantization works by reducing the number of colors on the basis of colors that already appear in the image. With the reduced set of colors, all pixels in the image are converted to the best possible choice.

The best possible choice is usually a color from the reduced set that is closest to the pixel in the image. Therefore, you need a distance measure between two colors to calculate which color is the best match.

That being said, no one stops you from defining colors yourself and writing a function that gives for each input color the best matching color from the set of manually chosen colors. Let me give an example where I take 32 colors from one of the ColorData indexed color schemes:

With[{cols = List @@@ (ColorData[24] /@ Range[32])},
selectColor[rgb : {_, _, _}] := First[SortBy[cols, Norm[rgb - #] &]]
];

img = Import[
ImageApply[selectColor, img]

An alternative for selectColor function using Nearest.

With[{cols = List @@@ (ColorData[24] /@ Range[32])},
selectColor[rgb : {_, _, _}] := Flatten@Nearest[cols, rgb, 1]];

This uses an image like this

to create

Obviously, this set of colors are missing green tones, so let's try a better set:

If you use this with

With[{cols =
List @@@
Flatten[Table[
ColorConvert[Hue[v, 1, b], "RGB"], {v, 0, 1, .1}, {b, .1,
1, .3}]]},
selectColor[rgb : {_, _, _}] := First[SortBy[cols, Norm[rgb - #] &]]
]

you will get

That should give you a start. For faster processing, you should compile this function and apply it in parallel on the pixel matrix.

Edit: Compiled version

With[{cols =
List @@@
Flatten[Table[
ColorConvert[Hue[v, s, b], "RGB"], {v, 0, 1, .1}, {s, 0,
1, .3}, {b, 0, 1, .3}]]},
fC = Compile[{{rgb, _Real, 1}},
Module[{min = 100.0, currMin = 100.0, minCol = cols[[1]]},
Do[
If[(currMin = Norm[rgb - c]) < min,
minCol = c;
min = currMin
]
, {c, cols}];
minCol
], CompilationTarget -> "C", Parallelization -> True,
RuntimeAttributes -> {Listable}
]
]

And then

Image[fC@ImageData[img]]

Or if you like to make it more autumn-like, give only a small color range

• This is pretty cool. I think Nearest can be used in the selectColor function like this Flatten@Nearest[cols, rgb, 1]. The results look similar. – Anjan Kumar Mar 15 '17 at 1:10
• @AnjanKumar Yes, in high-level code Nearest is the better alternative. I was giving the Norm approach as I had compilability in mind. Feel free to edit my answer if you like to have Nearest included in the answer. – halirutan Mar 15 '17 at 1:13
• Please check the edit. – Anjan Kumar Mar 15 '17 at 1:23
• There is buil-it ColorDistance (starting from version 10) which should give better results than Nearest in RGB colorspace. – Alexey Popkov Mar 16 '17 at 3:17
• @AlexeyPopkov I know. Additionally, RGB is not a good choice for calculating metric color distances. What I tried is to present the general approach. I hope that the OP investigates on his own and reads some introduction about color spaces and perception, if she/he is really interested in the matter. – halirutan Mar 16 '17 at 3:19

You can use ColorQuantize in this application by specifying the desired color palette using Colorize and ColorRules. This code uses a color palette cols (borrowed from halirutan's answer) and applies it to the canoe picture (also borrowed from halirutan):

img = Import["https://i.stack.imgur.com/VG7J1.png"];
cols = Flatten[Table[ColorConvert[Hue[v,1,b],"RGB"],{v,0,1,0.2}, {b,0.1,1,.3}]];
Colorize[ClusteringComponents[ColorQuantize[img, Length[cols]]],

I suppose a less garish color choice might be appropriate... You should keep two things in mind: First, the original colors from ColorQuantize and the chosen colors cols share no similarity, which looks artistic but is different from halirutan's approach, who tries to find nearest colors. As a consequence, you might want to consider turning Dithering->False in ColorQuantize as this tries to simulate more color shades by sprinkling neighbouring colors. This doesn't really make sense with random colors. Here is the output without dithering
• As I understand, effectively you just replace the colors selected by ColorQuantize with your own without taking into account color distances. That's explain why the result is so bad. Probably considering color distances would improve it. – Alexey Popkov Mar 16 '17 at 2:59
In Mathetica 11.3 ColorQuantize can take an image and a list of colors to do exactly what you ask for:


text:
• 14
• 12
• 9
• 10
• 13

# Simplifying Nested Ternary Conditionals

This topic is 2177 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm writing some VBA that does calculations with complex numbers. Here is my code that prints a complex number a+bi:

IIf(b = 0, a, IIf(a <> 0, a & " + ", "") & b & "i")

My question is twofold:

1. How can I simplify this further? 'a' is included in the expression twice and I'm sure there is a better way/order to wrap the conditionals so that one of those 'a's is removed without adding another term.

2. What method did you use to simplify this? Is there a mathematical technique for simplifying these things? (if the outputs were binary I know I could use sum-of-products as in circuits and some boolean logic to simplify it)

##### Share on other sites
I'm not familiar with VBA, but I see a couple ways to improve this:

1. I see you are aiming for a number not to appear if it equals 0. In this regard, your code is flawed. Take for example a = 0 and b = 0, or 0. I know, silly, but: b = 0 is true, then print a => output is "0".
2. The else statement seems actually independent from the exterior conditional, so those two should actually be two distinct conditionals. It's good practice and will help the code to be more clear.
IIf(a <> 0, a & " + ", "") IIf(b <> 0, b & "i", "")
3. Like I stated, I do not know VBA, but it would be good if you could save and accumulate the characters that you want to print in a String or array of characters in case you need to modify it further on.
4. Even though the use of the 'a' twice is gone, I can't come up with any more clever, mathematical solution to simplify the code. Sorry!

##### Share on other sites

1. I see you are aiming for a number not to appear if it equals 0. In this regard, your code is flawed. Take for example a = 0 and b = 0, or 0. I know, silly, but: b = 0 is true, then print a => output is "0"

Well actually I wanted it to output 0 if a and b are both 0. So I think my code is correct in this case. That's why I had it print 0. I was trying to isolate all the combinations and realized the ones where b=0, the final output = a (whether a is zero or not)

2. The else statement seems actually independent from the exterior conditional, so those two should actually be two distinct conditionals. It's good practice and will help the code to be more clear.
IIf(a <> 0, a & " + ", "") IIf(b <> 0, b & "i", "")
[/quote]

Hmm but is it independent? It seems like they are dependent since the whole thing evaluates to 0 if and only if both the real and imaginary components are zero. For this reason, I think it requires a nested conditional.

The code isn't really meant to be language specific, it was just a ternary operator. Here it is in C++:

b = 0 ? a : (a <> 0 ? a & " + " : "") & b & "i"

Seems like this may be able to be done in one less operand, but I'm not sure how because I don't know how to optimize these things.

Here is the table:

a ZERO, b ZERO ==> 0 (or a in order to reduce the number of possibilities from four to three)
a ZERO, b NONZERO ==> b & "i"
a NONZERO, b ZERO ==> a
a NONZERO, b NONZERO ==> a & " + " & b & "i"

##### Share on other sites
Your code seems perfectly efficient to me. I don't think you are doing any extra operations. I wouldn't worry too much about repeating something in the expression. You should worry more about the expression being easy to understand. I would probably do it like this:
IIf(b = 0, a, IIf(a = 0, b & "i", a & " + " & b & "i"))

I find that easier to read because I can see all three forms (a', b & "i"' and a & " + " & b & "i"') clearly in the code. And yes, I now also repeat b & "i"', but who cares?

##### Share on other sites
Gotcha thanks. I prefer your way too.

##### Share on other sites
Oh, I just realized that this wouldn't look too good if a is not zero and b is negative... I remember having written code for this in the past and it not being pretty.


text:
Sales Toll Free No: 1-855-666-7446

# How to Find Central Angle of a Circle?

TopThe central angle of a circle is the angle based at the circle's center. Here, we will discuss how to find the central angle of a circle

Given below are the steps for finding the central angle of a circle:

Step 1: First of all, we will calculate the circumference by using the following formula:
Circumference (C) = $2 \times \pi \times r$. Here, $\pi$ = 3.14 and ‘r’ is the radius, which is given in question. If diameter is given in diameter form, then we convert diameter into radius by dividing diameter by 2.

Step 2: After evaluation of circumference, now we calculate arc length of circle by using following formula:
Arc length (s) = $r \times \theta$

Step 3: After first two steps, now we calculate central angle of circle by using following formula:

Central angle of circle ($\theta$) = $\frac{\text{arc length} \times 360}{2 \times \pi \times r}$.

Now, we take an example to understand the process of evaluating the central angle of circle:

Example: Find the central angle of circle, whose arc length is 7.33 meter and diameter is 14 meter.

Solution: We use the following steps for evaluating a central angle of circle, whose diameter and arc length is given.

Step 1: First of all, we calculate circumference of circle by following formula:

Circumference (C) = $2 \times \pi \times r$

= $2 \times 3.14 \times ($$\frac{14}{2}$$)$. Here, 14 is diameter. So, radius is ($\frac{\text{Diameter}}{2}$),

= 2 x 3.14 x 7,

= 43.96 inches.

Step 2: Here, Arc Length of Circle is given.

Arc length (s) = 7.33 inches

Step 3: Now, we calculate central angle of circle by using the following formula:

Central angle of circle ($\theta$) = $\frac{\text{arc length} \times 360}{2 \times \pi \times r}$

= $\frac{7.33 \times 360}{43.96}$

= 60 degree

So, central angle of circle is '60 degree'.


text:
# examples of infinitely differentiable function

What types of infinitely differentibale functions $f:\mathbb{R} \rightarrow \mathbb{R}$ have the following property?

$$\lbrace x : |f(x)| = 1 \rbrace \nsubseteq cl \lbrace x : |f(x)| > 1 \rbrace$$

where $cl$ denotes closure of a set.

-
Why does the title mention infinitely differentiable functions? This seems to be unrelated to your question. – Antonio Vargas Jan 20 '13 at 3:43
I forgot to put it in the description, I'm interested in infinitely differentiable functions having the said property. – user58191 Jan 20 '13 at 3:47
Every infinitely differentiable function such that $|f(x)|=1$ at least once and $|f(x)|\leq 1$ for all $x$ is an example (this condition is sufficient but not necessary). $f(x)\equiv 1$ is the simplest. What do you mean by "what types"? Do you just want some examples? – Jonas Meyer Jan 20 '13 at 3:51
@JonasMeyer: I have some examples at hand, but am interested if there are some pathological examples – user58191 Jan 20 '13 at 4:00
What are your examples, and what do you mean by pathological? – Jonas Meyer Jan 20 '13 at 4:02

A continuous function has this property if and only if there is a point $x$ for which $|f(x)| = 1$ and $|f(y)| \leq 1$ for all $y$ in a neighborhood of $x$.

-
In the infinitely differentiable case, necessary conditions for such $x$ include $f'(x)=0$. If $f(x)=1$, then $f''(x)\leq 0$, and if $f(x)=-1$, then $f''(x)\geq 0$. – Jonas Meyer Jan 20 '13 at 4:00


text:
# Oscillation of the plank

1 vote
180 views

In the figure shown a plank of mass M is placed on a smooth horizontal surface . Two light identical springs of stiffness k each are rigidly connected to struts at the ends of the plank as shown in the figure

When the springs are in their unextended positions the distance between their free ends is 3l. A block of mass m is placed on the plank and pressed against one of the spring so that it is compressed by a length I. To keep the block at rest it is connected to the strut by means of a light string as shown in the figure. Initially,the system is at rest and the string is burnt through. Then (ignore any friction.) we have to find the period of oscillation of the plank .

I tried as

Now how to proceed , the answer given as

edited Jan 24, 2017

The CM of the plank and block must remain stationary, because there are no net external forces acting. So the period of $M$ is the same as that of $m$.
I don't understand where the answer you have been given is coming from.

Possibly the block $m$ is not attached to the springs, so the springs only exert a force on $m$ when they are compressed. If so, your question needs to be altered. I think you have missed out several words or phrases, some of which are crucial to understanding the problem.

Please edit your question to show the **exact wording** of the problem you have been given.

Assuming that the springs do not extend, the next step is to find the velocity of the block $m$ relative to the plank as it travels between the springs. If the time taken to travel this distance is $t_2$ then the period of the motion is $2(2t_1+t_2)$.
Sorry for the inconvenience .  This is the exact question http://dc.allenbpms.in/testpaper/solution/d8676-28-636206202521737165-028s.gif
Whoever photocopied the question missed some text on the right. Perhaps missing text is also preventing you from understanding the solution. Do you understand the problem now? Is there anything in the given solution which you still do not understand?
Yes the steps done after we got $t_1$
Can you be more specific?
I just don't get how they have written this  http://i.imgur.com/R0WbjOS.jpg
But your answer given has good explanation , that has cleared my doubt

1 vote

The oscillation of the plank and block can be considered in 2 parts.

In the SHM part of the motion the block is in contact with one of the 2 springs. The springs are never extended, only compressed, but as one spring is compressed the forces between the block and plank are the same as if the other spring were extended. So ignoring what happens in the gap, the system is equivalent to a two mass one spring system. The angular frequency of this motion is given by $\omega^2=\frac{k}{\mu}$ where $\mu=\frac{mM}{m+M}$ is the reduced mass. The period of this oscillation is $T=\frac{2\pi}{\omega}$.

In the other part of the motion the block and plank are moving towards each other with constant velocity, starting from a distance $3\textit{l}$ apart, because that is the separation of the relaxed springs. (I assume the block has negligible width, otherwise this separation must be reduced by the width of the block.) There is no PE stored in the spring at this stage, so the total KE now equals the initial PE :
$\frac12k\textit{l}^2=\frac12mv^2+\frac12MV^2$.

Momentum is conserved so $MV=mv$ hence $MV^2=(\frac{m}{M})mv^2$. The relative velocity of approach between block and the far spring is
$v+V=v(1+\frac{m}{M})=mv/\mu$.
Therefore
$k\textit{l}^2=(1+\frac{m}{M})mv^2=m^2v^2/\mu$
$(mv)^2=\mu k \textit{l}^2=\frac{k}{\mu}(\mu\textit{l})^2$
$mv=\omega \mu\textit{l}$.

The time taken to cover the round-trip distance of $2\times 3\textit{l}$ between the springs is
$t=\frac{6\textit{l}}{v+V}=\frac{6\textit{l} \mu}{mv}=\frac{6\textit{l} \mu}{\omega \mu \textit{l}}=\frac{6}{\omega}$.

Therefore the total period of the oscillation is $T+t=(2\pi+6)\frac{1}{\omega}$.

answered Jan 24, 2017 by (26,096 points)
edited Jan 24, 2017


text:
# Find the derivative of y=sin(pi x)

Trigonometric Functions
Find the derivative of
$$y=\sin(\pi x)$$

The outside function here is $$f(x)=\sin(x)$$. Remember that its derivative is $$\cos(x)$$
The inside function is $$g(x)=\pi x$$. The derivative of this is clearly $$\pi$$.
Putting these together we get $$f′=\cos(\pi x)\times \pi=\pi \cos(\pi x)$$ where the $$\pi x$$ in the coscos function comes from the fact that we also need to remember to put the same argument of the outside function back in when multiplying.


text:
# sysmetric tridiagonal matrix

• November 17th 2008, 04:57 PM
tinng
sysmetric tridiagonal matrix
For the following symmetric matrix A, find a symmetric tridiagonal matrix T, such that A and T have the same eigenvalues.

A=
[ 2 1 0 0
1 1 2 2
0 2 0 -1
0 2 -1 4]
• November 18th 2008, 10:49 AM
Opalg
Quote:

Originally Posted by tinng
For the following symmetric matrix A, find a symmetric tridiagonal matrix T, such that A and T have the same eigenvalues.

$A=\begin{bmatrix}2&1&0&0\\ 1&1&2&2\\ 0&2&0&-1\\ 0&2&-1&4\end{bmatrix}$

I suspect that you're meant to do this using Householder's method. Notice that the only things that stop A from being already tridiagonal are the 2s at the bottom of the second column and the end of the second row. We somehow have to get rid of them.

Start by splitting A into 2×2 blocks: $A = \begin{bmatrix}B&C^{\,\textsc{t}}\\C&D\end{bmatrix }$, where $B = \begin{bmatrix}2&1\\1&1\end{bmatrix}$, $C = \begin{bmatrix}0&2\\0&2\end{bmatrix}$, $D = \begin{bmatrix}0&-1\\-1&4\end{bmatrix}$.

Let Q be a 2×2 orthogonal matrix, and let P be the 4×4 matrix with 2×2-block decomposition $P = \begin{bmatrix}I&O\\O&Q\end{bmatrix}$, where I is the identity and the Os are zero matrices. Then P is orthogonal, and

$PAP^{\textsc{t}} = \begin{bmatrix}B&C^{\,\textsc{t}}Q^{\textsc{t}}\\ QC&QDQ^{\textsc{t}}\end{bmatrix}.\qquad(*)$

We need to choose Q so that the bottom right-hand element of QC is 0, or in other words $Q\begin{bmatrix}2\\2\end{bmatrix} = \begin{bmatrix}*\\0\end{bmatrix}$. In general, this can be done by Householder's method of using reflection matrices. In this case, there is also a straightforward geometric solution, taking Q to be the matrix representing a clockwise rotation through π/4. Then $Q = \begin{bmatrix}1/\sqrt2&1/\sqrt2\\ -1/\sqrt2&1/\sqrt2\end{bmatrix}$, and $Q\begin{bmatrix}2\\2\end{bmatrix} = \begin{bmatrix}2\sqrt2\\0\end{bmatrix}.$ Plug this into the equation (*), and you get $PAP^{\textsc{t}} = \begin{bmatrix}2&1&0&0\\ 1&1&2\sqrt2&0\\ 0&2\sqrt2&1&2\\ 0&0&2&3\end{bmatrix}.$

That matrix is visibly symmetric and tridiagonal, and it has the same eigenvalues as A because it is orthogonally equivalent to it.


text:
# Multicol layout with consistent blank column

So I am looking to create a standardized test with math questions going down the left side of page with space for figuring on the right side of page. My goal is to get code that is clean, where I would not have to break the text for each page. Here is a sample image of what I am trying to do.

If I were to use multicols environment, I would have to break the text every four questions and restart on each page. Is there an easier way to do this? Will a longtable work where I could fill the left cell with all the questions, and have the heading "USE THIS SPACE FOR FIGURING" on each page? Or maybe a absolute positioned node?

MWE:

\documentclass[letterpaper,twoside,openright]{memoir}
\usepackage{lipsum}
\usepackage{multicol}
\usepackage[bmargin=1in]{geometry}

%---------          Preamble
\newsavebox{\fmbox}
\newenvironment{fmpage}[1]
{\begin{lrbox}{\fmbox}\begin{minipage}{#1}}
{\end{minipage}\end{lrbox}\fbox{\usebox{\fmbox}}} %

{\vspace*{1in}
{\noindent
{\center
{\textbf{#1}}}}}

%---------          Document
\begin{document}
\psechead{SECTION 2 \\ Time - 35 Minutes \\ 37 Questions \\}

%---------          Directions

\begin{fmpage}{\textwidth}
\underline{\textbf{Directions:}} In this section there are four possible answers after each question. Choose which one is best. You may use the blank space at the right of the page for figuring problems.

\medskip

\underline{\textbf{Note:}} Figures are not drawn to scale.
\end{fmpage}

%---------          Questions

\end{document}

-
What's wrong with using a custom environment based on minipages? –  jon Feb 21 at 4:11

You can try the paracol package instead of multicol.

In this way you can write all your questions on the first column and then, after issuing

\switchcolumn

you can start writing the code for each page in the second column, for example

{\hfill USE THIS SPACE FOR FIGURING}\vfill{\hfill\small GO ON THE NEXT PAGE}

for all pages and

{\hfill USE THIS SPACE FOR FIGURING}

for the last page.

MWE (note that I've slightly modified your fmpage environment so to not overflow the right margin):

\documentclass[letterpaper,twoside,openright]{memoir}
\usepackage{lipsum}
\usepackage{paracol}
\usepackage[bmargin=1in]{geometry}

%---------          Preamble
\newsavebox{\fmbox}
\newenvironment{fmpage}[1]
{\noindent\begin{lrbox}{\fmbox}\begin{minipage}{\dimexpr#1-2\fboxrule-2\fboxsep}}
{\end{minipage}\end{lrbox}\fbox{\usebox{\fmbox}}\vspace*{.2in}} %

{\vspace*{1in}
{\noindent
{\centering
{\textbf{#1}}}}}

%---------          Document
\begin{document}
\psechead{SECTION 2 \\ Time - 35 Minutes \\ 37 Questions \\}

%---------          Directions

\begin{fmpage}{\textwidth}
\underline{\textbf{Directions:}} In this section there are four possible answers after each question. Choose which one is best. You may use the blank space at the right of the page for figuring problems.

\medskip

\underline{\textbf{Note:}} Figures are not drawn to scale.
\end{fmpage}

%---------          Questions
\begin{paracol}{2}
\begin{enumerate}
\item This is a question. Choose the appropriate answer.
\begin{enumerate}
\end{enumerate}
\end{enumerate}
\begin{enumerate}
\item This is a question. Choose the appropriate answer.
\begin{enumerate}
\end{enumerate}
\end{enumerate}
\begin{enumerate}
\item This is a question. Choose the appropriate answer.
\begin{enumerate}
\end{enumerate}
\end{enumerate}
\begin{enumerate}
\item This is a question. Choose the appropriate answer.
\begin{enumerate}
\end{enumerate}
\end{enumerate}
\newpage
\begin{enumerate}
\item This is a question. Choose the appropriate answer.
\begin{enumerate}
\end{enumerate}
\end{enumerate}
\begin{enumerate}
\item This is a question. Choose the appropriate answer.
\begin{enumerate}
\end{enumerate}
\end{enumerate}
\begin{enumerate}
\item This is a question. Choose the appropriate answer.
\begin{enumerate}
\end{enumerate}
\end{enumerate}
\begin{enumerate}
\item This is a question. Choose the appropriate answer.
\begin{enumerate}
\end{enumerate}
\end{enumerate}
\begin{enumerate}
\item This is a question. Choose the appropriate answer.
\begin{enumerate}
\end{enumerate}
\end{enumerate}
\begin{enumerate}
\item This is a question. Choose the appropriate answer.
\begin{enumerate}
\end{enumerate}
\end{enumerate}
\newpage
\begin{enumerate}
\item This is a question. Choose the appropriate answer.
\begin{enumerate}
\end{enumerate}
\end{enumerate}
\begin{enumerate}
\item This is a question. Choose the appropriate answer.
\begin{enumerate}
\end{enumerate}
\end{enumerate}

\switchcolumn

\vspace*{\baselineskip}
{\hfill USE THIS SPACE FOR FIGURING}\vfill{\hfill\small GO ON THE NEXT PAGE}
\newpage
{\hfill USE THIS SPACE FOR FIGURING}\vfill{\hfill\small GO ON THE NEXT PAGE}
\newpage
{\hfill USE THIS SPACE FOR FIGURING}
\end{paracol}

\end{document}

Output:

-

I was curious about whether this could be done with flowfram. This is much better than the crude use of longtable I used before. (Whether or not it has anything to be said for it in light of karkoeller's answer, I leave as an exercise for the reader.)

flowfram allows you to basically break up the body of the document into different frames and to specify how text should flow (or not flow) through them. What we'd essentially like in this case is to have a special frame on the first page for the exam header and instructions, a frame on the left where the questions can flow from page to page, and a frame on the right which contains just the standard instruction to use the space for calculations. After the first page, we don't need the special heading so we just want two frames taking the full height of text.

So basically, we need to define 5 frames:

1. examhead: a static frame which will appear only on the first page;
2. firstqns: a flow frame for the first page which doesn't eat into the heading;
3. firstfiguring: a static frame for the first page which doesn't eat the heading and which text can't flow into unless we put it there;
4. mainqns: a flow frame for all later pages which questions can flow through;
5. mainfiguring: a static frame for all later pages which text can't flow into unless we put it there.

Note that because text flows through the frames on the left, you have to prevent questions breaking across pages if you don't want that. I've indicated how to do so using a commented call to \framebreak below.

Here's the result:

Here's the code:

\documentclass[letterpaper,twoside,openright]{memoir}
\usepackage{kantlipsum}
\usepackage[bmargin=1in]{geometry}
\usepackage{enumitem}
\setlist[enumerate,1]{labelindent=0em,align=left,label=\arabic*.}
\setlist[enumerate,2]{label=(\Alph*)}
\usepackage{flowfram}
\newflowframe[1]{.5\textwidth}{.75\textheight}{0pt}{0pt}[firstqns]
\newflowframe[>1]{.5\textwidth}{\textheight}{0pt}{0pt}[mainqns]
\newstaticframe[1]{.5\textwidth}{.75\textheight}{.5\textwidth}{0pt}[firstfiguring]
\newstaticframe[>1]{.5\textwidth}{\textheight}{.5\textwidth}{0pt}[mainfiguring]
\setstaticcontents*{firstfiguring}{%
\centering USE THIS SPACE FOR FIGURING.\vspace*{\fill} }
\setstaticcontents*{mainfiguring}{ \centering USE THIS SPACE FOR FIGURING.\vspace*{\fill} }

%---------          Preamble
\newsavebox{\fmbox}
\newenvironment{fmpage}[1]
{\begin{lrbox}{\fmbox}\begin{minipage}{#1}}
{\end{minipage}\end{lrbox}\fbox{\usebox{\fmbox}}} %

{\vspace*{1in}
{\noindent
{\center
{\textbf{#1}}}}}

\psechead{SECTION 2 \\ Time - 35 Minutes \\ 37 Questions \\}

\begin{fmpage}{\textwidth}
\underline{\textbf{Directions:}} In this section there are four possible answers after each question. Choose which one is best. You may use the blank space at the right of the page for figuring problems.

\medskip

\underline{\textbf{Note:}} Figures are not drawn to scale.
\end{fmpage}
\end{staticcontents*}

%---------          Document
\begin{document}

%---------          Questions
\raggedright
\begin{enumerate}[series=myqns]
\item This is the first question. It is about aardvarks and shampoo.
\begin{enumerate}
\item This answer is just like the others.
\end{enumerate}
\item This is the second question. This question needs no answer.
\begin{enumerate}
\item This answer needs no question.
\item This answer needs a particular question.
\item This answer needs a pedantic question.
\item This answer needs no question today.
\end{enumerate}
\item This is the fourth question. This question needs a new home.
\begin{enumerate}
\item This answer needs happy question.
\item This answer needs a great question.
\item This answer needs furry question.
\end{enumerate}
\item This is the third question. It is misplaced and has wandered.
\begin{enumerate}
\item This answer needs a question.
\item This answer needs some question.
\item This answer needs no question.
\item This answer needs any question.
\end{enumerate}
%     \framebreak% uncomment this if you don't want the next question broken across pages
\item This is the fifth question. This question needs no answer.
\begin{enumerate}
\item This answer needs a better question.
\item This answer needs every question.
\item This answer needs nobody's question.
\item This answer needs someone's question.
\end{enumerate}
\item \kant[1-2]
\begin{enumerate}
\item Kant.
\item Not Kant.
\item Maybe Kant.
\item Who's Kant?
\end{enumerate}
\end{enumerate}
\makeoddfoot{headings}{}{}{}% we don't want continuation text on the last page whether it is odd or even!


text:
# If $$x + \frac{1}{x}=5,$$ x ≠ 0 then the value of  $$\frac{{{x^4} + \frac{1}{{{x^2}}}}}{{{x^2} - 3x + 1}}$$ is equal to:

This question was previously asked in
SSC CHSL Previous Paper 106 (Held On: 20 Oct 2020 Shift 2)
View all SSC CHSL Papers >
1. 60
2. 65
3. 55
4. 50

Option 3 : 55

## Detailed Solution

Given:

$$x + \frac{1}{x} = 5$$

Concept use:

$$x + \frac{1}{x} = k$$

$${x^3} + \frac{1}{{{x^3}}} = {k^3} - 3k$$

Calculation:

$$x + \frac{1}{x} = 5$$

$$\frac{{{x^4} + \frac{1}{{{x^2}}}}}{{{x^2} - 3x + 1}}$$

⇒ $$x({x^3} + 1/{x^3})/x(x + 1/x - 3)$$

⇒ $${x^3} + \frac{1}{{{x^3}}} = 125 - 3 \times 5$$

⇒ $${x^3} + \frac{1}{{{x^3}}} = 110$$

Put equation 1 & 2 in 3

⇒ 110/(5 – 3)

⇒ 55

∴ The value of  $$\frac{{{x^4} + \frac{1}{{{x^2}}}}}{{{x^2} - 3x + 1}}$$ is 55.


text:
# 15.1.1.2.1.1. cobra.flux_analysis.deletion¶

## 15.1.1.2.1.1.1. Module Contents¶

cobra.flux_analysis.deletion._reactions_knockouts_with_restore(model, reactions)[source]
cobra.flux_analysis.deletion._get_growth(model)[source]
cobra.flux_analysis.deletion._reaction_deletion(model, ids)[source]
cobra.flux_analysis.deletion._gene_deletion(model, ids)[source]
cobra.flux_analysis.deletion._reaction_deletion_worker(ids)[source]
cobra.flux_analysis.deletion._gene_deletion_worker(ids)[source]
cobra.flux_analysis.deletion._init_worker(model)[source]
cobra.flux_analysis.deletion._multi_deletion(model, entity, element_lists, method="fba", solution=None, processes=None, **kwargs)[source]

Provide a common interface for single or multiple knockouts.

Parameters: model (cobra.Model) – The metabolic model to perform deletions in. entity ('gene' or 'reaction') – The entity to knockout (cobra.Gene or cobra.Reaction). element_lists (list) – List of iterables cobra.Reactions or cobra.Genes (or their IDs) to be deleted. method ({"fba", "moma", "linear moma", "room", "linear room"}, optional) – Method used to predict the growth rate. solution (cobra.Solution, optional) – A previous solution to use as a reference for (linear) MOMA or ROOM. processes (int, optional) – The number of parallel processes to run. Can speed up the computations if the number of knockouts to perform is large. If not passed, will be set to the number of CPUs found. kwargs – Passed on to underlying simulation functions. A representation of all combinations of entity deletions. The columns are ‘growth’ and ‘status’, where index : frozenset([str]) The gene or reaction identifiers that were knocked out. growth : float The growth rate of the adjusted model. status : str The solution’s status. pandas.DataFrame
cobra.flux_analysis.deletion._entities_ids(entities)[source]
cobra.flux_analysis.deletion._element_lists(entities, *ids)[source]
cobra.flux_analysis.deletion.single_reaction_deletion(model, reaction_list=None, method="fba", solution=None, processes=None, **kwargs)[source]

Knock out each reaction from a given list.

Parameters: model (cobra.Model) – The metabolic model to perform deletions in. reaction_list (iterable, optional) – cobra.Reactions to be deleted. If not passed, all the reactions from the model are used. method ({"fba", "moma", "linear moma", "room", "linear room"}, optional) – Method used to predict the growth rate. solution (cobra.Solution, optional) – A previous solution to use as a reference for (linear) MOMA or ROOM. processes (int, optional) – The number of parallel processes to run. Can speed up the computations if the number of knockouts to perform is large. If not passed, will be set to the number of CPUs found. kwargs – Keyword arguments are passed on to underlying simulation functions such as add_room. A representation of all single reaction deletions. The columns are ‘growth’ and ‘status’, where index : frozenset([str]) The reaction identifier that was knocked out. growth : float The growth rate of the adjusted model. status : str The solution’s status. pandas.DataFrame
cobra.flux_analysis.deletion.single_gene_deletion(model, gene_list=None, method="fba", solution=None, processes=None, **kwargs)[source]

Knock out each gene from a given list.

Parameters: model (cobra.Model) – The metabolic model to perform deletions in. gene_list (iterable) – cobra.Genes to be deleted. If not passed, all the genes from the model are used. method ({"fba", "moma", "linear moma", "room", "linear room"}, optional) – Method used to predict the growth rate. solution (cobra.Solution, optional) – A previous solution to use as a reference for (linear) MOMA or ROOM. processes (int, optional) – The number of parallel processes to run. Can speed up the computations if the number of knockouts to perform is large. If not passed, will be set to the number of CPUs found. kwargs – Keyword arguments are passed on to underlying simulation functions such as add_room. A representation of all single gene deletions. The columns are ‘growth’ and ‘status’, where index : frozenset([str]) The gene identifier that was knocked out. growth : float The growth rate of the adjusted model. status : str The solution’s status. pandas.DataFrame
cobra.flux_analysis.deletion.double_reaction_deletion(model, reaction_list1=None, reaction_list2=None, method="fba", solution=None, processes=None, **kwargs)[source]

Knock out each reaction pair from the combinations of two given lists.

We say ‘pair’ here but the order order does not matter.

Parameters: model (cobra.Model) – The metabolic model to perform deletions in. reaction_list1 (iterable, optional) – First iterable of cobra.Reactions to be deleted. If not passed, all the reactions from the model are used. reaction_list2 (iterable, optional) – Second iterable of cobra.Reactions to be deleted. If not passed, all the reactions from the model are used. method ({"fba", "moma", "linear moma", "room", "linear room"}, optional) – Method used to predict the growth rate. solution (cobra.Solution, optional) – A previous solution to use as a reference for (linear) MOMA or ROOM. processes (int, optional) – The number of parallel processes to run. Can speed up the computations if the number of knockouts to perform is large. If not passed, will be set to the number of CPUs found. kwargs – Keyword arguments are passed on to underlying simulation functions such as add_room. A representation of all combinations of reaction deletions. The columns are ‘growth’ and ‘status’, where index : frozenset([str]) The reaction identifiers that were knocked out. growth : float The growth rate of the adjusted model. status : str The solution’s status. pandas.DataFrame
cobra.flux_analysis.deletion.double_gene_deletion(model, gene_list1=None, gene_list2=None, method="fba", solution=None, processes=None, **kwargs)[source]

Knock out each gene pair from the combination of two given lists.

We say ‘pair’ here but the order order does not matter.

Parameters: model (cobra.Model) – The metabolic model to perform deletions in. gene_list1 (iterable, optional) – First iterable of cobra.Genes to be deleted. If not passed, all the genes from the model are used. gene_list2 (iterable, optional) – Second iterable of cobra.Genes to be deleted. If not passed, all the genes from the model are used. method ({"fba", "moma", "linear moma", "room", "linear room"}, optional) – Method used to predict the growth rate. solution (cobra.Solution, optional) – A previous solution to use as a reference for (linear) MOMA or ROOM. processes (int, optional) – The number of parallel processes to run. Can speed up the computations if the number of knockouts to perform is large. If not passed, will be set to the number of CPUs found. kwargs – Keyword arguments are passed on to underlying simulation functions such as add_room. A representation of all combinations of gene deletions. The columns are ‘growth’ and ‘status’, where index : frozenset([str]) The gene identifiers that were knocked out. growth : float The growth rate of the adjusted model. status : str The solution’s status. pandas.DataFrame


text:
## Square matrices

A square matrix is a matrix with the same number of rows and columns. An n-by-n matrix is known as a square matrix of order n. Any two square matrices of the same order can be added and multiplied. The entries aii form the main diagonal of a square matrix. They lie on the imaginary line which runs from the top left corner to the bottom right corner of the matrix.

### Main types

Name Example with n = 3
Diagonal matrix $\begin{bmatrix} a_{11} & 0 & 0 \\ 0 & a_{22} & 0 \\ 0 & 0 & a_{33} \\ \end{bmatrix}$
Lower triangular matrix $\begin{bmatrix} a_{11} & 0 & 0 \\ a_{21} & a_{22} & 0 \\ a_{31} & a_{32} & a_{33} \\ \end{bmatrix}$
Upper triangular matrix $\begin{bmatrix} a_{11} & a_{12} & a_{13} \\ 0 & a_{22} & a_{23} \\ 0 & 0 & a_{33} \\ \end{bmatrix}$

#### Diagonal or triangular matrix

If all entries outside the main diagonal are zero, A is called a diagonal matrix. If only all entries above (or below) the main diagonal are zero, A is called a lower (or upper) triangular matrix.

#### Identity matrix

The identity matrix In of size n is the n-by-n matrix in which all the elements on the main diagonal are equal to 1 and all other elements are equal to 0, e.g.
$I_1 = \begin{bmatrix} 1 \end{bmatrix} ,\ I_2 = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} ,\ \cdots ,\ I_n = \begin{bmatrix} 1 & 0 & \cdots & 0 \\ 0 & 1 & \cdots & 0 \\ \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & \cdots & 1 \end{bmatrix}$
It is a square matrix of order n, and also a special kind of diagonal matrix. It is called identity matrix because multiplication with it leaves a matrix unchanged:
AIn = ImA = A for any m-by-n matrix A.

#### Symmetric or skew-symmetric matrix

A square matrix A that is equal to its transpose, i.e., A = AT, is a symmetric matrix. If instead, A was equal to the negative of its transpose, i.e., A = −AT, then A is a skew-symmetric matrix. In complex matrices, symmetry is often replaced by the concept of Hermitian matrices, which satisfy A = A, where the star or asterisk denotes the conjugate transpose of the matrix, i.e., the transpose of the complex conjugate of A.
By the spectral theorem, real symmetric matrices and complex Hermitian matrices have an eigenbasis; i.e., every vector is expressible as a linear combination of eigenvectors. In both cases, all eigenvalues are real. This theorem can be generalized to infinite-dimensional situations related to matrices with infinitely many rows and columns, see below.

#### Invertible matrix and its inverse

A square matrix A is called invertible or non-singular if there exists a matrix B such that
AB = BA = In.
If B exists, it is unique and is called the inverse matrix of A, denoted A−1.

#### Definite matrix

Positive definite matrix Indefinite matrix
$\begin{bmatrix} 1/4 & 0 \\ 0 & 1 \\ \end{bmatrix}$ $\begin{bmatrix} 1/4 & 0 \\ 0 & -1/4 \end{bmatrix}$
Q(x,y) = 1/4 x2 + y2 Q(x,y) = 1/4 x2 − 1/4 y2

Points such that Q(x,y)=1
(Ellipse).

Points such that Q(x,y)=1
(Hyperbola).
A symmetric n×n-matrix is called positive-definite (respectively negative-definite; indefinite), if for all nonzero vectors x ∈ Rn the associated quadratic form given by
Q(x) = xTAx
takes only positive values (respectively only negative values; both some negative and some positive values). If the quadratic form takes only non-negative (respectively only non-positive) values, the symmetric matrix is called positive-semidefinite (respectively negative-semidefinite); hence the matrix is indefinite precisely when it is neither positive-semidefinite nor negative-semidefinite.
A symmetric matrix is positive-definite if and only if all its eigenvalues are positive. The table at the right shows two possibilities for 2-by-2 matrices.
Allowing as input two different vectors instead yields the bilinear form associated to A:
BA (x, y) = xTAy.

#### Orthogonal matrix

An orthogonal matrix is a square matrix with real entries whose columns and rows are orthogonal unit vectors (i.e., orthonormal vectors). Equivalently, a matrix A is orthogonal if its transpose is equal to its inverse:
$A^\mathrm{T}=A^{-1}, \,$
which entails
$A^\mathrm{T} A = A A^\mathrm{T} = I, \,$
where I is the identity matrix.
An orthogonal matrix A is necessarily invertible (with inverse A−1 = AT), unitary (A−1 = A*), and normal (A*A = AA*). The determinant of any orthogonal matrix is either +1 or −1. A special orthogonal matrix is an orthogonal matrix with determinant +1. As a linear transformation, every orthogonal matrix with determinant +1 is a pure rotation, while every orthogonal matrix with determinant -1 is either a pure reflection, or a composition of reflection and rotation.
The complex analogue of an orthogonal matrix is a unitary matrix.


text:
CGAL 4.12 - 3D Alpha Shapes
AlphaShapeVertex_3 Concept Reference

## Definition

The concept AlphaShapeVertex_3 describes the requirements for the base vertex of an alpha shape.

Refines:

TriangulationVertexBase_3, if the underlying triangulation of the alpha shape is a Delaunay triangulation.

RegularTriangulationVertexBase_3, if the underlying triangulation of the alpha shape is a regular triangulation.

Periodic_3TriangulationDSVertexBase_3, if the underlying triangulation of the alpha shape is a periodic triangulation.

Has Models:
CGAL::Alpha_shape_vertex_base_3 (templated with the appropriate triangulation vertex base class).
CGAL::Alpha_status

## Types

typedef unspecified_type Point
Must be the same as the point type provided by the geometric traits class of the triangulation.

typedef unspecified_type Alpha_status
Must be CGAL::Alpha_status<NT> where NT is the number type used in the geometric traits class of the triangulation.

## Creation

AlphaShapeVertex_3 ()
default constructor.

AlphaShapeVertex_3 (Point p)
constructor setting the point.

AlphaShapeVertex_3 (Point p, const Cell_handle &c)
constructor setting the point and an incident cell.

## Modifiers

Alpha_statusget_alpha_status ()
Returns a pointer the alpha status of the vertex.