Mathematical question about sine and round waveform  - Page 1
Forum section: electronics / beginners

author: CaptDon
author_rank: Super Contributor
timestamp: November 18, 2023, 06:13:45 pm
content: So the traditional textbook example of a sinewave shows the mathematical progression of the individual points and I understand the calculations. Now picture if you can if I place a bowl with a center line intersecting it and draw a perfect half round line above the centerline the slide the bowl to the right by its own width and draw the perfect half circle under the centerline so it looks like a rounded sinewave. First question, is there a mathematical formula or calculation that predicts this waveform? Second question, I know a sinewave on the 'Y' channel of my scope and the same sinewave shifted by 90 degrees applied to the 'X' channel of my scope will display a circle but suppose I use the 'rounded' waveform applied to the scope in the same manner, what pattern would it draw?? I know a linear progression up and down is a triangle wave but I am not sure what progression would create the 'rounded' version of a sinewave? Does that more rounded waveform exist naturally in nature or electronic circuits? Thanks for any ideas / formulas. Cheers mates!!

author: ejeffrey
author_rank: Super Contributor
timestamp: November 18, 2023, 06:27:32 pm
content: Do you just mean alternating semicircles? Yes there is a formula for that. It's just defined piecewise using the the equation of a circle.Does it "exist in nature"? Not sure what that means but as something like v(t), it has infinite dv/dt so probably not.

author: CaptDon
author_rank: Super Contributor
timestamp: November 18, 2023, 06:37:27 pm
content: Yes, alternating semicircles would be the perfect description!! Sorry for not thinking of that. We know that most electrical circuits can be predicted using the math associated with sinewaves (sine/cosine functions) but I was wondering about the math related to the alternating semicircles? would that describe something any natural phenomena such as ocean waves or maybe orbits although I guess most orbits tend to be oblong except maybe planetary gears. Was also curious what the waveform would look like on a scope if the semicircle waveform was shifted 90 degrees and applied equally to the X and Y channel of the scope? We know a true sinewave will produce a circle.

author: IanB
author_rank: Super Contributor
timestamp: November 18, 2023, 06:50:45 pm
content: It's an interesting question.No, an alternating semi-circle does not occur naturally in nature. It is not a "natural" shape, oddly enough.I don't now what shape it would produce if plotted. Some kind of rounded square I would imagine.

author: ejeffrey
author_rank: Super Contributor
timestamp: November 18, 2023, 07:08:40 pm
content: You should be able to plot it out pretty easily, but if would look considerably more squareish on a scope in XY mode.

author: MarkT
author_rank: Frequent Contributor
timestamp: November 18, 2023, 07:58:54 pm
content: Just the segment from -a to +a is √(a^2 - x^2), where a is the equivalent of 90 degrees. You'd have to define the full waveform as an infinite piece-wise sum which is pretty horrible. That and it not being differentiable (and thus non-physical).Orbits oblong? Elliptical surely?

author: Nominal Animal
author_rank: Super Contributor
timestamp: November 18, 2023, 08:36:07 pm
content: The exact function for a single half-circle of radius \$r\$ around \$x = x_0\$ is$$f(x) = \sqrt{ r^2 - (x - x_0)^2 } = \sqrt{ r^2 + x_0^2 + 2 x_0 x - x^2 }$$For the first half period of a sine wave, \$0 \le x \le \pi\$, the matching half-ellipse wave simplifies to$$f(x) = \frac{2}{\pi} \sqrt{ x ( \pi - x ) } = \sin\biggl(\arccos\left(\frac{2 x}{\pi} - 1\right)\biggr)$$having been scaled to height 1, width \$\pi\$. To make that repeat, you'll need to wrap \$x\$ to half-open range \$[0, \pi)\$ and negate it every other half-wave.Powers of sine,$$f(x) = \operatorname{sgn}\bigl(\sin(x)\bigr) \, \left\lvert \sin(x) \right\rvert^\lambda, \quad \operatorname{sgn}\bigl(\chi\bigr) = \begin{cases}+1, & \chi \gt 0 \\0, & \chi = 0 \\-1, & \chi \lt 0 \\\end{cases}$$can approximate this, with \$\lambda = 0.45\$ minimizing the absolute error (to a bit over 0.0133). As \$\lambda\$ decreases towards zero, the curve fills out, so that at values close to zero it approximates a square wave. As \$\lambda\$ increases above 1, it becomes a sequence of pulses at \$\pi\$ intervals, the narrower the pulse the larger \$\lambda\$ is.

