*Note: This email is a little abstract/philosophical. It’s just an idea I’ve had for a while and wanted to write about. It’s a math-based framework for life. I’d love to get your opinion on it as well. Let me know what you think!*

Lets say Paul is a successful engineer making $120,000 a year doing what he loves. He is in a happy relationship and is generally enjoying life.

How did Paul end up here? Well, his life can be represented by the equation:

*y = f(x)*

Paul took *inputs (x)*, ran them through his personal *function (f)*, and created *behaviors and thoughts (y)* that generally worked in his favor.

Paul has had **billions** of inputs. **Everything** is an input. The itch he *just* felt on his nose is an input. The coffee he had this morning is an input. The fight he witnessed between his parents when he was 14, where his father slapped his mother and she proceeded to grab a knife, is an input. His 3rd-grade teacher politely guiding him through how division worked is an input. His premature birth is an input.

Every moment between his conception in the womb and the present day is an input represented as the variable *x*. Everything. Is. An. Input.

Again, *f* is the function that takes these inputs and creates the output *y*, his behaviors and thoughts. *y, *is effectively **what everyone sees asPaul.** When someone sees Paul, they don’t see Paul’s *function f, *they see the output* y* of Paul’s *function * based on the inputs *x*. They see his behaviors.

In reality, that *function f* is who **you truly are**.

That’s right, you’re a function. You’re an extremely complex function that takes a massive amount of data as input and creates the output that everyone else effectively knows as **you**. No one else shares the same function as you.

Look at you right now. You’re reading this email. Your personal function *f* took input *x* and resulted in the output *y *that said to read this email.

I really want to stress this: the mere fact that you are reading this email is the result of billions of input moments between your conception and the present day.

I’m essentially suggesting that every single thing that you have experienced has some weight on your current behavior. Remember that day when you were a child and you drew in coloring books? Probably not. But guess what. Your *function f* took that coloring book moment and decided how heavily to weigh it when deciding whether or not to read this email.

**But, how does our ****function f ****decide how heavily to weigh these inputs? **Well, it’s quite simple. It depends on what we’re optimizing for.

### A cost function.

In machine learning, there is this thing called a cost function.

This is the function that helps a machine learning algorithm understand how far it was from its goal. For example, given an image of a dog, if the algorithm predicted “cat”, the cost function would come in and say “hey, you were wrong!!”, and penalize the algorithm for doing a bad job. Then, the algorithm would do better next time. Make sense?

Well. We optimize our lives based on the cost function we **choose** for ourselves.

If life can be represented as *y = f(x)*, that means we can essentially create a cost function that will help us **optimize** our *function f* such that our **outputs ***y* are maximized to achieve the goal which we are optimizing for, given some input *x*. Read that again real quick if you didn’t catch it the first time!

Lets formalize the cost function as *C(y). *It takes our output *y* and runs it through a cost function *C* and tells us how well we are optimizing for our goals.

*And this is where it gets so so so interesting.*

Lets say Gabby is homeless on the streets of San Francisco and she is hopelessly addicted to heroin. Well, Gabby’s definition of optimizing life means doing more and more heroin. That’s her goal. Her *function f* will constantly be optimizing for more heroin. Why? Because her cost function *C(y)* said so! Her cost function may look something like this:

*C(y) = (y - constant_heroin)^2*

In this case, *y* is any action Gabby performs or any thought she has.

*constant_heroin* is a constant that represents any thought or behavior-related too heroin. So, if Gabby follows this cost function, she will constantly be penalized for actions or thoughts that are **not** related to heroin.

That means her function *f(x)* will constantly be trying inputs *x* that will try and make her cost function *C(y)* happy! That means when she does do heroin, her *function f* will **amplify** those past inputs in her life that contributed to her doing heroin in the present. For example, perhaps the painful memories of her abusive mother contribute to the dread she feels. This dread leads her to a depressive state which leads to her doing heroin.

What will happen?

Gabby’s *function f* will **amplify** those dreadful memories. Why? Because her cost function told it to! Those terrible memories lead Gabby to do more heroin which made her cost function happy.

This act of “optimization” is called gradient descent in mathematics, feel free to watch a video on it here.

**Finding your cost function.**

This whole email is a long way of me saying that we all need to find our cost function. What is it that you are optimizing for?

There is no such thing as a machine-learning algorithm without a cost function.

In machine learning, if you don’t know what you're optimizing for, the algorithm will go haywire! It will essentially be taking inputs *x* and output some random noise that makes the algorithm even more confused and lead it down an essentially random path.

The cost function you choose for your life is a very complex thing that is unique to you and is constantly changing. For Paul, his cost function may be optimizing his *function f* heavily for long term goals and his day-to-day relationship with his partner. For Gabby, her cost function may only be optimizing her* function f *for short-term pleasures in the form of drugs.

My cost function right now may consist of short-term happiness in the form of learning and exploration, but my cost function also understands that I want to be a massive success one day. So, it optimizes my *function f *accordingly.

We’re all different. What’s your cost function?