Showing posts with label math. Show all posts
Showing posts with label math. Show all posts

Friday, April 15, 2011

Watch This to be Lulled to Sleep by the Dulcet Sounds of my Voice



...as I talk about one of the most boring subjects known to man.


For those of you with persistent insomnia, a macabre fascination with what I've been doing at work over the last few years, or my adoring fan who just have to know what I'm up to (hi mom!), read on.

Monday, March 14, 2011

F.U. News Mailbag: Pi Day Edition

So last December, I received this email, which I'm sure is from a scammer or spammer or some other nefarious person:

***Begin Transmission***

From: Pierce [If that is his real name] <*snip*>
To: JoeCool (at) gmail (dot) com
Date: Fri, Dec 17, 2010 at 4:21 AM
Subject: I love your blog! [This is how I know he's up to no good; no one who is not related to me biologically or through marriage, a former college roommate of mine, or my confirmation sponsor, loves my blog]

Hi Joseph Belland, [Not only is he evil an untrustworthy, but he's also a mind-reader! How else could he know my full name? Maybe he's a Sith. Oh, wouldn't that be cool to have an evil Sith who's stalking me via my blog?]

I really enjoyed reading your blog. [More lies!] In particular, I liked your link to the Pi Song (2007) and the 10,000 Pi digits (2006) [Okay, those were kinda cool]; you offer up some great suggestions on how to celebrate Pi Day as well! [Well, thank you, evil Sith lord!]

I just finished this cool infographic on Visualizing Pi and thought you might be interested. You can check it out here: http://www.onlineschooling.net/visualizing-pi.

I thought your readers might enjoy the graphic and wanted to see if you would consider posting a link to it from your blog [I'll consider it, but no promises]. Let me know what you think of it.

Thanks! Pierce

Pierce Brown Online Schooling.net *snip*@sreducationgroup.org


***End Transmission***

What do I think of it, eh, Pierce? I think I don't have to worry about content for Pi day this year!

That and the graph is pretty cool. You should check it out, but for the fact that Pierce is probably an evil scammer Sith lord, and visiting his site will download Dark Side midichlorians to your computer that will fry your CPU, erase your hard drive, and steal your personal information, in that order. Such is the power of Dark Side midichlorians. That and they have the ability to make thousands of fan boys cry out in terror.

What I found most interesting was the part about how many significant digits are required to compute various accuracies of circles. Of note: 39 digits can compute the circumference of any circle within the observable universe to the width of a hydrogen atom. Looking up the width of a hydrogen atom in Planck lengths (3.1x1024) on Wolfram Hart Alpha, tells us that 63 digits of pi would be the theoretical limit to accuracy. Meaning any more digits of pi past 63 could not, in any physical way, give you a more accurate measurement. And yet pi is infinite. Trippy, huh?

Friday, May 22, 2009

Answers to the Programming Quiz:


Tom got the answer to number one. The assignment

(-1 ^ (j - 1))

will always be -1 for any integer value of j, because of Visual Basic's order of operations. The carat operator is applied before the minus operator. This added about 15 minutes to my debugging time.

As for the second question, Dave was right on with his assessment:
"it seems to take a set of real numbers and multiplies them against each other, alternately adding/subtracting the products."
That is, in fact, exactly what it does, and had he known the law in question, you probably would have gotten it from here. The law (or maybe formula would be a better term) is the general form of the Addition Law for n Independent, Non-exclusive Events, and is used in the field of probability to determine the chances that at least one of n events occurs, given the probabilities of each individual event.

To explain this, let me first define independent and non-exclusive. Two events are independent if the occurrence of one does not affect the occurrence of the other. Example: a die rolling 6 and a coin landing heads.

Two events are exclusive if they cannot occur at the same time. Example: a coin landing heads, and the same coin landing tails.

So the probability of either of two independent, non-exclusive events occurring is given by the equation:

P(A+B) = P(A) + P(B) - P(A)∙P(B)

Where P(A+B) is the probability that either A or B occurs, P(A) is the probability that A occurs independently, and P(B) is the probability that B occurs independently. (I am using + notation because I can't find the stupid Union symbol in the character map.)

This can be easier to understand with a Venn diagram.



If we want to find the area covered by both ellipses (the probability that at least one of the events occurs), we start by adding the area of each ellipse (P(A)+P(B)). But then we have added the intersection of the two events twice, so we need to subtract it out once (–P(A)∙P(B)).

We can determine the probability that any of three independent, non-exclusive events occurs with the equation:

P(A+B+C) = P(A) + P(B) + P(C) - P(A)∙P(B) - P(A)∙P(C) - P(B)∙P(C) + P(A)∙P(B)∙P(C)

To understand this, let's look at another Venn diagram.



To find the area covered by all three circles, we begin by adding in the area of each circle (the independent probability of each event, P(A) + P(B) + P(C)), but then we have added some regions more than once. To compensate, we can subtract out the intersection of every two circles (–P(A)∙P(B) – P(A)∙P(C) – P(B)∙P(C)). But now we have completely subtracted out the center region, the intersection of all three circles (P(A)∙P(B)∙P(C)).

I think you see where this is going for four events, etc. It gets very complex. In fact, the general form of the Addition Law, for n independent, non-exclusive events is:


(I)

In essence, we add in the independent probability of each event, subtract the products of each combination of two events, add the products of each combination of three events, subtract the products of each combination of four, etc., until we finally add or subtract (depending on if there are an odd or even number of events) the product of every event probability. This is what my VB code was attempting.

(There is an alternate, less complex way of attempting this. Instead of a brute force method, we can instead consider the inverse probabilities. Instead of finding the area covered by the circles/ellipses, we can find the area not covered by them, and subtract that from 1. To wit:



De Morgan's theorem states: P(A+B)' = P(A'∙B') = P(A')∙P(B')

That is, the probability that neither A nor B occurs is the probability that A does not occur and B does not occur. So if we subtract that from 1, we get:

P(A+B) = 1 – P(A')∙P(B') = 1 – (1 – P(A))∙(1 – P(B))

Which, for the general form, expands to:


(II)
)

So what brought this all up?

Probability theory figures heavily in fault tree analysis. A fault tree is, essentially, a collection of events (each with an associated probability of occurrence, specifically a probability of failure) connected via logic gates, such as AND and OR gates (and sometimes VOTE gates).

What? Explanation of the logic gates? Ok, we can do that.



This is an AND gate. It denotes that the output occurs if all of the input events occur.



An OR gate denotes that the output occurs if any of the inputs occurs.



A VOTE gate denotes that the output occurs if at least n of the inputs occurs (in this case 2).

(These symbols may seem familiar to those of you who took computer architecture. The symbols are the same ones used in logic gate diagrams, but turned sideways.)

There are also other miscellaneous gates, such as a NOT gate or XOR gate, but that's a bit beyond the scope of a simple introduction.

So the basic premise of fault tree analysis is we want to know about how often (the probability) a TOP event will occur, based on the occurrence of basic events. The TOP event is usually some hazard that we would like to prevent. A basic event is a failure or occurrence which may cause the TOP event to occur.

So, to create a fault tree, we connect these basic events to the TOP event through intermediate logic gates. These logic gates represent how the failures combine to cause a TOP event occurrence. A small fault tree might look like this:



The way to read this is by looking at the logic symbol of each gate to determine which of its input events must occur to cause the gate to occur. For example, if EVENT5 and EVENT6 occur, this will cause GATE3 to occur, because it's an AND gate and requires the occurrence of all input events. If GATE3 occurs, GATE2 will also occur, because it's an OR gate and the occurrence of any of its inputs will cause its occurrence. Now, if any two of the inputs to GATE1 occurs, say EVENT1 and EVENT3, then GATE1 will occur (because it's a VOTE gate). And if both GATE1 and GATE2 occur, then TOP1 will also occur. So we could say that TOP1 will occur if EVENT1, EVENT3, EVENT5, and EVENT6 all occur at the same time. We call this occurrence of events a minimal cut set. (I might talk more about cut sets in the future, if you wish, but as it is, this post is running too long.) Another minimal cut set might be EVENT2.EVENT3.EVENT4. (Note, EVENT2.EVENT3.EVENT4.EVENT5 is also a cut set, but not minimal. Do you see the difference?)

I will skip over how to produce the full list of minimal cut sets for this tree, and just list them all. They are: 

EVENT1.EVENT2.EVENT5.EVENT6
EVENT1.EVENT2.EVENT4
EVENT1.EVENT3.EVENT5.EVENT6
EVENT1.EVENT3.EVENT4
EVENT2.EVENT3.EVENT5.EVENT6
EVENT2.EVENT3.EVENT4

By this point, you can probably see how to produce them yourself. Now each cut set can be thought of as an event, itself. So, basically, what we have here is a list of non-exclusive, independent events, the occurrence of any of which will cause the TOP event.

Sound familiar?

The obvious way to solve this, then, would be to use... the Addition Law!

And this is exactly what the software (that company I work for) writes does. You tell it the events, how they're logically connected, and some quantitative data, such as a failure rate or MTTF (mean time to failure), and it will calculate:

1) The probability of each event occurring,
2) The probability of each cut set occurring (simple: the product of the probabilities of each event in the cut set)
3) The probability of occurrence of the TOP gate (using the Addition Law).

Note how quickly the addition law gets complex. This small and simple tree produces six cut sets, which would require 6 + 15 + 20 + 15 + 6 + 1 = 63 product terms in the addition law. Just the other day I was working with a fault tree that had 152 cut sets for one intermediate-level gate. This is why our software will use approximation methods and all sorts of other tricks to be able to solve the tree. In fact, one of the approximation methods involves using de Morgan's theorem and equation II. This is called the Esary-Proschan approximation method, but you didn't really want to know that.

If you would like, I could talk a little bit more about fault tree analysis later, and give real examples, instead of odd abstractions. But this post has gone on too long.

And now you know what I do for a living!

So back to the topic at hand, why was I writing a VB program to implement the Addition Law? Basically, I needed to verify the results of a fault tree. By hand.

Wednesday, May 20, 2009

Programming Quiz of the Day/Week/Month.


Question 1: What is the value of x after this code executes?

dim j as integer, x as integer
j = 5
x = (-1 ^ (j - 1))

Question 2: What mathematical law does the following code implement?

'Globals
dim i as integer, j as integer
dim dValues() as double

Private Function DoEet() As Double

    i = UBound(dValues)
    For j = 1 To i + 1
        DoEet = DoEet + RecursiveHell(-1, 0, -1, 1)
    Next j

End Function

Private Function RecursiveHell(k As Integer, l As Integer, _
    m As Integer, x As Double) As Double
Dim temp As Double

    If k = -1 Then
        k = 0
        RecursiveHell = RecursiveHell + RecursiveHell(k, 1, k, 1)
    Else
        If l < j
            Do While m < i - (j - 1)
                temp = x * dValues(m)
                RecursiveHell = RecursiveHell + RecursiveHell(k, l + 1, m + 1, temp)
                m = m + 1
            Loop
        Else    'l = j
            Do While m < i
                temp  = x * dValues(m) * ((-1) ^ (j + 1))
                RecursiveHell = RecursiveHell + temp 
                m = m + 1
            Loop
        End If
    End If

End Function

(Might want to resize your browser so that this fits on one line:)
-----------------------------------------------------------------------------------

(Don't know what recursion is? Click here to find out.)

Monday, April 20, 2009

"Paige Fox is bad at math"


Kudos to Bill Amend for drawing (another) strip that takes longer to read than the rest of the funny pages combined.

Wednesday, March 18, 2009

Click here to kill all your brain cells.


Thank you, Verizon. I think we are all officially dumber after listening to that. You are awarded no points and may God have mercy on your soul.

Tuesday, December 30, 2008

Offering of Indulgences: A Game Theory An Operations Research Approach.

Or: what happens when a math major ponders theology.

A few weeks ago, Fr. Robert gave a homily on the topic of indulgences: how to obtain them, the difference between partial and plenary, and offering them for the faithfully departed. And me being me, I began to wonder: what is the optimal way to offer indulgences to maximize grace through one's life?

First, let's define an indulgence. According to the Catechism of the Catholic Church, "an indulgence is a remission before God of the temporal punishment due to sins whose guilt has already been forgiven, which the faithful Christian who is duly disposed gains under certain prescribed conditions through the action of the Church which, as the minister of redemption, dispenses and applies with authority the treasury of the satisfactions of Christ and the saints."

It continues, distinguishing between partial and plenary, "an indulgence is partial or plenary according as it removes either part or all of the temporal punishment due to sin."

Lastly, the Catechism specifies, "the faithful can gain indulgences for themselves or apply them to the dead." (CCC 1471)

This last statement is what I would like to focus on, for the purpose of this discussion.

Why offer them for the dead?

The Catechism addresses the practice of offering an indulgence for the faithfully departed in paragraph 1479: "Since the faithful departed now being purified are also members of the same communion of saints, one way we can help them is to obtain indulgences for them, so that the temporal punishments due for their sins may be remitted."

And again, in 1032, "From the beginning the Church has honored the memory of the dead and offered prayers in suffrage for them, above all the Eucharistic sacrifice, so that, thus purified, they may attain the beatific vision of God. The Church also commends almsgiving, indulgences, and works of penance undertaken on behalf of the dead:

"Let us help and commemorate them. If Job's sons were purified by their father's sacrifice, why would we doubt that our offerings for the dead bring them some consolation? Let us not hesitate to help those who have died and to offer our prayers for them."

Lastly, in paragraph 1475, it is explained how the benefits of the holiness of one member of the church can benefit another: "In the communion of saints, 'a perennial link of charity exists between the faithful who have already reached their heavenly home, those who are expiating their sins in purgatory and those who are still pilgrims on earth. between them there is, too, an abundant exchange of all good things.' In this wonderful exchange, the holiness of one profits others, well beyond the harm that the sin of one could cause others. Thus recourse to the communion of saints lets the contrite sinner be more promptly and efficaciously purified of the punishments for sin."

So the teaching here is that by offering indulgences for the Church Suffering, we can help them to obtain their final glory, and there is the hope that, once they have achieved perfect unity with God, there holiness can then benefit us here on Earth (the reality, not the planet).

During the sermon, Fr. Robert mentioned that, since we cannot know who is in purgatory, he always offers the indulgences he earns for his closest relative that is in purgatory, and lets God sort out who that is. This brought to mind my method of offering indulgences: to offer them for the soul with the longest sentence. The idea here was that if I got a soul who would otherwise have a long temporal punishment out of purgatory, that soul would be more thankful, and thus be more likely to use his spiritual goods for my benefit here on Earth. But then I began to wonder. Is this really the best way to achieve optimal grace and spiritual benefit?

Assumptions (no, not August 15ths).

Let us began by making certain assumptions about indulgences and the Church Triumphant.

Firstly, let us assume that upon helping a soul obtain the beatific vision, that soul will be grateful and offer his share of the Church's Treasury (CCC 1476-1477) for our benefit. This will give us some spiritual benefit, B. Secondly, let us assume that B can vary depending on the length of time, T, of the soul's temporal punishment. That is, a soul who was to remain in purgatory for a very long time, who we help out, will be more grateful to us, and thus offer us a bigger portion of his spiritual goods than a soul who was not to serve for very long. If true, this would mean that B would be greater for helping a soul with a longer sentence. Now let us examine three possible cases for how B can vary between souls with different lengths of their temporal punishment.

1) Logarithmic or no change.

In this first case, a soul who has a long sentence would either not be any more grateful upon being helped out of purgatory by our good works, or his gratefulness would increase logarithmically in relation to his increased sentence. Since we are assuming a direct correlation between sentence length, gratefulness, and spiritual benefit, this would imply that B does not change, or increases logarithmically between souls with differing sentence lengths.

We could express B as:
B = c ln T, for the logarithmic case, or
B = c, for the constant case.

2) Linear.

In this second case, a soul's gratefulness for being helped from purgatory increases linearly with respect to the amount of time he was to spend in purgatory. That is, B increases linearly with respect to the length of time which we, through our indulgence-earning actions here on earth, remit from the soul's time in purgatory.

In this case, we would write
B = cT

3) Geometric or exponential.

In this last case, a soul's gratefulness, and thus our spiritual benefit, increases at a geometric rate or an exponential rate with respect to the amount of time by which we reduce the soul's temporal punishment.

In other words,
B = kTc, i.e., B increases geometrically with respect to the temporal punishment of the soul, or
B = ckT, or B increases exponentially with respect to time.
(For c, k positive.)

So the purpose of this exercise is to determine, for a given assumption about the relation between spiritual benefit and temporal punishment, what is the best strategy to maximize B with respect to indulgences earned during one's life? Essentially, we are balancing getting many less-grateful souls out of purgatory against getting fewer extremely-grateful souls.

Plenary vs. Partial.

A plenary indulgence, according to the Catechism, removes "all of the temporal punishment" due to sin. Basically, a plenary indulgence acts as a "get out of purgatory free" card, that will automatically attain the beatific vision for a given soul. In this context, it is clear that, for all but the most trivial case (that is, where there is no difference in B between souls with short or long sentences), it is most advantageous to offer indulgences to souls who have the longest temporal punishment. For this reason, we will instead focus our study on how best to offer partial indulgences.

