Largest triangle that can be inscribed in an ellipse | Function to find the area of the triangle ; a and b cannot be negative ; area of the triangle ; Driver code
function trianglearea ( a , b ) { if ( a < 0 b < 0 ) return - 1 ; var area = ( 3 * Math . sqrt ( 3 ) * Math . pow ( a , 2 ) ) / ( 4 * b ) ; return area ; } var a = 4 , b = 2 ; document . write ( trianglearea ( a , b ) . toFixed ( 4 ) ) ;