acer

32303 Reputation

29 Badges

19 years, 307 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

You could do,

   (u->FileTools:-ListDirectory(currentdir(),'all',select=u)[])~(["*.dvi","*.pdf"])

or,

   (u->FileTools:-ListDirectory(currentdir(),'all',select=u)[])~(L)

where L is your list of strings with wildcards.


ps. You don't need to right-quote the global name select, which is protected. If you're operating within a proc with a local by that name then use :-select. The usual story.

pps. I half expected to see something like select=".*\\.(dvi|pdf)$" work, as there is mention in the ListDirectory help-page of StringTools and its WildcardMatch, which in turn mentions RegMatch. This not so nice,
     select[2](StringTools:-RegMatch,".*\\.(dvi|pdf)$",FileTools:-ListDirectory("."))
and it's also more work to build up the pattern if there are many allowed extensions.

Your Question doesn't mention whether you mean the limits for the Java GUI, or for the kernel/engine (mservers) that do the computations. They have separate settings and options to control them.

See the Maple launch script options, and/or kernelopts Help page.

That launch script Help page unfortunately lacks mention of its -j option, for the Java GUI, which Rouben has mentioned. See also the kernelopts choices limitjvmheap and jvmheaplimit.

The launch script's -T option allows for specifying limits for the kernel/engine. See also the kernelopts choices datalimit and stacklimit.

You can also call simplify after calling solve. You could do each separately (with the assumptions), or nest the calls.

The empty brackets [] means that there is no solution for that case.

Also, you don't need to do the term cancellation stuff you asked about, to solve the inequality for Cv.

restart

kernelopts(version)

`Maple 2019.2, X86 64 LINUX, Nov 26 2019, Build ID 1435526`

ineq := -d*(Am-s1)/(2*Clm)-d*(Am*R0er*d^2-R0er*d^2*s1+Aer*Clm-Ce*Clm+Clm*Rer-Clm*l)/(2*Clm*(-R0er*d^2+Clr)) <= -d*(Am-Cv+Rm-s1-s2)/(-2*R0m*d^2+2*d^2*g1+2*Clm)-d*(Rer-Ce-l+Aer)/(-2*R0er*d^2+2*Clr)

ans1 := `assuming`([simplify(solve(ineq, Cv))], [d > 0, Am > 0, R0er > 0, Clm > 0, s1 > 0, Ce > 0, s2 > 0, Clr > 0, l > 0, g1 > 0, Aer > 0, Rer > 0])

piecewise(0 < -d/((2*R0m-2*g1)*d^2-2*Clm), [{((R0er*(Am+Rm-s1-s2)*Clm-Clr*(R0m-g1)*(Am-s1))*d^2-Clm*Clr*(Rm-s2))/((R0er*d^2-Clr)*Clm) <= Cv}], -d/((2*R0m-2*g1)*d^2-2*Clm) < 0, [{Cv <= ((R0er*(Am+Rm-s1-s2)*Clm-Clr*(R0m-g1)*(Am-s1))*d^2-Clm*Clr*(Rm-s2))/((R0er*d^2-Clr)*Clm)}], [])

Download Q_12_ac.mw

Why do you have a condition on g2?

If you wanted, you could also replace the final conditions in the piecewise answer. Eg, you could replace them after solving them for R0m. Eg,

`assuming`([expand(solve(0 < -d/((2*R0m-2*g1)*d^2-2*Clm), R0m))[]], [d > 0])

R0m < g1+Clm/d^2


Also, the name Ce only appears in an identical amount (ie, with the exact same coefficient, if collected) on both sides of your given inequality. So the given inequality doesn't provide any stipulation or restriction on Ce. Hence, trying to solve the inequality for Ce won't tell you anything about Ce.

@vv I can't see your response at the moment. But I notice that the following seem equal:

LinearAlgebra:-CharacteristicPolynomial(A,x);
evala(expand(mul(x-rr,rr=evstheory)));

It seems to me that the primary issue here is obtaining the maximum for (only piecewise continuous) Mprof for arbitray tau0 values in your range.

The next issues seem to be doing so reasonably efficiently. And then producing nice individual plots woul be next. And then showing the multiple plots that happen to be on quite different scales would be next.

And mixed in there is the issue of whether delta is always equal to 1 at the optima. I'm deliberately not going to simplify to the methodology for such a case, since you may want to modify your formula/conditions so that no longer holds.

In comparison to all that, merely combining multiple plots or array data seems straightfoward in comparison.

