Convection - A Widespread Mechanism in Nature

Last week I derived the PDE starting from an SDE describing a family of short rate models (see here). When we take a look at the resulting PDE we see that it is go the kind of a reaction-diffusion-convection equation. In a blog post a few months ago I explained the effect of diffusion for the example of osmotic pressure (see Diffusion and Osmotic Pressure). Starting with this friday I will make some blog posts to show examples of the physical effect of convection in nature.

Before we can give examples we should make something like a qualitative definition what convection is. Convection is the transfer of internal energy into or out of an object by the physical movement of a surrounding fluid (liquids or a gases). This fluid transfers the internal energy along with its mass. Although the heat is initially transferred between the object and the fluid by conduction, the bulk transfer of energy comes from the motion of the fluid. Convection can occur spontaneously/naturally through the creation of convection cells. Forced convection occurs either when the fluid is propelled across the object or the object is propelled through the fluid.

From a more microscopic view convection is a collective movement of groups or aggregates of molecules within fluids and rheids, either through diffusion or by advection (the term advection sometimes serves as a synonym for convection, but technically, convection covers the sum of transport both by diffusion and by advection - advection itself is the transport mechanism related to the fluid's bulk motion).

We will close todays blog post with a very common example where we observe convection: Cooking a pot of water. The water at the bottom of the pot is close to the flame (heat source) and heats up (red arrows). It rises because it expands and has lower density. Then the water releases heat as it cools down at the top (blue arrows) and sinks down again.  Basically, the moving (circulating) water is a conveyor belt for heat transport from the hot flame to the cooler surface.

Source: http://www.indiana.edu/~geol105/images/gaia_chapter_3/mantle_convection.htm

Next friday I will give some more examples of convection in nature and how this influences our live.

How I Failed Solving the Goats, Wolves and Lions Problem


The problem description. The solutions 3 ways to solve it.

I took the challenge and thinking that the students participating the mathematical kangaroo contest have about 2 1/2 minutes per problem, I thought 30 min would be fair looking for an elegant solution. Don't looking at the choices at first hand.

And I failed

When you start, It's just you and the problem and your ideas. And your ideas are influenced by your knowledge, skills and tools. I am an Algebraist by education, a kind of abstractonaut  driving things up to the "abstract nonsense" (Recall, the free algebraic structures in the freedom of a financial language).

Not bad for formal language structures, symbolic computation, functor programming, pattern matching programming, ….

However, my try: find a closed form solution. I did suppress that there are states and transitions and that a rule base that describes the constraints is also an analytic solution.

Not surprisingly, I did not find it. Time out

With Andreas' elegant solution you only need to know what even and odd numbers are and a simple inference engine for the rule base deducing new knowledge.

Andreas is sure that children of the age of 9 years could solve the problem with a few hints.

Children are "scientists" as well - outside "official"settings?

Deep, Beautiful and Elegant Explanations

After knowing the solution, I, by chance, looked for the current best sellers in science and maths and found: This Explains Everything - 150 Deep, Beautiful and Elegant Theories of How the Word Works, in short Essays.

There are all sorts of answers to: what is your favorite deep, beautiful or elegant explanation? One just wrote "keep it simple" and then crossed it out. One explained why "elegant=complex".

Edit: I need to confess a litte dishonesty: I started with a strategy (thinking wolves ..):

(1) 6 lions devour 6 goats:  (17, 55, 6) -> (11, 61, 0)
(2) 6 wolves
 devour 6 goats: (11, 61,0) ->(5, 55, 6)
(3) 6 lions devour …. uuups

(and said to myself: stop trying, solve! - and the headache began)

BTW, this strategy had worked with 18 goats (not 17) leading to (0, 61, 0). What a nice puzzle!

Picture from sehfelder (the lonesome "solver" and the possible paths ;))

Three Ways to Solve the Goats, Wolves and Lions Problem

I refer to the Easter puzzle on goats, wolves and lions. Thanks for the responses I got.

To obtain the solution, I present three possible ways:
  • a non-feasible brute force solution,
  • a feasible brute force solution, and
  • an elegant, so to say, analytical solution.
Remember that the initial state is 17 goats, 55 wolves, 6 lions.
When two animals of different species are chosen for a meal, these two animals disappear and an animal of the third species is generated. Therefore, there are finitely many possible states and finitely many ways to achieve these states. Devouring stops when there are animals of only one species left.

Non-feasible brute force algorithm
We can describe every devouring step by the animal that is generated in this step. E.g., if a lion devours a wolf, the resulting animal is a goat, and the step is described by the letter G (goat). Therefore, we could generate  all words with fewer than 78 letters (78 is the initial total number of animals) of the three-letter alphabet {G, W, L} and decide which words are the shortest ones leading to the wiping out of two species. In the worst case, this would lead to 3^77 (=5.47 * 10^36)  words to be generated. Of course, there are much fewer possibilities (no word can start with "GGGGGGG" (why?)), but far too many to obtain reasonable computing times.

A feasible brute force algorithm
Instead of bookkeeping the possible  paths, the next algorithm keeps track of the possible states. So, starting from (17, 55, 6) (78 animals), we could obtain (16,54,7), (16, 56, 5) or (18, 54, 5) (77 animals) and so on, checking for 77,76, 75, .... animals, which combinations are attainable and which not. The algorithm stops as soon as a state is achieved which contains two species wtih 0 animals,
This algorithm needs less than one second on a single core and delivers (0, 0, 23) as the final state. One could also derive the devouring strategy leading to those 23 lions left.

The elegant solution
We know:
(1) the final state must contain two zero-species.
(2) Every meal reduces the number of animals in two species by 1 (each of them) and increases the number in the third species by 1.
(3) Thus (following from (2)), the combined number of any zwo species (goats and wolves, goats and lions, wolves and lions) either remains the same after a meal or is reduced by 2.
(4) If the final state should contain two zeros, then any earlier state of the two species to be wiped out must conatin an even sum for these two species. And the initial state as well.
(5) The only even sum obtained in the inital state is that from goats and wolves (17+55=72), Thus, the surviving species has to be lions.
(6) We know from (3) that goats + lions always stay below the initials number of goats + lions, i.e. 23. Therefore, 23 is an upper bound for the number of lions.
(7) If we can devlop a strategy ending up at (0, 0, 23), we are done. We also know that every devouring step has to contain a wolve. Otherwsie (if a lion ate a goat), 23 could not be achieved.

An optimal devouring strategy 
The optimal strategy is not unique. One possibility is:
(1) 17 wolves devour 17 goats:  (17, 55, 6) -> (0, 38, 23)
(2) 19 lions devour 19 wolves: (0, 38, 23) ->(19, 19, 4)
(3) 19 wolves devour 19 goats (19,19, 4) -> (0,0,23).

Next week, I will discuss the relevance of this example to computational finance.

Quants - In the Cage of Strategic Planning

Quants are often forced to be racers at critical paths

This may also be the result of a principle trap - strategic planning

Again, do organizations, quants work for, always know what that means?

A plan may let us sleep well, but it's not a strategy. A strategy is a framework of measures - not the measures themselves.

The trap of time- and cost-based thinking

To build a strategy is a wicked problem. It is about taking risks and facing an unknown future. It is uncomfortable, consequently many turn into a more comfortable activity: strategic planning. Planning is usually based on time- and cost-baesd thinking -  it rarely contributes to group performances.

The trap of self-reference

If you have avoided the planning and cost trap don't forget to focus on the value makers that influence your business most: creators, developers, actors. Don't overestimate capabilities and resources.
This thinking often let see you (too) great opportunities and encourage a bad strategy.

Get out of your comfort zone

It is comfortable to think everybody needs your plans. But you better focus, make your strategy simple, without searching for perfection and explain the rationale and logic explicit. This usually makes you uncomfortable?

But this is what quants need to unfold their ideas and creativity, find new ways to help conserving capital, set the stage of successful investment and risk management, leverage technology and build more quantitative skills.

Picture from sehfelder

A Little About Food Webs and Debt Webs



Andreas' mathematical puzzle Goats, Wolves and Lions reminded me on a general discussion, motivated by the complexity economy thinkers: about analogy from food webs (what eats what) to economic webs (who profits from whom) - debt webs, for example, would provide better insight to avoid bank's (true) systemic risk?

Mark Buchanan suggests a transfer of Google's PageRank algorithm into a DebtRank scheme could help reducing instability of the finical system - How Google's algorithm could fix the financial system.

Motivated by this I have written about Analogies, Metaphors and Big Problems

Who are the Lions, Wolves and Goates in an economic web?

