PDA

View Full Version : One more Maple/math question


JayTee
03-01-2007, 05:02 PM
So I figured out what I wanted to do with the last question I brought here. Now I'm at the final step. I have a series of piecewise functions defining a triangular wave (if that's the correct term). I want to make the function differentiable by replacing the sharp points with curves (by using cosine functions). I've included a visual to help explain myself.

the equations for these two lines are:

x<=75/tan(4*Pi/9),-tan(4*Pi/9)*x+75

x<=150/tan(4*Pi/9),tan(4*Pi/9)*x-75

http://i74.photobucket.com/albums/i242/wvbluffer/sharppoint.jpg

My thoughts:

I know how to define the range around the x intercept, so I can make it arbitrarily small. I'm having trouble defining the wave and figuring out how to properly shift it, so that it merges seamlessly.

Thanks for any advice.

holmansf
03-01-2007, 07:09 PM
If what you want is to "smooth" out the corners, a good method is by convolution with a smooth bump function. In fact, if all you want is one derivative, it's pretty easy to contruct such a function using cosine. I can explain more, but if it won't help you I don't want to waste the time. Let me know.

JayTee
03-01-2007, 08:09 PM
[ QUOTE ]
If what you want is to "smooth" out the corners, a good method is by convolution with a smooth bump function. In fact, if all you want is one derivative, it's pretty easy to contruct such a function using cosine. I can explain more, but if it won't help you I don't want to waste the time. Let me know.

[/ QUOTE ]

Thanks

I have a series of functions that create sharp points (18 in all) and I need to round them all(I would prefer that the rounding be over a very small area). Any help would be greatly appreciated.

holmansf
03-01-2007, 08:30 PM
One good way to do this is as I said above, by "mollifying." The idea is to integrate the function you are trying to smooth out against a smooth function. So let's say your triangle wave is given by the function f(x). Also lets say g(x) is a function that is differentiable, is 0 outside of a the interval (-epsilon,epsilon) for some very small number epsilon, and has integral equal to one (ie the integral of g over the whole real number line is one).

Then you take the convolution of f and g, which is defined as follows:

g*f(x) = \int g(x-y) f(y) dy.

This integral is only over a small interval around x, since that's the only place g is nonzero, the function g*f is differentiable since you can differentiate under the integral and g is differentiable, and g*f only depends on values of f very close to x. In fact, if you choose g to be an even function and f is linear with epsilon of x, then f*g(x) = f(x). This will be the case in your example.

So you ask, what function do I use for g? A common choice (as can be found here http://en.wikipedia.org/wiki/Mollifier)is to start out with:

h(x) = e^{-1/(1-(x/epsilon)^2)} for |x|<epsilon, 0 otherwise,

and then divide by the integral of h, which needs to be computed numerically.

However you could use a cosine function. Start out with say:

h(x) = 1 + cos((x/epsilon)pi/2) for |x|<epsilon, 0 otherwise

which will be differentiable (only once though) then divide by the integral of h (which you could calculate exactly) to get g.

JayTee
03-01-2007, 09:18 PM
holmansf,

Thanks for your time. I'll try to figure out this method. However, this is pretty far of ahead of my current level.

Siegmund
03-01-2007, 11:17 PM
One simple approach -- there are many others -- is to pick any differentiable function g(x) you like that has g(x)->0 at -infinity and g(x)->1 at +infinity. One simple choice is exp(kx)/(1+exp(kx)).

Now, if f1(x) and f2(x) are your two straight lines that cross at x=d, then

h(x) = g(x-d)*f1(x) + (1-g(x-d))*f2(x)

is a function such that h(x) lies between f1(x) and f2(x) everywhere, but extremely close to one or the other of them when you are a long way from the crossing point. Because h(x) is a combination of linear transformations of g(x) it inherits all of g(x)'s differentiability properties.