|
"Diego Zegarra" <diegozbb@gmail.com> wrote in message <grlbba$3a2$1@fred.mathworks.com>...
> John,
>
> I would really appreciate if you could give me a reference where I can get this stuff. I need to do some curve fitting and do not want to be asking all the time if I can do it myself. Your explanation for all this was great by the way, very detailed and easy to follow. I am trying to see how you came with those numbers in the 4th level polynomial though.
>
> FYI. I am trying to fit curves with same characteristics but having the inflection point before, also having it after and also being not so linear, a little more 'pregnant'. If you could give me a hint where I can learn this I would really appreciate it.
>
> Thanks!
Rats. So now I need to remember what I did
then. 8-) Luckily it is just some basic calculus
as I recall.
Ok, so your question is where did m come from,
and I assume, how did I know that m has limits
[1/3, 2/3] for monotonic G(x) on the interval
[0,1]?
Start by applying the simple constraints
G(0) = 0
G(1) = 1
G'(0) = G'(1) = 0
If we assume initially that G(x) is a general 4th
order polynomial,
G(x) = a*x^4 + b*x^3 + c*x^2 + d*x + e
Then we know immediately that d = e = 0.
Why? What is the Taylor series for G, expanded
around x = 0? Remember, we know that G(0)=0.
That tells us that e = 0. Likewise, G'(0) = 0
implies that d = 0 in the above polynomial.
See what happens when we substitute 1 into
G now.
G(1) = a + b + c = 1
This gives us one linear constraint on the
parameters. Look at the derivative.
G'(x) = 4*a*x^3 + 3*b*x^2 + 2*c*x
so
G'(1) = 4*a + 3*b + 2*c = 0
Finally, let us choose the location of the
inflection point. I called the point of
inflection m. What is an inflection point?
It is a point where the second derivative
changes sign.
G''(x) = 12*a*x^2 + 6*b*x + 2*c
Thus we have
6*a*m^2 + 3*b*m + c = 0
For this to have a solution, what might we
know about the coefficients? Look at the
discriminant of the quadratic. For a real
root to exist for the quadratic, what can we
say?
9*b^2 - 24*a*c >= 0
Put it all together now.
(1) a + b + c = 1
(2) 4*a + 3*b + 2*c = 0
(3) 6*a*m^2 + 3*b*m + c = 0
Solve for a, b, c, in terms of m, I get these
relations:
c = 1 - a - b
b = -2 - 2*a
and, finally,
3 - 6*m + a - 6*a*m + 6*a*m^2 = 0
This gives us a, as a function of m.
a = 3*(2*m-1)/(6*m^2 - 6*m + 1)
Given a, we can now back out the values for b
and then c.
Look back at the discriminant expression. I'll use
my sympoly toolbox.
sympoly a b c
subs(subs(9*b^2 - 24*a*c,'c',1-a-b),'b',-2-2*a)
ans =
36 + 12*a^2
Obviously, this is positive for all real a. So as it
turns out, as long as we can find a valid solution
for a above in terms of m, it looks like things
should work. Recall the relation for a.
a = 3*(2*m-1)/(6*m^2 - 6*m + 1)
This has singularities at two points. So m cannot
go outside of that interval.
roots([6 -6 1])
ans =
0.78868
0.21132
To get a feeling for what happens, try this:
m = 1/3;
a = 3*(2*m - 1)/(6*m^2 - 6*m + 1);
b = -2 - 2*a;
c = 1 - a - b;
G = [a b c 0 0];
ezplot(@(x) polyval(G,x),[0 1])
Look at the resulting shape of the curve. Try
it again for a different value of m, perhaps 2/3.
Now, try it one more time, at m = 0.3. This is
just a wee bit lower than 1/3. What happened?
In fact, there was a SECOND inflection point in
the curve. That second inflection point in the
interval forces the curve to be non-monotonic.
G''(x) = 12*a*x^2 + 6*b*x + 2*c
At what point will that second inflection point
drop down below 1?
gpp = subs(subs(12*a*x^2 + 6*b*x + 2*c,'c',1-a-b),'b',-2-2*a)
gpp =
6 - 12*x + 2*a - 12*a*x + 12*a*x^2
subs(gpp,'x',1)
ans =
-6 + 2*a
So, G''(1) == 0 when 2*a - 6 == 0, or when
a = 1/3. For any smaller values of a, the second
inflection point on this curve creeps inside the
interval [0,1].
We can do the same analysis when m is near 2/3,
as the second inflection point will move above 0.
It is all just calculus and a little algebra. If you are
unsure what is happening, make some plots, think
about what you see. To be honest, there are surely
other ways to have derived these relations, and I
have no certainty that I used the same logic some
time ago when I first did the analysis. Luckily I
came to the same conclusion. 8-)
John
|