Kitonum

21500 Reputation

26 Badges

17 years, 61 days

MaplePrimes Activity


These are answers submitted by Kitonum

If you have specific points, you can use  geom3d  package.

Example:

restart;
with(geom3d):
point(P, 5, 6, 7);
point(A, 1, -2, 3);
point(B, 2, 4, 1);
line(AB, [A,B]);
projection(Q, P, AB);
detail(Q);
                               

 

 

A:=isolve(n+k=2*c);
is(A<>NULL and eval(n, A)::name);
                          
A := {c = _Z1, k = 2*_Z1-_Z2, n = _Z2}
                                                       true

Above  _Z1  and  _Z2  are any integers.

You can use  PolyhedralSets  package to get the vertices and edges of your polygon. This also works in the multidimensional case.

Your example (failed to load the contents of the file, so the image is shown, the link to the file below):


You can extract all vertices in one list with  Relations  command:
V:=Vertices(ps):
Relations~(V);
map(v->eval([x,y],v), %);
               
  [[y = -1, x = -1], [y = 1, x = -1], [y = -1, x = 1], [y = 1, x = 1]]
                                       [[-1, -1], [-1, 1], [1, -1], [1, 1]]

The same for edges.

 

Download PS.mw


 

 

Use  factors  command for this:

f:=x*(x+1)^4*(x^2+x+1)*(x^3+x^2+1)^5:
factors(f);
map(t->op(1,t), %[2]);
sort(%);
                         

 

I usually use  is  command for such checks:

is(2*cos(phi)^2-1=cos(2*phi));
                                                             
true


And more often I look  here , if I don’t know any rare identity.


Edit.

Maple 2018.2 returns the result in the form of finite sums and products (without hypergeometric functions):

restart;
int(sin(x)^n, x) assuming n::posint;
eval(%, n=10);
value(%);
int(sin(x)^10, x); # The direct calculation

      

restart;
Ke := Matrix(4, 4, {(1, 1) = (12*I)*E/l^3, (1, 2) = (6*I)*E/l^2, (1, 3) = -(12*I)*E/l^3, (1, 4) = (6*I)*E/l^2, (2, 1) = (6*I)*E/l^2, (2, 2) = (4*I)*E/l, (2, 3) = -(6*I)*E/l^2, (2, 4) = (2*I)*E/l, (3, 1) = -(12*I)*E/l^3, (3, 2) = -(6*I)*E/l^2, (3, 3) = (12*I)*E/l^3, (3, 4) = -(6*I)*E/l^2, (4, 1) = (6*I)*E/l^2, (4, 2) = (2*I)*E/l, (4, 3) = -(6*I)*E/l^2, (4, 4) = (4*I)*E/l}):
k:=E*I/l^3:
``(k).(Ke/k);

                        

 

You can take any initial value (also any range) for the parameter yourself.
Example:

restart;
plots:-animate(plot, [m*x, x=-10..10, -10..10], m=1..5, frames=100);

Here is a simple procedure for this and an example:

Code of the procedure

P:=proc(A::Matrix, B::Matrix)
local m1,n1,n2;
m1:=op([1,1],A);
n1:=op([1,2],A);
n2:=op([1,2],B);
Matrix(m1,n2, (i,j)->add(A[i,p].B[p,j], p=1..n1));
end proc:


Example

A:=Matrix(2,3,{seq(seq((i,j)=LinearAlgebra:-RandomVector(2,generator=-9..9), i=1..2),j=1..3)});
B:=Matrix(3,2,{seq(seq((i,j)=LinearAlgebra:-RandomVector(2,generator=-9..9), i=1..3),j=1..2)});

Matrix(2, 3, {(1, 1) = Vector(2, {(1) = 2, (2) = -9}), (1, 2) = Vector(2, {(1) = 3, (2) = 1}), (1, 3) = Vector(2, {(1) = -9, (2) = -7}), (2, 1) = Vector(2, {(1) = 3, (2) = 6}), (2, 2) = Vector(2, {(1) = -8, (2) = -8}), (2, 3) = Vector(2, {(1) = 0, (2) = -3})})

 

