I'm currently exploring periodic cycles of time over a span containing
several periods.  As a real life example, there's a particular lunar
cycle that's 346.62005 days in length.  What I'm seeking right now in J
is *not* to determine future dates of this cycle (given, say, the
current date) but, rather, to generate a cosine (that is, starting with
a peak) that can be used with plot commands to show this cycle in
graphical form (peak to peak) compared with other plotted data.  I'd
like to be able to construct a verb with o. where I can use a cycle
length (such as 346.62005 days) as an argument and which results in a
list of cosine values for each day (for a specified number of days as
another argument), starting the first day with a value of 1, reaching -1
between day 173 and 174 (173.31002), reaching 1 again between day 346
and 347 (346.62005), and so on.  (This example is where days are the
unit of time; it could just as easily be hours, years, or
what-have-you.)  I did a lot of trial and error and was stumped as to
how to do this.  The dictionary examples did not seem to address this
particular application of the circle function. 

Actually, I'm seeking TWO different solutions (and the second may be
harder or more complex than the first):

(1) a cosine solution as described above; and

(2) a solution similar to #1, but using *straight* lines joining the
positive and negative 1's of the highs and lows of the cycle
(alternating slopes rather than trigonometic curves), still resulting in
daily values which, of course, have a constant change from day to day
rather than a varying change.

For the mathematically-minded, I just thought of a third challenge
related (but not directly) to the two above, which I also need later for
some specialized calculations:

(3) Given a positive 1 point, its succeeding negative 1 point, and the
time distance between them, what would be the formula for the (half)
cosine curve which joins the 1 and _1 ?  (So that all of the intervening
values per time unit could be calculated as a list.)  By the way, I
assume a linear version of this single line could be readily calculated
by the standard xy-slope formula?

I hope I've been as specific as necessary.  Many thanks and much
appreciation in advance!

Harvey

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to