# Fixed, Variable, and Marginal Cost.

We here at the Khan
Academy are working on some type of a
software project. And we need to
think about what’s the optimal number of
programmers we should hire, at least think about
how much productivity we’re getting per
programmer when we’re working on this
software project. And so what I’ve done over
here– this is a spreadsheet so I’m not going to
be able to write. I’ll only be able to type. This is Microsoft
Excel right over here. In this column, I have
the different numbers of programmers. And then let’s say based on
other studies or industry studies or our past
experience, this tells us how many lines of programming
code we can get per month. And obviously, lines
of code isn’t maybe the best way to measure
things because someone can write good lines
or bad lines of code. But let’s just say this is one
way of measuring productivity for software engineers. So the first thing I’m
going to think about is what are my fixed costs? So what am I going
to spend no matter how many software engineers
I hire for this project? And for the sake of this
video, my fixed costs will be the office space
and the electricity and let’s assume I just have
an office that can accommodate any number of these programmers. So that’s a fixed cost. That’s not going
to change depending on the number of
programmers I have. And then the other
fixed cost, let’s say I have a product manager
for this project. And I’m going to pay her
salary to essentially help spec out what this
software should actually do. So her salary is, let’s
say, \$10,000 a month and then another \$5,000 a month
in office space for everybody. So it’s going to come
out to \$15,000 a month. And that’s not going to
change regardless of however many programmers I have. So I’m going to go into Excel
and go to this little bottom right right over here. And I’m going to drag that down. And so it’s going to be
\$15,000 in fixed costs no matter how many
programmers I end up hiring. Now the variable cost. Well, let’s just say that
the full compensation for a programmer
is \$10,000 a month. So if you include the
cost of their salary, if you include the cost
of their health insurance, you include the extra
goodies that they will eat from the company
kitchen, whatever it might be. So it’s going to
be \$10,000 a month. So my variable my
total variable costs are going to be \$10,000 times
the number of programmers. So here I’m going to write
equals, and I’m going to write, it’s going to be \$10,000
per programmer times– that little snowflake,
I pressed Shift + 8 to get that snowflake–
times, and I could say times whatever
is in that cell. So you see it’s cell D7. And actually let
me scroll this over so that you can see the cells. So that is cell D7. And let me press Enter. So it’s \$10,000 times D7, which
is this one right over here. And I just selected that. And I can press Enter. And right now, that’s nothing. Let me scroll over so we can see
everything a little bit better. Let me scroll over a little bit. There you go. I’m having trouble. OK. There you go. Now, what are going
to be my total costs? My total costs are my fixed
costs plus my variable costs. So that’s going to be equal
to– and I’m just using my arrow keys right now– it’s going
to be equal to F7, right? That’s cell F7 plus this
one, plus my variable costs. My total costs are my fixed
costs plus my variable costs. And so it’s \$15,000. And actually, I can make this
true for every row over here. And this is one of the
defined this cell as being \$10,000 times whatever this
cell is right over here. And so what I can just do
is I can just take that, drag that all the way down. And for every one
of these, it’s going to take \$10,000
times the cell that’s essentially three to its left. So now it’s going to
be 10,000 times D8. This will be 10,000 times D9. Let’s get that. So that we can see
it right there. 10,000 times D9. And you could, if
you click on there, you can actually see
what the formula is. 10,000 times D9. So by dragging that, I was
able to get the right formula all the way down. Now the total cost
for every row here is going to be two to the
left plus one to the left. And so if I drag
that down, it’ll do that for every row over here. So now this is 25, is
the 15 plus the 10. 105 is 15 plus 90,000. Our total costs are fixed
costs plus variable costs. Now let’s think about
the average fixed cost. And the average
fixed cost, we’re going to think about it in fixed
cost per line of code produced. And over here, line
of code produced is 0. So we’re going to divide
by 0, which is undefined. So we could leave that blank. But we could fill this one in. So our total fixed
costs– this is going to be our total fixed
costs, which is cell F8. I just used the arrow
keys to select F8. Divided by our total
lines of code per month. So divided by our total
lines of code per month. And so that gets me \$3.75
fixed costs per line of code. And then I can do the same thing
that I’ve been doing before. I can drag this down. And then we see what
the fixed cost is. So if at any given point if I
take the fixed cost, \$15,000, divided by the lines
of code, I get \$1.38. And this actually makes sense
because the more programmers I add on to this project, the
more lines of code I get, I’m using the same
fixed costs I’m. Using the same project manager. I’m using the same office space. So the cost of that project
manager and that office space gets spread out along
more and more code. So the fixed cost
per line of code goes down as we add more
and more programmers. Now what is the average
of variable cost? So once again, the
variable cost is going to be whatever
the variable cost is per lines of code per month. So when we’re talking
cost per line of code. So this is per line of code. Let me write it over here. Per line of code. And I can even say per month. Per line of code per month. Actually, I wanted
that spread out more. But the way I’ve set it up. So let me scroll down. Oops. I’m having issues here. All right. Well these are all average
lines of code per month. And so let’s think
about what happens with our variable costs. So I’m also going to
start here because I don’t want to divide by 0. So in this month, our total
variable costs were \$10,000 and our total lines of code
are going to be \$4,000. G8 divided by E8. And so average variable cost
per line of code is 2.50 . And then what happens? So let’s do that for
every row over here. So when we do it for every row,
something interesting happens. Our average fixed cost
went down because we’re taking the same cost and
we’re spreading it out amongst more code. But our average
variable cost went up. As we added more programmers,
per line of code, it actually costs
us a little bit more on average per line of code. And that’s actually,
if you look here, as we add the incremental lines
of code we get per programmer is actually going down. That first programmer
by themselves, she can write 4,000
lines of code. But then that second programmer
you’re not getting to 8,000, you’re getting to 3,000. And probably because they have
to coordinate with each other. They have to plan
a little bit more. It’s not all in
one person’s head. Then, when you’re
at the third one, you’re not even adding
3,000 lines of code. You’re only adding
2,000 lines of code. And this is actually
a real phenomenon that actually
happens in companies. The more people you
add on to a project, obviously they can
maybe do more work, but there’s also
more coordination. There’s going to
be more meetings. There’s going to be
more interruptions. And so each person’s
individual productivity is going to go down. And this isn’t to say that
this third coder is somehow worse than the first coder. On average, all of
them are now only going to produce 3,000 lines of code
a month, when maybe individually they could have each
produced 4,000 lines of code, but they have to spend
some of their energies now coordinating it. And so that’s why our average
variable cost per line of code is going up. As we add more and more
people, incrementally it’s becoming more and more
expensive on average to write that line of code. And now if we look at
average total cost, that’s going to be– and
this is once again, this is per line
of code– is going to be our total cost, H8 divided
by the total lines of code per month. So if we just hire
one engineer, we’re going to have \$6.25
spent per line of code. And this is actually
just the sum of these two right over here. And then, let me set that
formula for every row. And so we see
something interesting. When we start to
hire a few engineers, we’re able to spread out
our fixed costs, even though our average variable cost
per line of code are going up, our fixed costs are going down. So it’s actually we’re getting
a little bit of a benefit because we’re spreading our
fixed cost per line of code. But then it starts to
get expensive again because, as we said,
the more people you have working on the
project, they’re going to have spend more time
coordinating with each other and maybe even undoing
each other’s work or redoing each other’s work
as opposed to just writing the actual software. And now let’s think
about the marginal cost. The marginal cost, the
best way to think about it is, what is the incremental
cost of that next set of line of code? So one way to think
about it– so this is going to be how much
more you’re spending divided by how much more
code you’re getting. So for example, how much
more– and this is going to be, once again, per line of code. So when we go from zero
programmers to one programmer, we’re going from
\$15,000 of total cost to \$25,000 of total cost. We do it in parentheses. If we’re going
from 15 to 25, that means we’re increasing our
expenditure by 25 minus 15. And so that’s why I’m
doing H8 minus H7. So that’s how much more we’re
spending in expenditures. And then, how much more
code are we getting? Well we’re getting 4,000
minus 0 lines of code. And the reason why I’m
doing the formula this way is so that when we drag
it down on all the rows, the formula will be
right because it’s relatively taking the
right cells into account. And the reason why I’m
saying it’s average is because this
is saying, what’s the incremental cost per line of
code for this first 4,000 lines of code? And then we can go from there. And we can drag it down. And now this tells us
the incremental cost per code for the next
3,000 lines of code. And once again, it
got a little bit more expensive because we’re
getting a little bit less efficient as we add
more and more people. And there’s something very
interesting that happens here. And you might have even noticed
it in these numbers over here. We actually get a
negative marginal cost. And this isn’t meaning that
when we add more lines of code somehow we’re getting money. It’s actually saying that
as we spend more money, we’re actually
killing lines of code. Because at some point, if
you have too many people on this one project
team, they actually start killing each
other’s productivity. And you can even see it
right here in the numbers. When we had seven
people, we were able to write 11,400
lines of code. But then the eighth person,
because of coordination– it’s not that this eighth
person is incompetent, it’s just when you have
eight people on a team, everyone’s productivity
goes down so that you’re only able to
produce 11,200 lines of code. And that’s why you had this
negative marginal cost. Now, when you get to eight
people, all of a sudden by spending more
dollars, you’re actually destroying some of what you
were actually trying to produce. So what I wanted
to do here is just to really get you
behind the numbers and really maybe give
you a little sense of how you can actually do
this with a spreadsheet. And get you thinking a little
bit about how a firm’s cost structure might actually work.

