This sandbox is intended for saving drafts of long, complex posts, especially posts whose composition takes a long time. It serves to localize to one thread the front-page "bumps" caused by edits to drafts of such posts, so that they may be easily ignored. Also, it helps to guard against losing longly-composed posts due to system crashes.

When you are happy with your draft here, you may simply copy the code and paste it to the desired location.

Proper Use of the Sandbox

  1. Do not post a new answer! We wish all the answers on this page to be owned by the Community user (so that only a non-sentient bot is informed of edits to these answers). Posting a new answer will make you the owner, meaning that you will be notified whenever another user makes an edit to that answer.

    The sandbox has been closed to prevent the creation of new answers. There are more than enough existing answers for users to edit over, and this will greatly reduce the frequency at which we request that the answers be disassociated from specific users.

  2. Do not delete answers! Deleting seems like a reasonable option, but there are no "hard deletions" on Stack Exchange, and users will sufficient privileges will still see your supposedly deleted postings. Deleted answers will be undeleted and cleared for the use of others.

  3. Do look for an answer which indicates that it is free and then edit it to your heart's content. If none appears available, take over the one that has been left unchanged the longest (which will appear at the bottom of the page if you order answers by "activity").

  4. Do not expect your draft to remain untouched for days. There are no guarantees that your draft will be the latest revision if you return days later. While users will try not to step over others' toes, it may happen that an unfinished draft is edited out. Your draft will, however, still exist as a revision of the answer it was made in. If your drafting is expected to take place over a longer period of time, either

    • take note of the URL of the answer provided by clicking the share button, or
    • save a copy of your draft locally (or even "in the cloud").
  5. Do clear your draft when you are finished. This includes removing all $\LaTeX$ from your answers. Replacing all code with a simple statement like

    This answer is free for anyone to use

    is sufficient. Periodically users may go through and free up answer slots that have not been edited in, say, over one month. But you can aid in the smooth running of this sandbox by clearing away your drafts when you are finished with them.

  6. Do not "claim" multiple answers concurrently. Since this post is closed, the answers are a limited resource. If you really must compose several long, complex posts at the same time, you can still use a single answer, separating the different drafts using Markup: horizontal rules (---) and/or headings (# Header 1 #) are natural choices.

  7. Do not create new such sandboxes. The point of having a unique such sandbox is that it minimizes the noise on the front page when the sandbox is edited. If there were multiple sandboxes they will frequently occupy numerous front page slots, pushing other topics off the front page, and increasing noise.


put on hold as off-topic by Arthur Fischer 2 days ago

  • This question does not appear to be about Mathematics Stack Exchange or the software that powers the Stack Exchange network within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

I have added a [sandbox] tag to allow people ignore it more easily (via software support of ignoring tags), and since it seems that we have two sandboxes now, a tag may seem a bit more in place here. –  Asaf Karagila Jul 18 '12 at 8:35
(+1) For thinking outside the (sand)box. –  cardinal Jul 18 '12 at 19:40
At the suggestion of the moderators, I have gone and changed the associated owners of all the answers here to the Community user. This way, the original owners will not receive excess pings for each time another user uses the draft space for their work. Enjoy! –  Grace Note Oct 5 '12 at 14:45
To prevent crashes I've found the "Bookmarks to disable/enable MathJax", provided in here, pretty useful. –  leo Dec 17 '12 at 18:03
This "sandbox" is being closed to prevent the creation of new answers. To start a draft, simply edit one of the existing free answers. –  Arthur Fischer 2 days ago

17 Answers 17

This answer is free for anyone to use.


In this game, the character have skill points ($\newcommand\spts{\operatorname{spts}}\spts$) and intelligence points ($\newcommand\Int{\operatorname{Int}}\Int$). Let $\spts_n$ the skillpoints at level $n$. At the end of each level the skillpoints for the next level are calculated according following the rule: $$\spts_{n+1} = \spts_n + \left\lfloor \frac{\Int}{2}\right\rfloor.$$ (the calculations are a little different at first level, but this shouldn't be an issue. I'm just mentioning it to avoid questions on the math in the spreadsheet I'm going to link later.)

My aim is maximizing this skillpoint gain over several levels, by identifying the best way to spend resources on increasing $\Int$.

$\Int$ can be increased according by purchasing tomes. They are subject to the following:

  • There are 5 tomes, the $i$th tome increases $\Int$ by $i$ points
  • Tomes are not cumulative. Each time a tome is used, only the greatest single $\Int$ increase from all tomes bought to that point applies
  • (this is another way to express the previous dotted element) If you've purchased several tomes, say tomes $i_1,\ldots, i_m$, here $1\leq m\leq 5$, then the total increase of $\Int$ from tomes would be of $\max\{i_1,\ldots, i_m\}$.
  • This means it's useless to buy tomes with $i\leq i_m$, where $i_m$ is the best tome you've bought at the moment.
  • This also means it's useless to buy more than one tome at each level.
  • The $\spts$ expression makes it also useless to buy tomes adding odd amounts of $\Int$ if the initial $\Int$ value is even and even amounts of $\Int$ if the initial $\Int$ value is odd.
  • Each tome costs $i$ times the price of the $1$st tome
  • During each level, the character gains a fixed amount of money. The running total of gained money at each level is given.
  • $\spts$ are calculated based on the Int value at the end of the previous level (you can't level up, then buy a tome with the increased budget, then increase your $\spts$)
  • Starting from level $n_a$, tomes can be bought at 80% their market price (this is still not implemented in the spreadsheet)
  • Up to level $n_a$, the character might or might not need to spend only a given fraction of his current money on a single item. Whether that means the remaining money at each level where a tome is purchased needs to be spent for different character upgrades or is usable for the next tome purchase is also a given input

The starting condition is going to be either $\Int_0 = 0$ or $\Int_0 = 1$ or $\Int_0 = 2$.
While the first two starting conditions are somewhat equal (you gain no $\spts$ until you can purchase your first tome), the third one is there to explore the possibility that, under some unfavorable purchasing conditions, voluntarily decreasing the initial $\Int$ by one nets the same or even a bigger amount of $\spts$ by virtue of the different subset of even/odd tomes involved in the problem, even with the starting advantage of $\spts$ gained from $\Int_0 = 2$.

Bobson from RPG.SE made a spreadsheet that can be used for manually solving the problem by inputing the $i$ of each tome in the cell of the level at which it's purchased.
What I'm looking for is some mathematical procedure that automatically finds which tomes should be bought and at which levels to optimize the $\spts$ value at whatever level the progression stabilizes (i.e. at the level following the one that has the last tome purchase in all the different progressions, which could be set to the level following the one where all tomes could be bought at once to avoid unnecessary math).

(I'm waiting for Bobson's spreadsheet to be free of concept errors before posting it)


This answer is free for anyone to use.


We will prove that the $(n+2)$-gon is always the solution for non-intersecting $n$-triangles.


$A_n$ is a set of $n$ triangles satisfying the given conditions.

$s(X)$ is the area of $X \subset \Bbb R^2$.

$ch(A_n)$ is the convex hull of $A_n$, if interpreted as a polygon.

$h(A_n)$ denotes the hull of $A_n$, to elaborate -

Lets consider any candidate solution, $A_n$ (for now we will think of it as a polygon, not a collection of triangles), as a closed set in $\Bbb R^2$. Lets consider the boundary of $A_n$:

  1. if we are dealing with a simple polygon, then the boundary, ∂$A_n$, is equivalent to the hull, $h(A_n)$;
  2. If not, then the hull is a connected subset of the boundary, which contains the most area. If we then take the compliment ∂$A_n \setminus h(A_n)$, we can interpret it as the union of boundaries of closed sets, which are disconnected with $\Bbb R^2$. We will call said sets holes;

$v_h(A_n)$ equals the amount of vertices in $h(A_n)$.

$v_{ch}(A_n)$ equals the amount of vertices in $ch(A_n)$.


Postulate: If moving a set of vertices in $A_n$ can increase the total area and not violate the given conditions, then $A_n$ is not a solution.

Postulate 2: If we remove three adjacent vertices in a convex polygon, the remaining vertices are still in convex arrangement.

Triangulation theorem : Any simple polygon with $N$ vertices, can always be triangulated into $N - 2$ triangles. Conversely from $n$ triangles we can assemble a polygon with $n+2$ vertices. All triangles in such a triangulation have their vertices in the hull of the polygon.

Lemma 1: If $A \subsetneq B \subseteq \Bbb R^2$, then $s(A) < s(B)$.

Proof: Since $A \subsetneq B$, thus $B \setminus A \neq \varnothing$. From this it follows that $s(A) < s(B)$.

Proposition 1: $v_h(A_n) \ge n + 2$.

By definition $v_{ch}(A_n) \le v_h(A_n)$. There are four cases:

  1. $v_{ch}(A_n) = v_h(A_n)$ and $ v_h(A_n) \lt n + 2 $
  2. $v_{ch}(A_n) \lt v_h(A_n)$ and $ v_h(A_n) \lt n + 2 $
  3. $v_{ch}(A_n) = v_h(A_n)$ and $ v_h(A_n) \ge n + 2 $
  4. $v_{ch}(A_n) \lt v_h(A_n)$ and $ v_h(A_n) \ge n + 2 $

The $1$ and $2$ cases are not valid - $A_n$ cannot be a simple polygon with less than $n + 2$ vertices by the converse of the Triangulation Theorem, as we have not used all the given triangles. If $A_n$ is not a simple polygon, then we can swap it out for a simple polygon made from the convex hull of $A_n$, which by Lemma 1 would have greater area, the swap would also produce unused triangles.

Therefore only cases $3$ and $4$ remain, which both verify the proposition.

Corollary: $$n + 2 \le v_h(A_n)\le 3n $$

Proof: LS: from Proposition 1

RS: by virtue of the definition of the $h(A_n)$, it follows that we can place all triangle vertices on the circle to get $3n $ vertices.

Lemma 2 : The smallest area triangle in a convex polygon is always composed of three adjacent vertices.

Proof : Suppose we have a triangle where not all $3$ vertices are adjacent. Let $v$ be a vertex that is not adjacent to either of the other two. Let $a,b$ be the other two vertices. Then the area of the triangle is one half the length of $(a,b)$ multiplied by the height from $(a,b)$ out to $v$. But if $v$ is replaced with one of $v$'s neighbors, then one of the two neighbours must produce a lower height and hence a lower area triangle. Thus all $3$ vertices must be adjacent in a minimum area triangle. Original proof.

Proposition 2: All the vertices of holes are vertices of $h(A_n)$.

Proof: Consider $A_n$ as a polygon, all holes are also polygons. If there is a point not in $h(A_n)$, then it can moved about without changing the hull of the polygon. If we move it onto the one of the vertices of the hole - we will have reduced the amount of vertices of the hole. This process would give us another triangle to fill up the hole, thus increasing the area of $A_n$.

Thus if $A_n$ has a hole, whose vertex is not shared with $h(A_n)$, then $A_n$ is not a solution.

A special case of interest is when a hole has more than half of its vertices not in $h(A_n)$, in such a case it is possible to shrink the entire hole to nothing. This is the case for the example in the OP.

Lemma 3: $ch(A_n) = h(A_n)$

In Lemma 2 two cases remained -

  1. $v_{ch}(A_n) = v_h(A_n)$ and $ v_h(A_n) \ge n + 2 $
  2. $v_{ch}(A_n) \lt v_h(A_n)$ and $ v_h(A_n) \ge n + 2 $

If $v_{ch}(A_n) \lt v_h(A_n)$, then it is worth while to change as by Proposition 2 all holes share their vertices with $h(A_n)$, thus the triangles we gain can be used to fill up the hole. This would increase the total area of $A_n$. Therefore if $A_n$ satisfies the 2 case, $A_n$ is not a solution.

Theorem: $A_n$ is the $(n + 2)$-gon.

Proof: Suppose we fill up all the holes in $A_n$ with triangles, thus producing a simple polygon $P$. Consider the set of all triangulations of $P$. By Lemma 2 it so follows that we can always swap the triangles we used to fill up the hole, with triangles that are made from three adjacent vertices as these will be always smaller. Thus increasing the area.

When we remove a triangle made from three adjacent vertices, by Postulate 2 we remain with a convex polygon, for which Lemma 2 still holds. Therefore we can continue this process until we are left with a convex simple polygon with greater area.

Extending any vertex of a simple convex polygon to the perimeter of the unit circle, increases the area. Thus all the vertices are on the circle.

If we move a point $B$, in between two adjacent points $A$ and $C$, the area of $\Delta ABC$ will be maximum, when the altitude to $B$ is in the middle of $AC$. Therefore, any vertex on the unit circle is equally distanced from its neighbours.

Such a configuration can only be achieved by the $(n+2)$-gon with $n$-triangles.

Therefore, the $(n+2)$-gon, with all of its vertices on the unit circle, is the largest polygon that can be assembled from $n$-triangles.


$=\int_{t_0}^{t_1}[a(t)((\dot{x^*} + \dot{\eta})^2-\dot{x^*}^2)+b(t)((x^* + \eta)^2-{x^*}^2)]\mathrm{d} t$

$=\int_{t_0}^{t_1}[a(t)((\dot{x^*}^2 +2\dot{x^*}\dot{\eta} + \dot{\eta}^2-\dot{x^*}^2)+b(t)({x^*}^2 +2\eta x^*+ \eta^2-{x^*}^2)]\mathrm{d} t$

$=\int_{t_0}^{t_1}[a(t)(( 2\dot{x^*}\dot{\eta} + \dot{\eta}^2)+b(t)(\eta^2)+2x^*b(t)\eta]\mathrm{d} t$

$=\int_{t_0}^{t_1}[a(t)(( 2\dot{x^*}\dot{\eta} + \dot{\eta}^2)+b(t)(\eta^2)]\mathrm{d} t + \int_{t_0}^{t_1} 2x^*b(t)\eta\mathrm{d} t$

$=\int_{t_0}^{t_1}[a(t)(( 2\dot{x^*}\dot{\eta} + \dot{\eta}^2)+ b(t)(\eta^2)]\mathrm{d} t + \int_{t_0}^{t_1} \frac{d}{dt}(2\dot{x^*}a(t))\eta\mathrm{d} t$

$$u=\eta,\quad v'=\frac{d}{dt}(2\dot{x}a(t))$$ $$u'=\dot{\eta},\quad v= 2\dot{x^*}a(t)$$

$$=\left[\eta2\dot{x^*}a(t)\right]_{t_0}^{t_1}-\int_{t_0}^{t_1}\dot{\eta}2\dot{x^*}a(t) \mathrm{d} t$$

$$=0-\int_{t_0}^{t_1}\dot{\eta}2\dot{x^*}a(t) \mathrm{d} t$$

$$=\int_{t_0}^{t_1}[a(t)(( 2\dot{x^*}\dot{\eta} + \dot{\eta}^2)+ b(t)(\eta^2)]\mathrm{d} t -\int_{t_0}^{t_1}\dot{\eta}2\dot{x^*}a(t) \mathrm{d} t$$

$$\Delta J=\int_{t_0}^{t_1}[a(t)\dot{\eta}^2+ b(t)\eta^2]\mathrm{d} t$$



$\left({1+\sqrt5}\over2\right)^n-\left({1+\sqrt5}\over2 \right)^{n-1}\left({1+\sqrt5}\over2\right)^{n-2}= \left({1-\sqrt5}\over2\right)^n-\left({1-\sqrt5}\over2 \right)^{n-1}-\left({1-\sqrt5}\over 2\right)^{n-2}$


The task is to determine the Fourier cosine coefficients of $f(x)=\sqrt{1-k^2 \sin^2 t}$, which are found via direct integration as $\displaystyle a_n=\frac{4}{\pi}\int_0^{\pi/2} \cos(2n t)\sqrt{1-k^2 \sin^2 t}\,dt.$ To compute this, we first expand $\cos(2n t)$ using a general form of the multiple-angle formula (see eq. (37) of this link) $$\cos(2n t)=\sum_{k=0}^n (-1)^k \binom{n}{2k}(\sin t)^{2k}(\cos t)^{2n-2k}$$ and so it's enough to compute $$I_k:=\int_0^{\pi/2} (\sin t)^{2k}(\cos t)^{2n-2k}\sqrt{1-k^2 \sin^2 t}\,dt.$$ This isn't a trivial integral by any means, but entry 3.761.1 in Gradshteyn and Ryzhik yields $$I_k = \frac{1}{2}\text{B}\left(k+\frac{1}{2},n-k+\frac{1}{2}\right){_2F_1}\left(k+\frac{1}{2},-\frac{1}{2};n+1;k^2\right) $$ where B$(x,y)$ is the Euler Beta function and $ _2F_1(a,b;c;x)$ is the (ordinary) hypergeometric series. Since the arguments are all integer or half-integer, these can be simplified to

\begin{align} \text{B}\left(k+\frac{1}{2},n-k+\frac{1}{2}\right) &=\frac{\Gamma(k+\frac{1}{2})\Gamma(n-k+\frac{1}{2})}{\Gamma(n+1)}\\ &=\frac{(2k)!}{4^{k}k!}\pi^{1/2}\cdot \frac{(2n-2k)!}{4^{n-k}(n-k)!}\pi^{1/2}\cdot \frac{1}{n!}\\ &=\frac{\pi}{4^n}\frac{(2n-2k)!(2k)!}{k!(n-k)! n!},\\\\ {_2F_1}\left(k+\frac{1}{2},-\frac{1}{2};n+1;k^2\right) &= \end{align}

It's a linear combination of elliptic integrals, but I don't know which one...


$\int_0^2 \frac{\dot{x}^2}{x^3} \mathrm{d} t$ with $x(0)=1,x(2)=4$

It is of vital importance to notice here that $f$ is independent of $t$, this means the Euler-Lagrangian equation is not $$\frac{\partial f}{\partial x} - \frac{d}{dt}\left[\frac{\partial f}{\partial \dot{x}}\right]$$

But rather it takes the form $$f- \dot{x}\frac{\partial f}{\partial \dot{x}}=C$$

Hence here we have E-L: $$\frac{\dot{x}^2}{x^3}-\frac{2\dot{x}^2}{x^3}=\frac{-\dot{x}^2}{\;\;x^3}=C$$ $$\dot{x}^2=Cx^3$$ $$\frac{dx}{dt}=\sqrt{C}x^{(\frac32)}$$ $$x=\frac{2Cx^{\frac{5}{2}}}{5} + D$$ $$1=\frac{2C}{5}+D$$ $$4=\frac{64C}{5}+D$$ $$\frac{62C}{5}=3$$ $$C=\frac{15}{62}$$


This answer is free for anyone to use


This answer is free for everyone.


This answer is free for anyone to use.


Still drafting - Please leave be until the 20th at earliest

$\int_0^2 \left(\frac12 \dot{x}^2 + x\dot{x} + x + \dot{x} \right) \mathrm{d} t$ with $x(0)=0, x(2)=2$

Since this $f$ doesn't rely on $t$ we have the second form of $E-L$, meaning $$f-\dot{x}\frac{\partial f}{\partial \dot{x}}=C$$ $$\frac12\dot{x}^2 + x\dot{x}+x+\dot{x}-\dot{x}\left[\dot{x}+x+1\right]=C$$ $$\frac12\dot{x}^2 + x\dot{x}+x+\dot{x}-\dot{x}^2-x\dot{x}-\dot{x}=C$$ $$-\frac12\dot{x}^2+x=C$$ $$\dot{x}^2-2x=-2C$$ $$$$


$f(x)=2x^2, \quad -1\leq x\leq 0$

$f(x+1)=f(x),\quad -\infty \lt x \lt \infty$

Here we are looking at a periodic function, with a period of $1$

Meaning $f(-1)=2$, to $f(0)=0$ repeating infinitely. See

This is what we are referring to. Now we want to find the Fourier expansion here. How can this be done?

Well we need to find $A_0, A_n$ and $B_n$

This we know can be done by making the following calculations:


$\Delta J=J[y]-J[x^*]$

$J[x]=\int_{t_0}^{t_1}[a(t)\dot{x}^2+b(t)x^2]\mathrm{d} t$


$\Delta J=J[y]-J[x^*]=\int_{t_0}^{t_1}[a(t)\dot{y}^2+b(t)y^2]\mathrm{d} t -\int_{t_0}^{t_1}[a(t)\dot{x^*}^2+b(t){x^*}^2]\mathrm{d} t$

$\int_{t_0}^{t_1}[a(t)\dot{y}^2+b(t)y^2]-[a(t)\dot{x^*}^2+b(t){x^*}^2]\mathrm{d} t$

$\int_{t_0}^{t_1}[a(t)(\dot{y}^2-\dot{x^*}^2)+b(t)(y^2-{x^*}^2)]\mathrm{d} t$

Let $y = x^* + \eta$ for any $\eta \in C^2[t_0,t_1]$ with $\eta(t_0)=\eta(t_1)=0$

$\dot{y} = \dot{x^*} + \dot{\eta}$

From E-L



$\int_{t_0}^{t_1}[a(t)((\dot{x^*} + \dot{\eta})^2-\dot{x^*}^2)+b(t)((x^* + \eta)^2-{x^*}^2)]\mathrm{d} t$

$\int_{t_0}^{t_1}[a(t)((\dot{x^*}^2 +2\dot{x^*}\dot{\eta} + \dot{\eta}^2-\dot{x^*}^2)+b(t)({x^*}^2 +2\eta x^*+ \eta^2-{x^*}^2)]\mathrm{d} t$

$\int_{t_0}^{t_1}[a(t)((2\dot{x^*}\dot{\eta} + \dot{\eta}^2)+b(t)(2\eta x^*+ \eta^2)]\mathrm{d} t$


$\int_{t_0}^{t_1}a(t)((2\dot{x^*}\dot{\eta})+b(t)(2\eta x^*)\mathrm{d} t$

$\int_{t_0}^{t_1}a(t)((2\dot{x^*}\dot{\eta})\mathrm{d} t+ \int_{t_0}^{t_1}b(t)(2\eta x^*)\mathrm{d} t$

Left integral: $$u=a(t) \quad v' =2\dot{x^*}\dot{\eta}$$ $$\quad \quad \quad \quad \;\;\;\;\;\;\;\;u'=\dot{a}\quad v= \left.2\dot{x^*}\eta\right|_{t_0}^{t_1}+\int_{t_0}^{t_1} 2\ddot{x}\eta\;\mathrm{d}t=0$$

$$0-\int_{t_0}^{t_1} 0 \;\mathrm{d}t=0$$

Right integral:

$$u=2\eta x^* \quad v'=b(t)$$ $$u'=2\dot{\eta}x^*+2\eta\dot{x^*}\quad v=\int_{t_0}^{t_1}b(t) \mathrm{d}\,t$$ $$2\eta x^*\left[\int_{t_0}^{t_1}b(t) \mathrm{d}\,t\right]-\int_{t_0}^{t_1}\left[\left[2\dot{\eta}x^*+2\eta\dot{x^*}\right]\int_{t_0}^{t_1}b(t) \mathrm{d}\,t\right] \mathrm{d}\,t=0$$

Therefore we have:

$J[y] \geq J[x^*]$


From E-L



$\int2xb(t) \mathrm{d} t = 2\dot{x}a(t)$

$\int_{t_0}^{t_1}[a(t)((\dot{x^*}^2 + \dot{\eta}^2-\dot{x^*}^2)+2a(t)\dot{x^*}\dot{\eta}+b(t)({x^*}^2 +2\eta x^*+ \eta^2-{x^*}^2)]\mathrm{d} t$

$\int_{t_0}^{t_1}[a(t)((\dot{x^*}^2 + \dot{\eta}^2-\dot{x^*}^2)+\int2xb(t) \mathrm{d} t\;\dot{\eta}+b(t)({x^*}^2 +2\eta x^*+ \eta^2-{x^*}^2)]\mathrm{d} t$


This answer is free for anyone to use.


This answer is free for anyone to use.