MaplePrimes Questions

I have been using CodeTools::Usage with Maple 17 to compare timings of a couple of matrix inversion routines against each other and against the Maple library routines LinearAlgebra::MatrixInverse and LinearAlgebra::Determinant.

The small section of code that I use to collect the cpu times for each method is:

----------------------------------------

udata := Usage(invTest(x,y,z,delta,mu), output=['cputime', 'bytesused'],
              iterations=nRepeats, quiet);
dat[1]:=udata[1]; dat[2]:=udata[2];

----------------------------------------
nRepeats has been set to 25.

In order to get the timings as accurate as possible, I only open a couple of terminal windows on my laptop so as to run the tests with as low a loaded machine as I can get. (I'm running Ubuntu 14.04 on an 8 core Intel (R) Core i7-3840QM, 2.8GHz CPU with 16Gb of memory.)

A test run consists of a sequence of test matrices each of which is run for an increasing sequence of matrix orders. I either time an implementation on its own or I time both an implementation and the Maple library routines. In the later case for each test matrix and order of matrix, I use Usage to first time the Maple routines and then the times for one of the implementations:

----------------------------------------

if compMaple then
udata := Usage(MatrixInverse(A), output=['cputime', 'bytesused'],
              iterations=nRepeats, quiet);
mdat[1]:=udata[1]; mdat[2]:=udata[2];

udata := Usage(Determinant(A), output=[cputime, bytesused],
              iterations=nRepeats, quiet);
mdat[1]:=mdat[1]+udata[1];
mdat[2]:=mdat[2]+udata[2];
else
  mdat[1..2] := 0:
end if:

udata := Usage(invTest(x,y,z,delta,mu), output=['cputime', 'bytesused'],
              iterations=nRepeats, quiet);
dat[1]:=udata[1]; dat[2]:=udata[2];

----------------------------------------

I have noticed the following:

a) If I time both Maple and an implementation, and the same implementation on its own I can get timings that vary up to a factor of 2 or more,

b) Changes in timings for the same test run and as close to the same environment as I can get (i.e., just the two user terminal windows open) can generate timing differences of up to 50%.

