Carl Love

Carl Love

28025 Reputation

25 Badges

12 years, 311 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

If tangent lines are perpendicular, then their corresponding radii are perpendicular.  Given three points A, B, C, then AB is perpendicular to BC iff (A[2]-B[2])*(C[2]-B[2]) = (B[1]-A[1])*(C[1]-B[1]).

I also vastly simplified the rest of your code, mostly by using isolve to get the integer points on the circle.

restart:

with(geometry):

(Mx,My):= (-1,-5):  R:= 5:

point(M,Mx,My):

eqS:= (x-Mx)^2 + (y-My)^2 = R^2:

 

Find the points with integer coordinates on the circle and remove any with either coordinate the same as the center.

L:= remove(pt-> pt[1]=Mx or pt[2]=My, map2(eval, [x,y], [isolve({eqS})]));

[[-5, -8], [-5, -2], [-4, -9], [-4, -1], [2, -9], [2, -1], [3, -8], [3, -2]]

For each such point, get the equation of the tangent line.

circle(S, eqS, [x,y]):

k:= [seq](sort(Equation(TangentLine(P, S, point(A, pt[])), [x,y])), pt in L):

 

Pair each line with its point of tangency.

Lk:= zip(`[]`, L, k);

[[[-5, -8], -4*x-3*y-44 = 0], [[-5, -2], -4*x+3*y-14 = 0], [[-4, -9], -3*x-4*y-48 = 0], [[-4, -1], -3*x+4*y-8 = 0], [[2, -9], 3*x-4*y-42 = 0], [[2, -1], 3*x+4*y-2 = 0], [[3, -8], 4*x-3*y-36 = 0], [[3, -2], 4*x+3*y-6 = 0]]

 

Form all pairs of the tangent lines, and remove any pair where the lines are perpendicular. If tangent lines are perpendicular, then theircorresponding radii are perpendicular.  Given three points A, B, C, then AB is perpendicular to BC iff (A[2]-B[2])*(C[2]-B[2]) = (B[1]-A[1])*(C[1]-B[1]).

PLk:= remove(
     #Perpendicularity criterion:
     P-> (P[1,1,2]-My)*(P[2,1,2]-My) = (Mx-P[1,1,1])*(P[2,1,1]-Mx),
     combinat:-choose(Lk,2)
);

 

[[[[-5, -8], -4*x-3*y-44 = 0], [[-5, -2], -4*x+3*y-14 = 0]], [[[-5, -8], -4*x-3*y-44 = 0], [[-4, -9], -3*x-4*y-48 = 0]], [[[-5, -8], -4*x-3*y-44 = 0], [[2, -1], 3*x+4*y-2 = 0]], [[[-5, -8], -4*x-3*y-44 = 0], [[3, -8], 4*x-3*y-36 = 0]], [[[-5, -8], -4*x-3*y-44 = 0], [[3, -2], 4*x+3*y-6 = 0]], [[[-5, -2], -4*x+3*y-14 = 0], [[-4, -1], -3*x+4*y-8 = 0]], [[[-5, -2], -4*x+3*y-14 = 0], [[2, -9], 3*x-4*y-42 = 0]], [[[-5, -2], -4*x+3*y-14 = 0], [[3, -8], 4*x-3*y-36 = 0]], [[[-5, -2], -4*x+3*y-14 = 0], [[3, -2], 4*x+3*y-6 = 0]], [[[-4, -9], -3*x-4*y-48 = 0], [[-4, -1], -3*x+4*y-8 = 0]], [[[-4, -9], -3*x-4*y-48 = 0], [[2, -9], 3*x-4*y-42 = 0]], [[[-4, -9], -3*x-4*y-48 = 0], [[2, -1], 3*x+4*y-2 = 0]], [[[-4, -9], -3*x-4*y-48 = 0], [[3, -2], 4*x+3*y-6 = 0]], [[[-4, -1], -3*x+4*y-8 = 0], [[2, -9], 3*x-4*y-42 = 0]], [[[-4, -1], -3*x+4*y-8 = 0], [[2, -1], 3*x+4*y-2 = 0]], [[[-4, -1], -3*x+4*y-8 = 0], [[3, -8], 4*x-3*y-36 = 0]], [[[2, -9], 3*x-4*y-42 = 0], [[2, -1], 3*x+4*y-2 = 0]], [[[2, -9], 3*x-4*y-42 = 0], [[3, -8], 4*x-3*y-36 = 0]], [[[2, -1], 3*x+4*y-2 = 0], [[3, -2], 4*x+3*y-6 = 0]], [[[3, -8], 4*x-3*y-36 = 0], [[3, -2], 4*x+3*y-6 = 0]]]

 

For each such pair of lines, find the point of intersection.

map(P-> [P[1,2], P[2,2], solve([P[1,2],P[2,2]], [x,y])[]], PLk);

