“Is there a logic which allows to define functions and relationships both through formulas and by algorithms?”
For me it seems the wrong question. There isn't any special `logic´. All we do in math should hold (the) logic. And this is what we are able to understand. This understanding has to be without any contradiction on the background of all knowing so far and as you are able to take care about.
Propositional dynamic logic, and more generally the entire family of dynamic logics, might fit the bill here. Essentially, these are multimodal logics constructed by introducing a modality [\alpha]\phi which captures that "after executing the program \alpha then the formula \phi is true."
My memory is that Goldblatt's "logics of time and computation" contains a nice presentation of dynamic logic.
`Logic´, as used at this question, better should be presented by the expression `theory´.
Ever `logic´ is to use. Otherwise nonsense or unproved hypothesis.
Math depends on proofs / evidence. Proofs depend on assertions which are to verify. But for to do an assertion you need some fundamental definitions.
All this comes first before you will be able to do propositional dynamic logic.
Note, all at math is handling quantities and their combination. So at first the elements and further all the combinations which should hold without any contradiction.