Here are some ideas. I've used Maple 2019, as you did. One of the variants uses 3rd party add-on DirectSearch as fallback.

trial_question_acc.mw

And here's an Mprof plot.

@salim-barzani You need to use the appropriate Maple commands to get your plots.

Here are some examples. You could read the Help Pages for those commands, to adjust the coloring, etc.

You could even provide an actual explanation (in words) of what precisely you want, in terms of color, shading, etc.

graph-density-countour_ac.mw

That produces,

Here are some ways, to get you started.

Input_question_ac.mw

times := [-2.019619977*Unit('s'), 2.019619977*Unit('s'),
          17.019619977*Unit('s'), -11.019619977*Unit('s')];

[-2.019619977*Units:-Unit(s), 2.019619977*Units:-Unit(s), 17.019619977*Units:-Unit(s), -11.019619977*Units:-Unit(s)]

select(u->convert(u,unit_free)>0, times);

[2.019619977*Units:-Unit(s), 17.019619977*Units:-Unit(s)]

%[];

2.019619977*Units:-Unit(s), 17.019619977*Units:-Unit(s)

Download units_select.mw

number := 1;
Var2 := "b";

1

"b"

Using %s to denote a string for the second replacement.
I'd guess that this is like your goal here.

sprintf("file(%a)_%s",number,Var2);

"file(1)_b"

lprint(%);

file(1)_b

Using %a to denote a general algebraic quantity for the
second replacement.

This places the string value of Var2 literally inside the
result string (including the quotes, escaped). This might
not be what you want here.

sprintf("file(%a)_%a",number,Var2);

"file(1)_"b""

lprint(%);

file(1)_\"b\"


Download sprintf_1.mw

As worded, your query seems to be about the sprintf command, and the construction of the filename string to be assigned to fname by using multiple assigned names, rather than about the save command.

See also the Help page for sprintf, for explanation of the modifiers %a, %s, etc. (Apart from its ability to handle symbolic expressions, that Maple command is much like the C language command of the same name. You can find similar commands in C++, R, Matlab, etc.)

However, if you ever do have multiple assigned names (eg. A,C,F) that you wish to save to the .m file then you could pass them as follows,

   save A,C,F fname;

Is this along the lines of what you're trying to accomplish?

restart;

`&cong;`(a,b)

`&cong;`(a, b)

alias(`&cong;` = `union`);

`&cong;`

a union b;

`&cong;`(a, b)

Download congruence_symbol.mw

For the subscripts in italics,

   labels = [':-delta__0', ':-s__2']

For the subscripts in upright roman,

   labels = [':-delta[0]', ':-s[2]']

Those should both work even if those names are assigned values (before, or afterwards), and even if this code appears in a procedure with locals like those names.

Another (longer) way, with both base-name and subscript in upright roman,

   labels = [Typesetting:-msub(Typesetting:-mn("&delta;"),Typesetting:-mn("0")),
                  Typesetting:-msub(Typesetting:-mn("s"),Typesetting:-mn("2"))]

restart;


2D example

Env := x=0.8..3, y=0..1.3;

x = .8 .. 3, y = 0 .. 1.3


Note the `and` instead of And.

Dom := proc (x, y) options operator, arrow; `and`(y <= 1/(1+sinh(2*x)*ln(x)^2), .8 <= x, x <= 3, 0 <= y) end proc

proc (x, y) options operator, arrow; `and`(y <= 1/(1+sinh(2*x)*ln(x)^2), .8 <= x, x <= 3, 0 <= y) end proc


I see no issue (as yet) with having CharFunc return the piecewise,
for nunnumeric x and y. Doing it this way (or just using a piecewise
expression) is actually what I mean by a "bare piecewise".

CharFunc := unapply(piecewise(Dom(x, y), 1, 0),x,y);

CharFunc := proc (x, y) options operator, arrow; piecewise(y <= 1/(1+sinh(2*x)*ln(x)^2) and .8 <= x and x <= 3 and 0 <= y, 1, 0) end proc

CharFunc(x, y);

piecewise(`and`(`and`(`and`(y <= 1/(1+sinh(2*x)*ln(x)^2), .8 <= x), x <= 3), 0 <= y), 1, 0)

plot3d(
  [0, CharFunc(x, y)], Env
  , grid=[40, 40]
  , style=surface, color=[gray, blue], transparency=[0, 0]
  , title=typeset('CharFunc'(x, y))
);


I don't see the need to wrap it in a black-box, that might
return unevaluated for nonnumeric x and y.

