Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. You are designing a can shaped as a right circular cylinder with a capac- ity

ID: 3716875 • Letter: 2

Question

2. You are designing a can shaped as a right circular cylinder with a capac- ity of 2 liters. You want to choose dimensions that minimize the surface area of the can. If r represents the cylinder radius in centimeters and h the cylinder height, the dimensions are related as tr2h = 2000 Our cylinder's surface area can be expressed as Expressing h in terms of r, we can rewrite the area formula as A - 2r2+ 4000 The graph of A is concave up throughout its domain. Thus a zero of dA/dr will give us a minimum value for A. Write a program that uses Newton's method to find this zero and then displays the desired cylinder dimensio represent dA/dr. ns. Be sure to define a function named surfaceAreaPrime to 3. Imnlement the class Can described in Section 6.1 Review Question 1. In-

Explanation / Answer

#include <bits/stdc++.h>
using namespace std;
const double pi = 3.141592653589793;
double surfaceArea(double r)
{
return 2.0*pi*r*r + (4000.0/r);
}
double surfaceAreaPrime(double r)
{
return 4.0*pi*r - (4000.0/(r*r));
}
double surfaceAreaDoublePrime(double r)
{
return 4.0*pi+(2.0*4000.0)/(r*r*r);
}
int main(void)
{
double epsilon=1e-14;
double tolerance=1e-6; //6 digit accuracy requried
bool solution_found=false;
double x0,x1;
x0=1.0;
int maxIterations=10;
for(int i=1;i<=maxIterations;i++)
{
if(abs(surfaceAreaDoublePrime(x0)) < epsilon)//Don't want to divide by too small of a number
break; //Leave the loop
x1=x0-(surfaceAreaPrime(x0)/surfaceAreaDoublePrime(x0));
//cout<<x0<<" "<<x1<<endl;
if(fabs(x1-x0)<=tolerance*fabs(x1)) //If the result is within the desired tolerance
{
solution_found=true;
break;
}
x0=x1;
}
if(solution_found)
printf("%0.6f ",x0);
else
printf("Solution did not converge ");
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote