You are invited to Log in or Register a free Frihost Account!

# How is caculus applied to computer science?

inuyasha
I'm a freshman of computer science and technology. Besides the C programming language, we have to study caculus and linear algebra as well. Unfortunately, I find myself interested in programming only and caculus quite hard and dull.
It seems to me computer science contributes a lot to the development of math, while I can't imagine how caculus be applied to computer science. Perhaps students who study maths should learn computer science.
Are we studying maths to find a new way to look at the world? I was told that a few days ago.
Bikerman
Calculus is essential. Any program which needs to model movement requires calculus - that is how you calculate things like velocity. Any time you need to calculate a specific value of a quantity that is continuously varying then you are likely to need calculus.

Computer science has contributed a little to the general subject of maths - particularly in complexity theory - but more often it is maths that provides the computer scientist with the tools he/she needs.

In short, you cannot hope to study computer science in any depth without a solid grounding in maths, and that includes calculus.
Indi
Bikerman is quite right: you can't be a good programmer without calculus.

Let's use games, for example (and i chose games because everyone knows them, and they are surprisingly sophisticated pieces of software engineering).

Your linear algebra will come into play heavily in the graphics engine. All modern games use 3D graphics, and under the hood, all 3D graphics is, is just a collection of points (vertices) that are usually 1x3 matrices (or 3 point vectors). You use transformation matrices and matrix multiplication to turn 3D objects around, and orient them in camera space so you can see them. And that's just the start.

Your calculus will come into play very heavily in the physics engine. Let's say your character throws a grenade down a hall: the grenade bounces off the wall and ricochets around the corner. To calculate the path of that grenade you don't try to figure out an equation that describes the path - which would be difficult to do even if you knew ahead of time what path the grenade would take (like, how many times would it ricochet?). Instead, you do a discrete calculation. You take the position p at time t, and figure out what happens at time Δt... which is one frame after t. And, if you check your fundamental definition of calculus, you will see it looks something like this:
 Code: dp         p(t + Δt) - p(t) -- =  lim  ---------------- dt   Δt->0        Δt

In other words, calculus is the key to programming real-time simulations (along with many other things). If you know where you were in the last frame (which would be p(t)), you can find out where you are in the current frame (which would be p(t + Δt)) by using the equation: p(t + Δt) = (dp/dt) * Δt + p(t). So each frame you can take where you were in the last frame, and the time since the last frame, and figure out where you are in the current frame. That's how games do physics.
bukaida
Yeah, the latest graphics cards and games offer particle physics to bring realistic environment. That is every time you shoot something (in FPS games) or collide with objects (NFS like), you get different result based on angle of strike, speed, distance etc, based on real world physics and mathematics. In India, most of the universities do not allow to study Computer Science unless you have physics and maths at your pre degree level.
inuyasha
Thanks for your replies, Bikerman and Indi~~ Maybe I'm just studying something basic of programming currently. I believe I'll need calculus and linear algebra sometime in the future. My C programming professor told us he was quite regretful that he hadn't learnt maths well.
Calculus seems much more difficult than linear algebra, though both are not easy to learn. Anyway, I'll try my best.