Matrix(%id = 18446746086682646398)

(1)

P(A,B);

Matrix(2, 2, {(1, 1) = 122, (1, 2) = 104, (2, 1) = -80, (2, 2) = -12})

(2)

 


Addition. Below is an example of another method (without a custom procedure):
 

A:=Matrix(2,3,(i,j)->LinearAlgebra:-RandomVector(2,generator=-9..9));
B:=Matrix(3,4,(i,j)->LinearAlgebra:-RandomVector(2,generator=-9..9));
subsindets(A.B, `*`,t->`.`(op(t)));

Download P.mw

At the beginning of the code, you enter a recursive function  Tm . But your method does not work. Take a look:
 

restart;
Tm:=(t,m)-> 2*t*Tm(t,m-1)-Tm(t,m-2):
Tm(t,0):=1:
Tm(t,1):=t:
Tm(3,4);  # Example

     Error, (in Tm) too many levels of recursion


You can use the following procedure to correctly determine:
 

restart;
Tm:=proc(t,m)
option remember;
if m=0 then return 1 else
if m=1 then return t else
2*t*Tm(t,m-1)-Tm(t,m-2) fi; fi;
end proc:
Tm(3,4);  # Example

                                   577


You can also get an explicit formula for TM :
 

restart;
Tm:=unapply(rsolve({Tm(t,m)=2*t*Tm(t,m-1)-Tm(t,m-2), Tm(t,0)=1, Tm(t,1)=t}, Tm(t,m)),t,m);
Tm(3,4);
simplify(%);

We can use the inert form integral for this:

G := Int( exp( -epsilon * ( x^4 + x^2 ) ), x = -10 .. 10);
plot( G, epsilon=0 .. infinity );
         

          


 

restart

Dice1 := rand(1 .. 6)

Tal1 := Statistics:-Tally([seq(Dice1(), i = 1 .. 1000)], output = table)

table( [( 1 ) = 185, ( 2 ) = 169, ( 3 ) = 159, ( 4 ) = 180, ( 5 ) = 153, ( 6 ) = 154 ] )

(1)

EffectifDice1 := [seq(Tal1[i], i = 1 .. 6)]

[185, 169, 159, 180, 153, 154]

(2)

FreqDice1 := (1/1000)*EffectifDice1

[37/200, 169/1000, 159/1000, 9/50, 153/1000, 77/500]

(3)

A1 := evalf(sum(FreqDice1[i]*(FreqDice1[i]-1/6)^2, i = 1 .. 6))

0.1577317778e-3

(4)

NULL


 

Download QuestionSimulation_new.mw

RootFinding:-Analytic(exp(x)*sin(x)-exp(1), re=0..100, im=-1..1);
plot(exp(x)*sin(x)-exp(1), x=0..100,-3..3, size=[900,300]);  # Check

Notice that the exponential function with the base  e  must be encoded in Maple as  exp(x)  (not  as  e^x ). e is just a symbol in Maple.

Unfortunately, I do not see the possibility to significantly speed up this calculation. I just rewrote your code as a procedure, slightly simplifying it. The procedure returns  true  if the matrix is  MDS  and  false  otherwise. The example of a matrix of 12 order is considered. This calculation took about 35 minutes on my computer.


 

restart;

IsMDS:=proc(A::Matrix)
local n, k, P, p, q, F, r;
uses combinat, LinearAlgebra;
n:=op([1,1],A);
for k to n do
 P := choose(n, k);
 for p in P do
 for q in P do
 F := A(p, q);
 r := Determinant(F);
 if r = 0 then return false end if;
end do; end do;
end do:
true;
end proc:

ts:=time():
interface(rtablesize=100):
A:=LinearAlgebra:-RandomMatrix(12);
IsMDS(A);
time()-ts;

