text:
00:00 - 17:0017:00 - 00:00

12:24 AM
hey guys
just saying hello, today will be my quasi free day, so might just hang out and lurk a bit :D

2 hours later…
2:22 AM
@Blue One thing that I really like about Abraham Marsden is that is its very self contained unlike Arnold, which needs a good bit of familiarity of differential geometry notation(I feel notation is a big thing to get a hold of differential geometry)

5 hours later…
7:09 AM
morning

@Slereah u didn't respond to my challenge

which

Is it the whole QFT as a worldline thing

something like that
but on $\infty$-stacks

7:14 AM
What is a $\infty$-stack
Is that the famous stack
to exchange
on stackexchange

It's a sheaf with values in $\infty$-groupoids

Alas I'm not gr8 on category theory
Do u know a thing, btw
Does the worldline formalism actually reproduce QFT
I wonder because there's that whole thing about how the perturbation theory thing doesn't run over every possible state

Tangential fact: Prior to stackexchange.com there was a coding-related Q&A site called expertsexchange.com
which people used to call expert sexchange.com
alas they hyphenated it at some point

Like perturbation theory does the sin of exchanting the sum and integral

@Slereah I know staggeringly little about QFTs if that wasn't clear from my challenge

7:17 AM
BUSTED

indeed

Speaking of worldline formalism
I am learning aboot point particle BRST quantization
(STILL)
It is not an easy task
what with the general covariance

I have heard of BRST cohomology

Apparently the big difference between the Goto-Nambu action and the Polyakov one is that the mass-shell constraint is first class and second class in them or something
I am v. bad at constraints

1 hour later…
8:47 AM
Yo @BalarkaSen

Hey

What's up

Not much; I fly to Bangalore tomorrow

Ahhh nice nice. All the best at ISI

Thanks
How's symplectic geometry going, @Albas?

8:57 AM
Doing lie brackets right now, will slowly reach there
I was thinking about something. When we talk about vector bundles, we say that locally the preimage of a point should have the vector space structure. It might not yield anything much but can having the structure be an infinite dimensional vector space lead to anything interesting

You can do that

Though I do understand how a symplectic group structure comes from Hamiltons equations of motion and canonical transforms

That is precisely what I don't know :)

9:17 AM
Sorry @BalarkaSen but I am not well versed with it and hence I wont be able to take an attempt to explain it

No worries, tell me when you understand it better

The basic idea I think is that the jacobian is a symplectic matrix
We use that to obtain a symplectic group structure from the canonical transform

Aha
Jacobian of a canonical transform?

Yea

You can have fibers that are infinite dimensional
The tensor bundle is an example
Also whatever fiber continuous spin representations have
or the Hilbert bundle

9:57 AM
I found an English translation of Lemaitre's paper on "Quaternions and Elliptic Spaces" which I am reading now because google led me down a rabbithole

2 hours later…
11:52 AM
I have just succeeded in upgrading the CPU in my desktop PC to one considerably faster than Dell officially supports, and (so far) it hasn't burst into flames and exploded. A good morning's work I feel :-)

@bolbteppa Did you go through Kubiznak's lectures on the Perimeter site? Are they good (in terms of content)? I was watching the first lecture from 2015-2016's PSI and he seems to be following L&L and Arnold. Seems nice so far

12:46 PM
@JohnRennie Hi, I hope my message finds you well. If you're around today, I wanted to ask a question about one of your posts, thanks a lot in advance.

2 hours later…
2:53 PM
@user929304 Hi, I'm around now for a couple of hours.

@JohnRennie Great, thanks for getting back to me. First I had a somewhat dumb question to sanity check if I ve correctly understood how motion along time axis and spatial axes get mixed when spacetime is no longer flat
@JohnRennie So is it correct that, even if we may not be accelerating, and simply having a constant spatial velocity (say 1/3 of speed of light), then time in our frame evolves more slowly compared to if we were at 0 speed (spatially)? In other words, it doesn't have to be accelerated motion for motion along time axis to be slower than speed of light.
I guess im making a mistake in that if the spacetime is curved, we must be in acceleration by definition, right? Meaning if ever there's a discussion of time "slowing down" or ticking faster, it goes without saying that the object of interest is in a gravitational field and as such experiencing accelerated motion.

@user929304 have a look at this question. Although it might not appear to be directly relevant, in the answer I give a geometrical description of why different observers disagree about the time axis:
76

Suppose we have two twins travelling away from each other, each twin moving at some speed $v$: Twin $A$ observes twin $B$’s time to be dilated so his clock runs faster than twin $B$’s clock. But twin $B$ observes twin $A$’s time to be dilated so his clock runs faster than twin $A$’s clock. Eac...

The mixing of the time and space axes occurs even in flat spacetime. It doesn't require any curvature.

@JohnRennie Oh! Exactly what I was trying to get, so I always understood "flat" as time axis being orthogonal to spatial ones, consequently, motion along spatial axes will not influence motion along time axis. But I guess what you mean is that, because the four velocity is conserved and always equals speed of light, if we are on flat spacetime, that is, e.g. when experiencing constant velocity motion in space, time our clock measures is slower than it would be if we were at 0 velocity spatially?

3:09 PM
Your clock, i.e. the clock you are holding, always runs at the same speed of one second per second. But when you observe clocks moving relative to you in your coordinates they will be running slower than one second per second.
That's because what you consider the time axis is not what the moving clocks consider their time axis to be.

@JohnRennie I just read the linked post, clarified a lot for me already. Why do the chosen directions of time is different between the three? if they are all moving along the x-axis, then they are constantly moving in a direction orthogonal to time axis, what is here making the definition of actual time axis different for each party?
@JohnRennie Aha! so in my frame im at rest and by definition my clock ticks at 1 sec per sec, but what if Im in accelerated motion? such as falling from a mountain, then do I still measure on my clock 1 second per second?

@user929304 I don't know of a really intuitive explanation for why the time axes differ. You can show very easily that they must differ by crunching through a bit of maths. If you haven't already seen it I do this in:
56

Please will someone explain what time dilation really is and how it occurs. There are lots of questions and answers going into how to calculate time dilation, but none that give an intuitive feel for how it happens.

@user929304 in your frame your clock always ticks at one second per second, regardless of whether your frame is inertial or accelerated.

@JohnRennie then how can the four-velocity I measure in my frame be conserved? is it because by saying "in my frame" it is assumed that I am at rest spatially?

Your frame is, by definition, the frame in which you are at rest (usually at the origin). So your 4-velocity in your frame is $(c, 0, 0, 0)$.

3:24 PM
@JohnRennie oh I see, makes sense. Then to follow the reasoning, when we send a shuttle with people on it to space, say the shuttle goes at a constant speed +v relative to us (so no acceleration, to simply things), then in our reference frame on earth, we measure their spatial speed to be +v and consequently their velocity in time (according to us) must be slower for the four-velocity to be conserved, and we call this observation: time is dilated for them. Is this about right?

Yes, that's basically it

@JohnRennie great! but they in their frame (i.e. the shuttle s frame) measure in turn our velocity in time on earth to be slower, so from their point of view, they are at rest and the earth system is experiencing dilated time. But why do we say then that when they come back they ll have aged less...?

@user929304 See this question:
70

The paradox in the twin paradox is that the situation appears symmetrical so each twin should think the other has aged less, which is of course impossible. There are a thousand explanations out there for why this doesn't happen, but they all end up saying something vague like it's because one tw...

I feel i am missing a big point... :(

why is length contracted and not expanded?
geogebra.org/graphing/s34v3zpg this is my spacetime diagram, which i think is right

3:29 PM
The twin paradox necessarily involves accelerated motion and that changes the way the time dilation is calculated.

@JohnRennie ohhh! maybe that s what I was missing then! So if there s no accelarated motion and there s only constant relative motion at play between the two frames, we do measure relative time dilations but neither ages faster or slower, right? I guess acceleration somehow introduces an asymmetry.

each sees the other as younger
they are allowed to disagree because they are far away from each other

@zounds Lorentz contraction isn't a contraction! See:
12

Lorentz contraction is easy to understand once you realise that it is not a contraction at all. Instead it is a rotation and the length of the object, or more precisely its proper length, doesn't change at all. To see this take the usual example of a rod of length $2a$ aligned along the $x$ axis...

@user929304 correct

@JohnRennie my question, i guess is about the assymetry of time and space here

@zounds It is?

3:33 PM
if you look at the diagram i linked,

Great, so as long as constant relative speed is at hand, we have the scenario
as you described in your post with different definitions of north. Last bit of pestering if I may, is there any intuition for how "accelerated motion" introduces an asymmetry?

we take the "relativistic time" as being the y-value of a point, but the "relativistic length" as being where the time axis intersects our space axis

@user929304 if you observe my time then what that means is you measure my time in your coordinate system. The time dilation changes the mapping between our two coordinate systems, which is we we disagree about the time.
What acceleration does is change your coordinate system so that your coordinates become curved.
So even if you and I are (momentarily) stationary relative to each other, if you are accelerating then we will disagree about the time because your acceleration has caused the coordinates you are using to measure my time to be curved.
The trouble is that this is complicated, and while it seems intuitive to me that's only because I've been studying it so long. I'm sure it isn't intuitive to you.
@user929304 if you look at that last question I linked I go through the maths to show this, but I have to admit it's a bit short on intuition.

@JohnRennie indeed it is very hard to get a grip about :( So I guess, only if there's acceleration involved, then one sees the other s frame as curved (though in my frame Im still at rest and clock ticks 1 sec per sec), and experience time evolution differently
@JohnRennie Thanks a lot, I promise to go through it. Is it fair to say that if we sent out shuttles to space but only at constant speed relative to us on earth, then there would be no twin paradox once they return, because we'll have aged with equal pace?

Mathematically an accelerated frame is very like the situation where you are hovering near a black hole i.e. to really understand it requires some of the concepts used in general relativity.
@user929304 the shuttles can't return if they travel at constant speed. To return they must have decelerated to a stop then accelerated back towards us.
A return trip necessarily involved acceleration

3:43 PM
@JohnRennie ahhhhhhhhhhhhhhh! im so silly, I see what you mean!!! Neat!
@JohnRennie so with constant relative motion, time dilation (disagreement between clocks) is relative, but with accelerated motion the disagreement is "real" because one will have actually aged differently?

Yes. And that's due to the asymmetry in the acceleration. Only one of the twins has accelerated.

@JohnRennie great! I admit, I feel like I have both understood and still very puzzled at the same time :)

@user929304 it is basically hard to understand.
The funny thing is that after you've understood it then it seems obvious :-)

@JohnRennie I can only wish that day comes for me... :(

It's like riding a bicycle in a way, once you get the knack for it you wonder how you could ever have found it difficult.
@user929304 are you at school or university?

3:48 PM
@JohnRennie I am at university but I dont study physics, I read physics just for myself, hence all these naive questions sadly :/

Ah, OK. The problem is that we physicists are very familar with the maths involved, but if you don't have that background the maths is a real obstacle.
Really you need to learn the maths and get to the point where you easily calculate time dilations, and then you'll find suddenly you understand them!

indeed! I try to catch up but it is very slow.. I also get easily lost by the terminology at play often, proper time, coordinate time, time-like, ... etc.

@JohnRennie "The problem is that we physicists are very familar with the maths involved" Hmmmmmmm 🤔

@user929304 yes, you tend to get swamped by the detail. This happens to all of us and the only solution is to keep bashing your head against it :-)

@JohnRennie Speaking of four-velocity being conserved, applying this to photons, given they move through space at speed of light, can we say that a photon is by definition at rest in time? :)
@JohnRennie haha I promise to keep at it, the struggle is enjoyable!

3:52 PM
@BalarkaSen out, damned spot mathematician!
@user929304 photons do not have a rest frame. You'll find that if you attempt a coordinate transformation into the rest frame of a photon (or anyhting travelling at the speed of light) the transformation becomes singular.
This crops up over and over again in questions on the site. It is meaningless to ask about the time experienced by a photon.

@JohnRennie Right, oh so if there s no definable rest frame, we cannot speak of time evolution meaningfully?

what if they're siamese twins

it would be very painful
...for you

you're a big guy

3:56 PM
:D

The twin paradox is really pretty easy to solve with GR
Hell for globally hyperbolic spacetimes you can prove it for all spacetimes and observers!
since timelike geodesics are minimal then

not sure how much utility you're gonna get out of trying to explain the Twin Paradox to a beginner by invoking globally hyperbolic spacetimes lol

It's not a paradox! If you want a paradox ask a set theorist. They have lots to spare! :-)

Well if you're a beginner and you still don't get the twin paradox after all that's on the internet, take it on faith maybe :p

"What's a Globally Hyperbolic Spacetime?" "Well you see little Timmy, when you have a spacetime that can be foliated by Cauchy surfaces, you have a globally hyperbolic spacetime"

4:00 PM
Globally hyperbolic spacetimes are the boring spacetimes

they admit a Hamiltonian formulation of GR so maybe they're the fun spacetimes
don't discriminate bro

You know
I still don't know if that's true
I mean
It is true
But I don't know if the converse is true
Hamiltonian GR is a complicated topic

but you don't know if they're the only spacetimes that can be formulated that way?

yeah

@user929304 time evolution means some process that is mapped onto a time axis. Your time axis is a perfectly good time axis for measuring or calculating time evolution, so there's no problem calculating time evolution of photons. What you can't do is try and work in the rest frame of the photon.

4:02 PM
yeah, I'm not sure either, but the treatments of Hamiltonian GR invariably start off by assuming Global Hyperbolicity

I do know that at least if it's globally hyperbolic the development is unique
Which might be the issue
But I have seen some people use Hamiltonian GR for non-globally hyperbolic spacetimes

@JohnRennie Makes sense thanks! Last question for time being if I may, can we say that an object in a gravitational field, always experiences accelerated motion? (i.e. irrespective of the chosen reference frame of the observer)

perhaps within some region there's a local Hamiltonian formulation
@user929304 in GR a freely falling body experiences no acceleration, this includes freely falling bodies under the influence of gravity

@user929304 Sadly not. The only unambiguous measurement of acceleration that can be assigned to an observer is their four-acceleration, sometimes called proper acceleration.

@enumaris well every spacetime has a globally hyperbolic neighbourhood around every point

4:06 PM
If you are falling freely in a gravitational field then your four-acceleration is zero. The astronauts in the International Space Station are falling freely in the Earth's gravitational field and that's why they are weightless i.e. their four-acceleration is zero.

@Slereah yeah, that's just the statement that spacetimes are manifolds right

Pretty much

so if you just go to a specific coordinate system around some point you can probably do some Hamiltonian stuff

But you and I, sitting stationary on the surface of the Earth, have non-zero acceleration and that's why we aren't weightless.

Well, I think the metric has to be $C^2$ or something
So that you can define a convex normal neighbourhood

4:08 PM
hmmm

$C^0$ metric spacetimes act pretty weirdly

@JohnRennie exactly, but can we ever have a zero four acceleration if we are in a graviational field?

@user929304 yes, just jump off a cliff. While you're falling freely your four-acceleration is zero.
... though not for long :-)

I worry not about $C^0$ metrics
Everything is analytic to me
as all things should be

Everything analytic isn't great either
You can't have metrics defined on a compact region then

4:11 PM
no big deal

@JohnRennie aha :) So if my four acceleration is zero (i.e. free fall) I experience a flat spacetime?

Having metrics Minkowski except in a compact region is a nice thing to have for proofs

eh

@user929304 correct, and in fact that's a very important principle in GR. If you are falling freely then your local area of spacetime appears to you to be flat.

then let them be $C^\infty$

4:12 PM
Smooth is fine
ALTHOUGH
Thin shell
is nice

let them eat cake

$C^0$ physics anything sounds scary to me

$C^0$ isn't too spooky if it's well behaved enough, but it could be like
Non-differentiable anywhere

then you would have undefined parallel transport

you can get fairly weird spacetimes behaviours

4:16 PM
and undefined curvature

@JohnRennie Many thanks again! You are very kind and patient. I will mull over all this and hopefully get back to you with less silly questions :-) Thanks again.

you need at least $C^2$ if you want to have well defined curvature...

You can still talk about the causal structure
But it gets weird
Nah, you don't need $C^2$

The metric needs to be at least twice differentiable, no?

@user929304 you're welcome. I just hope I haven't just confused you further!

4:17 PM
You just need to have the Geroch-Traschen condition
but then they are defined in a distributional sense

What does Brownian motion count as?
in terms of smoothness, I mean

nowhere differentiable
but everywhere continuous
so $C^0$ I think

sounds right

In fact Brownian motion if Holder continuous
s
is
floopdoodle

4:20 PM
Holder continuous $2$, I think?

Sounds right

took a course on that once a long time ago

So is doing GR with a $C^0$ metric or similar something physicists do is it just of mathematical interest?

Or at least the set of holder continuous $2$ paths isn't of measure $0$
Well $C^0$ metrics might pop up in quantum gravity
For instance in the path integral formulation

Feels like you'd have trouble defining a Curvature lol
but if there's some fancy workaround
then so be it

4:23 PM
Things get Complicated with path integrals
you don't use the usual definitions

paths in path integrals can also be nowhere differentiable amiright

@JohnRennie I have one more question suddenly if you re still here :)

John is always here

in other news: sunburns aren't fun. I knew that. what I did not know about was sunburn itch

he is the silent knight

4:24 PM
which sounds innocuous enough but

Anytime you have an open wound, it'll itch

@user929304 yes?

@enumaris Paths that are differentiable anywhere are of measure 0

so if your skin peels...itchyness for days

@enumaris do we have to discuss skin pathologies while I'm eating lunch? :-)

4:26 PM
@Slereah give pathological cases an inch and they'll take all of the infinite-dimensional space you had around you that you hadn't even noticed was there

@JohnRennie well...fried Chicken skin is pretty good munchies

