Question

using python 3 notebook

only 4.2

An ellipse is defined by the equation which is solved for y to give a function yx) for the ellipse. 4.1 Define a function that takes x, a, b as input and returns y Make a plot of the full ellipse including all four quadrants using a-2 and b-1. Use a blue, dashed line. 4.2 Calculate the area under a quarter of the ellipse, use the top-right quadrant by approximating the quarter ellipse with vertical rectangles. The side length of each rectangle is Ax, while Ay follows from the formula for the circumference. Make sure that you calculate Δ y for each rectangle for the X value centered in the x direction in each Δ. 1. Make a bar plot of the rectangles and overplot the line of the ellipse to show this situation exactly. Hint: part of each rectangle should be outside the ellipse, and small areas inside the ellipse are not covered 2. Now calculate the area. Do not use a for loop but instead use only vector operations. Verify that you have the right answer by comparing it with the value computed from the formula for the area of the lipse Aellipexab 3. Calculate the difference between the sum of the rectangles and the value from the formula for 10 and 30 rectangles and save these differences in the variables dA10 and dA38. 4. Open a file called ellipse.dat and write two rows with two columns. The columns are the number of rectangles and the differences dA calculated in 3. Use formatted output: 2 digits for the integer, one space. 7 digits for the float with 5 after the decimal point. Close the file check the output and add it to your assignment commit. 5. Comment on the values dA18 and da3e. Why are they different?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

as per HOMEWORKLIB RULES, i have answered only 4.1, post again for the rest

Below is the full code for your question.

I will provide the complete description at the bottom.

import numpy as np
import matplotlib.pyplot as plt

def func(x,a,b):
return (1-((x**2)*(b**2))/a**2)**0.5

X = np.linspace(-2,2,20)
X = X.tolist()
y = [func1(x,2,1) for x in X]
y += [-func1(x,2,1) for x in lin[::-1]]

X += X[::-1]

plt.plot(X,y)

output :

I have defined the function for your provided equation. See that in the function ** is an exponentiation operator. so for square a value we make a**2 and for square root of a variable  we make a**0.5.

Now to plot the graph, I have taken 20 linearly separated values between -2 and 2 as x value. I have taken -2 and 2 because given a is 2. so the x value will range from -2 to 2. Next I have calculated the values of y for each values of x. As the output of function gives only positive numbers, I have also taken the negative values for y so that we will get the full ellipse. a[::-1] will give the reversed list. Next I have used plot function from plt to plot the values of X and y.

