> # Anylytická geometrie - příklad

> # Sestrojíme elipsu procházející body [3,2],[-1,2],[-1,0],[-1,2]
restart;

> elipsa:=(x-x0)^2/a^2+(y-y0)^2/b^2=1;

elipsa := (x-x0)^2/a^2+(y-y0)^2/b^2 = 1

> # Dosadíme body a budeme počítat xo,y0,a,b - soustava 4 rovnic o 4 neznámých

> x:=3;y:=2;

x := 3

y := 2

> rov1:=elipsa;

rov1 := (3-x0)^2/a^2+(2-y0)^2/b^2 = 1

> unassign('x','y');

> x:=1;y:=4;

x := 1

y := 4

> rov2:=elipsa;

rov2 := (1-x0)^2/a^2+(4-y0)^2/b^2 = 1

> unassign('x','y');

> x:=-1;y:=0;

x := -1

y := 0

> rov3:=elipsa;

rov3 := (-1-x0)^2/a^2+y0^2/b^2 = 1

> unassign('x','y');

> x:=3;y:=0;

x := 3

y := 0

> rov4:=elipsa;

rov4 := (3-x0)^2/a^2+y0^2/b^2 = 1

> unassign('x','y');

> reseni:=solve({rov1,rov2,rov3,rov4});

reseni := {y0 = 1, a = 3*RootOf(2*_Z^2-1, label = _L1), b = 3, x0 = 1}, {y0 = 1, a = 3*RootOf(2*_Z^2-1, label = _L1), b = -3, x0 = 1}

> evalf(reseni);

{y0 = 1., a = 2.121320343, b = 3., x0 = 1.}, {y0 = 1., a = 2.121320343, x0 = 1., b = -3.}

> assign(evalf(reseni[1]));

> el:=elipsa;

el := .2222222223*(x-1.)^2+.1111111111*(y-1.)^2 = 1

> m:=x0;n:=y0;aa:=a;bb:=b;

m := 1.

n := 1.

aa := 2.121320343

bb := 3.

> with(plots):

Warning, the name changecoords has been redefined

> implicitplot(elipsa,x=-3..6,y=-3..5);

[Plot]

> unassign('x0','y0');

> tec:=(x-m)*(x0-m)/aa^2+(y-n)*(y0-n)/bb^2=1;

tec := .2222222223*(x-1.)*(x0-1.)+.1111111111*(y-1.)*(y0-1.) = 1

> el;

.2222222223*(x-1.)^2+.1111111111*(y-1.)^2 = 1

> x0:=5;

x0 := 5

> y0:=0;

y0 := 0

> tec;

.8888888892*x-.7777777781-.1111111111*y = 1

> el;

.2222222223*(x-1.)^2+.1111111111*(y-1.)^2 = 1

> dot:=solve({tec,el});

dot := {y = -1.792073902, x = 1.775990762}, {y = 3.246619357, x = 2.405827419}

> bod1:=dot[1];

bod1 := {y = -1.792073902, x = 1.775990762}

> bod2:=dot[2];

bod2 := {y = 3.246619357, x = 2.405827419}

> assign(bod1);

> xx:=x;yy:=y;

xx := 1.775990762

yy := -1.792073902

> with(geometry):
point(A,xx,yy),point(B,5,0):

line(l,[A,B]);

> pr:=Equation(l,[c,d]);

l

pr := 8.960369510-1.792073902*c+3.224009238*d = 0

> el;

.2222222223*(x-1.)^2+.1111111111*(y-1.)^2 = 1

> unassign('x','y');

> with(plots):

> g1:=implicitplot(pr, c=-1..10,d=-2..5):

> g2:=implicitplot(el,x=-3..6,y=-3..5):

> display({g1,g2});

[Plot]

>