see, this is where i like bohmian trajectory stuff. the trajectories there are weird, but the space of such paths is pretty simple. (trajectories are smooth and don't cross in configuration space, weeee)

@JohnRennie to correctly understand the muon example in SR: one observer is on earth stationary, the other is the muon. Relative to us on earth, the muon is travelling at constant but very high speed (relative to speed of light), so we on earth measure the muon s clock to be ticking very slowly and that s how we explain why it can reach earth before its lifetime is reached (its time is going slowly in our frame so it can reach earth before lifetime ends). Whereas in the muons frame,

fried pork skin also not bad

@JohnRennie the clock is ticking 1 second per second, but it see the length to travel to have contracted, so it needs less time to travel before its lifetime reaches because it sees a lesser distance to travel. And there s no acceleration involved. Is it a sound picture?

4:28 PM
@user929304 yes, and in fact I'm sure I explained exactly this in an answer somewhere on the main site.

Since you GR guys are here, is Kaluza-Klein producing EM unique? It seems to me like you may be able to come up with an extra dimension in a way that you could add whatever interaction you wanted.

@JohnRennie And if the muon wanted to measure our time on earth, but in its own frame, it think our time is dilated on earth, right?

@EmilioPisanty You know that I really hate you? I mathjaxificated 2 equations in this when I saw that while I was doing that stuff somebody else had edited the post.

7

Take the two events when the muon is created, and when it decays. We'll choose the origins of the muon rest frame and the lab rest frame so their origins coincide at the point and time the muon is created i.e. the muon is created at (0, 0) in both frames. Both frames will agree about their relati...

Apparently $C^0$ metrics have that weird thing where $\partial I^+ \neq \partial J^+$

4:30 PM
@Chair I think there's a meta.PSE question about that

@user929304 there, that's a full treatment of the muon travel done using the Lorentz transformations.

> what do I do if I'm too slow with my edit
or sommn like that

@EmilioPisanty Lol really?

@Chair no, I shouldn't think so
=P

@danielunderwood Kaluza-Klein is related to the fiber bundle formulation of EM

4:30 PM
@user929304 yes

Other interactions can also be formulated in such a way, but I don't know if that would work, because EM is a pretty simple case

I've been doing mathjax stuff just for the practice of it though... I'll need to do some stuff with LaTeX later this semester so I thought it'd be a useful skill to pick up

ie the gauge group is abelian

So I guess it's not a huge loss

@EmilioPisanty oh, there's been further action on the question you bountied. (WimC gave quite a bit more details on what Numerical Recipes was doing)

4:31 PM
I don't think you could do the weak or strong interaction

@JohnRennie great! so I guess the moral is that, in either choice of frame, we consistently end up concluding that it can reach earth before it decays, right?

@Semiclassical yeah, I saw that

@user929304 Correct! :-)

@Semiclassical Also someone wrote a pretty lame answer for the 3 mirrors vs 2 one.

The trick for KK is that $\mathbb{R}^5$ is locally similar to $\mathbb{R}^4\times U(1)$

4:32 PM
@Semiclassical is the edit enough for your purposes?

@JohnRennie Physics is beautiful!

@Chair yeah, it seems Rod Vance just isn't that interested in answering =(

I mean $\mathbb{R}^7$ is locally similar to $\mathbb{R}^4 \times SU(2)$, but the group structure isn't there

@Chair two lame answers, one now deleted

yeah, it definitely clarified things a lot. I'd definitely rate it as deserving the bounty. (especially by comparison with the other answer, which while qualitatively helpful was not actually addressing the question being asked)

4:33 PM
@EmilioPisanty I guess when you have 70k+ rep 200 really won't mean too much?
@EmilioPisanty Oh, yeah, The ultra-short one got deleted too? Why? It wasn't VLQ standard, though it wasn't 200 bounty-level either.

(the fact that I'm the only person who has upvoted that answer sorta bugs me, tbh. i guess people just don't look at such questions that much?)

Never mind... one now deleted
I saw something a while back on a question with 500 bounty (the incident occurred some years ago, don't ask me how I saw it)... Someone put a placeholder answer which contained just 2 sentences about how it's a placeholder, and that answer won the bounty. Later, when someone put up a good answer, the bounty was re-initiated by the owner of the placeholder, if that made sense.

@Slereah Well at least I half understood most of that. I don't know that much about physics from the group side of things and combining spacetime with a group like $\mathbb{R}^4 \times U(1)$ seems a bit foreign to me. Guess it's time to learn!

My original thought was that you could arbitrarily add a dimension to GR to add a scalar field. There's obviously something wrong with that picture since EM requires a vector field, but is there any validity in it?

4:39 PM
@Semiclassical cool
I'll read in more detail when the bounty is closer to the end

And are fiber bundles worth learning? I've seen a couple sources of "this is what a tangent bundle is, which is an example of fiber bundles that we don't need here"

@danielunderwood when you add a dimension to 4 dimensions, and you look at rank 2 tensors like the Stress-Energy Tensor, you are actually adding 9 elements so you should have enough freedom to do some stuff there

fiber bundles are a very common thing in theoretical physics
For gauge theory

Actually fiber bundles look a lot simpler than tangent bundles

4:41 PM
Well the idea of a fiber bundle is simple
but there are many things to it

Tangent bundle is just a subclass of fiber bundles
where the fibers are tangent spaces
so I dunno how they can be more complicated o.O

A fiber bundle is just attaching a space at every point
ie at every point of space, you attack $R^4$, for the tangent bundle
Or $U(1)$, for the EM gauge bundle

With some specific rules on how the attachment goes

@enumaris In some sense, objects with less structure are often more complicated because you don't know as much as about them.
Compare, for instance, the theory of fields with that of arbitrary rings.

ring ring ring ring ring

4:43 PM
fair enough I guess

bananaphone

Ahh that sounds fairly simple. I still have trouble thinking in the math way where everything starts with a definition

the math way is
just making simple things
way complicated

because they have to be "rigorous"

4:44 PM

My real problem is when there are 4 different definitions for the same thing
I understand that they're useful for different things, but it sometimes seems like the definitions talk about different objects

@enumaris I often find a bit of rigor much preferable to "the physics way" where you can never really know what you're allowed to do with some symbol or object because people don't care for proper definitions.

@Slereah So are you saying that $\mathbb{R}^4 \times U(1)$ is an example of a fiber bundle?

Yes.

Too much rigor can suffocate, but too little of it leaves you afloat in an ocean of vagueness

4:46 PM
trivial bundles, they are called

@ACuriousMind just do what you need to do

Damn, ninja'd AGAIN!

let the mathematicians worry about it later
Just do it™

@enumaris "ask for forgiveness, not permission"

Indeed

4:47 PM
if it turns out to be justified, then you're going to need to do the calculation anyways

@ACuriousMind to ape a line of Kant, a bird can't fly in vacuum

$™$

and if you do the calculation and it turns out to not actually be useful, what was the use of worrying about whether it was justified?

@Semiclassical Can an ape?

There we go

4:48 PM
^ and I got that argument from a mathematician, I should point out

@Slereah yes. huzzah for rocket ships :P

Analysis II, probably close to the most rigorous I got while in undergrad

aaand blocked

4:49 PM
i suspect the counter argument to that is that you can have a calculation that looks right but actually isn't

You know I wonder how much that monkey freaked out once in orbit

and thus one can labor under the delusion that it's useful when it's actually not

@Semiclassical Cf. all the questions we have about "paradoxes" arising from pretending too hard that position eigenstates are actual states.

@Slereah why would orbit be the most freak-out-inducing part of the trip?

yeah

4:50 PM
@Slereah So even $\mathbb{R}^n, n > 1$ itself would be a fiber bundle? Assuming that my thought $\mathbb{R}^n = \mathbb{R} \times ... \times \mathbb{R}$ is actually correct, which I'm not entirely certain of

I would think launch would be by far the most terrifying bit

@danielunderwood You can define it as such, yes
You can even do $\mathbb{R}$ as a fiber bundle, with a zero-dimensional fiber
But there's not much point to it
The interesting part is more that you add structures to the manifold

@EmilioPisanty The way up may be more directly stressful, but I think the complete absence of gravity may be more fundamentally confusing than just "more" of it.

@ACuriousMind meh
if you're strapped in and you can't unbuckle the straps, you probably won't notice it that much

"Ham's lever-pushing performance in space was only a fraction of a second slower than on Earth, demonstrating that tasks could be performed in space."
That chimp is more professional than some humans

4:53 PM
That comic made me think of "sea monkey do"

@Slereah which reminds me, I have a copy of First Man sitting at home waiting for me to be not-busy enough to read it
hopefully I'll get through it before the movie hits theaters
it looks awesome
Gemini VIII, the training-vehicle crash, the whole deal
plus Ryan Reynolds has that shy-but-decided quality that Armstrong had

it would be better if the actor was a chimp

damn
Ryan Gosling

spking of movies has anyone seen antman II yet? liked it, lots of physics aspects in the series, eg QM realm, big budget, A list actors, etc

@vzn I have a backlog of all of the Avengers and MCU movies that I'm studiously not going through

4:59 PM
lol might as well not go to the movies then (these days) :P

00:00 - 17:0017:00 - 00:00


text:
# How to simplify -a*z+a*z to 0 where “a” is an expression

Consider the following:

a = 1+(x+y+z+u)^10000
(* Out[57]= 1+(u+x+y+z)^10000 *)
e = -a*z+a*z
(* Out[59]= z (-1-(u+x+y+z)^10000)+z (1+(u+x+y+z)^10000) *)

How can I simplify -a*z+a*z (assigned to e) to 0? The simplification is obvious.

I tried:

Simplify[e]
(* Out[60]= z (-1-(u+x+y+z)^10000)+z (1+(u+x+y+z)^10000) *)
FullSimplify[e]
(* Out[61]= z (-1-(u+x+y+z)^10000)+z (1+(u+x+y+z)^10000) *)
Distribute[e]
(* Out[62]= z (-1-(u+x+y+z)^10000)+z (1+(u+x+y+z)^10000) *)

None of it worked. The only two functions that can do that are Expand[e] and Apart[e], both of which work for smaller expressions, but never finish for this one:

Apart[e]
(*
No more memory available.
Mathematica kernel has shut down.
Try quitting other applications and then retry.
*)

because they are expanding the (u+x+y+z)^10000 part, which takes forever.

• Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. – bbgodfrey Jan 22 '15 at 22:17
• Please reformat your code according to the guidelines in meta1027. Doing so will encourage more people to try to answer your question. – bbgodfrey Jan 22 '15 at 22:19
• e /. (x + y + z + u) -> t // Simplify – Bob Hanlon Jan 23 '15 at 5:13

Expand takes forever, because it is trying to expand (u + x + y + z)^10000. Tell it not to.
Expand[e, Power[u + x + y + z, 10000]]

• Thanks! Or in general Expand[e, _^_] will work too. – Ondřej Čertík Jan 22 '15 at 23:23
• Well, hey, that's something I did not know about Expand, nifty. +1 – rcollyer Jan 23 '15 at 2:59

format: plain


text:
# Exponential growth and decay (Part 5): Paying off credit-card debt via recurrence relations

The following problem in differential equations has a very practical application for anyone who has either (1) taken out a loan to buy a house or a car or (2) is trying to pay off credit card debt. To my surprise, most math majors haven’t thought through the obvious applications of exponential functions as a means of engaging their future students, even though it is directly pertinent to their lives (both the students’ and the teachers’).

You have a balance of $2,000 on your credit card. Interest is compounded continuously with a rate of growth of 25% per year. If you pay the minimum amount of$50 per month (or \$600 per year), how long will it take for the balance to be paid?

In previous posts, I approached this problem using differential equations. There’s another way to approach this problem that avoids using calculus that, hypothetically, is within the grasp of talented Precalculus students. Instead of treating this problem as a differential equation, we instead treat it as a first-order difference equation (also called a recurrence relation):

$A_{n+1} = r A_n - k$

The idea is that the amount owed is multiplied by a factor $r$ (which is greater than 1), and from this product the amount paid is deducted. With this approach — and unlike the approach using calculus — the payment period would be each month and not per year. Therefore, we can write

$A_{n+1} = \displaystyle \left( 1 + \frac{0.25}{12} \right) A_n - 50$

Notice that the meaning of the 25% has changed somewhat… it’s no longer the relative rate of growth, as the 25% has been equally divided for the 12 months.

A full treatment of the solution of difference equations belongs to a proper course in discrete mathematics. However, this particular difference equation can be solved in a straightforward fashion that should be accessible to talented Precalculus students. Let’s use the above recurrence relation to try to find a pattern. For $n = 1$, we find

$A_1 = r A_0 - k = r P - k$.

For $n = 2$, we find

$A_2 = r A_1 - k$

$A_2 = r (rP - k) - k$

$A_2 = r^2P - rk - k$

$A_2 = r^2 P - k (1 + r)$

For $n = 3$, we find

$A_3 = r A_2 - k$

$A_3 = r \left[ r^2 P - k(1+r) \right] - k$

$A_3 = r^3 - rk(1+r) - k$

$A_3 = r^3 P - rk - r^2k - k$

$A_3 = r^2 P - k \left( 1 + r+r^2 \right)$

At this point, we can probably guess a pattern:

$A_n = r^n P - k \left( 1 + r + r^2 + \dots + r^{n-1} \right)$

Using the formula for a finite geometric series, this simplifies as

$A_n = r^n P - k \left( \displaystyle \frac{1 - r^n}{1-r} \right)$.

Indeed, though I won’t do it here, this can be formally proven using mathematical induction.

## One thought on “Exponential growth and decay (Part 5): Paying off credit-card debt via recurrence relations”

This site uses Akismet to reduce spam. Learn how your comment data is processed.


text:
# Overview

## Python Setup

This meta-project collects all of the python tools I typically use. It also serves as a fairly minimal example of setting up a package the pip can install, and specifying dependencies.

### Summary

There are two recommended ways of installing python:

Enthough Python Distribution:
The Enthough Python Distribution provided by Enthought_is a complete python installation including NumPy, SciPy, matplotlib, and many other useful tools. These all come packaged in a single working distribution that can be installed at once. There is both a free version, and a professional version -- the latter is free for academic use and includes some additional tools for analysis and visualization.
Anaconda:
An alternative complete python installation is provided through Anaconda from Continuum Analytics, developed by many of the people who developed the Enthough Python Distribution. There are also free and professional versions with the latter being free for academic use. One caveat is that Anaconda does not work on as many systems (it will not work on my 32 bit Mac for example). As a plus, in includes some cutting-edge high-performance tools like Numba.

My suggestion is to install one (or both) of these, then create appropriate virtual environments for managing any additional packages you need to install. In this way, you keep your system python clean, have access to the latest tools in a complete distribution (which is also kept clean) and can play with various package combinations: Important, for example, if you want to make sure you understand all of the dependencies of your code.

Note that Anaconda has its own environment manager instead of virtualenv called Conda so the setups are different. We describe both flavours here.

### Quick Start

#### Enthough Python Distribution

If you are impatient and courageous, here is the executive summary based on the Enthough Python Distribution:

• Install Enthough Python Distribution (or Anaconda), git, and GSL.

• Install virtualenv (and pip which is not provided by Enthough Python Distribution):

sudo easy_install pip
sudo pip install virtualenv

or down load virtualenv.py and replace $$virtualenv$$ with $$python virtualenv.py$$ below if you want to keep your base python installation pure.

• Install the virtual environments setup some aliases:

virtualenv --system-site-packages --distribute ~/.python_environments/epd
virtualenv --no-site-packages --distribute ~/.python_environments/clean
virtualenv -p /usr/bin/python --system-site-packages --distribute \
~/.python_environments/sys
virtualenv -p ~/usr/apps/anaconda/Current/bin/python \
--system-site-packages --distribute \
~/.python_environments/anaconda

cat >> ~/.bashrc <<EOF
alias v.epd=". ~/.python_environments/epd/bin/activate"
alias v.sys=". ~/.python_environments/sys/bin/activate"
alias v.clean=". ~/.python_environments/clean/bin/activate"
v.epd
EOF

• Install Mercurial:

pip install hg

• If on a Mac, then fix pythonw:

mkdir -p ~/src/python/git
cd ~/src/python/git
#git clone http://github.com/gldnspud/virtualenv-pythonw-osx.git
git clone http://github.com/nicholsn/virtualenv-pythonw-osx.git
cd virtualenv-pythonw-osx
deactivate; v.epd        # Make sure you use the appropriate virtualenv
python install_pythonw.py /Users/mforbes/.python_environments/epd

• Activate your desired virtual environment and choose the set of requirements to install:

v.epd
pip install -r all.txt

#### Anaconda

I install Anaconda in /data/apps/anaconda/1.3.1 which I symlink to /data/apps/anaconda/current. Add /data/apps/anaconda/current/bin to your path. One can use Conda to manage the equivalents of virtual environments, but for now I am just using a "global" environment. I needed to do the following to get to a working state:

conda update anaconda conda ipython pip sympy numexpr
conda pip ipdb winpdb zope.interface mercurial
conda pip psutil memory_profiler
conda pip scikits.bvp1lg theano
conda pip pp
conda pip

### Requirements

Here is a list of the various requirements. These are all disjoint, so you can pick and choose.

doc.txt :
Various documentation tools like Sphinx and associated packages. I use this for both my code documentation and for things like my website.
emacs.txt :
Various tools for setting up my development environment (I use emacs) including checking tools.
debug.txt :
Debugging tools, including remote debuggers.
profile.txt :
Profiling tools for optimizing code.
testing.txt :
Testing tools including code coverage.
vc.txt :
Version control tools like mercurial and extensions
misc.txt :
Odds and ends.
mmf.txt :
My source packages for projects. These will be installed as source distributions.
all.txt :
All of the above.

Here are some additional requirement files:

EPD.txt :
The list of requirements frozen from a fresh EPD install.
freeze.txt :
Snapshot of my system by running pip freeze > freeze.txt
bleeding-edge.txt :

Installs NumPy, SciPy, and matplotlib from source. Note: this does not work for some reason because pip fails to install some compiled libraries. (The NumPy install will look fine, but SciPy will then fail.) Here is a discussion. To deal with this, first use pip to install this developmental version of NumPy. This will install the source. Then go into the source directory and run python setup.py install --prefix=/path/to/virtualenv. I.e.:

pip install --upgrade -r bleading-edge.txt
cd ~/.python_environments/epd/src/numpy
python setup.py install --prefix=~/.python_environments/epd

mac.txt :
Specific packages for Mac's.

### Details

To use it do the following:

1. Install a version of python. Many systems have a version preinstalled, so this step is optional. However, if you plan to do serious development, then I strongly recommend installing the Enthough Python Distribution. There is a free version, and an almost full featured free version for academic use: You can also pay for a comercial version and recieve support. The EPD is very complete, and just works on most common platforms and I highly recommend it. Make sure you can run the version of python you desire.

If you install the EPD, then it will typically add something like the following to your ~/.bash_login or ~/.profile files:

# Setting PATH for EPD-7.3-2
# The orginal version is saved in .bash_login.pysave
PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}" export PATH MKL_NUM_THREADS=1 export MKL_NUM_THREADS  (If you want to use a multithreaded version of numpy, you will need to change the value of MKL_NUM_THREADS. See this discussion.) 1. Create a virtualenv. This will allow you to install new packages in a controlled manner that will not mess with the system version (or the EPD version). You can create multiple virtual environments for different projects or associated with different versions of python. Again, this is highly recommended. There are several ways of doing this. Note Methods 1) and 2) will install virtualenv to the location specified by the current version of python. This means that you might need root access, and it will slightly "muck up" you pristine system install. This is generally not a problem, but if it bothers you see step 3). 1. If you have pip (the new python packageing system), then you can use it to install virtualenv as follows: pip install virtualenv  2. If you do not have pip, you might have easy_install: easy_install virtualenv  3. If you do not want to muck up your system version of python at all, then you can simply download the file virtualenv.py. In the commands that follow, replace virtualenv with python virtualenv.py. 2. Setup a virtual environment for your work. You can have many differen environments, so you will need to choose a meaningful name. I use "epd" for the EPD version of python, "sys" for the system version of python, and "clean" for a version using EPD but without the site-packages: virtualenv --system-site-packages --distribute ~/.python_environments/epd virtualenv --no-site-packages --distribute ~/.python_environments/clean virtualenv -p /usr/bin/python --system-site-packages --distribute \ ~/.python_environments/sys  Once this virtualenv is activated, install packages with pip will place all of the installed files in the ~/.python_environments/epd directory. (You can change this to any convenient location). The --system-site-packages option allows the virtualenv access to the system libraries (in my case, all of the EPD goodies). If you want to test a system for deployment, making sure that it does not have any external dependencies, then you would use the --no-site-packages option instead. Run virtualenv --help for more information. 3. Add some aliases to help you activate virtualenv sessions. I include the following in my .bashrc file: # Some virtualenv related macros alias v.epd=". ~/.python_environments/epd/bin/activate" alias v.sys=". ~/.python_environments/sys/bin/activate" alias v.clean=". ~/.python_environments/clean/bin/activate" v.epd  You can activate your chosen environment with one of the commands v.epd, v.clean, or v.sys. The default activation script will insert "(epd)" etc. to your prompt: ~ mforbes$ v.epd
(epd)~ mforbes$v.sys (sys)~ mforbes$ deactivate
~ mforbes$ To get out of the environments, just type deactivate as shown above. Note If you have an older version of IPython (pre 0.13), then you may need to call ipython from a function like this: # Remap ipython if VIRTUAL_ENV is defined function ipython { if [ -n "${VIRTUAL_ENV}" -a -x "${VIRTUAL_ENV}/bin/python" ]; then START_IPYTHON='\ import sys; \ from IPython.frontend.terminal.ipapp import launch_new_instance;\ sys.exit(launch_new_instance())' "${VIRTUAL_ENV}/bin/python" -c "${START_IPYTHON}" "$@"
else
command ipython "$*" fi }  This deals with issues that IPython was not virtualenv aware. The recommended solution is still to install IPython in the virtualenv using pip install ipython, but then you will need one in each environment. As of IPython 0.13, this support is included. (See this PR.) If you have not used IPython before, then you should have a look. It has some fantastic features like %paste and the IPython notebook interface. 1. Install mercurial. You may already have this (try hg --version). If not, either install a native distribution (which might have some GUI tools) or install with: pip install hg  2. Install git. This may not be as easy, but some packages are only available from github. 3. On Mac OS X you may need to install pythonw for some GUI applications (like RunSnakeRun). You an do this using this solution: mkdir -p ~/src/python/git cd ~/src/python/git git clone http://github.com/gldnspud/virtualenv-pythonw-osx.git cd virtualenv-pythonw-osx python install_pythonw.py /Users/mforbes/.python_environments/epd  You will have to do this in each virtualenv you want to use the GUI apps from. 1. Non-python prerequisites. These need to be installed outside of the python environment for some of the required libraries to work. 2. Install various requirements as follows: pip install -r requirements/all.txt  ### Using pip Here are some notes about using pip that I did not find obvious. #### Version Control It is clear from the documentation about requirements that you can specify version controlled repositories with pip, however, the exact syntax for specifying revisions etc. is not so clear. Examining the source shows that you can specify revisions, tags, etc. as follows: # Get the "tip" hg+http://bitbucket.org/mforbes/pymmf#egg=pymmf # Get the revision with tag "v1.0" or at the tip of branch "v1.0" hg+https://bitbucket.org/mforbes/pymmf@v1.0#egg=pymmf # Get the specified revision exactly hg+https://bitbucket.org/mforbes/pymmf@633be89a#egg=pymmf  What appears after the "@" sign is any valid revision (for mercurial see hg help revision for various options). Unfortunately, I see no way of specifying something like ">=1.1", or ">=633be89a" (i.e. a descendent of a particular revision). (See issue 782) ### Using the MKL The EPD is build using the Intel MKL. Here are some instructions on how to compile your own version of NumPy and SciPy with the MKL. • Checkout the source code: pip install --no-install -e git+http://github.com/numpy/numpy#egg=numpy-dev pip install --no-install -e git+http://github.com/scipy/scipy#egg=scipy-dev  • Setup the environment to use the Intel compilers: . /usr/local/bin/intel64.sh . /opt/intel/Compiler/11.1/069/mkl/tools/environment/mklvarsem64t.sh  • Edit the site.cfg file in the NumPy source directory. I am not sure exactly which libraries to include. See these discussions: cd ~/.python_environments/epd/src/numpy cp site.cfg.example site.cfg vi site.cfg  Here is what I used: [mkl] library_dirs = /opt/intel/Compiler/11.1/069/mkl/lib/em64t/ include_dirs = /opt/intel/Compiler/11.1/069/mkl/include lapack_libs = mkl_lapack95_lp64 mkl_libs = mkl_def, mkl_intel_lp64, mkl_intel_thread, mkl_core, mkl_mc  I also needed to modify numpy/distutils/intelccompiler.py as follows:  cc_args = "-fPIC" def __init__ (self, verbose=0, dry_run=0, force=0): UnixCCompiler.__init__ (self, verbose,dry_run, force) - self.cc_exe = 'icc -m64 -fPIC' + self.cc_exe = 'icc -O3 -g -openmp -m64 -fPIC' compiler = self.cc_exe self.set_executables(compiler=compiler, compiler_so=compiler,  • Build both NumPy and SciPy with the following: cd ~/.python_environments/epd/src/numpy python setup.py config --compiler=intelem --fcompiler=intelem\ build_clib --compiler=intelem --fcompiler=intelem\ build_ext --compiler=intelem --fcompiler=intelem\ install cd ~/.python_environments/epd/src/scipy  • Run and check the build configuration: $ python -c "import numpy;print numpy.__file__;print numpy.show_config()"
/phys/users/mforbes/.python_environments/epd/lib/python2.7/site-packages/numpy/__init__.pyc
lapack_opt_info:
library_dirs = ['/opt/intel/Compiler/11.1/069/mkl/lib/em64t/']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/opt/intel/Compiler/11.1/069/mkl/include']
blas_opt_info:
library_dirs = ['/opt/intel/Compiler/11.1/069/mkl/lib/em64t/']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/opt/intel/Compiler/11.1/069/mkl/include']
lapack_mkl_info:
library_dirs = ['/opt/intel/Compiler/11.1/069/mkl/lib/em64t/']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/opt/intel/Compiler/11.1/069/mkl/include']
blas_mkl_info:
library_dirs = ['/opt/intel/Compiler/11.1/069/mkl/lib/em64t/']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/opt/intel/Compiler/11.1/069/mkl/include']
mkl_info:
library_dirs = ['/opt/intel/Compiler/11.1/069/mkl/lib/em64t/']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/opt/intel/Compiler/11.1/069/mkl/include']
None

