acer

32343 Reputation

29 Badges

19 years, 328 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

Look at the entries in PDE5 and PDE[5], instead of suppressing everything with full colons. The equations you're passing to fsolve contain scalar expressions added to rtables.

@FrancescoLR Could you upload a full example, including the missing data (T_O_I, D_vol, N, p_gamma, and other...)? It's pretty difficult to deal with the procedures without it, and it's not reasonable to expect people to cook up their own.

It could be a smaller subset of your full data, but it'd help if it were large enough that successful parallelism could show at least some measurable timing improvement.

Even better would be a variant that did the code-generation and export sequentially, successfully.

@minhhieuh2003 Why don't you get the free upgrade from Maple 2016.0 to Maple 2016.2?

Please use 1D plaintext input in a Worksheet for code you'd like me to edit/adjust in future.

restart;

NULL

NULL

multiple := module() option package;
  export dsds1d_s;
  local TSprintf;

  TSprintf := proc()
    uses Typesetting;
      mrow(seq(`if`(e::string, mn(e), Typeset(EV(e))), e = [args]));
  end proc:

  dsds1d_s := proc(rtc)
    global R1, R;
    local r, topic, tudo, num, dsd, dsss1, dsss2, dsss3;
    uses Typesetting;
    tudo := [1, -233243, sqrt(23+x), ('int')(2*x^2+35*x+4, x)];
    num := rand(1 .. nops(tudo())); dsd := tudo[num()];
    dsss1 := tudo[num()]; dsss2 := tudo[num()]; dsss3 := tudo[num()];
    for r to rtc do
      topic[r] := TSprintf(ex, " ", r, ". SomeLongSentence ", r);
      R[r] := mtr(mtd(topic[r], ':-columnspan'=4),
                  ':-columnalign' = ':-left'),
              mtr(mtd(mrow(mtext("A", mathcolor = `#ff0000`),
                           mtext(". "), TSprintf(dsd))),
                  mtd(mrow(mtext("   B"), mtext(". "), TSprintf(dsss1))),
                  mtd(mrow(mtext("   C"), mtext(". "), TSprintf(dsss2))),
                  mtd(mrow(mtext("   D"), mtext(". "), TSprintf(dsss3))),
                  ':-columnalign' = ':-left');
    end do;
    mtable(seq(op([R[r], mtr()$3]), r = 1 .. rtc));
  end proc;

end module:

 

with(multiple);

[dsds1d_s]

dsds1d_s(3);

"[[ex 1. SomeLongSentence 1],["A"". "1,"   B"". "sqrt(23+x),"   C"". "sqrt(23+x),"   D"". "-233243],[],[],[],[ex 2. SomeLongSentence 2],["A"". "1,"   B"". "sqrt(23+x),"   C"". "sqrt(23+x),"   D"". "-233243],[],[],[],[ex 3. SomeLongSentence 3],["A"". "1,"   B"". "sqrt(23+x),"   C"". "sqrt(23+x),"   D"". "-233243],[],[],[]]"

 

Download goi_maple_ac.mw

@minhhieuh2003 I have a hard time understanding you, since you don't state your question with full sentences. So I have to guess.

I am guessing that you are asking how to generate a representation, from a given expression, which displays in typeset 2D Output form.  So look at how foo1, foo2, foo3, and foo4 are displayed below.

I only used a forced mtext above, because you were asking about numbers and simple text. You can get representations for other expressions using Typesetting commands (as you did originally in your own code) or InertForm commands.

restart;

expr1 := 2^(1/2);

2^(1/2)

foo1 := Typesetting:-Typeset(Typesetting:-EV( expr1 ));

Typesetting:-msqrt(Typesetting:-mn("2"))

lprint(foo1);

Typesetting:-msqrt(Typesetting:-mn("2"))

 

expr2 := 'int'(2*x+4, x);

int(2*x+4, x)

foo2 := Typesetting:-Typeset(Typesetting:-EV( expr2 ));

Typesetting:-mrow(Typesetting:-mo("∫"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⁢"), Typesetting:-mi("x")), Typesetting:-mo("+"), Typesetting:-mn("4"))), Typesetting:-mspace(width = "0.3em"), Typesetting:-mo("ⅆ"), Typesetting:-mi("x"))

lprint(foo2);

Typesetting:-mrow(Typesetting:-mo("∫"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⁢"), Typesetting:-mi("x")), Typesetting:-mo("+"), Typesetting:-mn("4"))), Typesetting:-mspace(width = "0.3em"), Typesetting:-mo("ⅆ"), Typesetting:-mi("x"))

 

expr3 := 'sqrt'(2);

sqrt(2)

temp3 := InertForm:-MakeInert( eval(expr3, 1) );

%sqrt(2)

foo3 := InertForm:-Display( temp3, inert=false );

Typesetting:-mcomplete(Typesetting:-msqrt(Typesetting:-mrow(Typesetting:-mn("2"))), Typesetting:-_Hold([%sqrt(2)]))

lprint(foo3);

Typesetting:-mcomplete(Typesetting:-msqrt(Typesetting:-mrow(Typesetting:-mn("2"))), Typesetting:-_Hold([%sqrt(2)]))

expr4 := 'int'(2*x+4, x);

int(2*x+4, x)

temp4 := InertForm:-MakeInert( eval(expr4, 1) );

%int(`%+`(`%*`(2, x), 4), x)

foo4 := InertForm:-Display( temp4, inert=false );

Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mstyle(Typesetting:-mo("∫", Typesetting:-msemantics = "inert")), Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⋅"), Typesetting:-mi("x")), Typesetting:-_Hold([`%*`(2, x)])), Typesetting:-mo("+"), Typesetting:-mn("4")), Typesetting:-_Hold([`%+`(`%*`(2, x), 4)]))), Typesetting:-mspace(width = "0.3em"), Typesetting:-mstyle(Typesetting:-mo("ⅆ", Typesetting:-msemantics = "inert")), Typesetting:-mi("x")), Typesetting:-_Hold([%int(`%+`(`%*`(2, x), 4), x)]))

lprint(foo4);

Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mstyle(Typesetting:-mo("∫", Typesetting:-msemantics = "inert")), Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⋅"), Typesetting:-mi("x")), Typesetting:-_Hold([`%*`(2, x)])), Typesetting:-mo("+"), Typesetting:-mn("4")), Typesetting:-_Hold([`%+`(`%*`(2, x), 4)]))), Typesetting:-mspace(width = "0.3em"), Typesetting:-mstyle(Typesetting:-mo("ⅆ", Typesetting:-msemantics = "inert")), Typesetting:-mi("x")), Typesetting:-_Hold([%int(`%+`(`%*`(2, x), 4), x)]))

 

Download TS_fun.mw

You seem to be interested in laying out text and expressions in a particular format. Have you considered using the DocumentTools:-Tabulate command? Or, if that is not flexible enough for you, the commands from the DocumentTools:-Layout package? Unlike these Typesetting commands, those have Help pages. It's just an idea...

@shimaa sadk This one works for me.

restart

kernelopts(version);

`Maple 18.02, X86 64 LINUX, Oct 20 2014, Build ID 991181`

`λ1_N`[so] := 0.733e-3:

igrand := (Z^(`λ2_N`[so]/`λ1_N`[so]))^2*ln(Z)^2/((Z-1+`α_N`[so])^2*(Z^(`λ2_N`[so]/`λ1_N`[so])-1+`α_N`[so])^3):

evalf(Int(1/expand(1/igrand), Z = 1 .. infinity));

0.1114691036e-12

NULL

NULL

Download ask_new.mw

Another way is to force method=_d01amc the NAG function for semi-infinite domain, while preventing evalhf mode (so as to avoid overflow) as well as specifying a higher working precision both for integrand evaluations as well as internal handling of same. This is fast.

restart

kernelopts(version);

`Maple 18.02, X86 64 LINUX, Oct 20 2014, Build ID 991181`

`λ1_N`[so] := 0.733e-3:

igrand := (Z^(`λ2_N`[so]/`λ1_N`[so]))^2*ln(Z)^2/((Z-1+`α_N`[so])^2*(Z^(`λ2_N`[so]/`λ1_N`[so])-1+`α_N`[so])^3):

evalf[15](Int(unapply(('evalf[15]')(igrand), Z), 1 .. infinity, method = _d01amc));

0.111469103907766e-12

evalf[15](Int(subs(_ig = igrand, proc (Z) Digits := 15; []; evalf(_ig) end proc), 1 .. infinity, method = _d01amc));

0.111469103907766e-12

 

NULL

Download ask_new_faster.mw

 

@Ramakrishnan Please pay closer attention. The line that you claim is missing a statement terminator is not input. It is just the echoed output of the previous input line.

And the messages about long output are not an indication of a problem with the code.

Here is the Original Poster's code, with that output line removed, and some colons to suppress the printing of long itermediate structures. It works fine, in Maple 2018.

restart; with(VectorCalculus): with(Student[LinearAlgebra]): with(plots):
v[i] := 145000; thetabn := (1/8)*Pi; thetavn := (1/6)*Pi; k := 10; omegac := .5;
lrange := 6*Pi;
v[b] := cos(2*thetabn)/cos(thetabn); v[g] := sin(2*thetabn)/cos(thetabn);
n := `<,>`(k*cos(thetabn), k*sin(thetabn), 0);
vr:=
[v[b]*t, v[g]*sin(omegac*t)/omegac, v[g]*cos(omegac*t)/omegac];

lambda := v[i]*cos(thetavn)/cos(thetabn);
shockplot := PlanePlot(n, caption = "", planeoptions = [colour = blue, transparency = .5], normaloptions = [shape = cylindrical_arrow, colour = red]):

t1 := textplot3d([k*cos(thetabn), k*sin(thetabn), 0, 'n'], align = above):
B := animate(spacecurve, [[t, 0, v[g]/omegac], t = lrange .. A], A = lrange .. 0, axes = normal, thickness = 3):
C := animate(plot3d, [[v[b]*t, v[g]*sin(omegac*t)/omegac, v[g]*cos(omegac*t)/omegac], t = 0 .. x], x = 0 .. lrange, axes = normal, colour = red, labels = [" ", zeta, xi], thickness = 2, paraminfo = false):
reflection := display([B, display(op([1, -1, 1], B), C)], insequence, scaling = constrained, axes = normal, tickmarks = [0, 0, 0]):
display(shockplot, t1, reflection, axes = none);

If you have similar variations on this question then please add them here in a Comment/Reply to the original Question, instead of making a new and separate Question thread.

@brian bovril Your worksheet has two lines with identical input,

   combine(BS*FIT*pt*Unit(year),units);

One of those has a forced Units formatting of the output, to USD. So that is why that lines shows output in USD but the other identical line shows output in AUD.

You can see the Units formatting on that particular output by right-clicking on the output, and then selecting Convert Output Units... in the popup menu. Your worksheet had it set to system SI and units USD. If you check the radio button No Conversion then that forced effect goes away.

@Carl Love Those are taken from the analogous HTML tags for tables, I believe.

Eg, <tr> for table row, <td> for table data.

I don't know which other analogous tags are supported.

Another way to approach this problem would be to use DocumentTools:-Tabulate or, if that didn't allow fine enough control over horizontal alignment, to build up a simple procedure using DocumentTools:-Layout commands. These are ways to embed GUI Tables.

The Typesetting way is fun, though. I saw those mtable,mtr,mtd exports in use in a Calculus1 tutor, for placing multi-line, aligned output inside an embedded MathContainer.

This is already an unnecessay duplicate in a theme posted by this member. It's not helpful to separate the Question threads from each other.

Please, no more separate posts/questions of this.

I am in agreement with Carl. There are very few tasks which require programmatic analysis to get the `op` spec. and which can do that robustly.

Most of the few places where that is done (that I know of) are searching for the location of a particular kind of structure like a function call by a specific name. And those mostly use op for some additional reason.

Giving us more detail about the specifics of the task, such as the goal and constraints, would help.

@Rouben Rostamian  The GUI rendering implementation, or the changes to the various export plot driver, or the Library code tweaks to accept the new syntax and make sure nothing chokes on the new data structure form, or the documentarion edits, may not be complicated.

But finding people free to do all of those, and coordinating it, and convincing middle management that it should be top of the stack, could be tricky.

@Carl Love 

(A,B):= LinearAlgebra:-GenerateMatrix(liseq1, lisvar1):
X:=LinearAlgebra:-LinearSolve(A,B,method=LU):
LinearAlgebra:-Norm(A.X-B);
                               0

Xqr:=LinearAlgebra:-LinearSolve(A,B,method=QR):
LinearAlgebra:-Norm(A.Xqr-B);
                               0

LinearAlgebra:-LinearSolve(A,B,method=solve):
Error, (in LinearAlgebra:-Modular:-IntegerLinearSolve) invalid arguments to iratrecon

LinearAlgebra:-LinearSolve(A,B);
Error, (in LinearAlgebra:-Modular:-IntegerLinearSolve) invalid arguments to iratrecon

The method=solve option makes LinearSolve convert back to explicit equations and then pass to solve. The method=LU option does the steps as you did, involving LUDecomposition. The default behavior of LinearSolve depends on the domain of the entries.

Since you have completely edited your question and rudely removed the considerably larger original, I delete my Comment.

Your procedure new_print_F is not thread-safe. And very likely neither is CodeGeneration[Fortran].

 

First 228 229 230 231 232 233 234 Last Page 230 of 592