John Fredsted

2238 Reputation

15 Badges

20 years, 164 days

MaplePrimes Activity


These are answers submitted by John Fredsted

For a 5x5 matrix A, say, you could write as follows:

A := Matrix(5$2,shape = triangular[lower],symbol = a);

The conversion to abstract Lie algebra can be performed along the following lines (see Example 7 of the help page on DGsetup):

with(DifferentialGeometry):
with(LieAlgebras):
DGsetup([x,y,z,t,u]):
VectorFields := evalDG([
   y*D_y,
   z*D_z,
   z*D_y,
   y*D_z,
     D_t,
   x*D_x + 3*t*D_t,
     D_x,
   u*D_u
]):
LieAlgebraData(VectorFields);

A suggestion, using modulo 2:

bits := [1,0,0,0,0,0,0,0];
text := [1,1,1,1,0,0,1,1];
`+`((bits + text mod 2)[]);

If you define your blocks as a list of lists, then you can do it all in a one-liner, as follows:

block := [[0,0,1,1,0,0,1],[0,0,1,1,1,0,0],[0,1,0,1,0,1,0],[1,0,0,1,1,1,0]]:
ListTools:-Rotate(block,1);

What about simply doing the following?

y := rand(2..7  )();
x := rand(1..y-1)();

Perhaps you could use a construction like the following:

if rand() / 10^12 < 0.5 then
   ... do N ...
else
   ... do S ...
end if;

It will choose between N and S with the same likelihood because rand() returns a 'random' integer between 0 and 10^12 - 1, see its help page.

Perhaps the following functions will do:

binaryAdd := (x,y) -> convert(convert(x,decimal,2) + convert(y,decimal,2),binary):
binarySub := (x,y) -> convert(convert(x,decimal,2) - convert(y,decimal,2),binary):
binaryMul := (x,y) -> convert(convert(x,decimal,2) * convert(y,decimal,2),binary):
binaryDiv := (x,y) -> convert(convert(x,decimal,2) / convert(y,decimal,2),binary):

Some examples (the first three being the examples you give):

binaryAdd(1101,111);
binarySub(11000,1011);
binaryMul(1011,1101);
binaryDiv(10010011,11);
                             10100
                              1101
                            10001111
                             110001

PS: There seems to be something wrong with the division example you give: the division does not result in an integer, as you indicate.

The following function finds the complement (assuming x to be an integer from 0 to 255):

complement := (x) -> convert(255 - x,binary):

Examples:

complement(19);
complement(50);
                            11101100
                            11001101

I guess what you are looking for is simply get_compts(Estn).

A suggestion:

f := [2,e,3,-4,-a,b,d]:
map(x -> sign(x)*x,f);

 

Although not giving the exact Jacobian of yours (it never could, for how is l and r to emerge), is what you have in mind something along the following lines?

eq1 := l1*cos(theta)+l2*sin(beta)-x:
eq2 := l1*sin(theta)-l2*cos(beta):
VectorCalculus[Jacobian]([eq1,eq2],[beta,x,theta]);

Note that beta, x, and theta are written without the time parameter; otherwise the Jacobian cannot be calculated as shown.

It is perhaps cheating, but as

simplify(numer(expr)^2 + denom(expr)^2);

gives zero, your assertion immediately follows. Here, of course, expr means your expression.

What about something along the following lines?

myD := proc(x)
   if   type(x,`+`) then map(myD,x)
   elif type(x,`*`) then myD(op(1,x))*`*`(op(2..-1,x)) + op(1,x)*myD(`*`(op(2..-1,x)))
   elif type(x,`^`) then
      if type(op(2,x),constant) then op(2,x)*op(1,x)^(op(2,x) - 1)*myD(op(1,x))
      else simplify(myD(exp(op(2,x)*ln(op(1,x)))))
      end if
   elif type(x,function) then myD(op(0,x))(op(1,x))*myD(op(1,x))
   else D(x)
   end if
end proc:
myDiff := (x,coord) -> eval(myD(x),D = ((y) -> Diff(y,coord))):

Some examples:

myDiff(x*y*z,x);
myDiff(x^y,x);
myDiff((exp(1)^z)^6,x);
myDiff(x^Pi,x);

Perhaps the following is useful:

myDiff := (expr,coord) -> eval(D(expr),D = ((x) -> Diff(x,coord))):

Example of use:

myDiff(x*y/z,x);

The for loop:

for i from 1000 to 1015 do
   i,isprime(i)
end do;

The for in loop:

for i in `$`(1000..1015) do
   i,isprime(i)
end do;
First 9 10 11 12 13 14 15 Last Page 11 of 19