acer

32405 Reputation

29 Badges

19 years, 350 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

If you have a problem with your particular example then it would be better to upload and attach your worksheet. That can also help with syntax issues.

Here I've squinted and tried to reproduce the input for the int call from your image, in plaintext Maple notation. I prefer to use a different name for the upper limit of integration. 

restart;

kernelopts(version);

`Maple 2020.2, X86 64 LINUX, Nov 11 2020, Build ID 1502365`

simplify( combine( int( -(C__A*K+1)/(k*C__A), C__A=C__A0..C__AA ) ), size )
  assuming C__A0>0, C__AA>C__A0;

(ln(C__A0/C__AA)+(-C__AA+C__A0)*K)/k

Download integral_ex1.mw

I'm not sure whether you are trying to simplify or improve the code you gave, or obtain code to produce a table of a variety of such curves.

Here, procedure L produces the curve for a particular set of parameter values, from t=0 to t=T some final value. You could call L with some choice of parameter values, to see that. Procedure LL makes a table of different calls to L, using names lists of parameter choices. And LL can be animated across T values. (There are several other ways you could code this, expecially w.r.t. you choice of parameters for a table. Adjust as you see fit.)

restart;
dlist:=[0,1*Pi/4,2*Pi/4,3*Pi/4,4*Pi/4]:
ablist:=[[1,1],[2,1],[3,1],[3,2],[4,3],[5,3],[6,5]]:
adj:=[0,Pi/2,0,Pi/4,Pi/2,Pi,-Pi/2]:
L := proc(A,B,a,b,d,T) local ee,t; uses plots;
  display(subsindets(
            plot([A*sin(a*t+d),B*sin(b*t),t=0..T],
                 'color'="white",'thickness'=1),
            'specfunc(:-anything,:-THICKNESS)',u->':-THICKNESS(0.9)'),
          pointplot([A*sin(a*T+d),B*sin(b*T)],'color'="cyan",
                    'symbol'=':-circle','symbolsize'=6),
          'axes'=':-none','scaling'=':-constrained',background=black);
end proc:
LL := proc(T) local i,j; uses plots, plottools;
  display(seq(seq(translate(L(1,1,ablist[j][],dlist[i]+adj[j],T),
                            (nops(dlist)-i+1)*3,(nops(abslist)-j+1)*3),
                  i=1..nops(dlist)),j=1..nops(ablist)),
          'size'=[nops(dlist),nops(ablist)]*125,'axes'=':-none',
          'scaling'=':-constrained','background'="black");
end proc:
## A single call to LL
#LL(2*Pi/3);
plots:-animate(LL,[T],T=0..2*Pi,'paraminfo'=false,'frames'=51,
               'background'="black",'size'=[nops(dlist),nops(ablist)]*125);

Lissajous_anim1.mw

The code above is slightly more verbose than necessary, so that a few possible modifications might be a little more clear. If you wanted to get fancier you could also color the curves according to certain parameter values, or add captions below each to show values.

As for the code you originally supplied, I think that merging a multitude of calls to plots:-animate makes the coding unnecessarily complicated. One difficulty it brings is that the various curves and points cannot be easily seen together (as a visual check of correctness) as a single frame for a single value of the animating parameter.

As an alternative approach, the procedure F below generates any single frame, taking the animating parameter as its sole argument. Thus a call to F generates a single frame, which makes for a much easier and quicker way to test that a given frame looks right.

Also, the various plot and pointplot calls could be merged. An easy edit, but a bit tidier.

restart;

with(plots):

base := display(plot([cos(x), sin(2*x),x=0..2*Pi], thickness=2),
                display(plot([cos(t),t,t=0..2*Pi]),
                        plot([t,sin(2*t),t=0..2*Pi]), thickness=0)):

F := a -> display(base,
  plot([[[0,sin(2*a)],[cos(a),sin(2*a)]],[[0,a],[cos(a),a]],
        [[cos(a),sin(2*a)],[cos(a),a]],
        [[cos(a),0],[cos(a),sin(2*a)]],[[a,0],[a,sin(2*a)]],
        [[cos(a),sin(2*a)],[a,sin(2*a)]]], thickness=3,
       color=[green$3,red$3], linestyle=[seq([solid,solid,dash][],1..2)]),
  pointplot([[cos(a),sin(2*a)],[0,sin(2*a)],[0,a],[cos(a),a],
             [cos(a),0],[a,0],[a,sin(2*a)]], color=[blue,green$3,red$3],
            symbolsize=23, symbol=solidcircle)):

F(Pi/3);

animate(F, [a], a=0..2*Pi, frames=100);

 

Download Lissajous_ac.mw

