What does mathematics and physics have to do with programming?

vikhyat

Estimable
May 11, 2014
1
0
4,510
0
I am a basic programmer. I know some programming languages like VB, C++, Java, Javascript, Php etc. I have heard that maths and physics play a lot of role in programming but how?
 

Pinhedd

Distinguished
Moderator


The extreme lack of applied physics in the study of computation is one of the reasons why Software Engineering remains a controversial discipline. Using software to simulate physics is extremely common, but a programmer can get by without mastering physics as a discipline. On the other hand, a programmer without an understanding of mathematics is a disaster waiting to happen.

Programming is the practice of implementing algorithms, and algorithms are mathematical constructs. Most familiar computational algorithms are applications of linear algebra and boolean algebra as these are two mathematical domains that can be efficiently implemented in the electronic circuitry that software relies on. Other domains such as trigonometry and calculus usually fall back on linear algebra and boolean algebra for their own implementation.

For example, sine is a well known single-variable mathematical function that's used all the bloody time. However, it's a real non-linear function and has no easy electrical implementation. This means that creating a circuit to compute sin(x) would be incredibly difficult and incredibly resource-inefficient without even taking into consideration the precision of the calculation. Instead, a linear approximation of sin(x) can be calculated to arbitrary precision using a McLauren series and nothing more than basic arithmetic.



The function above is linear and the accuracy of the function increases as k increases (although time complexity increases as well and it will eventually exceed machine precision). This function uses operations that are easy to implement in circuitry, namely addition, multiplication, and division. Further optimizations can be made by storing commonly used values in a lookup table.
 

Ijack

Distinguished
Suppose that you wanted to program a flight simulator (or anything else that models the real world). Do you think you could do that without knowing a bit of physics (and mathematics)?
 

USAFRet

Illustrious
Moderator
maths and physics
Has everything to do with 'programming'.
-Calculate the arc and trajectory of a thrown grenade, given gravity gradient of Earth normal * 1.2. (Games)
-Calculate the time differential between a radio signal from 3 different satellites (GPS)
-Calculate the potential revenue 90 days from today, based on the knowledge that the farther out on the calendar, the less likely a contract will actually be completed. (Less than 30 days, 98% go to completion. Greater than 30 days, 90% complete. Greater than 60 days, 82% go to completion. Greater than 90 days, 68% go to completion)
-Based on this particular rocket motor and specific impulse, how much fuel do we need to put payload weighing xxx kilos in geosync orbit (NASA)

That's just some simple stuff.
 
Mathematics is very very closely related to logic, which is basically what programming is.

Physics is a bit less so, and typically only applies to simulating or predicting stuff (which includes games). If you end up working as a programmer, there's a good chance that someone else will give you all the equations necessary; you just have to implement them in an efficient manner.
 

Pinhedd

Distinguished
Moderator


The extreme lack of applied physics in the study of computation is one of the reasons why Software Engineering remains a controversial discipline. Using software to simulate physics is extremely common, but a programmer can get by without mastering physics as a discipline. On the other hand, a programmer without an understanding of mathematics is a disaster waiting to happen.

Programming is the practice of implementing algorithms, and algorithms are mathematical constructs. Most familiar computational algorithms are applications of linear algebra and boolean algebra as these are two mathematical domains that can be efficiently implemented in the electronic circuitry that software relies on. Other domains such as trigonometry and calculus usually fall back on linear algebra and boolean algebra for their own implementation.

For example, sine is a well known single-variable mathematical function that's used all the bloody time. However, it's a real non-linear function and has no easy electrical implementation. This means that creating a circuit to compute sin(x) would be incredibly difficult and incredibly resource-inefficient without even taking into consideration the precision of the calculation. Instead, a linear approximation of sin(x) can be calculated to arbitrary precision using a McLauren series and nothing more than basic arithmetic.



The function above is linear and the accuracy of the function increases as k increases (although time complexity increases as well and it will eventually exceed machine precision). This function uses operations that are easy to implement in circuitry, namely addition, multiplication, and division. Further optimizations can be made by storing commonly used values in a lookup table.
 
Thread starter Similar threads Forum Replies Date
M Apps General Discussion 2
H Apps General Discussion 8
aymen9309 Apps General Discussion 1
SyndiShanX Apps General Discussion 1
D Apps General Discussion 1
BlueMoon1890 Apps General Discussion 0
Neon The (Anthro) Umbreon Apps General Discussion 1
ktnrajput Apps General Discussion 1
K Apps General Discussion 2
T Apps General Discussion 10
I Apps General Discussion 1
1 Apps General Discussion 1
N Apps General Discussion 2
viveknayyar007 Apps General Discussion 0
rjackowens Apps General Discussion 4
fdd2blk Apps General Discussion 3
M Apps General Discussion 1
thebski Apps General Discussion 3
I Apps General Discussion 11
T Apps General Discussion 2

ASK THE COMMUNITY