Posts

Showing posts with the label Mathematics

The equation for a sunset

Image
 I’ve always been a big fan of sunsets. I get some really nice ones most evenings in the summer from my current flat but with winter approaching I wanted to try and make something virtual and consistent. One of my goals was that after I got my quest 2 to try and sit coding with a sunset in the background. There are a number of issues on the road to realising that dream in its entirety however I got a long way with watching the sunset over the ocean. Bellow, I present a shader (Code dedicated to programing the shader section of the graphics card pipeline) for a sunset over ocean waves. Ocean waves in deep water are much easier to generate than shallow-water waves as you can get away modelling them as not interacting with anything. That permits an ontogenetic style where you can skip to the future without calculating the intermediate steps. The surface is based on the sums of sin waves which is not true to how water actually moves as it moves in  Gerstner waves . So I based the ...

The full problem

Image
In a previous post I've solved issues of a farmer trying to maximise the area of their field using a given length of fence. Given that was solvable I thought, well what if rather than a wall the farmer was to use a circular lake? This is also modelable but the answer isn’t as intuitive. I would argue the reason the answer isn’t as intuitive is that the more of the fence circle you use, the more the lake invades the pasture. There must be some benefit in using the edge of the lake though, at least my intuition leads me to believe. Here I try to go about calculating the systems in the same way as in the previous post. Let the reflex angle BAD represents the large simple area of the pasture. The segment ABE represents half the remaining segment, bearing in mind that not all of this is usable. The area BEFB is subtracted from this and represents the area covered by water that would otherwise make the remainder of the arc.   This can be calculated i...

An exploration in number systems

For most people, the denary system of numbers is perfectly natural. So much so that people don’t even give other options a second thought. The alternatives are not just hypothetical but are in their own way ingrained in our culture. What is the denary system of numbers? Denary from the Latin decem for ten, is a system of numbers where we have 10 symbols 0 to 9. For this, we use a positional number system based on powers of 10. Each column to the left has a value 10 times that to the right. The number 1000 is: Thousands Hundreds Tens units 1 0 0 0 This isn’t the only system that could be used and in fact, 10 is special only in the sense that we have 10 fingers. If the number of fingers isn’t taken into account then base 12 would make arithmetic a lot simpler. Instead of a 10s column you have a dozens, instead of 100s you have 144s. For this you ofcourse need more symbols. 10 is represented with the symbol A and 11 is represented with the symbol B. 12 is re...

The lemon grove at the creperie: Maths behind economic intuition

Image
 There are a lot of things we have an intuition about in economics. If you haven't studied it you might not realise these often have a mathematical formalism. Two farms Take the following example I got from a blog   Having two farms that can be harvested in six months isn't equal to having one farm that can be harvested in three months and another that can be harvested in nine months. How do I take into account the amount of time involved? So intuitively there is a benefit from having a smaller output after a shorter time, but how do we quantify how much better it is? This is where a concept called discounting comes in. Discounting allows you to calculate the value of things based on how you value money now compared to in a years time. If I offered you £100 now, I'd not be surprised if you took me up on the offer. If, however, I give you a second option, I'll give you £x in exactly a years time. How much would I have to give you in a years time for you to choose to take...

But can't you just use integration on the arc length?

Image
 I recently came across the following video  It made me think surly this can be derived in the same way as one can derive the formula for a circle. I'd gone through that derivation a number of times at school and since the formula for an ellipse is so close thought the same approach would surly work for an ellipse. I decided to give it a go believing that I surely wouldn't get the answer I expected but it would be interesting to see why the arc-length method wouldn't work. At this point, if I had to guess I would guess that the impossibility lay in the issue with integration. The formula for a circle can be represented parametrically as: To adapt this to an ellipse one simply needs to add constants in front of each trigonometric function: The arc length of a line can be calculated by the following identity which follows from Pythagoras: Using this identity we can get a formula for s in terms of x and y. However, this is where the signs of the problem begin as to fin...

A failed attempt at yielding rivers from gradient noise

Image
From the jsfiddle here I have done a previous post on gradient noise , explaining my realisation at why the equations involved are what they are. Hydronics are notoriously challenging in procedural landscapes because very few realistic ontogenetic algorithms exist. The solutions employed by the likes of dwarf fortress is to run calculations based on a path at different levels of detail down from the mountains to the oceans. Given that gradient, noise is so-called because it makes use of gradients and from the simplicity with which beaches can be generated I wondered if a simple -1/a trick would yield path perpendicular to the beaches - a river? The reasoning behind -1/a is that if you have a gradient on a graph, say “a” from a line ax+b, if you want a perpendicular line, then the gradient will be (-1/a). Following this reasoning, and the fact that we have the gradient at each point, I attempted to calculate the negative inverse of the gradient, which ended up being fiendishly complicat...

A mathematical spell check

Image
As a dyslexic, I rely heavily on spellcheck to correct my writing and put it into a readable form. I heavily rely on a similar checker when writing code, paying close attention to use before declaration errors that might indicate that I have misspelt something. I also have spellcheck on in vim, which checks snake case words individually! I don’t however have the same thing for mathematics. Notation can be incredibly powerful. The best notation is that where it makes it clear when you have done something wrong. Or better still doesn’t allow you to do anything wrong. When writing long equations I often miss a sign in one place or another, manipulate them wrong and generally propagate these errors until I find a result which doesn’t make sense. I wondered if there was something simple I could use, that would not be any more time consuming than writing the equations out by hand, that would act as a “spellcheck” for my manipulation of equations. I use a lot of equations on this blog ...

As many Barys as baryons.

Image
Recent thoughts on the applicability of models made me think about if it was valid that we use a model of people’s height which gives a non-zero probability to a person with a negative height. Trying to calculate the probability of a man having a negative height has its challenges because most normal distribution tables don’t include such extreme Z numbers. I used the numbers for the average hight and standard deviation of a man from this site . We can convert our normal distribution to a Z score using the following formula: “Adult men in the United States are approximately normally distributed with a mean of 70 inches and a standard deviation of 3 inches.” As we are looking at a raw score of not negative x will be 0. Mu is 70 and sigma is 3. That gives us a Z score of about -23. Since most Z score tables don’t get even to 5 standard deviations from the mean, we will need to calculate being 23 out ourselves. With a little bit of help in finding out how to use scipy to do numeri...

Some thoughts on solving transcendental equations

Image
My thinking here is that although transcendental equations don’t have algebraic answers are there still links between them? That theory is supported by the contour lines in the following  So I wasn’t going to look into this but sometimes I just get captured by the mathematics. I have known for a while that most equations can’t be solved. The unsolvability of most equations leads to transcendental numbers. Numbers which aren’t the result of a solvable algebraic equation like 5x+1=7 or 2x^2=3 but can be computed, at least approximately. These numbers include pi and e. There isn’t a formula for pi or e, we can define them, we can even define them without the use of geometry. As I have found out in my curious investigations both numbers seem to crop up only when calculus is involved. e is the solution to the problem of The functions that produce these two have always seemed arbitrary to me. Why is it the case that when we don’t know the answer to we just say, the answer is the answer?...

Popular posts from this blog

THREE.js: minecraft in a weekend

Greedy meshing in javascript

Custom work from home desk