text:
# Are transfers between two orbits commutative?

Are the propellant mass and transfer time from orbit A to orbit B the same as from orbit B to orbit A, considering low-thrust propulsion? That is, in the case of dealing with Keplerian orbit parameters and having both points in the sphere of influence of Earth with any third body or perturbation effects neglected. In other words, can we say that the return transfer is a "mirror copy" of the forward one? If that is not generally the case, then under what conditions can we witness such symmetrical transfers?

• There is a problem with your question as asked. What exactly to you mean by "points A and B"? If you mean orbits A and B the question is much more straightforward and answerable. – uhoh Jan 14 '17 at 9:36
• To amplify on uhoh's comment, we can't even say whether points A and B are the same. For example, say point A is where I am, and point B is the location of the Apollo 11 landing. It's quite possible that I can get from A to B simply by waiting for the earth's motion to carry me there. In fact, there is guaranteed to be a frame of reference in which A, now, is the same as B, then. – Ben Crowell Jan 14 '17 at 22:25
• You are right. I did not pose the question very clearly. I meant a point as a set of the six orbital parameters. – Aleksandar Petrov Jan 15 '17 at 2:32
• @AleksandarPetrov: How about editing the question? If "low-thrust propulsion" means that expenditure of reaction mass is negligible, then I think the answer is yes, by the time-reversal symmetry of Newton's laws. But if you're using significant reaction mass, then it breaks the time-reversal symmetry. You can only expel reaction mass, not collect it. – Ben Crowell Jan 15 '17 at 3:48
• Changed it to orbit a and b, as I think it's fairly clear that's what the intent of the question is. – PearsonArtPhoto Jan 15 '17 at 16:39

TL;DR: No, continuous thrust maneuvers introduce too many complexities for the "return" trajectory to be a mirror copy.

For continuous thrust maneuvers, we need to consider how many orbital parameters we want to change at once, and whether we plan on having a minimum efficiency during that transfer. Even if only one orbital parameter is changed at once, then we still can't have a mirror trajectory: this is because each orbital element will have an important effect on the optimum thrusting to change that element, as shown in Fig 1 below. Then, if attempting to change multiple orbital elements at once, we have to select which of the six "summation" control laws we wish to use (Petropoulos, Ruggiero, Naasz, and a few more). Each will emphasize the change of one orbital element more than another, and they all will lead to different "return" trajectories.

For example, changing semi major axis (a) from 42164km to 24396km (around Earth) requires 21kg of fuel (supposing a Snecma PPS1350 engine) and 45 days, whereas going from 24396km to 42164km requires 17kg and only 37 days.

NOTE: Both figures are from Ruggiero and Pergola - IEPC 2011-102.

Sources: those of my MSc. thesis on continuous thrust applied to return interplanetary mission designs. I also hope to open source my propagator in the coming weeks or months, which should allow anyone to try out a variety of missions and control laws for continuous thrust missions.

