0
$\begingroup$

How can I plot this curve in Mathematica:

$\begin{align} x(t)&=\begin {cases} 2 (t-n+1) \: , \: t\in [n-1,n-1/2] \\ 2-2 (t-n+1) \: , \: t\in [n-1/2, n] \end {cases}\\ y(t)&=\begin {cases} 2 (\sqrt {2}t-n+1) \: , \: \sqrt {2} t\in [n-1,n-1/2] \\ 2-2 ( \sqrt {2} t-n+1) \: , \: \sqrt {2} t\in [n-1/2, n] \end {cases} \end{align}$

with $ n\in \mathbb{N} $

$\endgroup$
2
  • 3
    $\begingroup$ You've seen Mod[] already? $\endgroup$ Commented Nov 26, 2015 at 23:00
  • $\begingroup$ When posting code you should paste Mathematica code from your notebook as described here. $\endgroup$ Commented Nov 27, 2015 at 2:44

2 Answers 2

1
$\begingroup$

Since nobody followed up on my hint, here goes.

Noting that $y(t)=x(\sqrt 2 t)$, it suffices to define only $x(t)$.

A slight tweaking of the definition in the OP allows one to express the function in terms of Mod[]. However, it is actually more convenient to use QuotientRemainder[] instead, so I've employed it here:

x[t_] := Module[{nm, r}, {nm, r} = QuotientRemainder[t, 1]; 
                Piecewise[{{2 r, nm <= t < nm + 1/2},
                           {2 - 2 r, nm + 1/2 <= t < nm + 1}}]]

However, some more thought, assisted by looking at a plot of the function, suggests a more compact expression:

x[t_] := (1 + TriangleWave[t - 1/4])/2

Here then is a plot of the desired parametric equation:

ParametricPlot[{x[t], x[Sqrt[2] t]}, {t, 0, 20}, PlotPoints -> 95]

looks kinda messy to me

$\endgroup$
3
$\begingroup$

I am not quite certain what you mean by

t ∈ [n - 1, n - 1/2]

and similar constructs in your question.

I am interpreting it to mean that for a particular n you will have two functions that cover the range {n-1, n-1/2} and {n-1/2, n-1}.

If my interpretation is incorrect, this answer may not help you.

You can make plots for various values of n using Manipulate.

Manipulate[
 Show[
  ParametricPlot[{2 (t - n + 1), 2 (2 Sqrt[t] - n + 1)}, {t, n - 1, 
    n - 1/2}, PlotStyle -> Blue],
  ParametricPlot[{2 - 2 (t - n + 1), 2 - 2 (2 Sqrt[t] - n + 1)}, {t, 
    n - 1/1, n}, PlotStyle -> Red],
  PlotRange -> All,
  AspectRatio -> 1/GoldenRatio
  ],
 {{n, 1}, {1, 2, 3, 4, 5, 6}}
 ]

Mathematica graphics

$\endgroup$
2
  • $\begingroup$ I define the curve on [0,+\infty) Jack :) $\endgroup$ Commented Nov 27, 2015 at 6:36
  • $\begingroup$ Sorry, I don't understand your problem. See if you can re-formulate it to make it crystal clear the problem that you are experiencing. $\endgroup$ Commented Nov 27, 2015 at 16:34

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.