Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Part1(Solved)

Is it possible to create a function that maps x to y as follows:

x 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...

y 0 1 2 3 4 5 4 3 2 1 0 1 2 3 4 5 ...

So far, this is what I have been able to come up with:

|5 sin ((1/10)*pi*x)|

Which will give the following y's for x = 0 to 10:

 0.00000
 1.5451
 2.9389
 4.0451
 4.7553
 5.0000
 4.7553
 4.0451
 2.9389
 1.5451
 0.00000

This sequence will repeat every 10 steps, with the peak (5) at step 5. This is getting close to what I want so all that is left is to somehow adjust the function so that the required integers appear (1,2,3,4), but I don't know how.

Since the function is cycling through a series of numbers over and over, I figured that it might be possible to write the function in terms of a periodic function and not piece by piece.

Please comment.

Part2

How would I go about writing a function that produce the following plot:(x is an integer >=0 , the pattern repeats after x = 8)

alt text

Can this plot be expressed using a single formula or must it be defined piecewise? Thank you.

share|improve this question
4  
A piecewise linear function will do of course. Are there any extra requirements, like smoothness for example? –  Hans Lundmark Oct 31 '10 at 16:06
1  
Youre example of $|5\sin(\pi x/10)|$ doesn't actually work. –  Robin Chapman Oct 31 '10 at 16:15
    
You probably should have asked "part 2" as a separate question... –  J. M. Nov 20 '10 at 16:09
add comment

3 Answers 3

up vote 11 down vote accepted

$\frac{5}{\pi}\arccos\left(\cos\left(\frac{\pi x}{5}\right)\right)$ seems to do what you want, unless you need something smoother.

share|improve this answer
1  
...and this is in fact the "natural" piecewise linear function passing through the given points, but written in a clever way. –  Hans Lundmark Oct 31 '10 at 16:50
    
I should say @Hans, I thought of it immediately after I saw your comment. :) –  J. M. Oct 31 '10 at 16:58
    
@J.M: How did you find that function? Very impressive. i.imgur.com/JdBQf.jpg –  Robert Smith Oct 31 '10 at 17:17
    
+1 Very Good and very clever! –  Américo Tavares Oct 31 '10 at 18:48
    
@JM: Yes,that is exactly what I wanted. Thank you for your help. –  Sara Oct 31 '10 at 20:04
show 1 more comment

You ask for a function. A function is a mapping from one set to another set, but you neglect to specify which sets. Your list of $x$-values consists of small nonnegative integers together with an ellipsis. From this, one might surmise that your intended domain is $\mathbb{N}_0$, the set of nonnegative integers. Likewise you do not specify a codomain, but let's say for argument's sake that it is $\mathbb{N}_0$, the same as the domain.

Of course there are uncountably many functions from $\mathbb{N}_0$ to $\mathbb{N}_0$ containing your specified values. But you mention it has to be a "sine" function. The term sine refers to a particular function on the real numbers, taking all values between $-1$ and $1$ and having period $2\pi$. Your function cannot have all of these properties. Perhaps by a "sine" function you mean a periodic function? If so here is one defined on $\mathbb{N}_0$ which extends your table of values: $$f(n)=\begin{cases} 0&\text{if }n\equiv 0 \pmod {10},\\\\ 1&\text{if }n\equiv\pm1 \pmod {10},\\\\ 2&\text{if }n\equiv\pm2 \pmod {10},\\\\ 3&\text{if }n\equiv\pm3 \pmod {10},\\\\ 4&\text{if }n\equiv\pm4 \pmod {10},\\\\ 5&\text{if }n\equiv 5 \pmod {10}. \end{cases}$$ Of course, unlike the actual sine function, this never takes negative values.

Perhaps as in Hans's comment, you want a function on the reals restricting to your table of values. Here is a piecewise linear example as Hans suggests: $$g(x)= \begin{cases} 10\{x/10\}&\textrm{if }\{x/10\} < 1/2,\\ 10-10\{x/10\}&\textrm{if }\{x/10\}\ge 1/2 \end{cases}$$ where $\{t\}$ denotes the fractional part of a real number $t$.

share|improve this answer
add comment

PART 1 You were close: Look at your values. They rise with slope $1$ till $5$, and then continue with slope $-1$. This may be described by the function $h(x)'=\text{sgn}(\sin(\pi x/5))\,$.

$\hskip1.7in$enter image description here

(from W|A).

Integrate this, $h(n)=\int_0^n \text{sgn}(\sin(x))\,dx\,$, and you're done.

Instead of that, you might adapt the Fourier Series for the Triangle Function to your problem: $$ \begin{align} x_\mathrm{triangle}(t) & {} = \frac {8}{\pi^2} \sum_{k=0}^\infty (-1)^k \, \frac{ \sin \left( (2k+1)\omega t \right)}{(2k+1)^2} \\ & {} = \frac{8}{\pi^2} \left( \sin (\omega t)-{1 \over 9} \sin (3\omega t)+{1 \over 25} \sin (5\omega t) - \cdots \right) \end{align} $$

Part 2 Starting from $(n,h(n))=(9,5)$, you have $6$ values decreases, followed by a jump of $+3$ and then $6$ values increasing. So this is essentially the same problem with an additional offset function $\frac32 \left(\text{sgn}(\sin(\pi x/5))+1\right)$...

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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