This is an absolute brilliant snippet from EREL:
https://b4x.com/android/forum/threads/how-to-convert-a-linear-relation-to-a-x-y.68349/#post-433408
https://b4x.com/android/forum/threads/how-to-convert-a-linear-relation-to-a-x-y.68349/#post-433408