MaplePrimes Questions

Hi everybody,

I want to compare the performances of a set of codes that realize the same operation.
The worksheet I use is organized this way

restart:
Code1 := proc(...) ... end proc:
CodeTools[Usage](Code1(...))

restart:
Code2 := proc(...) ... end proc:
CodeTools[Usage](Code2(...))

and so on.

It appears that the execution of the whole worksheet doesn't always return the same values for the different indicators, which means that the ranking of the codes can be affected

To obtain more precise indicators I thought do do some statistics.
I then replace each bloc by :

restart:
CodeX := proc(...) ... end proc:  # here X stands for 1, 2, ...
N := "some positive integer"
for n from 1 to N do
   CodeTools[Usage](CodeX(...))
   "catch the values of the indicators"
end do:
"compute some statistics on the samples ot these indicator"

The problem is that Usage doesn't return any values but only does a printf.
I investigated two ways to circumvent this problem:

  1. - redirect the printings to file MyFile by using writeto(MyFile)
    - read MyFile
    - extract the numerical values of the indicators
    - compute the desired statistics
      It works well but it is far from being elegant
     
  2. - insert with(CodeTools) after the restart (within a separate block)
    - copy-paste the output of showstat(Usage) to define a new function, let's say MyUsage
    - insert at the correct place some lines like
             Tcpu := CodeTools:-FormatTime(result:-cputime)  (if my time of interest is the cpu time)
                          (this for all the indicators)
    - insert the line  [..., Tcpu, ...]; before the 'end proc' declaration;
      More elegant but it doesn't work
      I get the error   error (in T) DoUsage is not a command of the CodeTools package


Do you have some idea (beyond the first method above) of the way to catch the performance indicators that Usage computes ?

Thanks in advance


 

Quadratic equation ax^2 + bx + c = 0. Coeff's long and ugly expressions in their own right, but I know that a is nonzero, that there is at least one real solution, and that I want the largest.

So, question: How do I get Maple to return the -b/2a PLUS sqrt((b/2a)^2-c/a) solution?

I am learning patmatch. And found strange problem.

When I make an expression inside a proc A, and pass this expression to another proc B, which then uses patmatch  on it, the pattern fails to match.

but calling proc B directly, with exactly same expression, patmatch does match.

This is confusing and not sure why it happens. It seems related to using symbol which was declared local vs. same symbol but is global. Here is an example

restart;
foo:=proc()
  local x,C1;
  boo(exp(C1+x));
end proc;

boo:=proc(expr)
  local a,b,c,la;
  patmatch(expr,a::anything*exp(b::anything*C1+c::anything),'la');
end proc;

Call to foo() returns false. But call to boo() returns true. Even though I am using same expression.

foo();
   false


C1:='C1':
x:='x':
boo(exp(C1+x));
   true

  

What Am I doing wrong, and how to make it work in both cases?

Not sure if it's the right place to ask this very simple question.

I have solved a DE and got x(t) = _C1*sin(sqrt(k)*t/sqrt(m)). Both _C1 and sqrt(k/m) are constants but I want to use different letters for them. I want _C1 to be renamed A and sqrt(k/m) to be renamed W. Can someone please suggest how I can do this ?

Thanks.

Hello everyone!

I miss a convinient way to build interactive plots with parameters assigned to sliders. E.g. of such expressions as "a*sin(b*x+c)". Before Maple 2017 I could just right-click the expression, choose "plot builder" and then select "interactive plot with three parameters". That's it. Since the introduction of the new interactive plot builder I am at a loss because that way have been lost and I don't know any other way equally quick and convinient. "Interactive plot builder" now means quite another thing!

Any suggestions?

 

 

Hello everyone!

I want to solve a pde and create a matrix. But unfortunately, an error is formed. 

Please, someone help me to remove that error.

Here, I am attaching a mapple file.

pde_solu.mw

Probably I'm doing something severely wrong, but

sum(x^n,n=0..infinity)

does not evaluate to the geometric series result 1/(1-x), why?

Similarly this happens for the sum(x^n/n,n=1..infinity)

 

It works with Maple17 though.

Hi, i want to solve the Ax=b with jacobi method and 4 Iteration, A=Matrix(3, 3, [1, 2, 1, 2, 1, 3, -1, -3, 4]) and b=[8, 13, 5]. 

i want to write a code with for or if or while. tnx

MAPLE will evaluate the 1st integral below, but not the 2nd.  Is it possible to get MAPLE to do the evaluation?  I know it can be done numerically, but what about analytically?

int(sin(Pi*x*n/T), x);

 

int(sin(Pi*x*n/T), x)

int(sin(Pi*x*n/T)*cos(Pi*x*n/T)/(sin(Pi*x/T)*cos(Pi*x/T)), x);

int(sin(Pi*x*n/T)*cos(Pi*x*n/T)/(sin(Pi*x/T)*cos(Pi*x/T)), x)

Hi everyone !!

I have a problem to find a solution for some symbolic nonlinear equations. I used the solve command but it takes much time and finally, I stopped the process because doesn't give me a solution. I have attached the code. 