Let us assume that a partial indulgence remits a constant, finite amount from a soul's temporal punishment, where the amount remitted is dependent upon the act that earned the indulgence. We will call the amount of remission R.

The Trivial (Selfish) Solution.

The most obvious solution to the indulgence-offering problem is to apply all indulgences for the remission of one's own temporal punishment, according to CCC 1471. However, while applying indulgences to oneself removes one's own current sentence in purgatory, it does nothing to remit the temporal punishment incurred by future sins. Obviously, this is a short term solution, where there is no long-term benefit to the indulgence. This strategy is only recommended if death is feared to be imminent.

We will assume that helping another soul attain heaven produces some long-term benefit. That is, the soul, now in the presence of God, will have an ongoing and lasting influence in our life. Essentially, we are assuming that B is not temporary. As such, offering indulgences for the Church Suffering will have a better long-term ROI, whereas applying them to ourselves is the best solution until we commit our next sin.

Let us further examine the long-term case.

B is Constant.

In this trivial case, the gratitude showed by a soul we have helped does not differ based on the length of the soul's temporal punishment. This may be the case if a soul does not know the period of its time in purgatory. For the trivial case, it is best to maximize the number of souls we have helped from purgatory, since the benefit we receive is the same for each one.

B Increases Logarithmically.

In the case that the spiritual benefit offered by the soul whose temporal punishment we have helped to absolve increases at a logarithmic rate with respect to the length of said punishment, it is clear that applying the indulgence to a soul with a longer sentence suffers from diminishing returns. That is, the benefit received from the soul does not increase at a comparable rate with the time. This is because,

