# Applications of Calculus and Numerical Methods

nebbione
Hi, I'm a new user of this forum and i wanted to know how i can use calculus and interpolation in my projects.
I'm a student in engineering and i usually do home made electronics and computer programming projects, i would like to include calculus to my projects and understand the practical side of what I'm studying but sometimes in calculus and linear algebra for me it's diffcult to understand the practical aspects of some arguments or theorems.
Math for me is really enjoyable when i understand how i can apply the concepts to my projects and my work, i wanted to know : how can i use calculus for my electronics and computer engineering projects ?
And why scientists and engineers use interpolation instead of keeping tables ?
Does anybody know a good book or web source where i can really learn the full application of the concepts of calculus that I'm studying?

Homework Helper
Hi, I'm a new user of this forum and i wanted to know how i can use calculus and interpolation in my projects.
Welcome to PF; and woo! That's a big subject!
And why scientists and engineers use interpolation instead of keeping tables ?
The tables have to come from someplace.
The important ones come from experiments - like a time series of measurements (voltage vs time for eg).

What do we do if we need a number that is not on the table?

Does anybody know a good book or web source where i can really learn the full application of the concepts of calculus that I'm studying?
That would be none - there are lots of works that will give you bits and pieces but the full understanding would take a large chunk of a library.

In physics, math is a language and a tool. Concentrate on the things you need and build your understanding over time as you use the tools and talk to others in the language.

nebbione
Thank you ! You gave me a very good explanation, i understand now! Anyway I tried and understood the technique to make a polynomial interpolation, but i still don't understand how to make a linear or spline interpolation... can somebody explain me how to do it or link me a website where this is explained? Because I didn't find anything but the definitions and wikipedia page, but can't imagine the method.

Homework Helper
It is basically the same idea with a different equation.
You'll understand faster if you play around with one.

Studiot
Calculus and interpolation huh?

Well let us say you have a table of data. That is the y values for a series of x values. Each data point is therefore a pair of values (y,x)

Well polynomial interpolation of degree N means that you take a polynomial of degree N and make it 'fit' your data at each of the data points. That is you make the value of your polynomial at each x equal to your y data at that point.

So the polynomial equation is

y = axN + bxN-1 + cxN-2...dx + e

If you substitute each pair of x and y values in turn you will obtain a set of simultaneous equations you can solve for the constants a, b, c etc.

Since you have N+1 constants ypu will require N+1 data points to give N+1 equations.

Linear interpolation is just using a polynomial of degree one. This requires N+1 points ie 2 points to fit a straight line.

OK so your polynomial 'fits' the data at each point and you interpolate by using it to calculate y at some x you haven't measured at.

Well your polynomial will fit the y values at each measured x, but it will not in genreal have the same slope as the real curve at these points.

For instance there are many many functions that are zero at x = 0 but have vastly different slopes at x = 0.

Enter splines.

Differentiate the polynomial and do the same matching for the slopes at selected or all points.

The process of differentiation will lower all the equations by one degree so you will loose the cosntant and have one less point and simultaneous equation.

If you have more data points than you need for a given polynomial there are many possible solutions and you then need statistical techniques to chose the best one.

nebbione
Thank you very much for the explanation! But if i have my table of data what is the procedure to get a a linear function with the interpolation ? I didn't understand. With polynomial interpolation i use systems but with linear ? what is the procedure ?

Studiot
To perform linear interpolation you only require two points and you are approximating the change form one to the other by a straight line ( a polynomial of degree one as I said)

That is y = ax + b

So you can obtain the equations

y1 = ax1 + b

y2 = ax2 + b

Since you know (x1, y1) and x2, y2) you can solve the above for a and b.

Then you can calculate y3 for some x3 that is between x1 and x2

Strictly

x1 < x3 < x2

is called interpolation.

If you use your expression to calculate a y for x outside this range ie

if x3 < x1 or if x3 > x2

Then the process isc alled extrapolation. Extrapolation is inherently less relaible than interpolation, sometimes spectacularly so.

nebbione
thank you very much i undestand now!
And for the spline ? i just have to derive the polynomial function found with the polynomial interpolation ??

Studiot
Differentiate not derive.

Consider again my linear example.

You may have noticed that if you calculate a and b for the equation

y = ax + b

knowing (x1,y1) and (x2,y2)

then differentiate it

