Professional programmer struggling to learn Calculus

312 Views Asked by At

I've been a software engineer for about $12$ years now and I have been wanting to learn calculus to help expand my skill set and problem-solving skills (and also as a hobby because I enjoy physics). But I'm running into an issue: every time I try to start learning calculus the notion of "functions" confuses me.

Today I was trying to learn derivative notations (Lagrange, Leibniz and Newton) and I am really struggling to make sense of any of it. Newton and Lagrange with the dot and the prime tick mark are fine but Leibniz has me lost.

How does $\frac{d}{dx} (f(x))$ and $y = f(x)$ make $\frac{dy}{dx}$?

Also, simple things like $f(x)$ when trying to find the derivative of a curve have me confused too. Programming uses functions a lot so I think my understanding of a function is different enough and is throwing me off.

So I guess my real question is when given a function, how does one know what the function definition is? If $f(x)$ will return the value for the "rate of change of $y$ with respect to $x$ of $f$", where is that being defined? (and by defined I mean where can I find the procedure to get the value that the function will return and be assigned to $y$? (assuming that is the correct way to think about it)

Sorry if any of this is confusing! And thanks in advance!


EDIT: After reading the responses I will try to better explain my original question and include additional relevant details. This was my first post here so I apologize if I confused anyone or broke any community guidelines.


As a programmer (PHP 5.4 - 8.1), functions for computers have a very specific set of rules and principles for how they are written and operate. For the most part, they work the same across multiple programming languages with some exceptions (pun intended). Common rules such as: must be defined before calling, the scalar/compound type of the return value must match (if set) the return type that was set when the function was defined, etc.

I believe I have a strong understanding of the rules and mechanics that govern how functions work programmatically which is where I think the root of my issue is.

Math also has functions that appear to share similar properties with computer functions (i.e. inputs/arguments, output/returns) and these math functions also appear to perform some form of procedure like computer functions. They are even capable of being assigned to a variable in a sense ($y = f(x)$).

However, this is where the similarities appear to end.


My question boils down to what are the "rules" that make a math function an actual math function? What can they do? What must they do? What can't they do? And in what ways are math functions the same and different from computer functions at an abstract level?

I understand that they take an input and in the previous example $y = f(x)$ that the variables $y$ and $x$ share some form of relationship when plotted on a graph (i.e. to get the value for $y$ you "run" $f(x)$ so $y$ literally IS the $f$ of $x$)

But when I see functions used for things like derivatives, I get confused. Any computer function that could return a derivative must have some procedure it follows which is defined somewhere the computer can look up to execute it when that function is called to return the answer.

So my original question really boils down to:

IF function F() is defined THEN how can I locate the procedure that F() follows to get its result?

If there are other foundational mathematics I need to learn first (i.e. I am jumping too far into the deep end), please let me know what those are!

My main goals for learning calculus are to be able to solve and write my own physics equations and to help improve my programming skill set.

Thanks to all who have shared examples and resources to try and help me and thanks to future posters as well!

3

There are 3 best solutions below

7
On

I’ll walk you through a specific example and hopefully that will clarify your problem.

Notation

Let’s define a simple polynomial $f(x)=x^2$ where $x$$\in$$R$ (where $R$ is the set of all real numbers). You can think of this like a machine that maps the input value $x$ to the output value $x^2$.

Then we can calculate the rate of change by differentiating. There are many ways to denote a derivative. If you know the procedure for differentiating polynomials, then you should be able to arrive at the conclusion that the derivative here is simply $2x$.

Here are a few ways that mathematicians write this:

  • $f’(x) = 2x$
  • $\frac{df}{dx}=2x$
  • $\frac{d}{dx}(x^2) = 2x$

If we say $y=f(x)=x^2$ then differentiating $y$ with respect to $x$ is exactly the same as differentiating $f(x)$ with respect to $x$, and so we could also write:

  • $\frac{dy}{dx}=2x$

All we have done here is replace $\frac{df}{dx}$ with $\frac{dy}{dx}$. This isn’t a necessary step and is usually just a notational choice.

Meaning

To understand the meaning of a derivative, let’s use the above example to illustrate.

Imagine $f(x)=y=x^2$. Let’s say that the value of $x$ represents how difficult an activity is. And let’s say that $f(x)$ tells us how boring the task is.

This means that if a task is very difficult (for example $x=100$) or very easy (for example $x=-100$), then the person will be very bored ($f(x)=100^2=(-100)^2=10,000$). This is what the function tells us.

The derivative tells us how fast or slow a function is changing. This is easier to see on a graph, however, another way to think about this is to image what would happen if you move a small amount from a specific point. If you compare $x=100$ to $x=101$, then if you square both of these to calculate the level of boredom, you will find that the difference between the two is $201$. If you did the same for $x=1$ and $x=2$, if you square both of these, then the difference between the two is only $3$. Therefore, the rate of change is much faster from $100$ to $101$ than from $1$ to $2$.

The derivative quantifies this “rate of change” at every point. So we know that the derivative $\frac{df}{dx}=2x$ tells us that at the point $x=100$, the rate of change is $200$, but at the point $x=1$, the rate is only $2$. This helps to explain why we saw a much faster increase when comparing $x=100$ to $x=101$ than we did for $x=1$ and $x=2$ (despite them both being only $1$ apart).

enter image description here

There are lots of other complexities to consider depending on the type of function that you consider. This is something that you will likely come across if you continue to progress in your studies of calculus. Although this isn’t something to worry about too much at this stage.

0
On

Professional programmer here too, however also doing maths for my job.

A math function may have a definition... or it may not.

When you have a practical problem at hand, say for example a complex physics phenomenom which you approximate by a polynomial, then you have a perfectly defined function, such as $f(x) = 3x^2 + 5$ for example.

But when you want to discover all the properties of a class of functions, say all the continuous functions from $\mathbb{R}$ to $\mathbb{R}$, then you work on a function $f$ which is more declared than defined, to use computer science words.

Mathematicians (and especially in textbooks) more often work on a whole class of objects than on specific objects. A function is something that, given an element of a set, points to an element of another set (possibly the same). In textbooks you prove theorems where only the sets are known, or even the sets can be a whole class of objects: "a vector space", for example.

That's not surprising. Theories have to be general. The gravitation law, for example, is expressed for any two bodies that have masses $m_1$ and $m_2$ and are at a distance $d$ one from the other: the law is valid for any $m_1, m_2, d$. In math that's the same: theorems are expressed for math objects that are rather general, not specific.

What's more, in some circumstances you can prove that an object exists, but you are left without any practical means of finding some specific information about it. Such as you may demonstrate that there exists a function $f$ that has such and such properties, but you are enable to compute $f(2)$ (and in some extreme cases you may even prove that you cannot compute it).

To give an example of a theorem that concludes "something exists" but gives no clue as to calculate it: if $f$ is a continuous function ("continuous" has a precise definition, but let's say it means its graph does not jump from one point to another) on an interval [a, b], then for any $c$ between $f(a)$ and $f(b)$ there is (at least) one $x$ in [a, b] for which $f(x) = c$. That's intuitive, but the theorem is not concerned by a way to find $x$.

That's the same in real life: if a prisoner has escaped his prison, you can draw any sphere around the prison, if you are sure the prisoner is not inside the sphere or has been disintegrated, then you know there is a point on the sphere by which the prisoner has gone. But that gives no clue as to where that point is.

Actually this led to some heated debate one century ago, and some mathematicians went studying more "constructive" ways of doing maths. This produced nice theories (intuitionistic logic, etc.), although not simpler and with as many pitfalls and surprising results as more classical theories.

So all this prose to say that "finding the procedure to get the value that the function will return" is not necessarily the goal in math. Some textbooks and some theories are more abstract than others. Some mathematicians never give any examples.

And as you probably know already, calculating function values with computers is way more complex and haphazardous than we like to think. E.g. derivatives can in theory be approximated by using small increases... but that fails more often than not. When dealing with real numbers, algorithms look more like cooking recipes than theorems. And there are whole domains (e.g. most of AI) that are not soundly backed by math theories. So it should not be surprising that math theory often seems "too high in the sky" when you have a practical math problem to solve with a computer. That's also the beauty of math and a good derivative (pun intended) to our everyday troubles with computers.

5
On

Typing in lots of stuff about definitions of functions and derivatives into these answer boxes is silly in my opinion. If you want to learn calculus, there are lots of good ways. For example, try Prof Ghrist. If you want to learn it well, you should attempt the exercises too. I think you can access them here