author: Anthocyanina
author_rank: Frequent Contributor
timestamp: November 18, 2023, 08:37:09 pm
content: I quickly made a 400 point arb waveform using the circle equation. in the first image you can see what it looks like when plotted against the linear increase of X, looking like a circle, and when plotted against what would be time, looking like the rounded waveform you were asking about. and in the other images, you can see the waveform on the analog discovery, in XY mode against a 90° shifted version of itself, and against a linear ramp as was used in the spreadsheet to make it.

author: CaptDon
author_rank: Super Contributor
timestamp: November 18, 2023, 08:52:51 pm
content: Very very nice!!! Thanks all for the descriptive formulas and especially the plots!!! The square with rounded corners, indeed, Somehow I pictured it perhaps looking that way as I was driving to Lowe's today to get some materials to finish a speaker cabinet build. The math is way over my head but in my 'minds eye' I was trying to picture how the vectors would add and I indeed thought about the square with rounded corners. I have MatLab on my workhorse laptop and looking at the formulas provided in the post maybe I can re-create the plots! Again, many thanks!! I have recently started playing about with C++ and equations and somehow the concept of repeating semi-circles popped into my brain!!

author: EPAIII
author_rank: Super Contributor
timestamp: November 19, 2023, 03:23:57 am
content: The funny thing about things that "are not in nature" is, once we are aware of them, someone finds them in nature. Nature is more diverse than we will ever know or ever can know.I was starting to suspect the rounded square after about 4 or 5 points roughly plotted, Lincoln style on the back of an envelope.

author: golden_labels
author_rank: Super Contributor
timestamp: November 19, 2023, 04:14:46 am
content: Sinusoids are a mathematical description of a basic phenomenon: oscillation. That’s why they’re so widespread.(1)Not only simple oscillations, like in a spring with a weight. Often sums of these in multiple dimensions.One example is circular motion. It may be decomposed into two dimensions. As the angle increases, each of them sees a sinusoid. While combined, they appear as a circle.(2)This can be used to derive your semicircular curve equation!Start by looking at a quarter of a circle. For simplicity I assume the radius is 1:This gives us equations:x = cos(φ)y = sin(φ)Our goal is to find a function, which maps cos(φ) (thexcoördinate) tosin(φ)(theycoördinate). That is:f(x) = sin(φ).From the equations above we already know, what’s the relationship betweenxandφ:x = cos(φ)arccos(x) = φSubstituting, we get the same result as Nominal Animal:f(x) = sin(arccos(φ))(1)I want to avoid putting too much maths into this post, but it’s worth noting, that sinusoids are just a special case of something even more basic: exponential growth (in complex numbers). This makes their ubiquity even more obvious.(2)Strictly speaking it’s a spiral around φ axis. We get a circle, if we look along the axis.

author: Nominal Animal
author_rank: Super Contributor
timestamp: November 19, 2023, 02:19:54 pm
content: Yup. Similarly, we get \$y = \pm\sqrt{r^2 - x^2}\$ for a circle of radius \$r\$ around origin, because \$x^2 + y^2 = r^2\$, and therefore \$y^2 = r^2 - x^2\$.For the generic \$x^\lambda + y^\lambda = r^\lambda\$ (or same ignoring signs, \$\left\lvert x \right\rvert^\lambda + \left\lvert y \right\rvert^\lambda = r^\lambda\$), we get$$y = \pm \left( r^\lambda - \left\lvert x \right\rvert^\lambda \right)^{\frac{1}{\lambda}}, \quad -r \le x \le +r$$and centered on \$(x_0, y_0)\$ we get$$y = y_0 \pm \left( r^\lambda - \left\lvert x - x_0 \right\rvert^\lambda \right)^{\frac{1}{\lambda}}, \quad x_0 - r \le x \le x_0 + r$$For \$\lambda = 2\$, you get a circle.For \$\lambda \gt 2\$, you get an axis-aligned rounded rectangle.For \$\lambda = 1\$, you get a "diamond", a parallelogram, with vertices forming an axis-aligned +.For \$1 \lt \lambda \lt 2\$, you get a rounded diamond or a rounded parallelogram.For \$0 \lt \lambda \lt 1\$, you get a four-pointed rounded star.These generalize to three dimensions (with \$r\$ denoting anisosurface) with one or more points asmetaballs, which are extremely useful for blobby stuff and what was once called "plasma" in demos. (For example, if you have some programmable RGB leds, you can use a 3D space with colored metaballs, and only have to evaluate the metaball functions at the location of each LED, moving the metaball components around in the same space, usually cyclically or rotating them. RGB color model gives additive results, butYCbCrcolor space can make really nice psychedelic effects, with about a dozen additional multiplications and additions per led. Also makes for more realistic flames than array-based plasma.)

