acer

32333 Reputation

29 Badges

19 years, 318 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

The previous version has the splitting values for theta getting exactly reused at both the top & bottom of adjacent portions. This is slightly inferior, and also might be the cause of a slight visible seam.

[edit] Here is a revision which does better: WZ_p4.mw
This produce the following in about 10sec, without the visible seam.

Here is a non-fancy parallelization, using Grid:-Seq followed by stitching the resulting MESH's Arrays together.

For a total grid of 33-by-128, this takes 9.5sec on my machine, compared with 33.5sec for the unparallelized version.

restart;

nsplit := kernelopts(numcpus);

4

plots:-setoptions(size=[350,350]);

g := evalf((Beta(1/4, 1/4)/2)^4):

WZ := proc(a,b,c) option remember;
  if not [a,b,c]::list(complexcons) then return 'procname'(args);
  else evalf(WeierstrassZeta(a,b,c)); end if;
end proc:

WPP := proc(a,b,c) option remember;
  if not [a,b,c]::list(complexcons) then return 'procname'(args);
  else evalf(WeierstrassPPrime(a,b,c)); end if;
end proc:

Grid:-Set(WZ): Grid:-Set(WPP):

AA := Pi*r*cos(theta) - Re(WZ(r*exp(theta*I), g, 0) + Pi*WPP(r*exp(theta*I), g, 0)/g);
BB := Pi*r*sin(theta) + Im(WZ(r*exp(theta*I), g, 0) - Pi*WPP(r*exp(theta*I), g, 0)/g);
C := sqrt(6*Pi/g)*Re(WeierstrassP(r*exp(theta*I), g, 0));

Pi*r*cos(theta)-Re(WZ(r*exp(I*theta), 189.0727201, 0)+0.1661579022e-1*WPP(r*exp(I*theta), 189.0727201, 0))

Pi*r*sin(theta)-Im(-WZ(r*exp(I*theta), 189.0727201, 0)+0.1661579022e-1*WPP(r*exp(I*theta), 189.0727201, 0))

.3157447408*Re(WeierstrassP(r*exp(I*theta), 189.0727201, 0))

P := proc(a,b,c,tbegin,tend,BEGIN,END,m,n)
  local res, t_low, t_high;
  (t_low,t_high) :=  tbegin+(BEGIN-1)/n*(tend-tbegin), tbegin+END/n*(tend-tbegin);
  #lprint(tbegin,tend,BEGIN,END,m,n,t_low,t_high);
  res := plot3d([a,b,c], r = 1/5 .. 4/5, theta = t_low .. t_high,
                        view = [-8 .. 8, -8 .. 8, -8 .. 8], shading = zhue,
                        style = surface, grid = [m, END-BEGIN+1]);
  op([1,1],res);
end proc:

(M,N) := 33, 128;

33, 128

str:=time[real]():
temp:=[Grid:-Seq['tasksize'=1](P(AA,BB,C,-Pi,Pi,
                                 1+floor((i-1)*N/nsplit),floor(i*N/nsplit),
                                 M,N), i=1..nsplit)]:
GG:=Array(1..M,1..N,1..3,datatype=float[8]):
for i from 1 to nsplit do
  #print(floor((i-1)*N/nsplit)+1 .. floor(i*N/nsplit));
  GG[..,floor((i-1)*N/nsplit)+1 .. floor(i*N/nsplit), ..] := temp[i];
end do:
ans2 := subsop([1,1]=GG,plot3d([AA, BB, C], r = 1/5 .. 4/5, theta = -Pi .. Pi,
                               view = [-8 .. 8, -8 .. 8, -8 .. 8], shading = zhue,
                               style = surface, grid = [2, 2]));
(time[real]()-str)*':-seconds';

9.508*seconds

# clear remember tables, and recompute it all, unparallelized
WZ:=subsop(4=NULL,eval(WZ)): WPP:=subsop(4=NULL,eval(WPP)):
str:=time[real]():
K:=P(AA,BB,C,-Pi,Pi,1,N,M,N):
ans1 := subsop([1,1]=K,plot3d([AA, BB, C], r = 1/5 .. 4/5, theta = -Pi .. Pi,
                        view = [-8 .. 8, -8 .. 8, -8 .. 8], shading = zhue,
                        style = surface, grid = [2, 2])):
(time[real]()-str)*':-seconds';

33.649*seconds

Download WZ_p2.mw

ps. I used a 128 which is a multiple of 4 (my numcpus value) for the N to total of the second grid values. I didn't try very hard to see whether the bookkeeping stands up robustly when N is not a multiple of 4. You could try N=127, etc.

@Aung Your solution_1 is already an equation with P(t) alone on the left hand-side only.

And it's not a differential equation. What do you intend to accomplish by passing it to dsolve?

It's unclear what you're trying to accomplish in this followup. What do you mean by, "i want to solve for t= 0 to 600 s" ?  What are you trying to "solve" for?

ps. You also have lowercase pi, which means nothing special in Maple. You likely intend Pi.

I've been on vacation, and am now catching up. I'll try to get to this as soon as I can.

I appreciate having more examples, and will look at them carefully when I get a chance. Thank you.

ps. Originally this was just a toy experiment with objects. One lesson learned/confirmed is a suspicion that having such objects act as so-called 1st class algebraic expressions involves a tricky balance between either: teaching almost eveything how to deal with them, and/or having everything (floats, units, etc) that touches them arithmetically get absorbed into the object, or having the object-ness be so ephemeral that many operations just drop the object-ness. I'm more doubtful that most people can be satisfied here most of the time.

This Question was given the "mathml" tag. Does that mean that presentation MathML would be of use?

@RezaZanjirani Your last Reply has no attachment.

@RezaZanjirani In my code I made it take the first solution from solve.

Your situation might be better handled as an optimization problem, ie. maximize this new (as yet unstated) objective function, with the original equalities/inequalities as constraints. And, for speed, it might be formulated as a floating-point numeric problem.

Prior to this, you've created several separate Question threads on this (or very close) topic. Please don't spawn any more wholly separate new Question threads on this. Duplicate Question threads get flagged as such and may be deleted.

You could add your followup queries and details to this or an earlier relevant Question. I suggest providing as complete and detailed a description as you can of your eventual goal and motivating example as you can, even if you don't yet have prototype Maple code to solve it. That'd be much more useful than, say, slowly approaching your actual goal by a set of partial reveals of details & code attempts.

@RezaZanjirani You could construct the legend entries programmatically, as some function of the delta values. For example, HmaxProc_ac2.mw

Or you could simply construct them separately, by hand.

I don't know whether your "TEXT" has to vary with the delta values, and if so, how.

IIRC the X11_defaults/Maple file was used by the Classic GUI, which isn't really available any more for Linux.

There is a resources file used by the Java GUI, named like (version specific),
    ~/.maple/2023/maplerc
but I don't think that allows for much color configuration aside from the line like,
HelpBGColor=255 255 255
which I think specifies the background color for the main window portion of the Help viewer.

I have deleted yet another duplicate Question thread on this doCalc procedure.

If the OP has further followup queries or details on this then they can be added here, instead of in wholly separate new Question threads.

@minhthien2016 

with(Typesetting): with(InertForm):

mrow(Display(%sqrt(8) + %sqrt(32), inert=false),
     mo("="),
     Display(sqrt(2%*2%^2) + sqrt(2%*4%^2), inert=false),
     mo("="),
     Display(2 %* %sqrt(2) + 4 %* %sqrt(2), inert=false),
     mo("="),
     Display(6*sqrt(2)));

%sqrt(8)+%sqrt(32) = sqrt(`%*`(2, `%^`(2, 2)))+sqrt(`%*`(2, `%^`(4, 2))) and sqrt(`%*`(2, `%^`(2, 2)))+sqrt(`%*`(2, `%^`(4, 2))) = `%*`(2, %sqrt(2))+`%*`(4, %sqrt(2)) and `%*`(2, %sqrt(2))+`%*`(4, %sqrt(2)) = 6*sqrt(2)

Download inert_exa.mw

@minhthien2016 

F := proc(ee,LL)
  uses InertForm, Typesetting;
  mrow(Typeset(Display(eval(eval(MakeInert(factor(ee)),[`%*`=`*`])
                                 =MakeInert(subs(b=MakeInert(b*y)/y,
                        a=MakeInert(a*x)/x,p)),[a,b]=~LL),
                       inert=false)),
       mo("="),Typeset(eval(ee,[a,b]=~LL)))
end proc:

p := (a*x)^2 - 2*a*x*b*y + (b*y)^2:

L := [[2,3],[2,5],[2,7]];

[[2, 3], [2, 5], [2, 7]]

ans := F~(p, L):

print~(ans):

`%^`(`%+`(2*x, -3*y), 2) = `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, `%*`(2, x), `%*`(3, y)), `%^`(`%*`(3, y), 2)) and `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, `%*`(2, x), `%*`(3, y)), `%^`(`%*`(3, y), 2)) = 4*x^2-12*x*y+9*y^2

`%^`(`%+`(2*x, -5*y), 2) = `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, `%*`(2, x), `%*`(5, y)), `%^`(`%*`(5, y), 2)) and `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, `%*`(2, x), `%*`(5, y)), `%^`(`%*`(5, y), 2)) = 4*x^2-20*x*y+25*y^2

`%^`(`%+`(2*x, -7*y), 2) = `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, `%*`(2, x), `%*`(7, y)), `%^`(`%*`(7, y), 2)) and `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, `%*`(2, x), `%*`(7, y)), `%^`(`%*`(7, y), 2)) = 4*x^2-28*x*y+49*y^2

Download inert_ex7.mw

(or, in steps as before, inert_ex6.mw)

@minhthien2016 Once you have a process that works on a single data list, you can make it into a reusable procedure to work easily on multiple data lists.

restart;

 

F := proc(ee,LL)
  uses InertForm, Typesetting;
  mrow(Typeset(Display(eval(eval(MakeInert(factor(ee)),[`%*`=`*`])
                                 =MakeInert(map(sort,algsubs(a*x=MakeInert(a*x),ee),
                                                order=plex(b))),[a,b]=~LL),
                       inert=false)),
       mo("="),Typeset(eval(ee,[a,b]=~LL)))
end proc:

 

p := (a*x)^2 - 2*(a*x)*b + b^2:

L := [[2,3],[3,7],[9,10]];

[[2, 3], [3, 7], [9, 10]]

ans := F~(p, L);

[Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⁢"), Typesetting:-mi("x")), Typesetting:-mo("−"), Typesetting:-mn("3")), Typesetting:-_Hold([`%+`(2*x, -3)])))), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(`%+`(2*x, -3), 2)])), Typesetting:-mo("="), Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⋅"), Typesetting:-mi("x")), Typesetting:-_Hold([`%*`(2, x)])))), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(`%*`(2, x), 2)])), Typesetting:-mo("−"), Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⋅"), Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⋅"), Typesetting:-mi("x")), Typesetting:-_Hold([`%*`(2, x)]))), Typesetting:-mo("⋅"), Typesetting:-mn("3")), Typesetting:-_Hold([`%*`(2, `%*`(2, x), 3)])), Typesetting:-mo("+"), Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mn("3")), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(3, 2)]))), Typesetting:-_Hold([`%+`(`%^`(`%*`(2, x), 2), `%*`(-2, `%*`(2, x), 3), `%^`(3, 2))]))), Typesetting:-mo("="), Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mn("4"), Typesetting:-mo("⁢"), Typesetting:-msup(Typesetting:-mi("x"), Typesetting:-mn("2"))), Typesetting:-mo("−"), Typesetting:-mrow(Typesetting:-mn("12"), Typesetting:-mo("⁢"), Typesetting:-mi("x")), Typesetting:-mo("+"), Typesetting:-mn("9"))), Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mn("3"), Typesetting:-mo("⁢"), Typesetting:-mi("x")), Typesetting:-mo("−"), Typesetting:-mn("7")), Typesetting:-_Hold([`%+`(3*x, -7)])))), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(`%+`(3*x, -7), 2)])), Typesetting:-mo("="), Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("3"), Typesetting:-mo("⋅"), Typesetting:-mi("x")), Typesetting:-_Hold([`%*`(3, x)])))), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(`%*`(3, x), 2)])), Typesetting:-mo("−"), Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⋅"), Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("3"), Typesetting:-mo("⋅"), Typesetting:-mi("x")), Typesetting:-_Hold([`%*`(3, x)]))), Typesetting:-mo("⋅"), Typesetting:-mn("7")), Typesetting:-_Hold([`%*`(2, `%*`(3, x), 7)])), Typesetting:-mo("+"), Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mn("7")), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(7, 2)]))), Typesetting:-_Hold([`%+`(`%^`(`%*`(3, x), 2), `%*`(-2, `%*`(3, x), 7), `%^`(7, 2))]))), Typesetting:-mo("="), Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mn("9"), Typesetting:-mo("⁢"), Typesetting:-msup(Typesetting:-mi("x"), Typesetting:-mn("2"))), Typesetting:-mo("−"), Typesetting:-mrow(Typesetting:-mn("42"), Typesetting:-mo("⁢"), Typesetting:-mi("x")), Typesetting:-mo("+"), Typesetting:-mn("49"))), Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mn("9"), Typesetting:-mo("⁢"), Typesetting:-mi("x")), Typesetting:-mo("−"), Typesetting:-mn("10")), Typesetting:-_Hold([`%+`(9*x, -10)])))), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(`%+`(9*x, -10), 2)])), Typesetting:-mo("="), Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("9"), Typesetting:-mo("⋅"), Typesetting:-mi("x")), Typesetting:-_Hold([`%*`(9, x)])))), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(`%*`(9, x), 2)])), Typesetting:-mo("−"), Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⋅"), Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("9"), Typesetting:-mo("⋅"), Typesetting:-mi("x")), Typesetting:-_Hold([`%*`(9, x)]))), Typesetting:-mo("⋅"), Typesetting:-mn("10")), Typesetting:-_Hold([`%*`(2, `%*`(9, x), 10)])), Typesetting:-mo("+"), Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mn("10")), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(10, 2)]))), Typesetting:-_Hold([`%+`(`%^`(`%*`(9, x), 2), `%*`(-2, `%*`(9, x), 10), `%^`(10, 2))]))), Typesetting:-mo("="), Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mn("81"), Typesetting:-mo("⁢"), Typesetting:-msup(Typesetting:-mi("x"), Typesetting:-mn("2"))), Typesetting:-mo("−"), Typesetting:-mrow(Typesetting:-mn("180"), Typesetting:-mo("⁢"), Typesetting:-mi("x")), Typesetting:-mo("+"), Typesetting:-mn("100")))]

