# Finding a function that connects 3 points on a graph in the shortest path.

I have $$3$$ points on a $$2$$d graph. Say, $$(X_1, Y_1)$$, $$(X_2, Y_2)$$, $$(X_3, Y_3)$$. I want to find a function which is sum of several modulus functions which can achieve this .

For example,

1. $$(-1,1)$$, $$(0,0)$$, $$(1,1)$$. The function connecting these points in shortest path is $$|x|$$ or modulus of $$x$$.

2. $$(0,2)$$, $$(1,4)$$, $$(1.25,5)$$. The function connecting these three points in shortest path is $$|x| + |x-1| + |2x+1|.$$

Find the series sum of modulus function that joins $$(X_1, Y_1)$$, $$(X_2, Y_2)$$, $$(X_3, Y_3)$$.

• So say $x_1 < x_2 < x_3$, then the shortest path (that is a function) will be the 2 straight lines that connect these three points. Hint: How can we find a sum of 2 modulus that does this? EG $|2x-1|+|2x+1|$ works for the second example. Commented Jun 24, 2023 at 21:28
• I graphed |2x-1| +|2x+1| and found that it does not work for the second example, it takes a longer path compared to the |x| + |x-1| + |2x+1| Commented Jun 24, 2023 at 21:36
• Sir, your path distance for the three points. i.e., (0,2), (1,4), (1.25,5) is 3.59 .My function gives a path distance of 3.26 Commented Jun 24, 2023 at 21:51
• Oh, I see the error that I made when trying to combine from your solution. I found a sum of 2 modulus hat went through those 3 points, but it didn't give me those 2 line segments so it isn't the shortest distance. $\quad$ So, correcting my example, $|3x+1| + |x-1|$ works for the second example. It agrees with your path on $[0, 1.25]$. Commented Jun 24, 2023 at 21:56
• I had not thought of that sum. one thing I had notice from your solution and mine is that the coordinate (1,4) that is between the other two points has to remain a critical point, while the other two coordinates don't really need to. Commented Jun 24, 2023 at 22:04

Further Hint: $$\max (a, b) = \frac{ |a+b| + |a-b| } { 2}$$.
Find a similar formula for $$\min (a, b)$$.