This is not so easy to say, in a DebtRank the bank size is not as important as we might have thought. It is more the effect of transition: how wide would the spread of economies distress be, if a bank failed.

BTW, two physicist of Austria presented this article about how DebRank could be used to design a systemic risk transaction tax. It would maybe change the DebtRank in a way that financial institutions would never need to pay the tax. Lions and wolves may transmute?

DebtRank Value Adjustment?

Another thing comes to my mind. DVA is to reflect the market value of non-performace to the carrying value of fixed income securities issued by a company.

This needs exposure modeling, the prediction of future cash flows of a portfolio with a counter party - that needs the estimation of default potability …

This introduces much more complexity in the valuation space.

What, if we took into account the DebtRank of counter parties? With possible feedback loops?

p.s. the DebtRank metaphor has nothing to do with the solution of the puzzle.

Picture from sehfelder

Goats, Wolves and Lions

This is a puzzle from the Austrian 2014 mathematics kangaroo contest, taken from the students' level (16years and older), which was brought to me by a friend, who is high school teacher. I think, this is really a challenging and nice one. Remember that this puzzle is one of 30 puzzles (albeit the most difficult one), and the contestants have 75 minutes of time for all of them.
I will probably publish my solution on Wednesday. I am waiting for your answers (see below what I mean with an "answer") until Wednesday noon to Andreas Binder.

The puzzle
There are three species of animals in a magic forest: lions, wolves and goats. Wolves can devour goats, and lions can devour wolves and goats. ("The stronger animal eats the weaker one".)  As this is a magic forest, a wolve, after having devoured a goat, is transmuted into a lion; a lion, after having devoured a goat, is transmuted into a wolve; and a lion having devoured a wolve becomes a goat.

At the very beginning, ther are 17 goats, 55 wolves and 6 lions in the forest. After every meal, there is one animal fewer than before; therefore after some time, there is no devouring possible any more.
What is the maximum number of animals who can live in the forest then?

A super-correct answer in my understanding
A correct answer contains
(a) the number of animals left,
(b) a devouring strategy leading to this number
(c) the proof that this is the maximal possible number of animals left.

Two versions of the puzzle: The even more difficult one.
The even more difficult one does not give you possible answers for (a). This is thought for the geniuses among you.

The kangaroo version is a multiple choice test, giving you 5 possible answers. I will write down these possible answers below the pictures. Therefore, geniuses, stop reading now.

Image Source: http://commons.wikimedia.org/wiki/File:Hausziege_in_Tarbes-Tierpark.jpg
Image source: http://commons.wikimedia.org/wiki/File:Canis_lupus_lupus_prague_zoo.jpg
Image Source: http://commons.wikimedia.org/wiki/File:Barbary_lion.jpg


The multiple choice answers at the math kangaroo were
(A) 1
(B) 6
(C) 17
(D) 23
(E) 35

We Celebrate 555 Posts

About 5 years ago the first post in UnRisk Insight was first set free into the world: the introduction of the UnRiskverse and the evolutionary approach - that still drives UnRisk  development. A summary of the principles can be found here).

Post 555: Interest Rate Models - from SDE to PDE

Write more - learn more

It was the beginning of an exciting journey. We discussed more, wrote more, explained more, learned more - not only in the blog.

The UnRisk Academy was established and after Michael Aichinger and Andreas Binder wrote the book A Workout in Computational Finance, live workouts became an Academy reference class.

The most popular is not always the best?

The blog is read all over the world and starting with  a few page visits we enjoy now about 5000 per month. The reason? More are writing, we strive for publishing each work day, try to present posts in a rhythm and present more knowledge details.

From the all time hit list:

15 Years of Adaptive Integration 2012

Diffusion and Osmotic Pressure  2013

Skateboarding and Computational Finance 2013

VaR of the Jungle 2011

Black vs. Bachelier 2013

The Big Joke of Big Data 2011

In 2014

The series about The City Swap 

The Black Karasinski Calibration Problem

The series on models, like The Jump Diffusion Models

seem to be candidates for an all time high ...

As I personally reflect today on these 5 blogging years, what is amazing to me is how much it changed my working life.

And the blog journey continues ….

Interest Rate Models - From SDE to PDE

