More Philosophical, but not Mathematical, Inquiry

So I was reading Harry Browne’s argument against “The Unselfishness Trap”, which might I propose is ludicrous. He argues that everybody’s happiness is greater if one disposes of the injunction to sacrifice oneself for others. It’s easy to refute this by acknowledging that happiness is not a conserved quantity; one’s kind act for another can have positive consequences disproportionately greater than the sacrifice the act entailed. I would go on and propose a mathematical formula for this phenomenon but the restrictions in this post are already set.

Why I mention Browne is because he makes a fundamental logical error. He asserts that because we more or less acts selfishly when we are free, we as a species ought to remain free and discard notions that we ought to help others (and instead only do so when we ourselves benefit as a result). Well first of all acting selfishly is a tendency not an axiom. If we are truly free we have all option to do the opposite – act against ourselves and for the benefit of others. In fact one could argue that being free in his context means the exact opposite. If we are free such that maximize our own happiness as he says then aren’t we actually bound by our own selfishness? Anyway, I digress [again; I’m pretty passionate about refuting his ideology]. The logical error is in the following. Let’s say his axiom is correct, and that we as humans act for ourselves unless compelled to do otherwise by “the unselfishness trap”. He claims that, partly because of that, we ought to truly free ourselves and act selfishly.

But ought we? Couldn’t one argue that “the unselfishness trap” should exist regardless?

Before we go on, let me make some clarifications. What ought to be true is not the same as what is most likely to be true. It is the same as what should ideally be true. What can be true is what the truth potentially results in.

Here’s the upshot. What is true cannot be logically followed by what ought to be true. What is true, however, can be logically followed by what can be true.  The former fallacy has justified Social Darwinism, among others which I’m too lazy to recall right now. Like, I’ve never taken a logic class but I’m almost certain that people commit this fallacy often. Example: natural selection exists in nature so it follows that it should also exist among humans. Or, sex is natural/sex is needed for reproduction/lust is intrinsic in our biology so it follows that sex and lust should be uncensored and unrestricted. Or, a lower impoverished class has always existed since the dawn of labor specialization so it follows that we should leave the poor alone. Or, quoting from Nietzsche:

God is introduced everywhere, and utility is withdrawn; the natural origin in morality is denied everywhere …. What do I protest against? That people should regard this paltry and peaceful mediocrity, this spiritual equilibrium which knows nothing of the fine impulses of the great accumulations of strength, as something high, or possibly as the standard of all things.

In essence, what Nietzsche claims is that because strength exist as fundamentals in human nature, Christianity and its fundamentals (servitude, sacrifice, loving enemies, etc.) should be discarded.

As an aside, Mark Twain specifically warns against this type of thinking in Huck Finn, that one should sometimes discard the acts of the majority if they go against what obviously is not correct. Well a history is a type of majority truth. What ought to be true does not follow from it, and can be markedly different from it. This is the notion of the ideal.

What ought to be true can only be logically followed from 1) what can be true, and 2) what we will to be true if given the opportunity. Number 2 sounds like a restatement but it really isn’t. It really means “if we had a magic pill that would make the world as we like it, what we would do to the world.” Number 1 really means “this, this, and this might result from some truth. That does that, that, and that to the world.” Number 1 sounds consequentialist because it is. Number 2 is psuedo-Kantian, based on rational principles and duties. I won’t expound on this because I’m tired and too lazy to do so. Number 1 implies that a truth can lead to an ideal if a logical consequent intermediate between them exists. Integrated, we can say that an ideal follows from a truth if and only if the truth leads to a consequence which in principle is rationally optimal.

So what am I saying? Out of all moral theories and justifications for what is moral, i.e. what ought to be true, consequentialism and Kantian deontology are the only ones that make logical sense. More importantly, morality based on what has historically happened, or what happens in nature, or human nature itself, is not only dangerous, but logically incorrect.

And sadly, I am reminded that this is a logically fallacy I have committed, and often.

Reminder for future posts: Nietzsche, jack-of-all-trades, stoplights

Philosophical Inquiry

Note to all: this will be the most nerdy post I’ve ever written, so stand back and don’t read if you’re allergic to philosophy, mathematics, or both. Oh, and I finally found a LaTeX typer, so this post will be much more mathematically professional!

Utilitarianism, and all moral philosophy with the meta-ethic of consequentialism, is mathematical in nature. In general, consequentialists believe that the moral correctness of a thing is proportional to the effects that thing. Utilitarian philosophy emphasizes the effects of actions on people’s happiness or pleasure. So with that in mind let’s actually derive an equation that approximates Utilitarian thinking.

Let  be an operator that represents an action. It will map one level of happiness to another level of happiness. Mathematically speaking,

Where H(p,t) is the net happiness of a particular person p at a specific time t.

But now the question beckons, what is net happiness? It will be denoted as follows:

The raw happiness h is subtracted by the raw misery m at any time t, of any person p. It is important to make this distinction between raw and net happiness because, in accordance with the laws of life, the misery level of any person at any time is never zero. One can be happy but miserable, in pain, and not content at the same time; in such a state the net happiness would be in fact less than raw happiness. One can argue that the net happiness at any time is less than the raw happiness, due to unconscious pains that exist within each one of us. But I digress. More importantly, I claim that while net happiness can be negative (indicating some emotion that’s quite opposite from happiness), raw happiness and raw misery must be nonnegative – they are scalar measurements of raw emotion. (Also, an aside –  death means that H = 0, as no emotion can be felt after passing away.)

Jeremy Bentham attempted to formulate the misery and happiness functions when he was creating the theory. He argued in The Principles of Morals and Legislation that happiness (and, I will extend, for misery as well) is a linear combination of several components – intensity, duration, certainty, propinquity (“nearness”/closeness in space and time), fecundity (the ability for the emotion in one instance influence the emotion in a later one), purity (pure happiness or one diluted by misery?), and extent (how far reaching the emotion extends).

So this becomes a very difficult problem. First off what emotion is he referring to – raw or net? I will argue neither. The “raw” equations I have defined are valid at specific times with specific discrete persons, which do not factor in anything but intensity. Net emotion encompasses purity and certainty. But duration, propinquity, extent, and fecundity are still excluded. For the first three, we cannot look at the function at any one time; we must do more and take it through all times. In other words, we must take a summation, and from this I shall define total net happiness of a person:

where t0 is the time right now. This covers most things related to time, all the way to infinity (humans don’t live forever and they aren’t born “now”, but the reason for putting these limits will become evident later). It’s not a perfect model, but it will do for now.

Now, as for fecundity, that has everything to do with the change of net happiness. In other words, how does the net happiness H at this one instance change the net happiness H + dH? If fecundity is high then the change in net happiness will be great. At this time you’re probably thinking in terms of ∂H/∂t, and you’d be right. The key is to maximize that partial derivative. However, before you start freaking out about the explosion of terms, the integral in the total happiness function takes that into account – a function that, on average, decreases less/increases more than another function will have a larger area under the curve given same initial condition.

Believe it or not we’re almost done now! Let’s go back to the tenet of Utilitarianism: how does an action produce the greatest happiness for the most people? Well we have a formula for the happiness for one person, so lets start with an action’s effects for that one person. For an action to create the most happiness, it must optimally increase the existing happiness. We maximize the change in total happiness due to an action. Referring to old definitions and substituting:

See why now the limits make sense? An action at a current time will have an effect through the rest of time. Time before t0 is irrelevant.

Finally now we acknowledge that our actions have effects on more than one person. Since people are discreet beings (we don’t have infinitesimal fractions of human beings) we will take a discreet summation rather than an integral for this final part. The result will be defined as U(Â), the Utilitarian moral worth of an action:

where p0 to pn are all persons affected by the action.



This post is getting long so I’ll put this as a type of addendum. The major criticisms of Utilitarianism are of a) minority rights, and b) difficulty in predicting consequences. These are valid criticisms. Mathematically, a) is the neglecting of negative consequences for any one person because of overwhelmingly positive consequences for most others leading to a positive value for U. In other words the final summation through all persons drowns out the possible plights in minority persons. B) is the fact that the Utilitarian function is quite difficult to calculate using known integration techniques. 😉 A quick mental estimation could lead to faulty results.

A few little things

1) You know you were born to be a chemist if you look at a bowl of vegetables that leaves a deep red-violet residue, and immediately think… DAMN THAT’S A LOT OF CAROTENE. The conjugated systems of carotenoid and related compounds in [some] vegetables make them more colorful. From Wikipedia:

Conjugated systems of fewer than eight conjugated double bonds absorb only in the ultraviolet region and are colorless to the human eye. With every double bond added, the system absorbs photons of longer wavelength (and lower energy), and the compound ranges from yellow to red in color.

That’s always been pretty cool to me, and it’s kinda nice knowing how amazing chemistry can be.

2) I’ve always been *aware* of the Chinese Civil War, the rise of Mao, and all of what happened in Communist China afterwards, but up until senior year of HS, I never really *knew* the history behind it. I was well accustomed to hearing “Mao Zedong” in the forefront but this other figure Chiang Kai-Shek was mysterious, having never been uttered by my politically-passionate grandfather.

Well over the course of listening to a few conversations I finally recognized the name. They called him Jiang Jieshi (which only a few textbooks call him; most refer to him as Chiang). My first instinct: how the heck did Americans get Chiang Kai-Shek from Jiang Jieshi? This remained a mystery to me until I siphoned the all-knowing Wikipedia:

(Jieshi is the pinyin romanization of the name, based on Mandarin, but the common romanized rendering is Kai-shek which is in Cantonese romanization. As the republicans were based in Guangzhou (a Cantonese speaking area), Chiang became known by Westerners under the Cantonese romanization of his courtesy name, while the family name as known in English seems to be the Mandarin pronunciation of his Chinese family name, transliterated in Wade-Giles). In mainland China, Jiang Jieshi is the name under which he is commonly known today.

Aha! Problem solved.

So why did I make this post? I love epiphanies.

Next posts: Nietzsche, being a jack-of-all-trades

July 4th Photography

It was revolutionary in many ways:

1) I figured out another quirk of ACR… the awesome vibrance slider which adjusts saturation of desaturated colors, but leaves saturated colors alone (I’ve always used saturation in the past).

2) It was the first time I had gone on a photography trip with friends… before it was always me photographing and other person(s) feeling awkward.

With that said…


Shot most of my pics f/16 at 1/4-1/6 sec. In retrospect, I could’ve opened up the aperture a little more and used a slightly slower shutter speed. The waterfall was quite violent and some of my highlights lost detail.

Composition proved to be problematic, as usual. The PQ Waterfall area has many rocks, each of which can be either complement the waterfall or distract from it. In December, I took this zoomed-out shot, which turned out fine because the rocks complemented the waterfall. Now it’s July, well past the rainy season, and the total volume of water is less, which exposed some rocks closer to the waterfall. So on this trip I moved in, to that rock in front of the waterfall you see in the picture I linked. I focused in dynamic nature of the surging water, which turned out well. I still wish I could’ve taken a zoomed-out shot farther away, just to compare how much the falls have changed.


Fireworks was a whole ‘nother shenanigan. Between not knowing where they were to be set off, failure on my part to put the camera on the tripod, and last-minute switches in position, I almost didn’t get them. Really the Del Norte fireworks paled in comparison to the WV ones, but that’s because they prob just started doing them this year. By far the hardest I’ve had to work for decent photos. They released the fireworks behind the stands, and there was some fencing that was adjacent to it. All in all a terrible setup. But, things would turn out for the better…

From the WV fireworks on Friday I learned to zoom in and try to get something in the foreground (not easy with these school fireworks). Both these were forced onto me due to the setup. The “something in the foreground” was people in the stands. The zooming in was to avoid getting the fence in my photos. So I was lucky.

Regrets –

f/16 aperture. I thought I could hold my shutter long enough to get more fireworks in one exposure, but alas the force of habit resulted in underexposure of many of my shots.

Tripod. Fail.

Door-thingy on the sides of the stands. Distraction that hurt my shots a lot.

Recursion Disaster

Think you can’t get a StackOverflowError unless you have an recursive method that fails and undergoes infinite recursion?

Think again.

Try a working recursive method that is called iteratively.

The setup: I am trying to draw M implicitly defined curves by connecting N determined points on each curve. Many algorithms exist for determining points on an implicit function, but I’m using the  Bisection Method, slow but robust and easy to code. The runtime for drawing these curves is O(M*N*log(1/Ɛ)), where Ɛ is the error bound.

Here’s the iterative code for drawing a single curve (which in my case is known as a moist adiabat). I will do this M times (that code will not be shown here for brevity):

