algebraic.py updated

update and fix bugs in location/algebraic.py
addressing some particular scenarios (tbc)