Given H (Hypotenuse) and A (area) of a right angled triangle, find the dimensions of right angled triangle such that the hypotenuse is of length H and its area is A. If no such triangle exists, print “Not Possible”.
Input : H = 10, A = 24 Output : P = 6.00, B = 8.00 Input : H = 13, A = 36 Output : Not Possible
Before moving to exact solution, let’s do some of mathematical calculations related to properties of Right angled triangle.
Suppose H = Hypotenuse, P = Perpendicular, B = Base and A = Area of right angled triangle.
We have some sort of equations as :
P^2 + B^2 = H^2 P * B = 2 * A (P+B)^2 = P^2 + B^2 + 2*P*B = H^2 + 4*A (P+B) = sqrt(H^2 + 4*A) ----1 (P-B)^2 = P^2 + B^2 - 2*P*B = H^2 - 4*A mod(P-B) = sqrt(H^2 - 4*A) ----2 from equation (2) we can conclude that if H^2 < 4*A then no solution is possible. Further from (1)+(2) and (1)-(2) we have : P = (sqrt(H^2 + 4*A) + sqrt(H^2 - 4*A) ) / 2 B = (sqrt(H^2 + 4*A) - sqrt(H^2 - 4*A) ) / 2
Below is the implementation of above approach:
P = 3.00 B = 4.00
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.
- Find all sides of a right angled triangle from given hypotenuse and area | Set 1
- Find the hypotenuse of a right angled triangle with given two sides
- Find the height of a right-angled triangle whose area is X times its base
- Check whether right angled triangle is valid or not for large sides
- Number of possible pairs of Hypotenuse and Area to form right angled triangle
- Check if a right-angled triangle can be formed by the given coordinates
- Area of Circumcircle of a Right Angled Triangle
- Area of Incircle of a Right Angled Triangle
- Check if a right-angled triangle can be formed by moving any one of the coordinates
- Count of Right-Angled Triangle formed from given N points whose base or perpendicular are parallel to X or Y axis
- Dividing the rectangle into n right-angled triangles
- Count right angled triangles in a matrix having two of its sides parallel to sides of the matrix
- Biggest Reuleaux Triangle within a Square which is inscribed within a Right angle Triangle
- Kth Smallest Element of a Matrix of given dimensions filled with product of indices
- Find other two sides of a right angle triangle
- Find other two sides and angles of a right angle triangle
- Biggest Reuleaux Triangle inscribed within a Square inscribed in an equilateral triangle
- Program to print a Hollow Triangle inside a Triangle
- Maximum number of 2x2 squares that can be fit inside a right isosceles triangle
- Check if right triangle possible from given area and hypotenuse
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.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.
Improved By : vt_m