acer

32485 Reputation

29 Badges

20 years, 7 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

plots:-listplot( [seq(X[i],i=1..50)] );

acer

You could post the actual example.

Do you want exact, or floating-point results? Is it a polynomial of one variable or of several variables? If it is univariate, then you could pass it to fsolve for floating-point results. If the problem is that the form of the exact results from solve don't appear to match your expectation, then suggestions might be made if you post the example.

acer

Have a look at the help-page for rtable_scanblock. That routine can find max/min and locations for Matrix/Vector/Array.

> V:=<1,4,8,2>:

> rtable_scanblock(V, [1..3],
>                  (val,ind,res) -> `if`(val > res[2],[ind,val],res),
>                  [[1],V[1]]);
                                   [[3], 8]

> op(%[1]);
                                       3

Note that your [1,4,8,2] is a list, not a Vector.

acer

plot( 23*sin(x) + x - 1, x=-35..35 );

RootFinding:-Analytic(23*sin(x)+x-1, x=-100-0.1*I..100+0.1*I );

seq(eval(23*sin(x)+x-1,x=t), t in [%]);

acer

Powell := (M,N) -> (first(M,N),second(M,N)):
Powell(4,5); # for example

MyMat := Matrix(100,2):

for N from 1 to 10 do
  for M from 1 to 10 do
    MyMat[10*(N-1)+M,1],MyMat[10*(N-1)+M,2] := Powell(M,N);
  end do:
end do:

interface(rtablesize=100):
MyMat;

The interface(rtablesize) call only needs to be done once, and only serves if you wish to get the entries printed out to the Maple interface.

For the other aspect, of selecting just some of the values, you could use the following technique,

> Powell := (M,N) -> (first(M,N),second(M,N),third(M,N),fourth(M,N),fifth(M,N)):
> g:=[Powell(7,11)];
 g := [first(7, 11), second(7, 11), third(7, 11), fourth(7, 11), fifth(7, 11)]

> g[2],g[3];
                          second(7, 11), third(7, 11)

That is to say, the double loop might look like this,

for N from 1 to 10 do
  for M from 1 to 10 do
    g:=[Powell(M,N)];
    MyMat[10*(N-1)+M,1],MyMat[10*(N-1)+M,2] := g[2],g[3];
  end do:
end do:

The Matrix() constructor also admits an operator as an initializer, and that could likely be made to work here too (without all that looping). But maybe you have other things that you'd eventually want to happen inside your loop. And it's useful to get familiar with the loop and assignment syntax.

acer

How far have you gotten with any of these, so far?

Write down the cosine law (and/or the sine law). Fill in some of the variables with the information you're given. Figure out which of the other variables relate to the piece that you're asked to find. Solve for that variable.

acer

> expr := (beta*p-beta-p)*alpha/(p*(beta-1)):

> simplify(expr-(alpha+beta/p),{alpha=1-beta});

                                       0

> eval(collect(expr,p),beta=1-alpha);
                                       1 - alpha
                               alpha + ---------
                                           p

> collect(simplify(simplify(expr,{alpha+beta=1})),p) assuming alpha>0, beta>0;
                                       1 - alpha
                               alpha + ---------
                                           p
 
> subsindets(%,identical(1-alpha),t->beta);
                                         beta
                                 alpha + ----
                                          p

> subsindets(collect(expr,p),identical(beta-1),t->-alpha);
                                         beta
                                 alpha + ----
                                          p

acer

You forgot spaces before the opening round-brackets, when you typed in

d(27*d^2-40)^3

and

x(3*x^3-9*x^2+20)

Without the space (to imply multiplication) Maple interprets those as function calls to x() and d().

acer

The Matrix formed from those three vectors will have zero as its determinant when that Matrix has a rank of less than three.

> (u,v,w) := <-2,-5,5>, <1,7*a,-2>, <3,3,a>;

                                     [-2]  [ 1 ]  [3]
                                     [  ]  [   ]  [ ]
                          u, v, w := [-5], [7 a], [3]
                                     [  ]  [   ]  [ ]
                                     [ 5]  [-2 ]  [a]
 
> with(LinearAlgebra):

> values := [solve( Determinant( <u|v|w> ) )];
                                        1/2               1/2
                                    2962              2962
                values := [- 25/7 - -------, - 25/7 + -------]
                                      14                14
 
> seq( Rank( eval(<u|v|w>,a=values[i]) ), i=1..nops(values) );
                                     2, 2

acer

It seems most likely (to me) the the request is how to assign entries to a Matrix which already exists. Hopefully the submitter will clarify, if needed.

M := Matrix(10,10):
for i from 1 to 10 do
  for j from 1 to 10 do
     M[i,j] := Xlocal(i,j);
  end do;
end do;
M;

The above looping is ok. But really the answer depends on what form your Xlocal is in. If Xlocal is a list of lists or a Maple table (with the right sort of indices) already then you could just pass it directly to the Matrix() constructor. Eg,

Xlocal := [[1,3],[5,7]]:
Matrix(Xlocal);
Xlocal := table([(1,2)=17,(3,2)=11,(3,3)=13]):
Matrix(3,3,Xlocal);

If Xlocal is a procedure, then you could pass it to the Matrix() constructor as the initializer. Eg,

Xlocal := (i,j) -> i*sin(i+j):
Matrix(3,3,Xlocal);

acer

The B is typesetting of Beta. See the help-page for that special function by issuing the command ?Beta.

ps. Do not try define functions in Maple in this way,

f(x):=(1-x^(3/(2)))^(2/(3));

What that actually does is assign to f as if it had a remember table. It may not always behave as you expect. It actually does this,

> f(x):=(1-x^(3/(2)))^(2/(3));
                                         (3/2) (2/3)
                           f(x) := (1 - x     )
 
> eval(f);
               proc() option remember; 'procname(args)' end proc
 
> op(4,eval(f));
                                         (3/2) (2/3)
                        table([x = (1 - x     )     ])

To instead assign f as an expression, do it like this,

f:=(1-x^(3/(2)))^(2/(3));

eval(f, x=1/2); # evaluate at a point

Or, to assign f as a procedure (function) do it like this,

f:= x -> (1-x^(3/(2)))^(2/(3));

f(1/2); # evaluate at a point

acer

I suspect that the point of the exercise is to show that you can compute that more easily by going (temporarily) through polar forms.

Suppose that you have two complex numbers a and b. It can be awkward to raise those to high powers by hand. But if you first convert to polar form, then you can combine the radii and the angles more "easily", and then convert back. Notice how, below, one doesn't have to compute a^12 or b^11 by fully expanding out the complex numbers.

> a := 2-5*I:
> b := 4+I:
> abs(a)^12, 12*argument(a);
                          594823321, -12 arctan(5/2)
 
> abs(b)^11, 11*argument(b);
                                   1/2
                         1419857 17   , 11 arctan(1/4)
 
> rationalize( abs(a)^12 / abs(b)^11 );
                                            1/2
                                594823321 17
                                ---------------
                                   24137569
 
> simplify( arctan( tan(12*argument(a)-11*argument(b)) ) );
                                   3326168023240553
                           -arctan(----------------)
                                   1030781181093988

I'll leave it to you to see how best to convert back to rectangular complex coordinates. Of course, Maple can do it for you either way, easily.

> a^12/b^11;
                    -1030781181093988   3326168023240553
                    ----------------- + ---------------- I
                     34271896307633      34271896307633

> r,theta := op(convert(%,polar));
                                  1/2
                      594823321 17             3326168023240553
          r, theta := ---------------, -arctan(----------------) + Pi
                         24137569              1030781181093988

> r*cos(theta)+I*r*sin(theta);
                    -1030781181093988   3326168023240553
                    ----------------- + ---------------- I
                     34271896307633      34271896307633

acer

> L := [1,2,3,4,5]:
> Statistics:-Mean(L);
                                      3.

> L := Vector[row]([1,2,3,4,5]):
> Statistics:-Mean(L);
                                      3.

> kernelopts(version);
           Maple 11.00, IBM INTEL LINUX, Feb 16 2007 Build ID 277223

acer

By default only small Matrices/Vectors/Arrays are printed in full. Those objects are examples of the rtable data structure in Maple.

The default value at which the behaviour changes from a full elementwise view to the brief view varies with the choice of Maple user interface. I believe that in the Standard GUI the default is that it changes at size 10, and in the commandline interface it changes at size 25.

One can change the interface setting for rtablesize, which specifies the value at which the view switches. (See the ?interface help-page.)

For example,

> interface(rtablesize=3):
> Vector[row]([1,2,3,4,5]);
                           [ 5 Element Row Vector ]
                           [ Data Type: anything  ]
                           [ Storage: rectangular ]
                           [ Order: Fortran_order ]
 
> interface(rtablesize=50):
> Vector[row]([1,2,3,4,5]);
                                [1, 2, 3, 4, 5]

acer

This way, it does not assign to y.

> eq1:=x+y=2:
> isolate(eq1,y):

> eval( s=z+y, % );
                                 s = z + 2 - x
 
> y;
                                       y

acer

First 303 304 305 306 307 308 309 Last Page 305 of 337