author: golden_labels
author_rank: Super Contributor
timestamp: November 20, 2023, 08:01:19 am
content: I forgot to comment on obtaining this curve in practice and its presence in nature.This curve can never exist in our physical reality. It may be only approximated. The limitation is “mathematical”, not arising from imperfections of our world. The problem is with the points, where the curve crosses 0. Its rate of change at these exact spots is infinite.To see why without using algebra,(1)put a tangent line somewhere on that curve. Then slowly shift it towards the zero-crossing point. When the line touches this point, it is vertical. That line represents the rate of change and it being vertical indicates things must change infinitely fast.(1)Using algebra and calculus, the first derivative is-x/sqrt(1-x2). As this curve approaches ±1, it goes to ∓∞. The tall attachment shows it in orange.

author: MrAl
author_rank: Super Contributor
timestamp: November 20, 2023, 09:44:38 am
content: Quote from: CaptDon on November 18, 2023, 06:13:45 pmHello there,If by 90 degees you mean a 1/4 circle and you apply one quarter to the X channel and the shifted other 1/4 to the Y channel then you get this on the scope. Radii are both 2. It looks like a very good knee curve. This kind of plot is sometimes called parametric.You can easily imagine if you plot the entire thing you would get a rounded corner square with very rounded corners as you can see. This may be similar to a squircle. It may also be possible to modify the phase slightly so we get a four pointed star or four cusp hypocycloid also known as an astroid.Squircle:

author: AndyBeez
author_rank: Frequent Contributor
timestamp: November 20, 2023, 10:11:17 am
content: Maybe this is not strictly 'in phase' with the OP's post but... Nature does make some interesting waveforms in the field of doppler spectroscopy, which is regularly used to detect exosolar planets, by measuring the variation in the radial velocity of a star's light curve.https://en.m.wikipedia.org/wiki/Doppler_spectroscopyAnd for you astrophysics fanboys, further down the rabbit hole, measuring the radial velocities of binary star systems.https://phys.libretexts.org/Bookshelves/Astronomy__Cosmology/Celestial_Mechanics_(Tatum)/18%3A_Spectroscopic_Binary_Stars#:~:text=By%20measuring%20the%20change%20in,some%20of%20the%20orbital%20characteristics.So somewhere out in the galaxy, there must potentially be the Squircle System.

author: armandine2
author_rank: Frequent Contributor
timestamp: November 20, 2023, 01:25:07 pm
content: Quote from: Anthocyanina on November 18, 2023, 08:37:09 pmnot too quickly

author: RoGeorge
author_rank: Super Contributor
timestamp: November 20, 2023, 06:10:32 pm
content: I was curious about the Lissajous between sinusoidal and semicircles. Two of the sides of the "rounded square" become more curved, reminds of the shape of CRT tubes in the old TVs.It's funny when some phase shift is added (by dragging the 'b' slider). At some point, it looks a lot like a magnetic hysteresis curve.Geogebra can share live plots online, should work in most current browsers:https://www.geogebra.org/calculator/u8cwg8xuThe 'A' slider is for amplitude, 'b' slider is to add a phase shift between sinus and semicircles, should update the figures live in the web browser. Has animation, too, by right-clicking on a slider, then 'Animation'.

author: MrAl
author_rank: Super Contributor
timestamp: November 20, 2023, 08:59:29 pm
content: Here is the cartesian solution for the circle 0 degrees + circle 90 degrees, upper section, radius =2 (squarish circle):y=sqrt(4*sqrt(4-x^2)+x^2-4)