CharFunc(x, y);

piecewise(`and`(`and`(`and`(y <= 1/(1+sinh(2*x)*ln(x)^2), .8 <= x), x <= 3), 0 <= y), 1, 0)


By using `and` instead of And in the piecewise, the piecewise is evalhf'able.

evalhf(CharFunc(1.0, 0.3));

1.


So we have something to compare against.

evalf[20](Int(1/(1+sinh(2*x)*ln(x)^2),x=0.8..3));

.67684007571564628609


The question now might be, which results do you trust...

CodeTools:-Usage(
  evalf(Int(CharFunc(x, y), Env, method=_MonteCarlo, epsilon=1e-4))
);

memory used=0.82MiB, alloc change=0 bytes, cpu time=10.00ms, real time=10.00ms, gc time=0ns

.7150000000

CodeTools:-Usage(
  evalf(Int(CharFunc(x, y), Env, method=_CubaDivonne, epsilon=1e-5))
);

memory used=8.45MiB, alloc change=0 bytes, cpu time=380.00ms, real time=380.00ms, gc time=0ns

HFloat(0.6768336654696097)

CodeTools:-Usage(
  evalf(Int(CharFunc(x, y), Env, method=_CubaVegas, epsilon=1e-3))
);

memory used=145.82KiB, alloc change=0 bytes, cpu time=358.00ms, real time=359.00ms, gc time=0ns

HFloat(0.6768739604529882)

CodeTools:-Usage(
  evalf(Int(CharFunc(x, y), Env, method=_CubaSuave, epsilon=1e-5))
);

memory used=145.49KiB, alloc change=0 bytes, cpu time=2.08s, real time=2.08s, gc time=0ns

HFloat(0.6740073134054702)

CodeTools:-Usage(
  evalf(Int(CharFunc(x, y), Env, method=_CubaSuave, epsilon=1e-5))
);

memory used=15.92KiB, alloc change=0 bytes, cpu time=1000.00us, real time=1000.00us, gc time=0ns

HFloat(0.6740073134054702)

 

 

Download Integration_issue_ac.mw

Do you mean this video, available on youtube? (There is also a static PDF document of that.)

One other simple way to handle this example, aside from just the previously mentioned convert(x in solve(sl10),relation), is,

sl10 := -1 <= (3-5*x)*(1/2) and (3-5*x)*(1/2) <= 9

`and`(op(solve(sl10, {x})))

-3 <= x and x <= 1

Download Combined_Inequality_ac.mw


This new example can also be handled with the procedure I gave you last week (capable of handling some more involved compound examples), ie.,

restart;

G := proc(R)
   (u->ifelse(nops(u)>1,%or(op(u)),op(u)))(
      map(u->ifelse(u::{set,list} and nops(u)>1,
                    `%and`(op(u)),op(u)),
          [solve(subsindets(convert(R,relation),
                            And({`<`,`<=`},satisfies(u->has(u,infinity))),
                            ()->NULL),{x})]));
end proc:

 

sl10 := -1 <= (3-5*x)*(1/2) and (3-5*x)*(1/2) <= 9

G(sl10)

%and(-3 <= x, x <= 1)

Download some_2D_range_ineq_2.mw


note: The call solve(sl10) returns RealRange(-3,1), and your Question from last week was just about turning such closed set forms into inequalities. So, this really is almost the same Question.

In future please add such close followup queries as Replies/Comments in your earlier Question thread (or at least use the Branch button from there to create a related/linked new Question), instead of spawning a wholly separate new Question thread.

Both the commands to generate the teams, and the commands to printf the teams, can be done as simple one-liners.

The number of members of a team (or that minus 1) only appears once in each of those one-liners.

restart;

new_team := ["Michael K", "Andy C", "Michael G", "Mitch", "Jez", "Dean B", "Anthony B", "Rik B", "Ilya", "Fariborz", "Eugene", "Tania", "Bill", "Stevs", "Victor", "Jane", "Nash", "Ben"]:

sets := [ListTools:-LengthSplit(new_team,2)];

[["Michael K", "Andy C"], ["Michael G", "Mitch"], ["Jez", "Dean B"], ["Anthony B", "Rik B"], ["Ilya", "Fariborz"], ["Eugene", "Tania"], ["Bill", "Stevs"], ["Victor", "Jane"], ["Nash", "Ben"]]

seq(printf(cat("set %a:"," %s,"$1," %s\n"),i,sets[i][]),i=1..nops(sets));

