acer

32385 Reputation

29 Badges

19 years, 339 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

You are missing a multiplication symbol between the round brackets.

Without them your input is parsed as function application, rather than multiplication.

Another choice, in 2D Input, is to use a space to denote implicit multiplication. But that approach is error-prone, since it is difficult to distinguish visually.

restart

 

Firsy, using an explicit multiplication symbol.

 

q__1A := proc (p__1A, p__1B) options operator, arrow; (1/2+(1/2)*a+(1/2)*p__2A-(1/2)*p__1A)*(1/2+(1/2)*b+(1/2)*p__1B-(1/2)*p__1A) end proc

proc (p__1A, p__1B) options operator, arrow; (1/2+(1/2)*a+(1/2)*p__2A-(1/2)*p__1A)*(1/2+(1/2)*b+(1/2)*p__1B-(1/2)*p__1A) end proc

diff(q__1A(p__1A, p__1B), p__1A)

-1/2-(1/4)*b-(1/4)*p__1B+(1/2)*p__1A-(1/4)*a-(1/4)*p__2A

 

Next, using a space to denote the multiplication implicitly.

 

q__1A := proc (p__1A, p__1B) options operator, arrow; (1/2+(1/2)*a+(1/2)*p__2A-(1/2)*p__1A)*(1/2+(1/2)*b+(1/2)*p__1B-(1/2)*p__1A) end proc

proc (p__1A, p__1B) options operator, arrow; (1/2+(1/2)*a+(1/2)*p__2A-(1/2)*p__1A)*(1/2+(1/2)*b+(1/2)*p__1B-(1/2)*p__1A) end proc

diff(q__1A(p__1A, p__1B), p__1A)

-1/2-(1/4)*b-(1/4)*p__1B+(1/2)*p__1A-(1/4)*a-(1/4)*p__2A

 

Finally, omitting both multiplication symbol and space, which makes
the input get parsed as function application.

 

q__1A := proc (p__1A, p__1B) options operator, arrow; (1/2+(1/2)*a+(1/2)*p__2A-(1/2)*p__1A)(1/2+(1/2)*b+(1/2)*p__1B-(1/2)*p__1A) end proc

proc (p__1A, p__1B) options operator, arrow; (1/2+(1/2)*a+(1/2)*p__2A-(1/2)*p__1A)(1/2+(1/2)*b+(1/2)*p__1B-(1/2)*p__1A) end proc

diff(q__1A(p__1A, p__1B), p__1A)

-(1/4)*(D(a))(1/2+(1/2)*b+(1/2)*p__1B-(1/2)*p__1A)-(1/4)*(D(p__2A))(1/2+(1/2)*b+(1/2)*p__1B-(1/2)*p__1A)+(1/4)*(D(p__1A))(1/2+(1/2)*b+(1/2)*p__1B-(1/2)*p__1A)

 

Download 2d_mult.mw

 

If you want "gridlines" which illustrate the idea of rotation then why not use a non-cartesian (and suitable) coordinate system?

For example,

restart;

with(plots):

 

optwf := grid=[23,70], style=wireframe, color="Pink", thickness=3:
optsurf := grid=[70,70], style=surface, transparency=0.1, color=u:

ee := evalc(Re(sqrt(x+I*y)));

(1/2)*(2*(x^2+y^2)^(1/2)+2*x)^(1/2)

ff := simplify(eval(ee,[x=v*cos(u),y=v*sin(u)])) assuming real;

(1/2)*(2*abs(v)+2*v*cos(u))^(1/2)

display(seq(seq(plot3d([v*cos(u), v*sin(u), k*ff],
                       u=0..2*Pi, v=0..4, opt[]),
                k=[-1,1]),opt=[[optwf],[optsurf]]),
        view=[-1..1,-1..1,-1..1], orientation=[50,75,0]);

 

Download cylindrical.mw

I used a solid Pink above for the color of the gridlines, but you could change that to color=u so that they were colored by angle (or whatever other radial function you prefer). That covers one of your queries, it seems. For example,

restart;

with(plots):

optwf := grid=[23,70], style=wireframe, color=u, thickness=3:
optsurf := grid=[70,70], style=surface, transparency=0.7, color=u:

ee := evalc(Re(sqrt(x+I*y))):

ff := simplify(eval(ee,[x=v*cos(u),y=v*sin(u)])) assuming real:

display(seq(seq(plot3d([v*cos(u), v*sin(u), k*ff],
                       u=0..2*Pi, v=0..4, opt[]),
                k=[-1,1]),opt=[[optwf],[optsurf]]),
        view=[-1..1,-1..1,-1..1]);

 