print~(ans):

`%^`(`%+`(2*x, -3), 2) = `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, `%*`(2, x), 3), `%^`(3, 2)) and `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, `%*`(2, x), 3), `%^`(3, 2)) = 4*x^2-12*x+9

`%^`(`%+`(3*x, -7), 2) = `%+`(`%^`(`%*`(3, x), 2), `%*`(-2, `%*`(3, x), 7), `%^`(7, 2)) and `%+`(`%^`(`%*`(3, x), 2), `%*`(-2, `%*`(3, x), 7), `%^`(7, 2)) = 9*x^2-42*x+49

`%^`(`%+`(9*x, -10), 2) = `%+`(`%^`(`%*`(9, x), 2), `%*`(-2, `%*`(9, x), 10), `%^`(10, 2)) and `%+`(`%^`(`%*`(9, x), 2), `%*`(-2, `%*`(9, x), 10), `%^`(10, 2)) = 81*x^2-180*x+100

Download inert_ex5.mw

@minhthien2016 Like this?

restart;

with(InertForm): with(Typesetting):

p := (a*x)^2 - 2*(a*x)*b + b^2:

temp1 := eval(MakeInert(factor(p)),[`%*`=`*`]):

temp2 := MakeInert(map(sort,algsubs(a*x=MakeInert(a*x),p),
                       order=plex(b))):

L := [a=2,b=3]:

r1 := Display(eval(temp1=temp2,L),inert=false):

r2 := eval(p,L):

 

mrow(Typeset(EV(r1)),mo("="),Typeset(EV(r2)));

`%^`(`%+`(2*x, -3), 2) = `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, `%*`(2, x), 3), `%^`(3, 2)) and `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, `%*`(2, x), 3), `%^`(3, 2)) = 4*x^2-12*x+9

Download inert_ex4.mw

Please put your close followup examples here, instead of spawning wholly separate new Question threads on the same topic.

An example:

restart;

with(InertForm): with(Typesetting):

 

p := (a*x)^2 - 2*(a*x)*b + b^2;

a^2*x^2-2*a*b*x+b^2

temp1 := eval(MakeInert(factor(p)),[`%*`=`*`]);

`%^`(`%+`(a*x, -b), 2)

temp2 := MakeInert(algsubs(a*x=MakeInert(a*x),p));

`%+`(`%^`(`%*`(a, x), 2), `%*`(-2, b, `%*`(a, x)), `%^`(b, 2))

L := [a=2,b=3];

[a = 2, b = 3]

r1 := Display(eval(temp1=temp2,L),inert=false);

Typesetting:-mrow(Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⁢"), Typesetting:-mi("x")), Typesetting:-mo("−"), Typesetting:-mn("3")), Typesetting:-_Hold([`%+`(2*x, -3)])))), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(`%+`(2*x, -3), 2)])), Typesetting:-mo("="), Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⋅"), Typesetting:-mi("x")), Typesetting:-_Hold([`%*`(2, x)])))), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(`%*`(2, x), 2)])), Typesetting:-mo("−"), Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⋅"), Typesetting:-mn("3"), Typesetting:-mo("⋅"), Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⋅"), Typesetting:-mi("x")), Typesetting:-_Hold([`%*`(2, x)])))), Typesetting:-_Hold([`%*`(2, 3, `%*`(2, x))])), Typesetting:-mo("+"), Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mn("3")), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(3, 2)]))), Typesetting:-_Hold([`%+`(`%^`(`%*`(2, x), 2), `%*`(-2, 3, `%*`(2, x)), `%^`(3, 2))])))

r2 := eval(p,L);

4*x^2-12*x+9

mrow(Typeset(EV(r1)),mo("="),Typeset(EV(r2)));

`%^`(`%+`(2*x, -3), 2) = `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, 3, `%*`(2, x)), `%^`(3, 2)) and `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, 3, `%*`(2, x)), `%^`(3, 2)) = 4*x^2-12*x+9

Download inert_ex3.mw

First 64 65 66 67 68 69 70 Last Page 66 of 591