Here's a page with code for all of Photoshop's blend modes. http://inlandstudios.com/en/?p=851 It's written using C macros so it looks a bit weird, but the maths you want is all there, including dodge and burn. I used this info a while ago when I wanted to create a procedural animation using the overlay blend mode.
If you search for Photoshop blend modes, you'll find a lot more info out there.
(EDIT) Heres another good page on the blend modes: http://photoblogstop.com/photoshop/photoshop-blend-modes-explained