Download cylindrical2.mw

I don't know why the transparency option isn't effective with fine granularity, eg. for small values.

It would be more useful if the "gridlines" could be rendered on a coarse grid but computed using the finer grid -- so that the surface and lines match.

If the grid dimensions are odd then the wireframe produced in other Answers (using cartesian coordinates especially, for this particular example) will not match the (finer grid) surface properly.

[edit] For your approach of drawing the curves manually (in lieu of wireframe grid lines), you could generate them in another coordinate representation (eg, theta and z), coloring them by a function of theta say, and then transform to the cartesian coordinate plot. That would also give you your radial or cylindrical lines with either being shaded by angle. I don't think that your expectation makes good sense: to compute and draw the lines in cartesian coordinates while expecting a mechanism for shading radially. If you want them shaded as a function of angle then use a suitable coordinate system.

The problem with literal subscripted names (and showassumed=1 for trailing tildes) occurs with the extended typesetting level.

It apparently does not occur in my Maple 2019.2 for standard typesetting level. So that may be another workaround, see attached: assumed_literalsubscript.mw

The behavior seems to involve complicated interplay between the GUI and the Library Typesetting.

You need to specify which property of the ListBox you're trying to set. The property value denotes the selected item.

Eg,
   SetProperty("ListBox0", itemlist, convert(DataSet[..,1],list));
   SetProperty("ListBox0", value, DataSet[2,1]);
   SetProperty("ListBox0", value, DataSet[1,1]);

Also, load the package using with as a command, without any space before the opening bracket (or else it will be parsed as implicit multiplication in 2D Input mode). Or utilize the long form, eg.
   DocumentTools:-SetProperty("ListBox0", value, DataSet[1,1]);

LB.mw

There are various ways to accomplish this, depending on whether you want to be able to utilize expression form versus operator form.

restart;

points :=  <<0.4000|  10.0000>, <0.7000|   10.0000>,
            <1.0000|  10.0000>, <0.3000|   30.0000>,
            <0.4000|  30.0000>, <0.5000|   30.0000>>:

Data := <0617,0767,0220,0444,0692,0789>*0.001:

intmethod := LinearInterpolation:

g := Interpolation[intmethod](points(1..-1,1),Data):

g(sqrt(2)/2); # observe

Error, (in ModuleApply) unable to store '(1/2)*2^(1/2)' when datatype=float[8]

g(evalf(sqrt(2)/2)); # observe

HFloat(0.7540419693099999)

plot(g(x),x=0..1, size=[400,200]);

e := x/sqrt(2);

(1/2)*x*2^(1/2)

G := unapply('g'('evalf'(x)),x,numeric):

G(e);

G((1/2)*x*2^(1/2))

g(1), G(1);

HFloat(0.21999999999999997), HFloat(0.21999999999999997)

G(sqrt(2)/2);

HFloat(0.7540419693099999)

F := 5+G(e)*x^2;

5+G((1/2)*x*2^(1/2))*x^2

eval(F, x=1);

HFloat(5.75404196931)

plot(F, x=0..0.1, size=[400,200]);

Optimization[Minimize](F, x=0 .. 1);

[HFloat(4.999958234488289), [x = HFloat(0.040873203060322515)]]

 

Here are some other ways...

 

f1 := unapply(5+'g'('evalf'(e))*x^2,x,numeric):
f1(1);
f1(x);

HFloat(5.75404196931)

f1(x)

plots:-display(Array([
  plot(f1, 0..0.1), plot(f1(x), x=0..0.1) ]), size=[400,200]);

 

 

 

 

 

Optimization[Minimize](f1(x),x=0 .. 1);
Optimization[Minimize](f1, 0 .. 1);

[4.99995823448829, [x = 0.408732030603225e-1]]

[HFloat(4.999958234488289), Vector[column](%id = 18446884277741824710)]

#plots:-display(Array([
#  plot(f1, 0..1), plot(f1(x), x=0..1) ]), size=[400,200]);

f2 := proc(xx) if not xx::numeric then return 'procname'(args); end if;
                     5+g(evalf(eval(e,x=xx)))*xx^2;
            end proc:
f2(1);
f2(x);

HFloat(5.75404196931)

f2(x)

plots:-display(Array([
  plot(f2, 0..0.1), plot(f2(x), x=0..0.1) ]), size=[400,200]);

 

 

 

 

 

Optimization[Minimize](f2(x),x=0 .. 1);
Optimization[Minimize](f2, 0 .. 1);

[4.99995823448829, [x = 0.408732030603225e-1]]

[HFloat(4.999958234488289), Vector[column](%id = 18446884277732910134)]

#plots:-display(Array([
#  plot(f2, 0..1), plot(f2(x), x=0..1) ]), size=[400,200]);

ee := unapply('evalf'(x/sqrt(2)),x,numeric):

f3 := unapply(5+'g'(ee(x))*x^2,x,numeric):
f3(1);
f3(x);

HFloat(5.75404196931)

f3(x)

Optimization[Minimize](f3(x), x=0 .. 1, method=branchandbound);
Optimization[Minimize](f3, 0 .. 1, method=branchandbound);

[4.99995823448829, [x = 0.408731898269163e-1]]

[HFloat(4.999958234488289), Vector[column](%id = 18446884277725040262)]

 

``

Download convert_interpolation_object_ac.mw

Are you trying to change your setup so that input as in 1D plaintext Maple Notation in a Worksheet (which happens to default to red input)? Carl's Answer shows how to accomplish that.

Or are you trying to change the color of typeset 2D Input from default black to red (in your choice of Document or Worksheet)? If that is your situation then use the main menubar and select,
   Format -> Styles...
then in the popup scroll down and select
   2D Input
then in that popup push the button
   Create Character Style
and in the next popup push the Color button.

If you modify some such aspect of the Style then you can also make that Style set as default moving forwards in new sheets, using Format -> Manage Style Sets...

See also the Help page with Topic
   worksheet,documenting,characterstyles

Apparently it relates to whether the floating-point exponent in a call to `^` matches the type of the base.

It seems to work if the float exponents are cast to complex floats. I got the "expected" result in either of these ways:
1) instead of exponents like 1/beta I used Complex(1/beta,0.0) , and similarly for the others
or,
2) I specified the procedure's parameters alpha and beta as complex(float) rather than float.

I consider this a  bug, and will submit a report

note: I think that your code and operations could be simplified, with several steps combined, etc. I haven't done any of that.

restart; kernelopts(version); interface(version)

`Standard Worksheet Interface, Maple 2019.2, Linux, November 26 2019 Build ID 1435526`

NULLNULL

Erealm := Array([1235.773, 1383.61, 1457.262, 1500.264, 1550.184, 1612.161, 512.7612, 656.6554, 743.6461, 793.375, 855.7937, 939.1199, 79.9523, 128.1375, 167.1459, 193.592, 230.5401, 287.8348, 22.389, 29.41424, 35.91883, 40.86366, 48.79128, 63.4475, 15.34275, 17.10101, 18.63288, 19.77424, 21.5671, 24.84739, 13.8321, 14.52843, 15.07626, 15.47014, 16.07713, 17.16574, 13.13383, 13.63704, 13.95888, 14.16849, 14.46123, 14.93971, 12.76736, 13.2203, 13.50072, 13.673, 13.89852, 14.23242], datatype = float[8]); LFm := Array([.156795, .1248161, .1108722, .1032334, 0.9474591e-1, 0.8496174e-1, .361361, .3020133, .2706018, .2546556, .2356126, .2121333, .6883826, .6532309, .6155578, .5906291, .5578895, .5123917, .394458, .5326358, .6095816, .6489291, .6894866, .7232845, .1456468, .2226473, .2826954, .3228541, .3789496, .4632182, 0.6758032e-1, 0.9437384e-1, .1198126, .1387971, .1680719, .2181531, 0.5173809e-1, 0.586771e-1, 0.6591736e-1, 0.7206892e-1, 0.8243504e-1, .1024519, 0.457877e-1, 0.493836e-1, 0.5191291e-1, 0.539114e-1, 0.5708074e-1, 0.6330242e-1], datatype = float[8]); maxx := ArrayNumElems(LFm); E0 := 13.; E00 := 4200.; alpha := .5; beta := 0.7e-1
``

NULL

SoS := proc (E0::float, E00::float, alpha::(complex(float)), beta::(complex(float)), maxx::integer, Erealm::(Array(datatype = float[8])), LFm::(Array(datatype = float[8])))::float; local k, omegatau, Ecomplex, Erealc, Eimagc, LFc, sos; sos := 0.; for k to maxx do Ecomplex := Complex(Erealm[k], Erealm[k]*LFm[k]); omegatau := abs(-I*(((E0-E00)/(Ecomplex-E00))^(1/beta)-1)^(1/alpha)); Erealc := Re(E00+(E0-E00)/(1+(I*omegatau)^alpha)^beta); Eimagc := Im(E00+(E0-E00)/(1+(I*omegatau)^alpha)^beta); LFc := Eimagc/Erealc; sos := sos+(log10(Erealm[k])-log10(Erealc))^2+(LFm[k]-LFc)^2 end do; return sos end proc

