CoCalc Public FilesFinaExamMiniProject.ipynbOpen with one click!
Author: Edgar Arevalo
Views : 102
In [ ]:

Final Exam

Name: Edgar Arevalo


Rules for writing in this notebook

  • Insert your name in the first cell of this notebook

  • Answer every part of the mini project in a different cell.

  • To insert a cell use the menu item Insert

  • State the input(s) and output(s) before each of your functions

  • Give your functions suggestive names

  • Restrict the size of figures that you create

J## Mini project 4: Area of a tilted ellipse

Problem formulation

Consider the equation of a conic Ax2+2Bxy+cy2=D A*x^2+2B*x*y+c*y^2=D with ACB2>0.A*C-B^2>0. Recall that the condition means that the conic is an ellipse.

  1. (manual) Use completing the square technique to rewrite the given equation in the form (x+ky)2/a2+y2/b2=1,(x+k*y)^2/a^2+y^2/b^2=1, where a,k,ba,k,b are expressions depending on the parameters of the given ellipse.

let k=B/A, a=D/A, and b=D/(A*C-B^2/A)


  1. Show that if the shear transformation defined by the matrix M=[1k01]M = \left[ \begin{smallmatrix} 1&k\\ 0&1 \end{smallmatrix} \right] is applied to the points x,yx,y of the standard ellipse x2/a2+y2/b2=1,x^2/a^2+y^2/b^2=1, the reslting curve has the equation that you derived in part 1. Use this fact to derive the formula for the area of the given ellipse in terms of parameters A,B,C,D.A, B, C, D.

M=[1B/A01]M = \left[ \begin{smallmatrix} 1&B/A\\ 0&1 \end{smallmatrix} \right]


  1. Write a function that takes parameters A,B,C,DA, B, C, D, checks the condition ACB2>0A*C-B^2>0 and, if the condition is true, returns the area of the given ellipse. If the condition is false, your function returns the string "The conic is not ellipse."

  2. Test your function on example of your choice. Plot the given ellipse and the corresponding standard ellipse in one figure.

In [5]:
def area_el(A,B,C,D): if A*C-B^2>0: return (D/A)*(D/(A*C-B^2)/A)*pi else: return "The conic is not ellipse" area_el(2,1,3,1)
In [10]:
var"x y" G = 2*x^2+2*1*x*y+3*y^2==1 P = x^2/(1/2)+y^2/(1/1*3-1^2/2)==1
File "<ipython-input-10-026dfbce6afb>", line 1 var"x y" ^ SyntaxError: invalid syntax
In [7]:
--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-7-3953782f1ed5> in <module>() ----> 1 NameError: name 'G' is not defined
In [ ]:
#1) #Ax2+2Bxy+Cy^2=D #A(x^2+Bxy/A+(By/A)^2-(By/A)^2 #A(x+Bx/A)^2-(By/A)^2+Cy^2=D #A(x+Bx/A)^2-y^2(B^2/A+C)=D #(x+B/A*y)^2/(D/A)+y^2/D/(A*C-B^2/A)=1