Trigonometric function graph

56 Views Asked by At

I tried to tweak a trigonometric function in Wolframalpha to kinda transform the sin function into a rounded square function. Please see screenshot here: Wolframaplpha graph.

First function looks good for y=1, but I'd prefer to have a higher slope for y=0, just as the second function is.

Is there an elegant formula to achieve that with a periodic function , like sin?

Cheers!

3

There are 3 best solutions below

1
On

Here's the Fourier synthesis of an unnormalized square wave, cut off at term $n$. Adjust $n$ to your needs.

$f(x) = \sum\limits_{i=1, 3, 5 \ldots}^n {1 \over i} \sin (i x)$

unnormalized rounded square

0
On

A Fourier series will work here, it is a linear combination of individual sin functions with different periods and amplitudes. For example, for the square function

$$ f(x) = \frac{4}{\pi}\sum_{k = 0}^{+\infty}\frac{1}{2 k + 1}\sin\left((2k + 1)\frac{x}{2}\right) $$

If you truncate the series at a given $k$ you will be successively better approximations, here's a graph

enter image description here

0
On

I have found the answer. First, I was thinking why is 1.8 so special, but realized it is close to pi/2, so I've changed 1.8 to pi/2. Then, I thought I should try sin(sin(sin(x)...

Here's the graph: https://www.wolframalpha.com/input/?i=plot+sin(sin(x)*pi%2F2)+plot+sin(sin(sin(x)*pi%2F2)*pi%2F2)