SoS(E0, E00, alpha, beta, maxx, Erealm, LFm)

HFloat(0.015392438292813794)

cSoS := Compiler:-Compile(SoS); cSoS(E0, E00, alpha, beta, maxx, Erealm, LFm)

0.153924382465951241e-1

NULL

NULL

Download Compile_proc_ac.mw

You assigned the result to cSos.

You then tried to call cSoS.

Note the capitalization.

 

I am surprised that the VolumeOfRevolution command doesn't accept options to specifiy the initial and end angles.

Anyway, for fun,

restart;
with(Student:-Calculus1):
with(plots):
kernelopts(opaquemodules=false):
foo:=eval(VolumeOfRevolution:-ModuleApply):
animate(A->subs(2*Pi=A,eval(foo))(cos(x)+1,x=0..4*Pi,output=plot),
        [A],A=0..2*Pi,paraminfo=false);

 

Here are attached two more ways.

One uses Explore, since the regular animation frames can be heavy on GUI resources.

Another gets an animated effect by calling Tabulate within a loop. I include this because by various tricks it allows a long 3D plot to be displayed (scaled) without all the usual empty white space above and below.

QuestionAnimationVolumeOfRevolution_ac.mw

The following will export the plot to a file p1.png

You can choose other formats (eg, gif, bmp).

You can utilize the cat command to form the filename (including some location in your filesystem). If you utilize a relative path in the filename, or just a simple filename like the example below, then it will use currentdir() as the base location.

The inline setting puts things back to normal, where plots get displayed in the GUI.

restart;
P:=plot(sin(x),x=0..Pi):
plotsetup(png, plotoutput = "p1.png"):
print(P);
plotsetup(inline):
print(P);

See the Help page for topic plotsetup . And alternative is to use the Export command, which also has a help page with a plotting example.

You don't have to use the use the print command for code at the top-level. But that's what you'd want if running this inside a procedure.

And, of course, you don't also have to output the plot in the GUI as in the last line of the example above (since that's problematic for you).

Whether this solves your problem will depend on whether it really was due only to the inline rendering of the plots.

Up until Maple 2015.2 I get,

  piecewise(1 <= n and n < 10,2^(1-n)*product((-1)^n0*(n0^2+n0-90)/(n0+1),n0 = 1 .. n-1),0)

And from Maple 2016.0 up to Maple 2019.2 I get that unfortunate result.

However,

restart;

kernelopts(version);

`Maple 2019.2, X86 64 LINUX, Nov 26 2019, Build ID 1435526`

eqa := x(n) = x(n-1)*(9+n)*(10-n)*(-1)^n/(2*n);

x(n) = (1/2)*x(n-1)*(9+n)*(10-n)*(-1)^n/n

H := rsolve({eqa,x(1)=1},x(n)) assuming n::integer;

H := piecewise(1 <= n and n < 10, -(n+1)*(n+2)*(n+3)*(n+4)*(n+5)*(n+6)*(n+7)*(n+8)*(9+n)*(-1)^(n+(1/2)*n^2)*2^(-n)*exp(-(I*(1/2))*n*Pi)/(45*GAMMA(10-n)), 0)

seq(H,n=1..12);

1, 22, -308, -3003, 21021, 105105, -360360, -765765, 765765, 0, 0, 0

convert(simplify(evalc(rsolve({eqa,x(1)=1},x(n)))),factorial) assuming n::integer;

piecewise(n < 1, 0, n < 10, -2^(-n)*(n+1)*(n+2)*(n+3)*(n+4)*(n+5)*(n+6)*(n+7)*(n+8)*(9+n)*(-1)^((1/2)*n*(n+1))/(45*factorial(9-n)), 10 <= n, 0)

 

Download rsolve_hmm.mw

It seems weird, to be calling rsolve with such an assumption.

 

 

If I enter the word permute in the Help search then the top result is for the command combinat:-permute.

That returns the permutations of a list.

But that Help pages also has a cross-reference to the parent combinat package, whose page shows links to numbperm, nextperm, etc.

 

 

