Git: Merging and detached HEAD

A while ago I had a problem where I needed to recover code from an earlier branch by using the git checkout option. I then proceeded to develop that branch, and got a detached HEAD. This situation doesn’t allow you to push your work back to master or even to remote. To resolve this state, and be happily back on master, you need to:

git merge master HEAD #resolve all conflicts with master
git branch temp-branch
git checkout master
git merge temp-branch
git push origin master

Taken from:

The max(a,b) function

My latest post dealt with how to use represent the maximum function as a combination of exp and log function. The problem with these functions is that they are not the exact representation of the maximum function. Here is another suggestion on how to represent the maximum function:

max(a,b)=|a-b|/2 + (a+b)/2

This function is easy to derive, e.g. assume |a-b| is equivalent to ((a-b)^2) ^0.5. The derivative is not defined everywhere, and is not continuous, but you can define the derivative yourself at these points for numerical reasons.