Note

You will need to setup the environment to run with the MKL libraries. The EPD avoids this by distributing the libraries. I suggest that you add the following to the activation script:

cat >> ~/.python_environments/epd/bin/activate <<EOF

# This adds the MKL libraries to the path for use with my custom numpy
# and scipy builds.
. /usr/local/bin/intel64.sh
. /opt/intel/Compiler/11.1/069/mkl/tools/environment/mklvarsem64t.sh
EOF

## Other Software

This section describes various other pieces of software that I use that interact with python.

### pyaudio

pyaudio is a python interface to the PortAudio library for generating sounds and sound files. To do real-time sound generation, one really needs to non-blocking interface (otherwise, the delay between blocking calls will affect the signal in a manner that is difficult to compensate for). Unfortunately, the default builds require Mac OS X 10.7 or higher.

### reStructuredText

I like to write my local documentation in reStructuredText (such as this file). As I often use math, I make the default role :math: and use MathJax. Here is an example:

.. default-role:: math

Now I can type math like this: E=mc^2 or in an equation line this

.. math::
\int_0^1 e^{x} = e - 1

Note

Now I can type math like this: $$E=mc^2$$ or in an equation line this

\begin{equation*} \int_0^1 e^{x} = e - 1 \end{equation*}

In order to work offline, I install MathJax locally using the IPython as described here:

from IPython.external.mathjax import install_mathjax
install_mathjax()

This installs it in ~/.python_environments/epd/lib/python2.7/site-packages/IPython/frontend/html/notebook/static/mathjax which can be used locally. I symlink it to ~/.mathjax, but you must find a way to inject the stylesheet into your HTML. One way is with the .. raw:: html directive:

.. raw:: html

<script type="text/javascript"
src="/Users/mforbes/.mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

### Emacs

I use Emacs as my principle editor and like to have access to syntax highlighting, auto-completion etc. Thus, I typically install the following packages, but these are not completely straightforward.

#### Pymacs

Pymacs allows Emacs to access the python interpreter and is used by Ropemacs to provide some nice features like code checking. The source appears not to be pip installable, so you must download it and run make as follows:

git clone http://github.com/pinard/Pymacs.git
cd Pymacs
make
pip install -e .

### Anaconda

Anaconda provides a very nice python system, especially with the Conda package management tool, but there are a few problems:

1. No installation for 32-bit Mac OS X systems. (No longer an issue for me since I finally have a 64 bit machine.)
2. No Mayavi_. This means that I must maintain an EPD 32-bit installation as well (with all my required packages) in order to visualize.

#### Creating Packages

As an example, here we create a Conda package for installing the FFTW_ and related software. We start with a fresh Anaconda installation: (this command would show if we have any packages installed that are not managed by Conda)

$conda package --untracked prefix: /data/apps/anaconda/1.3.1 Now we manually install the FFTW_ etc.: cd ~/src wget http://www.fftw.org/fftw-3.3.3.tar.gz wget http://www.fftw.org/fftw-3.3.3.tar.gz.md5sum md5 fftw-3.3.3.tar.gz # Check that this is okay tar -zxvf fftw-3.3.3.tar.gz cd fftw-3.3.3 # Build and install the single, double, long-double # and quad-precision versions PREFIX=/data/apps/anaconda/current/ for opt in " " "--enable-sse2 --enable-single" \ "--enable-long-double" "--enable-quad-precision"; do ./configure --prefix="${PREFIX}"\
--enable-shared\
$opt make -j8 install done # Note: this needs a patch to work on Mac OS X # https://code.google.com/p/anfft/issues/detail?id=4 export FFTW_PATH=/data/apps/anaconda/current/lib/ pip install --upgrade anfft pyfftw  These are untracked: $ conda package --untracked
prefix: /data/apps/anaconda/1.3.1
bin/fftw-wisdom
...
include/fftw3.f
...
lib/libfftw3.3.dylib
...
lib/pkgconfig/fftw3.pc
...
lib/python2.7/site-packages/Mako-0.7.3-py2.7.egg-info/PKG-INFO
...
lib/python2.7/site-packages/anfft-0.2-py2.7.egg-info/PKG-INFO
...
lib/python2.7/site-packages/pyFFTW-0.9.0-py2.7.egg-info/PKG-INFO
...
lib/python2.7/site-packages/pyfftw/__init__.py
...
share/info/fftw3.info
...
share/man/man1/fftw-wisdom-to-conf.1
...

These can be bundled into a new package that can later be installed directly:

\$ conda package --pkg-name=fftw --pkg-version=3.3.3
prefix: /data/apps/anaconda/1.3.1
Number of files: 82
fftw-3.3.3-py27_0.tar.bz2 created successfully

## Problems

I had problems installing a virtual environment with Anaconda. Don't do this! Use Conda instead.


text:
About a month ago, I realized I didn’t understand perps.

For the cost of $1, a 100x bitcoin perp (short for “perpetual swap”) behaves like$100 of bitcoin. This is a pretty neat trick, especially considering you can’t redeem the perp for bitcoin or anything else.

My vague idea of how they achieved this (“funding rate,” right?) seemed lacking for an instrument that traded tens or sometimes hundreds of billions of dollars per day.

I spent some time puzzling it over with some brilliant people, including the creators of some of the world’s most popular perps.

In this post, I’ll share what I learned: four very different (but mathematically identical) mental models for what perps are, how they work, and when they don’t.

# Perp Anatomy

Unlike bitcoin, which can be traded anywhere, your standard perp is native to a particular exchange and can only be traded there. Perp implementations can also vary quite a bit from exchange to exchange. This post models a simplified version of the FTX perp.

A perp’s value at any given time is represented by its mark price. This is the price used to calculate profits and losses and trigger liquidations. It is generally based on the trading price of the perp on its exchange.

The basic idea of the perp is that, ignoring complicating factors like inflationary rewards, it should be worth about the same as its underlier (i.e. bitcoin). The underlier’s value is represented in the system by the index price, which is generally calculated from its trading price on some external exchange.

When the index price and mark price are the same, the perp is worth the same as the underlier, and all is as it should be.

When the index price and the mark price diverge, the system transfers a funding fee between those who are long the perp (have bought it) and those who are short the perp (have sold it). In our example perp, the funding fee paid by the longs to the shorts is $(mark price - index price) per contract per day. When this number is negative, the shorts pay the longs. Traders must also put down collateral, known as margin. When the mark price moves against the trader, the resulting losses are deducted from this margin. If the margin balance gets too low, the trader will be liquidated, meaning their position is automatically closed out. Taken together, these pieces explain what a perp is, but not what it does. # Perp as Thermostat A thermostat is an example of a feedback control system, which keeps a value near a set point by applying increasing force as it strays. The hotter your house gets relative to your desired temperature, the higher your thermostat will crank the AC. Similarly, our perp wants its mark price to equal its index price. It attempts to achieve this by charging the funding rate of$(mark price - index price) per contract per day. The more expensive the perp gets relative to the underlier, the larger this difference will be, and the more the longs will have to pay the shorts.

Compared to the situation where there is no funding fee, longs might be marginally more inclined to close their positions, and traders in general might be marginally more inclined to open new shorts. This increase in selling should push down the price of the perp.

However, markets are notoriously hard to predict. How do we know how much more selling the funding fee will induce, or how much impact that selling will have on the price? And what if there are other factors we haven’t considered that are pushing prices in the opposite direction?

# Perp as PNL Loan

Let’s follow along with Alice and Bob, two crypto enthusiasts who don’t know about perps because their friends shamefully neglected to send them this post.

We join them with the price of bitcoin at $100k. Alice wants to go long a bitcoin and Bob wants to go short one, but Alice doesn’t have$100k and Bob can’t find a bitcoin to borrow.

They make a deal: they will pretend Alice bought a bitcoin from Bob for $100k (the mark price). As the price of bitcoin (the index price) changes, they will settle profits and losses in cash, moving the mark price. Until settled, losses are treated as debt with an interest rate of 100% per day. The next morning, the price of Bitcoin jumps to$110k.

Alice has $10k of profit on the pretend trade, which Bob needs to pay her. However, it will take him an hour to get the money. During that hour, Bob pays Alice interest on her unrealized profit. At the rate of 100% per day, this comes out to$10k/24 ~ $400 in interest. After that hour, Bob also transfers Alice her$10k in profits, so that they are back to even. Now it is as if they had just made their deal with Bitcoin at $110k, the new mark price. They have, of course, re-invented the perp: Bob must pay Alice$(index price - mark price) per day until he transfers over her profits and resets the mark price to the current index price.

While there is no guarantee that Bob will ever pay Alice her unrealized profits, as long as he remains solvent Alice will be receiving 100% interest per day on her missing capital. This is a good deal whenever her cost of capital is less than 100% per day, which should be almost always.

# Perp as Loan Swap

Let’s rejoin Alice and Bob with the price of bitcoin back at $100k. Alice wants to short the dollar against bitcoin, and Bob wants to short bitcoin against the dollar. They make another deal: Alice will borrow$100k from Bob, and Bob will borrow one bitcoin from Alice. Since they are each borrowing equivalent amounts, no cash or bitcoin actually needs to change hands.