[[-4*x-3*y-44 = 0, -4*x+3*y-14 = 0, [x = -29/4, y = -5]], [-4*x-3*y-44 = 0, -3*x-4*y-48 = 0, [x = -32/7, y = -60/7]], [-4*x-3*y-44 = 0, 3*x+4*y-2 = 0, [x = -26, y = 20]], [-4*x-3*y-44 = 0, 4*x-3*y-36 = 0, [x = -1, y = -40/3]], [-4*x-3*y-44 = 0, 4*x+3*y-6 = 0], [-4*x+3*y-14 = 0, -3*x+4*y-8 = 0, [x = -32/7, y = -10/7]], [-4*x+3*y-14 = 0, 3*x-4*y-42 = 0, [x = -26, y = -30]], [-4*x+3*y-14 = 0, 4*x-3*y-36 = 0], [-4*x+3*y-14 = 0, 4*x+3*y-6 = 0, [x = -1, y = 10/3]], [-3*x-4*y-48 = 0, -3*x+4*y-8 = 0, [x = -28/3, y = -5]], [-3*x-4*y-48 = 0, 3*x-4*y-42 = 0, [x = -1, y = -45/4]], [-3*x-4*y-48 = 0, 3*x+4*y-2 = 0], [-3*x-4*y-48 = 0, 4*x+3*y-6 = 0, [x = 24, y = -30]], [-3*x+4*y-8 = 0, 3*x-4*y-42 = 0], [-3*x+4*y-8 = 0, 3*x+4*y-2 = 0, [x = -1, y = 5/4]], [-3*x+4*y-8 = 0, 4*x-3*y-36 = 0, [x = 24, y = 20]], [3*x-4*y-42 = 0, 3*x+4*y-2 = 0, [x = 22/3, y = -5]], [3*x-4*y-42 = 0, 4*x-3*y-36 = 0, [x = 18/7, y = -60/7]], [3*x+4*y-2 = 0, 4*x+3*y-6 = 0, [x = 18/7, y = -10/7]], [4*x-3*y-36 = 0, 4*x+3*y-6 = 0, [x = 21/4, y = -5]]]


Download Nonperpendicular.mw

Let the expression be expr. Then do

op(indets(expr, specfunc(anything, RootOf))[1]);

Yes, it is easy with plotsetup(window). See help pages ?plot,device and ?plotsetup .

Your question is barely readable. In the future, enter your matrix into Maple and then cut-and-paste the matrix into your post.

I hope that you can draw your conclusions from the following worksheet. If not, ask for more help.


restart:

A:= < k+3, 2, k-4, 3;
      0,   2,  -9, 5;
      0,   0, k^2+k-2, k-1 >;  

A := Matrix(3, 4, {(1, 1) = k+3, (1, 2) = 2, (1, 3) = k-4, (1, 4) = 3, (2, 1) = 0, (2, 2) = 2, (2, 3) = -9, (2, 4) = 5, (3, 1) = 0, (3, 2) = 0, (3, 3) = k^2+k-2, (3, 4) = k-1})

(1)

eval(A, k=1);

Matrix(3, 4, {(1, 1) = 4, (1, 2) = 2, (1, 3) = -3, (1, 4) = 3, (2, 1) = 0, (2, 2) = 2, (2, 3) = -9, (2, 4) = 5, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0, (3, 4) = 0})

(2)

solve(A[3,3] = 0, {k});

{k = 1}, {k = -2}

(3)

eval(A, k= -2);

Matrix(3, 4, {(1, 1) = 1, (1, 2) = 2, (1, 3) = -6, (1, 4) = 3, (2, 1) = 0, (2, 2) = 2, (2, 3) = -9, (2, 4) = 5, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0, (3, 4) = -3})

(4)

 


Download Parametric_linear_system.mw

 

 


restart:

Notice the use of  `*` instead of implied multiplication

Sys:=
     4*x1 + 2*x2 - 7*x3 - 11*x4 = 5,

     2*x1 + 1*x2 - 2*x3 - 4*x4 = 2,

     4*x1 + 2*x2 - 10*x3 - 14*x4 = 6
:

X:= [x||(1..4)]:

A:= LinearAlgebra:-GenerateMatrix([Sys], X, augmented);

A := Matrix(3, 5, {(1, 1) = 4, (1, 2) = 2, (1, 3) = -7, (1, 4) = -11, (1, 5) = 5, (2, 1) = 2, (2, 2) = 1, (2, 3) = -2, (2, 4) = -4, (2, 5) = 2, (3, 1) = 4, (3, 2) = 2, (3, 3) = -10, (3, 4) = -14, (3, 5) = 6})

(1)

R:= LinearAlgebra:-ReducedRowEchelonForm(A);

R := Matrix(3, 5, {(1, 1) = 1, (1, 2) = 1/2, (1, 3) = 0, (1, 4) = -1, (1, 5) = 2/3, (2, 1) = 0, (2, 2) = 0, (2, 3) = 1, (2, 4) = 1, (2, 5) = -1/3, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0, (3, 4) = 0, (3, 5) = 0})

(2)

Sol:= LinearAlgebra:-LinearSolve(A, free= t);

Sol := Vector(4, {(1) = t[1], (2) = -2*t[1]+4/3+2*t[4], (3) = -1/3-t[4], (4) = t[4]})

(3)

The solution space is two-dimensional. Verify the solution by plugging into the original system of equations.

eval(Sys, X =~ convert(Sol, list));

5 = 5, 2 = 2, 6 = 6

(4)

 


Download Linear_system.mw

Use command residue. For example

residue(1/z, z= 0);

     1

The problem is that you are using m in two different ways. You are using it as an index to the middle add, and you are using it as a procedure. Try this:

t:= exp(2*Pi*I/11);
Mij:= (i,j)-> M[(i mod 11)+1, (j mod 11)+1] ;  
mu:= proc(i,j)
local n,m,k;
     add(add(add(a[k]*a[m]*a[n]*t^m*Mij(i+k-m,j+n-m), n= 0..10), m= 0..10), k= 0..10)
end proc;

Your "New problem" is caused by you trying to return an expression sequence. There is no facility for the return value of a procedure produced by unapply to be an expression sequence. There are two things you can do: (1) Make the return value a list, or (2) Make the return value a list and compose the result with op to convert it back to an expression sequence.

To do (1):

f:= unapply(
      [seq(product(t[j]^'Q[j,i]',j=1..RowDimension(Q)),i=1..ColumnDimension(Q))]
    , seq(t[i],i=1..RowDimension(Q))
);

To do (2):

f:= op@unapply(
      [seq(product(t[j]^'Q[j,i]',j=1..RowDimension(Q)),i=1..ColumnDimension(Q))]
    , seq(t[i],i=1..RowDimension(Q))
);

The solve command should contain variables u and v, not %u and %v.

You can do it like this:

for i in seq(0..100, 0.2), seq(100..0, -0.2) do ... end do;

I will assume that the backslash in your expression should have been a forward slash---that it represents ordinary division. I'll plot a unit sphere in spherical coordinates. So, I am also assuming that you want x and y to range from -1 to 1.

f:= (x,y)-> (5*x^2*y^2-6*x^4)/((1-y^2)*(x^2+y^2)-y^2*(1-x^2-y^2));

plot3d(
     1, theta= 0..2*Pi, phi= 0..Pi,
     color= f(cos(theta)*sin(phi), sin(theta)*sin(phi)),
     coords= spherical, style= patchnogrid, labels= [x,y,z]
);

 

Make it a single command:

eval(y, isolate(x, D(a)));

Do you want a uniform random selection from all 6-tuples of nonnegative integers whose sum is 8? It can be done like this:

C:= combinat:-composition(8+6, 6):
C[(rand() mod nops(C))+1] -~ 1;

If you want to make such a random selection repeatedly, the above can be made more efficient. Let me know.

Your attempt to trap division-by-zero errors went awry. You set it up so that division by zero returns infinity, but the plots:-circle command doesn't know what to do with infinity as an argument. Your problem can solved by simply filtering out the values that lead to division by zero; there is no need to trap those errors. 

To fix the problem, simply replace the line

d := seq(circle([1, 1/i], 1/i, color = blue), i = -20 .. 20, .1);

with

d:= seq(`if`(i=0, NULL, circle([1, 1/i], 1/i, color= blue)), i= -20 .. 20, .1):

The principles for solving the system of piecewise ODEs are the same as the simplified example above. It is done like this:

Sys1:= EQ||(1..3), op(2, EQ4), op(2, EQ5):
Sys2:= EQ||(1..3), op(4, EQ4), op(4, EQ5):
ICs1:= seq(q||k(0)=0, k= 1..5), seq(D(q||k)(0)=0, k= 1..3):
Sol1:= dsolve({Sys1, ICs1}, numeric, maxfun=0, range= 0..10):
ICs2:= eval(
     [seq(q||k(10) = q||k(t), k= 1..5),
      seq(D(q||k)(10) = diff(q||k(t), t), k= 1..3)
     ], Sol1(10)
)[]:
Sol2:= dsolve({Sys2, ICs2}, numeric, maxfun= 0):
P1:= plots:-odeplot(Sol1, [seq([t, q||k(t)], k= 1..5)], t= 0..10):
P2:= plots:-odeplot(Sol2, [seq([t, q||k(t)], k= 1..5)], t= 10..20):
plots:-display([P1,P2]);

First 295 296 297 298 299 300 301 Last Page 297 of 395