Store Function Value into temporary table
Build a table with every day for the next few years:

 CREATE TABLE foo (
     dy DATE NOT NULL,   -- every day
     bow DATE NOT NULL,  -- date (yyyy/mm/dd) of the Beginning Of Week
     eow DATE NOT NULL,
     PRIMARY KEY(dy)
 ) ENGINE=InnoDB;


Then, instead of having a function, JOIN to that table to fetch the bow and/or eow needed.

Meanwhile, DATE_FORMAT(some_date, '%a') yields Sun, Mon, etc.  And WEEKDAY(some_date) gives you 0 for Monday, etc.  These might simplify some of your code.