Para determinar la relación de aspecto , debe tener una relación a la que apuntar.

function getHeight(length, ratio) {
var height = ((length)/(Math.sqrt((Math.pow(ratio, 2)+1))));
return Math.round(height);
}

function getWidth(length, ratio) {
var width = ((length)/(Math.sqrt((1)/(Math.pow(ratio, 2)+1))));
return Math.round(width);
}
En este ejemplo, utilizo 16:10
ya que esta es la típica relación de aspecto del monitor.
var ratio = (16/10);
var height = getHeight(300,ratio);
var width = getWidth(height,ratio);
console.log(height);
console.log(width);
Los resultados de arriba serían 147
y300
max-width
ymax-height
a100%
.