kill(all)$

maxima : computation of the asymptote of conic,version 1.0
peter.vlasschaert@gmail.com, 10/05/2022

load packages
-------------------

load(lrats)$

→ option :

ordergreat(x,y)$

quadratic form:
===========

values : 2d quadratic form:
---------------------------------

quadr(a,h,b,g,f,c):=ev(a*x^2+2*h*x*y+b*y^2+2*g*x+2*f*y+c,nouns);

p1:quadr(a,h,b,g,f,c);

p1b:ratcoeff(p1,x^2);
p1bx:ratcoeff(p1,2*x);
p1c:ratcoeff(p1,y^2);
p1cy:ratcoeff(p1,2*y);
p1d:subst([x=0,y=0],p1);

function :
------------

p1a:f(x,y):=''p1;

matrix quadratic form:
-----------------------------

vv: matrix(
 [a,h,g], 
 [h,b,f], 
 [g,f,c]
);

detvv(a,h,b,g,f,c):=determinant(vv);

p1e:Δ=expand(detvv(a,h,b,g,f,c));

p1e1:[reverse(p1e)];

 submatrix =δ1,quadratic part 

p1f1:δ1 = submatrix(3,vv,3);

→ determinant :δ1→δ

p1f2:δ =determinant(rhs(p1f1));

p1f3:reverse(p1f2);

The pair of straight lines:

example : 3*x^2+8*x*y-3*y^2+29*x-3y+18 = 0

p2:quadr(3,8/2,-3,29/2,-3/2,18)=0;

p2a1:ratcoeff(lhs(p2),x^2);
p2a2:ratcoeff(lhs(p2),x);
p2a3:subst([x=0],lhs(p2));

p3:solve(p2,x);

p3a1:makelist(lhs(p3[i])-rhs(p3[i])=0,i,1,2);

p3a2:expand(makelist(lhs(p3[i])-rhs(p3[i])=0,i,1,2)*3);

p3a3:[expand(p3a2[1]/3),p3a2[2]];

wxdraw2d(grid      = true,
             color = blue,
             line_type = dots,
             key       = string(line1= p3a3[1]),
             implicit(p3a3[1], x, -8,8, y, -8,8),             
             key       = string(line2= p3a3[2]),
             implicit(p3a3[2], x, -8,8, y, -8,8),
             title     = " both straight lines " )$

wxdraw2d(grid      = true, 
             color =red,
             line_type = solid,
             key       = string(p2),
             implicit(3*x^2+8*y*x+29*x-3*y^2-3*y+18=0, x,-8,8, y,-8,8),
             title     = " implicit functions,x,y " )$

→ check :

p4:expand((p3a2[1]*p3a2[2])/3);

p4a:is(lhs(p2)=lhs(p4));

intersection : two straight lines,"x+3*y+9=0,3*x-y+2=0"

p4b:solve(p3a3,listofvars(p3a3[1]))[1];

asymptotes: general conic
----------------

→ 1e step: given conic

p5:quadr(a,h,b,g,f,c)=0;

→ 2e step : c→c+λ into p5

p5a:subst([c=c+λ],p5);

→ 3e step:use :p1e ,c→ c+λ

p5b:expand(subst([c=c+λ],rhs(p1e)))=rhs(p5);

p5c:collectterms(lhs(p5b),λ)=rhs(p5);

use :p1e1

p5d:lratsubst(p1e1,p5c);

→ 4e step: find λ

p5e:solve(p5d,λ);

p5e1:δ =-1*denom(rhs(p5e[1]));

p5e2:num(rhs(p5e[1]));

rem : definition , submatrix :δ1

use : p1f3 & p5e

p5e3:lratsubst([p1f3],p5e);

→ 5e step : subst λ into p5a

p5f:subst(p5e3,p5a);

→ 6e step : simplification

p5g:subst([reverse(p5e1)],p5f);

p5g1:expand(δ*p5g);

p5g2:collectterms(lhs(p5g1),δ)=rhs(p5);

example :3*x^2-2*x*y-5*y^2+7*x-9*y=0

p6:3*x^2-2*x*y-5*y^2+7*x-9*y=0;

p6a:quadr(3,-2/2,-5,7/2,-9/2,c)=rhs(p6);

1e-step : c→λ

p6b:subst([c=λ],p6a);

