Don't understand how they figured out the equations.

1 view (last 30 days)
So I have attached the problem that is part of my final review. I have also the code that will give me the answer (shown below). My question is... how did they figure out the equation for "L" and "P"?? I know that it is mostly algebra but still not sure. Any help would be great!
w = 6; %width in meters
A = 80; %area in meters squared
%solve for the length, terms of A, w
L = (A - w^2/4)/w;
%solve for the perimeter
P = 2*L + w + 2*w/sqrt(2);
%display your answers
fprintf('The length is %5.2f\n ', L)
fprintf('The total perimeter is %5.2f\n ', P)
%done

Answers (3)

the cyclist
the cyclist on 4 Dec 2014
Here are some facts that may help you make the connection:
The enclosure (area = A) is made up of two parts:
  • A rectangle of area L * W
  • A triangle of area D*D/2
The triangle is a right triangle with side lengths D, D, and W. W is the hypotenuse, so
  • D^2 + D^2 = W^2
Is that enough for you to see how the whole thing works?

Star Strider
Star Strider on 4 Dec 2014
Edited: Star Strider on 4 Dec 2014
I don’t see ‘P’ anywhere, so I’ll wait for clarification on it.
The rest is relatively straightforward:
First, consider the triangle on the right —
W^2 = 2*D^2
D = W/sqrt(2)
For the area, since it’s a right triangle, D = base = height and the area of it is —
Atri = 0.5 * D^2
The area of the rectangle bounded by L and W is obvious.
So the area of the entire figure is —
Atot = W * L + 0.5 * D^2
I’ll leave you to simplify this expression and do all the coding. (It’s all just secondary-school geometry and algebra.)
  2 Comments
Star Strider
Star Strider on 4 Dec 2014
I assumed that, but since it was over the horizon (not in the Question), I wanted to be sure. I also wanted to be sure it wasn’t ‘D’.

Sign in to comment.


Jessica
Jessica on 4 Dec 2014
ok I see. I was confused on why they were dividing by 4 to find "L". Thanks for the help!! :)

Categories

Find more on Computational Geometry in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!