To calculate the length of a ladder leaning against a wall, you can use the trigonometric function cosine (cos).