Robert Israel

6577 Reputation

21 Badges

18 years, 209 days
University of British Columbia
Associate Professor Emeritus
North York, Ontario, Canada

MaplePrimes Activity


These are answers submitted by Robert Israel

It looks to me like p and theta are the polar coordinates for the closest point to the origin on the straight line through the two points A and B.

You can try something like this:

> Sol := pdsolve(pde, ibc, numeric);
  usol:=  subs(Sol:-value(output=listprocedure),u(x,t));

usol is then a function of two variables x and t, which for numerical values of x and t gives the solution at that point.  And you should be able to use this in numerical integration, e.g.

> evalf(Int(x * usol(x, 0.2), x = 0 .. 1));

or even

> plot(Int(x * usol(x,t), x = 0 .. 1)/Int(usol(x,t), x = 0 .. 1),
    t = 0 .. 2);

For a 2-d plot (of a monochrome image), you can try listdensityplot:

> plots:-listdensityplot(immy,style=patchnogrid);

(you may want to rotate that 90 degrees clockwise).

Unfortunately listdensityplot doesn't allow an m * n * 3 Array which you would get from a colour image, but you could use listdensityplot on one of the colour components.

Also this might not work very well on big images, especially in Standard GUI. 

Thus:

> immy:=ImageTools:-Read(
       "c:/Program Files/Maple 13.02/data/images/tree.jpg"):
   reds:= immy(..,..,1);
   plottools[rotate](plots[listdensityplot](reds,
      style=patchnogrid), -Pi/2);

There are several ways to create a matrix, of which the Matrix command is probably the most useful here.  The number of rows and columns (n and q in the case of the result of this procedure) are input parameters of the procedure.  You don't need a loop, because you can give the Matrix command a procedure to tell it how to produce the matrix elements.  Thus your answer could be of the form

> MULTIPLYMATRIX:= (A,B,n,m,q) -> Matrix(n,q, (i,j) -> ***) 

where *** is a formula for the (i,j) matrix element of the product A . B.

A problem I have with this question is that it says "Your procedure should print the result matrix", which I doubt is meant to be taken literally: the procedure I outlined above will produce the product matrix as its result, which will be printed if you enter
something like

> MATRIXMULTIPLY(A,B,n,m,q);

(for appropriate A, B, n, m and q).  Or does the instructor really want a print statement in the procedure?

 

Here's the bug in just about its simplest form, I think:

> product(i-3, i=k+1 .. 3);

0

... which is of course wrong for k >= 3.

1) According to the help page, the second parameter to coeffs is

x - (optional) indeterminate or list/set of indeterminates

In (a), the second parameter is omitted, and the default is to compute the coefficients with respect to all the indeterminates, namely x and y in this case.  Whether the indeterminates are specified as a set (as in (b)) or list (as in (c)) does not matter.  In
both (d) and (e) you gave x as the indeterminate.  But there is a difference between (d) and (e), because in (e) you specified a third parameter y, which means that y is assigned a value, in this case the expression sequence 1, x, x^2,, corresponding to the powers of x (so that p1 is the sum of the coefficients times the corresponding powers of x).

2) Did you mean coeffs(p1,x) and coeffs(p1,y)?  Well then,

> coeffs(p1,x), coeffs(p1,y);

3) I don't understand what you're asking for in this one.

Assuming j is an explicit integer, you could try:

> add(A[i,j], i = {$1..12} minus {j});

Or if you want a symbolic sum for symbolic j,

> Sum(A[i,j]*piecewise(i=j,0,1), i=1..12);

 

Perhaps this?

> p3:= reflect(p1,[[e1,0],[FresnelC(u0),FresnelS(u0)]]):
  display(p1,p2,p3);

You can sort a polynomial in various ways (see the help page ?sort).  You may find that helpful, even if your expression is not a polynomial.

intConv works if it's given two functions (well, it would if you corrected a small typo).

Heaviside is a function, and so is rect, i.e. you can say rect(x) where x is a number and you'll get a number.  But rect(-t) is an expression, not a function: rect(-t)(x) doesn't make sense.  You can use unapply to make an expression into a function.  Thus

> intConv(Heaviside, unapply(rect(-t),t));

You could do something like this (to get the second and third of three columns), which reads all the data and then extracts the second and third columns.

> Matrix(readdata("location", float, 3))( .. , 2 .. 3);

 

I might try something like this.  Go through your list L and check, for each element, whether that element is a duplicate of one that occurs earlier.  You can do that using the three-argument form of member, since 

> member(L[i], L, 'j');

will leave j as the first position where L[i] occurs in the list L.  Keep track of those i for which that is true.  Then use subsop to remove the duplicate entries.  For efficiency, just use one subsop: if you want to remove entries number i1, i2, ..., ik, then

> subsop(i1=NULL, i2=NULL, ..., ik=NULL, L)

will do it.

For testing whether a polynomial f is primitive mod p, you can use Primitive(f) mod p.
So e.g. to find 10 different primitive polynomials of degree 10 over GF(2):
 

> F:= NULL: n:= 0: 
  while n < 10 do
      f:= 1+expand(x*randpoly(x,degree=8,coeffs=rand(0..1)))+x^10;
      if Primitive(f) mod 2 and not member(f,[F]) then 
          F:= F,f; n:= n+1 fi
  end do:
  F;

Or to get all 60 primitive polynomials of degree 10 over GF(2):

> numtopoly:= (U,d) -> sort(convert(zip(`*`,convert(U,base,2), 
        [seq(x^i,i=0..d)],0),`+`));
  select(f -> Primitive(f) mod 2, map(numtopoly,
        [seq(i, i=2^10+1 .. 2^11-1, 2)],10));

Utilisez textplot.  

Assuming your vectors are column Vectors:

> f := x -> x^%T . H . x + g^%T . x;

 

First 50 51 52 53 54 55 56 Last Page 52 of 138