'Simplification in Maxima

I have defined the following expression: r:sqrt((y1-x1)^2+(y2-x2)^2); When I differentiate r with respect to y1, i.e. diff(r,y1); I get the answer as (y1-x1)/sqrt((y1-x1)^2+(y2-x2)^2); The answer is technically correct but I would like the answer to be of the form (y1-x1)/r. I have tried using "subst" but I am not getting the desired answer. Here is the code

kill(all);
r:sqrt((y1-x1)^2+(y2-x2)^2);
t1:diff(r,y1);

Can someone please guide me in how to get the desired answer. Thank you



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source