Each will pay interest on their debt at a rate of 100% per day. With the price of Bitcoin at $100k, these interest payments cancel out perfectly. If their debt amounts ever get out of balance, each agrees to let the other equalize the debt by means of a cash transfer. The next morning, once again, the price of Bitcoin jumps to$110k.

At the 100% per day interest rate, Alice owes Bob $100k in interest per day on her borrowed$100k, while Bob now owes Alice $110k in interest per day on his borrowed bitcoin. Netted out, Bob must pay Alice$10k in interest per day, or around $400 per hour, until he transfers an additional$10k to her to equalize their debts.

Once again, Alice and Bob have re-invented the perp. The $(index price - mark price) funding rate arises when we net out the interest on Alice’s cash debt (the size of which is equivalent to the mark price) with the interest on Bob’s bitcoin debt (the value of which scales with the index price). Once again, our perp makes sense as long as both parties remain solvent and the cost of capital is less than 100% per day. # Perp as One-Day Future Let’s consider a new pair: Anon and Bot. Nobody knows who Anon is, and Bot isn’t even a person. These two can’t talk to each other, let alone structure complex deals. Can their interactions tell us anything universally true about perps? I thought not, until the inimitable Sam Bankman-Fried showed me a theoretical scheme to let them gradually transform a perp into its underlier. Imagine the price of Bitcoin is again at$100k. Anon is long one bitcoin perp (Bot is short) and would like to trade it in for one bitcoin. Unfortunately, the mark price of the perp, which we will in this example define as its trading price, is only $90k. If Anon were to sell her entire perp position, she would get only$90k for it, and would need an additional $10k to buy a whole bitcoin. However, if she were to sell just 1/24th of her position, she would need only$10k / 24 ~ $400 extra to buy 1/24th of a bitcoin from Bot. This happens to be precisely the amount of funding fee she receives from Bot every hour. So, Anon waits an hour, collects her funding fee, and trades that and 1/24th of her perp position for 1/24th of a bitcoin. Now she owns 23/24ths of a bitcoin perp and 1/24th of a bitcoin. If she keeps transforming her position in this way, within a few days it will be almost entirely bitcoin. Amazingly, Anon’s time-weighted exposure to bitcoin through the perp during this process ends up being the same as it would be if she were holding a futures contract expiring in exactly 24 hours. Ignoring interest rate term structure, this means the two should be priced roughly the same. Now we have a way to interpret the constant factor on the funding rate. If the funding rate were, say, 50% of$(mark price - index price) per contract per day instead of 100%, it would take Anon twice as long to transmute her perp, which would then be equivalent to a two day future.

Pretty crazy, right?

# Margin And Liquidations

All of our examples so far have relied on funding rates actually being paid when they are due. While Alice and Bob simply trusted each other, Anon and Bot must put down margin to enter into their positions. This is meant cover any losses that might occur before the positions can be liquidated.

Let’s say Anon wants to go long $100 worth of Bitcoin via a 100x perp. She must deposit at least$1 of margin, but she deposits $1.50 to be safe. Almost immediately, the mark price of the perp drops by 1%, so that she has lost$1. This $1 is removed from Anon’s margin account, which now contains only$0.50. This is below the minimum threshold set by the exchange, so she is liquidated and will have to pay a penalty. Ultimately, she may get back only $0.25. Now imagine that the price had dropped 2% before the system was able to liquidate her. In that case, her losses would have totaled$2, and Bot, who was on the other side of the trade, would have made $2. However, Anon only had$1.50 of margin posted, so that Bot’s last \$0.50 of profit would have had to come from somewhere else. On most perp exchanges, this place would have been the insurance fund.

Generally speaking, the system is safe to the extent that liquidations happen quickly enough and the insurance fund is sufficiently capitalized.

# Perpetual Innovation

There you have it: how I see perps as they exist today.

Are you working to change how all of us will see them tomorrow?

I’d love to help. You can email me at dave@paradigm.xyz or DM me on Twitter.

### Acknowledgements (Chronological)

The views expressed herein are for informational purposes only and, unless otherwise stated, reflect only the subjective views of the applicable speaker, which are subject to change. Nothing herein constitutes investment, legal, or tax advice or recommendations. This material does not constitute or form part of an offer to issue or sell, or of a solicitation of an offer to subscribe or buy, any securities or other financial instruments, nor does it constitute a financial promotion, investment advice or an inducement or incitement to participate in any produce, offering or investment. This material should not be relied upon as a basis for making an investment decision. It should not be assumed that any investment in the asset class described herein, or any company or asset described herein, will be profitable and there can be no assurance that future events and market factors would lead to results similar to the results discussed in this article. Any projections, estimates, forecasts, targets, prospects and/or opinions expressed in these materials are subject to change without notice and may differ or be contrary to opinions expressed by others. No representation or warranty, express or implied, is made as to the accuracy or completeness of the information contained herein.


text:
Home Asp NetCore 2 Required validation - ModelState Valid is true when in error

# Asp NetCore 2 Required validation - ModelState Valid is true when in error