x(c ln T) > c ln (xT), for x, c positive.

In other words, if I receive x partial indulgences, where each one will remit t amount of temporal punishment, I have the option of getting x souls with sentences of length t out of purgatory, or I can get one soul with sentence xt out of purgatory. Since the latter case suffers from diminishing returns, the first case provides the most benefit to me.

In general, B = x/p c ln (p/x t),

where x is the number of indulgences obtained, p is the number of indulgences applied to each given soul, and t is the total amount of temporal punishment remitted by all received indulgences. A simple calculation will show that this is maximized at p = 1.

B Increases Linearly.

In the case that B increases in a linear relation to the amount of time, T, remitted by our indulgences, there is no difference between which souls we apply our indulgences to. This is because,

x (cT) = c (xT)

In other words, the benefit to us is the same, regardless to whether we help one soul, with temporal punishment xT or x souls, with temporal punishment T.

B Increases Geometrically or Exponentially.

In these last two cases, it is more beneficial to apply an indulgence to a soul with a long temporal punishment, as the spiritual benefit we receive will increase at a rate exceeding the temporal punishment we help to remit. This is because,

x (kTc) < k(xT)c

and,

x (ckT) < ckxT

For this strategy, it is best to offer partial indulgences for the soul with the longest time in purgatory, that we can remit during our lives.

