acer

17443 Reputation

29 Badges

14 years, 149 days

On google groups. (comp.soft-sys.math.maple and sci.math.symbolic)

On stackoverflow.

On math.stackexchange.com.

MaplePrimes Activity


These are answers submitted by acer

The AudioTools package was introduced in Maple 10 (2005). So it should work in your Maple 12.

restart;
with(AudioTools):

# A[6] 1760.00 Hz
A := Create(duration=2.0, rate=44100,
            x->evalhf(sin(x*2*Pi*1760.00/44100))):
Write(cat(kernelopts(homedir),"/mapleprimes/sampA.wav"), A):

# B[6] 1975.53 Hz
B := Create(duration=2.0, rate=44100,
            x->evalhf(sin(x*2*Pi*1975.53/44100))):
Write(cat(kernelopts(homedir),"/mapleprimes/sampB.wav"), B):

# A[4] 440.00 Hz
A440 := Create(duration=2.0, rate=44100,
            x->evalhf(sin(x*2*Pi*440.00/44100))):
Write(cat(kernelopts(homedir),"/mapleprimes/sampA440.wav"), A440):

As you can see this is very straightforward. Producing, say, B[4] = 493.88 Hz is done similarly.

And of course you could also write a 1-line procedure that took a frequency as an argument and generated the corresponding pure tone.

Using the App Centre link you gave (with its code from the year 2000 using writebytes, convert, and much Library level code) seems unnecessarily much more complicated, and quite possibly slower and less robust.

L1:=[a,b]:

`/`(op(L1));

                 a/b

L2:=[a,b,c,d]:

`/`(op(L2));

                   a
                 -----
                 b c d

It looks like you're trying to compute something simple (like, say, the min or max real root of some cubics). But you have not provided a clear description of your goal. And your worksheet contains weird unreferenced expressions and parameters, as if part of your inputs were copy&pastes.

Trying to deal with symbolic expressions representing roots (and which contain explicit radicals) by calling solve on a cubic with float coefficients will lead to numeric roundoff error upon subsequent floating point evaluation. That includes the case involving substituition for parameter sigma. One consequence is that the purely real root(s) may be hidden behind nonzero imaginary float artefacts. Even the fact that a cubic has at least one real root may be obscured by this unsound technique.

Here's my guess as to what you're trying to accomplish, using fsolve.

In the following attachment I break up the plotting in order to force use of the value of sigma where the discriminant (with respect to a) of the first cubic changes sign. This allows the curves of two of the "roots" to match up.

restart

interface(warnlevel = 0)

R := proc (ee, s, i) local res; options remember, system; if not s::numeric then return ('procname')(args) end if; res := [fsolve(eval(ee, sigma = s))]; if i <= nops(res) and 0 < res[i] then res[i] else Float(undefined) end if end proc

eq := sigma = 1.004210973*a^2+0.1634980569e-2/a

new := (rhs-lhs)(expand(a*eq))

1.004210973*a^3+0.1634980569e-2-a*sigma

cutoff := fsolve(discrim(new, a))

0.2626543768e-1

P1a := plot([R(new, s, 1), R(new, s, 2), R(new, s, 3)], s = -.2 .. cutoff, size = [500, 400], axes = box, color = black); P1b := plot([R(new, s, 1), R(new, s, 2), R(new, s, 3)], s = cutoff+1.0*10^(-Digits+1) .. 1.2, size = [500, 400], axes = box, color = black)

eq2 := sigma = 1.004210973*a^2-0.1634980569e-2/a

new2 := (rhs-lhs)(expand(a*eq2))

1.004210973*a^3-0.1634980569e-2-a*sigma

P2 := plot([R(new2, s, 1), R(new2, s, 2), R(new2, s, 3)], s = -.2 .. 1.2, size = [500, 400], axes = box, color = black)

plots:-display(P1a, P1b, P2)

 

Download cposfsolvediscrim.mw

Here is an earlier attempt using fsolve, which did not force use of the value for sigma where the discriminant changed sign. Notice the hole in the curves where two of the "roots" to not quite match up.
Download cplotposfsolve.mw

Here is an attachment that plots all the roots (not just a>0), using indexed RootOfs.
Download cplot.mw

Here is a related way to obtain the plot of only the positive roots, using the indexed RootOfs. (This is slower than the above way, using fsolve, I believe.) 

Download cplotpos.mw

The very last 2D Input equation in subsection Projektioner is invalid (corrupted, in the sense that the stored base64 encoded .m represents a blob of Typesetting calls that are not validly displayable).

But I believe that the following attachment contains everything else, recovered. Please check.

recovered_ac.mw

(My attachment above was saved in Maple 2019.1. Just in case there's any issue, here also is the original attachment by the OP, with only the offending XML Equation manually removed from the .mw file. raw_edited_ac.mw )

[edited]
Note, sometimes when the GUI has collapsed everything to a single line then formatting can be recovered by doing the main menubar actions View->Sections->Collapse All Sections followed by View->Sections->Expand All Sections. For the OP's corrupted original that doesn't fix everything, as the invalid 2D Input instance makes the GUI go wrong still.

The problematic 2D Input instance is decoded here. errantTS.mw

If I attempt to form a similar invalid 2D Input typeset column Vector (with simply a minus sign in one entry) then the GUI indicates it's invalid but otherwise doesn't run amok. errant2D.mw So I don't know how to reproduce the bug. 

You're second to last line does t:=evalf(t[1]) but before that `t` is not something which can be indexed. So that line makes no sense.

And so what you're passing to fsolve is not a sensible expression.

Your Question is marked as Maple 2019, so I'll use that.

If I load the linkedlist module from a .mla Library Archive (including the one that resides within a workbook), or if I first savelib it to a .mla, then my output from your examples shows the long form linkedlist:-nil provided that I have the typesetting level set to standard.

If I toggle that level back to extended (ie. its original default for new users) then the output shows the short form nil only.

If I simply read the .mpl source then my output shows the short form nil regardless of typesetting level.

Perhaps this is the source of your problem.

nb. You can set the level as a GUI preference -- automatic across sessions. Or you can programmatically set it for an opened worksheet by issuing the command,
   interface('typesetting'=':-extended'):
in its own execution group.

nb. The level extended is the new default for new users. It behaves better than it did back when standard was the default. IMHO it may be generally best to use the default, unless there is some special cause.

I believe that it is not.

For a float Matrix the CharacteristicPolynomial command computes an unexpanded product, using the computed eigenvalues. (So it's mostly "ok" to compute the roots of that, but unnecessary since the Eigenvalues command computes that directly. It would be bad to expand the characteristic polynomial and then do numeric root-finding, because that is numerically less stable.)

What is also not a great idea is to compute the eigenvalues by doing numeric root-finding on the determinant of the characteristic matrix (which is what the OP's code does at one point), and which is what I suspect Carl is describing as unwise.

Additionally, if one happens to want singular values then utilize the SingularValues command. That can provide a numerically robust approach to PCA.

I'm not completely sure what form of answer you're looking for. Here's my guess as to what you may be after, given a polynomial system.

restart;

kernelopts(version);

`Maple 2019.1, X86 64 LINUX, May 21 2019, Build ID 1399874`

eqns := {-1+theta[3, 6] = 0, 1-theta[3, 6] = 0, alpha+rho-theta[2, 2]+theta[3, 3] = 0, -theta[3, 6]^2+1 = 0, theta[2, 2]*theta[3, 6]-alpha = 0, theta[2, 2]*theta[3, 6]^2-alpha = 0, -2*theta[3, 3]*theta[3, 6]-2*rho = 0, theta[1, 2]*theta[2, 1]*theta[3, 6]^2+1 = 0, -alpha^2+rho^2+theta[2, 2]^2-theta[3, 3]^2 = 0, -theta[2, 2]^2*theta[3, 6]+2*theta[2, 2]*theta[3, 3]*theta[3, 6]+alpha^2+2*alpha*rho = 0, -theta[1, 3]*theta[2, 2]^2*theta[3, 0]+theta[1, 3]*theta[2, 2]*theta[3, 0]*theta[3, 3]-alpha^2*beta-alpha*beta*rho = 0, -theta[1, 2]*theta[2, 1]*theta[2, 2]*theta[3, 6]+2*theta[1, 2]*theta[2, 1]*theta[3, 3]*theta[3, 6]-alpha-2*rho = 0, -theta[1, 2]*theta[2, 1]*theta[2, 2]*theta[3, 3]+theta[1, 2]*theta[2, 1]*theta[3, 3]^2+theta[1, 3]*theta[2, 2]*theta[3, 0]*theta[3, 6]+alpha*beta+alpha*rho+rho^2 = 0, -alpha^2*rho-alpha*rho^2+theta[1, 2]*theta[2, 1]*theta[2, 2]-theta[1, 2]*theta[2, 1]*theta[3, 3]+theta[1, 3]*theta[3, 0]*theta[3, 6]-theta[2, 2]^2*theta[3, 3]+theta[2, 2]*theta[3, 3]^2+alpha+beta+rho = 0}:

fc := {theta[1, 2], theta[1, 3], theta[2, 1], theta[2, 2],
       theta[3, 0], theta[3, 3], theta[3, 6]};

{theta[1, 2], theta[1, 3], theta[2, 1], theta[2, 2], theta[3, 0], theta[3, 3], theta[3, 6]}

PS1 := SolveTools:-PolynomialSystem(eqns, fc, backsubstitute=false, engine=triade);

[[theta[3, 0]*theta[1, 3]+beta, theta[1, 2]*theta[2, 1]+1, theta[3, 3]+rho, theta[2, 2]-alpha, theta[3, 6]-1], {theta[1, 2] <> 0, theta[3, 0] <> 0}]

PS1[1]=~0;

[theta[3, 0]*theta[1, 3]+beta = 0, theta[1, 2]*theta[2, 1]+1 = 0, theta[3, 3]+rho = 0, theta[2, 2]-alpha = 0, theta[3, 6]-1 = 0]

map(u->`if`(u::`+`,`=`(selectremove(has,u,fc)),u),PS1[1]);

[theta[3, 0]*theta[1, 3] = beta, theta[1, 2]*theta[2, 1] = 1, theta[3, 3] = rho, theta[2, 2] = -alpha, theta[3, 6] = -1]

 

Download solve_polysys.mw

Here's my original Answer, which accomplished a similar thing in a rough, manual sort of way,

solveQ.mw

The commands in DocumentTools, such as DocumentTools:-GetProperty, are for use in query properties of Embedded Components. Those are quite different and separate from Maplets.

You cannot use DocumentTools:-GetProperty to check whether a Maplets:-Elements:-CheckBox is toggled. Those do not interact, since Embedded Components and Maplets provide quite separate functionality.

If you really do plan on using Maplets, then in order to learn to use Checkbox from the Maplets:-Elements package you might start by studying basic examples, eg. online here, here, and here. Or you can read the corresponding Help pages within your Maple itself.

Or are you trying to use Embedded Components, rather than Maplets?

restart;

kernelopts(version);

`Maple 2019.1, X86 64 LINUX, May 21 2019, Build ID 1399874`

f1:=(-3*sin(8*x)+3*sin(8*x+2*y)-3*sin(8*x+6*y)+3*sin(8*y+8*x)
+3*sin(8*y+6*x)+3*sin(8*y)-18*sin(8*y+4*x)+3*sin(8*y+2*x)-45*sin(6*y+6*x)
+87*sin(4*y+6*x)-3*sin(6*x-2*y)-87*sin(6*x+2*y)+18*sin(4*x-4*y)
-93*sin(4*x+4*y)+93*sin(4*x+6*y)-51*sin(2*x-4*y)-342*sin(2*x+4*y)
-3*sin(-6*y+2*x)+51*sin(6*y+2*x)-93*sin(-2*y+4*x)+342*sin(-2*y+2*x)
+639*sin(2*x+2*y)-639*sin(2*x)+45*sin(6*x)+93*sin(4*x)+231*sin(4*y)
-225*sin(2*y)-63*sin(6*y)-57*sqrt(3)*cos(2*x)-375*sqrt(3)*cos(2*y)
+sqrt(3)*cos(8*y+8*x)-5*sqrt(3)*cos(8*x+6*y)-7*sqrt(3)*cos(8*y+6*x)
+sqrt(3)*cos(8*x)+192*sqrt(3)*cos(2*y+4*x)+43*sqrt(3)*cos(-2*y+4*x)
-7*sqrt(3)*cos(6*x+2*y)+7*sqrt(3)*cos(-6*y+2*x)-5*sqrt(3)*cos(6*y)
-149*sqrt(3)*cos(4*x+4*y)-149*sqrt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7*y)
+639*sin(y)-9*sin(3*y+8*x)-12*sin(6*x-y)+3*sin(7*y)-9*sin(7*y+2*x)
+9*sin(-5*y+2*x)+48*sin(6*x+y)+36*sin(4*x-y)-126*sin(2*x-3*y))):

expand(convert(numer(f1),exp)):
P1:=factor(numer(%))/denom(%);

(1/8192)*(-3*I+3^(1/2))*(I*3^(1/2)-2*exp(I*y)*exp(I*x)-1)*(I*3^(1/2)+2*exp(I*y)*exp(I*x)-1)*(I*3^(1/2)+2*exp(I*x)+1)*(I*3^(1/2)-2*exp(I*x)+1)*(-2*exp(I*y)-I+3^(1/2))*(2*exp(I*y)-I+3^(1/2))*(I*(exp(I*x))^2*3^(1/2)-2*(exp(I*x))^2*(exp(I*y))^2-I*3^(1/2)+(exp(I*x))^2+1)^3*(I*(exp(I*y))^2*3^(1/2)-2*(exp(I*x))^2*(exp(I*y))^2-I*3^(1/2)+(exp(I*y))^2+1)^3/((exp(I*y))^8*(exp(I*x))^8)

expand(convert(denom(f1),exp)):
P2:=(factor(numer(%))/denom(%));

-(1/512)*3^(1/2)*(I*3^(1/2)+2*exp(I*y)*exp(I*x)-1)*(I*3^(1/2)-2*exp(I*y)*exp(I*x)-1)*(I*3^(1/2)+2*exp(I*x)+1)*(I*3^(1/2)-2*exp(I*x)+1)*(I*(exp(I*x))^2*3^(1/2)-2*(exp(I*x))^2*(exp(I*y))^2-I*3^(1/2)+(exp(I*x))^2+1)^3*(I*(exp(I*y))^2*3^(1/2)-2*(exp(I*x))^2*(exp(I*y))^2-I*3^(1/2)+(exp(I*y))^2+1)^3/((exp(I*y))^7*(exp(I*x))^8)

K:=convert(simplify(evalc(expand(P1/P2))),phaseamp,y);

sin(y+(1/6)*Pi)

Download simptrigexample.mw

[edit] I see that others have responded since I last refreshed this webpage in my browser (which I did only after I posted my answer). So, taking the OP's hint, I can reduce the number of steps in my original answer, by avoiding my previous separation of numerator and denominator,

convert(simplify(evalc(evala(expand(convert(f1,exp))))),
        phaseamp,y);

                            /    1   \
                         sin|y + - Pi|
                            \    6   /
convert(simplify(evalc(radnormal(expand(convert(f1,exp))))),
        phaseamp,y);

                            /    1   \
                         sin|y + - Pi|
                            \    6   /

note: Simplifying the intermediate result immediately prior to these latter calls to evalc may illustrate that I'm using evalc primarily as a convenient shorthand for conversion to trig (and avoiding a division by zero), not because I'm trying to concede something about realness of y more generally).

You didn't tell us the aspect ratio (relative lengths displayed of the axes) that you wanted.

So you can try this, with a value for the parameter that suits you,

restart;

H:=K->plot3d(K*sech(1/2*sqrt(3/5)*(x - 2*t)),
             x=-10..10, t=-10 .. 10, style=patchnogrid,
             scaling=constrained,
             view=[-10..10, -10..10, K*0.0..K*1.0],
             tickmarks = [default, default,
                          Equate((L->[K*L,L][])([0., 0.5, 1.0]))]):

H(6);

H(12);

 

Download 3d_aspect_example.mw

This is simply a one-off of the idea I posted on more generally (but for 3D implicit plots) here.

You have previously installed the Syrup add-on package. It is bundled with a Help database file in the old .hdb format. The message is informing you of that.

You can convert that older format Help database Syrup.hdb to the newer format by following the instructions on the Help page whose topic is HelpTools,Migrate. The message is informing you that details are available on that Help page.

If you're not using the Syrup package's Help pages then you could simply ignore the message. If the message bothers you then you could remove the add-on or follow the instructions to update/migrate its help database file.

It is unclear whether you are asking about selected item or the action code of the Component. It's also unclear what you mean by "preprogrammed".

So I've done both for you, using two examples. If you're trying to ask about the selected item then my first example should make it clear. If you're trying to ask about the action code of the component then you can make it a string containing a procedure call of your choice (as I did in my second example), and you can define that procedure either before or after the insertion.

I've also fixed several mistakes.

ASK_ac.mw

I also toggled your Question as being for Maple 2016, since that's the version in which your attachment was last saved. It'd be helpful if you could do that yourself for future Questions.

You might be able to use something like this, for such (simple) ordered piecewise with a single parameter. I don't know whether you need to distinguish that the lower end-point is a strict inequality.

restart;

f := t -> piecewise(-1 < t and t <= 0, t+1,
                    0 < t and t <= 1/2, 1-t,
                    0 < t and t <= 1, 1-t):

pw := f(t);

pw := piecewise(-1 < t and t <= 0, t+1, 0 < t and t <= 1/2, 1-t, 0 < t and t <= 1, 1-t)

pwrng := PiecewiseTools:-Support(pw);

-1 .. 1

op(pwrng);

-1, 1

pwlist := convert(pw, list);

[-1 < t and t <= 0, t+1, 0 < t and t <= 1/2, 1-t, 0 < t and t <= 1, 1-t]

pwconds := seq(pwlist[2*(i-1)+1], i=1..nops(pwlist)/2);

-1 < t and t <= 0, 0 < t and t <= 1/2, 0 < t and t <= 1

solve( Or(seq(p, p=pwconds)), t );
lprint(%);

RealRange(Open(-1), 1)

RealRange(Open(-1),1)

 

Download pwsupport.mw

First 7 8 9 10 11 12 13 Last Page 9 of 201