▼ Matt Agajanian Posting Freak Posts: 980 Threads: 239 Joined: Aug 2006 04-12-2013, 05:14 PM Hello all, I am trying to develop a sine function such that the negative part of the phase is shorter than the positive part of it. It's a biorhythm curve. But, what makes this curve so different is that as the 23-day cycle has 11-1/2 days in positive and 11-1/2 in negative area, my variation only has three days below zero line. Now, one of the algorithms I've fiddled with is the trigonometric formation: a * sin [b * (x + c)] + d Where a will adjust the amplitude of the wave, d will affect the horizontal position of the wave. Although coefficients a and d do not affect the variance in periodicity, I am wondering if adjusting coefficients b and c will produce the variance of periodicity I need. If so, how should I adjust coefficients b & c so that of the 23-day cycle, 20 days are spent on the positive part of the graph while the remaining three are in negative range? Thank you ▼ Kiyoshi Akima Senior Member Posts: 325 Threads: 18 Joined: Jul 2006 04-12-2013, 06:01 PM The coefficient c has no effect on the period, only on the phase. To get a period of 23 days, set b to pi/11.5 . To get 20 days above and only three below, set d to 0.9172a. This will give you a sine wave with a period of 23 days, an amplitude of 2a, a minimum of .0828a, a maximum of 1.9172a, and positive everywhere except from day 15.75 to day 18.75 . ▼ Matt Agajanian Posting Freak Posts: 980 Threads: 239 Joined: Aug 2006 04-12-2013, 06:06 PM So that I understand the trigonometry a bit better, please tell me how you arrived at these numbers. Thanks Kiyoshi Akima Senior Member Posts: 325 Threads: 18 Joined: Jul 2006 04-12-2013, 06:12 PM I suppose I'm eventually going to have to explain how I arrived at my results, so here goes... I want to shift the basic sine wave up so that only 3/23 of the period is negative. To do this I found two points 3/23 of a period apart that have the same sine by using this 15C+ program: ```01 LBL 9 02 SIN 03 LASTx 04 RCL - 0 05 SIN 06 - ``` Where Register 0 contains (3/23)*(2pi) and then simply SOLVEd it between pi and 2pi (yes, yes, it might have been a bit quicker to solve between pi and 1.5pi). This gave me 4.3026, and the sine of that is -0.9172 . Edit: Yep, Matt's request for an explanation came while I was composing this. Edit 2: Now that I've had a night's sleep, I realize I've done this the hard way. The simple way is -sin[3pi/2 - (1/2)*(3/23)*(2pi)] Edited: 13 Apr 2013, 1:45 p.m. after one or more responses were posted ▼ Matt Agajanian Posting Freak Posts: 980 Threads: 239 Joined: Aug 2006 04-12-2013, 06:43 PM Okay, got it! Matt Agajanian Posting Freak Posts: 980 Threads: 239 Joined: Aug 2006 04-13-2013, 12:21 AM Okay! Now that we solved that, I noticed that the amplitude reaches past +1, the negative period is so short, the negative amplitude is not an issue. So, how can I restrict the maximum positive amplitude to +1? Next, how can I adjust the function so that 0 occurs at x= 16 1/2 and continues decreasing, followed by an upturn which reaches 0 at x=19? Edited: 13 Apr 2013, 1:16 a.m. after one or more responses were posted ▼ Kiyoshi Akima Senior Member Posts: 325 Threads: 18 Joined: Jul 2006 04-13-2013, 12:54 AM Since the maximum is 1.9172a, simply set a to 1/1.9172 . ▼ Matt Agajanian Posting Freak Posts: 980 Threads: 239 Joined: Aug 2006 04-13-2013, 01:55 AM Now I'm completely confused. When I put in the new value for a, 1/0.917211302 so that f(0)=1, I still get f(0)=0.917211302. After putting the original coefficients you gave me in, 0.917211302 comes as the first value where x=0, so, starting from scratch, how can I adjust the function so that positive maximum is 1, f(15 1/2)=0 decreasing towards an upturn where f(19)=0. Now, with all this restated, what should the coefficients be. And, please accept my apologies for any confusion or frustration this project has caused. Edited: 13 Apr 2013, 2:22 a.m. ▼ fhub Posting Freak Posts: 1,216 Threads: 75 Joined: Jun 2011 04-13-2013, 05:54 AM Quote: ..., so, starting from scratch, how can I adjust the function so that positive maximum is 1, f(15 1/2)=0 decreasing towards an upturn where f(19)=0. Now, with all this restated, what should the coefficients be. Well, now you're indeed a bit confusing: first you wanted a negative interval of 3 days, and now you want 3.5 days (from 15.5 to 19). Or is it 2.5 days (from 16.5 to 19 as in your last post?). Ok, I take these conditions (with 15.5, i.e. a negative interval of 3.5), and I still assume the whole period should be 23 and the maximum value 1. With these conditions your function looks like this: y = a*sin((2*pi/23)*x) + a*sin(8*pi/23) with a=1/(1+sin(8*pi/23)) So for your initial function a * sin [b * (x + c)] + d that means: a = 1/(1+sin(8*pi/23)) = 0.529693219 b = 2*pi/23 = 0.273181969 c = 0 d = sin(8*pi/23)/(1+sin(8*pi/23)) = 0.47030678 i.e. y = 0.529693219*sin(0.273181969*x) + 0.47030678 Franz ▼ Walter B Posting Freak Posts: 4,587 Threads: 105 Joined: Jul 2005 04-13-2013, 08:23 AM Good grieve, all that hassle and nine decimals for a biorhythm. Employ RAN# instead ;-/ ▼ fhub Posting Freak Posts: 1,216 Threads: 75 Joined: Jun 2011 04-13-2013, 08:29 AM Quote: Good grieve, all that hassle and nine decimals for a biorhythm. Employ RAN# instead ;-/ Aaah, once again a great comment from our math expert ... ;-) Franz Edited: 13 Apr 2013, 10:47 a.m. Matt Agajanian Posting Freak Posts: 980 Threads: 239 Joined: Aug 2006 04-13-2013, 11:50 AM My focus was on f(16.5)=0 downward to f(19)=0, proceeding upward. So, what would the equation look like with this setup? Edited: 13 Apr 2013, 11:51 a.m. ▼ Kiyoshi Akima Senior Member Posts: 325 Threads: 18 Joined: Jul 2006 04-13-2013, 12:35 PM Like Franz, I'm getting confused. You now want it negative for 2.5 days instead of the original 3? fhub Posting Freak Posts: 1,216 Threads: 75 Joined: Jun 2011 04-13-2013, 01:34 PM Quote: My focus was on f(16.5)=0 downward to f(19)=0, proceeding upward. So, what would the equation look like with this setup? Well, then the function is: y = a*sin((2*pi/23)*(x-1/2)) + a*sin(9*pi/23) with a=1/(1+sin(9*pi/23)) So for your initial function a * sin [b * (x + c)] + d that means: a = 1/(1+sin(9*pi/23)) b = 2*pi/23 c = -1/2 d = sin(9*pi/23)/(1+sin(9*pi/23)) I hope this is the last change in your conditions! ;-) Franz ▼ Matt Agajanian Posting Freak Posts: 980 Threads: 239 Joined: Aug 2006 04-13-2013, 02:08 PM To Franz and all the group. Thank you very much. Like I said, I am grateful for all your help on this and, as I'd said before, I apologise for any confusion and frustration my inquiry has caused. Matt Agajanian Posting Freak Posts: 980 Threads: 239 Joined: Aug 2006 04-13-2013, 03:02 PM So that I can learn more about how this trig algorithm works, how were these values derived? Thank you. ▼ fhub Posting Freak Posts: 1,216 Threads: 75 Joined: Jun 2011 04-13-2013, 04:19 PM Quote: So that I can learn more about how this trig algorithm works, how were these values derived? Oh, that's complicated to describe only with words without showing it on a graph, but I'll try it: I did it in 4 steps: 1) make the period 23 (i.e. b=?) ==> y = f(x) = a*sin(2*pi/23*x) 2) shift the function upwards, so that y is negative only in an interval of 2.5 (i.e. d=?): this 2.5 interval is symmetric around the minimum at x=23/4*3 (or the maximum at x=23/4), so this shift-value d is f(23/4-2.5/2) (I took it at the maximum for getting smaller numbers) which leads to d = a*sin(2*pi/23*(23/4-2.5/2)) = a*sin(9*pi/23) Now we have y = f(x) = a*sin(2*pi/23*x) + a*sin(9*pi/23) 3) now scale the function to get a max. y-value of 1 (i.e. a=?): you get this max. y-value of 1 for x=23/4: f(23/4) = a*sin(2*pi/23*23/4) + a*sin(9*pi/23) = a*sin(pi/2) + a*sin(9*pi/23) = a + a*sin(9*pi/23) = a*(1+sin(9*pi/23)) = 1 ==> a = 1/(1+sin(9*pi/23)) 4) and finally shift the function in x-direction, so that the first zero should be at x=16.5 (i.e. c=?): as I explained in point 2) the zero of the up-shifted function is currently at 16 (that is 23/4*3-2.5/2), so the function must be shifted to the right by a value of 0.5, and thus x has to be replaced by x-1/2 These 4 steps together lead to the following solution: y = f(x) = 1/(1+sin(9*pi/23))*[sin(2*pi/23*(x-1/2)) + sin(9*pi/23)] Franz Edited: 13 Apr 2013, 4:23 p.m. ▼ Matt Agajanian Posting Freak Posts: 980 Threads: 239 Joined: Aug 2006 04-13-2013, 05:02 PM Franz, your explanation is just what I needed to understand this precisely. You are very good at putting the graph into words. With your step-by-step explanation, I am able to understand more clearly how the equation works because you have explained how each step affects the graph's appearance and function's periodicity. That helps me understand precisely how and why the function works the way it does. Thanks. ▼ fhub Posting Freak Posts: 1,216 Threads: 75 Joined: Jun 2011 04-13-2013, 05:12 PM You're welcome, Matt! Quote: You are very good at putting the graph into words. Well, after teaching mathematics for about 30 years I guess I have a bit ;-) experience in explaining, but of course in German (and with a diagram at hand) I could have done it much better. Franz C.Ret Senior Member Posts: 260 Threads: 0 Joined: Oct 2008 04-14-2013, 03:29 PM Quote: Oh, that's complicated to describe only with words without showing it on a graph, but I'll try it: I did it in 4 steps: 1) make the period 23 (i.e. b=?) ==> y = f(x) = a*sin(2*pi/23*x) 2) shift the function upwards, so that y is negative only in an interval of 2.5 (i.e. d=?): this 2.5 interval is symmetric around the minimum at x=23/4*3 (or the maximum at x=23/4), so this shift-value d is f(23/4-2.5/2) (I took it at the maximum for getting smaller numbers) which leads to d = a*sin(2*pi/23*(23/4-2.5/2)) = a*sin(9*pi/23) Now we have y = f(x) = a*sin(2*pi/23*x) + a*sin(9*pi/23) 3) now scale the function to get a max. y-value of 1 (i.e. a=?): you get this max. y-value of 1 for x=23/4: f(23/4) = a*sin(2*pi/23*23/4) + a*sin(9*pi/23) = a*sin(pi/2) + a*sin(9*pi/23) = a + a*sin(9*pi/23) = a*(1+sin(9*pi/23)) = 1 ==> a = 1/(1+sin(9*pi/23)) 4) and finally shift the function in x-direction, so that the first zero should be at x=16.5 (i.e. c=?): as I explained in point 2) the zero of the up-shifted function is currently at 16 (that is 23/4*3-2.5/2), so the function must be shifted to the right by a value of 0.5, and thus x has to be replaced by x-1/2 These 4 steps together lead to the following solution: y = f(x) = 1/(1+sin(9*pi/23))*[sin(2*pi/23*(x-1/2)) + sin(9*pi/23)] Franz ▼ Matt Agajanian Posting Freak Posts: 980 Threads: 239 Joined: Aug 2006 04-18-2013, 04:00 PM Franz, this is fantastic. Not only do I see what you were developing, with the graph's step by step transformation I can clearly understand it. Thanks again!! ▼ fhub Posting Freak Posts: 1,216 Threads: 75 Joined: Jun 2011 04-18-2013, 04:51 PM Quote: Franz, this is fantastic. Matt, this diagrams were made by C.Ret, not by me. ;-) BTW, in the last final formula there's a () missing. Franz ▼ Matt Agajanian Posting Freak Posts: 980 Threads: 239 Joined: Aug 2006 04-25-2013, 04:47 PM So, how should that last formula read? ▼ fhub Posting Freak Posts: 1,216 Threads: 75 Joined: Jun 2011 04-25-2013, 05:04 PM Quote: So, how should that last formula read? The error is not in the text but in the last formula in the graphic: Instead of sin(2*pi/23*x-1/2) it must be sin(2*pi/23*(x-1/2)), i.e. the () around x-1/2 is missing. Franz ▼ Matt Agajanian Posting Freak Posts: 980 Threads: 239 Joined: Aug 2006 04-29-2013, 04:10 PM Thanks for the clarification. And thanks to you folks here, I'm brushing up on my long forgotten trig properties, axioms and identities. Csaba Tizedes (Hungary) Member Posts: 59 Threads: 9 Joined: Apr 2008 04-15-2013, 04:28 PM Really you're do not need the value of these three function. The "critical days" are where these graphs cross out the x-axis. So the simplest biorithm calculator need only delta-days calculation and a fractional part function, like on 12C: ```RCL 0 x<>y deltaDYS STO 1 33 / FRAC RCL 1 28 / FRAC RCL 1 23 / FRAC RCL1 GTO 00 ``` For running you need to store the birthdate to Reg0 and type in actual date and press R/S. After running you can see the days from the birth, then press RollDown, you can see the Physical cycle fractional part of 23 days, press RollDown, you can see the Emotional cycle fractional part and then press again RollDown, you can see the Intellectual part. Because one day is approx 0.03...0.05 part of the cycle the critical values where the each function crosses the x-axis: 0.00...0.04 and 0.96...1.00 For example Euler Physical, Emotional and Intellectual state on 18. Sept, 1783. (birthdate: 15. Apr, 1707.): ```g D.MY 15.041707 STO 0 18.091783 R/S (...running...) 27915 (number of days Euler's life) 0.70 Physical (difference from 1.00 = -0.30 it's approx. -7 days from crytical days) 0.96 Emotional (Crytical!!!) 0.91 Intellectual (3 days from crytical!) ``` Csaba fhub Posting Freak Posts: 1,216 Threads: 75 Joined: Jun 2011 04-12-2013, 06:19 PM Make it sin(2*pi/23*(x+3)), i.e. b=2*pi/23 and c=3. Franz ▼ Kiyoshi Akima Senior Member Posts: 325 Threads: 18 Joined: Jul 2006 04-12-2013, 06:23 PM This still has 11.5 days negative instead of the requested 3. ▼ fhub Posting Freak Posts: 1,216 Threads: 75 Joined: Jun 2011 04-12-2013, 06:25 PM No, make a plot and you'll see that it's correct. Ftanz ▼ Kiyoshi Akima Senior Member Posts: 325 Threads: 18 Joined: Jul 2006 04-12-2013, 06:29 PM I did plot it, and half of the graph is negative. ▼ fhub Posting Freak Posts: 1,216 Threads: 75 Joined: Jun 2011 04-12-2013, 06:33 PM I guess I misunderstood what Matt wanted!? I thought he meant a period of 23 days, but it shouldn't start at zero but at -3 (or in other words: the curve should be shifted left 3 days). That's the usual problem with a foreign language ... :-( Franz ▼ Kiyoshi Akima Senior Member Posts: 325 Threads: 18 Joined: Jul 2006 04-12-2013, 06:38 PM As I interpreted the question (and it's not my native tongue either) he wants a function which is negative 3/23 of the time and positive the other 20/23. ▼ Matt Agajanian Posting Freak Posts: 980 Threads: 239 Joined: Aug 2006 04-12-2013, 06:40 PM Yup, that's it. Matt Agajanian Posting Freak Posts: 980 Threads: 239 Joined: Aug 2006 04-12-2013, 06:39 PM Quote: I guess I misunderstood what Matt wanted!? I thought he meant a period of 23 days, but it shouldn't start at zero but at -3 (or in other words: the curve should be shifted left 3 days). That's the usual problem with a foreign language ... :-( Franz No Franz, you were right, the period is 23 days, yes. It's just that the variance in positive/negative duration is very different. It's okay. 