Why's that?

It is important to note that even in the last case, it is not most beneficial to offer our indulgences for the soul with the longest temporal punishment. One must consider the possibility that the sum total of all partial indulgences we earn will not equal the sentence length of the soul we offer them for. In this case, as of the time of our death, we will not have elevated the soul to the status of Church Triumphant, and will not have begun to receive our spiritual benefit, B. This is why it is important to make sure we at least get one soul out of purgatory with our indulgences.

A Soul's Access to the Church's Treasury.

Another variable to take into account is the holiness of the souls we are helping. It is conceivable that a holier soul would have greater access to the spiritual goods of the Church's Treasury, and thus elevating a holier soul could have a greater benefit, even with less gratefulness on the part of the soul. In this case, even though soul A, whose temporal punishment, and therefore gratitude, is much greater than that of soul B, soul B may have much greater access to spiritual goods. 

In other words, we wish to maximize,

B' = B · Hs,

where B' is our adjusted spiritual benefit, B is the unadjusted benefit, derived from the gratefulness calculations above, and Hs is the holiness of the soul whose punishment we have remitted. In this case, reasonable assumptions must be made about the likely holiness of the souls.

This approach would seem to favor souls with shorter temporal punishments, as these souls are likely to be holier than those with longer temporal punishments.

NB: I could find no indication in the Catechism that a soul's access to spiritual treasures depends on that soul's holiness during his life. If this is the case, one can safely discount holiness as a factor in application of indulgences.

