Given are two circles whose radii are given, such that the smaller lies completely within the bigger circle, and they touch each other at one point. We have to find the length of the perpendicular bisector of the line joining the centres of the circles.

**Examples:**

Input:r1 = 5, r2 = 3Output:9.79796Input:r1 = 8, r2 = 4Output:15.4919

**Approach**:

- Let the two circles have center at
**A**and**B**.The perpendicular bisector**PQ**, bisects the line at**C**. - Let radius of bigger circle =
**r1**

radius of smaller circle =**r2** - so,
**AB = r1-r2**, - therefore,
**AC = (r1-r2)/2** - In, the figure, we see

**PA = r1** - in triangle
**ACP**,

**PC^2 + AC^2 = PA^2**

PC^2 = PA^2 – AC^2

PC^2 = r1^2 – (r1-r2)^2/4 - so,
**PQ = 2*√(r1^2 – (r1-r2)^2/4)**

Length of the perpendicular bisector = 2 * sqrt(r1^2 – (r1-r2)*(r1-r2)/4)

Below is the implementation of the above approach:

## C++

`// C++ program to find the Length ` `// of the perpendicular bisector ` `// of the line joining the centers ` `// of two circles in which one lies ` `// completely inside touching the ` `// bigger circle at one point ` ` ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `void` `lengperpbisect(` `double` `r1, ` `double` `r2) ` `{ ` ` ` `double` `z = 2 * ` `sqrt` `((r1 * r1) ` ` ` `- ((r1 - r2) ` ` ` `* (r1 - r2) / 4)); ` ` ` ` ` `cout << ` `"The length of the "` ` ` `<< ` `"perpendicular bisector is "` ` ` `<< z << endl; ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `double` `r1 = 5, r2 = 3; ` ` ` `lengperpbisect(r1, r2); ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java program to find the Length ` `// of the perpendicular bisector ` `// of the line joining the centers ` `// of two circles in which one lies ` `// completely inside touching the ` `// bigger circle at one point ` ` ` `class` `GFG { ` ` ` `static` `void` `lengperpbisect(` `double` `r1, ` `double` `r2) ` `{ ` ` ` `double` `z = ` `2` `* Math.sqrt((r1 * r1) ` ` ` `- ((r1 - r2) ` ` ` `* (r1 - r2) / ` `4` `)); ` ` ` ` ` `System.out.println(` `"The length of the "` ` ` `+ ` `"perpendicular bisector is "` ` ` `+ z ); ` `} ` ` ` `// Driver code ` `public` `static` `void` `main(String[] args) ` `{ ` ` ` `double` `r1 = ` `5` `, r2 = ` `3` `; ` ` ` `lengperpbisect(r1, r2); ` `} ` `} ` ` ` `// This code has been contributed by 29AjayKumar ` |

*chevron_right*

*filter_none*

## Python3

` ` `# Python program to find the Length ` `# of the perpendicular bisector ` `# of the line joining the centers ` `# of two circles in which one lies ` `# completely inside touching the ` `# bigger circle at one point ` ` ` `def` `lengperpbisect(r1, r2): ` ` ` `z ` `=` `2` `*` `(((r1 ` `*` `r1) ` `-` `((r1 ` `-` `r2) ` `*` `(r1 ` `-` `r2) ` `/` `4` `))` `*` `*` `(` `1` `/` `2` `)); ` ` ` ` ` `print` `(` `"The length of the perpendicular bisector is "` `, z); ` ` ` ` ` `# Driver code ` `r1 ` `=` `5` `; r2 ` `=` `3` `; ` `lengperpbisect(r1, r2); ` ` ` `# This code contributed by PrinciRaj1992 ` |

*chevron_right*

*filter_none*

## C#

`// C# program to find the Length ` `// of the perpendicular bisector ` `// of the line joining the centers ` `// of two circles in which one lies ` `// completely inside touching the ` `// bigger circle at one point ` `using` `System; ` ` ` `class` `GFG ` `{ ` ` ` `static` `void` `lengperpbisect(` `double` `r1, ` `double` `r2) ` `{ ` ` ` `double` `z = 2 * Math.Sqrt((r1 * r1) ` ` ` `- ((r1 - r2) ` ` ` `* (r1 - r2) / 4)); ` ` ` ` ` `Console.WriteLine(` `"The length of the "` ` ` `+ ` `"perpendicular bisector is "` ` ` `+ z ); ` `} ` ` ` `// Driver code ` `public` `static` `void` `Main() ` `{ ` ` ` `double` `r1 = 5, r2 = 3; ` ` ` `lengperpbisect(r1, r2); ` `} ` `} ` ` ` `// This code has been contributed by anuj_67.. ` |

*chevron_right*

*filter_none*

**Output:**

The length of the perpendicular bisector is 9.79796

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Ratio of the distance between the centers of the circles and the point of intersection of two direct common tangents to the circles
- Ratio of the distance between the centers of the circles and the point of intersection of two transverse common tangents to the circles
- Distance between centers of two intersecting circles if the radii and common chord length is given
- Number of common tangents between two circles if their centers and radius is given
- Find the radii of the circles which are lined in a row, and distance between the centers of first and last circle is given
- Maximum possible intersection by moving centers of line segments
- Slope of perpendicular to line
- Perpendicular distance between a point and a Line in 2 D
- Find foot of perpendicular from a point in 2 D plane to a Line
- Length of the transverse common tangent between the two non intersecting circles
- Length of the direct common tangent between two externally touching circles
- Length of direct common tangent between the two non-intersecting Circles
- Length of direct common tangent between two intersecting Circles
- Find the side of the squares which are lined in a row, and distance between the centers of first and last square is given
- Find the foot of perpendicular of a point in a 3 D plane
- Count of Right-Angled Triangle formed from given N points whose base or perpendicular are parallel to X or Y axis
- Number of triangles formed by joining vertices of n-sided polygon with two common sides and no common sides
- Check if number formed by joining two Numbers is Perfect Cube
- Length of rope tied around three equal circles touching each other
- Equation of straight line passing through a given point which bisects it into two equal line segments

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.