6
$\begingroup$

I've been trying to find the formula for the offset/parallel to a sine wave. Not just the parametric equation, but the y = f(x) form.

Here's what I've done so far: Read up on the parametric form and plugged in the x(t) and y(t) formulas. What I get is of course a parametric equation in terms of t.

If $$ y=\sin(x) $$

then the parameterization would be $$ x=t $$ $$ y=\sin(t) $$

Plugging in the offset formula:

$$ x_d(t) = t + \frac{d \cos (t)}{\sqrt {1 + \cos (t)^2}} $$

$$ y_d(t) = \sin (t) - \frac{d}{\sqrt {1 + \cos (t)^2}} $$

Now, that's all accurate, but it doesn't put it into a function form. According to my calculus book, the next step is to solve each of these for t and then set them equal to one another. The problem is that they are kind of a mess, with those sinusoidal functions involved.

My question is: Can Mathematica find the y = f(x) form for an offset curve of a sine wave?

A little background: I need this because I'm trying to find the intersection point when 3 offsets of three PI/3-out-of-phase to each other sine waves intersect. Basically where the green, blue and red intersect at the same time in the link below. I can find it numerically, but I'd like it exactly because it's something of discovery to find out how the ancient people drew braids using just compass and straight edges.

I can draw it no problem in C#: The intersection point was found using trial and error and is approximately 0.63. There are two blue lines, two red lines and two green lines, because I used +0.63 offset and -0.63 offset from the sine wave.

http://postimg.org/image/un06qseiv/

http://s10.postimg.org/jn8jvl095/braid_colored_in.jpg

Thank you in advance for any help.

$\endgroup$
4
  • $\begingroup$ Can you expand a bit on what you mean by "an offset curve of a sine wave"? To me that sounds like it should be a sine wave that's shifted up & over by some amount(s). But the curves $x_d$ and $y_d$ that you've given us are most assuredly not sine waves (try using ParametricPlot to graph the curve for $d = 1$, for example.) $\endgroup$ Mar 1, 2016 at 17:29
  • 1
    $\begingroup$ By offset, I mean a fixed distance from one side of the sine wave. It's definitely not a shift. Wikipedia's page does a good write-up. en.wikipedia.org/wiki/Parallel_curve. I'm looking for the formula in y=f(x) form and then when I have it, I want to find the intersections. Yes the parametric formula isn't one of a sine wave. It's for the parallel curve. But I want the y=f(x) equivalent of the parametric equations. $\endgroup$ Mar 1, 2016 at 17:46
  • $\begingroup$ Gotcha. You have an error in your formula for $y_d$, BTW — it should have a minus sign in it. $\endgroup$ Mar 1, 2016 at 18:02
  • $\begingroup$ Thank you Michael. I corrected that. $\endgroup$ Mar 1, 2016 at 20:08

2 Answers 2

11
$\begingroup$

I suspect that there simply isn't a nice equation of the form $y = f(x)$ for these curves. As you note the equation for $x_d$ involves both algebraic and trigonometric terms, and almost all such equations are transcendental (i.e., no solution in the form of "elementary functions".)

Mathematica can, however, construct inverse functions that it can use internally to give numerical results. The syntax would be as follows:

xd[t_, d_] = t + d Cos[t]/Sqrt[1 + Cos[t]^2];
yd[t_, d_] = Sin[t] - d 1/Sqrt[1 + Cos[t]^2];
yx[x_, d_] := yd[InverseFunction[Function[{a, b}, xd[a, b]], 1, 2][x, d], d];

(Note the minus sign in the definition of $y_d$, which I'm pretty sure should be there.) You can then plot these curves:

Plot[{Sin[x], yx[x, 0.9], yx[x, -0.9]}, {x, -5, 5}, AspectRatio -> Automatic]

enter image description here

Or you can apply Mathematica's numerical root-finding algorithms to them:

root = FindRoot[Cos[x] == yx[x, 0.9], {x, 1}]
Cos[x /. root]
Plot[{Cos[x], yx[x, 0.9]}, {x, 0, 3}, Epilog -> {PointSize[Large], Red, Point[{x, Cos[x]} /. root]}]

(* {1.49089, 0.0798206} *)

enter image description here

$\endgroup$
5
  • $\begingroup$ Thank you very much. Basically, I'm re-assured now there is no easy formula, it's transcendental, and so I should rely on numerical, rather than exact solutions, which are just as good of course. After doing this problem, now I'm seeing braids everywhere: youtube.com/watch?v=tqVrAFFovNM $\endgroup$ Mar 1, 2016 at 20:18
  • 2
    $\begingroup$ For values of $d$ greater than a critical value, the parallels aren't even functions… $\endgroup$ Mar 2, 2016 at 3:31
  • $\begingroup$ @J.M.: I noticed that too. I think the critical value is $d = 1$, since then $x'_d(t)$ becomes negative in the region around $t = \pi/2$. $\endgroup$ Mar 2, 2016 at 14:47
  • $\begingroup$ Yes, that's an interesting aspect of many offset/parallel curves. They are extremely useful when using a computer controlled wood cutting router. The cutting tool spins, making a round cutting effect. If you have a 1 inch cutter, you can't do detail work if you want to cut an inner radius of 1/2 an inch. Thus you get the discontinuities. So, I suppose in this sin(x) example, the biggest circle you can place inside a sine wave has a diameter of 1. $\endgroup$ Mar 2, 2016 at 16:16
  • $\begingroup$ Reminiscent of Jacobi elliptic function $cn (z)$ $\endgroup$ Jul 17, 2016 at 19:39
4
$\begingroup$

You may also find the intersection of parametric curves by working directly on their parametric representation instead of finding explicit functions. For example, finding the intersection points (assumed to be isolated) of two curves defined by the tuples $(x_1(t),y_1(t))$ and $(x_2(s),y_2(s))$, $t, s\in \mathbb{R}$, is equivalent to finding pairs of $t_k$, $s_k$ such that $x_1(t_k)=x_2(s_k)$ and $y_1(t_k)=y_s(s_k)$.

Borrowing the example from @MichaelSeifert's answer,

sol = FindRoot[{s == t + 0.9 Cos[t]/Sqrt[1 + Cos[t]^2], 
                Cos[s] == Sin[t] - 0.9 1/Sqrt[1 + Cos[t]^2]}, {{t, 0.}, {s, 0.}}]
{s, Cos[s]} /. sol
{t -> 1.15159, s -> 1.49089}
{1.49089, 0.0798206}
$\endgroup$
1
  • $\begingroup$ If the intersection points are all that are needed, this is probably a better approach than mine; in particular, it can (in principle) find intersection points between parametric curves for which there isn't a well-defined function $y(x)$. $\endgroup$ Mar 2, 2016 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.