vikhyat :
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?
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.