Add a comment
Know the answer?
Add Answer to:
using python 3 notebook only 4.2 An ellipse is defined by the equation which is solved...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • full steps and how to solve please 1. Let y-x'. a) Using 4 rectangles of equal width (Ar-2 )and the right endpoi...

    full steps and how to solve please 1. Let y-x'. a) Using 4 rectangles of equal width (Ar-2 )and the right endpoint of the subinterval for the height of the rectangle, estimate the area under the curve on the interval [0,8. Then sketch a graph of the function over the interval along with the rectangles. b) Using 4 rectangles of equal width (Ax 2 and the left endpoint of the subinterval for the height of the rectangle, estimate the area...

  • Python Programming language. Complete the problems below using Jupyter Notebook. Problem Needs to be solved from...

    Python Programming language. Complete the problems below using Jupyter Notebook. Problem Needs to be solved from number #1 link provided for the Data: -----> https://docs.google.com/spreadsheets/d/1TqhyxFKQlOHAyXpQBL-4C96kgZFBoMwUgE8-b33CqPQ/edit?usp=sharing PROBLEMS # 0.0 Import the libraries (pandas, matplotlib, and seaborn) Include the code line: %matplotlib inline #Include the code line: plt.style.use(“ggplot”) #Load the data using pandas #Inspect the data using head(), dtypes ANSWERD: import pandas as pd import matplotlib.pyplot as plt import seaborn as sns plt.style.use('ggplot') %matplotlib inline df = pd.read_csv() print(df.head()) print(df.dtypes) # 1...

  • question #5 is “what is the secret?”. The secret is that the squares have the largest...

    question #5 is “what is the secret?”. The secret is that the squares have the largest area when the perimeters are all the same. 1. Does the reasoning you used for answering Question 5 constitute a complete proof? How would you show that no other rectangle with a perimeter of 100 meters will have an area larger than the rectangle you discovered when answering Question 5? Do this in two ways. a. Give a geometric proof using the following figure....

  • We've been using L'Hopitals as well as family of functions and modeling. stuff from chapter 4 in the 7th Editio...

    We've been using L'Hopitals as well as family of functions and modeling. stuff from chapter 4 in the 7th Edition of single variable calculus book. 1. (7 points) A rectangle is located with its base along the x axis, one corner at (8,0) and the opposite corner on the graph y = ln(x) for some 1 x 10. Draw a picture of the given scenario. a. If the other corner along the x axis an x value of e, what...

  • Lab 7: Void and Value-Returning Functions Lab 7: Void and Value-returning functions             ...

    Lab 7: Void and Value-Returning Functions Lab 7: Void and Value-returning functions              Due date: 11/6/19 Problem: Write a C++ program that calculates the areas of a rectangle and of an ellipse.                    Area = base * height             Area = π * radius a * radius b Note: all images extracted from http://www.mathsisfun.com/area-calculation-tool.html ------------------------------------------------------------------------------------------------------------------------ Your task: implement in C++ the algorithm solution shown below. ------------------------------------------------------------------------------------------------------------------------ Part A (79...

  • Required information Area of Rectangles and Triangles As we progress in economics courses, there are some...

    Required information Area of Rectangles and Triangles As we progress in economics courses, there are some concepts that are best handled geometrically as opposed to (or in addition to) algebraically. We might, for example, need to calculate the area of a triangle, a rectangle, or a trapezoid. Therefore, this document will cover the basics of each, and give examples for practice. The area of a rectangle or square A rectangle is a four-sided figure that has two sets of parallel...

  • Required information Area of Rectangles and Triangles As we progress in economics courses, there are some...

    Required information Area of Rectangles and Triangles As we progress in economics courses, there are some concepts that are best handled geometrically as opposed to (or in addition to) algebraically. We might, for example, need to calculate the area of a triangle, a rectangle, or a trapezoid. Therefore, this document will cover the basics of each, and give examples for practice. The area of a rectangle or square A rectangle is a four-sided figure that has two sets of parallel...

  • Required information Area of Rectangles and Triangles As we progress in economics courses, there are some concepts that...

    Required information Area of Rectangles and Triangles As we progress in economics courses, there are some concepts that are best handled geometrically as opposed to (or in addition to) algebraically. We might, for example, need to calculate the area of a triangle, a rectangle, or a trapezoid. Therefore, this document will cover the basics of each, and give examples for practice. The area of a rectangle or square A rectangle is a four-sided figure that has two sets of parallel...

  • Show clearly your steps answering requests below and upload a single file. (3 points each) (1)Use...

    Show clearly your steps answering requests below and upload a single file. (3 points each) (1)Use a Riemann sum to estimate the area under the curve of the function f(x) = x2 - 6x + 10 between x = 0 and x = 8 using the midpoint rule with n= 2 subintervals. State the midpoints and other values that are used, and the answer. (2) Graph the above f (x) between x = 0 and x = 8, show the...

  • EXAMPLE Le rectangliste ustimate the area and the parabola y - 4x2 from 0 to 1(the...

    EXAMPLE Le rectangliste ustimate the area and the parabola y - 4x2 from 0 to 1(the parabolic region Sillustrated to the left . SOLUTION We first notice that there must be where between 0 and 4 because S is continued in a rectangle of Side 1 and 4, but we can can do bethan that. Suppose we divide the region into four strips by drawing articles 1- ts in this figure (allalaw. 2.1 21.45 3 A Vin Exampled (D) We...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT