Investments that will Zero up your taxes

Let’s assume your yearly base income is I, out of which you make some investment, which gives you a capital gain, G. Your tax T, in this case would be a function of I and G:

T=f(I+G) ...................(1)

For your investment to make up for all this tax, the capital gain G must be greater than or equal to the tax T.

G \geq T

G \geq f(I+G) ...................(2)

Considering a flat tax rate of x%, equation (2) becomes:

G \geq x(I+G)

G \geq I \frac{x}{1-x} ...................(3)

x-1-xNow, let’s see what kind of investments can actually produce that kind of gain. As you can see from equation (3), it really depends on your base income and the tax you’d end up paying. If you plot a graph of x v/s x/(1-x) as shown on the right, you can see as the tax increases, it would become harder to find an investment that would produce a gain enough to zero up the taxes. Even worst, it becomes exponentially difficult to achieve such a gain.

So how does it look for a person who makes a mere $65K a year and falls under 15% tax bracket? He/she would need to invest such that the gain is at least 65 x 0.15  / 0.85 = $15K. If this person invests in anything that produces a healthy 10% yearly gain, he/she should be investing 15/0.1 = $150K, which is roughly 2.3 times the base income. And how would it look for a person who makes $500K a year and falls under 33% tax bracket? He/she would need to invest such that the gain is 500 x 0.33 / 0.67 = $246.27K. If this person invests in anything that produces a similar 10% yearly gain, he/she should be investing 246.27/0.1 = $2.46M, which is roughly 4.9 times the base income!

This means the more your base income, harder it will be for you to find investments that produce gain enough to Zero up your taxes. The only way you’d be able to do that is to make risky investments in the hope they’d flourish.

Lesson: do your own math; Use your own brain and invest carefully. Because earning more wouldn’t necessarily give you more leverage as far as taxes are concerned :-).

Java Geolocation API

This is my Java implementation of the Geolocation API specifications put together by W3C: https://bitbucket.org/gautamtandon/java-geolocation

The reason I wrote this implementation is because I often had to deal with converting IP addresses to geographic location using some sort of IP to geolocation database feed, and I realized that while there are so many such utilities available, none of them follow a standard approach. This becomes a challenge specially when you want to prototype something quickly so you pick up a cheap/free library just to prove your point, but then later when it comes to developing “the actual product” you can’t really reuse much of your geolocation code because now you are dealing with some “production grade” geolocation service. And of course, your cheap/free geolocation provider doesn’t follow the same API signatures, etc. that your production grade geolocation service provider uses. Even more, both of them don’t follow any common industry standard at all!

My code is available under the MIT License, and I hope one day all geolocation service providers out there will use this code (or its variant) in order to provide a standardized way to perform IP to geolocation.

Please check it out and do not hesitate to get back to me if you have questions, doubts, suggestions, etc. You can simply reply to this post, or find my contact information in the MIT License file.

Will there ever be a “Software Architectural Wonder” in the World?

The Architect's Dream by Thomas Cole (1840)

The Architect’s Dream by Thomas Cole (1840)

Chuo-ku, Osaka, Japan

Chuo-ku, Osaka, Japan

The field of Architecture has played a vital role throughout the history of mankind. It has helped build structures that have lasted for centuries; Some of them are so breathtaking that we call them “the wonders of our World”. It has played a key role in battles throughout the history, and it has even triggered revolutions. In some sense every architectural marvel acts as a tribute to its civilization. It’s a way for a civilization to pass on their message to its future civilizations that anything can be accomplished if you believe in yourself.

Being in touch with the “Software World” for over two decades it never struck me how differently we perceive the word “Architecture” when it comes to “Software”. Could an “Architectural Wonder” really exist in the World of “Software”? Would there ever be “that amazing piece of software” that people say two hundred years from now would look at and go spell bound, and really appreciate what our civilization had accomplished with “so little software knowledge” as compared to them? Would there ever be references made to “great architectural work done in software”, that perhaps would help future generations understand the cultural values of our current society?

Modern Software Programming

Modern Software Programming

Today, software is everywhere, and yet it’s nowhere! From the very basic program burnt into the Flash ROM of a quartz watch to sophisticated software programs that coordinate flight plans, run trains and telephones across the globe, we have woven software everywhere into our lives. But it’s not visible at all. Perhaps it is the most “hidden” form of product ever developed by mankind. So how a “Software Architectural Wonder” would look like? How would we “see” it? And moreover, how would future generations look at it? Is a “software program” really capable of reflecting the true cultural values of a society just like other (non-software) works of art are? And if so, how?