## 54 thoughts to “Fixed, Variable, and Marginal Cost.”

1. kevkallon says:

what, i didint know you thought business lessons

2. shinenot says:

Wow, amazing video. Can you do some business videos, since you have MBA?

3. jesusneverexisted300 says:

Great video!!!

4. Saber Ahmed says:

5. ishfaque10 says:

@PSPhacking2009 Yes Bangladeshi Father and Indian Mother

7. Emeengor says:

sorry i hate to sound like a smarta55 but is this really considered to be a science? and do people really need to get tought these obvious things?

8. Chris Sio says:

@Emeengor Yes, people unfortunately need to be taught obvious things such as how to spell.

9. FirenDeath says:

10. James Gillis says:

@Emeengor its obvious if someone hits another person with their car that the driver will be liable but it's still covered when you go to law school… As this, it also needs to be covered.

@Emeengor I sometimes wonder how is that not easy to do, but I think it gets much harder when you get to the higher levels

12. shinenot says:

@FrankiePoker thanks. I'm watching that playlist now, and it's very good.

13. spirituelconnexion says:

My only observation is that the second,and maybe and third, added worker should have made the total product greater than what two workers can produce by themselves, to show the synergy effect, which is more realistic. Then the total product can go down as we add more workers to come back to the scenario you're following.
What I am saying is there is a little step in the scenario that's skipped, probably for the sake of simplicity. Other than that, excellent video, helped me a lot !

