Let ABC be a triangle with side lengths a, b, c and a=2, b+2c=4. Find the value of c which maximizes the area of the triangle.
clc
a=2; prev=0;
for b= 1.82970846:.000000002: 1.82970849
c=(4-b)/2;
s=(a+b+c)/2;
A=sqrt(s*(s-a)*(s-b)*(s-c));
if A==real(A)
disp([b c A A-prev])
end
prev=A;
end
is the final stage of the program after narrowing down the range, and finds the maximal area as:
b c Area
1.829708486 1.085145757 0.98402327954184
|
Posted by Charlie
on 2023-09-04 12:27:26 |