Math help wanted: Zeller congruence

For general Flowcode discussion that does not belong in the other sections.
Post Reply
MJU20
Posts: 244
http://meble-kuchenne.info.pl
Joined: Tue Dec 08, 2020 5:11 pm
Has thanked: 75 times
Been thanked: 50 times

Math help wanted: Zeller congruence

Post by MJU20 »

I'm trying to get an ESP32 to calculate Zeller's congruence.

This calculates a number that represents the weekday for a certain date.
https://en.wikipedia.org/wiki/Zeller%27s_congruence

I have tried several methods for calculation but it doesn't always return the right number.
In this example I have variables (not shown) for the day, month and year.
If I calculate the Zeller number, it doesn't always work.

I have tried local variables (.val1 ... .val8) as integer, as float and so on.

What can I try next?
This is one of my latest versions where I tested the variables with Floats..
zeller1.jpg
zeller1.jpg (113.42 KiB) Viewed 194 times
Any suggestions?

chipfryer27
Valued Contributor
Posts: 1147
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 284 times
Been thanked: 412 times

Re: Math help wanted: Zeller congruence

Post by chipfryer27 »

Hi

Sorry to be brief, it's stupid O' clock and I'm heading out soon.

Very interesting little project. I would break the calculation down into individual steps containing one action (calculation) and then step through your chart checking each result is as expected. This would hopefully allow you to see where things are going astray.

I do notice that in your post you are assigning .val4 = .val3 /4 then in the next line assigning it to (year / 100). Haven't got time to check if that's correct but initially looks suspect.

Regards

medelec35
Matrix Staff
Posts: 1451
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 512 times
Been thanked: 472 times

Re: Math help wanted: Zeller congruence

Post by medelec35 »

Hello.
I have attached a Flowchart which is not Zeller congruence, but it does calculate the day of the week in any year from 1753 to 2699.
I don't know if it will be useful for you.
Attachments
Day of the week.fcfx
(21.26 KiB) Downloaded 8 times
Martin

MJU20
Posts: 244
Joined: Tue Dec 08, 2020 5:11 pm
Has thanked: 75 times
Been thanked: 50 times

Re: Math help wanted: Zeller congruence

Post by MJU20 »

@Both: Thanks for your reaction!

@chipfryer27 the example is my "disassembled" version of the Zeller congruence.
I've tried it in one calculation but this returned not always a good result.
That is why I decided to make the calculation again but step-by-step.
I can not figure out why this sometimes returns a good and why sometimes a bad result.
Is it because I use the wrong settings for the variables?
But even with a Float this should return a good result...
Strange :-(

@medelec35 Thanks for the example.
You won't believe this but this was something I already started with.
But, this seemed a bit overkill for me :-)
I appreciate this, and maybe, if I can't the Zeller one to work, I will use this one.

Still I wonder why the Zeller doesn't work...
Any suggestions?

medelec35
Matrix Staff
Posts: 1451
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 512 times
Been thanked: 472 times

Re: Math help wanted: Zeller congruence

Post by medelec35 »

MJU20 wrote:
Mon Mar 18, 2024 10:44 pm
But, this seemed a bit overkill for me
The experessions are simplified compared to Zeller congruence in my eyes, but I have place one expression in their own clacluatio box so help you single step to see how it all works.

Of couse you don't need the function call, I added it for my benefit.
MJU20 wrote:
Mon Mar 18, 2024 10:44 pm
Still I wonder why the Zeller doesn't work...
Any suggestions?
I would try without floats.
You don't need floor as the equivalent of floor is just a variable e.g byte, int or uint.
For example if you had intA= 11 and intB = 4
Then result of intA/intB = 2
That is the floor of 2.75
Martin

Post Reply