Perhaps one could say that the Internet and the TCP/IP standard is the true testament of mankind’s software architectural capability because it is responsible for the “connected World” as we see it today. Or perhaps the UNIX operating system is the true epitome of mankind’s software architectural achievement because it is in a way the genesis of all modern operating systems – the very basic code that brings “life” into a piece of silicon, metal and plastic we call “computer”. If you think in these lines, then perhaps a “Software Architectural Wonder” would be more comparable to an outstanding work in “poetry” or “painting” rather than a “physical structure”. Question then will be – Are current software programming languages rich enough to produce such an outstanding work? In other words, do the basic building blocks of current programming languages allow us to produce a work of art, so “beautiful” and “meaningful”, that it would truly be respected by future civilizations as a “Software Architectural Wonder”? One could argue, yes we do have those building blocks already. Just like a painting masterpiece, such as a sketch art, can be created with only two contrasting colors – black and white, so can a “Software Architectural Wonder”. Only that in the case of software, the fundamental building blocks would be the binary Zero and One.

I believe the question whether or not there will be a “Software Architecture Wonder” in the World can be better answered by understanding the “philosophy of writing software”. Does our society write software to only solve certain problems? Or they are also written to express a thought? Is it “beautiful”? Is it “meaningful”? Is it worth “cherishing”? Perhaps only when software development would mature to a point where its use goes beyond the basic needs of solving problems, only then our society would be ready to create a true “Software Architectural Wonder”.

If you look at it from a different angle, it took mankind literally hundreds of years to reach to the point where spoken and written languages could be used for a purpose beyond basic communication. Perhaps in the same manner it shall take a few centuries before we can see a true “Software Architectural Wonder”. Until then let’s keep learning and perfecting our software development skills.

This is to all the amazing software engineers out there – Some day one of You will be acknowledged as the creator or a “Software Architectural Wonder”!

jQuery plugin for showing informational popup

I recently created a jQuery plugin for showing informational popup right next to any HTML element. I have made it available on https://bitbucket.org/gautamtandon/jquery.attachinfo. It is free and open source (under MIT license). All the information related to this plugin is available on that link. So I’m not going to duplicate the same information here :-).

If you are using jQuery and need something like this, give it a try! And feel free to send me your feedback!

Here’s how it’ll look like:

jquery-attachinfo

Mathematical proof of why most quarrels generally start because of one single stupid reason

Two days back I had a heated argument with my wife. The good part is, like every other time we quickly patched up things and life was back to normal. Later, we looked back and laughed as to how stupid we were just fighting on a “small thing” that didn’t even matter anymore!

Next day, when I was introspecting myself (like I usually do when I’m stuck in an hour long jam on I-880) and replaying the whole situation in my head, it struck upon me, how did that “one small thing” become such a “big thing” after all? Big enough to shake the entire relationship, even if it were for a moment? And why generally there’s always “that one thing” that unleashes the “beast” in us? When people have quarrels, why don’t they generally say “It all started because he or she did so, and so, and so.”; Or may be “It all started because he said this and this and that to me”? It’s generally always “just one stupid reason”. Why?

I’m sure many people would try to answer this from a psychological point of view. Some would perhaps throw a biological angle to it. And few would choose the path of Mathematics. I thought to go that direction and see if I can come up with some conclusion, mathematically, behind it all. This post is about my quest of understanding a part of the human psychology using Mathematics. Here’s my take:

Assumptions

  1. A quarrel can only begin if there are at least two people involved. This is kind of “obvious”, but since we are under the shelter of Mathematics, let’s call it out loud.
  2. A quarrel is always initiated by one person. While many quarrels may seem as if they started with both the people taking action at the same time, if you take a careful look at it, you’ll notice that it is always initiated by one person. After that it may continue back and forth.
  3. Quarrel can be described as inverse of Understanding. In other words, when someone quarrels with someone, his/her “understanding” about the other person depletes. This again is one of those “obvious” things, but it’s important to call it out here.

Formulation

To make our equations easy to discuss, let’s assume there two individuals, a and b. And let’s assume a started the quarrel. With these assumptions, let’s define Quarrel as Q and understanding of a person a about a person b as U(a, b). So our equation of quarrel between a and b becomes:

Q = U^{-1}(a, b) \dots (1)

Now let’s dig deeper into the function U(a, b) because that seems to be the center theme here. U(a, b) signifies the “understanding” person a has for person b. This can be further broken down into function of traits that that b shows and how much weight a gives to each of those traits. Hence each “weighted trait” T_{i} can be represented as:

T_{i} = w_{a_{i}}t(b_{i}) \dots (2)