• @uhoh not yet, no. I'm still finishing up the technical work and I'm defending mid March. – ChrisR Jan 16 '17 at 16:51
• @ChrisR: In the example that I use, the initial mass and all the orbital elements are identical (apart from the semi major axis), so it's an idealized case for continuous thrusting. But it's not the idealized case in which zero reaction mass is consumed, because the roles of initial and final mass are swapped. That's the point of my answer. – Ben Crowell Jan 16 '17 at 23:02
• @uhoh, I have open sourced my code for space mission design. It's not complete at all yet (one can only do patched conics for interplanetary mission design and the J2 pertubations don't yet affect the true anomaly), but it does have a few cool features like exporting the mission to Cosmographia. I've open sourced it because I'll use it in my interplanetary mission design class, where I might need to show the code to my professor. Anyway, here it is: github.com/ChristopherRabotin/smd (it's in golang by the way). – ChrisR Jan 21 '17 at 6:19
• @ChrisR that's fantastic!!! I will definitely take a look. The open source approach has so many benefits, glad to see you've gone that direction. Also, I have been looking for an excuse to learn go for quite a while, this should make it a lot easier. Although I have an "allergy to curly braces", this seems too interesting to pass up! – uhoh Jan 21 '17 at 6:30
• @uhoh I forgot to update the thread here, but my thesis is now online: scholar.colorado.edu/asen_gradetds/184 . – ChrisR Jul 6 '18 at 4:30

The answer is no except in the mathematically idealized case where the reaction mass used is negligible and the engine is an idealized device capable of making any force up to some maximum.

Let's consider a Hohmann transfer orbit from a lower orbit to a higher orbit. This requires a $\Delta \textbf{v}_1$ out of the lower orbit and a $\Delta \textbf{v}_2$ to insert into the higher orbit. The force exerted on the spacecraft during one of the burns is $\textbf{F}=m\textbf{a}$, where $m$ is the mass of the spacecraft, which is a function of time because we're expending reaction mass. The mass is large during the low-altitude burn and smaller during the high-altitude burn.

Now let's time-reverse the motion. Under time reversal, $\textbf{a}$ stays the same, which means that $\textbf{F}$ has the same direction. But $|\textbf{F}|$ doesn't stay the same, because $m(t)$ is now a different function. In this version, the mass is large during the high-altitude burn and smaller during the low-altitude burn. This breaks the symmetry.

However, when the reaction mass is negligible and the engine is an idealized device capable of making any force up to some maximum, $m(t)$ is a constant function, and time-reversing the orbit keeps $\textbf{F}$ the same.

This argument does not depend on the assumption of a Hohmann transfer orbit, which was just illustrative. The only assumption was that the gravitational field was static.

None of this actually depends in principle on whether it's low-thrust or high-thrust propulsion, continuous acceleration or acceleration in short burns. However, because of the high exhaust velocities used in low-thrust propulsion, it may be a better approximation to say that the reaction mass is negligible. I would assume that this is why, in the numerical example given by ChrisR's answer, there is at least approximate symmetry.

• It was mentioned to me that there is also the question whether the case should consider Oberth effects and non-spherical primary objects. – kim holder Jan 16 '17 at 15:25
• @kimholder: The Oberth effect isn't a separate effect that needs to be taken into account in addition to Newton's second law. Re a nonspherical primary, there is no assumption in the argument I've given that the gravitational field is of any particular form. I only assumed implicitly that it was static. The Hohmann transfer orbit is only an example. The argument doesn't require a Hohmann transfer orbit. I'll edit the answer to try to clarify those points. – Ben Crowell Jan 16 '17 at 15:29

Given no third body effects, atmospheric drag, etc, and an instantaneous burn, the amount of fuel required to switch to an orbit is the same as is required to return to the previous orbit. This assumes the following:

1. The starting mass is the same.
2. No fuel spent on station keeping.
3. The exact reverse trajectory is kept.
4. The profile of the thrust is the same.

For the low thrust case, however, the profile of the thrust changes. You have more thrust at the end of the maneuver, which will change the optimal trajectory slightly. I suspect moving to the closer orbit would take less fuel then moving to the higher one, but I haven't do a simulation to actually prove that. I suspect that except in extreme cases, where most of the mass of the spacecraft is fuel, then this is essentially the same.

• I'm confused by your caveat for the "low thrust case". Does "...more thrust at the end of the maneuver..." mean more acceleration due to a lower mass a the end? A good ion engine will have roughly an order of magnitude higher specific impulse, so for a given delta-v the relative change in mass would be less than for a chemical engine. But maybe I am missing the point. – uhoh Jan 15 '17 at 18:32
• Sorry, this answer is incorrect. Even a basic Hohmann transfer (supposing a perfect two-body computation) will lead to opposite departure and arrival deltaVs. Only the absolute value of the velocities will be the same. – ChrisR Jan 16 '17 at 5:28
• I don't think this answer is right, for the reasons given in my answer. – Ben Crowell Jan 16 '17 at 15:21
• @ChrisR there could be a commutation relation that involves a sign change, Considering the question includes "In other words, can we say that the return transfer is a 'mirror copy' of the forward one?" the OP has some flexibility here, and would still be interested in a less-than-purely-mathematically-rigorous use of the term. So do you think that "incorrect as written yet fixable with a caveat" might fly in this case? – uhoh Jan 16 '17 at 16:44
• @uhoh yes, I agree. Let's go with "the answer is correct within the OP's constraints". Thanks for shining a light on that quote from the OP. – ChrisR Jan 16 '17 at 20:53


text:
### Math Teacher At Play: e-to-the-i-theta

Somebody’s preparing a lecture or something and mentions the angle-sum laws. There are two of ’em sharing the office with me doing the same class (different from mine but one I’ve taught many times). Says he probably won’t get to it tonight.

Me:
“I could never remember the doggone things until I found out about the “cis” function… e-to-the-i-theta equals cos-theta plus i-sine-theta. I always make it a point to show it to the students this way too… if you can just take this bit on faith, you can remember what’s what forever. After a while it even begins to make sense… cosines are x-coördinates (so we should think of “real parts”) and sines are y’s (and so, “imaginary parts”)… then things multiply out accordingly.”

And the *other* guy seemed to know pretty well what I was talking about. But the guy who brought it up, not. But he’s in too much of a hurry to sit still for any actual explanation, alas (not that I blame him). So I gave up and prepared my *own* stuff or something and did my lecture and all that. But had it on my mind.

So, first, here’s the part I’ve known since, I forget, early grad school days.

Prerequisite: A little trig and a little faith. (Actually, you could take it *all* on faith and still have the best way to memorize the angle-sum laws… but of course there’s no *point* in memorizing the angle-sum laws if you’re not already studying trig.) On faith, you should believe that there’s a Complex Number Field “containing” the Reals and a number, i, satisfying i^2 = -1. This isn’t much of a leap… anyhow, students will have heard rumors about this situation and may even have done a few exercises.

The *leap* of faith comes with the proclamation
$e^{i\theta} = \cos(\theta) + i\sin(\theta)\,.$
This is admittedly something of a whopper. To *prove* this admittedly-weird equation one requires some Analysis (that’s “Calculus” to you, I suppose). The only proof I’ve worked out in detail involves so-called “infinite series”… oh, what the hell.

[
$e^t = \sum_{k=0}^\infty {{t^k}\over{k!}}$
$\sin(t)= \sum_{k=0}^\infty{{(-1)^k t^{2k+1}}\over{(2k+1)!}}$
$\cos(t) = \sum_{k=0}^\infty{{(-1)^k t^{2k}}\over{(2k)!}}\,;$
Shove in i-times-theta for “t” and turn the crank; equate real and imaginary parts.
]

The function
$\cos(\theta) + i\sin(\theta)$
is sometimes called “cis($\theta$)”, by the way. So the theorem I’ve outlined—the one I ask my students to “take on faith” if they want to learn my favorite trig-mnemonic—can be stated as $e^{i\theta}$ = cis($\theta$). OK. Everybody’s willing to suspend disbelief thus far, right? Because, look. The “angle sum” law for the cis function goes like this.

$\cos(\phi + \psi) + i\sin(\phi + \psi)=$
$e^{i(\phi + \psi)} =$
$e^{i\phi}e^{i\psi}=$
$[\cos(\phi)+i\sin(\phi)][cos(\psi)+i\sin(\psi)]=$
$\cos(\phi)\cos(\psi)-\sin(\phi)\sin(\psi) + i[\cos(\phi)\sin(\psi) + \sin(\phi)\cos(\psi)]\,.$

Equate real and imaginary parts for the results. To wit:
$\cos(\phi + \psi) = \cos(\phi)\cos(\psi)-\sin(\phi)\sin(\psi)$
and
$\sin(\phi + \psi) = \cos(\phi)\sin(\psi) + \sin(\phi)\cos(\psi)\,,$
the “angle sum” laws.

Amazing isn’t it.

(Summary: when you know “cis” and how to work with exponents [“*add* exponents to *multiply* exponentials-with-matching-bases]… and, oh yeah, how to use i^2 = -1 [to multiply “complex numbers”]… you get the [matchings and {s, i, g, n}-signs for] the trig functions “for free”. And you really *oughta* know those things: this isn’t all they’re good for [by a long shot]. )

Now, that’s essentially the lecture I’ve given many times: the part I’ve known for years. But I’ve dusted off some ODE books lately and think I have a better idea than I ever did about what’s “really” going on.

Bump up the prerequisites. To get much of anything out of what follows, the reader should know a little Calculus… derivatives for exponentials and trig-functions… and be willing to believe an existence-and-uniqueness theorem from ODE (“ordinary differential equations”). I plan to get *around* the “infinite series” argument… or maybe just to *hide* it…

Let’s imagine that we *know* about e^x for Real x and want to investigate e^z for Complex z. Write z = x + iy.

Now e^(x+iy) = e^x * e^(iy), of course. And we already understand e^x by assumption. So we can focus in on the function

f(t) = e^(it).

Differentiate f twice: f”(t) = -e^(it).
So f is a solution to the ODE f” + f = 0.

But one already knows (or readily checks) that sin(t) and cos(t) are *also* solutions to the same ODE. Moreover (here’s the “high theory”), since ours is a *second-order* ODE, these *two* (“linearly independent”) functions “span the solution space”: *every* solution can be written as a sum-of-scalar-multiples of these two.

Assuming this is true. There exist constants K_1 and K_2 satisfying
$e^{it} = K_1\cos(t) + K_2\sin(t)\,.$

Putting t = 0 shows that K_1 = 1 (recall that cos(0)=1 and sin(0)=0); it then follows that $e^{\pi i} = -K_1 = -1$ (by a similar calculation).

Now consider $e^{{i\pi}\over2}$. Our sum-of-scalar-multiples equation gives us $e^{{i\pi}\over2} = K_2$
but we can also calculate $(e^{{i\pi}\over2})^2 = e^{i\pi} = -1$ (by our previous paragraph). So K_2 is a square-root-of-minus-one: $\pm i$.

OK. It’s late. Getting rid of the \pm (plus-or-minus) is an exercise. The point, if I still have a reader, is clear, I hope: assuming “good behavior” for Complex solutions to (second-order linear) Differential Equations, we’ve *bypassed* the series (which in some sense are just a complicated expression of the facts that (e^x)’ – (e^x) = 0, (sin(x))” + sin(x) = 0, and (cos(x))” + cos(x) = 0 [along with, now that I think of it, the values of e^0, cos(0), and sin(0)])… to obtain the e-to-the-i-theta-equals-cis theorem.

If I’d’ve known you could actually *do* stuff with ODE, maybe I’d’ve learned about it when I was a sophomore. Or the one time I taught it…

1. I like the ODE argument a lot; I have an awesome one to offer in return. I got it from an early chapter of Tristan Needham’s utterly fantastic book Visual Complex Analysis. (Maybe for the sake of my time I should just refer you there and not take the time to write it out, but it’s so delicious I can’t resist.) It is not rigorous but it is highly intuitively illuminating.

All you have to believe to begin with is that, if z is seen as a vector in the complex plane, then iz is a ccw right angle from z and at the same magnitude; and that a suitable set of facts from calculus are going to generalize without change to the complex case.

Consider the function z=e^it of a real variable t. Interpret z as a position vector and t as time. Clearly for t=0 we have z=e^0=1.

Find the velocity: z’ = i*e^it = iz.

Interpret this physically. z is a vector-valued function of time t whose velocity vector is at right angles ccw to itself and of the same magnitude.

ALREADY I know that because z’s derivative is orthogonal to z, its path will be along a circle centered at the origin. (Again, thinking physically here. z’s velocity is orthogonal to z, therefore z is not moving toward or away from the origin, therefore z is at a constant distance from the origin.) I know it’s the unit circle because of the initial value at t=0.

This tells me z’s magnitude is 1. Thus its velocity is also 1, and it is traveling ccw around a unit circle at a constant speed of 1 (unit of distance per unit of t). I.e. 1 radian per 1 unit of t.

This is the whole story. Just use this information to calculate z’s exact (real and imaginary) coordinates to find z=cos t + i*sin t.

Is that gorgeous or what?

2. gorgeous indeed. somewhere along the line
i’d satisfied myself of the tangents-at-right-angles-
-producing-circles thing for r*e^(it).
but never thought of pushing it any further.

i’ll get a look at the book.
recently i was in the math library
at big state u; haven’t visited in years.
blown away as could have been predicted.
lots of mind-blowing new stuff.
in grad school i’d spend probably
an hour a week just browsing stacks…

ccw?

3. w.p. handel

counter-clockwise.

• ## (Partial) Contents Page

Vlorbik On Math Ed ('07—'09)
(a good place to start!)

format: plain


text:
# Solving Linear Systems by Elimination Worksheet

Solving Linear Systems by Elimination Worksheet
• Page 1
1.
When the digits of a two-digit number are reversed, the new number is 7 more than twice the original number. Find the original number if the sum of its digits is 11.
 a. 29 b. 38 c. 92 d. 83

#### Solution:

Let t represent the tens digit and u represent the units digit.

Then, the original number is 10t + u and the new number is 10u + t.
[Two digit number = 10 × number in tens place + number in unit place.]

Tens digit + units digit = 11

t + u = 11 - - - (1)

New number = 7 + 2(original number).

10u + t = 7 + 2(10t + u)

10u + t = 7 + 20t + 2u

8u - 19t = 7 - - - (2)
[Simplify.]

8t + 8u = 88
19t - 8u = -7
--------------------
27t      =   81
[Multiply equation (1) by 8, equation (2) by - 1 and then add.]

t = 3

3 + u = 11
[Substitute the values.]

u = 8

Original number = 10t + u = 10(3) + 8 = 38

So, the original number is 38.

2.
A two-digit number is 9 less than the number obtained by reversing its digits. Find the original number if it is 5 times the sum of its digits
 a. 64 b. 46 c. 54 d. 45

#### Solution:

Let t represent the tens digit, u represent the units number.

Then, 10t + u represents the original number and 10u + t represents the number obtained by reversing the digits.
[Number = 10 × number in tens place + number in units place.]

5(tens digit + units digit) = original number

5(t + u) = 10t + u

- 5t + 4u = 0 - - - (1)
[Simplify.]

Reversed number - 9 = original number

10u + t - 9 = 10t + u

9u - 9t = 9

That is: u - t = 1 - - - (2)
[Divide throughout by 9.]

-5t + 4u = 0; - t + u = 1;

- 5t + 4u = 0
5t - 5 u = - 5
-------------------
- u = - 5
[Multiply second equation by - 5 and add to the first equation.]

u = 5
[Solve for u.]

- 5t + 4(5) = 0
[Substitute the values.]

t = 4

So, the original number is: 10t + u = 10(4) + 5 = 45.

3.
Find the solution to the system of equations 2$x$ + $y$ + $z$ = 4, $x$ - $y$ - $z$ = - 1, and 3$x$ + $y$ - $z$ = 3.
 a. $x$ = -1, $y$ = 1, $z$ = -1 b. $x$ = 1, $y$ = 1, $z$ = 1 c. $x$ = -1, $y$ = 1, $z$ = 1 d. $x$ = 1, $y$ = -1, $z$ = 1

#### Solution:

2x + y + z = 4  ---------(1)
x - y -  z = -1 ---------(2)
3x + y - z = 3  ---------(3)

Solve the equations (1) and (2):
2x +   y  +  z  = 4
-2x + 2y + 2z = 2
-------------------
3y + 3z = 6 ---------(4)
[Multiply equation (2) by -2 and add to the equation (1).]

Solve the equations (2) and (3):
-3x + 3y + 3z = 3
3x  +  y  -   z = 3
------------------
4y + 2z = 6 ---------(5)
[Multiply the second equation by -3 and add to the equation (3).]

Solve the equations (4) and (5):
-12y - 12z = -24
12y +  6z  = 18
-----------------
- 6z = - 6
[Multiply equation (4) by - 4, multiply equation (5) by 3 and then add.]

z = 1
[Solve for z.]

4y + 2(1) = 6 and hence y = 1
[Substitute z = 1 in equation (5) and solve for y.]

2x + (1) + (1) = 4 and hence x = 1
[Substitute y = 1, z = 1 in equation (1) and solve for x.]

The solution to the system is x = 1, y = 1, z = 1.

4.
Find the solution to the system of equations 4$x$ - $y$ + 5$z$ = 8, $x$ + $y$ + $z$ = 3, and 2$y$ + $z$ = 3.
 a. $x$ = -1, $y$ = -1, $z$ = 1 b. $x$ = 1, $y$ = 1, $z$ = -1 c. $x$ = 1, $y$ = 1, $z$ = 1 d. $x$ = -1, $y$ = 1, $z$ = -1

#### Solution:

4x - y + 5z = 8 -------(1)
x + yz  = 3 -------(2)
2y + z = 3 -------(3)

Solve the equations (1) and (2):
4x - y + 5z =  8
x + y +  z  =  3
------------------
5x       + 6z = 11 -------(4)

Solve the equations (2) and (3):
-2x - 2y - 2z = -6
2y +  z =  3
------------------
-2x          - z = -3

[Multiply equation (2) by -2 and add to the equation (3).]

2x + z = 3 -------(5)

Solve the equations (4) and (5):
5x + 6z =  11
-12x - 6z = -18
----------------
-7x        =   -7

[Multiply equation (5) by -6 and add to the equation (4).]

x = 1
[Solve of x.]

2(1) + z = 3 and hence z = 1
[Substitute x = 1 in equation (5) and solve for z.]

1 + y + 1 = 3 and hence y = 1
[Substitute x = 1, z = 1 in equation (2) and solve for y.]

The solution to the system is x = 1, y = 1, z = 1.

5.
Solve the system: 4$x$ - $y$ + $z$ = 5, $y$ + $z$ = - 1, and $x$ + $z$ = 4.
 a. $x$ = - 2, $y$ = - 7, $z$ = 6 b. $x$ = 2, $y$ = 5, $z$ = - 6 c. $x$ = -2, $y$ = - 7, $z$ = - 6 d. $x$ = 2, $y$ = -5, $z$ = 6

#### Solution:

4x - y + z =  5  ---------(1)
y + z = -1  ---------(2)
x       + z =  4  ---------(3)

Solve the equations (1) and (2):
4x - y + z =  5
y + z = -1
---------------------
4x    + 2z =  4 ---------(4)

Solve the equations (3) and (4):
- 4x - 4z = -16
4x + 2z =   4
----------------
- 2z = -12
[Multiply the equation (3) by - 4 and add to the equation (4).]

z = 6
[Solve for z.]

x + 6 = 4 and hence x = -2
[Substitute z = 6 in equation (3) and solve for x.]

y + 6 = -1 and hence y = - 7
[Substitute z = 6 in equation (2) and solve for y.]

The solution to the system is x = - 2, y = - 7 and z = 6.

6.
Solve: $x$ - $y$ + $z$ = 0, 3$x$ + $y$ + $z$ = 0, and 5$x$ + $z$ = 0.
 a. $x$ = 1, $y$ = 0, $z$ = 0 b. $x$ = 0, $y$ = 1, $z$ = 1 c. $x$ = 0, $y$ = 1, $z$ = 0 d. $x$ = 0, $y$ = 0, $z$ = 0

#### Solution:

x -  yz = 0 ---------(1)
3x + y + z = 0 ---------(2)
5x       + z = 0 ---------(3)

Solve the equations (1) and (2):
x -  y +   z = 0
3x + y +  z = 0
---------------------
4x      + 2z = 0 ---------(4)

Solve the equations (3) and (4):
-10x - 2z = 0
4x + 2z = 0
-----------------
-6x         = 0

[Multiple equation (3) by -2 and add to the equation (4).]

x = 0
[Substitute for x.]

4(0) + 2z = 0
[Substitute x = 0 in equation (4).]

z = 0
[Solve for z.]

0 - y + 0 = 0
[Substitute z = x = 0 in equation (1).]

y = 0
[Solve for y.]

The solution to the system is x = 0, y = 0 and z = 0.

7.
Solve: 7$x$ - $y$ + $z$ = 5, $x$ + 3$y$ = 4, and $z$ = - 1.
 a. $x$ = -1, $y$ = 1, $z$ = -1 b. $x$ = -1, $y$ = 1, $z$ = -1 c. $x$ = 1, $y$ = 1, $z$ = -1 d. $x$ = 1, $y$ = 1, $z$ = 1

#### Solution:

7x - y + z =  5  ----------(1)
x + 3y     =  4  ----------(2)
z = -1 ----------(3)

Solve the equations (1) and (3):
7x - y + z =  5
z = -1
--------------------
7x - y       =  6 ----------(4)

[Multiply equation (3) by -1 and add to the equation (3).]

Solve the equations (2) and (4):
x + 3y =   4
21x - 3y = 18
----------------
22x         = 22

[Multiply equation (4) by 3 and add to the equation (2).]

x = 1
[Solve for x.]

7(1) - y = 6
[Substitute x = 1 in equation (4).]

y = 1
[Solve for y.]

The solution to the system is x = 1, y = 1 and z = -1.

8.
Solve the system: 2$x$ - 3$y$ = -13, 4$x$ + $y$ = - 5
 a. $x$ = -2, $y$ = -3 b. $x$ = 2, $y$ = 3 c. $x$ = 2, $y$ = -3 d. $x$ = -2, $y$ = 3

#### Solution:

2x - 3y = - 13, 4x + y = - 5 are the two equations.

4x - 6y = -26
4x +  y = -5
---------------
-7y = - 21
[Multiply the first equation by 2 and then subtract the second equation.]

y = 3
[Solve for y.]

2x - 3(3) = -13
[Substitute y = 3 in the first equation.]

x = -2
[Solve for x.]

The solution to the given system is x = -2 and y = 3.

9.
Find the solution to the system of equations $x$ + 2$y$ = - 2; 3$x$ - 4$y$ = 9.
 a. $x$ = 1, $y$ = - $\frac{3}{2}$ b. $x$ = - 1, $y$ = - $\frac{3}{2}$ c. $x$ = -1, $y$ = $\frac{3}{2}$ d. $x$ = 1, $y$ = $\frac{3}{2}$

#### Solution:

x + 2y = -2, 3x - 4y = 9 are the two equations.

3x + 6y = -6
3x -  4y =  9
---------------
10y = -15
[Multiply the first equation by 3 and then subtract the second equation.]

y = - 3 / 2
[Solve for y.]

x + 2(- 3 / 2) = - 2
[Substitute y = - 32 in the first equation.]

x = 1
[Solve for x.]

The solution to the given system is x = 1, y = - 32.

10.
Solve the system: 2$x$ + 5$y$ = - 3, $x$ - 2$y$ = 1
 a. $x$ = $\frac{1}{9}$, $y$ = $\frac{5}{9}$ b. $x$ = - $\frac{1}{9}$, $y$ = $\frac{5}{9}$ c. $x$ = $\frac{1}{9}$, $y$ = - $\frac{5}{9}$ d. $x$ = - $\frac{1}{9}$, $y$ = - $\frac{5}{9}$

#### Solution:

2x + 5y = -3, x -  2y = 1 are the two equations.

2x + 5y = -3
2x -  4y =  2
---------------
9y = -5
[Multiply the second equation by 2 and then subtract from the first equation.]

y = - 59
[Solve for y.]

x - 2(- 59) = 1
[Substitute y = - 59 in the second equation.]

x = - 1 / 9

The solution to the given system is x = - 19, y = - 59.


text:
# 3.10 Find unknown quantities

Lesson

Do you remember how to find the  missing number in a number sentence,  in order to make it balanced?

### Examples

#### Example 1

Complete the number sentence: 48 - ⬚ = 19 + 16

Worked Solution
Create a strategy

Find the right hand side of the equation first then use a number line to complete the number sentence.

Apply the idea

Add the numbers in the right hand side of the equation in a vertical algorithm. \begin{array}{c} & &1 &9 \\ &+ &1 &6 \\ \hline \\ \hline \end{array}

Add the ones column first: 9 + 6 = 15. Bring down the 5 and carry the 1 to the tens column. \begin{array}{c} & &\text{}^1 1 &9 \\ &+ &1 &6 \\ \hline & & &5 \\ \hline \end{array}

Add the tens column: 1 + 1 + 1 = 3. \begin{array}{c} & &\text{}^1 1 &9 \\ &+ &1 &6 \\ \hline & &3 &5 \\ \hline \end{array}

The simplified number sentence would be: 48 - ⬚ = 35

Locate 48 in the number line.

Jump back from 48 and count the number of units until we reach 35.

We have jumped back 13 units from 48. So the complete number sentence would be: 48 - 13 = 19 + 16

Idea summary

For number sentences to be equivalent, or balanced, both sides must equal the same amount.

## Find unknown quantities in single step problems

This video looks at how to find unknowns values in number sentences that involve one step.

### Examples

#### Example 2

Complete the statement with the missing number: 9\times⬚=135

Worked Solution
Create a strategy

Use the number line below to count how many jumps of 9 there are between 0 and 135.

Apply the idea

Locate where 0 and 135 is.

We can see that there are 15 jumps of 9 from 0 to 135. So, the complete statement is 9 \times 15 = 135

Idea summary

We can use a number line to find an unknown quantity.

## Find unknown quantities in multi-step problems

Now we look at problems that will need more than one step to find the answer.

### Examples

#### Example 3

Complete the number sentence: 40 = 8 + 8 \times ⬚

Worked Solution
Create a strategy

Simplify the number sentence and solve it to help with the more complicated number sentence.

Apply the idea

We can simplify the number sentence to be: 40 = 8 + ⬚

To find the unknown, we locate where 8 is then jump to the right to get 40.

We have jumped 32 spaces to the right of 8.40 = 8 + 32

To complete the original number sentence, we need to find the unknown for the following number sentence: 8 \times ⬚ = 32

We can count up by multiples of 8 to get: 8,\,16,\,24,\,32, so we get 32 after 4 counts. This means that: 8\times 4 = 32

The complete number sentence is: 40 = 8 + 8 \times 4

Idea summary

To find the missing number in a multi-step number sentence, we can make the number sentence simpler and solve that one first.

## Simplify problems

Sometimes you can make the problem easier if you simplify the question first, this video will show you how.

### Examples

#### Example 4

Let's work out what must equal to make the following number sentence true.

⬚ + 16 = 3 \times 8

a

First, what does 3 \times 8 equal?

Worked Solution
Create a strategy

We can think of it as 3 groups of 8, like in the array below where there are 3 rows of 8 squares.

Apply the idea

Count the number of squares in the array to get: 3\times 8=24

b

So now we have ⬚ + 16 =24. What number plus 16 equals 24?

Worked Solution
Create a strategy

Use the number line below to count how many jumps are between the starting number and the target number.

Apply the idea

Plot 16 and 24 on the number line and count the number of jumps.

We have jumped 8 spaces to the right of 16. So: 8 + 16 = 24

This means that the unknown was 8: 8 + 16 = 3 \times 8

Idea summary

To balance a number sentence, work out the value of one side first, and use the answer as the target value to work out the other side.

### Outcomes

#### VCMNA183

Solve problems involving multiplication of large numbers by one- or two-digit numbers using efficient mental, written strategies and appropriate digital technologies

#### VCMNA184

Solve problems involving division by a one digit number, including those that result in a remainder

#### VCMNA185

Use efficient mental and written strategies and apply appropriate digital technologies to solve problems

#### VCMNA193

Use equivalent number sentences involving multiplication and division to find unknown quantities


text:
시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 256 MB 24 6 5 21.739%

## 문제

NEERC featured a number of problems about cactuses — connected undirected graphs in which every edge belongs to at most one simple cycle. Intuitively, cactus is a generalization of a tree where some cycles are allowed.

In 2005, the first year where a problem about cactuses appeared, the problem was called simply “Cactus”. In 2007 it was “Cactus Reloaded”, in 2010 it was called “Cactus Revolution”, and in 2013 it was called “Cactus Automorphisms”. Here is an example of cactus that was used in those problems:

For four years judges had to generate test files for cactuses with thousands of vertices. Of course, a number of test generators of ever-increasing complexity were built, culminating with a domain-specific language called CGL — Cactus Generator Language. CGL can compactly define a big cactus for purposes of a test. In this problem you have to parse a simplified version of this language, which we call SCGL — Simple Cactus Generator Language, and output a resulting cactus.

A cactus has to be output by listing the minimal set of edge-distinct paths that cover the whole graph.

The syntax of SCGL cactus definition is represented by the graph non-terminal in the grammar that is given below using the Extended Backus-Naur Form:

   graph = “c”
| “c(” list “)”
| “loop(” list “)”
| “t(” list “)”
list = graph { “,” graph }
| (number | range | variable ) [ “,” graph ]
number = nzdig { “0” | nzdig }
nzdig = “1” | “2” | ... | “8” | “9”
range = “range(” variable “,” numvar “,” numvar “)”
variable = “A” | “B” | ... | “Y” | “Z”
numvar = number | variable

A graph production rule denotes a graph with two labeled vertices — the first and the last. Graphs definition rules have the following semantics:

• The basic building block c denotes a graph with just two vertices (one is the first and the other one is the last) and one edge.
• The c(σ) rule connects a specified list of graphs σ from left to right into a chain, merging the last vertex of the first graph in the list with the first vertex of the second graph in the list, the last vertex of the second graph with the first of the third one, and so on. The resulting graph’s first vertex is the first vertex of the first graph in the list, and the resulting graph’s last vertex is the last vertex of the last graph in the list.
• The loop(σ) rule connects a specified list of graphs σ from left to right, merging the last vertex of the first graph in the list with the first vertex of the second graph in the list, and so on like in c(σ), while the last vertex of the last graph in the list is merged with the first vertex of the first graph in the list to form a loop. The resulting graph’s first and last vertices are the first and the last vertices of the first graph in the list. Loop can be applied only to lists with more than one graph.
• The t(σ) rule connects a specified list of graphs σ, merging their first vertices. The resulting graph’s first and last vertices are the first and the last vertices of the first graph in the list.

The list of graphs is either specified explicitly, by a comma-separated list, or using a list repetition with a number, a range, or a variable, optionally followed by a comma and a graph. When a graph is not explicitly specified in a list repetition, then the given graph is assumed to be c.

The simplest list repetition is defined using a number non-terminal. It denotes a list of graphs with the specified integer number of copies of the given graph.

A range list repetition is defined by range(ν, α, β) rule which has three components — a variable ν, and numbers α and β. If ξ character sequence is a graph, then c|loop|t(range(ν, α, β), ξ) are called rangeenabled rules and the variable ν is called a bound variable in ξ. In the context of a range-enabled rule, ξ is repeated |β − α| + 1 times to form a list. Every occurrence of variable ν in ξ is replaced by consecutive integer numbers between α and β inclusive in ascending order. That produces a list of |β −α|+ 1 graphs, which are then connected according the specification of the corresponding range-enabled rule. The α and β themselves might refer to variables that are bound in the outer range-enabled rule.

In a well-formed graph:

• each variable non-terminal (a letter from A to Z) occurs at most once as ν in range(ν, α, β) rules;
• all other occurrences of variable non-terminal that are allowed by the grammar are bound.

Note, that if a character sequence ξ is a graph, then ξ, c(ξ), c(1, ξ), t(ξ), and t(1, ξ) all denote the same graph. On the other hand, neither loop(ξ) nor loop(1, ξ) are allowed.

The following examples illustrate these basic rules. The graphs have their first and last vertices marked with letters F and L correspondingly.

## 입력

The input file contains a single line with a well-formed cactus definition in SCGL. While the syntax and semantics of SCGL themselves do not guarantee that the resulting graph is a cactus, the input file for this problem always defines a cactus — every edge belongs to at most one simple cycle and there are no multiple edges between vertices. For example, neither loop(3,loop(3)) nor loop(2) are possible.

The line in the input file is at most 1000 characters long and defines a cactus with at most 50 000 vertices. Integer numbers represented by number non-terminals do not exceed 50 000.

## 출력

The first line of the output file must contain two integer numbers n and m. Here n is the number of vertices in the graph. Vertices are numbered from 1 to n, where 1 is the number of the first vertex of the graph and n is the number of the last vertex of the graph. The other vertices can be numbered arbitrarily. Edges of the graph are represented by a set of edge-distinct paths, where m is the minimal number of such paths.

Each of the following m lines must contain a path in the graph. A path starts with an integer number ki (ki ≥ 2) followed by ki integers from 1 to n. These ki integers represent vertices of a path. A path can go to the same vertex multiple times, but every edge must be traversed exactly once in the whole output file.

## 예제 입력 1

c(c,t(loop(3),c(c,loop(6))),loop(c,c,t(c,loop(4))))

## 예제 출력 1

15 1
19 1 2 9 10 11 12 13 10 15 9 14 2 3 4 5 6 7 8 3

## 예제 입력 2

c

## 예제 출력 2

2 1
2 1 2

## 예제 입력 3

c(2)

## 예제 출력 3

3 1
3 1 2 3

## 예제 입력 4

c(3)

## 예제 출력 4

4 1
4 1 2 3 4

## 예제 입력 5

t(c(3),c,c)

## 예제 출력 5

6 2
2 1 2
5 3 1 4 5 6

## 예제 입력 6

c(2,t(c(2),c,c))

## 예제 출력 6

9 3
3 2 1 3
3 4 5 6
5 1 7 5 8 9


text:
## 15.27 vs 15.35

$\frac{d[R]}{dt}=-k[R]^{2}; \frac{1}{[R]}=kt + \frac{1}{[R]_{0}}; t_{\frac{1}{2}}=\frac{1}{k[R]_{0}}$

Justin Chu 1G
Posts: 52
Joined: Thu Jul 13, 2017 3:00 am
Been upvoted: 1 time

### 15.27 vs 15.35

For the homework problems, I noticed that in 15.27 (first-order reaction), you could simply calculate how many half lives have occurred and multiply the number by the half-life (ex: 1/8 of the original concentration would equal (1/2)^3 so you could multiply the half life by 3). However, I noticed that in 15.35 (second-order reaction), I couldn't simply do the same thing. Is there a specific reason why?

Manvir2K
Posts: 32
Joined: Fri Sep 29, 2017 7:05 am

### Re: 15.27 vs 15.35

This method works for 27 because it is in first order, while 35 is in second order. I think calculating the half lives that have occurred and multiplying the number by the half-life only works for 1st order.

Gwyneth Huynh 1J
Posts: 30
Joined: Fri Sep 29, 2017 7:05 am

### Re: 15.27 vs 15.35

I agree! For first order reactions, the half life is independent of initial concentration. However, for second order reactions, the half life depends on initial concentration.

Jennie Fox 1D
Posts: 66
Joined: Sat Jul 22, 2017 3:01 am

### Re: 15.27 vs 15.35

This is because in second order reactions, half life depends on initial concentration, whereas half life in first order reactions does not depend on concentration.


text:
## Geometry & Topology

### The centered dual and the maximal injectivity radius of hyperbolic surfaces

Jason DeBlois

#### Abstract

We give sharp upper bounds on the maximal injectivity radius of finite-area hyperbolic surfaces and use them, for each $g ≥ 2$, to identify a constant $rg−1,2$ such that the set of closed genus-$g$ hyperbolic surfaces with maximal injectivity radius at least $r$ is compact if and only if $r > rg−1,2$. The main tool is a version of the centered dual complex that we introduced earlier, a coarsening of the Delaunay complex. In particular, we bound the area of a compact centered dual two-cell below given lower bounds on its side lengths.

#### Article information

Source
Geom. Topol., Volume 19, Number 2 (2015), 953-1014.

Dates
Revised: 19 March 2014
Accepted: 15 June 2014
First available in Project Euclid: 16 November 2017

https://projecteuclid.org/euclid.gt/1510858717

Digital Object Identifier
doi:10.2140/gt.2015.19.953

Mathematical Reviews number (MathSciNet)
MR3336276

Zentralblatt MATH identifier
1330.51007

#### Citation

DeBlois, Jason. The centered dual and the maximal injectivity radius of hyperbolic surfaces. Geom. Topol. 19 (2015), no. 2, 953--1014. doi:10.2140/gt.2015.19.953. https://projecteuclid.org/euclid.gt/1510858717

#### References

• C Bavard, Disques extrémaux et surfaces modulaires, Ann. Fac. Sci. Toulouse Math. 5 (1996) 191–202
• R Benedetti, C Petronio, Lectures on hyperbolic geometry, Springer, Berlin (1992)
• K B ör öczky, Packing of spheres in spaces of constant curvature, Acta Math. Acad. Sci. Hungar. 32 (1978) 243–261
• J A De Loera, J Rambau, F Santos, Triangulations: Structures for algorithms and applications, Algorithms and Computation in Mathematics 25, Springer, Berlin (2010)
• J DeBlois, The Delaunay tessellation in hyperbolic space
• J DeBlois, Tessellations of hyperbolic surfaces
• J DeBlois, The geometry of cyclic hyperbolic polygons (2014)
• B Farb, D Margalit, A primer on mapping class groups, Princeton Mathematical Series 49, Princeton Univ. Press (2012)
• S Kojima, Y Miyamoto, The smallest hyperbolic $3$–manifolds with totally geodesic boundary, J. Differential Geom. 34 (1991) 175–192
• D Mumford, A remark on Mahler's compactness theorem, Proc. Amer. Math. Soc. 28 (1971) 289–294
• B P Palka, An introduction to complex function theory, Springer, New York (1991)
• J-M Schlenker, Small deformations of polygons and polyhedra, Trans. Amer. Math. Soc. 359 (2007) 2155–2189
• E Vanderzee, A N Hirani, D Guoy, E A Ramos, Well-centered triangulation, SIAM J. Sci. Comput. 31 (2009/10) 4497–4523


text:
# The 39th International Symposium on Lattice Field Theory (Lattice 2022)

Aug 8 – 13, 2022
Hörsaalzentrum Poppelsdorf
Europe/Berlin timezone

## Electromagnetic finite-volume effects to leptonic decays through order $1/L^3$ in QED$_{\textrm{L}}$

Aug 10, 2022, 2:20 PM
20m
CP1-HSZ/1st-1.002 - HS6 (CP1-HSZ)

### CP1-HSZ/1st-1.002 - HS6

#### CP1-HSZ

50
Oral Presentation Weak Decays and Matrix Elements

### Speaker

Dr Nils Hermansson-Truedsson (Lund University/The University of Edinburgh)

### Description

Analytical techniques to derive the finite-volume dependence of observables calculated in lattice simulations can be used to improve numerical determinations. With the need for (sub-)percent precision in lattice predictions, also isospin-breaking effects have to be considered. When including electromagnetism in the so-called QED$_{\textrm{L}}$ prescription, having good control of the associated finite-volume effects is particularly important, as the scaling with the spatial extent L typically is inverse polynomial. In this talk, we will discuss the finite-size effects in the RBC/UKQCD calculation of radiative corrections to leptonic decays. Particular emphasis will be put on the order $1/L^3$ contribution, where the non-locality of QED$_{\textrm{L}}$ plays an important role.

### Primary author

Dr Nils Hermansson-Truedsson (Lund University/The University of Edinburgh)


text:
# Math calculations in PDF forms?

From LibreOffice, is it possible to create a PDF form which performs mathematical calculations?

If so, how?

edit retag close merge delete

Sort by » oldest newest most voted

I still do not know if this is possible with LO. However, my research lead me to an open-source tool call Scribus ( http://www.scribus.net ) which allowed me to build my PDF Form with calculated fields.

Thank you all for your input.

Statler Waldorf.

more

It seems PDF has JavaScript scripting support. Just google for

pdf scripting

more

Thanks rautamiekka. A quick search turned up this sample document: http://www.pdfscripting.com/public/Fr...

Is it possible to accomplish this in LO?

( 2015-03-17 15:57:14 +0200 )edit

Answering what I expected from the title - in case someone else reads the question expecting the same :

To calculate expressions in the input fields of the from itself (which is different from what the question body asks for):

It could be done using an utility software that helps evaluating expressions inside the input fields:

An example would be Typinator (Mac OS) which advertises the feature "Inline Calculation".

Another approach would be a calculator utility that mirrors its output to a form field (or manual copy and paste to a calculator, of course) (I do not know whether that exists; Should be possible to do it with something like AutoKey)

more

A pdf-file is merely a printed document in a universal format. I cannot imagine that a pdf-file can make mathematical calculations.

more

It can, I have seen it. Based on theory which I have also studied you can even animate content in a PDF by use of JavaScript. As I recall, a PDF contains something like PostScript code which in itself is a programming language for graphical documents. Or so I recall.

( 2019-07-24 01:01:06 +0200 )edit
1

A pdf document is written in postscript. Postscript is a very powerful and full computer language. It is not only quite possible to do calculations in Postscript, but the print job itself is produced from this language. For example, many years ago I adjusted a postscript print job to tile out a small page onto many pages to make 18' wide signs, but based on an 8.5 x 11" page just by encapsulating the postscript with more postscript.

( 2019-07-24 14:48:10 +0200 )edit


text:
## AravindG 4 years ago A disc of radius r at time t=0 moving along positive x axis with linear speed v and angular speed w .Find the x and y coordinates of the bottommost point at any time t

1. JamesJ

So is this point fixed, or is it the point that is always in contact with the surface? If it's the latter, it's trivial. So I'm guessing you actually want to first?

2. AravindG

hmm

3. AravindG

i hav a fig hope it helps

4. AravindG

|dw:1327765174049:dw|

5. TuringTest

|dw:1327764644850:dw|$\overrightarrow{OP}=\overrightarrow{OA}+\overrightarrow{AB}+\overrightarrow{BP}=<r\theta,0>+$

6. anonymous

|dw:1327765593766:dw|here dont bother about omega as as it is zero (v=rw) so just consider the velocity and plot down the points(for that u have to know how it moves along the axis at a given time ) considering uniform velocity v at time t in a straight line(x-axis) v/t will give the x-co-ordinate y co-rdinate is zero

7. AravindG

|dw:1327765734194:dw|

8. AravindG

is that the answr?

9. AravindG

hw is omega equal to 0??

10. TuringTest

$\overrightarrow{OP}=\overrightarrow{OA}+\overrightarrow{AB}+\overrightarrow{BP}=<r\theta,0>+<0,r>+<-r\sin\theta,-r\cos\theta>$$\overrightarrow{OP}=<r\theta-r\sin\theta,r-r\cos\theta>$subbing in omega t for the angle$\overrightarrow{OP}=<r(\omega t-\sin(\omega t)),r(1-\cos(\omega t))>$if we are talking about the situation I am imagining...

11. JamesJ

Nicely done TT

12. TuringTest

Thanks, hats of to OCW on that :D

13. AravindG

heyy TT why is your and salini's answr different?

14. TuringTest

I don't know what situation salini is imagining, but it is different than mine. I think he is imagining just looking at whatever point is on the bottom, not letting it rotate.

15. AravindG

so which is the right method?

16. TuringTest

if you are talking about this http://ocw.mit.edu/courses/mathematics/18-02sc-multivariable-calculus-fall-2010/part-c-parametric-equations-for-curves/session-17-general-parametric-equations-the-cycloid/MIT18_02SC_s17_applet.html then mine is right depends on what your question means, are we following point P or always looking at the bottom

17. anonymous

i thought that the point on the bottom lies on the axis of rotation of the disc then omega=v/r where r is 0

18. AravindG

look at my fig

19. TuringTest

Well which is it arvind? are we always looking at the bottom point or are we following point P which starts at the bottom?

20. AravindG

wel i think we are looking at co ordinates of bottom point

21. AravindG

but in pure rollindg dont we assume that the particles rotate about the bottom point???

22. TuringTest

then why does it ask for the y-coordinates if they don't change?

23. AravindG

hmmm

24. anonymous

oh i get it......when u said ocw helped u solve this was it walter lewin professors video?

25. AravindG

guys i will be back in 10 min

26. TuringTest

actually I learned about cycloids from the multivariable calculus section

27. anonymous

oh thank u for rresponding

28. AravindG

so wat is the answer is it salini's or turings??

29. TuringTest

ohj here it is http://ocw.mit.edu/courses/mathematics/18-02sc-multivariable-calculus-fall-2010/part-c-parametric-equations-for-curves/session-18-point-cusp-on-cycloid/ @arvind you have to figure out what your question is asking

30. JamesJ

^^ exactly. The fact that you (Aravind) aren't clear on what the question is makes me very suspicious that you're actually paying attention to the method in the solutions. That is why I recommend again that you only post one or at the most two questions at a time. With those one or two questions, really, truly, thoroughly, completely understand the answers, then move onto the next problem. This is example number #9 or #10 in my book where it's clear to me you're not really paying attention to the answers we give. I'm not going to help you again, unless I see you try and really work out a problem with us, instead of putting things out there and grabbing in a half-*ssed way the answers and questions we propose back to you.


text:
# Writing a Brainfuck interpreter in Python.

Leave a comment

September 2, 2012 by Vedat

For those unaware, Brainfuck is a programming language.
This is how wikipedia describes Brainfuck:

Brainfuck is an esoteric programming language noted for its extreme minimalism. It is a Turing tarpit, designed to challenge and amuse programmers, and was not made to be suitable for practical use. It was created in 1993 by Urban Müller.

The name of the language is generally not capitalized except at the start of a sentence, although it is a proper noun.

I discovered the language a while ago, when I got interested in esoteric languages. Since the language is very simple, I figured that it wouldn’t be too hard to write an interpreter for it.

Brainfuck has 8 commands:

1. <  :  Increment the data pointer (go to the next cell).
2. >  :  Decrement the data pointer (go to the previous cell).
3. +  :  Increment the value in current cell.
4. –    :  Decrement the value in current cell.
5. ,    : Read a character from stdin, and write it to the current cell.
6. .    : Print the character in the current cell.
7. [   : If the value in the current cell is greater than 0, go read the next instruction else jump to the closing “]”.
8. ]   : Jump to the opening “[“.

Of course, each cell represents a char and the tape which contains the cell is a char array of the length 30000.

The Primitives
The first thing to do is representing the cells and the data pointer.  Quite simply we can do that by using a list to represent the cells and an integer to represent the current value of the data pointer.

# simulate the cells with a list
tape = [0]*(3*10**4)
# the data pointer
ptr = 0

The next thing to do is to represent the first 6 commands.
Since they have no scope, they could be handled directly by simple functions.
We have to be careful while implementing “” to make sure that the data pointer doesn’t leave the tape (this would cause a segmentation fault).

def lt():
""" performs a < """
global ptr
if ptr <= 0:
raise ValueError, "Segmentation fault!"
ptr -= 1

def gt():
"""" performs a > """
global ptr
if ptr >= 3*10**4 - 1:
raise ValueError, "Segmentation fault!"
ptr += 1

While implementing + and – we should make sure, that the value stays in the range 0,256. If the value of a cell gets smaller than 0 o greater than 256 we interpret it as an underflow or as an overflow and quitely let it pass.

def plus():
""" performs a + """
global ptr
tape[ptr] = (tape[ptr] + 1) % 256

def minus():
""" perfoms a - """
global ptr
tape[ptr] = (tape[ptr] - 1) % 256

Implementing “,” and “.” is quite straight forward as well. The only edge case is handling the EOFs while reading from stdin. Since the ASCII code for EOF is 26, we can simply test whether the byte value of the newly read character is 26 and write it to the cell only after we make sure, that this isn’t the case.

def dot():
""" performs a . """
global ptr
sys.stdout.write(chr(tape[ptr]))

def comma():
""" performs a , """
global ptr
c = ord(sys.stdin.read(1))
if c != 26:
tape[ptr] = c

Handling Loops
(Observation, the “[“s and “]”s can be interpretted as while loops where the condition is $tape[ptr] > 0$ with a scope from “[” to “]”.)
Now we must implement the commands “[” and “]”. To do this, we must map the “[“s on the corresponding “]”s (we map the indices of the opening brackets, to the indices of the balancing closing brackets). The way we do this is quite straight forward: We keep a stack for the indices of the “[“s and every time we encounter a “[“, we push its index to the stack. Every time we encounter a “]” we pop an index from the stack and map the current index to it (it being the index of the “]” encountered).

The reason why this does the right thing is quite simple. Assume we haven’t yet encountered a “]” but have encountered n “[“s. The stack must contain n indices. Obviously the first “]” we encounter always balances the last “[” encountered, so its index should be mapped on it. For the second “]” we encounter this is also similiar, the first “]” we encounter balanced the last “[” so the second “[” we encounter should balance the “[” we encountered second from last, which is the one that is currently on top of the stack. It isn’t hard to imagine why this also works when we encounter a further “[” popping all the indices from the stack or when we encounter a further “]”. There are multiple ways of proving this formally, but the one I like the most is simply induction over the language of balanced brackets (the Dyck Language), which could be generated by the CFG with the terminals “[“, “]” the nonterminal and the start symbol $S$ and the production $S \Rightarrow \epsilon|[S]|SS.$ I will spare the proof and just give the code.

But before doing that let’s think about the two cases where this can go south:

1. The stack is empty, and we encounter a “]”. The program cannot possibly be a valid Brainfuck program, because the brackets aren’t balanced.
2. After reading the whole program, the stack isn’t empty. This means that there are more “[“s then “]”s. This also indicates that the program cannot possibly be valid, as having more “[“s then “]”s is a syntactic violation.

We should therefore test whether these are present in the code we are to read:

def parse(code):
""" maps the "["s to the corresponding "]"s """
# stack to contain the indices of the opening brackets
opening = []
# dict which maps the indices of the opening brackets
# to the closing brackets
loop = {}
for i,c in enumerate(code):
if c == "[":
opening.append(i)
elif c == "]":
try:
begin = opening.pop()
loop[begin] = i
except IndexError:
raise ValueError, "Supplied string isn't balanced, too many ]s!"
# if the stack isn't empty, the string cannot be balanced
if opening != []:
raise ValueError, "Supplied string isn't balanced, too many [s"
else:
return loop

We could of course also use the same dictionary to map the indices of the opening brackets to the closing brackets, the resulting eval code might be faster, but I like this version better.

Evaluation

Now we must write a function which evaluates valid Brainfuck programs which should also be quite simple.
Whenever we encounter a brainfuck command which isn’t “[” or “]” we handle it by the functions we have already written, else whenver we encounter a “[” we check whether the current cell contains a value greater than 0 if so, we push the current index to the stack and enter the loop body, else we jump to the instruction to the right of the corresponding balancing “]”. Whenever we encounter a “]” we pop the index of the corresponding “[” from the stack and jump there.

This is how it looks like

# primitives which can directly be handled
handle_directly = { "." : dot, "," : comma, "<" : lt, ">" : gt, "+" : plus, "-" : minus}

def eval_bf(code):
""" evaluates brainfuck code """
global ptr
# get the scopes of the "[", "]"s
loop = parse(code)
# initialize the program counter
pc = 0
# a stack to store the pc for loops
stack = []
while pc < len(code):
instruction = code[pc]
# handle the primitives directly
if instruction in handle_directly:
apply(handle_directly[instruction])
elif instruction == "[":
# if loop condition is fullfiled
# enter loop block
if tape[ptr] > 0:
stack.append(pc)
else: # else go to the end of the block
pc = loop[pc]
elif instruction == "]":
# jump back where you came from!
pc = stack.pop() - 1
pc += 1

Notice the “-1” on line 28, if it weren’t for that we would jump directly in the loop block (because of the incrementation in line 29), thus would never have any terminating loops (i.e for [] the program would first read the “[” then read the “]”, and continually jump on “]”).

So this was all.
The whole code is in my github, though it differs from the one I posted here in minor ways. The script in my github can also be used as an interactive brainfuck shell.

Note to self: Use pygments the next time you want to post code on your blog.

Advertisements


text:
# Notation for the prime-counting functions for subsets of the natural numbers

The prime-counting function is commonly denoted by $$\pi(x)$$, and if $$b$$ is a modulus and $$a$$ a unit in $$\mathbb Z/b$$, then $$\pi(b,a,x)$$ counts the primes in $$a \mod b$$. Yet suppose one wants to count the primes within a subset $$S$$ of the natural numbers. What would be the corresponding notation? $$\pi(S,x)$$? What if $$S$$ is the union of several residue classes modulo $$b$$?

• You can use any notation you like, provided you are careful to explain it. – Gerry Myerson Jan 12 at 23:42


text:
# Simple Words, Complicated Ideas

Part of the peterjamesthomas.com Maths and Science archive

Mathematics is often described as the academic discipline that uses simple words to label complicated ideas. Whereas Chemists might refer to Tetrakis[3,5-bis(trifluoromethyl)phenyl]borate [1], Biologists to Macracanthorhynchus hirudinaceus [2] and Physicists to Dissipative Decoherence [3], Mathematicians talk about Rings for arguably just as complicated concepts. This brief article provides an inexhaustive list of examples of this phenomena; one to which I may add over time.

 Notes: All “normal” definitions are taken from Dictionary.com. Where there are multiple parts to a definition, I have in general only reproduced the first few of these. However, links to the full Dictionary.com definitions are provided, just click on the relevant picture of a link. In some cases, the simple everyday word relates to a Mathematical concept which is even more complicated than on average. In these cases, I merely provide a hand-wavy picture of the Mathematics, lest I fill this article with thousands of words of background material. In these cases, I will generally provide a link to more information, typically on Wikipedia.

Analysis
Everyday Usage

 The separating of any material or abstract entity into its constituent elements (opposed to synthesis). This process as a method of studying the nature of something or of determining its essential features and their relations: the grammatical analysis of a sentence.

Mathematical Usage

Analysis is a broad and fundamental part of Mathematics which is concerned with all aspects of limits [4]. In turn, limits relate to what happens to expressions, shapes, sequences, series and other concepts when some parameter becomes infinitely big or infinitely small; for example the sum of an infinite number of terms. Both elements of The Calculus, namely Differentiation [5] and Integration, are based on the concept of limits and thus are part of Analysis. The study of infinite sequences and the sum or product of infinite series (particularly power series) are similarly part of this area. Analysis is typically split into studies relating to Real Numbers (Real Analysis) and relating to Complex Numbers (unsurprisingly Complex Analysis).

 Further reading: Several sections of Euler’s Number Several sections of The Equation

Bundle
Everyday Usage

 Several objects or a quantity of material gathered or bound together: a bundle of hay. An item, group, or quantity wrapped for carrying; package. A number of things considered together: a bundle of ideas.

Mathematical Usage

XXX

Cage
Everyday Usage

 A boxlike enclosure having wires, bars, or the like, for confining and displaying birds or animals. Anything that confines or imprisons; prison. Something resembling a cage in structure, as for a cashier or bank teller.

Mathematical Usage

XXX

Category
Everyday Usage

 Any general or comprehensive division; a class. A classificatory division in any field of knowledge, as a phylum or any of its subdivisions in biology.

Mathematical Usage

XXX

Complex
Everyday Usage

 Composed of many interconnected parts; compound; composite: a complex highway system. Characterized by a very complicated or involved arrangement of parts, units, etc.: complex machinery. So complicated or intricate as to be hard to understand or deal with: a complex problem.

Mathematical Usage

A set of numbers, denoted by $\mathbb{C}$, whose members are of the form $a+ib$, where both $a$ and $b$ are Real Numbers and $i^2=-1$. The Complex Numbers form each of a Group (under both addition and multiplication), a Field, a Space and a Division Algebra (a set of numbers that behave well with respect to division, save for when the denominator is zero of course). They are closed under algebraic operations (addition/subtraction, multiplication/division [6], raising to powers/taking roots and so on). This means that if you perform any of these operations on Complex Numbers, you always end up with more Complex Numbers. In fact the Complex Numbers are what you get if you extend the Real Numbers [7] to include the result of any algebraic operation which is performed on them.

 Further reading: The relevant section of A Brief Taxonomy of Numbers, this provides a brief overview Glimpses of Symmetry, Chapter 7 – Imaginary Battleships, this is a gentler, more discursive introduction Glimpses of Symmetry, Chapter 11 – Root of the Problem, this is a little more advanced and demonstrates a surprising link between certain types of Complex Numbers and geometry
Derivative
Everyday Usage

 Derived Not original; secondary.

Mathematical Usage

The derivative is essentially the slope of a curve (more properly a function [8]) at a point. However, where such a slope varies from point to point, the derivative captures the slope at any point in another expression (using the prefered language of functions, the derivative of a function, $f(x)$ is another function, denoted by $f^{\prime}(x)$ or $\frac{d}{dx}\hspace{1mm}f(x)$. So $f^{\prime}(1)$ is the slope of function $f(x)$ at the point $1$).

As an example, if we have $f(x)=x^2+x+1$, then $f^{\prime}(x)=2x+1$ [9]

Derivatives can also be calculated for two-dimensional surfaces (or higher dimensional objects). Often the approach is to fix one or more of the dimensions. So for a two dimensional surface, if we fix one dimension, we reduce the problem to a one dimensional curve. Such derivatives are called partial derivatives with the slightly different notation, $\frac{\partial}{\partial x}\hspace{1mm}f(x,y)$.

 Further reading: Euler’s Number, which explains derivatives from first principles

Dual
Everyday Usage

 Of, relating to, or noting two. Composed or consisting of two people, items, parts, etc., together; twofold; double: dual ownership; dual controls on a plane. Having a twofold, or double, character or nature.

Mathematical Usage

 Note: The word Dual actually has many different meanings in Mathematics and one could argue that – looking for what these have in common – the overall sense is not a million miles from quotidian usage. The general concept is to be able to regard one mathematical object as the equivalent of (or at least strongly related to) another via some way of translating between them. Here I will concentrate just one one of best known Dual concepts, that which applies to Regular Polyhedra.

A Polyhedron is a three dimensional solid object whose faces consist of Polygons. If all of the faces are identical, then the shape is a Regular Polyhedron.

Two obvious examples of Regular Polyhedra are the Tetrahedron and the Cube. The former has four faces, each of which is an equilateral triangle. The latter has six faces, each of which is a square. The above image also shows some examples of vertices, points where three or more faces meet.

We are now ready to offer our definition of the Dual of a Polyhedron. It is simply the Polyhedron which we obtain by joining up the midpoints of all of the faces of our original Polyhedron. A diagram is probably called for – let’s look at the Cube:

If we identify the mid-points of each Cube face in the left-hand diagram and link these, we create a shape inside the Cube which is two square pyramids glued base-to-base; this is called an Octahedron. Moving to the right-hand diagram, if we carry out the same process on an Octahedron, we recover a Cube again. Alternatively, you can start the process by constructing a shape outside of the cube and with the mid-points of its faces touching the Cube’s vertices; again the result is an Octahedron. This is probably obvious to see by thinking about the two exhibits above from right to left instead of left to right.

Some Polyhedra, like the Tetrahedron above, are their own Dual.

We have covered three of the five Platonic Solids above. The remaining ones are the Dodecahedron and Icosahedron. These two are also each other’s Duals in the same way that the Cube and Octahedron are.

Expectation
Everyday Usage

 The act or the state of expecting: to wait in expectation. The act or state of looking forward or anticipating. Something expected; a thing looked forward to.

Mathematical Usage

Expectation (or Expected Value) is a concept in Probability Theory. Consider a finite set of outcomes, $O=\{o_1,o_2,\ldots,o_n\}$, which occur with probabilities $P=\{p_1,p_2,\ldots,p_n\}$ (noting of course that $p_1+p_2+\cdots+p_n=1$ because one of the outcomes must happen), then we have:

$E(O)=\displaystyle\sum_{i=1}^{n}o_ip_i$

The canonical example is the long-term average value thrown by a standard six-sided die (one with the number of dots on each face ranging from one to six. The outcomes here are:

$O=\{1,2,3,4,5,6\}$

and the probabilities of these are:

$P=\bigg\{\dfrac{1}{6},\dfrac{1}{6},\dfrac{1}{6},\dfrac{1}{6},\dfrac{1}{6},\dfrac{1}{6}\bigg\}$

So the Expectation is:

\begin{aligned}E(O)&=1\cdot\dfrac{1}{6}+2\cdot\dfrac{1}{6}+3\cdot\dfrac{1}{6}+4\cdot\dfrac{1}{6}+5\cdot\dfrac{1}{6}+6\cdot\dfrac{1}{6}\\&\\&=3\frac{1}{2}\end{aligned}

Here we can see that (given the likelihood of throwing any number with the die is the same for all cases) the Expectation is the same as the Mean of the outcomes. So for a Icosahedral die labelled one to twenty, the Expectation is the mean of one to twenty, or $10.5$. If some outcomes are more likely than others, then this does not hold of course.

One might view the Expectation as a sum of the values of the outcomes, weighted by their probability of occuring. The above definition generalises for countably infinite sets of outcomes and their probabilities, with $\infty$ replacing $n$ as the upper bound of the sum. For continuous (i.e. uncountable) distributions, the concept generalises to an integral rather than a sum.

Field
Everyday Usage

 An expanse of open or cleared ground, especially a piece of land suitable or used for pasture or tillage Sports. A piece of ground devoted to sports or contests; playing field. A sphere of activity, interest, etc., especially within a particular business or profession: the field of teaching; the field of Shakespearean scholarship.

Mathematical Usage

 Note: This definition is adapted from the first section of Glimpses of Symmetry, Chapter 16 – …But not as we know it.

A Field is essentially a Mathematical structure that behaves the same way as the Rational Numbers with respect to addition, multiplication and division. There are some quite recherché examples, but if you think of the Rational or the Real Numbers as the prototype, then you won’t go far wrong. The set of formal properties that a Field, $F$, exhibits is as follows:

Closure

For all $a, b \in F$:

$a + b \in F$ and

$ab \in F$

Commutativity

For all $a, b \in F$:

$a + b = b + a$ and

$ab = ba$

Identities

There exist $0$ and $1 \in F$, such that for all $a \in F$:

$a + 0 = a$ and

$1a = a$

Inverses

For all $a \in F$, there exists $-a \in F$, such that:

$a + -a = 0$

For all $a \in F$ where $a \ne 0$, there exists $a^{-1} \in F$, such that:

$aa^{-1} = 1$

Associativity

For all $a, b, c \in F$:

$a + (b + c) = (a + b) + c$ and

$a(bc) = (ab)c$

Distributivity

For all $a, b, c \in F$:

$a(b + c) = ab + ac$

From the above we can see that a Field F is effectively two for the price of one with respect to Groups, $(F,+)$ is a Group and so is $(F\backslash0,\times)$. What is more both Groups are Abelian.

Function
Everyday Usage

 TBC TBC TBC

Mathematical Usage

XXX

Graph
Everyday Usage

 TBC TBC TBC

Mathematical Usage

XXX

Group
Everyday Usage

 TBC TBC TBC

Mathematical Usage

XXX

Identity
Everyday Usage

 TBC TBC TBC

Mathematical Usage

XXX

Imaginary
Everyday Usage

 TBC TBC TBC

Mathematical Usage

XXX

Integral
Everyday Usage

 TBC TBC TBC

Mathematical Usage

XXX

Irrational
Everyday Usage

 TBC TBC TBC

Mathematical Usage

XXX

Manifold
Everyday Usage

 TBC TBC TBC

Mathematical Usage

XXX

Map
Everyday Usage

 TBC TBC TBC

Mathematical Usage

XXX

Measure
Everyday Usage

 TBC TBC TBC

Mathematical Usage

XXX

Module
Everyday Usage

 TBC TBC TBC

Mathematical Usage

XXX

Normal
Everyday Usage

 TBC TBC TBC

Mathematical Usage

XXX

Perfect
Everyday Usage

 TBC TBC TBC

Mathematical Usage

XXX

Rational
Everyday Usage

 TBC TBC TBC

Mathematical Usage

XXX

Real
Everyday Usage

 TBC TBC TBC

Mathematical Usage

XXX

Ring
Everyday Usage

 TBC TBC TBC

Mathematical Usage

XXX

Simple
Everyday Usage

 TBC TBC TBC

Mathematical Usage

XXX

Smooth
Everyday Usage

 TBC TBC TBC

Mathematical Usage

XXX

Space
Everyday Usage

 TBC TBC TBC

Mathematical Usage

XXX

Tree
Everyday Usage

 TBC TBC TBC

Mathematical Usage

XXX

Variety
Everyday Usage

 TBC TBC TBC

Mathematical Usage

XXX

 << The Irrational Ratio Part of the peterjamesthomas.com Maths and Science archive.

Notes

 [1] [{3,5-(CF3)2C6H3}4B]−, or more colloquially BARF. [2] A type of thorny-headed worm, or Acanthocephala. [3] You most likely don’t want to know. It involves stuff like: [4] See a section of Euler’s Number for more background on limits. [5] See another section of Euler’s Number for more background on differentiation. [6] If we exclude dividing by zero of course. [7] The Real Numbers are not algebraically closed, not least as $\sqrt{-1}$ is not a Real Number. [8] A curve implies a one-dimensional line. Derivatives may be taken of two-dimensional surfaces, or indeed higher-dimensional shapes. [9] A section of Euler’s Number shows how to calculate the derivative of a function.
 Text & Images: © Peter James Thomas 2018. Published under a Creative Commons Attribution 4.0 International License.


text:
# Long chain of remainders $\pmod{11}$

Find the remainder of $2014.2015.2016.................2023$ on division by $11$.

×


text:
# [machine learning] how to use half grid search to shorten the grid search speed?

Contents of this chapter:

1. The principle and operation process of half grid search (theoretical description)
2. Description of halfinggridsearchcv parameter in sklearn
3. 🤷♀ Case: half grid search_ House price data set_ python

Indexes

• 🔣 Functions and parameters
• 🗣 case
• 🤷♀ case
• 📖 Extract

# 1 (Theory) principle and process of half grid search

📖 The main solution to semi grid search
Long operation time caused by large amount of data

📖 Principle of half grid search
By extracting some data sets each time, the amount of data used in each modeling can be reduced, so as to reduce the amount of calculation.
It should be noted that in order to ensure that the reduced amount of data can effectively reflect the overall data situation, the distribution of a small number of extracted data sets needs to be consistent with the overall data distribution.

📖 Half grid process

1. Firstly, a small subset 𝑑 0 is randomly sampled from the whole data set, and the performance of all parameter combinations is verified on 𝑑 0. According to the verification results on 𝑑 0, eliminate the half parameter combination with the last half of the score. (because the data set is very small, it is faster to verify all parameter combinations)

2. Then, a subset 𝑑 1 twice as large as 𝑑 0 is sampled from the whole data set, and the performance of the remaining half of the parameter combination is verified on 𝑑 1. According to the verification results on 𝑑 1, the parameter combination with the lowest score of 1 / 2 is eliminated

3. Then, a subset 𝑑 2 twice as large as 𝑑 1 is sampled from the whole data set, and the performance of the remaining 1 / 4 parameter combination is verified on 𝑑 2. According to the verification results on 𝑑 2, eliminate the parameter combination with the last half of the score

4. When there is only one group of alternative parameter combination left, or the remaining available data is insufficient, the circular search stops.

📖 Limitations of half grid search

• For the data set selected at the beginning of half search, the most parameter combinations are filtered out; If the initial data set is quite different from the overall data set, the effect of the last selected parameter is not good.

• In order to avoid this problem, the initial data set should not be too small, and the sample size of the overall data should be large.

• If the overall data sample is small, the search effect on the half grid may not be as good as that on the ordinary grid.

# 2. Description of halfinggridsearchcv parameter in sklearn

🔣 HalvingGridSearchCV parameter description

from sklearn.experimental import enable_halving_search_cv
# You must import this module before you can import HalvingGridSearchCV!
from sklearn.model_selection import HalvingGridSearchCV

HalvingGridSearchCV(
estimator, # Evaluator
param_grid, #parameter space
*,
factor=3, # Proportion of new sample size in each iteration
resource='n_samples', # Type of verification resources added in each iteration
max_resources='auto', # Maximum sample size of parameter combination in each iteration
min_resources='exhaust', # Sample size of parameter combination at the first iteration
aggressive_elimination=False, # Whether the condition for stopping iteration is to use all data. Not by default
cv=5, # Number / mode of cross validation
scoring=None, # Evaluation index
refit=True, # Is training performed on a complete dataset
error_score=nan, # The result returned when an error is reported. When 'raise' is selected, an error will be reported directly and the training process will be interrupted
return_train_score=True, # Show training set scores
random_state=None,
n_jobs=None,
verbose=0,
)

NameDescription
estimatorParameter adjustment object, an evaluator
param_gridThe parameter space can be a dictionary or a list composed of dictionaries
factorThe proportion of the new sample size in each iteration is also the proportion of the parameter combination left after each iteration
resourceSet the type of validation resources added in each iteration
max_resourcesIn one iteration, the maximum sample size allowed to be used to verify any combination of parameters
min_resourcesAt the first iteration, the sample size r0 used to verify the parameter combination
aggressive_eliminationWhether to use the completion of all numbers as an indicator to stop the search. If not, take measures
cvDiscount of cross validation
scoringEvaluation indicators, supporting simultaneous output of multiple parameters
refitSelect the evaluation indicators and the best parameters for training on the complete data set
error_scoreWhen grid search reports an error, the result will be returned. When 'raise' is selected, the error will be reported directly and the training process will be interrupted
In other cases, a warning message will be displayed before continuing to complete the training
return_train_scoreWhether to display parameter scores in training set in cross validation
random_stateControlling the randomness of randomly sampled data sets
n_jobsSet the number of threads participating in the calculation when working
verboseOutput work log form
• factor

The proportion of the new sample size in each iteration is also the proportion of the parameter combination left after each iteration. For example, when factor=3, the sample size of the next iteration will be three times that of the previous one, and 1 / 3 of the parameter combination will be left after each iteration. The effect is better when this parameter is usually taken as 3.

• resource

Set the type of verification resources added in each iteration, and enter it as a string. The default is the sample size, and the input is "n_samples". It can also be a weak classifier that inputs a positive integer in any integration algorithm, such as "n_estimators". Then the tree of the tree will increase by factor times after each iteration.

• min_resource

At the first iteration, the sample size r0 used to verify the parameter combination. You can enter a positive integer or two strings "smallest" and "exhaust".

1. Enter a positive integer n, indicating that n samples are used in the first iteration.

2. Enter "smallest" to calculate r0 according to the rule:

☑ When the resource type is sample size,
For regression algorithms, r0 = cross validation discount n_splits * 2 when the resource type is sample size;
For classification algorithm, r0 = number of categories n_classes_ * Cross validation n_splits * 2；
When the resource type is not a sample size, it is equal to 1;

3. Enter "exhaust" to reverse r0 according to the maximum available resources in the last round of iteration.
For example, if factor=2 and the sample size is 1000 and there are 3 iterations in total, the maximum available resources of the last iteration are 1000, the penultimate iteration is 500, and the penultimate iteration (the first iteration) is 250. At this point r0 = 250. In "exhaust" mode, it is most likely to get good results, but the amount of calculation will be slightly larger and the calculation time will be slightly longer.

📖 How to determine the conditions for stopping iteration?

1. f a c t o r ∗ m i n _ r e s o u r c e i > number according to collection factor*min\_ Resource ^ I > dataset factor∗min_ Resourcei > data set, and i is the number of iterations supported by the data volume
2. ginseng number group close number / / f a c t o r i < 1 Number of parameter combinations / / factor ^ I < 1 The number of parameter combinations / / factori < 1, and the calculated i is the number of iterations supported by the parameter combination

In the i of the above two methods, the smaller i corresponds to the condition of iteration stop.

such as i i < i 2 i_i<i_2 ii < I2, then the condition for stopping the iteration is: use all the data;
The number of iterations in this case does not support running a complete parameter combination, that is, the iteration has stopped before the possible optimal parameter combination has time to test.

🔣 aggressive_ Eliminationparameter

1. This parameter is used to solve the situation that the amount of data is small and is not enough to support running a complete combination of parameters;
2. When the parameter is set to True, the sample size at the first iteration will be reused until the remaining data is sufficient to support the increase of the sample size until only the last set of alternative parameters are left.
3. When the parameter is set to False, all samples are used up as an indicator of the end of the search.

Limitations: due to the use of the first iteration sample, the difference between this sample set and the overall data set is the largest; Therefore, the more times of use, the greater the possible deviation of the results.

☑ Points to consider when weighing the number of iterations and the amount of calculation:

1. min_ The value of resources cannot be too small, and we want to use as much data as possible before the end of the whole iteration process

2. After the iteration, the combination of remaining verification parameters should not be too many. It is best below 10. If it cannot be achieved, it is also acceptable below 30

3. The number of iterations should not be too many, otherwise the time may be too long

🗣 How to determine the first sample size:
First, print the number of samples and parameter combinations for each iteration:

factor = 1.5
n_samples = X.shape[0]
min_resources = 500
space = 1440

for i in range(100):
if (min_resources*factor**i > n_samples) or (space//factor**i < 1):
break
print(i+1,"Sample of this round of iteration:{}".format(min_resources*factor**i)
,"Parameter combination of this round of verification:{}".format(space//factor**i + 1))

1. i: Indicates the total number of iterations performed when the iteration stops
2. Iterative sample size: indicates how many samples are used for calculation. The closer it is to the overall data size, the better
3. Parameter combination: indicates how many combinations are left in the parameter space. The smaller the better.
4. The larger the factor, the better; min_ The larger the resources, the better

# 🤷♀ Case 3: semi random grid search_ House price data set_ python

📖 Semi random grid search VS random grid search
Running time: half search time is shorter
Model effect: random grid search is slightly better

🔣 Case: semi random grid search_ House price data set_ python

# Import dataset
data=pd.read_csv(r'C:\Users\EDZ\test\ML-2 courseware\Lesson 9.Stochastic forest model\datasets\House Price\big_train.csv',index_col=0)
X=data.iloc[:,:-1]
y=data.iloc[:,-1]
X.head()

# Set parameter space
param_grid_simple={'n_estimators':range(60,120,5)
,'max_depth':range(10,25,2)
,'max_features':['sqrt',16,32]
,'min_impurity_decrease':range(5,30,5)}

# Calculate the size of the parameter space
def count_space(param_grid_simple):
no_option=1
for i in param_grid_simple:
no_option*=len(param_grid_simple[i])
return no_option
count_space(param_grid_simple)

from sklearn.ensemble import RandomForestRegressor as RFR
from sklearn.model_selection import KFold

model=RFR(random_state=7)
cv=KFold(n_splits=5,shuffle=True,random_state=7)
search=HalvingGridSearchCV(estimator=model
,param_grid=param_grid_simple
,factor=1.5
,min_resources=500
,scoring='neg_mean_squared_error'
,n_jobs=4
,random_state=7
,cv=cv
)
search.fit(X,y)

search.best_estimator_ # View the optimal parameter combination
abs(search.best_score_)**0.5 # View RMSE

# View the model effect of the optimal parameters

from sklearn.model_selection import cross_validate

def RMSE(cvresult,key):
return (abs(cvresult[key])**0.5).mean()

def rebuild_on_best_param(ad_reg):
cv=KFold(n_splits=5,shuffle=True,random_state=7)
res_post_adjusted=cross_validate(ad_reg,X,y
,cv=cv
,scoring='neg_mean_squared_error'
,return_train_score=True
,n_jobs=-1)
print('train RMSE: {:.3f}'.format(RMSE(res_post_adjusted,'train_score')))
print('test RMSE: {:.3f}'.format(RMSE(res_post_adjusted,'test_score')))

rebuild_on_best_param(search.best_estimator_)
# Training RMSE: 460.432
# Test RMSE: 1107.865

Keywords: Machine Learning Data Analysis

Added by asaschool on Thu, 03 Mar 2022 16:38:46 +0200


text:
# How to customize emacs auc-tex function Tex-command-list? [closed]

I'm trying to use the latex package `nomencl' which allows one to easily create a Nomenclature section in an article. So far so good.

I'm using emacs with AucTeX and I added the nomenclature compile option to the emacs Tex-Command-list by editing my .emacs file, adding:

``````;;nomenclature for latex
'("Nomenclature" "makeindex %s.nlo -s nomencl.ist -o %s.nls" TeX-run-command nil t :help "Create nomenclature file")))
``````

to it, this works: when I press `C-c C-c` (the shortcut for TeX-command-list I can use the `Nomenclature` command and the appropriate file is generated. I am unhappy though, for the following reason:

When I run BibTex (using Tex-Command-list), and then press C-c C-c again, emacs offers to run LaTeX, as appropriate, and if references have changed, it will offer LaTeX again, finally, it will offer View, once the .log doesn't report references have changed.

However When I run Nomenclature, the next command offered by Tex-command-list is View, which is alway inappropriate, since one needs to compile again after recreating the nomenclature file.

How can I tell emacs to give LaTeX as the next TeX-command-list command after running Nomenclature (same behavior as BibTeX)?

## closed as off topic by Charles Stewart, Jim G., ecatmur, DocMax, MatteoNov 24 '12 at 10:48

Questions on Stack Overflow are expected to relate to programming within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here. If this question can be reworded to fit the rules in the help center, please edit the question.

The AUCTeX function `TeX-command-query` is responsible for that. Right now, it simply checks for the existence of .bbl, .pdf, .ps, .dvi files and guesses the next step. If Nomenclature also generates some new files that, when present determine that TeX must be run again, it should be easy to add that feature.


text:
Sometimes, you might need text to flow from one text box into another (and maybe another after that!). In that case, you need to use Word 2007 to create linked text boxes. For example, you might use text boxes to create a sidebar with text related to your document. If the sidebar is particularly long, you can continue it in another text box.

Follow these steps to create a set of nicely linked text boxes:

1

Type the text you want to place in a series of text boxes.

Creating linked text boxes is often easier if you first create the text to put in them.

2

Create two or more text boxes.

Need a refresher on creating text boxes? Here’s what you do: First click the Text Box button in the Text group on the Insert tab. Then choose Draw Text Box from the menu that appears. Now, click where you want one corner of the text box to appear and drag to where you want the opposite corner. Then release the mouse button.

3

Select the text you typed in Step 1 and press Ctrl+C.

The text copies to the Clipboard.

4

Select the first text box and press Ctrl+V.

The text from the Clipboard pastes into the text box. The text box displays as much of the text as it can; the rest is hidden.

5

Right-click the text box and choose Create Text Box Link.

The cursor changes to a weird-looking coffee cup.

6

Click the second text box.

The extra text that’s overflowing in the first text box spills over into the second.

7

If you want to spill text into additional text boxes, repeat Steps 5 and 6.

You can link as many text boxes together as you want.

To remove a text box from a chain of linked text boxes, right-click the text box that comes before it in the chain and choose Break Forward Link.


text:
# Basis for the linear spacer $\ell^p$ [duplicate]

Is there any well known basis (Hamel basis) for the vector space $\ell^p$? And what about the cardinality of such basis? Is it countable?

## marked as duplicate by user147263, Jonas Meyer, Adam Hughes, user99914, graydadJun 10 '15 at 5:11

• To see that the cardinality is uncountable you can use the Baire category theorem. Regarding the other question, there are models of set theory where there are no Hammel basis for $\ell^p$, so although it is not obvious you really need AC. – azarel Jun 10 '15 at 1:54
• @Chilote: You may be right: The axiom of choice does not exclude the existence of an explicit Hamel basis for certain spaces, or? As another example the existence of ONB for Hilbert spaces requires the axiom of choice. However there are spaces that admit explicit ONB's anyway even in the inseparable case. As an example consider $\ell^2(\mathbb{R})$. It has the explicit ONB $e_s:=\chi_{\{s\}}$ for $s\in\mathbb{R}$. – C-Star-W-Star Jun 10 '15 at 8:28
• @azarel: Exploiting the axiom of choice does not exclude the existence of an explicit Hamel basis. As an example for inseparable Hilbert spaces the proof for ONB requires the axiom of choice, in general. However, there are examples of inseparable Hilbert spaces where there is a well-known explicit ONB; e.g. $\ell^2(\mathbb{R})$ has ONB $e_s:=\chi_{\{s\}}$ for $s\in\mathbb{R}$. – C-Star-W-Star Jun 10 '15 at 8:29


text:
# Solutions to Problems 1051-1056

Q1051. What is the fractional derivative $$\frac{d^{\frac{1}{2}f}}{dx^\frac{1}{2}}$$ of $f(x)=1/\sqrt{x}$ (see the article on fractional calculus
in Parabola, Vol. 35, No. 2)?


text:
Not signed in (Sign In)

# Start a new discussion

## Not signed in

Want to take part in these discussions? Sign in if you have an account, or apply for one below

• Sign in using OpenID

## Site Tag Cloud

Vanilla 1.1.10 is a product of Lussumo. More Information: Documentation, Community Support.

• CommentRowNumber1.
• CommentAuthorUrs
• CommentTimeOct 8th 2010

polished regular category somewhat and added a few things, for instance a Properties-section.

Also started and linked to a dedicated entry on regular logic.

• CommentRowNumber2.
• CommentAuthorTodd_Trimble
• CommentTimeJan 8th 2016

Added to regular category and exact category the statements that slices and co-slices of regular/exact categories are regular/exact (under Examples).

• CommentRowNumber3.
• CommentAuthorTodd_Trimble
• CommentTimeFeb 21st 2017

Added to regular category and exact category the statements that for a Lawvere theory $T$, the category of $T$-models in a regular/exact category is regular/exact (under Examples).

• CommentRowNumber4.
• CommentAuthorPeter Heinig
• CommentTimeJun 7th 2017
• (edited Jun 7th 2017)

Added two properties, and headings to regular category. Intend to describe an axiomitization result of Makkai concerning regular functors i in more detail on this page. Had to pause for the time being. Motivation is that I work on a non-axiomatizability proof concerning infinite (undirected simple) graphs, for which I am learning more categorical logic.

• CommentRowNumber5.
• CommentAuthorThomas Holder
• CommentTimeJun 8th 2017

I brushed up the reference and idea section a bit.

Add your comments
• Please log in or leave your comment as a "guest post". If commenting as a "guest", please include your name in the message as a courtesy. Note: only certain categories allow guest posts.
• To produce a hyperlink to an nLab entry, simply put double square brackets around its name, e.g. [[category]]. To use (La)TeX mathematics in your post, make sure Markdown+Itex is selected below and put your mathematics between dollar signs as usual. Only a subset of the usual TeX math commands are accepted: see here for a list.

• (Help)