c) Sometimes `chaotic' timings are generated, for example,

    n = 150, t = 3 (secs)
    n = 200, t = 24 (secs)
    n = 250, t = 18 (secs)

which cannot be reflecting the times required to perform the calculations. This type of behaviour always seems to occur when the reported memory bytecount is increasing from ~0.25* 10^9 to over 10^9.

Is there anything I can be doing here to get more consistent timings?

I want to use the timings from these tests in a journal article so it would be good to have the same test run under very similar conditions to return timings within a few percent difference of one another. I certainly get this sort of tolerances (<10%) if I use the Fortran cpu_time intrinsic to time Fortran code.

Any advice would be gratefully received.

Hi, 

As an example, I have these 3 equations below and I need to balance them similar to balancing a chemical equation.

Equation 1: E1=A+B+C+D
Equation 2: E2=A-B+C-D
Equation 3: E3=C

So, I am wondering if there are any functions or algorithms that allow me to input such that they will give me a result of 

xE1 ± yE2 ± zE3 = wA

where w,x,y &z are integers and x,y & z can be zero. 

Thanks.

Ho do I print this?

A - lambdaI = some matrix

On the left of the equation I have the letter "A" a minus sign, the Greek letter "lambda" and the letter "I" right next to it.
The rest. from "=" on, is math.

Thank you!

mapleatha

I'm trying to create the set of monomials in n variables (given as a list var), up to a given degree d. Her eis my code. Any comments to make it better?

mondeg:=proc(var::list,d)
local n, mon, moni, i, j, m1, m;

   n:=nops(var);
   mon:={1};
   moni:={1};
   for i to d do
        for m1 in moni do
             #print(m1);
             moni:=moni minus {m1};
             #print(moni);
             for j to n do
                #print(var[j]);
                 m:=m1*var[j];
                 moni:=moni union {m};
                #print("moni=",moni);
             od;
        od;
        mon:=mon union moni;
        #print(mon);
   od;

mon;
end:

Hello everyone,

I know that it is possible to obtain the DH parameters of a robot manipulator model in the MapleSim environment.

I was wondering if it is possible to obtain the Jacobian matrix of a robot manipulator from the MapleSim model?

Thank you,

 

Often after using collect(expression,x) the prefactors of x are within a bracket but typically contain factors in each term of the bracket that are equal and not pulled out of the bracket. Is there a way to ask maple to automatically factor out these after collecting?

I hope it is clear what I mean...

Hi,
Triing to solve some 2 differential equations system (plan mechanical movement), using "output=" as last option, I am interrested by the values of the second derivatives of the coordinates. The "output" runs fine to get t, x(t), y(t), dx/dt(t) and dy/dt(t). To get d^2x/dt^2 and d^2y/dt^2, I thought it would work to write something like (A is the times array) this :

dsol := dsolve(dsys, type = numeric,  {diff(x(t),t,t), diff(y(t),t,t},output = A),

But if I do this, I get next error message :

Error, (in dsolve/numeric/process_input) dependent variables must be functions of a single unknown, the independent variable. Got [diff(diff(x(t), t), t), diff(diff(y(t), t), t)]


Could you please help me ?
Thanks

 

I generated a few plots using the plot command. When I try to animate them using the display command, only the first plot appears and not the rest. I can't figure out what the problem is. Any help is appreciated. I have attached below the commands I am using to generate the plots and animate them:

restart;
with(plots):
with(OrthogonalExpansions):

f := x -> x;
L := 1:
fexplt:=plot(f(x),x=-L..L):
fs := n->FourierSeries(f(x),x=-L..L,n,'Coefficients');
fs(n);
                  n                            
                -----                          
                 \          (1 + i)            
                  )   2 (-1)        sin(Pi i x)
                 /    -------------------------
                -----           Pi i           
                i = 1                          

nmax := 25:

display([seq(plot([f(x),fs(m)],x=-L..L),m=1..5)],insequence=true);
 

If I just use

seq(plot([f(x),fs(m)],x=-L..L),m=1..5);
 

I get all the five plots output to the screen.  So, I know the plots are there. It's the animation part that doesn't seem to work. I am using Maple 2015 on a linux mint desktop.

 

Thanks.

Hello all,

I am looking for a maple command to do the following

#outline of idea, is a user would pre-define a number of rows and a single Matrix command would automatically generate a Matrix based on the data the user provides.

numRows:= ;#user would enter a number here

row1:=[1,2,3];  #user enters data for each row

row2:=[4,5,6,7];

row4:=['red','blue',7];

#user will enter a few more rows to match numRows, specified above

Matrix([[row1],[row2],[row3],....,[rown]]);#this matrix command would be generated based on the above entered data

 

I was thinking some form of counter could do this?  Any suggestions would be appreciated.

Hello everyone,

First I want to thank you for paying attention to my post.

I'm trying to determine the maximum of the following function:

Maple Code:

(1/4)*(-1/4+alpha*(-1+b)*e^2+((1-b)*alpha+(1/4)*b)*e)^2/((-1+e)^2*(b*e-1)*alpha*e*(-1+b))(1/4)*(-1/4+alpha*(-1+b)*e^2+((1-b)*alpha+(1/4)*b)*e)^2/((-1+e)^2*(b*e-1)*alpha*e*(-1+b))

e is my variable and I want to study it in [0,1[. I have a several parameters restriction like b in [0,1[ and alpha>1.

When I value this function for specific values (b=0.1, alpha=4 for instance) I get the equation and its associated graphic representation:

Maple Code:

-0.6944444445e-1*(-1/4-3.6*e^2+3.625000000*e)^2/((-1+e)^2*(.1*e-1)*e)

 

 

I'm only interested in the domain where e is betweeen 0 and 1. I clearly on the graph see that there is a maximum and when 1) I compute roots of the expression I get 2) following solutions:

1)

2) 

    0.9324708634, 0.07447358108, 0.6965691592, 1.345632810, 

      -0.07419084270.

Here: 0.6965691592 corresponds to the maximum I'm looking for.

So now when I try to get a generalization of this function according to my parameters and when I compute the first derivative with respect to e

1)

 

2) 

3)...

the last is very big so I do not write it here.

To sum-up: I see that the solution I'm looking for exists but when it comes to use parameters I cannot define correct roots.

RootOf has the option index=real[i]  for the i-th real root:

evalf([seq(RootOf(x*(x^2-1)*(x^2-4)+1/100, x, index=real[i]), i=1..5)]);
     [-2.000416306, -0.9983310082, -0.002500019532, 1.001664362, 1.999582971]

This option does not seem to be documented. Why? Or, is it?

 

Hi !

I am importing a matrix from a text file. I am using the command,

ImportMatrix("Filelocation/Filename.txt", 'source' = 'delimited', 'delimiter' = " ");

I see the following error:

Error, (in ImportMatrix) cannot interpret file

I think it is because of the huge size.(700 MB, and 28 GB respectively)

How to import such a matrix in maple?

thanks,

I just found that Maple 17 and Maple 16 do not have the option "output=string" in the latex command.

And I need a way to convert the Latex generated to the screen to a string and save it to a variable like I can do with Maple 2017

Here is an example. In current Maple 2017 this works

result_of_int:=int((-5+3*x)^2/(2*x-1)^(7/2),x):
my_latex:= latex(result_of_int,output=string);

But in Maple 16, it gives an error

If I remove the output, then the result is not string.

How to capture the above output which is on the screen and save it as string in a variable?

I do not want to send the output to a file as is. I need to first convert it to a string, and save
it to variable first.

 

 

how do you answer people's questions on here to get the points?

Hello!

I have a problem with solving of my differential equation second order. Whenever I Try to draw a plot of it I have this "Warning, cannot evaluate the solution past the initial point, problem may be complex, initially singular or improperly set up".

All "A", "B", "C", "K" and Vare constants which can be any number except Vwhich is only a positive number.

 

restart;
v[0] := 500; C[0] := 1; B[0] := 1; K[1] := 1; C[1] := 1; K[2] := 1; C[2] := 1; eqn := x(t) = v[0]*t-C[0]*B[0]*K[1]*C[1]*(D(x))(t)*t^2/(1+C[0]*x(t))^2-C[0]*B[0]*K[2]*C[2]*(C[0]*x(t)*((D@@2)(x))(t)-2*C[0]*(D(x))(t)^2)/(1+C[0]*x(t))^3;
sln := dsolve({eqn, x(0) = 0, (D(x))(0) = 500}, numeric);
plots[odeplot](sln, t = 0 .. 1);

First 921 922 923 924 925 926 927 Last Page 923 of 2433