- Given a length of wire P units long, where P is an integer, it is possible in some cases to bend
the wire into an isosceles triangle(with two sides equal) where the lengths of all the sides are
also integers. For example a wire of length P = 3 units can be bent into an isosceles triangle,
while a wire of length P = 4 can not. For some lengths there is more than one isosceles
triangle with integer length sides. Of those isosceles triangles with integer length sides some
will have an area which is also an integer, while others will not.
The area of a triangle, given the lengths of its three sides a; b; c, is
Area = m(m-a)(m-b)(m-c);
where m = (a + b + c)/2.
(a) Write a function, which has as input an integer length P, and outputs(not prints) a
triple (a, b, A), where a is the integer length of the two equal length sides of an isosceles
triangle, b is the integer length of the other side, and A is the integer area of the
triangle. The function should output non-zero values (a,b,A) when there is ONLY
ONE isosceles triangle which has both integer length sides, and integer area,
otherwise it should return (0,0, 0). Test your function with P = 15, where the output
should be (0, 0, 0) and P = 16, where the output should be (5, 6, 12).
(b) Write a small program, using your function above, to print out all the lengths P, a, b
and Area A, in that order, of the first 12 unique triangles with integer sides and integer
area, such that P > 100. Do not print out the values where the output of your function
is (0; 0; 0).
You may only use the sqrt() and fix() Matlab functions for this question.