# What does mathematics and physics have to do with programming?

#### vikhyat

##### Estimable
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.

#### Someone Somewhere

##### Splendid
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.

Apps General Discussion 2
Apps General Discussion 8
Apps General Discussion 1
Apps General Discussion 1
Apps General Discussion 1
Apps General Discussion 0
Apps General Discussion 1
Apps General Discussion 1
Apps General Discussion 2
Apps General Discussion 10
Apps General Discussion 1
Apps General Discussion 1
Apps General Discussion 2
Apps General Discussion 0
Apps General Discussion 4
Apps General Discussion 3
Apps General Discussion 1
Apps General Discussion 3
Apps General Discussion 11
Apps General Discussion 2