/*
Maxima Macros of High School Math ,daisuu(algebra)2012/12/12
by FieldStone
euc(a,b)
Euclidean Algorithm a>=b
denor(r)
rationalize or realize of denominator
sqrtt(a)
get out square of root
ssqrt(a)
out nestroot
ineq1(a*x+b)
solve a inequality such that a*x+b>0
D(a,b,c)
discriminant of a*x^2+b*x+c=0
vertex(a,b,c)
vertex of y=a*x^2+b*x+c
stan(a,p,q,x)
standard form of quadratic function y=a*(x-p)^2+q
gene(a,b,c,x,y)
general form of quadratic function a*x^2+b*x+c-y
quadfn(a,b,c,d,e,f)
quadratic function through (a,b),(c,d),(e,f)
quadmax(a,b,c,s,t)
maximum of quadratic function a*x^2+b*x+c in [s,t]
quadmin(a,b,c,s,t)
minimum of quadratic function a*x^2+b*x+c in [s,t]
D(f)
discriminant of quadratic expression
ineq2(a,b,c,d)
solve quadratic inequality such that a*x^2+b*x+c"<"or">=0"
ineq(f)
solve quadratic inequality of x
dhio2()
integer solution of quadratic equation
change equation in the macro
dio(a,b)
integer solution of quadratic equation a*x+b*y=1
modulus method
diof(a,b)
integer solution of quadratic equation a*x+b*y=1
continuance fraction method
nota(a,p)
change notation of a from 10 to p
nota10(l,p)
change notation of l from p to 10
kai(a,b,c)
put solution of a*x^2+b*x+c=0 to s1,s2
eq(a,b)
the quadratic equation that solution is a,b
symP(a,b,c,d)
symmetric point of (c,d) with respect to (a,b)
symL(a,b,c,d,e)
symmetric point of (d,e) with respect to a*x+b*y+c=0
l1(a,b,m)
the line of slope m through (a,b)
l2(a,b,c,d)
the line through (a,b) and (c,d)
com(a,b,c,d,e,f)
the intersection of a*x+b*y+c=0 and d*x+e*y+f=0
g(a,b,c,d,e,f)
the center of gravity (a,b),(c,d),(e,f)
m(a,b,c,d)
the center point of (a,b) and (c,d)
d(a,b,c,d)
the distance from (a,b) to (c,d)
p(a,b,c,d,m,n)
the point of (a,b) and (c,d) that ratio of m:n
dl(a,b,c,d,e)
the distance from a*x+b*y+c=0 to (d,e)
cir(a,b,r)
the equation of the circle that center(a,b),radius r
std(l,m,n)
the center and radius of x^2+y^2+l*x+m*y+n=0
cir3(a,b,c,d,e,f)
the equation through (a,b),(c,d),(e,f)
com2(a,b,c,l,m,n)
the intersection of a*x+b*y+c=0 and x^2+y^2+l*x+m*y+n=0
com3(a,b,R)
the tangent point of x^2+y^2=R through (a,b)
simp()
linear plan
change inequalities in the macro
big(a,b,c)
large
liin(a,b,c,d,e,f)
linear coefficient m(a,b)+n(c,d)=(e,f)
liin3(a,b,c,d,e,f,g,h,i,o,p,q)
linear coefficient l(a,b,c)+m(d,e,f)+n(g,h,i)=(o,p.q)
area(a,b,c,d)
the area of (0,0),(a,b),(c,d)
ang(a,b,c,d)
the angle of (0,0),(a,b),(c,d)
outprod(a,b,c,e,f,g)
the outproduct of (a,b,c) and (d,e,f)
chebamene(k,l,m,n)
intersection vector of ratio k:l ratio m:n
plane(a,b,c,l,m,n,o,p,q,s,t,u)
four points (a,b,c),(l,m,n),(o,p,q),(s,t,u) on the same plane
npower(a,b,c,d)
load(eigen)
n'th power of matrix([a,b],[c,d])
Rot(th)
rotation matrix of angle th
lt-u(a,b,c,d,n)
view matrix matrix([a,b],[c,d]) n'th term
palla(a,b,c)
the vertex,focus,parametrix of the parabola x=a*y^2+b*y+c
elli(a,b,c,d,e)
the center,minor axis,major axis,focus of the ellipse a*x^2+b*y^2+c*x+d*y+e=0
hyp(a,b,c,d,e)
the center,asymptoic line,focus of the hyperbolaa*x^2+b*y^2+c*x+d*y+e=0
*/
euc(a,b):=block(
while b>0 do(print(c:mod(a,b)),a:b,b:c)
)$
denor(r):=block(
algebraic:true,
rat(r)
)$
sqrtt(a):=block(
jj:1,
ss:1,
l:ifactors(a),
m:length(l),
for i:1 thru m do
(
b:l[i][1],
j:floor(l[i][2]/2),
r:mod(l[i][2],2),
jj:jj*j*b,
ss:ss*sqrt(b^r)
),
print(jj,rootscontract(ss))
)$
ssqrt(r):=block(
load(sqdnst),
sqrtdenest(sqrt(r))
)$
ineq1(a):=block(
t:ev(x,solve(a,x)),
if subst(t-1,x,a)>0 then return(sconcat("x<",t))
else return(sconcat("x>",t))
)$
D(a,b,c):=b^2-4*a*c$
vertex(a,b,c):=[-b/2/a,-(b^2-4*a*c)/a/4]$
stan(a,p,q,x):=a*(x-p)^2+q$
gene(a,b,c,x,y):=a*x^2+b*x+c-y$
quadfn(a,b,c,d,e,f):=block(
return(expand(f*(x-a)*(x-c)/(e-a)/(e-c)+d*(x-a)*(x-e)/(c-a)/(c-e)+b*(x-e)*(x-c)/(a-b)/(a-e)))
)$
quadmax(a,b,c,s,t):=block(
f(x):=a*x^2+b*x+c,
p:-b/2/a,
if (s
0 and d=">" then return(sconcat("x<",min(e,f)," ",max(e,f),"0 and d="<" then return(sconcat(min(e,f),"0 and d=">=" then return(sconcat("x<=",min(e,f)," ",max(e,f),"<=x"))
else if g>0 and d="<=" then return(sconcat(min(e,f),"<=x<=",max(e,f)))
else if g<0 and d=">" then return("all")
else if g<0 and d="<" then return("nothing")
else if g<0 and d=">=" then return("all")
else if g<0 and d="<=" then return("nothing")
)$
ineq(f):=block(
load(fourier_elim),
fourier_elim([f],[x])
)$
dhio2():=block(
for a:-50 thru 50 do
for b:-50 thru 50 do
if a*b+3*a+2*b=1 then print("(",a,",",b,")")
)$
dio(a,b):=block(
x:inv_mod(a,b),
y:(1-a*x)/b,
return([x,y])
)$
diof(a,b):=block(
r:radcan(cfdisrep(delete(last(cf(a/b)),cf(a/b)))),
return([-denom(r),num(r)])
)$
nota(a,p):=block(
l:[ ],
for i:1 while i<100 do
(
l:append([mod(a,p)],l),
a:floor(a/p),
if a=0 then return(l)
)
)$
nota10(l,p):=block(
s:0,
(
for i:0 thru length(l)-1 do
s:s+l[length(l)-i]*p^i
),
return(s)
)$
kai(a,b,c):=block(
s1:ev(x,solve(a*x^2+b*x+c,x)[1]),
s2:ev(x,solve(a*x^2+b*x+c,x)[2])
)$
eq(a,b):=x^2+(a+b)*x+a*b=0$
symP(a,b,c,d):=[2*a-c,2*b-d]$
l1(a,b,m):=ratsimp(expand(m*(x-a)-y+b=0))$
symL(a,b,c,d,e):=solve([-a/b*(y-e)/(x-d)+1,a*(x+d)/2+b*(y+e)/2+c],[x,y])$
com(a,b,c,d,e,f):=solve([a*x+b*y+c,d*x+e*y+f],[x,y])$
l2(a,b,c,d):=ratsimp(expand(y-b-(d-b)*(x-a)/(c-a)=0))$
d(a,b,c,d):=sqrt((a-c)^2+(b-d)^2)$
cir(a,b,r):=(x-a)^2+(y-b)^2=r^2$
m(a,b,c,d):=[(a+c)/2,(b+d)/2]$
std(l,m,n):=[-l/2,-m/2,sqrt((l^2+m^2)/4-n)]$
cir3(a,b,c,d,e,f):=block(
h:x^2+y^2+l*x+m*y+n=0,
c1:sublis([x=a,y=b],h),
c2:sublis([x=c,y=d],h),
c3:sublis([x=e,y=f],h),
sublis(solve([c1,c2,c3],[l,m,n])[1],h)
)$
com2(a,b,c,l,m,n):=solve([a*x+b*y+c=0,x^2+y^2+l*x+m*y+n=0],[x,y])$
dl(a,b,c,d,e):=abs(a*d+b*e+c)/sqrt(a^2+b^2)$
simp():=block(
load(simplex),
l:[x+2*y<=4,x-y<=1,x>=0,y>=0],
minimize_lp(2*x+y,l),
maximize_lp(2*x+y,l)
)$
big(a,b,c):=block(
if a<=b then (d:a,a:b,b:d),
if c>a then return([c,a,b]) else if c>b then return([a,c,b])
else return([a,b,c])
)$
liin(a,b,c,d,e,f):=block(
return(solve([m*a+n*c=e,m*b+n*d=f],[m,n]))
)$
liin3(a,b,c,d,e,f,g,h,i,o,p,q):=block(
return(solve([l*a+m*d+n*g=o,l*b+m*e+n*h=p,l*c+m*f+n*i=q],[l,m,n]))
)$
area(a,b,c,d):=(determinant(matrix([a,b],[c,d])))$
ang(a,b,c,d):=acos(radcan([a,b].[c,d]/sqrt(a^2+b^2)/sqrt(c^2+d^2)))$
outprod(a,b,c,e,f,g):=[b*g-c*f,c*e-a*g,a*f-b*e]$
chebamene(k,l,m,n):=ratsimp((n*k*a+m*l*b)/(n*k+m*l+n*l))$
plane(a,b,c,l,m,n,o,p,q,s,t,u):=block(
solve(determinant(matrix(([l,m,n]-[a,b,c]),([o,p,q]-[a,b,c]),([s,t,u]-[a,b,c])))=0,x)
)$
npower(a,b,c,d):=block(
A:matrix([a,b],[c,d]),
if length(eivects(A)[2])=2 then(
l1:eivects(A)[2][1][1],l2:eivects(A)[2][2][1],
P:transpose(matrix(l1,l2)),
return(P.(P^^(-1).A.P)^n.P^^(-1))
)
else
a:eivals(A)[1][1],
return(n*a^(n-1)*A-(n-1)*a^n*matrix([1,0],[0,1]))
)$
Rot(th):=matrix([cos(th/180*%pi),-sin(th/180*%pi)],
[sin(th/180*%pi),cos(th/180*%pi)])$
lt-u(a,b,c,d,n):=block(
coord: setify(makelist(k,k,-1*n,n)),
points2d: listify(cartesian_product(coord,coord)),
vf2d(x,y):= vector([x,y],[(a-1)*x+b*y,c*x+(d-1)*y]),
vect2: makelist(vf2d(k[1],k[2]),k,points2d),
apply(draw2d,
append([head_length=0.1, unit_vectors=true,color=blue],
vect2))
)$
palla(a,b,c):=block(
p:1/4/a,
s:-b/2/a,
t:(4*a*c-b^2)/4/a,
print("vertex:(",t,",",s,")"),
print("focus:(",t+p,",",s,")"),
print("directrix:x=",t-p),
return("pallabola")
)$
elli(a,b,c,d,e):=block(
s:-c/2/a,t:-d/2/b,u:-e+c^2/4/a+d^2/4/b,
print("center:(",s,",",t,")"),
p:sqrt(u/a),q:sqrt(u/b),
print("x-axis:",2*p,"y-axis:",2*q),
if p<=q then print("focus:(",s,",",t-sqrt(q^2-p^2),"),(",s,",",t+sqrt(q^2-p^2),")")
else
print("focus:(",s-sqrt(p^2-q^2),",",t,"),(",s+sqrt(p^2-q^2),",",t,")"),
return("ellipse")
)$
hyp(a,b,c,d,e):=block(
s:-c/2/a,t:-d/2/b,u:-e+c^2/4/a+d^2/4/b,
print("center:(",s,",",t,")"),
p:sqrt(abs(u)/a),q:sqrt(-abs(u)/b),
print("asympt:y-",t,"=pm",abs(q/p),"(x-",s,")"),
if p<=q then print("focus:(",s,",",t-sqrt(q^2+p^2),"),(",s,",",t+sqrt(q^2+p^2),")")
else
print("focus:(",s-sqrt(p^2+q^2),",",t,"),(",s+sqrt(p^2+q^2),",",t,")"),
return("hyperbola")
)$