1

I am trying to plot a triangle function that linearly increases in amplitude and decreases in frequency.

Sketch of what I am looking to do

The purpose is to use it in Fusion 360 sketching, but I want to plot it either on my Ti-84 or in Desmos to get the point coordinates of each peak. But that's beside the point. I really just want to know the formula that can allow me to achieve this. I think it would be more helpful to others coming across this to keep it general rather than to find a specific way that works with my end purpose.

I got as far as $$x\arcsin\left(\sin\left(x\right)\right)$$ but I don't know how to decrease its frequency while keeping it as a triangle function.

Thank you.

John Alexiou
  • 13,816
  • There's no reason to try to make the function into a neat mathematical formula. It would be enough to have a mathematical formula for where each cycle begins, and define the function piecewise between those points. Presumably your programming language has user defined functions, so you can hide all the mess inside your own function definition. – David K Dec 25 '23 at 15:38
  • The software does not have a programming language in the area of the software where I'm trying to use this. – J. Tanin Dec 25 '23 at 16:33
  • Can you include a sketch of what you're looking for exactly? It will help tremendously. – Cameron Williams Dec 25 '23 at 16:45
  • In addition to the sketch, I would advise describing your software more explicitly. If it's generally available software, tell us its name. If it's your professor's private project that nobody else has access to, show how the interface works. – David K Dec 25 '23 at 16:48
  • I just want to know a formula that will give me the result I want. Besides, the more specific to a specific software the question is, the less useful this question will be to others that come across it. I found nothing anywhere on the internet about how to do this. – J. Tanin Dec 25 '23 at 17:01
  • 1
    "I just want to know a formula that will give me the result I want." Unfortunately, if you cannot precisely describe exactly what you want, there is little likelihood that we are going to be able to help. And once you have precisely described what it is that you want, you likely have enough of a description to give to a computer. – Xander Henderson Dec 25 '23 at 17:03
  • I have described it as accurately as I could. I have limited vocabulary sorry. I have already included a sketch.

    "And once you have precisely described what it is that you want, you likely have enough of a description to give to a computer."

    That's why I'm here. I can't do it by myself.

    – J. Tanin Dec 25 '23 at 17:04
  • How about something close to what you're looking for with $x\arcsin(\sin(x^2))$ and variations thereof? – Cameron Williams Dec 26 '23 at 06:40
  • @CameronWilliams I played around with ideas like that. They seem to produce curved segments of the function. I gave up on that idea after OP posted the figure showing straight lines. – David K Dec 26 '23 at 17:42
  • The question is much improved now that you have described some of the places you want to use it. – David K Dec 26 '23 at 21:04
  • Now we have some specific requirements to check, I may want to update my answer. – David K Dec 26 '23 at 21:05

1 Answers1

2

I'm not familiar with Fusion 360, so I cannot say if this is the best approach to creating such a graph there, but I enjoyed working on this problem as a puzzle.

A formula like the one below makes a graph that looks like yours. You didn't specify the slopes of any of your lines, so I let $a$ be the ratio between successive crossings of the $x$ axis and let $\pm b$ be the slope of the function. The two straight lines that bound the function then have slope $\pm b\frac{a-1}{a+1}$.

$$ f(x) = b(-1)^{\left\lfloor \Large\frac{\ln\left(2ax\right)-\ln(a+1)}{\ln(a)} \right\rfloor} \left(x - a^{\left\lfloor \Large\frac{\ln\left(2ax\right)-\ln(a+1)}{\ln(a)} \right\rfloor}\right). $$

See this graph for a demonstration. (The function there uses a third parameter, $c$, in its definition, but if you set $c = 1$ then you get the formula above.)

As it happens, in Desmos you can define your own functions, so a somewhat less repetitive way to write $f(x)$ is as follows:

\begin{align} k(x) &= \left\lfloor\frac{\ln\left(2ax\right)-\ln(a+1)}{\ln(a)}\right\rfloor, \\ f(x) &= b(-1)^{k(x)} \left(x - a^{k(x)}\right). \end{align}


Some notes about how these equations work:

The graph of the function $f(x)$ relates to a sequence of similar isosceles triangles with their bases along the $x$ axis, alternating above the axis and below the axis, such that the two equal legs of each triangle form the graph of $f(x)$. Because all the triangles are similar (with the same angles), the legs of each triangle above the axis are collinear with the legs of the adjacent triangles below the axis, and so you get your straight lines from trough to peak to trough.

The triangle formed by each linear segment of the function and the two bounding lines (green in your figure) is also similar to the triangle formed by any of the other linear segments of the function and the same two lines. This implies that the linear sizes of this sequence of triangles are in a geometric progression (see this answer). It follows that the $x$-intercepts of $f(x)$ are in geometric progression and the sizes of the isosceles triangles are in geometric progression.

Suppose the axis crossings of $f(x)$ occur at $\ldots, \frac1{a^2}, \frac1a, 1, a, a^2, a^3, \ldots .$ Since the local minima and local maxima of the function are vertices of the aforementioned isosceles triangles, their $x$ coordinates are exactly halfway between the nearest $x$-intercepts, so they occur at $\ldots, \frac12\left(\frac1{a^2} + \frac1a\right), \frac12\left(\frac1a + 1\right), \frac12\left(1 + a\right), \frac12\left(a + a^2\right), \frac12\left(a^2 + a^3\right), \ldots .$ The $y$ coordinates of these points can be found by applying the rise/run definition of the slope of $f(x)$ using a run equal to half the base of the relevant isosceles triangle. If we assume the slope of $f(x)$ is $b$ at $x = 1$, then the graph of $f(x)$ goes straight from $(x,y) = (1,0)$ to $(x,y) = \left(\frac{a + 1}2, b\frac{a - 1}2\right),$ a local maximum.

The rest of the local maxima and minima are found by multiplying or dividing these coordinates by $a$ repeatedly and alternating the signs of the $y$ coordinates, so we have \begin{multline} \ldots, \left(\frac{a + 1}{2a^2}, b\frac{a - 1}{2a^2}\right), \left(\frac{a + 1}{2a}, -b\frac{a - 1}{2a}\right), \left(\frac{a + 1}2, b\frac{a - 1}2\right),\\ \left(a\frac{a + 1}{2}, -ab\frac{a - 1}{2}\right), \left(a^2\frac{a + 1}2, a^2b\frac{a - 1}2\right), \ldots . \end{multline}

This is also how we know that the line through all the maxima has slope $b\frac{a - 1}{a + 1}$ and the slope through the minima has slope $-b\frac{a - 1}{a + 1}$.

If you don't want the $f(x)$ to have an $x$-intercept at $x = 1$, pick an $x$-intercept you do want, let $x = c$ be that intercept, and scale all the coordinates in the list by $c$.

The bizarre function $k(x) = \left\lfloor\frac{\ln\left(2ax\right)-\ln(a+1)}{\ln(a)}\right\rfloor$ serves the purpose of telling us which segment of $f(x)$ any given value of $x$ belongs to. For any $x$ in the interval from $\frac{a + 1}2 a^{n-1}$ to $\frac{a + 1}2 a^n$, $k(x)$ evaluates to $n$ and $a^n$ is the $x$-intercept in that interval. Then $y = \left(x - a^{k(x)}\right)$ is the equation of a line through the desired $x$-intercept at $\left(a^n, 0\right)$, and $b(-1)^{k(x)}$ gives the desired slope of the line, alternating positive and negative for even and odd values of $n$.

David K
  • 98,388