# Divide an isosceles triangle in two parts with ratio of areas as n:m

Given the height of an isosceles triangle and two integers , . The task is to find the height from top of the triangle such that if we make a cut at height h from top parallel to base then the triangle must be divided into two parts with the ratio of their areas equal to **n:m**.

**Examples**:

Input : H = 4, n = 1, m = 1 Output : 2.82843 Input : H = 4, n = 1, m = 0 Output : 4

First of all before proceeding let us mention some of the basic properties of an isosceles triangle.

Let ▲ABC is an isosceles triangle with AB = AC and BC being unequal side and base of the triangle. If D is mid-point of BC, then AD is our height H. Also, if we draw a parallel line to BC which cuts AB and AC at points E and F respectively and G being the midpoint of EF then ▲AEG is similar to ▲ABD, ▲AFG is similar to ▲ACD, ▲AEF is similar to ▲ABC, and by using properties of similar triangles we can conclude the following points:

**AE/AB = AG/AD = EG/BD = EF/BC = AF/AC —–(i)**

As per problem’s requirement, we have to find out the height h, such that the ratio of the area of ▲AEF to the area of trapezium EFCB = n:m.

Let, h is the height of cut from the top of the triangle.

Now, area of ▲AEF = 0.5 * AG * EF and area of trapezium EFCB = 0.5 * GD * (EF+BC)

also, ratio of both is n:m.

So, we can say that ratio of area of ▲AEF to area of ▲ABC is equal to n :(n+m).

=> area of ▲AEF / area of ▲ABC = n / (n+m)

=> (0.5 * AG * EF) / (0.5 * AD * BC) = n / (n+m)

=> (AG/AD) * (EF/BC) = n / (n+m)

=> (EF/BC) * (EF/BC) = n / (n+m)

=> h^{2}/H^{2}= n / (n+m)

=>h = H*sqrt(n/(n+m))

Below is the implementation of the above approach:

## C++

`// C++ program, to find height h ` `// which divide isosceles triangle ` `// into ratio n:m ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to return the height ` `float` `heightCalculate(` `int` `H, ` `int` `n, ` `int` `m) ` `{ ` ` ` `// type cast the n, m into float ` ` ` `float` `N = n * 1.0; ` ` ` `float` `M = m * 1.0; ` ` ` `// calculate the height for cut ` ` ` `float` `h = H * ` `sqrt` `(N / (N + M)); ` ` ` `return` `h; ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `int` `H = 10, n = 3, m = 4; ` ` ` `cout << heightCalculate(H, n, m); ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java program, to find height h ` `// which divide isosceles triangle ` `// into ratio n:m ` ` ` `import` `java.io.*; ` ` ` `class` `GFG { ` ` ` ` ` `// Function to return the height ` `static` `float` `heightCalculate(` `int` `H, ` `int` `n, ` `int` `m) ` `{ ` ` ` `// type cast the n, m into float ` ` ` `float` `N = (` `float` `)(n * ` `1.0` `); ` ` ` `float` `M = (` `float` `)(m * ` `1.0` `); ` ` ` `// calculate the height for cut ` ` ` `float` `h = H *(` `float` `) Math.sqrt(N / (N + M)); ` ` ` `return` `h; ` `} ` ` ` `// Driver code ` ` ` ` ` ` ` `public` `static` `void` `main (String[] args) { ` ` ` `int` `H = ` `10` `, n = ` `3` `, m = ` `4` `; ` ` ` `System.out.print( heightCalculate(H, n, m)); ` ` ` `} ` `} ` |

*chevron_right*

*filter_none*

## Python3

`# Python 3 program, to find height ` `# h which divide isosceles triangle ` `# into ratio n:m ` `from` `math ` `import` `sqrt ` ` ` `# Function to return the height ` `def` `heightCalculate(H, n, m): ` ` ` ` ` `# type cast the n, m into float ` ` ` `N ` `=` `n ` `*` `1.0` ` ` `M ` `=` `m ` `*` `1.0` ` ` ` ` `# calculate the height for cut ` ` ` `h ` `=` `H ` `*` `sqrt(N ` `/` `(N ` `+` `M)) ` ` ` `return` `h ` ` ` `# Driver code ` `if` `__name__ ` `=` `=` `'__main__'` `: ` ` ` `H ` `=` `10` ` ` `n ` `=` `3` ` ` `m ` `=` `4` ` ` `print` `(` `"{0:.6}"` `. ` ` ` `format` `(heightCalculate(H, n, m))); ` ` ` `# This code is contributed ` `# by Surendra_Gangwar ` |

*chevron_right*

*filter_none*

## C#

`// C# program, to find height h ` `// which divide isosceles triangle ` `// into ratio n:m ` `using` `System; ` ` ` `class` `GFG ` `{ ` ` ` `// Function to return the height ` `static` `float` `heightCalculate(` `int` `H, ` ` ` `int` `n, ` `int` `m) ` `{ ` ` ` `// type cast the n, m into float ` ` ` `float` `N = (` `float` `)(n * 1.0); ` ` ` `float` `M = (` `float` `)(m * 1.0); ` ` ` ` ` `// calculate the height for cut ` ` ` `float` `h = H * (` `float` `) Math.Sqrt(N / (N + M)); ` ` ` `return` `h; ` `} ` ` ` `// Driver code ` `public` `static` `void` `Main () ` `{ ` ` ` `int` `H = 10, n = 3, m = 4; ` ` ` `Console.WriteLine(heightCalculate(H, n, m)); ` `} ` `} ` ` ` `// This code is contributed ` `// by inder_verma ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP program, to find height h ` `// which divide isosceles triangle ` `// into ratio n:m ` ` ` `// Function to return the height ` `function` `heightCalculate(` `$H` `, ` `$n` `, ` `$m` `) ` `{ ` ` ` `// type cast the n, m into float ` ` ` `$N` `= ` `$n` `* 1.0; ` ` ` `$M` `= ` `$m` `* 1.0; ` ` ` ` ` `// calculate the height for cut ` ` ` `$h` `= ` `$H` `* sqrt(` `$N` `/ (` `$N` `+ ` `$M` `)); ` ` ` `return` `$h` `; ` `} ` ` ` `// Driver code ` `$H` `= 10; ` `$n` `= 3; ` `$m` `= 4; ` `echo` `heightCalculate(` `$H` `, ` `$n` `, ` `$m` `); ` ` ` `// This code is contributed ` `// by anuj_67 ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

6.54654

## Recommended Posts:

- Find the altitude and area of an isosceles triangle
- Maximum number of 2x2 squares that can be fit inside a right isosceles triangle
- Maximum number of squares that can fit in a right angle isosceles triangle
- Divide a big number into two parts that differ by k
- Divide number into two parts divisible by given numbers
- Divide a number into two parts such that sum of digits is maximum
- Minimum cuts required to divide the Circle into equal parts
- Count number of ways to divide a number in 4 parts
- Split a number into 3 parts such that none of the parts is divisible by 3
- Ratio of mth and nth terms of an A. P. with given ratio of sums
- Sum of Areas of Rectangles possible for an array
- Check if difference of areas of two squares is prime
- Number of Isosceles triangles in a binary tree
- Biggest Reuleaux Triangle within a Square which is inscribed within a Right angle Triangle
- Biggest Reuleaux Triangle inscribed within a Square inscribed in an equilateral triangle

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.