MATLAB: How to plot sawtooth wave sawtooth function
functionsawtooth
Related Solutions
Hi Jeff,
First of all, if you are fourier expanding a function y(x) in the interval [0,1] and its start value y(0) is not equal to its end value y(1), then the function has a discontinuity. That's because the fourier series is periodic, so the start and end points are effectively next to each other. With that out of the way, take a look at the function
y(x) = 1-x 0 <= x <= 1 (fig 1 trace 1)
It has f(0) = 1, f(1) = 0 and has an upward discontinuity of +1 at the origin. There is no discontinuity anywhere else. With its single discontinuity, y(x) is more basic than the square wave. Its fourier expansion is
y(x) = 1/2 + (1/pi)*Sum{1,N} sin(2*pi*n*x)/n
You can see the Si integral emerging on the right hand side of this. The max value of y(x) shows the familiar overshoot, 1/2 + (1/pi)*Si(pi) = 1.089 as you can confirm, having done very similar sums many times before. It may converge to that value more slowly than does a square wave, I don't know, but the Gibbs phenomenon is about the value, not the rate.
Keeping in mind that y(x) is periodic, suppose you translate y(x) to the right by distance x0 to create a new function y1(x). Then of course the discontinuity moves to x0. Also y1(0) = y1(1) and there is no other discontinuity. I'm not going to prove it but it's pretty intuitive that the overshoot is the same as before. Also, if you multiply y1(x) by a constant r (fig 1 trace 2), then discontinuity height and overshoot are both multiplied by the same factor, so overshoot relative to height does not change.
Suppose there is a "sensible" but otherwise arbitrary function f(x) in the interval [0,1], with a single discontinuity of height r, located at x = x0. Since there is no other discontinuity, necessarily f(0) = f(1). Now the idea is to remove the discontinuity in f(x) by using r*y1(x):
f(x) = [f(x) -r*y1(x)] + r*y1(x)
The part in square brackets has the discontinuity removed and its two end points have the same value. It has no overshoot. The remaining part does have the height r discontinuity and the 1.089 relative overshoot. That means so does f(x), for any reasonable f(x).
(Note that the part in square brackets does have values near the discontinuity, so it may affect the perceived rate of convergence to 1.089 in some manner).
x = 0:1e-3:1;y = 1-x;x0 = .25; r = .4;n = round((1-x0)/1e-3);y1 = r*[y(n+1:end) y(1:n)];plot(x,y,x,y1)
When I plotted your function, there is only one zero. I would plot it as:
f = @(x) exp(-sin(x)) - x;xz=fzero(f,1);figure(1)fplot(f, [0, pi])hold onplot(xz, 0, '+r')hold off
Best Answer