What equations graph these curves?
June 12, 2019 4:44 PM   Subscribe

I've got three curves that I'd love to find equations for, if such exist. I've done some research on the Internet but everything I find is talking way over my head. I got up through trigonometry in high school, but that was probably the miracle of teacher apathy during grading. So, do you know what equations graph these three curves? (Okay, one is straight lines, but that's still a curve for these purposes, isn't it?)

Here's a graphic with the curves - well, actually points along the curves.

They're all symmetrical across the vertical axis. If that makes it problematic I'd settle for an equation for one half of the curve.

Alternatively, do you have any links to resources that discuss this kind of thing for people who are not that advanced at math(s)?
posted by under_petticoat_rule to Science & Nature (18 answers total) 3 users marked this as a favorite
 
#1 is an absolute-value curve, probably of the form:
y=a-(|x-b|)
(a and b control where the point of the V sits on your graph, and which direction it points.)

#2 might be some sort of parabola:
y=a(x-b)2+c
(a, b and c control various aspects of the curve.)

#3 might be a normal-distribution curve, but that's beyond my Wolfram Alpha skill.
posted by spacewrench at 4:56 PM on June 12, 2019 [2 favorites]


It's been a long time since I've had to do any of this but here goes my best shot:

The first one looks like y = absolute value of x, which would be upwards facing and centred at 0,0. To make it downwards facing you make it y = - absolute value of x and to move the centre up you just add 5 so y = 5 - absolute value of x.

The second one looks like a semi-circle to me. The general equation for a circle is x^2 + y^2 = r^2 where r is the radius of the circle you're making. If your circle has a radius of 5 then it would be x^2 + y^2 = 25. You only want positive values of y so you would want y = square root of (25 - x^2). The bottom half of the semi-circle would be y = - square root of (25 - x^2)

The third one could be part of a sine curve so would be of the form y = sin (x). I don't remember how to adjust the curve to match your points in the graph though.

For all of these I am assuming that the bottom of each graph is at y=0 and that the line in the middle is x=0. If that isn't the case you'd have to add or subtract some constant to shift them to the right place.
posted by any portmanteau in a storm at 5:06 PM on June 12, 2019


Second one is a semicircle. Third one I was ready to assume was a normal (Gauss) probability distribution, but it does look like a cosine (cosine 0=1, but the shape is just like a sine curve, just shifted).

If each square is 5, then it’s be like
y=2.5 cos(pi*x/5)+2.5
I’m not as sure on the scaling factor inside the parentheses. But if it’s a cosine or a sine wave, it will repeat.
posted by Huffy Puffy at 5:24 PM on June 12, 2019


As far as general resources are concerned the one I can think of is Khan Academy. I haven't used it myself because I'm too old and my kids are too young but it looks like they cover sine functions and conic sections (which is what a circle is).
posted by any portmanteau in a storm at 5:36 PM on June 12, 2019


Best answer: I made a Desmos worksheet with curves similar to your first and last one. You can move the sliders to observe the effect of each numerical parameter.
posted by aws17576 at 5:42 PM on June 12, 2019 [5 favorites]


(I didn't include the middle curve because I'm not sure what it is -- the dots aren't in precisely the right places for it to be a semicircle, though they are close. It's definitely not a parabola.)
posted by aws17576 at 5:46 PM on June 12, 2019


I think the answer to this depends on what you want the equations to the curves for. Do you want to print something? Do you want the party trick of being able to rattle off functions about your needlepoint pillow in both rectangular and polar coordinates?

If you search for 'fit equation to points', that will get you information about statistics ("regression"), which is probably why it seems so wild and irrelevant.
posted by batter_my_heart at 10:48 PM on June 12, 2019


Best answer: Oooh, Desmos is a nice tool! Thanks, aws17576.

I tweaked aws17576's parameters a little to centre the vertical axis as specified, and added a semicircle because that's what the second curve looks like to me. Results here.
posted by flabdablet at 2:53 AM on June 13, 2019


Another version with independent height and width sliders for the semicircle, allowing it to be tweaked into various kinds of half-ellipse.
posted by flabdablet at 3:07 AM on June 13, 2019


If a parabola or a circle isn't precise enough for the second one, you might be able to approximate it more precisely with a superellipse. Here it is in Desmos; n = 2 corresponds to a circle.
posted by Johnny Assay at 4:18 AM on June 13, 2019 [1 favorite]


Here's a graphic with the curves - well, actually points along the curves.

In order to settle the semicircle vs superellipse issue definitively (and I agree with Johnny Assay that a superellipse with n = 1.9 fits the graphic as presented better than a semicircle does) it would be helpful to know how those points were originally plotted.
posted by flabdablet at 4:47 AM on June 13, 2019


For the third, try y = 5 * exp (-(x/3)^2) for x = [-5,5].
posted by disconnect at 5:44 AM on June 13, 2019


Best answer: I'm a mathematician. It's not entirely clear to me what you're asking for; the root of the problem is that there are actually many different equations I could write down, all of which might be considered answers to your question. As others have noted, if we knew your goal then we could do a much better job of providing a *good* answer.