set 1: Michael K, Andy C
set 2: Michael G, Mitch
set 3: Jez, Dean B
set 4: Anthony B, Rik B
set 5: Ilya, Fariborz
set 6: Eugene, Tania
set 7: Bill, Stevs
set 8: Victor, Jane
set 9: Nash, Ben

new_team := ["Michael K", "Andy C", "Michael G", "Mitch", "Jez", "Dean B", "Anthony B", "Rik B", "Ilya", "Fariborz", "Eugene", "Tania", "Bill", "Stevs", "Victor", "Jane", "Nash", "Ben", "Malachi T", "R", "Sachin ", "Prakash Sn", "Graeme", "Nayu", "Martih", "Rickn", "Ahmed"]:

sets := [ListTools:-LengthSplit(new_team,3)];

[["Michael K", "Andy C", "Michael G"], ["Mitch", "Jez", "Dean B"], ["Anthony B", "Rik B", "Ilya"], ["Fariborz", "Eugene", "Tania"], ["Bill", "Stevs", "Victor"], ["Jane", "Nash", "Ben"], ["Malachi T", "R", "Sachin "], ["Prakash Sn", "Graeme", "Nayu"], ["Martih", "Rickn", "Ahmed"]]

seq(printf(cat("set %a:"," %s,"$2," %s\n"),i,sets[i][]),i=1..nops(sets));

 

set 1: Michael K, Andy C, Michael G
set 2: Mitch, Jez, Dean B
set 3: Anthony B, Rik B, Ilya
set 4: Fariborz, Eugene, Tania
set 5: Bill, Stevs, Victor
set 6: Jane, Nash, Ben
set 7: Malachi T, R, Sachin
set 8: Prakash Sn, Graeme, Nayu
set 9: Martih, Rickn, Ahmed


Download teams_ac.mw


If you wanted a reusable procedure that did both the construction and the printf,

restart;

G := proc(L,n)
  local sets:=[ListTools:-LengthSplit(L,n)];
  seq(printf(cat("set %a:"," %s,"$(n-1)," %s\n"),
             i,sets[i][]),i=1..nops(sets));
  sets;
end proc:


new_team := ["Michael K", "Andy C", "Michael G", "Mitch", "Jez", "Dean B", "Anthony B", "Rik B", "Ilya", "Fariborz", "Eugene", "Tania", "Bill", "Stevs", "Victor", "Jane", "Nash", "Ben"]:

sets := G(new_team, 2);

set 1: Michael K, Andy C
set 2: Michael G, Mitch
set 3: Jez, Dean B
set 4: Anthony B, Rik B
set 5: Ilya, Fariborz
set 6: Eugene, Tania
set 7: Bill, Stevs
set 8: Victor, Jane
set 9: Nash, Ben

[["Michael K", "Andy C"], ["Michael G", "Mitch"], ["Jez", "Dean B"], ["Anthony B", "Rik B"], ["Ilya", "Fariborz"], ["Eugene", "Tania"], ["Bill", "Stevs"], ["Victor", "Jane"], ["Nash", "Ben"]]


new_team := ["Michael K", "Andy C", "Michael G", "Mitch", "Jez", "Dean B", "Anthony B", "Rik B", "Ilya", "Fariborz", "Eugene", "Tania", "Bill", "Stevs", "Victor", "Jane", "Nash", "Ben", "Malachi T", "R", "Sachin ", "Prakash Sn", "Graeme", "Nayu", "Martih", "Rickn", "Ahmed"]:

sets := G(new_team, 3);

set 1: Michael K, Andy C, Michael G
set 2: Mitch, Jez, Dean B
set 3: Anthony B, Rik B, Ilya
set 4: Fariborz, Eugene, Tania
set 5: Bill, Stevs, Victor
set 6: Jane, Nash, Ben
set 7: Malachi T, R, Sachin
set 8: Prakash Sn, Graeme, Nayu
set 9: Martih, Rickn, Ahmed

[["Michael K", "Andy C", "Michael G"], ["Mitch", "Jez", "Dean B"], ["Anthony B", "Rik B", "Ilya"], ["Fariborz", "Eugene", "Tania"], ["Bill", "Stevs", "Victor"], ["Jane", "Nash", "Ben"], ["Malachi T", "R", "Sachin "], ["Prakash Sn", "Graeme", "Nayu"], ["Martih", "Rickn", "Ahmed"]]


Download teams_ac2.mw

First 8 9 10 11 12 13 14 Last Page 10 of 336