###################################################################### ##LUACH: Save this file as LUACH To use it, stay in the # ##same directory, get into Maple (by typing: maple ) # ##and then type: read LUACH : # ##Then follow the instructions given there # ## # ##Written by Doron Zeilberger, Rutgers University , # #zeilberg at math dot rutgers dot edu # ###################################################################### #Created: Tishrei 8, 5768 print(`Created: Tishrei 8, 5768`): print(` This is LUACH `): print(`to convert from the Hebrew to the Gregorian Calendars`): print(`and vice versa, and make-up yearly Hebrew calendars`): print(`by Doron Zeilberger`): print(`It accompanies Doron Zeilberger's lecture`): print(`Why Erev Yom Kippur is never on Thursday Evening`): print(`given on 5:00pm, Tishrei 8, 5768, at the Rutgers University`): print(`Experimental Mathematics Seminar.`): print(``): print(`Please report bugs to zeilberg at math dot rutgers dot edu`): print(``): print(`The most current version of this package and paper`): print(` are available from`): print(`http://www.math.rutgers.edu/~zeilberg .`): print(`For a list of the procedures type ezra();, for help with`): print(`a specific procedure, type ezra(procedure_name); .`): print(``): print(`Mukdash le-gimel baribua` ): with(combinat): ezra1:=proc() if args=NULL then print(` The supporting procedures are: DayOfTheWeekG`): print(`DayToGreg1 `): print( ` ExtraDaysInPeriod, IsGregLeapYear, KamaYamim, KamaYamim1 `): print(` KamaYamim1G, KamaYamimG `): print(` NextGregDate, RevKamaYamimG `): else ezra(args): fi: end: ezra:=proc() if args=NULL then print(`The main procedures are: Chagim, Conway, FirstRosh, GregToHebrew`): print(` HebrewToGreg, LuachShana, Molad `): print(` Min, Min1, Molad , NextHebrewDate, Sidra, Yom `): elif nops([args])=1 and op(1,[args])=Chagim then print(`Chagim(i): All the Civil dates of the Jewish`): print(`Holidays of Hebrew year i`): print(`For example, to get all the Civil dates of the Hebrew year`): print(` 5716, type: Chagim(5716); `): elif nops([args])=1 and op(1,[args])=Conway then print(`Conway(Y): The Conway formula for the Gregorian date of`): print(`Rosh Hashana of year Y. For example, try: Conway(1955);`): elif nops([args])=1 and op(1,[args])=Conway1 then print(`Conway1(Y): The Conway formula for the Gregorian date (in September)`): print(`of Rosh Hashana, for the years between 1900 and 2099. For `): print(`example, try: Conway1(1955);`): elif nops([args])=1 and op(1,[args])=DayOfTheWeekG then print(`DayOfTheWeekG(D1,M1,Y1): Given a Gregorian date`): print(`after Jan. 1, 1800, finds the day of the week`): print(`For example, try:`): print(`DayOfTheWeekG(8,12,1955);`): elif nops([args])=1 and op(1,[args])=DayToGreg1 then print(`DayToGreg1(D1): Given the day from the creation of the world`): print(`computes the Gregorian date. So far we need D1>=2030500`): print(`(after [1,1,1800]). For example, try:`): print(`DayToGreg1(2030500);`): elif nops([args])=1 and op(1,[args])=ExtraDaysInPeriod then print(`ExtraDaysInPeriod(i): the number of days in Period i `): print(`(i.e. years 19*(i-1)+1 to 19*(i-1)+19 to`): print(`the creation of the world. For example, try:`): print(`ExtraDaysInPeriod(3);`): elif nops([args])=1 and op(1,[args])=FirstRosh then print(`FirstRosh(D1,M1): when is the first year where Rosh Hashana will`): print(`be on Gregorian date Date. For example, to find the first year`): print(`when Rosh Hashana will be on Christmas, type:`): print(`FirstRosh(25,12);`): elif nops([args])=1 and op(1,[args])=GregToHebrew then print(`GregToHebrew(D1,M1,Y1): Given any date after Jan. 1, 1800`): print(`figures out the Hebrew Date. For example`): print(`try: GregToHebrew(8,12,1955); `): elif nops([args])=1 and op(1,[args])=HebrewToGreg then print(`HebrewToGreg(D1,M1,Y1): Inputs the Hebrew Date`): print(`Day,Month,Year, and outputs the Gregorian Date.`): print(`For example, try: HebrewToGreg(23,3,5716);`): elif nops([args])=1 and op(1,[args])=IsGregLeapYear then print(`IsGregLeapYear(Y1): is Gregorian year Y1 a leap year?`): print(`For example, try: IsGregLeapYear(1955);`): elif nops([args])=1 and op(1,[args])=KamaYamim then print(`KamaYamim(D1,M1,Y1): How many days, since the Creation`): print(`of the World, is Hebrew Date [D1,M1,Y1]`): print(`where D1 is the day of the month, M1 is the month of the`): print(`year, and Y1 is the year. (Note in leap years: AdarI =6`): print(`Adar II=6+1/2 .)`): print(`For example, try:`): print(`KamaYamim(23,3,5716);`): elif nops([args])=1 and op(1,[args])=KamaYamimG then print(`KamaYamimG(D1,M1,Y1): How many days, since Jan. 1, 1800`): print(`is the Gregorian Date [D1,M1,Y1]`): print(`where D1 is the day of the month, M1 is the month of the`): print(`year, and Y1 is the year. `): print(`For example, try:`): print(`KamaYamimG(8,12,1955);`): elif nops([args])=1 and op(1,[args])=KamaYamim1 then print(`KamaYamim1(Y): How many days since the Creation`): print(`of the World BEFORE 1 Tishri, year Y?`): print(`For example, try: KamaYamim1(5716);`): elif nops([args])=1 and op(1,[args])=KamaYamim1G then print(`KamaYamim1G(Y): How many days since Jan. 1, 1800`): print(`Before Jan.1, year Y (Gregorian)`): print(`For example, try: KamaYamim1G(1955);`): elif nops([args])=1 and op(1,[args])=LuachShana then print(`LuachShana(i): prints out the Hebrew Calendar for`): print(`Hebrew Year i, for example, try: LuachShana(5716);`): elif nops([args])=1 and op(1,[args])=Min then print(`Min(Shana): inputs the Hebrew year Shana and returns`): print(`the triple [DayOfTheWeekOfRoshHashana,IsItSimple,WhatType]`): print(`Where IsItSimple is 1 if it is a simple year and`): print(`0 if it is a leap year, and WhatType is `): print(`-1: if Heshvan and Kislev have both 29 days (a short year)`): print(`0: if Heshvan has 29 days and Kislev has 30 days (a regular year)`): print(`1: if Heshvan and Kislev have both 30 days (a long year)`): print(`For example, try: Min(5716);`): elif nops([args])=1 and op(1,[args])=Min1 then print(`Min1(Shana): inputs the Hebrew year Shana and returns`): print(`what type of year it is (Full (shlema) (+1), Regular`): print(`(kesidra) (0), or khasera (-1)`): print(`For example, try: Min1(5716);`): elif nops([args])=1 and op(1,[args])=Molad then print(`Molad(Shana): Given a Hebrew Year, Shana, computes the`): print(`time day of the week and time of the Molad of`): print(`Tishri, year Y. For example, try: Molad(5716);`): elif nops([args])=1 and op(1,[args])=NextGregDate then print(`NextGregDate(mu): Given a Gregorian date mu=[D,M,Y],`): print(`computes the Gregorian date of the day after. `): print(`Warning: European style NOT American Style.`): print(`For example, try:`): print(`NextGregDate([8,12,1955]);`): elif nops([args])=1 and op(1,[args])=NextHebrewDate then print(`NextHebrewDate(mu): Given a Hebrew date mu=[D,M,Y]`): print(`computes the Hebrew date of the day after. `): print(`For example, try:`): print(`NextHebrewDate([23,3,5716]);`): elif nops([args])=1 and op(1,[args])=RevKamaYamimG then print(`RevKamaYamimG(d): the reverse of KamaYamimG. Inputs`): print(`the number of days after Jan. 1, 1800 and outputs the`): print(`date. `): elif nops([args])=1 and op(1,[args])=Sidra then print(`Sidra(A,B): The sequence of types of Hebrew Years from`): print(`year A to year B`): print(`period. Do: Sidra(1,100);`): elif nops([args])=1 and op(1,[args])=Yom then print(`Yom(Shana): Computes the day of the week of Rosh Hashana`): print(`of Hebrew year Shana. For example, try: Yom(5716);`): else print(`There is no ezra for`,args): fi: end: #Molad(Shana): Given a Hebrew Year, Shana, computes the #time day of the week and time of the Molad of #Tishri, year Shana. For example, try: Molad(5768); Molad:=proc(Shana) local a,a0,f,Khod,MM,T0: MM:=29+12/24+793/1080/24; T0:=(5+11/60+20/60/60)/24; Khod:=12*(Shana-1)+trunc((7*Shana-6)/19): a:=2+T0+MM*Khod: a0:=trunc(a): f:=(a-a0)*24: [a0 mod 7, f]: end: #Yom(Shana): Computes the day of the week of Rosh Hashana #of Hebrew year Shana. For example, try: Yom(5768); Yom:=proc(Shana) local gu,yom,rega,pshuta,pshutaP: if member(Shana mod 19, {3,6,8,11,14,17,0}) then pshuta:=0: else pshuta:=1: fi: gu:=Molad(Shana): yom:=gu[1]: rega:=gu[2]: if yom=1 or yom=4 or yom=6 then RETURN(yom+1): fi: if rega>=18 then yom:=yom+1: if yom=1 or yom=4 or yom=6 then yom:=yom+1: fi: RETURN(yom): fi: if yom=3 and pshuta=1 and rega>=9+204/1080 then RETURN(5): fi: if member(Shana-1 mod 19, {3,6,8,11,14,17,0}) then pshutaP:=0: else pshutaP:=1: fi: if pshuta=1 and pshutaP=0 and yom=2 and rega>=15+589/1080 then RETURN(3): fi: if yom=0 then yom:=7: fi: yom: end: #Min1(Shana): what type of year is it (Full (shlema) (+1), Regular #(kesidra) (0), or khasera (-1) Min1:=proc(Shana) local pshuta,yom0,yom1,hefresh: if member(Shana mod 19, {3,6,8,11,14,17,0}) then pshuta:=0: else pshuta:=1: fi: yom0:=Yom(Shana): yom1:=Yom(Shana+1): hefresh:=yom1-yom0: if hefresh<=0 then hefresh:=hefresh+7: fi: if pshuta=1 then if hefresh=3 then RETURN(-1): elif hefresh=4 then RETURN(0): elif hefresh=5 then RETURN(1): else ERROR(`Something is wrong`): fi: elif pshuta=0 then if hefresh=5 then RETURN(-1): elif hefresh=6 then RETURN(0): elif hefresh=7 then RETURN(1): else ERROR(`Something is wrong`): fi: fi: end: #Min(Shana): inputs the Hebrew year Shana and returns #the triple [DayOfTheWeekOfRoshHashana,IsItSimple,WhatType] #Where IsItSimple is 1 if it is a simple year and #0 if it is a leap year, and WhatType is #-1: if Heshvan and Kislev have both 29 days (a short year) #0: if Heshvan has 29 days and Kislev has 30 days (a regular year) #1: if Heshvan and Kislev have both 30 days (a long year) #For example, try: Min(5768); Min:=proc(Shana) local pshuta: option remember: if member(Shana mod 19, {3,6,8,11,14,17,0}) then pshuta:=0: else pshuta:=1: fi: [Yom(Shana),pshuta, Min1(Shana)]: end: #ExtraDaysInPeriod(i): the number of days in Period i #(i.e. years 19*(i-1)+1 to 19*(i-1)+19 to #the creation of the world. For example, try: #DaysInPeriod(3); ExtraDaysInPeriod:=proc(i) local j: option remember: add(Min(j)[3], j=19*(i-1)+1..19*(i-1)+19): end: #KamaYamim1(Y): How many days since the Creation #of the World BEFORE 1 Tishri, year Y? #For example, try: KamaYamim1(5768); KamaYamim1:=proc(Y) local gu,p,sher,i,Y1: Y1:=Y-1: p:=trunc((Y1-1)/19): sher:=Y1-19*p: gu:=(354*19+30*7)*p+add(ExtraDaysInPeriod(i),i=1..p): gu:=gu+354*sher+add(Min(i)[3],i=p*19+1..p*19+sher): for i from p*19+1 to p*19+sher do if Min(i)[2]=0 then gu:=gu+30: fi: od: gu: end: #KamaYamim(D1,M1,Y1): How many days, since the Creation #of the World, is Hebrew Date [D1,M1,Y1] #where D1 is the day of the month, M1 is the month of the #year, and Y1 is the year. (Note in leap years: AdarI =6 #Adar II=6+1/2 .) #For example, try: #KamaYamim(17,9,5710); KamaYamim:=proc(D1,M1,Y1) local gu,lu: gu:=KamaYamim1(Y1): lu:=Min(Y1): if lu[2]=1 then if M1=1 then RETURN(gu+D1): elif M1=2 then RETURN(gu+30+D1): elif M1=3 then if lu[3]<>1 then RETURN(gu+30+29+D1): else RETURN(gu+30+30+D1): fi: elif M1=4 then if lu[3]=-1 then RETURN(gu+30+29+29+D1): elif lu[3]=0 then RETURN(gu+30+29+30+D1): else RETURN(gu+30+30+30+D1): fi: elif M1=5 then if lu[3]=-1 then RETURN(gu+30+29+29+29+D1): elif lu[3]=0 then RETURN(gu+30+29+30+29+D1): else RETURN(gu+30+30+30+29+D1): fi: elif M1=6 then if lu[3]=-1 then RETURN(gu+30+29+29+29+30+D1): elif lu[3]=0 then RETURN(gu+30+29+30+29+30+D1): else RETURN(gu+30+30+30+29+30+D1): fi: elif M1=7 then if lu[3]=-1 then RETURN(gu+30+29+29+29+30+29+D1): elif lu[3]=0 then RETURN(gu+30+29+30+29+30+29+D1): else RETURN(gu+30+30+30+29+30+29+D1): fi: elif M1=8 then if lu[3]=-1 then RETURN(gu+30+29+29+29+30+29+30+D1): elif lu[3]=0 then RETURN(gu+30+29+30+29+30+29+30+D1): else RETURN(gu+30+30+30+29+30+29+30+D1): fi: elif M1=9 then if lu[3]=-1 then RETURN(gu+30+29+29+29+30+29+30+29+D1): elif lu[3]=0 then RETURN(gu+30+29+30+29+30+29+30+29+D1): else RETURN(gu+30+30+30+29+30+29+30+29+D1): fi: elif M1=10 then if lu[3]=-1 then RETURN(gu+30+29+29+29+30+29+30+29+30+D1): elif lu[3]=0 then RETURN(gu+30+29+30+29+30+29+30+29+30+D1): else RETURN(gu+30+30+30+29+30+29+30+29+30+D1): fi: elif M1=11 then if lu[3]=-1 then RETURN(gu+30+29+29+29+30+29+30+29+30+29+D1): elif lu[3]=0 then RETURN(gu+30+29+30+29+30+29+30+29+30+29+D1): else RETURN(gu+30+30+30+29+30+29+30+29+30+29+D1): fi: elif M1=12 then if lu[3]=-1 then RETURN(gu+30+29+29+29+30+29+30+29+30+29+30+D1): elif lu[3]=0 then RETURN(gu+30+29+30+29+30+29+30+29+30+29+30+D1): else RETURN(gu+30+30+30+29+30+29+30+29+30+29+30+D1): fi: fi: else if M1=1 then RETURN(gu+D1): elif M1=2 then RETURN(gu+30+D1): elif M1=3 then if lu[3]<>1 then RETURN(gu+30+29+D1): else RETURN(gu+30+30+D1): fi: elif M1=4 then if lu[3]=-1 then RETURN(gu+30+29+29+D1): elif lu[3]=0 then RETURN(gu+30+29+30+D1): else RETURN(gu+30+30+30+D1): fi: elif M1=5 then if lu[3]=-1 then RETURN(gu+30+29+29+29+D1): elif lu[3]=0 then RETURN(gu+30+29+30+29+D1): else RETURN(gu+30+30+30+29+D1): fi: elif M1=6 then if lu[3]=-1 then RETURN(gu+30+29+29+29+30+D1): elif lu[3]=0 then RETURN(gu+30+29+30+29+30+D1): else RETURN(gu+30+30+30+29+30+D1): fi: elif M1=6+1/2 then if lu[3]=-1 then RETURN(gu+30+29+29+29+30+D1+30): elif lu[3]=0 then RETURN(gu+30+29+30+29+30+D1+30): else RETURN(gu+30+30+30+29+30+D1+30): fi: elif M1=7 then if lu[3]=-1 then RETURN(gu+30+29+29+29+30+29+D1+30): elif lu[3]=0 then RETURN(gu+30+29+30+29+30+29+D1+30): else RETURN(gu+30+30+30+29+30+29+D1+30): fi: elif M1=8 then if lu[3]=-1 then RETURN(gu+30+29+29+29+30+29+30+D1+30): elif lu[3]=0 then RETURN(gu+30+29+30+29+30+29+30+D1+30): else RETURN(gu+30+30+30+29+30+29+30+D1+30): fi: elif M1=9 then if lu[3]=-1 then RETURN(gu+30+29+29+29+30+29+30+29+D1+30): elif lu[3]=0 then RETURN(gu+30+29+30+29+30+29+30+29+D1+30): else RETURN(gu+30+30+30+29+30+29+30+29+D1+30): fi: elif M1=10 then if lu[3]=-1 then RETURN(gu+30+29+29+29+30+29+30+29+30+D1+30): elif lu[3]=0 then RETURN(gu+30+29+30+29+30+29+30+29+30+D1+30): else RETURN(gu+30+30+30+29+30+29+30+29+30+D1+30): fi: elif M1=11 then if lu[3]=-1 then RETURN(gu+30+29+29+29+30+29+30+29+30+29+D1+30): elif lu[3]=0 then RETURN(gu+30+29+30+29+30+29+30+29+30+29+D1+30): else RETURN(gu+30+30+30+29+30+29+30+29+30+29+D1+30): fi: elif M1=12 then if lu[3]=-1 then RETURN(gu+30+29+29+29+30+29+30+29+30+29+30+D1+30): elif lu[3]=0 then RETURN(gu+30+29+30+29+30+29+30+29+30+29+30+D1+30): else RETURN(gu+30+30+30+29+30+29+30+29+30+29+30+D1+30): fi: fi: fi: end: #IsGregLeapYear(Y1): is Gregorian year Y1 a leap year? #For example, try: IsGregLeapYear(2000); IsGregLeapYear:=proc(Y1): if Y1 mod 4=0 then if Y1 mod 100=0 then if Y1 mod 400=0 then RETURN(true): else RETURN(false): fi: else RETURN(true): fi: else RETURN(false): fi: end: #DayToGreg11(D1): Given the day from the creation of the world #computes the Gregorian date. So far we need D1>=2030500 #(after [1,1,1800]). For example, try: #DayToGreg11(2030500); DayToGreg11:=proc(D1) local mu: option remember: if D1<2030500 then ERROR(`Not yet implemented`): fi: if D1=2030500 then RETURN([1,1,1800]): fi: mu:=DayToGreg11(D1-1): NextGregDate(mu): end: #HebrewToGreg(D1,M1,Y1): Inputs the Hebrew Date #Day,Month,Year, and outputs the Gregorian Date. #For example, try: HebrewToGreg(17,9,5710); HebrewToGreg:=proc(D1,M1,Y1): DayToGreg(KamaYamim(D1,M1,Y1)): end: #NextGregDate(mu): Given a Gregorian date mu=[D,M,Y] #computes the Gregorian date of the day after. #(after [1,1,1800]). For example, try: #NextGregDate([18,9,2007]); NextGregDate:=proc(mu): if mu[1]<28 then RETURN([mu[1]+1,mu[2],mu[3]]): elif mu[2]<>2 and mu[1]<29 then RETURN([mu[1]+1,mu[2],mu[3]]): elif member(mu[2],{1,3,5,7,8,10,12}) and mu[1]<31 then RETURN([mu[1]+1,mu[2],mu[3]]): elif member(mu[2],{4,6,9,11}) and mu[1]<30 then RETURN([mu[1]+1,mu[2],mu[3]]): elif mu[2]=2 and mu[1]=28 then if not IsGregLeapYear(mu[3]) then RETURN([1,3,mu[3]]): else RETURN([29,2,mu[3]]): fi: elif mu[2]=2 and mu[1]=29 then RETURN([1,3,mu[3]]): elif member(mu[2],{1,3,5,7,8,10}) and mu[1]=31 then RETURN([1,mu[2]+1,mu[3]]): elif mu[2]=12 and mu[1]=31 then RETURN([1,1,mu[3]+1]): elif member(mu[2],{4,6,9,11}) and mu[1]=30 then RETURN([1,mu[2]+1,mu[3]]): fi: end: #DayToGreg1(D1): Given the day from the creation of the world #computes the Gregorian date. So far we need D1>=2030500 #(after [1,1,1800]). For example, try: #DayToGreg1(2030500); DayToGreg1:=proc(D1) local i,gu: for i from 2030500 to D1 do gu:=DayToGreg11(i): od: gu: end: #KamaYamim1G(Y): How many days since Jan. 1, 1800 #Before Jan.1, year Y (Gregorian) #For example, try: KamaYamim1G(2000): KamaYamim1G:=proc(Y) local gu,Y1: Y1:=Y-1800: gu:=365*Y1: gu:=gu+trunc((Y1-1)/4): gu:=gu-trunc((Y1-1)/100): if Y1>=201 then gu:=gu+trunc((Y1-201)/400)+1: fi: gu: end: DayOfTheWeekG:=proc(D1,M1,Y1): KamaYamimG(D1,M1,Y1)+3 mod 7: end: #KamaYamimG(D1,M1,Y1): How many days, since Jan. 1, 1800 #is the Gregorian Date [D1,M1,Y1] #where D1 is the day of the month, M1 is the month of the #year, and Y1 is the year. #For example, try: #KamaYamimG(2,7,1950); KamaYamimG:=proc(D1,M1,Y1) local gu: gu:=KamaYamim1G(Y1): gu:=gu+30*(M1-1)+D1: if not IsGregLeapYear(Y1) then if M1=2 then gu:=gu+1: elif M1=3 then gu:=gu+1-2: elif M1=4 then gu:=gu+1-2+1: elif M1=5 then gu:=gu+1-2+1+0: elif M1=6 then gu:=gu+1-2+1+0+1: elif M1=7 then gu:=gu+1-2+1+0+1+0: elif M1=8 then gu:=gu+1-2+1+0+1+0+1: elif M1=9 then gu:=gu+1-2+1+0+1+0+1+1: elif M1=10 then gu:=gu+1-2+1+0+1+0+1+1+0: elif M1=11 then gu:=gu+1-2+1+0+1+0+1+1+0+1: elif M1=12 then gu:=gu+1-2+1+0+1+0+1+1+0+1+0: fi: else if M1=2 then gu:=gu+1: elif M1=3 then gu:=1+gu+1-2: elif M1=4 then gu:=1+gu+1-2+1: elif M1=5 then gu:=1+gu+1-2+1+0: elif M1=6 then gu:=1+gu+1-2+1+0+1: elif M1=7 then gu:=1+gu+1-2+1+0+1+0: elif M1=8 then gu:=1+gu+1-2+1+0+1+0+1: elif M1=9 then gu:=1+gu+1-2+1+0+1+0+1+1: elif M1=10 then gu:=1+gu+1-2+1+0+1+0+1+1+0: elif M1=11 then gu:=1+gu+1-2+1+0+1+0+1+1+0+1: elif M1=12 then gu:=1+gu+1-2+1+0+1+0+1+1+0+1+0: fi: fi: gu: end: #DayToGreg(D1): Given the day from the creation of the world #computes the Gregorian date. So far we need D1>=2030500 #(after [1,1,1800]). For example, try: #DayToGreg(2030500); DayToGreg:=proc(D1) local mu,gu,Y1: option remember: if D1<2030500 then ERROR(`Not yet implemented`): fi: if D1=2030500 then RETURN([1,1,1800]): fi: gu:=D1-2030500: Y1:=trunc(gu/365.25): mu:=[1,1,Y1+1800]: while KamaYamimG(op(mu))<>gu do mu:=NextGregDate(mu): od: NextGregDate(mu): end: #Conway1(Y): The Conway formula for the Gregorian date (in September) #of Rosh Hashana, for the years between 1900 and 2099. For #example, try: Conway1(2007); Conway1:=proc(Y) local G,gu,y,d,f,F,dw: if Y<1900 or Y>=2100 then print(`This formula is only good for Y in [1900,2099]`): RETURN(FAIL): fi: G:= Y mod 19 +1: F:=12*G mod 19: y:=Y-1900: gu:=6+3/2*F+(F+1)/18+ (y mod 4)/4-2*y/630: d:=trunc(gu): f:=gu-d: if d<=30 then dw:=DayOfTheWeekG(d,9,Y): else dw:=DayOfTheWeekG(d-30,10,Y): fi: if dw=1 or dw=4 or dw=6 then d:=d+1: elif dw=3 and f>=.633 and F>6 then d:=d+2: elif dw=2 and f>=.898 and F>11 then d:=d+1: fi: d: if d>30 then RETURN([d-30,10,Y]): else RETURN([d,9,Y]): fi: end: #Conway(Y): The Conway formula for all Gregorian dates #of Rosh Hashana, For example, try: #Conway(2007); Conway:=proc(Y) local y0,G,gu,y,d,f,F,dw,mu: y0:=trunc(Y/100)-trunc(Y/400)-9: G:= Y mod 19 +1: F:=12*G mod 19: y:=Y-1900: gu:=y0+3/2*F+(F+1)/18+ (y mod 4)/4 -(2*(Y-1900)-1)/630-F/760+(11*(2100-Y)+7*(F-1))/3447360: d:=trunc(gu): f:=gu-d: dw:=DayOfTheWeekG(d,9,Y): if dw=1 or dw=4 or dw=6 then d:=d+1: elif dw=3 and f>=1367/2160 and F>6 then d:=d+2: elif dw=2 and f>=23269/25920 and F>11 then d:=d+1: fi: mu:=[d,9,Y]: if d>30 then mu:=RevKamaYamimG(KamaYamimG(op(mu))): fi: mu: end: #NextHebrewDate(mu): Given a Hebrew date mu=[D,M,Y] #computes the Hebrew date of the day after. #For example, try: #NextHebrewDate([1,1,1]); NextHebrewDate:=proc(mu) local m: m:=Min(mu[3]): if mu[1]<=28 then RETURN([mu[1]+1,mu[2],mu[3]]): fi: if mu[2]=12 and mu[1]=29 then RETURN([1,1,mu[3]+1]): fi: if m[2]=0 and mu[2]=6 and mu[1]=29 then RETURN([30,6,mu[3]]): fi: if m[2]=0 and mu[2]=6 and mu[1]=30 then RETURN([1,6+1/2,mu[3]]): fi: if m[2]=0 and mu[2]=6+1/2 and mu[1]=29 then RETURN([1,7,mu[3]]): fi: if m[2]=1 and mu[2]=6 and mu[1]=29 then RETURN([1,7,mu[3]]): fi: if mu[1]=29 and member(mu[2],{4,6,8,10}) then RETURN([1,mu[2]+1,mu[3]]): elif mu[1]=30 and member(mu[2],{1,5,7,9,11}) then RETURN([1,mu[2]+1,mu[3]]): fi: if m[3]=-1 then if mu[1]=29 and member(mu[2],{2,3}) then RETURN([1,mu[2]+1,mu[3]]): fi: elif m[3]=0 then if mu[1]=29 and mu[2]=2 then RETURN([1,3,mu[3]]): elif mu[1]=30 and mu[2]=3 then RETURN([1,4,mu[3]]): fi: elif m[3]=1 then if mu[1]=30 and member(mu[2],{2,3}) then RETURN([1,mu[2]+1,mu[3]]): fi: fi: [mu[1]+1,mu[2],mu[3]]: end: #RevKamaYamimG(d): the reverse of KamaYamimG. Inputs #the number of days after Jan. 1, 1800 and outputs the #date. RevKamaYamimG:=proc(d) local Y1,mu,i: Y1:=1800+trunc(d/365): mu:=[1,1,Y1]: while KamaYamimG(op(mu))>d do mu:=[1,1,mu[3]-1]: od: for i from 1 do if KamaYamimG(op(mu))=d then RETURN(mu): else mu:=NextGregDate(mu): fi: od: end: #FirstRosh(D1,M1): when is the first year where Rosh Hashana will #be on Gregorian date Date. For example, to find the first year #when Rosh Hashana will be on Christmas, type: #FirstRosh(25,12); FirstRosh:=proc(D1,M1) local i: for i from 1 do if KamaYamimG(op(Conway(i)))>=KamaYamimG(D1,M1,i) then RETURN(i): fi: od: end: #GregToHebrew(D1,M1,Y1): Given any date after Jan. 1, 1800 #figures out the Hebrew Date. For example #try: GregToHebrew(8,12,1955) GregToHebrew:=proc(D1,M1,Y1) local gu,y,y1: if Y1<=1800 or not (M1>=1 and M1<=12) or not (D1>=1 and D1<=31) then ERROR(`Bad input`): fi: gu:=KamaYamimG(D1,M1,Y1): y:=trunc(gu/365)+5560: for y1 from y by -1 while HebrewToGreg(1,1,y1)[3]>=Y1 do od: gu:=[1,1,y1]: while HebrewToGreg(op(gu))<>[D1,M1,Y1] do gu:=NextHebrewDate(gu): od: gu: end: RoshChrist:=proc() local i: for i from 1 do if Conway(i)[1]>=116 then RETURN(i): fi: od: end: #Sidra(A,B): The sequence of types of Hebrew Years from #year A to year B #period. Do: Sidra(1,100); Sidra:=proc(A,B) local i,gu,mu,T: gu:=[]: for i from A to B do gu:=[op(gu),Min(i)]: od: mu:=convert(convert(gu,set),list): for i from 1 to nops(mu) do T[mu[i]]:=i: od: [seq(T[gu[i]],i=1..nops(gu))],mu: end: EzeKhodesh:=proc(mu) local i,m: i:=mu[2]: m:=Min(mu[1])[2]: if i=1 then Tishrei: elif i=2 then Heshvan: elif i=3 then Kislev: elif i=4 then Tevet: elif i=5 then Shvat: elif i=6 then if m=1 then Adar: else AdarAlef: fi: elif i=6+1/2 then AdarBet: elif i=7 then Nissan: elif i=8 then Iyar: elif i=9 then Sivan: elif i=10 then Tamuz: elif i=11 then Av: elif i=12 then Elul: fi: end: EzeYom:=proc(j) : if j=0 or j=7 then RETURN(Saturday): elif j=1 then RETURN(Sunday): elif j=2 then RETURN(Monday): elif j=3 then RETURN(Tuesday): elif j=4 then RETURN(Wedensday): elif j=5 then RETURN(Thursday): elif j=6 then RETURN(Friday): fi: end: MonthG:=proc(i): if i=1 then January: elif i=2 then February: elif i=3 then March: elif i=4 then April: elif i=5 then May: elif i=6 then June: elif i=7 then July: elif i=8 then August: elif i=9 then September: elif i=10 then October: elif i=11 then November: elif i=12 then December: else ERROR(`Bad input `): fi: end: #LuachShana(i): prints out the Hebrew Calendar for #Hebrew Year i, for example, try: LuachShana(5768); LuachShana:=proc(i) local gu,mu,j,m,d,gd,gu1: mu:=[1,1,i]: gd:=HebrewToGreg(op(mu)): gu:=[]: gu1:=[]: while mu[3]=i do gu:=[op(gu),mu]: gu1:=[op(gu1),gd]: mu:=NextHebrewDate(mu): gd:=NextGregDate(gd): od: print(`The Hebrew Calendar for the Year`, i): m:=Min(i): d:=m[1]: print(` Tishrei `): print(1, EzeYom(d) ): for j from 2 to nops(gu) do d:=d+1 mod 7: if gu[j][2]=gu[j-1][2] then print(gu[j][1], EzeYom(d),`:`, gu1[j][1], MonthG(gu1[j][2]), gu1[j][3] ): else print(EzeKhodesh(gu[j])): print(gu[j][1], EzeYom(d),`:`, gu1[j][1], MonthG(gu1[j][2]), gu1[j][3] ): fi: od: end: #Chagim(i): All the Civil dates of the Holidays of Hebrew year i Chagim:=proc(i) local gu,mu: print(`In the Hebrew Year`, i, `the holidays are as follows`): gu:=[1,1,i]: mu:=HebrewToGreg(op(gu)): print(`Rosh Hashana is on`, mu[1], MonthG(mu[2]), mu[3]): gu:=[10,1,i]: mu:=HebrewToGreg(op(gu)): print(`Yom Kippur is on`, mu[1], MonthG(mu[2]), mu[3]): gu:=[15,1,i]: mu:=HebrewToGreg(op(gu)): print(`Succot is on`, mu[1], MonthG(mu[2]), mu[3]): gu:=[25,3,i]: mu:=HebrewToGreg(op(gu)): print(`Chanukka is on`, mu[1], MonthG(mu[2]), mu[3]): gu:=[15,5,i]: mu:=HebrewToGreg(op(gu)): print(`TuBishvat is on`, mu[1], MonthG(mu[2]), mu[3]): if Min(i)[2]=1 then gu:=[15,6,i]: mu:=HebrewToGreg(op(gu)): print(`Purim is on`, mu[1], MonthG(mu[2]), mu[3]): else gu:=[15,6+1/2,i]: mu:=HebrewToGreg(op(gu)): print(`Purim is on`, mu[1], MonthG(mu[2]), mu[3]): fi: gu:=[15,7,i]: mu:=HebrewToGreg(op(gu)): print(`First Day of Pesach is on`, mu[1], MonthG(mu[2]), mu[3]): gu:=[6,9,i]: mu:=HebrewToGreg(op(gu)): print(`Shavuot is on`, mu[1], MonthG(mu[2]), mu[3]): gu:=[9,11,i]: mu:=HebrewToGreg(op(gu)): print(`TishaBeAv is on`, mu[1], MonthG(mu[2]), mu[3]): end: