Kitonum

13367 Reputation

24 Badges

11 years, 72 days

MaplePrimes Activity


These are answers submitted by Kitonum

Here is corrected and simplified the code:

restart;

N := 2;

alias(epsilon = e, eta = t);

eq1 := 5*diff(F(t), t$3)+(1+3*e)*F(t)*diff(F(t), t$2)-(2+e)*diff(F(t), t)^2 = 0;

G :=unapply(add(F[i](t)*e^i, i = 0 .. N),t); 

deqn := simplify(collect(subs(F(t)=G(t),eq1), e), {e^(N+1) = 0});

P:=proc(L)

local It, M;

It:=proc(K)

[seq([-1,op(K[i])],i=1..nops(K)),seq([1,op(K[i])],i=1..nops(K))];

end proc;

M:=(It@@nops(L))([[ ]]);

[seq(abs(add(L[j]*M[i,j],j=1..nops(L))),i=1..nops(M))];

Minimum =min(%);

end proc:

 

The procedure P is faster than  minsum.

Examples:

st:= time():  P([seq(i^2,i=1..15)]);  time() - st;

 Minimum=0

1.139

 

st:= time(): minsum([seq(i^2,i=1..15)]); time() - st;

0

20.639

                       

 

Try to write the code yourself!

Directions:

1) Find a plane passing through point A and plane d1 

2) Find the point of intersection of the plane from 1) and plane d2

In some cases, your problem may have no solutions or have an infinite number of solutions.

Your main idea and your code are good! Try to rewrite it as a procedure for any points A, B, E, F and any number k. The procedure must include verification that the points A, B, E, F does not lie in one plane. In the equation of the plane, get rid of the common divisors of the coefficients.

Here's the procedure that you asked! It returnes the equation of the common perpendicular of any skew lines. The procedure uses only tools of the Maple's core without calling packages.

 

ComPerp:=proc(a::list,b::list)

local a1,b1,t,s,V1,V2,V,A,B,sol,L,d1,d2;

a1:=subsindets(a,'symbol',x->t); b1:=subsindets(b,'symbol',x->s);

V1:=<seq(coeff(a1[i],t),i=1..3)>;

V2:=<seq(coeff(b1[i],s),i=1..3)>;

V:=<seq(a1[i]-b1[i],i=1..3)>;

sol:=solve({add(V1[i]*V[i],i=1..3)=0,add(V2[i]*V[i],i=1..3)=0},{t,s}); assign(sol);

A:=eval(a1,'t'=t); B:=eval(b1,'s'=s); L:=[x,y,z];

d1:=ilcm(seq(denom(A[i]-B[i]),i=1..3)); d2:=igcd(seq(numer(A[i]-B[i]),i=1..3));

print(`Equation of the common perpendicular`);

{seq(L[i]=A[i]+(A[i]-B[i])*d1/d2*'t',i=1..3)};

end proc:

 

Example of working for your data:

a := [3*t-7, -2*t+4, 3*t+4]:

b := [m+1, 2*m-9, -m-12]:

ComPerp(a,b);

 

The result

Your code is correct, but too long.

Another solution:

restart:

with(LinearAlgebra):

A:=<1,-3,0>: B:=<-2,1,1>: C:=<3,1,2>: M:=x*A+y*B+z*C:

{DotProduct(B-A,C-M)=0, DotProduct(C-A,B-M)=0, x+y+z = 1}:

solve({DotProduct(B-A,C-M)=0, DotProduct(C-A,B-M)=0, x+y+z = 1}): assign(%): M:

'M'=[seq(M[i],i=1..3)];

 

M=[4/5, -2/5, 1]

restart:

with(LinearAlgebra):

A:=<4,-1,-2>: B:=<0,2,3>: C:=<2,0,1>: M:=x*A+y*B+z*C:

solve({Norm(A-M,2)=Norm(B-M,2), Norm(C-M,2)=Norm(B-M,2), x+y+z = 1}): assign(%):

'M'=convert(M,list);

We find the coordinates of M.

The apparent error of Maple! I did the same example using the command Optimization [Minimize] . The result is also wrong!


Checked the calculation of the minimum by the second method. The result again is false:

h:=x->1+2*cos(2*x)+3*cos(4*x)+4*cos(8*x);
minimize(h(x),x=-Pi/12..5*Pi/12,location);
Optimization[Minimize](h(x),x=-Pi/12..5*Pi/12);

h := proc (x) options operator, arrow; 1+2*cos(2*x)+3*cos(4*x)+4*cos(8*x) end proc

1/2-3^(1/2), {[{x = 5*Pi/12}, 1/2-3^(1/2)]}

[-2.02634418581704, [x = .452809600260151]]

 

plot(h(x),x=-Pi/12..5*Pi/12);

 

minimize



Download minimum.mws

Such non-linear systems are usually solved numerically for given values ​​of all parameters! Note that parameter m on the right side of the first equation must be equal to 0, otherwise it would be contrary to the initial conditions.


restart; U := (x+y)/sqrt(2); V := (x-y)/sqrt(2); U1 := unapply(simplify(subs(x = (u+v)/sqrt(2), y = (u-v)/sqrt(2), U)), u, v)

proc (u, v) options operator, arrow; u end proc

 

(D[`$`(1, 2)](U1))(u, v)

0

 

(D[`$`(2, 2)](U1))(u, v)

0

 

``

Similarly, you can do the same with the second function!

Download Change_of_variable.mw

Instead of y:=unapply(f):  should be y:=unapply(f,x):

Use the command expand:

B1 := [1, 2, 0, -1]:       B2 := [0, 1, -1, 0]:                         

A1 := expand(a*B1+b*B2);                                

 

A1 := [a, b + 2 a, -b, -a]

In accordance with the syntax of Maple should be

Int(subs(x=1/t,expression)*(-1/t^2), t)

Apparently, you need to make the change of variable in the integral by the formula t = 1 / x. Then it will be necessary to write

Int(expression(x=1/t)*(-1/t^2), t)

First 206 207 208 209 Page 208 of 209