sursumCorda

922 Reputation

13 Badges

2 years, 207 days

MaplePrimes Activity


These are questions asked by sursumCorda

After studying the plottools:-transform command, I intend to visualize the following regions with constrained parameters in 
 

(plottools[transform](proc (u, v) options operator, arrow; [u^3-v^2, u^2-v^3] end proc))(plots[inequal](`or`(u^2+4*v^2 <= 4, `and`(u^2+v^2 < 4, 4*v >= (u+2)^2+2*v^2)), nolines))

 

(plottools[transform](proc (s, t) options operator, arrow; [s^2*sqrt(t)*cos(t), s^2*sin(t)] end proc))(plots[inequal](`and`(`and`(s >= 1, 5*s <= 5+t), t < 5), s = 1 .. 2, t = 0 .. 5))

 

 

But Mma gives 

The first instance (with default settings) is the same, but as for the second instance, which graph is correct? 

restart;
with(plottools):
with(plots):
transform((u, v) -> [u^3 - v^2, u^2 - v^3])(inequal(Or(u^2 + 4*v^2 <= 4, And(u^2 + v^2 < 4, (u + 2)^2 + 2*(v - 1)^2 <= 2)), nolines));
transform((s, t) -> [s^2*sqrt(t)*cos(t), s^2*sin(t)])(inequal(`and`(1 <= s, 5*s <= 5 + t, t < 5), s = 1 .. 2, t = 0 .. 5));


Download TransformedRegion.mws

The range is wrong. For details, see below, please.
 

restart;

assume(x, RealRange(0, 1))

plot([sqrt(x*(2 - x)/3), 1 - sqrt((1 - x^2)/3)], legend = InertForm:-Display~([sqrt(x*(2 - x) %/ 3), 1 - sqrt((1 %- x^2) %/ 3)], 'inert' = false));

 

smartplot([sqrt(x*(2 - x)/3), 1 - sqrt((1 - x^2)/3)]);

 

smartplot([''piecewise'(And(0 <= x, x <= 1), sqrt(x*(2 - x)/3))', ''piecewise'(And(0 <= x, x <= 1), 1 - sqrt((1 - x^2)/3))']);

 

smartplot(['piecewise(And(0 <= x, x <= 1), sqrt(x*(2 - x)/3))', 'piecewise(And(0 <= x, x <= 1), 1 - sqrt((1 - x^2)/3))']);

 

smartplot([''piecewise''(And(0 <= x, x <= 1), sqrt(x*(2 - x)/3)), ''piecewise''(And(0 <= x, x <= 1), 1 - sqrt((1 - x^2)/3))]);

 

x := 'x'NULL


 

Download SmartPlots.mw

The help page claims that smartplot(..) will call 2-D plot procedures ultimately, but why is the smartplots command incompatible with the use of assume?

Mathematica's Dimensions returns a list of the allowed levels, which has been implemented in Maple as . But 

MmaTranslator:-Mma:-Dimensions(<<1 | 2>, <1 | 0>>);

returns [6], and 

MmaTranslator:-Mma:-Dimensions([[1, 2], [1, 0]]);

returns [2, 2, 4]. What happened here?

It should be [2, 2].

restart;

MmaTranslator:-Mma:-Dimensions(linalg[matrix]([[1, 2], [1, 0]]));

[0]

(1)

MmaTranslator:-Mma:-Dimensions(< 1 , 2 ; 1 , 0 >);

[6]

(2)

MmaTranslator:-Mma:-Dimensions(convert(`{{1, 2}, {1, 0}}`, FromMma));

[2, 2, 4]

(3)

MmaTranslator:-FromMma(`Dimensions[{{1, 2}, {1, 0}}]`, evaluate);

[2, 2]

(4)

NULL

Download Mma[Dimensions].mws

Execute the following codes in Maple input (1-D math) in the Standard interface. 

(cat("A".."C"),cat("d".."f"))||'$"G".."I",$"j".."l"'; 

Then an error occurred. But if one copy them into 2-D math (instead of Convert To>2-D Math Input) and execute them directly, everything goes without any error messages.

It says that mixed 1-D and 2-D math inside one command is not supported and not recommended stylistically. However, I just want to understand the reason why an error is raised here. 

restart;

kernelopts(version);

`Maple 2022.2, X86 64 WINDOWS, Oct 23 2022, Build ID 1657361`

(1)

interface(version);

`Standard Worksheet Interface, Maple 2022.2, Windows 10, October 23 2022 Build ID 1657361`

(2)

(cat("A".."C"),cat("d".."f"))||'$"G".."I",$"j".."l"';

Error, `||` unexpected

 

cat("A" .. "C"), cat("d" .. "f") || '`$`("G" .. "I"), `$`("j" .. "l")'

"AG", "AH", "AI", "Aj", "Ak", "Al", "BG", "BH", "BI", "Bj", "Bk", "Bl", "CG", "CH", "CI", "Cj", "Ck", "Cl", "dG", "dH", "dI", "dj", "dk", "dl", "eG", "eH", "eI", "ej", "ek", "el", "fG", "fH", "fI", "fj", "fk", "fl"

(3)

NULL

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 0, 1,
0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0]], Matrix): # adjacency

The desired diagram resembles:

The first one comes from Mathematica; the second one comes from MATLAB.
In MMA, we can use GraphLayout -> "LayeredDigraphEmbedding"; in MatLab, we can use Layout = "layered". Note that overlapping edges should be avoided in a layered plot.

Currently, since the vertices of a 2-D graph can be manually positioned, we can click, drag and place them to embed vertices, route edges, and then get a hierarchical structure as follows:

However, it's just a clumsy and fiddly job. Isn't there a fully automatic and less time-consuming method to do so in Maple?

First 16 17 18 19 Page 18 of 19