What is the cost equation, and how do you find it?

A cost equation can be thought of as a penalty equation.

You can come up with many different examples to penalize a system that you are interested in to get the answer. Simply calculate a bunch of different scenario’s penalties based on the equation you made and find the scenario that has the smallest penalty and you have optimized the system.

Another simple example would be the following:

You want to make your sibling happy with a fruit of baskets. There are a number of pre-packaged fruit baskets. You need to decide which fruit basket your sibling would like best. You can come up with a cost equation or penalty equation.

For example: your sibling likes tangerines the most, bananas 2nd most, pineapples 3rd most and they like apples the least.

You look into the fruit baskets and you decide your cost equation will be like this:

Cost equation = 4*Apples + 3*Pineapples + 2* Bananas + Tangerines.

You calculate the value of the answer for all of the fruit baskets…

Let’s say: basket 1, 2, 3, 4, and 5 have cost values of: 14, 16, 28, 29, and 32.

The fruit basket that would make your sibling the happiest would therefore be the fruit basket that gave a value of 14.

You can come up with any kind of cost equation that would optimize your system following that simple method too. In my opinion, the most common cost equation though is:

Sum(residuals)^2.

For example, to find a linear fit, you can implement the sum(residuals^2) or the sum of the residuals squared. This means you take the (correct answer – the observations)^2 or the (observations – correct answer)^2 and sum as many of the observations that you have. The correct answer for the linear fit would be the value that lies on the candidate line. The best fit would be the candidate line that minimizes the sum of the residuals squared. The reason for this is because the cost equation is calculating the penalty for not having the correct answer. The smallest penalty is the best fit.

This cost equation can be applied to many instances. You can use it to obtain the answer to a system of differential equations. You can use it for many things. There are a number of cost equations out there. The sum of the residuals or (observations – answer)^2 or (answer- observations)^2 is just one example.

Best wishes,

Pharmacoengineering.com