Question:
EXAMPLES OF MATH IN COMPUTER SCIENCE AND/OR PROGRAMMING?
anonymous
2013-10-01 14:25:12 UTC
I am considering a major in computer science and would like to know what i am getting myself into. What mathematics would i need to get up to, to be a proficient computer scientist? Also can you please give me some examples of math used in computer science type problems and/or prgrams. I am just starting out my first computer science class and we are learning html/css and soon javascript. What math is involved in those?

Thank you
Three answers:
Mr. Smartypants
2013-10-01 14:35:28 UTC
I got into computers as a hobby in the late 70s. I taught myself to program (from books) and within a few years I was working as a programmer (you could do that in the 80s!). In the early 80s I looked into what it would take to go back to college and get a BS in Computer Science. I was shocked to find that the math required for a computer science degree was more than was required for a math degree!



Programming is not necessarily math-intensive (though I occasionally did need to get help with some of the math). But computer science as a whole is EXTREMELY math-intensive. starting with boolean algebra (not like you learned in high school!) and going up through calculus and beyond! The curriculum for a BSCS at my college required a 'calculus sequence' of classes. I supposed that meant a sequence of math classes culminating with calculus. But nooooo! It BEGINS with calculus!
texasmaverick
2013-10-01 22:31:31 UTC
The first responder gave an excellent answer.



I would add, very little calculus is used in computer math. Most math can be done with algebra and trigonometry. You must also be familiar with physics.



In general, if I come across an application that requires calculus, I will write a quick simulation code, using a Do loop. I will vary the magnitude of the variable in extremely small increments until the required answer is reached.



The following code is small portion of simple application that analyses projectile motion by using only 2 of several parameters of the projectile general formulas. It is written in VB net. You will see the basic math functions are algebra, trig and the projectile formulas.





If Angle > 0 And MaxRange > 0 And Flag6 = 0 Then

Do

Velocity += 0.0001

HorVel = Velocity * CosA

VertVel = Velocity * SinA

TimeHeight = VertVel / g

MaxHeight = TimeHeight ^ 2 * 0.5 * g

If Elev > 0 Then

TempHeight = MaxHeight + Elev

TimeFall = Sqrt(TempHeight / (0.5 * g))

TotalTime = TimeHeight + TimeFall

Else

TotalTime = 2 * TimeHeight

End If

Loop Until TotalTime * HorVel >= MaxRange



The electrical engineering applications I have written (and marketed) are a little more complex, but are still mostly algebra, trig and electrical formulas.



All engineering courses (Computer science is considered an engineering couse by some) require a great deal of math, whether you use it in the real work world or not.



TexMav

.
green meklar
2013-10-04 05:52:38 UTC
If you're just starting university, then all you need to know at the moment is high school algebra. Pay particular attention to power laws, logarithms and base conversion, because these are things that come up a lot in computer science. The other stuff, such as boolean logic and set theory, will probably be taught in your computer science courses sooner or later. Geometry and calculus are generally not necessary unless you're doing graphics or scientific computing, and you won't encounter such topics for a while yet.



Here's one example of math being used in computer science: Consider the mergesort algorithm. It works in the following way. Given a list of numbers, do the following to the list:

- If the list is less than 2 items long, pass it back up.

- If the list is exactly 2 items long, and the first item is larger than the second, switch the two with each other, then pass the list back up.

- If the list is more than 2 items long, then split it apart at the middle (with the remaining 1, if any, going to one side or the other) to get two smaller lists. Perform the entire algorithm on each of these smaller lists. Then scan through the two lists from the beginning to the end, always taking the smaller of the two next items and adding it to a third list (and moving up along the list you took the smaller item from). When the third list is full, pass it back up.

If we assuming that each individual step such as 'move up 1 space along a list' and 'compare two numbers with each other' and 'switch two numbers' and 'add a number from one list to another' takes constant time. What is the running time of the algorithm? Imagine splitting the running of the algorithm up into 'levels', where the first level has a single list, the second has roughly two lists (the sizes of which add to the size of the original list), the third has roughly four (which also add to the size of the original), etc. On each level, the total amount of work is linear in the size of the original list. Because the size is being divided in half at each lower level until it reaches a low constant (2 or less), the number of levels to reach that point will be the logarithm (to the base 2) of the size of the original list. Thus, the algorithm's running time can be expressed algebraically as proportional to N*log2(N), where N is the size of the original list (whatever that happens to be when you run the algorithm).



Don't worry if that all flew over your head. In a few years it will make sense. :)


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...