Length of the Diagonal of the Octagon | Function to find the diagonal of the octagon ; side cannot be negative ; diagonal of the octagon ; Driver code
function octadiagonal ( a ) { if ( a < 0 ) return - 1 ; return a * Math . sqrt ( 4 + ( 2 * Math . sqrt ( 2 ) ) ) ; } var a = 4 ; document . write ( octadiagonal ( a ) . toFixed ( 5 ) ) ;