$$\frac{{dy}}{{dx}} = a$$

So

$$a = \frac{{{y_2} - {y_1}}}{{{x_2} - {x_1}}}$$

rearrange the differential

$$dy = adx$$

so having calculated a we can calculate y3 for any x3

$${y_3} - {y_1} = a({x_3} - {x_1})$$

or

$${y_3} = {y_1} + a({x_3} - {x_1})$$

Now if you have a higher degree polynomial you have to differentiate it and set up more simultaneous equations to match slopes for the spline.

Last edited:
nebbione
Ok, let me see:
If after a polynomial interpolation i find a polynomial form like :

3x^4+4x^3-35x^2+42x+9

i only have to differentiate this (respect x). is that right ? and the polynomial form that i find is:

12x^3+12x^2-70x+42

So the result of spline interpolation right ?
Is it done like this ?

Anyway thank you for the collaboration

Studiot
No there is more to it but I am now going to ask you to do some work.

What is the shape of the curves y = ax2 and y = ax3 ?

Particularly what happens (what is the sign of y) when x is negative?

nebbione
the shape of the first one is a parabola and the second one is like a turned straight S.
For the first one, the sign of y is always positive and for the second one the sign of y is positive if x is positive and negative if x is negative.

But what is the matter of this with interpolation ?

Studiot
Well for most tabulated functions (or measured ones) in the real world we expect y to increase as x increases.

This means that we do not want approximating functions like a parabola that falls in the second quadrant and turns at the y-axis (zero slope) and starts going up again into the first quadrant.

The cubic that I asked about is ideal for this because it comes up from below in the third quadrant, crosses the y-axis with a definite slope and keeps going up into the first quadrant.

Gosh it is easier to draw all this than say it!

Anyway that is why the first order spline we normally use is a cubic spline, which you will normally see referenced.

nebbione
i'll think about it ! anyway i think you are saying that we try to use odd polynomials because the positive ones are always positive with spline interpolations ?

Studiot
Very often we break the full range of the datset into shorter sections.

Each section is approximated by its own cubic spline.
These will in general have different constants, but the same form.

When we are using a cubic spline we are approximating our data by a general cubic

y = ax3 + bx2 + cx + d

There are four constants, but instead of making this cubic match the data points we make the first and second derivatives at the end of the first spline match the beginning of the spline in the second section and so on.

That way the splines for each sections blend smoothly one into the next.

Incidentally the word spline comes from the way an old fashioned draftsman would have used a flexible steel strip to bend round the plotted data points to provide a curved ruler to draw the plotted line. A bent steel strip, fixed at four points naturally takes up a cubic profile.

This means solving the simultaneous equations

y' = 3ax2 + 2bx + c
y'' = 6ax + 2b

for the end of one spline and the beginning of the next.

nebbione
ok thanks a lot! anyway which is a nice way that i can use calculus in my electronics and comupter engineering projects ? what can i analyze and how can i include functions and plots ? Sorry for a too general question, but I'm trying to get a better understing on how i can apply calculus and numerical methods.

You'll get better help if you reveal some of your projects.

The application of calculus to digital electronics may not be very impressive since much of calculus (of the ordinary sort) does not deal with discrete quantities.

If you have some projects using analog electronics, someone might point out how calculus applies.
.

nebbione
Ok for example one of my new projects is two joystick system for pc made with a PIC that can be connected to a pc via usb!

Is there a way i can make some analysis etc... ?
Anothere project is a small robot with three wheels that is controlled by infrared and has ultrasonic distance sensor and it is programmed to not touch the wall (it will change its direction). I even designed the circuit with photo resistence so that when it's darker it will light his own LEDs.

How can i use calculus and numerical methods or linear algebra to this kind of projects ? what data can i collect ? what could be an interesting function about these things ?

In terms of data collection, you need to specify the I/O protocol for the device.

As long as you can can capture the direct data (it used to be done through using IN and OUT assembler commands, but modern OS design and device driver interaction is a lot better) and then just flush it to a file.

If you want to process the data, then you can but you can write the raw data to some file in some format and then deal with it later on.

Analyzing the data though is another story and a whole other issue that depends on tonnes of things.

nebbione
Sorry but i don't understand what you wrote.

I try to better formulate my question:
How can i include data collection for interpolation andcalculus to my Comp.Eng projects ?