Q:

Calculating the minimum of two distances with tikz

I am trying to make the middle circle fit inside the two larger circles:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\usepackage{amsmath}
\begin{document}
\begin{tikzpicture}
    \coordinate (x0) at (-2.5,0);
    \coordinate (x1) at (2,0);
    \coordinate (y) at (0,0);

    \filldraw[fill=lime,fill opacity=0.3] (x0) circle (4);
    \filldraw[fill=lime,fill opacity=0.3] (x1) circle (3.5);
    \filldraw[fill=blue,fill opacity=0.2]
        let \p0 = ($(x0) - (y)$) in
        let \p1 = ($(x1) - (y)$) in
        (y) circle
        ({min(4 - veclen(\x0,\y0),3.5 - veclen(\x1,\y1))});

    \node at (x0) {\textbullet};
    \node[below left=20pt of x0] {$\operatorname{Ball}(x_0;r_0)$};
    \node at (x1) {\textbullet};
    \node[below right=20pt of x1] {$\operatorname{Ball}(x_1;r_1)$};
    \node at (y) {\textbullet};
    \node[below=0.1pt of y] {$y$};
\end{tikzpicture}
\end{document}

I suppose that taking the minimum of r_0 - d(x_0,y) and r_1 - d(x_1,y) will work, but instead it gives the strange result above.
Edit: The centre of the middle circle will be moved somewhere else not on the axis. The radius has to adapt to the centre.

A:

You don't need veclen here as the relevant points are all on the axis, so  it's just 1.5

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}%grrr
\usepackage{amsmath}%grrr
\begin{document}
\begin{tikzpicture}
    \coordinate (x0) at (-2.5,0);
    \coordinate (x1) at (2,0);
    \coordinate (y) at (0,0);

    \filldraw[fill=lime,fill opacity=0.3] (x0) circle (4);
    \filldraw[fill=lime,fill opacity=0.3] (x1) circle (3.5);
    \filldraw[fill=blue,fill opacity=0.2] (y) circle (1.5);
    \node at (x0) {\textbullet};
    \node[below left=20pt of x0] {$\operatorname{Ball}(x_0;r_0)$};
    \node at (x1) {\textbullet};
    \node[below right=20pt of x1] {$\operatorname{Ball}(x_1;r_1)$};
    \node  at (y) {\textbullet};
    \node[below=0.1pt of y] {$y$};
\end{tikzpicture}
\end{document}

A:

You have to specify the units for the radius in the calculation:
(y) circle
    ({min(4cm - veclen(\x0,\y0),3.5cm - veclen(\x1,\y1))});

A:

Here is yet another solution that only needs the specification of the two circles and computes the rest by itself. For the result see the other answers.
\documentclass[border=1mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\usepackage{amsmath}
\begin{document}
\begin{tikzpicture}[x=1cm,y=1cm]
    \coordinate (A) at (-2.5,0); % center first circle
    \newcommand\ra{4cm}          % radius first circle
    \coordinate (B) at (2,0);    % center first circle
    \newcommand\rb{3.5cm}        % radius first circle

    \coordinate (BA) at ($(B)!\rb!(A)$); % point on circle around B towards A
    \coordinate (AB) at ($(A)!\ra!(B)$); % point on circle around A towards B
    \coordinate (C) at ($0.5*(BA)+0.5*(AB)$); % center third circle

    \filldraw[fill=lime,fill opacity=0.3] (A) circle (\ra);
    \node at (A) {\textbullet};
    \node[below left=20pt of A] {$\operatorname{Ball}(x_0;r_0)$};

    \filldraw[fill=lime,fill opacity=0.3] (B) circle (\rb);
    \node at (B) {\textbullet};
    \node[below right=20pt of B] {$\operatorname{Ball}(x_1;r_1)$};

    \filldraw[fill=blue,fill opacity=0.2]
       let \p1=($(C)-(AB)$) in
       (C) circle ({veclen(\x1,\y1)});
    \node at (C) {\textbullet};
    \node[below=0.1pt of C] {$y$};
\end{tikzpicture}
\end{document}

