Determining polynomial coefficients by known derivatives

Hello community, I'm trying to create a cubic polynomial function, I know these: y(0)=1 y(30)=0.5 dy(0)/dx=-1 dy(30)/dx=-1 Can I determine the values for coefficients ?

 Accepted Answer

Yes. Just in case this is homework, I will give an example to get you started.
Let's say you have the case below (I will start with the case where we do not have derivatives at a location).
We are trying to solve for A, B, and C
y(x) = A*x^2 + B*x + C
Knowns:
x1 = 0; y1 = 1;
x2 = 3; y2 = 6;
x3 = 7; y3 = 7;
So we can construct an inverse problem of the form G * m = d, where:
G = [x1^2,x1,1; x2^2,x2,1; x3^2,x3,1];
d = [y1; y2; y3];
We determine m (equal to [A; B; C] in our example) by:
m = G\d;
And we get:
plot(-1:10,polyval(m,-1:10),'r-', [x1,x2,x3],[y1,y2,y3],'k+')

8 Comments

In your case you have 2 known derivative points... based on the example/hint above, how would you define the G matrix to account for derivative information?
Maybe I need do define an another matrix as dg=diff(G); But how it will be calculated in sync with main matrix, also I only know start and end of the function, I have missing points which require some sort of interpolation. I have written dynamic analysis FEM codes but this thing struggled me.
Nope... you can put the derivative information right in the same G matrix. Another hint is below:
In your case you have information associated with:
y(x) = A*x^2 + B*x + C
and
y'(x) = 2*A*x + B
So... if you have y(x) info and y'(x) info you would set up your matrix equation like:
| x1^2, x1, 1 | | A | | y1 |
| x2^2, x2, 1 | | B | = | y2 |
| | | C | | dydx1 |
| | | dydx2 |
How would you fill in the last 2 rows of G ?
Incidentally, I think you meant your dy(30)/dx = +1 (not -1). Once you factor that in and fill out your G matrix you should obtain something like:
Omur
Omur on 18 Oct 2012
Edited: Omur on 18 Oct 2012
Like 2x1 0 0 2x2 0 0 ? (How you do line down and write codes?) No, it's derivative is -1, therefore function is cubic. I guess ? Elige, I'm confused.
Almost... since you will need to expand to a 3-order polynomial, I will give you the G for a 2-order (which would give you the plot immediately above if dydx2 = +1). In your case, your y and y' info are at the same 2 x locations... so:
| x1^2, x1, 1 | | A | | y1 |
| x2^2, x2, 1 | | B | = | y2 |
| 2*x1, 1, 0 | | C | | dydx1 |
| 2*x2, 1, 0 | | dydx2 |
You still need to have contribution from your "B", which is why the second column of the last two rows have the 1. Once you expand to a 3-order polynomial for your data, you should get something like:
To learn more about using mark-up to format your questions/answers/comments you can check out this page:

Sign in to comment.

More Answers (1)

This answer doesn't incorporate the derivative. How would this be solved taking into account the derivative?
What about in 3 dimensions?

Categories

Asked:

on 18 Oct 2012

Commented:

on 8 Jul 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!