Tip to get optimal cylinder surface area

Share your advanced PureBasic knowledge/code with the community.
User avatar
Psychophanta
Addict
Addict
Posts: 4997
Joined: Wed Jun 11, 2003 9:33 pm
Location: Lípetsk, Russian Federation
Contact:

Tip to get optimal cylinder surface area

Post by Psychophanta »

Old wellknown problem: wanted to know the maximum volume of a cylinder with a minimum quantity of material, i.e. surface area

Code: Select all

;Old wellknown problem: wanted to know the maximum volume of a cylinder with a minimum quantity of material, i.e. surface area
;20170605 by Psychophanta

;Let A the total surface area of the cylinder
;Let V the total inner volume of the cylinder
;Let h its height
;Let r the radius of its base

Define .f V,A,h,r

V=ValF(InputRequester("Maximum volume of a cylinder with a minimum quantity of its total surface","Input the wanted amount of cubic units","350",0))

r=Pow(V/2/#PI,1/3)
h=2*r ; h=V/#PI/r/r
A=3*V/r

MessageRequester("Result","The radius cylinder base must be "+StrF(r)+" linear units,"+#CRLF$+"its height must be "+StrF(h)+" linear units,"+#CRLF$+"its total surface area will have "+StrF(A)+" square units.",#PB_MessageRequester_Ok)
http://www.zeitgeistmovie.com

While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB :mrgreen: