Mathematical best-fit computation by Js