Find family coordinates, starting and ending points

I am writing a script to find the placed family location with its starting locations and use formula method to calculate the ending locations.
Not know why error comes and can anyone please help.
Your kindly help will be much appreciated!

Math “M” in upper case

Yes. But still have problems.

x = (x + …) replace x with another variable
A = (x + …)
same for y, z

Thank you