public Path2D getMoistAdiabat(double Teq, double fromP, double toP) {
pressureRangeCheck(fromP, toP);
double hiP = fromP;
double t0 = GeneralCalc.tempFromMoistAdiabat(Teq + 273.15, hiP) - 273.15;
double[] bottomPt = tempToCoord(t0, hiP);
Path2D isentrope = new GeneralPath();
isentrope.moveTo(bottomPt[0], bottomPt[1]);

int h = 25; //decrement interval
for (double p = hiP - h; p >= toP; p -= h) {
t0 = GeneralCalc.tempFromMoistAdiabat(Teq + 273.15, p) - 273.15;
double[] pt = tempToCoord(t0, p);
isentrope.lineTo(pt[0], pt[1]);
return isentrope;

public void graphMoistAdiabat(double Teq) {
graphMoistAdiabat(Teq, highestPres(), 200);

public void graphMoistAdiabat(double Teq, double fromP, double toP) {
graphics.draw(getMoistAdiabat(Teq, fromP, toP));

And here’s the key function tempFromMoistAdiabat(), which uses the Bisection Method to determine a point on a curve, “T”, from the variables “thE” and “pres”. I originally designed it to be recursive, as shown below:

public static double tempFromMoistAdiabat(double thetaW, double pres) {
//all variables already defined, this code actually in helper method called moistAdiab()
//but I deleted the method
double Tguess_mid = avg(Tguess1, Tguess2);
double thE_mid = psuEqPotentialTemp(Tguess_mid, pres);
if (MathUtils.equalsApprox(thE_target, thE_mid)) {
return Tguess_mid;
} else if (thE_target > thE_mid && thE_target < thE2) { return moistAdiab(thE_target, Tguess_mid, thE_mid, Tguess2, thE2, pres); } else if (thE_target > thE1) {
return moistAdiab(thE_target, Tguess1, thE1, Tguess_mid, thE_mid, pres);
} else if (thE_target > thE2) {
double newT = Tguess2 * 2;
double newThE = psuEqPotentialTemp(newT, pres);
return moistAdiab(thE_target, Tguess2, thE2, newT, newThE, pres);
} else if (thE_target < thE1) {
double newT = Tguess1 - Tguess1;
double newThE = psuEqPotentialTemp(newT, pres);
return moistAdiab(thE_target, newT, newThE, Tguess1, thE1, pres);
throw new ArithmeticException();

It would throw the error after about 3 curves. So after many trials and errors, I decided [intelligently] to rewrite this iteratively:

public static double tempFromMoistAdiabat(double thetaW, double pres) {
double thE_target = thetaE_thetaW(thetaW);
double Tlow = -150 + 273.15;
double thELow = psuEqPotentialTemp(Tlow, pres);
double Thigh = 150 + 273;
double thEHigh = psuEqPotentialTemp(Thigh, pres);
double Tmid = avg(Tlow, Thigh);
double thEMid = psuEqPotentialTemp(Tmid, pres);
while (!MathUtils.equalsApprox(thE_target, thEMid)) {
if (thE_target - thEMid < 0) { Thigh = Tmid; thEHigh = thEMid; } else if (thE_target - thEMid > 0) {
Tlow = Tmid;
thELow = thEMid;
Tmid = avg(Tlow, Thigh);
thEMid = psuEqPotentialTemp(Tmid, pres);
return Tmid;

And voila! Worked perfectly.

Moral of the story? Think and write iteratively especially when a method will be invoked M*N times. That way you won’t spend 30+ min debugging a working method.

Epiphany: Informal Half-Proof of the Integral Test of Convergence

Had this epiphany while I was thinking about the end behavior of the oh-so-special logarithm. The natural logarithm diverges, but at a very slow rate; proof of this can be found in its derivative, 1/x, whose discrete series, the harmonic series, diverges.

Well, so all of this lends to thinking about the integral test. It states the following (copied from Wikipedia):

Consider an integer N and a non-negative monotone decreasing function f defined on the unbounded interval [N, ∞). Then the series

\sum_{n=N}^\infty f(n)

converges if and only if the integral

\int_N^\infty f(x)\,dx

is finite. In particular, if the integral diverges, then the series diverges as well.

Damnit, I wish I had math typing software here. Anyway, let’s start with some definitions:

Let f(x) be an arbitrary function defined, continuous, nonnegative, and decreasing for all x > 0, and let F(x) be defined and continuous on the same interval. If f(x) were increasing the divergence would be clear; if the range was extended to all real numbers then…. iono… the universe would implode.

Let dy/dx = y’ ≡ f(x), and the (antiderivative/indefinite integral of y’) = y ≡ F(x);

Let S(f, a, b, x) ≡ the definite integral of f with respect to x, evaluated from a to b. [since S looks like an integral sign]

Let lim(f, x, c) ≡ the limit of f as x approaches c.

From the fundamental theorem of calculus we know the following:

S(f(x), a, b, x) = F(b) – F(a).

And if the upper limit is to be infinite, that is, an improper integral is involved:

S(f(x), a, ∞, x) = lim(F(b), b, ∞) – F(a).

Intuitively, if the above improper integral were to diverge, then:

lim(F(b), b, ∞) = ∞.

[F(a) could not be infinite due to the restrictions in the definitions; thus F(b) has to be infinite.] Again, intuitively, if this is the case then

lim(F'(b), b, ∞) = lim(f(b), b, ∞) ≠ 0.

Because to be diverging, the function has to be “moving” (i.e. slope not nearing 0) as b -> ∞ (if the slope was closing in on 0, the function would be staying constant, converging to a real number).

From the divergence test we know that a discrete sequence f*(n) corresponding to its infinite series and to f(x) must diverge if and only if lim(f*(n), n, ∞) ≠ 0. This can be extended to the corresponding function; if lim(f*(n), n, ∞) ≠ 0, then clearly also lim(f(x), x, ∞) ≠ 0 (and vice versa). And this result is of course what we have above from our calculus analysis. So it follows that if the improper integral diverges, so does the infinite series.

This is only a half-proof because the inverse of the divergence test does not follow (e.g. harmonic series, which is what made me start thinking of this in the first place). Maybe I’ll have another epiphany someday.