Here w_{a_{i}} is the weight person a assigns to the i^{th} trait t(b_{i}) of person b.

Since traits can be positive or negative we can safely assume that the best way to combine traits in order to form the understanding will be by performing a root mean square of all the T_{i}'s. This brings us to our third equation:

U(a, b) = \sqrt{\frac{\sum_{i=1}^{n}T_{i}^2}{n}} \dots (3)

Combining (2) and (3) gives us:

U(a, b) = \sqrt{\frac{\sum_{i=1}^{n}w_{a_{i}}^2t^2(b_{i})}{n}} \dots (4)

In case of a quarrel, understanding U(a, b) becomes Zero. Let’s represent that as \mu\lim_{\mu\rightarrow 0}.  Hence (4) becomes:

\sqrt{\frac{\sum_{i=1}^{n}w_{a_{i}}^2t^2(b_{i})}{n}} = \mu\lim_{\mu\rightarrow 0} \dots (5)

Further simplification of this equation gives us:

\sum_{i=1}^{n}w_{a_{i}}^2t^2(b_{i}) = \mu\lim_{\mu\rightarrow 0} \dots (6)

Since w^2_{a_{i}}t^2(b_{i}) will always be a positive number, the only way equation (6) can resolve is if all the w^2_{a_{i}}t^2(b_{i}) values are significantly small. In all practical terms this is going to be harder to achieve as the value of n increases. This is because the higher the number n becomes, the more traits are being evaluated; And the more traits are evaluated, the harder it is going to be to sum them all up to Zero! Hence, the least possible value of n will give us highest probability of quarrel. That means, for highest probability of quarrel,  n = 1. In other words person a only considers one trait of person b. Hence, we have:

\dpi{150} \large n = 1 \dots (7)

Assuming traits in general don’t vary drastically, however weights may change based on the “heat of the situation”, we can combine equations (6) and (7) and reach to this:

\dpi{150} \large w_{a_1} = \mu \lim _{\mu \rightarrow 0} \dots (8)

In other words, equations (7) and (8) tell us that the possibility of a quarrel becomes extremely high when person a “judges” person b on only one trait that highlights during the argument and applies a very low weight on that trait. While doing so person a completely disregards all other traits of person b that otherwise would have created a healthy understanding U(a, b) between both of them, just enough to not lead to any quarrel.

Conclusion

When you are in a heated debate with someone, while you may get “tempted” to just pick that “one trait” that highlights at that moment, try to look at as many other traits as possible. This will help you “judge” the person in a much more “neutral” way and will possibly avoid quarrels at the first place! It’s common sense! It works! And Mathematics has just proved it!

Are you a bot or a human – php utility

Are you looking for a quick and easy way to detect if a website call to your server came from a human or a bot? Here’s a simple PHP utility that I wrote for just that: https://bitbucket.org/gautamtandon/areyouabot-php

It’s extremely simple; does not require any extra software or changes in your code; and last but not the least, it’s free and open source!

Enjoy!

Lego Mindstorms NXT Touchless Motion Sensing Faucet

This is my first Lego creation using the Mindstorms NXT set. After trying out the usual basic creations such as the ball sorter, car, etc. I wanted to build something that would be equally as much fun, simple, and at the same time useful in day to day activities. So I came up with this idea of converting our normal kitchen faucet into “touchless faucet”. And around two hours later here’s what I was able to do:

Lego Mindstorms NXT Touchless Faucet - closeup

Lego Mindstorms NXT Touchless Faucet – closeup

Lego Mindstorms NXT Touchless Faucet - complete picture

Lego Mindstorms NXT Touchless Faucet – complete picture

I used one motor and a pair of gear assembly to handle the kind of power needed for turning the faucet.

Most of the assembly actually goes into securing the motor and gear system to the faucet as tightly as possible.

 

 

 

The ultrasonic sensor at the top senses if there’s anyone in front of the faucet.

As soon as someone approaches within 20 inches range, the sensor notifies the mindstorms brick, which turns on the faucet. Once the person moves farther than 20 inches, the faucet is turned off.

 

touchless faucet program

 

 

Here is the programming that went behind this.

I start by setting a logic variable called “isOpen” to “false”. This signifies that the faucet is currently closed.

Then, every 2 seconds, I check if there’s someone within 20 inches of proximity using the ultrasonic sensor. If there is someone within the range, and the “isOpen” logic variable is “false”, I run the motor to open the faucet and set the “isOpen” variable to “true”. Otherwise, I run the motor the other way round to close the faucet and set the “isOpen” variable to “false”. Simple! :-)