acer

32490 Reputation

29 Badges

20 years, 7 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@adel-00 No, do it as,

   plot3d(Zf(t,f), f=-1..1, t=0..3, grid=[29,49]);

The procedure Zf sets the value for parameter f, and then calls zfun at the value of t.

The CodeTools:-Usage is just there to show the timing.

restart;

SumTools:-Summation(1/n*sin(n*x),n=1..infinity) assuming 0<x, x<Pi;

-((1/2)*I)*(-ln(1-exp(I*x))+ln(1-exp(-I*x)))

restart;

SumTools:-DefiniteSummation(1/n*sin(n*x),n=1..infinity) assuming 0<x, x<Pi;

-((1/2)*I)*(-ln(1-exp(I*x))+ln(1-exp(-I*x)))

 

Download Summation.mw

@minhhieuh2003 Column span relates to how many columns a cell will span over. It doesn't specify a width.

You might be able to force some kind of increase to width, by padding with a long empty string. But it would be poor, in the sense that it would hardly offer the functionality to get a target pixel size.

I'll repeat an earlier suggestion: Consider using the documented commands in DocumentTools:-Layout instead of all these undocumented commands in Typesetting. It also gives the control you've requested for horizontal alignment as well as width. For example,

goi_maple_ac_EC.mw

@FrancescoLR What I'm expecting is a worksheet or text file, that contains all code, including procedures and data and the function calls that will reproduce your error messages when re-executed.

Use the green up-arrow in the Mapleprimes editor to upload.

@torabi As I wrote before, "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."

You wrote the code which constructs PDE[i], and you haven't explained it. So, you ought to fix it.

@torabi Examine the arguments you are passing to fsolve. They contain some non-scalar nonsense.

@Carl Love He is also attempting to do Fortran code-generation, if I am understanding rightly. But we've been told very little about the data. It might be possible to get some improvement for at least the CG part, perhaps by using Grid on a few chunks.

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("&int;"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("&InvisibleTimes;"), Typesetting:-mi("x")), Typesetting:-mo("&plus;"), Typesetting:-mn("4"))), Typesetting:-mspace(width = "0.3em"), Typesetting:-mo("&DifferentialD;"), Typesetting:-mi("x"))

lprint(foo2);

Typesetting:-mrow(Typesetting:-mo("&int;"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("&InvisibleTimes;"), Typesetting:-mi("x")), Typesetting:-mo("&plus;"), Typesetting:-mn("4"))), Typesetting:-mspace(width = "0.3em"), Typesetting:-mo("&DifferentialD;"), 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("&int;", Typesetting:-msemantics = "inert")), Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("&sdot;"), Typesetting:-mi("x")), Typesetting:-_Hold([`%*`(2, x)])), Typesetting:-mo("&plus;"), Typesetting:-mn("4")), Typesetting:-_Hold([`%+`(`%*`(2, x), 4)]))), Typesetting:-mspace(width = "0.3em"), Typesetting:-mstyle(Typesetting:-mo("&DifferentialD;", Typesetting:-msemantics = "inert")), Typesetting:-mi("x")), Typesetting:-_Hold([%int(`%+`(`%*`(2, x), 4), x)]))

lprint(foo4);

Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mstyle(Typesetting:-mo("&int;", Typesetting:-msemantics = "inert")), Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("&sdot;"), Typesetting:-mi("x")), Typesetting:-_Hold([`%*`(2, x)])), Typesetting:-mo("&plus;"), Typesetting:-mn("4")), Typesetting:-_Hold([`%+`(`%*`(2, x), 4)]))), Typesetting:-mspace(width = "0.3em"), Typesetting:-mstyle(Typesetting:-mo("&DifferentialD;", 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`

`&lambda;1_N`[so] := 0.733e-3:

igrand := (Z^(`&lambda;2_N`[so]/`&lambda;1_N`[so]))^2*ln(Z)^2/((Z-1+`&alpha;_N`[so])^2*(Z^(`&lambda;2_N`[so]/`&lambda;1_N`[so])-1+`&alpha;_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`

`&lambda;1_N`[so] := 0.733e-3:

igrand := (Z^(`&lambda;2_N`[so]/`&lambda;1_N`[so]))^2*ln(Z)^2/((Z-1+`&alpha;_N`[so])^2*(Z^(`&lambda;2_N`[so]/`&lambda;1_N`[so])-1+`&alpha;_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.

First 230 231 232 233 234 235 236 Last Page 232 of 594