CoCalc Shared FilesFinaExamMiniProject.ipynb
Author: Edgar Arevalo
Views : 35
In [ ]:



# Final Exam

## 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 $A*x^2+2B*x*y+c*y^2=D$ with $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+k*y)^2/a^2+y^2/b^2=1,$ where $a,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)

$(x+B/A*y)^2/(D/A)+y^2/D/(A*C-B^2/A)=1$

1. Show that if the shear transformation defined by the matrix $M = \left[ \begin{smallmatrix} 1&k\\ 0&1 \end{smallmatrix} \right]$ is applied to the points $x,y$ of the standard ellipse $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.$

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

$(X)^2/(D/A)+y^2/D/(A*C-B^2/A)=1$

1. Write a function that takes parameters $A, B, C, D$, checks the condition $A*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)

1/20*pi
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]:
G.show()

--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-7-3953782f1ed5> in <module>() ----> 1 G.show() 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