13340 Reputation

29 Badges

11 years, 271 days

On google groups. (comp.soft-sys.math.maple and sci.math.symbolic)

On stackoverflow.


MaplePrimes Activity

These are answers submitted by acer

Try the command `timelimit` which can wrap around another procedure call.

The `timelimit` command is intended for exactly the kind of situation you describe.

You can use the try...catch mechanism to control this flow.

When `timelimit` times out it emits an error, and your code can catch that, and proceed.

The command LinearAlgebra:-GenerateMatrix should be able to do that.

It's awkward to do, and not general, but... you can alter the Typesetting so that the exponent is smaller.

Making this more precise, say to affect only powers within sqrts, would be more involved.

Using labelfont=[...,bold,N] might make the two sizes appear more similar in weight.


N := 24:

plot(cos(1/theta)/sqrt(1-theta^2), theta=0.2 .. 0.99,
     labels = ['theta', typeset(cos," (","1/",theta,") / ",


plot(cos(1/theta)/sqrt(1-theta^2), theta=0.2 .. 0.99,
     labels = ['theta', typeset(cos," (","1/",theta,") / ",K)],

Did you intend something more like,

F53 := eval(u(y), sol)


Also, assigning to `u` just makes it more difficult to re-use `sol`.

I find the whole approach to be unnecessarily cryptic.

Why not use the -c option of cmaple, to assign the filename string (and read MyCode too if you want).

Then you just need Eclipse to form the full call to cmaple.

To get the dot notation for the derivatives you can issue this command at the top of the Document.

Typesetting:-Settings(typesetdot=true, usedot=true, dot=t):

If you didn't need the derivatives to be pretty-printed in dot notation then you could simply set the typesetting level to standard. Getting the formatting effect you describe, without setting typesetting to standard, requires fooling the system into not recognizing that common 1/2 factor as being a rational number. There are a few ways to do that, some fancier than others. See this attachment .

As far as grouping with respect to particular variable names goes, see the collect command.

These should also produce a plot as shown in Adri's answer:

S:=proc(u,v) 10*u^2+20*u*v+15; end proc:
p:=proc(u,v) if u<v then S(u,v); else S(u,v)+10; end if; end proc:
h:=proc(u) 2*u; end proc:
plot3d([(u,v)->40*u,(u,v)->80*v,p], 0..1, 0..h);

plot3d([40*u,80*v,piecewise(u<v,ee,ee+10)], u=0..1, v=0..2*u);

S:=proc(u,v) 10*u^2+20*u*v+15; end proc:
    if not ( u::numeric and v::numeric ) then
      return 'procname'(args);
    end if;
    if u<v then
    end if;
end proc:
plot3d([40*u,80*v,p(u,v)], u=0..1, v=0..2*u);

Apply the procedure to some name(s).

Maple is telling you, correctly, that it cannot cast an unassigned name to a hardware double-precision floating-point number.

And your command instructs Maple to convert every element of K to a double-precision float.

Do you think that the name actually has a value which should evaluate to a float?

Is there some possibility that there are two similar names in play (perhaps a copy and paste mismatch of atomic identifiers)? It's hard to be more specific if you don't bother to upload a worksheet that exhibits the problem.

I'm not really content with having to break up the original condition, let alone the speed, but...


   Maple 2017.0, X86 64 LINUX, May 17 2017, Build ID 1231047

         { evalc(abs(a+b*I+3-2*I))^2 =(K1)^2,
           evalc(abs(a+b*I-3-8*I))^2 = (K2)^2,
           K1>=0, K2>=0, (K1+K2)^2=(6*sqrt(2))^2},
           {K1,K2} ) ):
memory used=47.74GiB, alloc change=1.12GiB, cpu time=8.79m, real time=5.81m, gc time=4.39m


       bettersol := {a = b - 5, 2 <= b, b <= 8}


                            2    2 1/2
            expr := ((b - 5)  + b )


                   brng := 2 .. 8

simplify( [ minimize( expr, b=brng, location) ] ):
op(1,%), op([2,1,1,..],%), eval(op(1,bettersol), op([2,1,1],%));

             5 2
            ------, b = 5/2, a = -5/2

simplify( [ maximize( expr, b=brng, location) ] ):
op(1,%), op([2,1,1,..],%), eval(op(1,bettersol), op([2,1,1],%));

               73   , b = 8, a = 3

Use procedures as much as possible. Have the procedures be exports of a module. Keep all the procedures' sources (including those for all module members, whether locals or exports) in individual plaintext files, and keep the module's source in another text file. Use the $include directive to reference the module-members' sources from within that of the parent module.

That way all our procedures are defined in separate plaintext files, and they can all be used with full revision control. (Over the last 20 years I have used at least 4 different revision control systems on large Maple projects, with all the source in text files. Mostly unix/linux/cygwin. )

Next, write a short bit of code that uses the Maple `read` command, which pulls in and interprets all the above (e.g. read the master module defn file). This can build everything in a few lines. Optionally a separate short command can savelib the modules to ".mla" Library archive.

If you like you can make regular use of the $define directive at each text file's head, to specify common keywords. I do this to keep all references to other, stock package exports (e.g. LinearAlgebra) terse. You can even put such stuff in "include files".  

I keep module defns in text files with extension ".mpl", and module members (local or exported procedures or submodules) in text files with extension ".mm", and other included common stuff in files ".mi".

Of course, all the files then have their own revision histories.

All the above makes my Maple project development scheme match that of my C/C##/etc projects, at least as far as "action code" goes.

You wrote "application". Does that mean an assembly of interactive components? For that kind of application I now generate the full worksheet and its components programatically, using text files there too. So my project's graphical interface bits are revision controlled just like my project's engine bits.

For this example,


SS:=simplify(SS) assuming a>1:






S < arctan((1/2)*(-2*a+1+(4*a^2+4*a-3)^(1/2))*2^(1/2)/((2*a-1)^(1/2)*((4*a^2+4*a-3)^(1/2)+2*a-3)^(1/2))), 1 < a, -(1/2)*Pi < S, S < arctan((1/2)*(5^(1/2)-1)^(1/2)*2^(1/2))



                           {22/5, 28/5}

        {a,b}, 's');

                           {22/5, 28/5}


               {{a = -22/5, b = 0}, {a = 28/5, b = 0}}
On stackexchange you seem to have come up with abs(z)=sqrt(591/17). So what point z (with that modulus) satisfies the additional constraint?

There's likely an easier way... (especially to obtain gg from ff).






           u->simplify((Re+Im*I)(u))) assuming t::real;




