## 13340 Reputation

11 years, 271 days

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

On stackoverflow.

On math.stackexchange.com.

## timelimit...

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.

## GenerateMatrix...

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

## something...

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.

 > restart;
 > N := 24:
 > plot(cos(1/theta)/sqrt(1-theta^2), theta=0.2 .. 0.99,      size=[700,400],      labels = ['theta', typeset(cos," (","1/",theta,") / ",                sqrt(sort(1-theta^2,theta,ascending)))],      labelfont=[Times,N],labeldirections=[horizontal,vertical]);

 > K:=eval('Typesetting:-Typeset'(sqrt(sort(1-theta^2,theta,ascending)))): K:=subsindets(   subsindets(K,specfunc({Typesetting:-mn,                          Typesetting:-mo,Typesetting:-mi}),   uu->op(0,uu)(op(uu),size=sprintf("%d",N))),   specfunc(Typesetting:-msup),              u->op(0,u)(op([1,0],u)(op([1,..],u),size=sprintf("%d",N)),                         op([2,0],u)(op([2,..],u),size=sprintf("%d",ceil(0.5*N))))   ):
 > plot(cos(1/theta)/sqrt(1-theta^2), theta=0.2 .. 0.99,      size=[700,400],      labels = ['theta', typeset(cos," (","1/",theta,") / ",K)],      labelfont=[Times,N],      labeldirections=[horizontal,vertical]);

 >

## F53...

Did you intend something more like,

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

?

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

BVP_1.mw

I find the whole approach to be unnecessarily cryptic.

## -c option to cmaple...

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.

## Typesetting:-Settings...

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 formatting.mw .

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

## a few more...

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

```restart;
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);

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

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

## apply it to a name...

Apply the procedure to some name(s).

## datatype=float[8]...

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.

## something...

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

```kernelopts(version);

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

sol:=CodeTools:-Usage(
SolveTools:-SemiAlgebraic(
{ 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

sollist:=PiecewiseTools:-ToList(sol):
bettersol:=solve(Or(seq(sollist[i,1],i=1..nops(sollist)-1)));

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

expr:=eval(evalc(abs(a+b*I)),op(1,bettersol));

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

brng:=`..`(op([2,..],convert(And(op(2..3,bettersol)),RealRange)));

brng := 2 .. 8

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

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

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

1/2
73   , b = 8, a = 3```

## source in text files...

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.

## another way...

For this example,

 > restart;
 > SS:=eval(S,isolate(((2*a*sin(S)*cos(S)^(2)))/(1-sin(S)^(3))=1,S)): SS:=simplify(SS) assuming a>1:
 > shi:=eval(SS,a=1):
 > conds:=[S1,S>-Pi/2]:
 > plots:-inequal(conds,S=-Pi/2..shi,a=1..10,xtickmarks=piticks);

 > op(conds),S

trigsol.mw

## extrema...

```z:=a+b*I:

extrema(evalc(abs(z)),evalc({abs(z+1)+4*abs(z-1)=25}),
{a,b});

{22/5, 28/5}

extrema(evalc(abs(z)),evalc({abs(z+1)+4*abs(z-1)=25}),
{a,b}, 's');

{22/5, 28/5}

s;

{{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?

## something...

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

 > ee:=int((0.0064-0.06851*I)/(0.0402+0.0868*I)         *exp((-0.9696+0.7611*I)              /(0.0402+0.0868*I)*(t-tau)),tau=0..t):
 > ff:=simplify(ee);

 > gg:=subsindets(       eval(simplify(              subsindets(ff,'complex(float)',                         u->``(csgn(u))                            *convert(u/csgn(u),polar))),            ``=(u->u)),       'specfunc(anything,polar)',       evalc);

 > subsindets(gg,            'specfunc(anything,exp)',            u->simplify((Re+Im*I)(u))) assuming t::real;

 >

## focus on a/b rather than position...

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.

 > restart;
 > 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;

 > restart;
 > 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(`*`@op,[selectremove(type,[op(B)],identical(a,b)^anything)]): `*`(op(normal(eval(simplify(eval(%,a=Q*b)),Q=a/b)))) assuming a>=0, b>=0;

 >