acer

32358 Reputation

29 Badges

19 years, 331 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Using the menubar, select to View -> Show/Hide Contents...  and in the popup dialogue that appears toggle off Execution Group Boundaries.

Note this is a property of the Worksheet itself, rather than a global setting. Which means when the sheet is saved it retains the property when re-opened (by you or someone else). It also won't affect other newly opened sheets. 

restart;

 

simplify( [solve({x=r*cos(theta), y=r*sin(theta)}, {r,theta},
                 explicit, useassumptions)] )[]
   assuming x::real, y::real, r>0;

{r = (x^2+y^2)^(1/2), theta = arctan(y, x)}

restart;

 

simplify( [solve({r>0,x=r*cos(theta), y=r*sin(theta)}, {r,theta},
                 explicit, useassumptions)] )[]
   assuming x::real, y::real;

{r = (x^2+y^2)^(1/2), theta = arctan(y, x)}

 


Download solve_r.mw

For AudioTools:-Preview to recognize a float[8] Array as an audio thing it has to have certain attributes.

In Maple 2017 the Statistics:-MovingAverage operation does not return an Array with the attributes of the original its input Array. But in Maple 12.02 that command did do that.

I don't really understand how a computation like that done by Statistics:-MovingAverage could sensibly just copy over values for audio qualities like sampling rate. Simply giving the same audio attributes to the returned result doesn't make much sense to me. Perhaps even more importantly, what about the case that someone has used atttributes to mean something else entirely, for which blind copying over of attributes bu MovingAverage might make no sense at all.

Perhaps audio things could be implemented as objects. Then their data could be extracted on demand, but it'd be more obvious that manipulations of such data would then just be Arrays of revised data, and not new audio objects per se.

You could put the attributes of a onto d, or you could apply the AudioTools:-Create command to d to set its audio attributes. You may need to think about what values to use.

restart;

kernelopts(version);

`Maple 2017.3, X86 64 LINUX, Sep 27 2017, Build ID 1265877`

with(AudioTools):
with(Statistics):

a:=Read(cat(kernelopts(datadir),"/audio/ding.wav"));

a := Vector(4, {(1) = ` 1 .. 20191 `*Array, (2) = `Data Type: `*float[8], (3) = `Storage: `*rectangular, (4) = `Order: `*C_order})

b:=ToMono(a): #changing to Mono.
c:=b^2: #squaring the signal.

d:=MovingAverage(c,30):

attributes(a);

22050, 16, 1

attributes(d); #NULL

setattribute(d,attributes(a)):
attributes(d);

22050, 16, 1

Preview(d);

dd:=Create(d,rate=22050);
attributes(dd);

dd := Vector(4, {(1) = ` 1 .. 20162 `*Array, (2) = `Data Type: `*float[8], (3) = `Storage: `*rectangular, (4) = `Order: `*C_order})

22050, 16, 1

Preview(dd);

 


audio_prev.mw

Computations are performed on the local computer than is running Maple.

(There are some very uncommon and specials ways to communicate with other machines/servers, but it has to be done purposefully and many people would not even know how. So, to a practical extent: all computations executed in your standard Maple program will be computed locally.)

As for indications of progess, well that depends very much on what kind of computation. And you've told us nothing about the particulars.

Is it a computation done by a procedure (not just a document) written by you? If so then you can inject periodic messaging code into it, in several different ways.

For quite a few Maple stock commands you can also adjust the infolevel setting, to get some progress notes. Note that the extent of such detail varies quite a bit, from command to command.

There are also ways to get Maple to plaster your screen with almost all that its doing at the interpreted Library code level. But this is usually so overwhelming that its not helpful.

 

This can be controlled manually using the the Typesetting:-RuleAssistant popup, or programmatically using the Typesetting:-Settings command.

This setting is not saved as part of the Worksheet/Document, nor can it saved as a global preference.

But you can hide preliminary calls to commands Typesetting:-Settings in the Startup Code region of the sheet, and so get such settings to be specific to the particular sheet.

restart;

Typesetting:-Settings(useprime); # default

true

diff(f(x), x)

diff(f(x), x)

Typesetting:-Settings(useprime=false):

diff(f(x), x)

`#msup(mi("f"),mo("'"))`

lprint(%);

`#msup(mi("f"),mo("'"))`

kernelopts(version);

`Maple 2017.2, X86 64 LINUX, Jul 19 2017, Build ID 1247392`

 


Download primediffparsing.mw

