Starting from:

$25

COMP1012-Assignment 3 & 4 Solved

Question 1:
  In this assignment, we are going to find the length and area under a curve. The curve that you will consider in this assignment is given by the (single variable) function    . So for each value of , we will get a corresponding y value. For example, If we have    values of , we will get   values for . Now, if we plot these values, we will get a figure like the one we showed here.

 

 line and so on. As the two neighboring points are straight line, we need to calculate the Euclidean distance between the two neighboring points and then take the summation of those distances. For example, suppose the Euclidean distance between     and        is           , p1 and         is           , ... ... and   and

. So, if we have  points, the length of the

  indicates the Euclidean distance between two points. The Euclidean distance can be

The surface area of the solid obtained when you revolve the curve   around the  -axis can be approximated in a way that is similar to the way we approximated the length of the curve. We can approximate the surface area of a small part of the solid and then take the summation of those small parts to finally get the approximate surface area.  This can be compared to [frustums]

[tutorial.math.lamar.edu/Classes/CalcII/SurfaceArea.aspx]. Frustums look like the figure below.

 

What to do:

 

In your program, you need to implement the following functions. generatePoints( ):

This function will generate  points using arange function where   is the start and   is the end and   is the step.

evalFunction( ):

This function takes one parameter as input. The parameter   is an  array of numbers. It implements the curve function   mentioned in the description and returns the array. calculateSegmentDists(xx, yy):

This function takes two numpy array as input. The values in the   array indicate   axis and values in   array indicates   axis. It then returns the distances between each segment as an array. Here, the

segment means the Euclidean distance between the neighboring points.

calculateCurveLen(segDists):

This function takes segment distances as input and returns the curve length. calculateSurfaceArea(segDists, y):

This function takes segment distances   and functional values given by    as input and return the surface area for the solid. main():

The program will begin from this function. In this function, you need to use a for loop that starts at 1 and ends at 100 with step 10. Inside the for loop, you need to call the generatePoints function. The first parameter of generatePoints will be the value of for loop variable. For example, if we write:

 

here, i is the for loop variable. The second parameter of generatePoints function will be the value of for loop variable, i + 10 and you can set the third parameter, interval = 1. Then you need to call other functions inside the for loop to get surface areas and length of the curve for each iteration. For example, if the for loop iterates   times, you will get   lengths and areas. See sample output for clarification. You also need to print the values. printValues(starts, ends, lengths, areas):

This function takes a list of start points, end points, lengths and areas as input and show them in the output screen as given below.

 

 Sample output:

 

 

 

"Programmed by..."
 

Use the following code snippet at the end of your script to print out the time and end of processing message:

 

More products