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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to create a function that repeats on an annual cycle (i.e. time is a vector of $1$ to $365$), that has $2$ peaks of different magnitudes - one approx a third of the year and the second approx two thirds of the year. The mean of the cycle is ~$450$, with the $y$-limits being ~$100-800$. The value at the beginning of the year should be the minimum value.

With the help of a much more mathematically-minded friend, I've managed to get the following:

$$\text{MeanValue} + 250\left(\sin\left(\frac{0.2164}{2\pi}\left(\text{time}-55\right)\right)+\left(\sin\left(\frac{0.2164\cdot0.5}{2\pi}\left(\text{time}-55\right)\right)\right)\right)$$

where MeanValue is $450$ and time is the vector of $1$ to $365$.

However, although this seems to show the correct pattern over a small number of years, after $1000$ years, the value at the end of the year is not the minimum value, but ~$700$, implying the whole cycle seems to be about half a phase out by then. What am I missing to make this repeat in the way I want?

share|cite|improve this question
up vote 2 down vote accepted

The function we are told to model analytically has only been qualitatively described, together with hints about its range and mean. The model proposed here provides a reasonable fitting of this description; but as soon as more "intelligence" about the actual function to be modeled is available, more involved (numerical) methods will have to be used.

Playing around with parameters one finds that the following function of period $2\pi$ suits your description of the graph:

$$f(x)\ :=\ -\cos x-\sin x-{5\over2}\cos(2x)+{1\over2}\sin(2x)\ .$$ This is the graph of $f$:


Now we want the time variable $t$ be days that run from $0$ to $365$ in a full period. This means that $x$ should go from $0$ to $2\pi$ when $t$ goes from $0$ to $365$. Letting $x:={2\pi\over 365}t$ does the trick. Therefore we define a new function $g: {\mathbb R}/(365{\mathbb Z})\to{\mathbb R}$ by means of the formula $$g(t)\ :=\ f\bigl({2\pi\over 365}t\bigr)=\ -\cos{2\pi t\over 365}-\sin {2\pi t\over 365}-{5\over2}\cos({4\pi t\over 365})+{1\over2}\sin({4\pi t\over 365})\ .$$ The resulting graph looks the same, but with a different labeling on the horizontal axis:


The mean value $(\sim 450)$ and the range $\bigl(\sim[100,800]\bigr)$ are not yet as desired. But this is easy to accomplish: Note that $f$ has mean value zero, and so has $g$. As $f(0)=g(0)=-3.5$ the function $$h(t)\ :=\ 100 g(t)+450$$ fulfills the requirements pretty well: We have $h(0)=100$, mean $450$, and the maximum of $h$ is $\sim810$.

share|cite|improve this answer
Still need to scale and shift it upwards. – El'endia Starman Feb 24 '12 at 16:19
@El'endia Starman: See my edit. – Christian Blatter Feb 24 '12 at 19:23
Perfect. [thumbs up] :) – El'endia Starman Feb 24 '12 at 19:28
Thanks very much for this, it's helped greatly (I didn't put this in my original post, but ideally, the larger peak should be 1st; I'll make this an exercise for me to swap them round!) :) – ChrisW Feb 25 '12 at 12:01
@ChrisW: One has to reflect the graph of $f$ with respect to the $y$-axis. This is accomplished by considering the new function $$f^\wedge(x):=f(-x)=-\cos x+\sin x-{5\over2}\cos(2x)-{1\over2}\sin(2x)\ .$$ – Christian Blatter Feb 25 '12 at 16:45

$\sin x$ has a period $2\pi$. $\sin2\pi x$ has period $1$. $\sin(2\pi/365)x$ has period $365$, which I think is what you want. I don't know where you get $.2164/(2\pi)$. Whatever you use, if you only use 4 decimal place accuracy, it's no surprise that you'll be out of phase by the time the argument gets to $1000$.

share|cite|improve this answer
$.2164$ was found after trial and error - this seemed to make the cycle correct after 1 year. If, for example, $0.2$ was used instead, then the values of y when t=1 and t=365 were different. I'm a little confused that I've got $2\pi$ as a denominator, but you imply I need it as a numerator? Is this correct? – ChrisW Feb 24 '12 at 12:14
Well, you tell me. Is $\sin((2\pi/365)x)$ the same as $\sin((2\pi/365)(x+365))$? Be sure your calculator is in radian mode, not degree mode, when you answer that question. – Gerry Myerson Feb 24 '12 at 12:19
Umm, this is obviously where my lack of understanding of radians comes in...! I've worked out that $sin(2\pi)$ is $0$, but when if I let $x$ be 1, then $sin(2\pi/365)$ is $0.0860699$, and $sin((2\pi/365)(366))$ is $-0.0860699$ - have I got this right? – ChrisW Feb 24 '12 at 12:50
That 0.086 number is $\sin(\pi/365)$, not $\sin(2\pi/365)$ – Gerry Myerson Feb 24 '12 at 22:50
Ah yes. Sorry. I was concerned about trying to understand radians I didn't notice my typo there! – ChrisW Feb 25 '12 at 12:02

Your Answer


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.