acer

32490 Reputation

29 Badges

20 years, 8 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

You could arrange numbers in a heap according to size.

> h := heap[new](`<`, 4, 7, 19, 111, 2):

> heap[insert](17, h):

> while not heap[empty](h) do heap[extract](h); end do;
                                      111

                                      19

                                      17

                                       7

                                       4

                                       2

As for extracting them to a list, I presume that you want the list sorted (by the same boolean-valued function used by the heap). Note that, for a heap h stored in a table according to the scheme above, the element h[0] is the number of stored values while the element h[`<`] is the boolean valued function which compares/sorts them.

> h := heap[new](`>`, 4, 7, 19, 111, 2):
> sort([seq(h[i],i=1..h[0])],h[`<`]);
                              [111, 19, 7, 4, 2]

> h := (heap[new])(lexorder, greg, tony, bruno, michael):
> sort([seq(h[i],i=1..h[0])],h[`<`]);
                         [bruno, greg, michael, tony]

See here for some nice notes on efficient sorting of lists.

note: This stuff above involves heaps implemented as Maple tables. You also wrote that you wanted to implement a heap as a list. Do you really want to do that, as well, even though Maple lists are not efficient mutable data structures?

acer

I'm not really sure what you're trying to get.

> X := `<,>`(1, 2, 3):

> T := proc () K[1] end proc:

> S := proc (X::evaln) subs(K = ''X'', eval(T)) end proc:

> g:=S(X);
                          g := proc() 'X'[1] end proc

> g();
                                     X[1]

What is the "more complex case", and what do you wish for it?

acer

This seemed OK for me, in Maple 12.01 (on Linux). I didn't see quotes around the name, as with the typeset() solution.

Z:=(x,y,t)->plots[textplot]([x, y, Typesetting:-mover(Typesetting:-mi(convert(t,string)),Typesetting:-mo("→"))]):

Z(1,1,P);

The arrow symbol that you see there is actually "&rarr;" in case you wanted to type it in rather than cut 'n paste from here.

For some reason the above procedure (itself, its own body, not its output) would not print in the Standard GUI. That's a bug, but it shouldn't prevent one from actually using the procedure.

acer

Why not send the Matrix in as one of the arguments, have the procedure act on it "in-place". After it runs, the Matrix will have been updated by this process. The procedure could, say, return NULL.

acer

What is the characteristic equation here? Is it not r^2-b*r=0 where b=1? If so, then it has roots of 1 and 0. Your series is not stationary, but its first difference should be (because the only other root is 0). And if you take the difference s[i]-s[i-1] then you get just randd[i] which is from the normal sample itself. And you find that first difference to be stationary. Ok, fine.

I don't understand what the P() refers to, when you talk of "increasing the return". Also, you seem to have made two posts, the first which claims that you did not detect autocorrelation after the differencing s[i]-s[i-1], and the second which claims that you did. Could you explain that with more detail, and your expectation, please?

acer

What progress have you gotten with this so far?

What do you know about the RSA scheme? Can you write it out here, so that we know that you understand it? What variable's value(s) are you searching for, in it? What mathematical techniques do you think that you'll need to understand, to answer it? (Will it it be anything like those needed for this, or not?)

What number range and layout are you using for the alphabet of 95 printable ASCII characters (space=32 and tilde=126?)?

acer

> f := n -> Matrix(n+1,n+1,scan=band[1,1],[[a$n],[b$(n+1)],[c$n]]):

> f(4);
                            [b    c    0    0    0]
                            [                     ]
                            [a    b    c    0    0]
                            [                     ]
                            [0    a    b    c    0]
                            [                     ]
                            [0    0    a    b    c]
                            [                     ]
                            [0    0    0    a    b]


> subs([a=sin(x),b=cos(x),c=x^2],f(4));
               [             2                                ]
               [cos(x)      x         0         0         0   ]
               [                                              ]
               [                       2                      ]
               [sin(x)    cos(x)      x         0         0   ]
               [                                              ]
               [                                 2            ]
               [  0       sin(x)    cos(x)      x         0   ]
               [                                              ]
               [                                           2  ]
               [  0         0       sin(x)    cos(x)      x   ]
               [                                              ]
               [  0         0         0       sin(x)    cos(x)]

> (a,b,c):=sin(x),cos(x),x^2:
> f(4);
               [             2                                ]
               [cos(x)      x         0         0         0   ]
               [                                              ]
               [                       2                      ]
               [sin(x)    cos(x)      x         0         0   ]
               [                                              ]
               [                                 2            ]
               [  0       sin(x)    cos(x)      x         0   ]
               [                                              ]
               [                                           2  ]
               [  0         0       sin(x)    cos(x)      x   ]
               [                                              ]
               [  0         0         0       sin(x)    cos(x)]

acer

Does this get what you're after?

v:=t->Vector(3,{1=t^2,2=3*t,3=t^3}):
a := unapply( map(diff,v(t),t), t):
a(5)

acer

You mentioned that a1, b1, ..., a8, b8 are between 1e-2 to 1e-13, which are floating-point. But otherwise, you seem to be angling for an exact result (if possible, though it would be huge, and, what would one do with it...?).

So my question is, do you want an exact symbolic result or a floating-point approximation (for some stated values of a1,b,..a8,b8)?

acer

The string was not transcribed correctly, in the OP's post. It should probably be something more like,

