Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

B Simple double integration of square wave question

  1. Aug 16, 2017 #1
    Hi,
    Simple question, sort of:

    I see that according to the internet the mathematical description of a triangular wave is rather complex, so I'll try to stay as far away from that as I can, because I'm a bit rusty.

    I understand that if you integrate a square wave you get a triangular wave on the x-axis. But If you integrate that triangular wave you get something resembling a sineusoid. (something about it being the first harmonic of the triangular wave I believe)

    My questions are: How close is that to a sine wave? What does it look like graphically? (I don't have matlab)
    Secondly, are there different slopes of triangular waves, including asymmetrical triangular waves, which are closer to a sine wave?

    I am so rusty on Fourier transforms / series, it's not funny. But regarding this:
    http://mathworld.wolfram.com/FourierSeriesTriangleWave.html

    I see the asymmetrical figure, which is kind of what I have in mind, but I'm not sure what the red sine wave is indicating.

    Cheers
     
  2. jcsd
  3. Aug 16, 2017 #2

    Nidum

    User Avatar
    Science Advisor
    Gold Member

    You can see immediately what successive integrals of a square wave form look like if you remember that one definition of integration is simply the area under a curve .

    Just draw graphs of the integrated area under the curves as you progress along the x axis . Take integrated areas above the y=0 line as positive and below as negative .

    You can do square to triangular and triangular to the next one using simple geometric calculation of areas . Gets a bit difficult for higher levels of integration so you have to do some proper calculus for these .

    You might like to conjecture what the curve looks like after a large number of successive integrations of the original square wave form .
     
  4. Aug 16, 2017 #3

    mfb

    User Avatar
    2016 Award

    Staff: Mentor

    I guess you integrate over pieces of the original function, e. g. ##g(x) = \int_{x-c}^{x+c} f(x') dx'##? If f(x) is a triangle function, you can evaluate this integral analytically. You get parabolic parts, potentially with linear pieces in between. To answer how close that is to a sine you first have to define what "close" means.
     
  5. Aug 17, 2017 #4
    Not meaning to sound entitled/lazy and narcissistic but I want to see it graphically, but I don't have all day (hardly 5 spare minutes in fact) to do the calculations and graphing (nor do I have wolfram or matlab).

    I can imagine how you'd get parabolic parts, but what sort of parabola? And why are there linear pieces in between, at the inflection points?

    Yes, 'how close' IS an interesting question. Aside from graphical inspection/opinion, can you have a section of parabola curve-fit to part of a sine wave? Or is that a mathematical impossibility?

    Thanks all.
     
  6. Aug 17, 2017 #5

    mfb

    User Avatar
    2016 Award

    Staff: Mentor

    There is just one sort of parabola.
    If your whole integration range is on the slope of the triangle, the integral is linear with respect to the position of the center of the integration.
    Not exactly, but the difference can be very small.
     
  7. Aug 19, 2017 #6
    Thanks for the reply. Okay, I just did something I would have done the other day I was on PF if I'd have had the time, which was to wiki 'parabola'. It has been a long long time since I'd thought of parabolas in a non-trivial way (I basically just remembered locus and focus). The same thing almost goes for integration :P
    Anyway, the picture of https://upload.wikimedia.org/wikipe...rabeln-var-s.svg/330px-Parabeln-var-s.svg.png
    as was the family of conic sections. Basically a parabola is a graph of a quadratic function. So what I meant in my last post, was 'what [sort of] quadratic equation.
    So does this mean that the [type] of parabola y = x2 with no 'a' coefficient or +/- 'constant' ?

    Interesting, is there a way I can construct a quadratic equation which is really close to that of a half circle? I suppose this would mean that the conic section slides right down the cone close to the base.

    Thanks
     
  8. Aug 19, 2017 #7

    mfb

    User Avatar
    2016 Award

    Staff: Mentor

    What you quoted was about a part that is not a parabola.
    No. You can approximate a small part reasonably well, but a parabola will never look like a half circle.
     
  9. Aug 20, 2017 #8
    I understand that, it must be bounded to leave only part of the parabola which approximates the half-circle, relevant. I want to make that clear.

    My inquiry now is, how to I mathematically articulate this? How do I construct or arrive at a quadratic which is close to a half circle, i.e. varying the coefficients and constants of the equation, and how [or where] do I bound the quadratic?

    Thank you!
     
  10. Aug 20, 2017 #9

    mfb

    User Avatar
    2016 Award

    Staff: Mentor

    I'm missing too much context to understand what exactly you are asking.
     
  11. Aug 20, 2017 #10
    No worries, I'll elaborate.
    Before I do, I just thought of something: if you were integrating a square wave from 0 to 2π from A to -A. Then would the result not be a triangular wave sitting on top of the x-axis. But then, wouldn't the resulting 'parabolic wave' also be sitting completely on top of the x-axis?

    Anyway, what I was getting at before in my last post was: To find the parabola you'd integrate the triangular wave from x-axis [0] to x-axis [2π].
    Say we were integrating this triangular wave; since y = mx + b for a line; I think it would be something like:

    0π mx + b dx -
    π mx + b dx = [mx2 + bx - mx2 + bx ]

    does this mean that 'm' (the slope) is, the equivalent of 'a' here:
    https://upload.wikimedia.org/wikipe...rabeln-var-s.svg/330px-Parabeln-var-s.svg.png
    ??

    Which would mean the smaller 'm' is, the lower down the cone the parabola is, and so the closer it is to a half circle? (as per https://upload.wikimedia.org/wikipe...nic_Sections.svg/330px-Conic_Sections.svg.png)

    Thanks
     
  12. Aug 21, 2017 #11
    P.S. I was thinking today, wouldn't ∫0π mx + b dx just exponentially rise? (Until it reaches π)

    So wouldn't the parabolic wave actually be something like:
    [ A - 1/∫0π (A/π)*x dx ] - [ A + 1/∫π (A/π)*x dx ] ???
    Where 'A' is amplitude.

    Also, according to
    http://www.embedded.com/electronics-blogs/programmer-s-toolbox/4025567/Rosetta-Stone-explained

    This is what the integral of the triangular wave looks like, also in the attached picture is what I would have expected it to look like:
    integral of triangle.png


    I assume I'm mistaken, could you please explain how?
    Thanks
     
    Last edited: Aug 21, 2017
  13. Aug 26, 2017 #12

    jim hardy

    User Avatar
    Science Advisor
    Gold Member
    2016 Award

    test - edit has quit saving changes
    hmmmm got 'em all that time . Feast or famine. Computers are just that way; never trust one.


    i'll just reply to the thread. There's far better math folks than me on PF.



    Methinks you're not integrating properly in your head

    integral-of-triangle-png.png

    Intuitively,

    So long as your top trace is positive, ie above the abscissa, integration proceeds upward so bottom trace should have positive slope for entire first, third, fifth half cycles of top trace, and negative slope for the even ones. You've reversed slopes in the wrong place.

    Bottom trace should have zero slope directly under top one's zero crossings not under its peaks.

    Bottom trace's maxima and minima should lie underneath top one's zero crossings because zero crossings demark the end of an integration period that went in one direction..

    In that picture i'd expect bottom trace to never get below zero - it integrates up for a half cycle then back down for another half cycle. It should swing between zero and some positive value, just like transformer inrush .

    Next look at Fourier transform of a triangle wave

    for some reason system refuses to show the wikipedia link ipasted it in four times.
    Look for wikipedia triangle wave
    https://en.wikipedia.org/wiki/Triangle_wave


    upload_2017-8-26_15-32-7.png
    Fundamental plus odd harmonics.....


    Much easier approach using Fourier

    Integration can be thought of as low pass filtering. It attenuates not removes higher harmonics.
    So integrating once attenuates harmonics, integrating again attenuates them more. As you cascade stages of integration and attenuate the harmonics you approach just the fundamental which would be a pure sine wave.
    Apparently some people are happy enough with two stages to claim it's a sine wave. Really it only resembles one.

    Then there's the practical problem of keeping an integrator zeroed - it'll integrate its offset error and eventually saturate.
    So if you build one use a low pass filters instead of integrators. Signal after each successive stage will more closely resemble a sinewave. After just a few your eye will be unable to detect the difference.

    Would be interesting to see what the ear picks up ?
     
    Last edited: Aug 26, 2017
  14. Aug 27, 2017 #13
    Thanks for the reply Jim!

    That is extremely frustrating when the machine won't comply.

    Yes, yes, a thousand times: of course!

    Is this more accurate:
    abscissa.png
    Sorry it's a pretty rubbish drawing, but hopefully you get the picture.

    Jim, to get you up to speed, we were previously discussing the result of the integration as being that of a parabola section.

    But the result of the above picture doesn't look much like a parabola to me because it exponentially rises and falls sharply after the gradual rises and falls, which makes it look not quite smooth at the point where the triangular wave crosses the axis. Is this a fair representation?

    I STILL think this would be described by:

    Anyway, what I was getting at before in my last post was: To find the parabola you'd integrate the triangular wave from x-axis [0] to x-axis [2π].
    Say we were integrating this triangular wave; since y = mx + b for a line; I think it would be something like:

    0π mx + b dx - ∫π mx + b dx = [mx2 + bx - mx2 + bx ]
    Correct?

    Is this a fair description of a parabolic wave?

    That is very interesting that it is the a fourier series, so I suppose that means it isn't really like a parabolic wave? (due to aforementioned reasons and harmonics)

    I might explore this further for fun; if you integrated this one more time, in your opinion would you be able to see the difference between this an a pure sin wave?

    Thanks !
     
    Last edited: Aug 27, 2017
  15. Aug 27, 2017 #14

    jim hardy

    User Avatar
    Science Advisor
    Gold Member
    2016 Award

    Why not just integrate from 0 to pi, a half cycle make that 0 to pi/4, a quarter cycle ??
    Symmetry says next one is just its mirror image.
    if
    y = ax
    ∫y = ax2/2
    and it's going to be some conic section.

    I'm not too sure about integrating discontinuous functions anyway isn't that a ground rule ?
    Intuitively an ellipse looks continuous a parabola does not.

    But you can integrate a triangle wave's Fourier series term by term
    https://ocw.mit.edu/courses/mathema...on-fourier-series/MIT18_03SCF11_s22_4text.pdf
    upload_2017-8-27_10-11-47.png

    Integrate that twice !
    I'll wager the denominators get bigger, representing suppressed harmonics . If so intuition is confirmed.
     
    Last edited: Aug 27, 2017
  16. Aug 27, 2017 #15

    jim hardy

    User Avatar
    Science Advisor
    Gold Member
    2016 Award

    here i cut and pasted together four y = x2 segments
    used Paint to snip, flip and connect them
    just to see how much y=x2 looks like a ¼ cycle of a sinewave ...
    then i drew a triangle underneath just to relate it to what you're doing in this thread. .
    integratedtriangle4tim9k.jpg

    Not bad. eh ? You could peddle that as a sinewave but it's not.
    I wonder what another integration would do? y = x3 ?

    g-mat-graph-dia04.gif

    Got a graphing program ? Plot all 3 over first quadrant and see how close they come.
    In my younger days i'd have done a longhand least-squares fit....


    old jim
     
    Last edited: Aug 27, 2017
  17. Aug 28, 2017 #16
    I need to get matlab again, maybe there are free graphing programmes on the net. Because I'm not quite sure how your #14 Example 2. is a sawtooth wave, so I'll need to graph it to believe it (and the harmonics). I get that it's f(t) = t for the region -π to π, but I don't see how this is repeating.

    Okay, so the drawing I made in #13 was not quite good enough.
    You did an excellent job of cutting and pasting the x2's. It does look much more like a sine wave than I thought.

    Honestly, I forgot about the denominators, that's how rusty my basic maths is, but yes, the denominators would grow with successive integrations.

    What I am still confused about, is that I'm interpretation what you said as to mean that the conical section wave (which is being generated from the triangular wave), IS the same as a Sine wave, but it's a Sinusoidal fundamental WITH harmonics. So a parabola = a circle part + harmonic?

    Does this mean that some signal generator (or whatever device) which generates sine waves by this integral method, would just use a DC offset, to push the bottom half of the wave below the X-axis?

    Sorry (very rushed post), thanks again!
     
  18. Aug 29, 2017 #17

    jim hardy

    User Avatar
    Science Advisor
    Gold Member
    2016 Award

    no, i dont think i said that.

    Quadratics describe conic sections
    https://en.wikipedia.org/wiki/Conic_section
    300px-Conic_Sections.svg.png

    upload_2017-8-29_1-16-18.png

    Conic sections are curved as is sine but i do not believe any simple quadratic describes a sine.
    If it did the Taylor series for sine would be much simpler
    upload_2017-8-29_0-55-19.png
    http://people.math.sc.edu/girardi/m142/handouts/10sTaylorPolySeries.pdf
    that doesn't look like the formula for a parabola.

    I graphically pieced together segments of y=X2 which is curved and it indeed resembles a sine wave but is not one.


    More likely it'd use DC feedback to force the output to be centered at zero. You have to do that with analog integrators, actively zero them ..
     
  19. Sep 4, 2017 #18
    Let go of mathematics and move to literature because very little math serves real life
     
  20. Sep 8, 2017 #19
    Hi Jim, sorry I took so long to reply; hopefully I'll be more active on PF this coming week.

    Yes I think you're right, that 'x' being squared as well as the 'y', makes all the difference in distinguishing a circle from a quadratic [parabola]. I suppose what I was remiss in was that any wave can be expressed as a series of sine components, but only a circle or sine wave can exist as only a sine wave. So the fact that a conical section wave has a sine component is irrelevant and insignificant compared to any other wave.

    Thanks

    Okay, first and foremost, it's maths. Secondly, I'm not sure I understand what you're getting at. Yeah quality humanist pursuits is just as important as anything else, but in quantity of production far less useful to mankind. Given that the minority of fiction writers, wanna-be philosophers, sociologists, artists, music and communication don't produce uplifting or useful, transcendent pieces of work. Today it seems to be mostly this post-modern rubbish. [Because these fields have a low-bar and should be reserved for the Noam Chomsky, Bertrand Russell and Buckminster Fuller types, IMO.] However, quality engineering and science is quality, 100% of the time....And yes, it serves my real life every day.
     
  21. Sep 8, 2017 #20

    jim hardy

    User Avatar
    Science Advisor
    Gold Member
    2016 Award


    There does seem to be a lot of money in mediocrity - just look at the fortunes of Zuckerberg and Gates ...

    We need more Robert Pirsigs .

    old jim
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Simple double integration of square wave question
  1. A simple wave equation (Replies: 2)

Loading...