To be more specific:
- do you need the curve to go exactly through the points you plotted? If so, we would need to know what those points are. If not, then you need to specify in some other way how to know whether we've got a 'correct' curve or not.
- do you need the curve to have a relatively simple representation of the form y = f(x)? If not, then a cubic spline might be the best answer.

Without benefit of more detail, I'd guess:

The plots appear to be showing a few sample points, plotted at equally spaced x-intervals, taken from each of three simple functions.
- The first is probably absolute value of x, i.e. y = -|x| + 1
- The second is probably a semicircle, y = √(25 - x^2)
- The third is probably a cosine, y = cos(x) + 1

You haven't labeled the axes, so I assumed for each of them that y = 0 is the bottom of the figure and x = 0 is the middle of the figure.
posted by dbx at 9:36 AM on June 13, 2019


Best answer: I agree with dbx on the most likely basic versions of the functions for your points. To look at them in, say, WolframAlpha, you could type

plot y=cos(x) +1 from x = -Pi to Pi

plot y=Sqrt[1-x^2] from x = -1 to 1

plot y=-Abs[x]+1 from x = -1 to 1

(for a generic version), or if you wanted to get the scale in your picture assuming each of your grid points is 1 unit, you could type

plot y=3 cos(Pi x/6) +3 from x = -6 to 6
plot y = Sqrt[25 - x^2] from x = -5 to 5
plot y = -Abs[x] +5 from x = -5 to 5

(For example, the 3 in front of the cosine scales the function vertically, the Pi/6 inside the cosine scales the function horizontally (and makes the period of your cosine function be integers, not integer multiples of Pi), and the +3 shifts the function vertically. Here's a random worksheet that discusses shifting and scaling in more detail. Here, the original function is y = cos(x).)
posted by leahwrenn at 10:16 AM on June 13, 2019


Best answer: I think they are instances of Bézier curves, the kind you can create in drawing programs like inkscape. These curves can come close to the shapes of common curves like circular arcs, but generally can't match them exactly.

This svg document overlays your image with two bezier curves that very closely replicate the original plots.

In the first case, the curve starts at the peak, has a "control point" two units to the right, and ends at the right hand side with its "control point" three units up.

In the second case, the curve has a "control point" 2.5 units left/right from the endpoints.

You should be able to view this file in your browser (tested in firefox) or bring it into a vector editing program like inkscape.

This website will let you experiment with bezier curves; the links are my efforts at recreating the same curves there.
posted by the antecedent of that pronoun at 8:20 PM on June 13, 2019 [1 favorite]


Response by poster: These answers are all helpful and very interesting. It may be that there are no equations that match perfectly.

These are shapes in a feature of text layers in Adobe After Effects called Text Animators. The graphs were generated using a string of periods and applying the different available stock shapes to the y position value in the Text Animator applied to that string. You can move the shapes through the text to produce animation per character (or word, or line).

I'm trying to help colleagues understand that feature of After Effects better, so I'm trying to describe how the values applied to the characters in the affected text are calculated for the different shapes. Not necessarily in an iron-clad precise way, but just to explain basically what the program is doing behind the scenes to produce those values.

It's a bit tricky because the height depends on the maximum value the user specifies, and the width depends on a lot of factors such as how much of the text string is selected to be influenced, tracking, font size etc. So there's no fixed pure aspect ratio for those shapes, just a sort of gradient of some kind, which could either be some hard-coded value gradient that gets mapped over the affected area, or some equations that are applied. I'm thinking it must be equations because they appear to be able to be applied over a vast number of characters with no detectable loss of resolution.

You specify what contiguous subset of your text you want to include and a maximum value for the chosen property. The program treats everything inside the selection as getting up to 100% of the specified property value, multiplied by a number between 0 and 1 which is determined by the shape that is chosen.

The images show the Text Animator applied to the Position property of the characters, but it can be applied to any number of properties such as scale, opacity, rotation etc. It's a lot harder to visualize the influence of the different shapes on those properties though, so I'm trying to come up with a bit of "science" just to help people get an additional perspective on what's going on with that feature.
posted by under_petticoat_rule at 10:39 AM on June 14, 2019


Best answer: In that case, I agree with the antecedent of that pronoun and would be surprised to find that any of those curves are other than some variety of composite Bezier curve. The math for those is baked deep into PostScript, the original Adobe technology, and it would be surprising to find it not taken advantage of wherever possible in anything else they've ever made.
posted by flabdablet at 4:08 AM on June 15, 2019


Best answer: If you want to learn about the kinds of equation you encounter when working mathematically with Bézier curves, the term you want to search for is splines. A spline is a piecewise curve defined by multiple equations, each of which applies to only one of the pieces; for practical splines like Bézier curves, all of those equations are of the same kind (polynomials of degree 2 or 3, usually).

I'm not sure that you need to get this specific if your aim is just to explain to somebody else what After Effects is doing under the hood, though. I'd just say that it's using some surprisingly simple maths that can generate a wide variety of smoothly varying outputs and leave it at that; the plots you've already made are more than likely a better hook to hang an understanding on than a tour through the actual arithmetical operations they're based on.
posted by flabdablet at 5:55 AM on June 15, 2019


« Older Best books on US racism   |   Can you recommend some really good, long essays? Newer »
This thread is closed to new comments.