Spiritual Interest Rates.

One more thing which we ought to consider is the moral decay, or lack of spiritual advancement in our lives brought about by delayed spiritual benefits. Simply put, having more members of the Church Triumphant, even those with a small benefit, praying for us now may, in the long run, provide us with greater benefit than having one soul praying for us in fifty years. This can be thought of as "spiritual interest", and can be likened to banking interest rates. For instance, is it wiser to invest $2000 now, or $5,000 in ten years?

To take this into account, one can simply apply the compound interest formula to the spiritual benefit we've calculated previously. In other words, we want to maximize the total lifetime benefit, BL, where,

BL = H(1 + B/n)nt,

where H is our initial holiness, B is the spiritual benefit that we expect to receive from our strategy, as calculated above, n is the number of souls we expect to elevate to Church Triumphant per year with our current strategy, and t is our lifetime.

Plenary vs. Partial, Part Deux.

One more thought on plenary vs. partial indulgences: in order to maximize spiritual benefit during your life, you should never offer a plenary indulgance for a soul for whom you have already offered a partial indulgence. In such a case, the partial indulgences you've already spent on the soul will in essence be wasted, since they did not serve to remit the soul's punishment any faster. Instead, you might offer a plenary indulgence for the soul for whom your worst enemy has spent the most partial indulgences on, to minimize the spiritual benefit gained by him.

Note that while I could not find any evidence in the Catechism to indicate so, common sense might indicate that such a strategy would cancel out any earned indulgences, as part of the requirement for earning a plenary indulgence is to be "free from any attachment to sin," and such spiteful application of an indulgence would indicate the opposite.

God Knows What's Best.

With all these variables, and special cases, and unknowns, it seems that it is very difficult to find the optimum indulgence-application strategy. However, God always knows what is best for us. It is for this reason that I recommend we fall back on God. When you offer an indulgence, you can simply make a prayer as such, "Father in Heaven; I offer up the graces I receive today to that poor soul in purgatory whose gratefulness will maximize the equation:

BL = H(1 + B'/n)nt,

where BL is the total spiritual benefit achieved in my lifetime, H is my current holiness, n is the number of souls I will help out of purgatory in my lifetime, t is my lifetime, B' = B(T) · Hs is the adjusted holiness of the soul (where applicable), and B(T) is the gratefulness function for a soul, based on the time of his temporal punishment. Amen."

God will know what you mean.

Sunday, December 14, 2008

28 / 1 = 28
28 / 2 = 14
28 / 4 = 7
28 / 7 = 4
28 / 14 = 2

1 + 2 + 4 + 7 + 14 = 28

I'm perfect!

(Thanks Mom!)

Current Earth-Destruction Status This page is Class A WWW Depricated

Lilypie Third Birthday tickers
Lilypie First Birthday tickers
All material on these pages is ©2003-2010 by Joe Belland, Dave Belland, Tom Adams, Cari Burud and/or Paul Harold except for the stuff that we blatantly stole from other sources. All rights reserved.