The functionality to specify the format of the float in the labels is a good idea. It would be nice to be able to specify that in the Explore call, for each parameter if relevant. (I will submit a Software Change Request.)

The following surgery on Explore alters the hard-coded numeric formatting for those labels. This might go in your personal initialization file, if it suffices for you. If you really need more flexibility I could make it utilize an environment variable, so that you could adjust it dynamically.

restart;

__KO:=kernelopts(opaquemodules=false):
try
  __KK:=ToInert(eval(Explore:-Runtime:-Update)):
  unprotect(Explore:-Runtime:-Update):
  Explore:-Runtime:-Update:=FromInert(subsop([5,3,4,1,1,2,1,2,3]
    =subs("%.3g"="%.2f",op([5,3,4,1,1,2,1,2,3],__KK)),__KK)):
catch:
  protect(Explore:-Runtime:-Update):
  kernelopts(opaquemodules=__KO):
end try:

Explore(plot(1/10*x^2+a,x=0..10,view=10..23), a=10.5 .. 11.5);

Or you could edit the above to utilize, say, "%.3f" instead of "%.2f", or something else of your choice for the sprintf format string.

Explore_label_format.mw

Of course the optimal solution would be for each parameter's label in each separate exploration to be able to retain its own independent formatting specification.

restart;

kernelopts(version);

`Maple 2015.2, X86 64 LINUX, Dec 20 2015, Build ID 1097895`

P1 := Sum(a*X[n]+b, n=1..N);

Sum(a*X[n]+b, n = 1 .. N)

subs(sum=Sum,expand(value(P1)));

N*b+a*(Sum(X[n], n = 1 .. N))

restart;

P2 := Sum(X[n]+Y[n], n=1..N);

Sum(X[n]+Y[n], n = 1 .. N)

# This alone will work in Maple 2019, but not your Maple 2015
expand(P2);

Sum(X[n]+Y[n], n = 1 .. N)

# This alters how `expand` works on sums
with(student):

expand(P2);

Sum(X[n], n = 1 .. N)+Sum(Y[n], n = 1 .. N)

restart;

P2 := Sum(X[n]+Y[n], n=1..N);

Sum(X[n]+Y[n], n = 1 .. N)

EX := S->subsindets(S,And(specfunc({sum,Sum}),
                           satisfies(u->type(op(1,u),`+`))),
                    u->`+`(map(op(0,u),[op([1,..],u)],op(2..,u))[])):

EX(P2);

Sum(X[n], n = 1 .. N)+Sum(Y[n], n = 1 .. N)

 

Download sum_stuff.mw

Are you looking primarily for a way to manually resize (after embedding), or a programmatic way?

The Explore command itself accepts a size option. You haven't mentioned that, so perhaps you are as yet unaware of that? Eg,


    Explore(plot3d(sin(a*x)*y^2,x=-Pi..Pi,y=-1..1),
                  a=1..2.0,size=[600,600]);

The Explore command uses Embedded Components, and in particular it uses a Plot Component to contain the rendered plot. It is true that this component does not have mouse-pointer "resize handles". But you can adjust the width and height properties of that component, after the exploration is embedded in the Worksheet/Document.

For example, using the mouse-pointer, you can do this (Maple 2019), to change the dimension of the Plot Component:
   - Open the context-panel
   - left-click in the plot itself (It has to be within the Plot Component, and not its surroundings. Getting it slightly off will show properties for some surrounding component, which by your description seems to have been key.)
   - Adjust the "Width in pixels" and "Height in Pixels" context-panel

In versions that predate the context-panel you can right-click on the plot and get the context-menu for the Plot Component. Choose Component Properties, and adjust the two relevant fields in the popup. 

[edited] It is true that plot3d does not accept the size option. If it did then Explore would act like it does for the 2D plot command, and utilize that for the dimensions of the component. Indeed, this does work too,

   Resize:=proc(P,m::posint,n::posint)
      op(0,P)(op(P),ROOT(BOUNDS_X(0),BOUNDS_Y(0),
                   BOUNDS_WIDTH(n),BOUNDS_HEIGHT(m)));
   end proc:


    Explore(Resize(plot3d(sin(a*x)*y^2,x=-Pi..Pi,y=-1..1),600,600),
                   a=1..2.0);

That Resize procedure also works for displaying 3D plots outside of Explore. (You could add it to a personal initialization file.)

I came up with a "hot fix" that allows 3D plotting commands to accept the size option. I'll try to find a moment to share it.

First 135 136 137 138 139 140 141 Last Page 137 of 336