acer

33400 Reputation

29 Badges

20 years, 332 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@anton_dys It would also be possible to construct piecewise coloring functions, for just the original plot3d construction of the sphere, using complicated piecewise formula(s). But to me it seems easier to leverage the colorscheme functionality, and replace the COLOR substructure.

There are other ways to obtain a new COLOR substructure for use as a replacement. Eg, making sure to use the same grid sizes,

restart;
c := ph+th/16:
P2 := plot3d(1, th=0..2*Pi, ph=0..Pi, coords=spherical, grid=[49,49]):
P2 := subsindets(P2,specfunc(anything,{COLOR,COLOUR,SHADING}),()->NULL):
U := plot3d(c, th=0..2*Pi, ph=0..Pi, grid=[49,49],
            colorscheme= ["zgradient",[black, red, yellow, white]]):
subsop([1]=op([1,0],P2)(op([1,..],P2),indets(U,specfunc(anything,COLOR))[1]),P2);

You could even use a different coordinate set for producing the colorscheme colors, or different scheme like "xgradient". (I'm just making this example up...)

restart;
c := ph+th/16:
P2 := plot3d(1, th=0..2*Pi, ph=0..Pi, coords=spherical, grid=[49,49]):
# Next step not strictly necessary here, as P2 has not COLOR substructure.
# But more generally P2 could have arisen elsewhere. So remove any COLOR
# or SHADING from it.
P2 := subsindets(P2,specfunc(anything,{COLOR,COLOUR,SHADING}),()->NULL):
U := plot3d(c, th=0..2*Pi, ph=0..Pi, grid=[49,49], coords=spherical,
            colorscheme= ["xgradient",[black, red, yellow, white]]):
subsop([1]=op([1,0],P2)(op([1,..],P2),indets(U,specfunc(anything,COLOR))[1]),P2);

@minhhieuh2003 You only need to state the followup question and insert a link to any new uploaded worksheet. You don't need to inline the contents of every newly uploaded worksheet.

I advise that you stop using global variables. They are counterproductive and make it awkward. Simply have dsds1d_s return a list of the Rows. And have printdata accept a list of Rows. You can then call printdata with a merged list of the different results from separate calls to dsds1d_s .

goi_maple_new_Q_ac.mw

 

@torabi For multivariate systems the method fsolve uses is Newton's method.

I doubt that re-implementing Newton's method will help.

But, now that the equations are correct you should be able to try other things.

You could try looking for more suitable ranges for the varables.

You could construct procedures, so as to call fsolve with higher working precision while keeping acceptance/convergence tolerance looser.

Or you could try DirectSearch:-SolveEquations.

@adel-00 Why do you keep ignoring the suggestions which work?

@Preben Alsholm What I was trying to convey, in my Answer above, is that I get the following performance using the Zf(t,f) I had.

plot3d(Zf(t,f), f=1..10, t=0..3, grid=[29,49]);     # 9.0 sec

plot3d(Zf(t,f), t=0..3, f=1..10, grid=[49,29]);     # 3.6 minutes

Using the implementation for Q(f,t) which you've given, I see the following, similar, performance distinction (albeit a smaller absolute difference, but a somewhat comparable relative difference).

CodeTools:-Usage( plot3d(Q(f,t), f=1..10, t=0..3, grid=[29,49]) ):
memory used=11.90MiB, alloc change=0 bytes, cpu time=330.00ms, real time=331.00ms, gc time=30.19ms
CodeTools:-Usage( plot3d(Q(f,t), t=0..3, f=1..10, grid=[49,29]) ):
memory used=49.77MiB, alloc change=0 bytes, cpu time=4.82s, real time=4.82s, gc time=29.40ms

The key aspects are that it seems important to:
1) Have the dsolve parameter be the first/inner plotting variable, so that it changes value less often.
2) Don't set that parameter (using a procedure returned by dsolve) if its value is not different/changed.

Yes, I realize that the axis roles can be interchanged by using the parametric plotd3 calling sequence, while retaining the dsolve-parameter as the inner/first plotting variable for efficiency. But I was trying to keep it simple since the OP has trouble following instructions.
 

 

@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

First 247 248 249 250 251 252 253 Last Page 249 of 612