restart;
with(plots,display): with(geom3d):
point(A, [1, 2, 3]):
point(B, [-2, 3, -1]):
point(C, [0,-3, 1]):
segment(S1, A, B):
segment(S2, A, C):
display(
  display(draw(A(symbol=solidsphere, symbolsize=15)), colour=green),
  display(draw(B(symbol=solidsphere, symbolsize=30)), colour=red),
  display(draw(C(symbol=solidsphere, symbolsize=20)), colour=magenta),
  draw([S1(thickness=4, color=red),
        S2(thickness=4, color=blue)]));

The leading minus sign gets generated depending on what Maple considers the sign of some expressions (or subexpressions) involved in the computation (here, by solve).

If you can find a lexicographic ordering for which the sign of (say...) the numerator is -1 then you might apply sort w.r.t that ordering and reconstruct.

For example,

restart;

ee := -(C__iss2*V__gs_th2-Q__total)/i__GateDriveN;

-(C__iss2*V__gs_th2-Q__total)/i__GateDriveN

inds := [op(indets(ee,And(name,Not(constant),
                          satisfies(nm->type(ee,polynom(anything,nm))))))];

[C__iss2, Q__total, V__gs_th2]

cand := [Q__total, C__iss2, V__gs_th2, i__GateDriveN];

[Q__total, C__iss2, V__gs_th2, i__GateDriveN]

sign(numer(ee), inds);

-1

sign(numer(ee), cand);

1

ee := sort(numer(ee), order=plex(op(cand)))/denom(ee);

(Q__total-C__iss2*V__gs_th2)/i__GateDriveN

Download sign_sort.mw

I have not included code that might search (loop) through candidate orderings (say, permutations) until the desired sign might be found.

Maple's design in this regard is for efficiency over beautification of the final display. Note that the application above of the sort command will transform the uniquified expression that was numer(ee). This reorders the terms of that polynomial. That is done to the unique representation stored in the kernel, for that expression. Uniquification of expressions is for effiiciency. Reordering expressions for the purpose of beautification of display is a performance killer in general since in general that might require repeated waste of time as the same expression could get sorted and resorted for situations that vie against each other. Even for mere printing effects, searching for beautification may get expensive in the multivariate case, and being inconsistent in that regard would be very poor.

note: One might also (have to) examine sign(ee), and sign(denom(ee)), depending on the example.

A difference in sign:

restart;

raw := t^(2*a - 1)/(-t^2 + 1);

t^(2*a-1)/(-t^2+1)

facraw := factor(raw);

-t^(2*a-1)/((t-1)*(t+1))

int(raw, t = 0 .. infinity, CPV = true) assuming 0 <= a, a <= 1;

(1/2)*Pi/(sin(Pi*a)*(-1)^(1-a))

evalc(%);

-(1/2)*Pi*cos(Pi*a)/sin(Pi*a)-((1/2)*I)*Pi

int(facraw, t = 0 .. infinity, CPV = true) assuming 0 <= a, a <= 1;

-(1/2)*Pi/(sin(Pi*a)*(-1)^(1-a))

evalc(%);

(1/2)*Pi*cos(Pi*a)/sin(Pi*a)+((1/2)*I)*Pi

Download int_cpv_ex1.mw

You have not provided your problematic module, so I'm going to guess.

This is not allowed in Maple 2026,

restart;
kernelopts(version);
   Maple 2016.2, X86 64 LINUX, Jan 13 2017, Build ID 1194701

M := module()
  local x;
  x := 5;
  export F := proc(x) sin(x); end proc:
end module:
Error, unexpected `export` declaration in `module` body

But it's ok in Maple 2020,

restart;
kernelopts(version);
   Maple 2020.2, X86 64 LINUX, Nov 11 2020, Build ID 1502365

M := module()
  local x;
  x := 5;
  export F := proc(x) sin(x); end proc:
end module:

You might consider,

restart;
kernelopts(version);
   Maple 2016.2, X86 64 LINUX, Jan 13 2017, Build ID 1194701

M := module()
  local x;
  export F := proc(x) sin(x); end proc:
  x := 5;
end module:

M := module()
  export F;
  local x;
  x := 5;
  F := proc(x) sin(x); end proc:
end module:

Perhaps the simplest is to store the data in a file.

If the data is in a Matrix, Array, or table then you could save it as a .m file. Or if it's a Matrix or Array you could export it to a file.

Then you could read (or import, if exported) that file back into your separate worksheet.

It's not quite clear (to me) from your Question whether you "table" might be an Matrix, Array, or table data-structure.

If you don't mind your worksheets being bundled together then you could also store both those and the data in a workbook. Or you could share a variable across them.

I really dislike making unnecessary assignments, since then the assigned symbolic names are no longer directly available for further symbolic manipulations (unless you also unassign, ie. wasting time and effort).

So, after what you had so far, you could do the following, if like me you prefer Qb11,etc remain unassigned. This does substitution instead of assignment.

eqs1 := Equate(lhs(eq1), rhs(eq1));

plot(eval(Qb11, eval(eqs1, [Q22 = 1, s = 1])), p = 0 .. 9);

plotting_elements_of_matrix_ac.mw

For your example, the rational factor of 1/3 gets distributed by a process within the Maple engine called automatic simplification.

That cannot be prevented through unevaluation, eg. it's not prevented by uneval quotes.

'1/3*(1-exp(-3))';

          1   1        
          - - - exp(-3)
          3   3        

So, about the best you can do here is turn some part(s) of the expression into a form that pretty-prints as you want it (even if it isn't the same value, internally).

Your example is rather short, and there are a few ways to accomplish such pretty-printing workarounds for it. Some of the approaches render slightly differently across versions. You didn't say which version you're using.

For example,

restart;

kernelopts(version);

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

a:=1/3 -exp(-3)/3:

interface(typesetting=extended):

`%/`(numer(a),denom(a));

`%/`(1-exp(-3), 3)

InertForm:-Display(icontent(a))*InertForm:-Display(a/icontent(a));

Typesetting:-mfrac(Typesetting:-mn("1"), Typesetting:-mn("3"))*Typesetting:-mrow(Typesetting:-mn("1"), Typesetting:-mo("&minus;"), Typesetting:-msup(Typesetting:-mo("&ExponentialE;"), Typesetting:-mn("&uminus0;3")))

Download inert_autsimp.mw

You seem to expect that the condition x>=-4 implies only one explicit solution (for y). But that's incorrect. As the following plot illustrates, there are two y-solutions for each x>=-4.

plots:-implicitplot(x=subs(x=y,x^2+8*x), x=-18..5, y=-10..1,
                    rangeasview, size=[400,300]);

Perhaps you mean instead that y>=-4 ?  With that condition one may obtain a single, restricted solution. That can be accomplished either by utilizing assumptions or by supplying the extra condition in solve's first argument.

restart;

solve(x=y^2+8*y, y, useassumptions, parametric)
  assuming y::RealRange(-4, Open(infinity));

piecewise(x < -16, [], -16 <= x, [[y = -4+sqrt(x+16)]])

solve({x=y^2+8*y, y>=-4}, y, parametric);

piecewise(x < -16, [], -16 <= x, [[y = -4+sqrt(x+16)]])

Download solve_restr.mw

Similarly, for y<=-4,

solve(x=y^2+8*y, y, useassumptions, parametric)
  assuming y::RealRange(Open(-infinity),-4);
           /                       [[                 (1/2)]]\
  piecewise\x < -16, [], -16 <= x, [[y = -4 - (x + 16)     ]]/

solve({x=y^2+8*y, y<=-4}, y, parametric);
           /                       [[                 (1/2)]]\
  piecewise\x < -16, [], -16 <= x, [[y = -4 - (x + 16)     ]]/

A Plot Component has a programmable property for the delay between frames.

You can programmatically construct, embed, and control the playing an properties of an animation inside a Plot Component. (see attachment)

You can even programmatically embed an animation which automatically starts playing, with your specified frame delay.

Ignoring some (usually small) rendering overhead, the frame-delay can be taken approximately as the reciprocal of the frame-rate -- accomodating also for the scaling conversion seconds vs milliseconds.

anim_auto_fps.mw

Somewhere I had a version of this which included play/stop/fastforward/etc Buttons below the Plot Component. I can't find it now -- it was years ago. I might have included a Dial for frame-rate/fame-delay.

Of course, this does not provide any way to alter the frame-rate for exporting to animated .GIF file. For that purpose all I know is the crude slowing down of an animation by duplication of certain/all frames.

restart

p := proc (S) options operator, arrow; .32*exp(S)/(1.2+1.901885*exp(S)-S^3) end proc

eta := proc (S) options operator, arrow; (D(p))(S)*S/p(S) end proc

assume(k > 0)

f := proc (k) options operator, arrow; A*k^alpha end proc

w := proc (k) options operator, arrow; f(k)-(D(f))(k)*k end proc

beta := 1

A := 28

alpha := .33

chi := proc (i) options operator, arrow; i*((1+beta)/beta+eta(i))/(1+eta(i)) end proc

H := proc (k, i) options operator, arrow; chi(i)-w(k) = 0 end proc

str := time[real](); Praw := plots:-implicitplot(H(k, i), k = 1 .. 2, i = 3 .. 15); (time[real]()-str)*'seconds'

0.53e-1*seconds

transf := plottools:-transform(proc (x, y) options operator, arrow; [x, ln((w(x)-y)*(A*alpha)^beta*(p(y)*y)^(alpha*beta))] end proc)

transf(Praw)

NULL

Download Worksheet_1_implicit_acc.mw

You might also consider applying the print command to the procedure.

In recent versions you could also utilize fprintf with a new format to write out procedures with nice formatting and line-breaks. [edited] See Comment below for an example.

The text version does a step like,

  gen := (i, j) -> evalf(a(inits[j], i))

whereas your version does that like,

   gen := (i, j) -> evalf(a(inits, i))

Those are not the same. And that seems the central mistake.

In this attachment I also changed the call of evalf[4](...), slightly, so that the results are rounded to four digits while still computed at Digits=10 precision. It doesn't make a difference in this example, but using evalf[4] alone is unnecessarily innacurate in general; using that alone is not a great way to simply round results to four digits.

I also inserted an unassignment to name `a`  -- after it was assigned an operator earlier on, and before a subsequent rsolve call. (I had already done this earlier, but have now edited my Answer to mention it.)

Discrete_Dynamical_Models_2_ac.mw

restart

DDS := a(n+1) = (1+.12*(1/12))*a(n)+1000

a(n+1) = 1.010000000*a(n)+1000

rsolve({DDS, a(0) = 0}, a(n)); a := unapply(%, n)

proc (n) options operator, arrow; -100000+100000*(101/100)^n end proc

plot([-100000+100000*(101/100)^n], n = 0 .. 100, a = 0 .. 200000)

pts := {seq([k, a(k)], k = 0 .. 24)}; plot(pts, style = point, title = "Savings Account with Monthly Deposit")

a := 'a'; rsolve({a(0) = 497.5124378, a(n+1) = -1.01*a(n)+1000}, a(n))

a

-(11/1005000000)*(-101/100)^n+100000/201

plot([-(11/1005000000)*(-101/100)^n+100000/201], n = 0 .. 20, a = 0 .. 1000)

solve(ev = -1.01*ev+1000, ev)

497.5124378

rsolve({a(n+1) = .5*a(n)+16}, a(n))

a(0)*(1/2)^n-32*(1/2)^n+32

rsolve({a(0) = 10, a(n+1) = .5*a(n)+16}, a(n))

-22*(1/2)^n+32

smartplot(-22*(1/2)^n+32)

rsolve({a(0) = 20, a(n+1) = .5*a(n)+16}, a(n))

-12*(1/2)^n+32

smartplot(-12*(1/2)^n+32)

rsolve({a(0) = 32, a(n+1) = .5*a(n)+16}, a(n))

32

rsolve({a(0) = 50, a(n+1) = .5*a(n)+16}, a(n))

18*(1/2)^n+32

smartplot(18*(1/2)^n+32)

solve(ev = .5*ev+16, ev)

32.

solve(ev = .5*ev+64, ev)

128.

rsolve({a(0) = A, a(n+1) = .5*a(n)+64}, a(n)); a := unapply(%, [A, n])

A*(1/2)^n-128*(1/2)^n+128

proc (A, n) options operator, arrow; A*(1/2)^n-128*(1/2)^n+128 end proc

inits := [0, 50, 100, 150, 200]

gen := proc (i, j) options operator, arrow; evalf[4](evalf[10](a(inits[j], i))) end proc

proc (i, j) options operator, arrow; evalf[4](evalf[10](a(inits[j], i))) end proc

DrugConcTable := Matrix(10, 5, gen)

Matrix(%id = 18446884047296012030)

 

ps. I also changed your Post into a Question.

If you omit both an explicit multiplication symbol as well as an intervening space then in 2D Input (in Maple 2017) the second brackets will get parsed as a function call.

In Maple the syntax allows for an addition or subtraction of the operator names. Eg,

   (sin + cos)(x)

gets parsed as  sin + cos  applied to argument x, and evaluates to sin(x) + cos(x) .

Also, a number (such as 11) applied to an argument evaluates to just 11 itself.

And so,

   (epsilon[3] - 1)( ... something ...)

gets parsed as  epsilon[3] - 1  applied to that something as argument. It gets parsed as a function call. And it evaluates to  -1  plus  epsilon[3] applied to that something.

This appears to be what has happened in your example, judging by your attachment.

If you do not like to see the explicit "dot" in the 2D Input then you could put a space between such brackets instead, in your Maple 2017. You can control whether such a space gets interpreted implicitly as multiplication as a user preference. See Tools->Options->Interface from the main menubar.

First 82 83 84 85 86 87 88 Last Page 84 of 336