Matrix(12, 12, {(1, 1) = -69, (1, 2) = -30, (1, 3) = -75, (1, 4) = 42, (1, 5) = -81, (1, 6) = -97, (1, 7) = -63, (1, 8) = -5, (1, 9) = 58, (1, 10) = -29, (1, 11) = 48, (1, 12) = 28, (2, 1) = 17, (2, 2) = -50, (2, 3) = -3, (2, 4) = 55, (2, 5) = 11, (2, 6) = -92, (2, 7) = 27, (2, 8) = 47, (2, 9) = -43, (2, 10) = 9, (2, 11) = -60, (2, 12) = -81, (3, 1) = -87, (3, 2) = 98, (3, 3) = 19, (3, 4) = 34, (3, 5) = -76, (3, 6) = 73, (3, 7) = 58, (3, 8) = -54, (3, 9) = -85, (3, 10) = 81, (3, 11) = 51, (3, 12) = -36, (4, 1) = 37, (4, 2) = 5, (4, 3) = 69, (4, 4) = -55, (4, 5) = 82, (4, 6) = 44, (4, 7) = 2, (4, 8) = -72, (4, 9) = -85, (4, 10) = 35, (4, 11) = 20, (4, 12) = -88, (5, 1) = 33, (5, 2) = -23, (5, 3) = -89, (5, 4) = 54, (5, 5) = -29, (5, 6) = 92, (5, 7) = 54, (5, 8) = -79, (5, 9) = 19, (5, 10) = 80, (5, 11) = -46, (5, 12) = 91, (6, 1) = -17, (6, 2) = 19, (6, 3) = 95, (6, 4) = 79, (6, 5) = 29, (6, 6) = 73, (6, 7) = 47, (6, 8) = 75, (6, 9) = 25, (6, 10) = 20, (6, 11) = 35, (6, 12) = -62, (7, 1) = 58, (7, 2) = -93, (7, 3) = 77, (7, 4) = -99, (7, 5) = 35, (7, 6) = -39, (7, 7) = 90, (7, 8) = -85, (7, 9) = 17, (7, 10) = 39, (7, 11) = -54, (7, 12) = -94, (8, 1) = -21, (8, 2) = 12, (8, 3) = -84, (8, 4) = -32, (8, 5) = -70, (8, 6) = 62, (8, 7) = -41, (8, 8) = -19, (8, 9) = 81, (8, 10) = -35, (8, 11) = -17, (8, 12) = 27, (9, 1) = 15, (9, 2) = 82, (9, 3) = -63, (9, 4) = -9, (9, 5) = -43, (9, 6) = 11, (9, 7) = -79, (9, 8) = 57, (9, 9) = 89, (9, 10) = 26, (9, 11) = -25, (9, 12) = 18, (10, 1) = -58, (10, 2) = -4, (10, 3) = 96, (10, 4) = 69, (10, 5) = -23, (10, 6) = 61, (10, 7) = 9, (10, 8) = 83, (10, 9) = 92, (10, 10) = -74, (10, 11) = 78, (10, 12) = 18, (11, 1) = 75, (11, 2) = 14, (11, 3) = 69, (11, 4) = 31, (11, 5) = -14, (11, 6) = 28, (11, 7) = 45, (11, 8) = -45, (11, 9) = -2, (11, 10) = 13, (11, 11) = 23, (11, 12) = 63, (12, 1) = -31, (12, 2) = 78, (12, 3) = 72, (12, 4) = -66, (12, 5) = 37, (12, 6) = -48, (12, 7) = -10, (12, 8) = 68, (12, 9) = -46, (12, 10) = 32, (12, 11) = -67, (12, 12) = 86})

 

true

 

2090.344

(1)

%/60*minutes;

34.83906667*minutes

(2)

 


 

Download MDS.mw

 

Since the system is easily reduced to a linear system, it can easily be solved symbolically, that is, absolutely exactly:

Sys:=convert({(T[1]-T[0])/(10000-T[1]+T[0]) = -2.000000000, (T[2]-T[0])/(20000-T[2]+T[0]) = 0, (T[3]-T[0])/(50000-T[3]+T[0]) = 50, .1*T[0]+.3*T[1]+.55*T[2]+0.5e-1*T[3]-5000 = 0}, fraction);
solve(Sys);


                

First 97 98 99 100 101 102 103 Last Page 99 of 290