After our review of different equity models in the physics's friday blog post series we now turn to the family of interest rate models. Today's model I want to show the derivation of a PDE (partial differential equation) for a short rate model, where the SDE (stochastic differential equation) is given by


We are interested in the change dV of the value of an interest rate instrument V(r , t) in an infinitesimally short time interval dt. We set up a self-replicating portfolio containing two interest rate instruments with different maturities T1 and T2 and corresponding values V1 and V2 and apply Ito's Lemma to obtain

Choosing


we can get rid of the stochastic terms in the equation above. To avoid arbitrage we use the risk free rate 

and with some rearranging


This equality only holds when both sides of the equation only depend on r and t and not on product specific quantities, thus we get the following PDE for our short rate models


In our next blog post we will take a look on the different terms of this equation. 

Happy Easter

A Good Financial Languages has Freedom, Knowledge and brings Documents to Life


In my recent post The Freedom of a Financial Language I have emphasized on the benefit of a (domain specific) programming language that represents everything in symbolic expressions, for declarative programming, symbolic code manipulation, scripting ….. as a kind of freedom

When I wrote this I recalled the book Meta Math, Gregory Chaitin, about complexity, computability, randomness and incompleteness.

And think of

Computational knowledge

A little more abstractonautics: a Formal Axiomatic System is built of an Alphabet, a Grammar, Axioms, Inference Rules and a proof-checking Algorithm. Mathematical proofs must be formulated in this language and use axioms and the inference rules to create the logic "proof chain".

If the language is a an adequate programming language an automated theorem prover can create a constructive proof, a program that computes results applying the theorem.

Remember the polynomial ring. A system of multivariate polynomial equations can be solved by constructing the so called Groebner basis. The constructive proof that the Groebner bases are result of correct equivalence transformations (of the original system of polynomials) is a program that computes them. Provided, the language is a symbolic language and knows how to do the transformations.

A mathematical theorem that is proven can be pushed into the mathematical knowledge base.

A weaker, but still strong, requirement is: verified and validated.  An adequate programming language helps to automate verification and validation

A a verified and validated program can be pushed into the computational knowledge base. It is a new building block for something higher. The knowledge base becomes richer and richer and higher problems can be solved easier and easier.

Freedom (the language aspect) is complemented by automation (a rich world of algorithms).

But theres is more:

Documents that are programs 

In Language is too Clumsy an Instrument, I have introduced the idea of representing the cores of the term sheet in a document centered declarative (symbolic) language that comes with a vast variety of algorithms.

The vision: term sheets become documents that are computational. The same with financial reports, ...

UnRisk Financial Language is document centered, symbolic, declarative and it has built-in computational knowledge.

Enabling quants to extending it into their problem world with little code.

Announcement

This Easter weekend, Andreas Binder will introduce a nice and challenging mathematical puzzle about Goats, Wolves and Lions. For recreational maths fans and geniuses.

Picture from sehfelder

Why are Adjoint Problems That Fast?

Last Monday, Hannes pointed out in his post on the Black Karasinski calibration that adjoint techniques are essential to obtain results in reasonable time.

For the sake of simplification, assume that we know the reversion speed and the volatility and we want to calibrate the drift parameter function theta. This problem is somehow similar to the Hull-White curve fitting problem (see also Austria is famous for skiing and calibration) but of higher complexity due to the lack of an analytic solution already for bond prices.

Remember that in both cases (Hull-White and Black-Karasinski), the drift terms are parameters in the respective partial differential equations (PDEs) that have to be solved for the valuation of financial instruments. For the Hull-White system, explicit solutions are available that need only the evaluation of a handful of integrals. In the Black-Karasinski case, the PDE has to be solved by numerical technques with finite elements being the preferred one.

In the calibration problem, the drift term has to be fitted to meet market bond prices (minimize an error functional plus some regularization term). This could either be done by calculate the so-called Gateaux derivatives in the directions of the changes of theta: This is the sensitivity approach which needs, for the calculation of the gradient, as many finite element solutions as there are design variables (i.e. free parameters in theta). The adjoint approach reformulates the problem and needs only one PDE solution for the gradient.

Further reading:
Michael Hinze, Rene Pinnau, Michael Ulbrich, Stefan Ulbrich: Optimization with PDE constraints, Springer 2009.

Similar approches are used in the local volatility calibration.

Left: Naive application of Dupire formula, right: Egger-Engl utilizing regularization and adjoint techniques.