Kitonum

21440 Reputation

26 Badges

17 years, 40 days

MaplePrimes Activity


These are answers submitted by Kitonum

The procedure  coefff  returns the coefficient of the monomial  t  in the multivariate polynomial  P (T - the list of variables of the polynomial). The procedure works with both numeric and symbolic  coefficients.

 

coefff:=proc(P, T, t)

local L, H, i, k:

L:=[coeffs(P, T, 'h')]: H:=[h]: k:=0:

for i from 1 to nops(H) do

if H[i]=t then k:=L[i] fi:

od:

k;

end proc:

 

Examples of use:

Pol:=3*x^2-a*x*y+1:

coefff(Pol, [x,y], x^2);

coefff(Pol, [x,y], x*y);

coefff(Pol, [x,y], 1);

                 3

                -a

                 1

 

If I understand the question right, you need to generate all of the matrix of a given size n, which have k units on the diagonal, other elements are 0  (you have n=10). The procedure SM make this.

SM:=proc(n,k)

local P;

uses combinat;

P:=permute([1$k, 0$n-k]);

seq(Matrix(n, p, scan= diagonal), p=P);

end proc:

 

Example of use:

SM(5,2);

 

I do not know commands in Maple, which realize an approximation by piecewise constant functions. It is easy to write a procedure that makes it. The  function should be specified in the nodes [x [i], y [i]] . The procedure determines the value of the function at intermediate points as the average of the values in neighboring nodes.

Code of the procedure:

PWCapprox:=proc(L::list)

local n;

n:=nops(L);

piecewise(seq(op([x>L[i,1] and x<L[i+1,1],(L[i,2]+L[i+1,2])/2]), i=1..n-1));

end proc:

 

Example of use (approximation of sinusoid arch):

n:=20:

L:=[seq([Pi/n*k,sin(Pi/n*k)], k=0..n)]:

A:=plot(L, style=point,color=red):

B:=plot(PWCapprox(L), x=0..Pi, color=red, thickness=2, discont):

plots[display](A, B, scaling=constrained);

 

 

 

See the help in  GraphTheory  package on the commands  DijkstrasAlgorithm , AllPairsDistance, BellmanFordAlgorithm,  ShortestPath

I think that this inequality intended for manual solution. Here is the such solution with partial  use of Maple. Since the function is continuous, then the solution of the inequality reduces to finding the exact roots of the corresponding equation.

A:=18*9^(x^2+2*x)+768*4^((x+3)*(x-1))-5*6^((x+1)^2):

applyop(expand, {seq([i,2,2], i=1..3)}, A);  # We open the brackets in power exponents

algsubs(x^2+2*x=t, %);  # Substitions  t=x^2+2*x

applyop(expand, {[2,2], [3,2]},%);  # Simplification

map(s->s/4^t, %)=0;  # We divide both sides by  4^t

So we come to the quadratic equation  B  for  s=(3/2)^t

B:=18*s^2+12-30*s=0:

solve(B);

                           1, 2/3

It remains to solve two simple equations  (3/2)^(x^2+2*x)=2/3  and  (3/2)^(x^2+2*x)=1  and original inequality:

solve(x^2+2*x=-1), solve(x^2+2*x=0);

solve((x+1)^2*(x+2)*x>=0);

             

 

 

 

 

 

 

 

First, we find the rank of a given system of vectors (let rank is n), and then generate all possible sets of n vectors of the original system and the selection of those of them that have a maximum rank.

Example:

restart;

with(LinearAlgebra):

S:=[seq(RandomVector(3, generator=rand(0..3)), n=1..15)];  # The list of 15 random vectors

Matrix(S):

n:=Rank(%);

T:=combinat[choose](S, n):  # The list of all sets of n vectors of S

nops(T);

k:=0:

for t in T do

if Rank(Matrix(t))=n then k:=k+1; B[k]:=convert(t,set) fi;

od:

B:=convert(B, list):  # The list of all bases 

nops(B);  # The number of bases

B[1..10];  # the first 10 bases of B

I do not know in Maple direct commands that solve both problems for multivariate polynomials. Here are some solutions  for the polynomial  P:

P:=a*x^2*y*z+b*x*y*z+c*x^2*y*z+d*x*y^2*z+e*x*y*z;

L:=[coeffs(P, [x,y,z], 't')];

H:=[t];

add(L[i]*H[i], i=1..nops(L));  # Solution of the first problem

                        

 

for i to nops(H) do  # Solution of the second problem

if H[i]=x^2*y*z then break fi;

od;

L[i];

                                a+c

 

L[ListTools[Search](x^2*y*z, H)];  # Shorter variant

                                a+c

 

Addition: If you want to have the members of the polynomial  P  to be sorted, for example, in lexicographical order, then

sort(add(L[i]*H[i], i=1..nops(L)), [x,y,z]);

        (a+c)*x^2*y*z+d*x*y^2*z+(b+e)*x*y*z

Use   GraphTheory[SequenceGraph]  command.

simplify(combine(-sqrt(1-cos(t))*sqrt(cos(t)+1)))  assuming t>=0, t<=Pi;

                                     -sin(t)

 

For other  t  this is not true.

 

If the variables in your expression are ordinary letters of the English alphabet, extract them as follows:

Expr:="(x-y)/(x-y)";

S:={seq(Expr[i], i=1..length(Expr))};

map(parse, select(StringTools[IsAlpha], S));

    

 

 

The simple procedure  CoeffsOfLinComb   finds all the coefficients of zero linear combination of several polynomials. If all the coefficients are 0, this means that the polynomials are linearly independent. It is clear that in the case of non-zero coefficients they are not uniquely defined, but only up to a constant factor. The procedure works also with polynomials with symbolic coefficients (in general case).

CoeffsOfLinComb:=proc(L::list(polynom), V::list(symbol))

local n, lincomb, M;

n:=nops(L);

lincomb:=expand(add(C[k]*L[k], k=1..n));

M:={coeffs(lincomb,V)};

solve(M, {seq(C[k], k=1..n)});

end proc: 

 

Examples of use:

CoeffsOfLinComb([x+y, y+z, x+z], [x,y,z]);   # The polynomials are linearly independent

CoeffsOfLinComb([x+y, y+z, x+z, x+y+z], [x,y,z]);  # The polynomials are linearly dependent

map(t->lhs(t)=eval(rhs(t), C[1]=1), %); 

CoeffsOfLinComb([x, a*x+b*y, a*x-b*y], [x,y]);  # The polynomials with symbolic coefficients

map(t->lhs(t)=eval(rhs(t), C[2]=1),%);

       

 

 

 

I do not understand why you use the loop. A simple solution without any loops:

restart;

Z:=Matrix(2, symbol=z);

Z[1,1]:=1;

Z;

                        

 

 

The command  identify does the inverse transformation:

evalf( ln(3) );

evalf( exp(5) );

identify(%%);

identify(%%);

convert(%%, ln);

                   

 

 

I understand the question so that it is not allowed to use any packages, only the core of Maple. Solution for rows (similarly for columns):

M:=<1,  5,  6; 0,  0,  0;  2,  3, 5 >:

r:=0:

for i from 1 to op([1,1], M) do

if convert([seq(M[i,j]<>0, j=1..op([1,2],M))], `or`) then r:=r+1 fi;

od:

r;

                                           2

 

 

If I understand the problem, all the pieces are in the form of a circular sector of the same radius. The first step - add them together to get a single sector.

1) The solution of 3 sections: just cut this single sector by 3 sections into 4 equal pieces.

2) The solution of 2 sections: one section goes along the symmetry axis of the sector, the second section is perpendicular to the first one. For reasons of continuity it is always possible.

 

Addition. With Maple (if the radius and the angle of the sector are known) easy to find at what distance from the center of the circle to do the second cut.

                           

 

 Addition 2. I downloaded the file and saw that I understood the problem incorrectly. Therefore, my solutions are the solutions of other problem. Tomleslie's solution is right.

First 210 211 212 213 214 215 216 Last Page 212 of 289