Please, help me

 

Cond_Poincare.mw


 

I*mu*A(t[2])*omega[0]*(1/2)-A(t[2])*omega[0]*(diff(B(t[2]), t[2]))+I*(diff(A(t[2]), t[2]))*omega[0]-(1/4)*A(t[2])^5*beta[2]*omega[0]^2-(1/4)*A(t[2])^3*beta[1]*omega[0]^2-(1/2)*F[0]*exp(I*sigma*t[2]-I*B(t[2]))+5*alpha[2]*A(t[2])^5*(1/16)+3*alpha[1]*A(t[2])^3*(1/8);

((1/2)*I)*mu*A(t[2])*omega[0]-A(t[2])*omega[0]*(diff(B(t[2]), t[2]))+I*(diff(A(t[2]), t[2]))*omega[0]-(1/4)*A(t[2])^5*beta[2]*omega[0]^2-(1/4)*A(t[2])^3*beta[1]*omega[0]^2-(1/2)*F[0]*exp(I*sigma*t[2]-I*B(t[2]))+(5/16)*alpha[2]*A(t[2])^5+(3/8)*alpha[1]*A(t[2])^3

(1)

simplify(%);

-(1/2)*F[0]*exp(-I*(-sigma*t[2]+B(t[2])))+I*(diff(A(t[2]), t[2]))*omega[0]+(1/2)*(-2*(diff(B(t[2]), t[2]))*omega[0]+(-(1/2)*beta[2]*omega[0]^2+(5/8)*alpha[2])*A(t[2])^4+(-(1/2)*beta[1]*omega[0]^2+(3/4)*alpha[1])*A(t[2])^2+I*mu*omega[0])*A(t[2])

(2)

subs(C(t2)=-sigma*t2+B(t2),%);

-(1/2)*F[0]*exp(-I*(-sigma*t[2]+B(t[2])))+I*(diff(A(t[2]), t[2]))*omega[0]+(1/2)*(-2*(diff(B(t[2]), t[2]))*omega[0]+(-(1/2)*beta[2]*omega[0]^2+(5/8)*alpha[2])*A(t[2])^4+(-(1/2)*beta[1]*omega[0]^2+(3/4)*alpha[1])*A(t[2])^2+I*mu*omega[0])*A(t[2])

(3)

 


Download no_change.mw

I need to use newtons method to solve this in maple if someone can help me i will be very thankfull

help required to find the value of u analytically

Dear friends, i want to solve inequalities as follow:

solve({0 < Q, 0 < delta, 0 < t, 0 < E[0], 0 < lambda[1], 0 < (lambda[1]^2*(Q+2*t+4*delta-4*E[0])+lambda[1]*(Q+2*t+3*delta-7*E[0])-3*E[0])/((lambda[1]^2-6*lambda[1]-6)*t), Q < -(3*delta*lambda[1]+2*t*lambda[1]-4*E[0]*lambda[1]+6*delta-3*E[0])/lambda[1], delta < E[0]*(4*lambda[1]+3)/(3*(lambda[1]+2)), t < -(3*delta*lambda[1]-4*E[0]*lambda[1]+6*delta-3*E[0])/(2*lambda[1]), lambda[1] < 1, (lambda[1]^2*(Q+2*t+4*delta-4*E[0])+lambda[1]*(Q+2*t+3*delta-7*E[0])-3*E[0])/((lambda[1]^2-6*lambda[1]-6)*t) < (lambda[1]*(-2*Q-4*t-2*delta+3*E[0])-lambda[1]^2*delta+lambda[1]^2*E[0]+2*E[0]-2*Q-4*t)/((lambda[1]^2-6*lambda[1]-6)*t) and (lambda[1]*(-2*Q-4*t-2*delta+3*E[0])-lambda[1]^2*delta+lambda[1]^2*E[0]+2*E[0]-2*Q-4*t)/((lambda[1]^2-6*lambda[1]-6)*t) < 1})

But, processing is very heavy and takes too much time! is there any alternative solution?

Thank you in advance.

I am in the process of rewriting a long program so that it invokes procs.  After each proc I write I want to test the proc, so am not interested in any further output.  So in the code I entered `quit` (12);  - which I obtained from the Maple 7 Help documentation.  ...and possibly for good measure:  done;   The system crashed and I had to start again.   I have looked on the MaplePrimes documentation.  There are a couple of posts which treat this as an amusement.  eg

subs(_=sscanf(D,%m)[],proc() _end)();   which I haven't been game to try yet.

  I am curious about the number 12.  In the Maple 7 documentation the output is meant to give some useful information regards bytes used, allocation, & time taken.  Maple 7 documentation says that the number between parentheses should be an nteger in the  range 0..255.  Does varying this number make any difference?

WARNING!  Running the following program could crash your system.  Save any work before trying it.

restart:  `quit` (12);

   I'm curious to know what that does on later versions.  I'm running Maple 7 on Windows 7, so I suspect some incompatibility.

Any comments, advice gratefully received.  David

First 816 817 818 819 820 821 822 Last Page 818 of 2427