14. Emeengor says:

1st its was a typo… 2nd I am not a native english speaker nor do I live in an english speaking country….

15. jackuy12345 says:

cool story bro, nobody cares

16. SVIKC says:

It was awesome! Really helpful specially for people like me, who are from Sc. background!

17. Naim Xibalba says:

what is "lines of code per month" ? is it an input or output ?

18. Naim Xibalba says:

or is it Total Product ?

19. Nick Saylor says:

I think it's an output since it's the programmers' combined productivity.

20. Jonnemanne says:

Would it be possible for KhanAcademy to make a video series on using Excel? ðŸ™‚ Thanks!

Does productivity come into play and how

22. Sunny Love says:

Lines of code is quantity

23. Chwa982 says:

Thank you! You're really good at explaining things! I came to learn Econ but I also learned some Excel tips too.

24. Pegasi says:

Looks like hiring 3 people or hiring 7 people are the most efficient options for low-budget/output and high-budget/output respectively.

25. kbchsm says:

26. Nicky Khilnani says:

THANK YOU SO SO MUCH FOR THIS!

27. walaa omeran says:

thanx

28. T. D. Pearce says:

Would adding that 8th person create what is called a dis-economy of scale? Â (I'm learning and considering taking undergrad econ. Currently have a French degree that sincerely enriches my impoverished life.)

29. aaa says:

Beautiful! Thanks so much.

30. Harun Tareb says:

Too fast,,,,,

31. Julie Lai says:

Not only did I learn aboutÂ Fixed, Variable, and Marginal Costs
Â but also learned how to use Excel lol

32. No Bro says:

THANK YOU!!

33. Shazer says:

so what if variable cost is missing and all the data is given? what's the formula for that?

34. Nick Zelner says:

are you making the fc and the vc up?

35. Nick Zelner says:

where'd the fixed cost come from

36. Nick Zelner says:

why 15000

37. Snake says:

why would lines of code go down with more programmers :X

38. nana Plaatjie says:

if im only given units(output) column. and total cost column, all other columns are empty. and they say calculate marginal cost, average fixed cost average variables and average total cost. eg. output is 4. total cost is 220

39. Kgomotso Aphane says:

wow wow I literally enjoyed this one…Thanks.

40. I K says:

great video!!!

41. Tony Jimenez says:

awesome video very easy to understand

42. KING X-RIDER says:

still don't understand about Variable Cost ! " Well, Let's just say that the full compensation for a programmer is \$10,000 a month." Why \$10.000 a month ??? saying for fun ? lol please explain this ! pleaseeeeeeeeee

43. Quick March! says:

This is actually funny that I learned it pretty much the same way at school. This is normal since economics is a science I guess :p

44. wreck'em tech says:

How can I calculate fixed cost and variable cost if I only have quantity and total cost!!??

45. Scott Wilson says:

"i'm having issues here" – quote of the year

46. Nia E. says:

Thanks Khan

47. Autumn Munden says:

All I could think about was how he sounded like Brendan Fraser haha

48. TFrills says:

Awesome, but waht about physical product? Average product, average total product, total product, marginal product?

49. Lucas Scott says:

lol "varilbe"

50. Golekane Komane says:

How can i calculate the Variables Costs and Marginal income

51. Spongey says:

wow i like that little snowflake

52. Alfanda Canga says:

Very useful, thank you.

53. Jessie Fu says:

??i thought quantity should be the number of programmers instead of lines of code