apj1981
1#
apj1981 Published in 2017-12-07 20:46:52Z
 I'm trying to get some required field validation working in AspNetCore 2, and what I expect to happen, isn't happening. Model [Required(ErrorMessage = "The game name cannot be blank")] [StringLength(100,ErrorMessage = "The game name must be between 2 and 100 characters", MinimumLength = 2)] [Display(Name = "Name")] public string GameName { get; set; }  Controller [HttpPost] [ValidateAntiForgeryToken] public IActionResult GameDetail(GameDetail model, IFormCollection form) { if (!ModelState.IsValid) { return View(model); } // code removed for clarity }  View
 In MVC5, if this form was posted with no value entered, ModelState would be invalid and an error would be returned to the view. However, in this instance, ModelState.IsValid is true, but the error count is 1 and the error list does show the field is required as an error. I have tried a few things including adding [Bind("GameName")] on the post parameters against the model and also [BindRequired] on the model as well as this post: https://docs.microsoft.com/en-us/aspnet/core/mvc/models/validation Yet, the form submits and redirects to the next page (code removed for clarity) without showing any errors. I would expect to see the view returned with the field error message showing the required error message and an error summary showing the same error.
Tony Basallo
2#
Tony Basallo Reply to 2017-12-07 21:01:31Z
 I think you have to add AllowEmptyString=false on the required attribute. [Required (AllowEmptyStrings = false)]
apj1981
3#
 Goddamnit! Right, it was a complete and utter screw up on my part and I don't know why I didn't see this first! I coded the page with a simple form first just to get a layout sorted, so just used IFormCollection to save me writing a model public IActionResult GameDetail(GameDetail model, IFormCollection form)  Removed the IFormCollection form and it works exactly as I expect it to.


text:
# shared_tools¶

Todo

add paragraph description of the module

The tools are defined in pyDeltaRCM.shared_tools.

## Shared functions¶

This module defines several functions that are used throughout the model, and so are organized here for convenience.

pyDeltaRCM.shared_tools.get_random_uniform(limit: float) float

Get a random number from the uniform distribution.

Get a random number from the uniform distribution, defined over the interval [0, limit], where limit is an input parameter (usually 1).

Hint

Function returns only a single float. Wrap the call in a simple for loop to get many random numbers.

Parameters:

limit (float) – Upper limit to distribution to draw from.

Returns:

Float value from the random number generator in the interval defined.

Return type:

float

Examples

>>> get_random_uniform(1)
0.5488135039273248

>>> get_random_uniform(0.1)
0.07151893663724194

pyDeltaRCM.shared_tools.get_inlet_weights(inlet)

Get weight for inlet parcels.

This method is called at the top of water and sediment routing steps by default, as implemented in the methods get_inlet_weights_water and get_inlet_weights_sediment.

The function determines the weights describing which inlet cells parcels are fed into the domain. As implemented by default, returns “ones” for all inlet cell locations, so that the input sediment source is balanced across all inlet cells. The returned weight array is typically passed to get_start_indices to determine the locations to feed parcels into the domain based on the weights determined by this function.

Parameters:

inlet (ndarray of int) – Integer array specifying the inlet cell indices.

pyDeltaRCM.shared_tools.get_start_indices(inlet: ndarray, inlet_weights: ndarray, num_starts: int) ndarray

Get start indices.

Reutrn a randomly generated list of starting points for parcel routing. These starting points are selected from the inlet array.

Parameters:
• inlet (ndarray) – Array of inlet cells.

• inlet_weights (ndarray) – Array of weights to select items from inlet. Should have same dimensions.

• num_starts (int) – Number of starting points to generate.

Returns:

start_indices

num_starts starting points, generated from inlet

according to weights in inlet_weights.

Return type:

ndarray

pyDeltaRCM.shared_tools.get_steps(new_direction: int, iwalk, jwalk) Tuple[float, int, int, bool]

Find the values given the next step.

Get the steps for updating discharge and velocity arrays based on the direction of each step.

pyDeltaRCM.shared_tools.random_pick(prob)

Pick number from weighted array.

Randomly pick a number weighted by array probabilities (len 9) Return the index of the selected weight in array probs Takes a numpy array that is the precalculated probability around the cell flattened to 1D.

Examples

Todo

Examples needed (pull from tests?).

pyDeltaRCM.shared_tools.custom_unravel(i: int, shape: Tuple[int, int]) Tuple[int, int]

Unravel indexes for 2D array.

This is a jitted function, equivalent to the numpy implementation of unravel_index, but configured to accept only a single integer as the index to unravel.

Parameters:
• i (int) – Integer index to unravel.

• shape (tuple of int) – Two element tuple of integers indicating the shape of the two-dimensional array from which i will be unravelled.

Returns:

• x (int) – x index of i into array of shape shape.

• y (int) – y index of i into array of shape shape.

Examples

>>> _shape = (100, 200)  # e.g., delta.eta.shape

>>> np.unravel_index(5124, _shape)
(25, 124)

>>> custom_unravel(5124, _shape)
(25, 124)

pyDeltaRCM.shared_tools.custom_ravel(tup: Tuple[int, int], shape: Tuple[int, int]) int

Ravel indexes for 2D array.

This is a jitted function, equivalent to the numpy implementation of ravel_multi_index, but configured to accept only a single tuple as the index to ravel, and only works for two-dimensional array.

Parameters:
• tup (tuple of int) – Two element tuple with the x and y index into an array of shape shape to ravel.

• shape (tuple of int) – Two element tuple of integers indicating the shape of the two-dimensional array from which tup will be ravelled.

Returns:

i – Ravelled integer index into array of shape shape.

Return type:

int

Examples

>>> _shape = (100, 200)  # e.g., delta.eta.shape

>>> np.ravel_multi_index((25, 124), _shape)
5124

>>> custom_ravel((25, 124), _shape)
5124

This is a jitted function, equivalent to the numpy implementation of pad with certain optional parameters:

np.pad(arr, 1, 'edge')

In pyDeltaRCM model fields (e.g., depth) are frequently padded to enable straightforward slicing of the neighbors of a given cell; i.e., padding guarantees that all cells will have 9 neighbors.

Parameters:

arr (ndarray) – Array to pad.

Returns:

Return type:

ndarray

Examples

Consider a model domain of size (4, 8)

>>> arr = np.arange(32).reshape(4, 8)

True
(6, 10)

which enables all elements of the original (4, 8) array to be safely sliced:

>>> for i in range(4):
...     for j in range(8):

>>> slc.shape  # will always be a (3, 3) 9-cell neighborhood
(3, 3)

pyDeltaRCM.shared_tools.get_weight_sfc_int(stage, stage_nbrs, qx, qy, ivec, jvec, distances)

Determine random walk weight surfaces.

Determines the surfaces for weighting the random walks based on the stage and discharge fields.

Todo

Expand description. Where is it used? Include an example? Equations? Link to Hydrodyanmics doc?

A custom YAML loader to handle scientific notation.

We are waiting for upstream fix here:

https://github.com/yaml/pyyaml/pull/174

Returns:

Return type:

pyyaml.Loader with custom resolver

Examples

The custom loader can be used as:

>>> loader = pyDeltaRCM.shared_tools.custom_yaml_loader()

>>> a_file = open('/path/to/file.yaml', mode='r')

## Time scaling functions¶

Scaling of real-world time and model time is an important topic covered in detail in Time in pyDeltaRCM. Several functions are defined here which can help with scaling between model and real-world time.

pyDeltaRCM.shared_tools.scale_model_time(time: float, If: float = 1, units: str = 'seconds') float

Scale the model time to “real” time.

Model time is executed as assumed flooding conditions, and executed at the per-second level, with a multi-second timestep. This model design implicitly assumes that the delta is always receiving a large volume of sediment and water at the inlet. This is unrealistic, given that rivers flood only during a small portion of the year, and this is when morphodynamic activity is largest. See Time in pyDeltaRCM for a complete description of this assumption, and how to work with the assumption in configuring the model.

Using this assumption, it is possible to scale up model time to “real” time, by assuming an intermittency factor. This intermittency factor is the fraction of unit-time that a river is assumed to be flooding.

$t_r = \dfrac{t}{I_f \cdot S_f}$

where $$t$$ is the model time (time), $$t_r$$ is the “real” scaled time, $$I_f$$ is the intermittency factor, and $$S_f$$ is the scale factor to convert base units of seconds to units specified as an input argument. Note that this function uses _scale_factor internally for this conversion.

Parameters:
• time (float) – The model time, in seconds.

• If (float, optional) – Intermittency factor, fraction of time represented by morphodynamic activity. Should be in interval (0, 1]. Defaults to 1 if not provided, i.e., no scaling is performed.

• units (str, optional) – The units to convert the scaled time to. Default is to return the scaled time in seconds (seconds), but optionally supply argument days or years for unit conversion.

Returns:

scaled – Scaled time, in units, assuming the intermittency factor If.

Return type:

float

Raises:

ValueError – if the value for intermittency is not 0 < If <= 1.

pyDeltaRCM.shared_tools._scale_factor(If: float, units: str) float

Scaling factor between model time and “real” time.

The scaling factor relates the model time to a real worl time, by the assumed intermittency factor and the user-specified units for output.

Parameters:
• If (float) – Intermittency factor, fraction of time represented by morphodynamic activity. Must be in interval (0, 1].

• units (str) – The units to convert the scaled time to. Must be a string in [‘seconds’, ‘days’, ‘years’].

## Utilities¶

Additionally, functions defined in pyDeltaRCM.shared_tools manage the random state of the model, and help with documentation and version management.

pyDeltaRCM.shared_tools.set_random_seed(_seed: int) None

Set the random seed from an integer.

Set the seed of the random number generator with a single integer. Importantly, this function will affect the state of the numba random number generator, rather than the numpy generator.

This function is called during model intialization, but is not called during loading a model from checkpoint (load_checkpoint()) where the random number generator state is configured via the set_random_state() function.

Important

This function is preferred to setting the random seed directly. If you are working with model subclassing, interacting with the numpy random number generator directly will lead to a model that is not reproducible!

Internally, the method is simply the below line; however it is crucial this happens inside a jitted function, in order to affect the state of the numba random number generator seed.

np.random.seed(_seed)

Parameters:

_seed (int) – Integer to use as the random number generator seed. Should be in interval [0, 2^32].

pyDeltaRCM.shared_tools.get_random_state()

Get the random state as a tuple.

Get the random state from a tuple in the form returned by numba._helperlib.rnd_get_state(). This tuple contains the necessary information for resuming a checkpoint from the exact same random number generator state.

Important

You probably do not need to use this function. Be sure you know exactly how you are affecting the random number generator state before using this function, or you are likely to create a model that cannot be peproduced.

See also set_random_seed().

Returns:

state – Random number generator state as a tuple.

Return type:

tuple

pyDeltaRCM.shared_tools.set_random_state(_state_tuple) None

Set the random state from a tuple.

Set the random state from a tuple in the form returned by numba._helperlib.rnd_get_state().

Important

You probably do not need to use this function. Be sure you know exactly how you are affecting the random number generator state before using this function, or you are likely to create a model that cannot be peproduced.

See also set_random_seed().

Parameters:

state (tuple) – Random number generator state as a tuple.

pyDeltaRCM.shared_tools._docs_temp_directory() Iterator[str]

Helper for creating and tearing down models in documentation.

This function should be used as a context manager, to create a DeltaModel with a temporary folder as output, rather than anywhere in the project structure.

Examples

>>> with _docs_temp_directory() as output_dir:
...     delta = pyDeltaRCM.DeltaModel(out_dir=output_dir)

pyDeltaRCM.shared_tools._get_version() str

Extract version from file.

Extract version number from single file, and make it availabe everywhere. This function is used to make sure that when the version number is incremented in the pyDeltaRCM._version module, it is properly updated throughout documentation and version-controlled release.

Note

You probably don’t need to use this function.

Returns:

ver_str – Version number, as a string.

Return type:

str

Examples

>>> pyDeltaRCM.shared_tools._get_version()


text:
# zbMATH — the first resource for mathematics

One-legged caterpillars span hypercubes. (English) Zbl 0589.05031
A caterpillar is a tree with at least three vertices, which after removal of the end vertices and incident edges reduces to a snake or a simple vertex. A connected bipartite graph is called balanced if each part contains half of all vertices. It is shown that any balanced caterpillar having $$2^ n$$ vertices and maximum degree 3 spans the n-dimensional hypercube.
Reviewer: P.Kirschenhofer

##### MSC:
 05C05 Trees
##### Keywords:
caterpillar; hypercube
Full Text:
##### References:
 [1] Graph Theory. Addison-Wesley, Reading, MA (1969). [2] Harary, Discrete Math. 6 pp 359– (1973) [3] Havel, Čas. Pěst. Mat. 109 pp 135– (1984) [4] Nebeský, Čas. Pěst. Mat. 99 pp 164– (1974)
This reference list is based on information provided by the publisher or from digital mathematics libraries. Its items are heuristically matched to zbMATH identifiers and may contain data conversion errors. It attempts to reflect the references listed in the original paper as accurately as possible without claiming the completeness or perfect precision of the matching.