How to perform calculations similar to this page?