S:="#fM2{Sz{\
&fg{Z22 &{,_32zU{&Y2{r~_%_92{%u$z?TT+{_& 2%{92{f?{J{Y_%{%2yf`Y2z2%{3\
Y2{9_F@&yzf`3{ZYfyY{Y_%{3Y2{3z_F&9@3_3fSF{`zSy2%@z2o{J{3S,%{Y2z{3Y_3{J{\
Y_%o{n>f3YS@3{3Y2{ 2tU{&fzU{2gy@&2{92{f?{J{l2,f2M2{3Y2{3YfFL{f9`S&&fl,2o{n\
jS{tS@{Zf&Y{92{3S{F_92{tS@z{ 2tU{9_%_92){nJ?{tS@{`,2_&2on{J{3Y2F{3S,%{Y2z{\
3Y2{ 2tbZSz%U{ZYfyY{l2,SFL&{3S{FS{,_FL@_L2U{_F%{J{&_Z{Y2z{&@z`zf&2o{kY2{\
3S,%{92{3Y_3{f3{Z_&{f9`S&&fl,2U{?Sz{&Y2{l2,f2M2%{Y2z&2,?{3Y2{SF,t{`S&&2\
&&Sz{S?{3Y_3{ZSz%{ZYfyY{&Y2{ 2`3{fF{Y2z{929Szt{_F%{ZYfyY{&Y2{Y_%{F2M2z{Z\
zf332F{%SZFo{J{yS@,%{Y_M2{3S,%{Y2z{3Y2{3z@3Y{bb{3Y_3{3Y2{&_92{y_,y@,_3f\
SF{ZYfyY{Y_%{&2zM2%{92{?Sz{%2yf`Y2zfFL{3Y2{9_F@&yzf`3{Y_%{2F_l,2%{92{3S\
{,2_zF{3Y2{ZSz%{bb{l@3{SF{_{y_`zfy2{f3{&3z@y {92{3S{32,,{Y2z{3Y_3{_{L2Ff\
2{Y_%{z2M2_,2%{f3{3S{92o{xYf&{?_,&2{%f&y,S&@z2{?2332z2%{~_%_92{%u$z?TT{\
3S{92o{xY_3{%_t{J{l2y_92{3Y2{9_&32z{S?{Y2z{&S@,U{_F%{J{_l@&2%{9t{`SZ2zo\
{wM2zt{3f92{J{3YfF {S?{f3U{J{_9{%f&3z2&&2%{_F%{_&Y_92%U{_F%{J{%S{`2F_Fy2\
{FSZ{fF{3Y2{Sl,fL_3fSF{@F%2z{ZYfyY{J{`,_y2{9t&2,?{S?{32,,fFL{3Y2{3z@3Y{\
fF{Zzf3fFL{9t{929Sfz&o":

It looks like a fragment by Giacomo Casanova (which would be fitting, for a cipher). I don't see how it's helpful to consider it as an affine cipher, without knowing the alphabet in use. The character set of the enciphered message is not the usual alphabet (as claimed by the OP).

Five or six weeks later, she [Madame D'Urfe'] asked me if I had
deciphered the manuscript which had the transmutation procedure.
I told her that I had.

"Without the key, sir, excuse me if I believe the thing
impossible."

"Do you wish me to name your key, madame?"

"If you please."

I then told her the word, which belongs to no language, and I
saw her surprise. She told me that it was impossible, for she
believed herself the only possessor of that word which she kept
in her memory and which she had never written down.

I could have told her the truth -- that the same calculation
which had served me for deciphering the manuscript had enabled
me to learn the word -- but on a caprice it struck me to tell
her that a genie had revealed it to me. This false disclosure
fettered Madame d'Urfe' to me. That day I became the master of
her soul, and I abused my power. Every time I think of it, I am 
distressed and ashamed, and I do penance now in the obligation
under which I place myself of telling the truth in writing my
memoirs.

acer

It should be possible to write an iterative procedure to do this (when a solution exists) for numeric input (similar to methods for discrete Lyapunov or Stein equations).

[ref] Kitagawa: An Algorithm for Solving the Matrix Equation X = F X F' + S, International Journal of Control, Vol. 25, No. 5, p745–753 (1977).

Whether this is necessary or advisable may depend on whether you have exact or approximate floating-point data to solve (and the dimensions).

acer

Maybe you could create a Matrix inside the procedure get_quantities, instead of a table like q1, and then have that procedure assign directly to the entries of that Matrix, and have that routine also return that Matrix? Ie, right at the beginning of the procedure, insert a line like the following, and leave the rest as it is.

q1 := Matrix(4,4);

Having done it your original way, can you get the conversion of table q1 to a 4x4 Matrix like so, assuming q1's indices are valid?

Matrix(4,4,{op(map(op@lhs=rhs, op(eval(q1))))});

acer

> Optimization:-Maximize( diff(2*Pi*(x+1)*(ln(sqrt(x)+1)),x$4), x=0..10 );
              [0.0427548197437215699, [x = 2.75891892689316043]]

acer

Use := instead of = to assign a value to a variable. Eg, x:=3

acer

ko:=2*Pi/v*f;v:=2.998*10^8;f:=2.525*10^9:
Lo:=29.379;Wo:=34.477:

evalf(1/(120*Pi^2)*Int(eval((sin(ko*W/2*cos(theta))
  /cos(theta))^2*sin(theta)^3
  *BesselJ(0,ko*L*sin(theta)),
                            [L=Lo,W=Wo]),
                       theta=0..Pi,
                       'method'='_d01akc'));

I got a result of -0.01815483673 in 50sec or so, using default precision and error tolerance.

It may be that you could speed it up by using a faster J0, see here for some idea on that.

acer

First 308 309 310 311 312 313 314 Last Page 310 of 337