It's not completely clear to me why (a/b)^p is wanted but not (w__2/w__1)^p.

And it's not clear to me whether the order of the multiplicands in the desired target form will matter.

Also, I might elect for a mechanism that did not rely on the happenstance position of any of the multiplicands, at any intermediate stage.

So below are two more ways to follow up Kitonum's Answer's first stage, which focus deliberately on a/b. For this example it's not necessary to assume y>0 so I wrote out all the other assumptions for that first stage, despite it being longer code. (You might know that you can assume all positive, however.) The second way makes extra effort, just to ensure that the (a/b)^p term appears at left, as the first multiplicand in the final form.


x__1 := y^(1/(a+b))/(w__1*b/(a*w__2))^(b/(a+b)):
B := combine(expand(x__1)) assuming a>0, b>0, w__1>0, w__2>0:

map(normal,eval(simplify(eval(B,a=Q*b)),Q=a/b)) assuming a>=0, b>=0;



x__1 := y^(1/(a+b))/(w__1*b/(a*w__2))^(b/(a+b)):
B := combine(expand(x__1)) assuming a>0, b>0, w__1>0, w__2>0:

`*`(op(normal(eval(simplify(eval(%,a=Q*b)),Q=a/b)))) assuming a>=0, b>=0;




1 2 3 4 5 6 7 Last Page 1 of 140