p6ba:quadr(3,-2/2,-5,7/2,-9/2,λ)=rhs(p6);

2e-step : use p1e, c→λ

p6c:rhs(p1e)=rhs(p6);

p6c1:[a=3,h=-2/2,b=-5,g=7/2,f=-9/2,c=λ];

rem :a*x^2+2*h*y*x+2*g*x+b*y^2+2*f*y+c=0

p6c2:subst(p6c1,p6c);

3e-step:find λ

p6d:solve(p6c2,listofvars(p6c2));

4e-step : asymptote of the conic,use :p6b

p6e:subst(p6d,p6b);

5e-step : asymptote , pair of straight line

p6f:solve(p6e,x);

p6f1:[lhs(p6f[1])-rhs(p6f[1])=0,p6f[2]];

p6f2:[p6f1[1],expand((p6f[2]*3))];

p6f3:[p6f1[1],lhs(p6f2[2])-rhs(p6f2[2])=0];

check this : center of quadratic form.

show principal : with circle with center (x0,y0)→ (r,x0,y0)

circle :(r,x0,y0)

p7:(x-x0)^2+(y-y0)^2=r^2;
p7a:lhs(p7)-rhs(p7)=0;

find : x0,y0

→ x0

p7b1x:'diff(lhs(p7a),x) =diff(lhs(p7a),x);

p7b2x:rhs(p7b1x)=0;

p7b3x:solve(p7b2x,x);

→ y0

p7b1y:subst([x=y],p7b1x);

p7b2y:rhs(p7b1y)=0;

p7b3x:solve(p7b2y,y);

rem : we get center back:(x0,y0)

we need : differentation 
-------------------------------

1e) diff(central conic,x)→ x0=xC
2e) diff(central conic,y)→ y0=yC

use : example "central conic"

p8a:3*x^2-2*x*y-5*y^2+7*x-9*y=0;

→1e) diff(central conic,x)→ x0=xC

 p8ax:diff(p8a,x);

→2e) diff(central conic,y)→ y0=yC

p8ay:diff(p8a,y);

p8b:sort(listofvars(p8ax));

solve system :{p8ax,p8ay}

p8c:solve([p8ax,p8ay],p8b)[1];

p8c1:subst([y=yC,x=xC],p8c);

check :use "p6f3"

p8c2:subst(p8c,p6f3);

reason : center central conic ,is a point on the asymptote (=both).
--------------------------------------------------------------------------------
called : center of conic ,see :p8c1

p8c3:map(is,p8c2);

→   "3*x^2-2*x*y-5*y^2+7*x-9*y=0"

 wxdraw2d(grid      = true,
             color = blue,
             line_type = dots,
             key       =string(asymp1=p6f3[1]),
             implicit(p6f3[1], x, -8,8, y, -8,8),
             line_type = dots,
             key       =string(asymp2=p6f3[2]),
             implicit(p6f3[2], x, -8,8, y, -8,8),
             color =red,
             line_type = solid,
             key       = "3*x^2-2*x*y-5*y^2+7*x-9*y=0",
             implicit(3*x^2-2*x*y-5*y^2+7*x-9*y=0, x,-8,8, y,-8,8),
                         title     = " example :implicit functions,x,y " )$

→ intersection : both asymptote,use :p6f3

p9:solve(p6f3,[x,y])[1];

→ intersection :xC,yC,                    use:p8c1

p9a:reverse(p8c1);

use :wxplot2d ,implicitplot

→ implict :plot

→ use :p6

wxplot2d (p6, [x,-8,8], [y,-8,8],nobox,grid2d,
[yx_ratio, 1], [axes, solid],[title, "A hyperbola"]);

→ combination plot : two asymptote, implicit plot

F:p6f3[1];
G:p6f3[2];
H:p6;

wxplot2d ([F, G, H], [x, -8, 8], [y, -8, 8],grid2d,nobox,[yx_ratio, 1])$

wxplot2d ([F, G, H], [x, -8, 8], [y, -8, 8],grid2d,[yx_ratio, 1],[axes, solid],
   [style, points, points,lines], [color, red, red,black],
        [point_type, diamond,asterisk],
        [legend, "asymptote1", "asymptote2","conic:hyperbola"],
        [xlabel, "x-values"],
        [ylabel, "y-values"])$ 

--------------------------------------------------------------------------------------------------------