If you change that to Shutdown("0") then the return value wil be the string "0" upon Cancel (and, as you've implemented the other button, a list containing the selected filename string otherwise).

Assign the return value directly to say f1, and leave indexing into it until after you've tested whether it is "0".

You can just check evalb(f1="0") and then return/break/next/stop/end/etc as you wish. If it isn't then you can index into it like f1[1], etc, to get at the filename.

You can use subsindets and type anyfunc or type specfunc to find and act directly upon (ie. freeze) all those subexpressions which you don't want to be combined.

For example, excluding any function of alpha or beta,

thaw(combine(subsindets( expr, anyfunc(identical(alpha,beta)), freeze)));

Or, restricting it to just a few particular functions such as any combination of sin or cos of alpha or beta,

thaw(combine(subsindets( expr, specfunc(identical(alpha,beta),{sin,cos}), freeze)));

For handling an explicit (and small, say) list of items to exclude the choice is a matter of personal preference, I'd say. I find that I usually reach for subsindets so that I have less editing to do if I want to switch from a fixed list to more encompassing type. For example, to work on expression expr,

L:=[cos(beta),sin(alpha)]:
thaw(combine(subs(((x->x)=freeze)~(L),expr)));
thaw(combine(eval(expr,((x->x)=freeze)~(L))));
thaw(combine(eval(expr,(x->x=freeze(x))~(L))));
thaw(combine(subsindets(expr,identical(op(L)),freeze)));

I pointed out a new bug in the parsing of 2D Input, new to Maple 2017, on Sept 7th, 2017 in another thread on Mapleprimes.

There is a new problem in that infix arithmetic operations are being parsed to prefix function calls. For your example done in 2D Input Maple compute the float reciprocal of the denominator first, and then multiplies the numerator by that preliminary result.

Of course, compared to using proper float division, that new behavior can violate the expected behavior of attaining no more then 0.6 ulps error for the atomic floating-point arithmetic operation.

I recall that the rules for when this happened for 2D Input infix arithmetic operations, or not, were all over the map.

I submitted at least two bug reports related to it, at that time. (The bug report submitted approximately Sept 7th did not make it to a fix for the 2017.3 point release of Oct 3rd.)

I'll note that your Question's input appears to be in 1D Notation input. But you also indicated that it made a difference whether you were in a Document of Worksheet. It may be that the disctinction occurs, say, between a Document Block and a plain Execution Group. It would help if you uploaded your document as an attachment rather than just inlining images input in your Comments.

If you are passing a list of expressions to plot then you can also pass a list for the legend option. Eg,

exprs:=[sin(x), cos(x), sqrt(x)*sin(x)];

plot(exprs, x=0..6, legend=exprs);
Here are a few different ways:

restart;

sys:={x^2 + y^2 + z^2 = 4, x + y + z = 0, x*sin(y*z) = -1}:


After inspecting the implicit plot (Kitonum's idea) we could call
fsolve using restricted ranges for y.

fsolve(sys, {x,y,z}, {y=0.8..1});

{x = -1.630958259, y = .8860579420, z = .7449003167}

fsolve(sys, {x,y,z}, {y=0..0.8});

{x = -1.630958259, y = .7449003167, z = .8860579420}

restart;

sys:={x^2 + y^2 + z^2 = 4, x + y + z = 0, x*sin(y*z) = -1}:


It turns out that fsolve (with its avoid option) can find two roots for
the restriction that comes from eliminating x.

T:=eliminate(sys,{x});

[{x = -y-z}, {-sin(y*z)*y-sin(y*z)*z+1, 2*y^2+2*y*z+2*z^2-4}]

S1:=fsolve(T[2], {y,z});
ans1:=S1 union eval(T[1],S1);

{y = .7449003167, z = .8860579420}

{x = -1.630958259, y = .7449003167, z = .8860579420}

S2:=fsolve(T[2], {y,z}, avoid={S1});
ans2:=S2 union eval(T[1],S2);

{y = .8860579420, z = .7449003167}

{x = -1.630958259, y = .8860579420, z = .7449003167}

kernelopts(version);

`Maple 2017.3, X86 64 LINUX, Sep 27 2017, Build ID 1265877`

 

Download sys_fsolve.mw

[edit] Having obtained a solution, there will be another with values for y and z interchanged (due to symmetry).

sys:={x^2 + y^2 + z^2 = 4, x + y + z = 0, x*sin(y*z) = -1}:

evalb( eval(sys, [y=z,z=y]) = sys );

                    true

So swapping values for y and z is another way to get a second solution.

One way (without re-doing your whole approach) is to use the select command to take only the real roots, before calling max.

In the attachment I've done that for all the solve calls (though some may not have needed it, returning purely real roots, according to the particular equations passed).

mathias_1_M18.mw

You don't need the assumption, for these to work. It is true for any n.

restart;

expr:=exp(-n*ln(2*Pi));

exp(-n*ln(2*Pi))

simplify(expr,exp) assuming n::nonnegint;

(2*Pi)^(-n)

restart;

assume(n >= 0, n::integer);

simplify(exp(-n*ln(2*Pi)), exp);

(2*Pi)^(-n)

 


Download simplify_exp.mw

This kind of call to simplify is called simplify with side-relations.

simplify( log[1/3](x)-log[sqrt(3)](x^2)+log[x](9), {log[3](x)=a} ) assuming x>0;

                      2
                  -5 a  + 2
                  ---------
                      a

That works in Maple 2015, 2016, and Maple 2017. In earlier versions it also needs a wrapping call to (at least) normal.

You need to figure out what you mean by raising to power 1/p, since the quantity that you're raising to that power may be negative.

You have at least these three choices of interpretation:
1) Using the principle pth root, you'll get nonzero imaginary results when the radicand is negative.
2) Using the surd concept (eg. after conversion of 1/p=1/0.15 to 1/p=20/3)
3) Using the absolute value of the integral.

We cannot tell you which interpretation you are looking for.

For 1) and 2) you'll need to specify a looser accuracy option on the numerical integration.

int_pthroot.mw

The Statistics:-Biplot command uses the plots:-arrow command, not the plottools:-arrow command.

So instead of options wb, wh, hh you could use options width, head_width, head_length, etc.

 

First 187 188 189 190 191 192 193 Last Page 189 of 336