pagan

5147 Reputation

23 Badges

17 years, 126 days

 

 

"A map that tried to pin down a sheep trail was just credible,

 but it was an optimistic map that tried to fix a the path made by the wind,

 or a path made across the grass by the shadow of flying birds."

                                                                 - _A Walk through H_, Peter Greenaway

 

MaplePrimes Activity


These are answers submitted by pagan

<seq(`if`(a[i,3]<4,a[i,1..-1],NULL),i=1..op([1,1],a))>;

Yes, that is how it works for the mutable data structure Array.

You'd see the same sort of tied relationship if you had instead changed just an element of x, where the corresponding entry of A would also change to match. It's because there is only one underlying Array, and both names x and A point at it.

> A:=Array([5,5]):
> x:=A:
> evalb(addressof(x)=addressof(A));
                              true

Just do  x:=copy(A) or x:=Array(A) instead of x:=A , if you want x to be a wholly distinct new Array where x gets the same entry values as A (at the time that x gets assigned). In that case the entries of x will be subsequently distinct and independent from the entries of A.

Change

T[i,j]:= Matrix(7)

to

T:= Matrix(7)

Notice also that you are not suppressing printing of output when you create the empty (all-zero) initial T with the Matrix() call. That's why an all-zero Matrix gets printed by part of your issued commands. But your double do-loop won't get its actions displayed, under default printlevel. So just call

T;

after your loop, to see how it worked.

For what it's worth, you could also do it this way

T := Matrix( 7, (i,j)->multiply(monoid[i],monoid[j]) );

You don't need to extract each row as a new Vector object. You can index right into the data (by row).

> data:=Matrix(2,3,[[1,1,1],[4,5,9]]):

> t:=op([1,1],data);
                               2

> seq([fsolve(data[i,1]*x^2+data[i,2]*x+data[i,3],x,complex)], i=1..t);

[-0.5000000000 - 0.8660254038 I, -0.5000000000 + 0.8660254038 I], 

  [-0.6250000000 - 1.363589014 I, -0.6250000000 + 1.363589014 I]

> for i from 1 to t do
>   [fsolve(data[i,1]*x^2+data[i,2]*x+data[i,3],x,complex)];
> end do;

[-0.5000000000 - 0.8660254038 I, -0.5000000000 + 0.8660254038 I]
 [-0.6250000000 - 1.363589014 I, -0.6250000000 + 1.363589014 I]

Just don't assign to F. Then you can use `algsubs` to go one way, and `eval` to go the other way.

> restart:

> Feq := F=a*c;
                            F = a c

> K := (a*c)^2;
                              2  2
                             a  c 

> simplerK := algsubs((rhs=lhs)(Feq), K);
                                2
                               F 

> eval(simplerK, Feq);
                              2  2
                             a  c 

> eval(F^(1/3)/cos(F), Feq);
                                (1/3)
                           (a c)     
                           ----------
                            cos(a c) 

> simplify(simplerK, {Feq});
                              2  2
                             a  c 
> L:=[[1,1],[2,4],[4,8],[5,7],[8,1],[5,3],[4,2]]:

> L[ListTools:-Search([4,8],L)..ListTools:-Search([5,3],L)];

                [[4, 8], [5, 7], [8, 1], [5, 3]]
> sol1:=fsolve(A3,S=0..1);

                        sol1 := 0.04329927503

> sol2:=fsolve(A3,S=0..2,avoid={S=sol1});

                        sol2 := 0.9619584407

Other ways to get your results include:

> Student:-Calculus1:-Roots(A3);

                    [0.04329927503, 0.9619584407]

RootFinding:-Analytic(A3,S=0-0.001*I..2+0.001*I);

                0.961958440719070, 0.0432992750296218

BTW, are you interested in a 3rd root just to the left of zero? Try plot(lhs(A3)-rhs(A3),S=-0.02..1) to see that.

> RootFinding:-Analytic(A3,S=-0.02-0.001*I..2+0.001*I);

      0.961958440719070, -0.0182764889720272, 0.0432992750296218

> fsolve(A3,S=-0.02..0);

                            -0.01827648897

while these miss it:

Student:-Calculus1:-Roots(A3,S=-0.02..2);

                    [0.04329927503, 0.9619584407]

> fsolve(A3,S=-0.02..2,avoid={S=sol1,S=sol2}): # returns unevaluated, boo

This looks like homework.

Since Maple can just give you the answer (which really won't help you understand how it works) then maybe it's ok to explain.

Ask youself why this formula works:

> product(i^k,k=1..N);
                  /           2              \
                  \1/2 (N + 1)  - 1/2 N - 1/2/
                 i                            

Let's simplify that a bit, to make it more legible.

> simplify(%,power,size);
                         (1/2 N (N + 1))
                        i               

Do you understand that you can add exponents when taking a product? I think it's likely that you are supposed to use the formula for sum(k,k=1..N). Have you studied that?

> simplify(sum(k,k=1..N),size);
                          1          
                          - N (N + 1)
                          2          

Once you know that, and if you know how to combine exponents of products using addition, you can get here.

> i^((2010*(2010+1))/2);
                             2021055
                            i       

> i^sum(k,k=1..2010);
                             2021055
                            i       

> product(i^k,k=1..2010);
                             2021055
                            i       

Does that make sense to you?

(For the Maple purists, yes, `add` and `mul` could be used instead of `sum` and `product` in those last two results involving a finite number of terms. But using so many command names might make it more confusing.)

ee:=h*BesselJ(0,x)=x*BesselJ(1,x);

Student:-Calculus1:-Roots(evalf(eval(rhs(ee)-lhs(ee),h=3)),x=-20..20);

plot(eval(rhs(ee)-lhs(ee),h=3),x=-20..20);

> G:=S->map(T->{op(T),S minus T},combstruct[allstructs](Combination(S))):

> G({1,2,3});
{{{1, 2, 3}}, {1, {2, 3}}, {2, {1, 3}}, {3, {1, 2}}, {1, 2, {3}}, 

  {1, 3, {2}}, {2, 3, {1}}, {1, 2, 3, {}}}

> G({1,2,3,4});
{{{1, 2, 3, 4}}, {1, {2, 3, 4}}, {2, {1, 3, 4}}, {3, {1, 2, 4}}, 

  {4, {1, 2, 3}}, {1, 2, {3, 4}}, {1, 3, {2, 4}}, {1, 4, {2, 3}}, 

  {2, 3, {1, 4}}, {2, 4, {1, 3}}, {3, 4, {1, 2}}, {1, 2, 3, {4}}, 

  {1, 2, 4, {3}}, {1, 3, 4, {2}}, {2, 3, 4, {1}}, {1, 2, 3, 4, {}}

  }

You might also want to look at this variant (if there is duplication you consider unnecessary in the above representation)

G:=(S,n)->map(T->{T,S minus T},combstruct[allstructs](Combination(S))):

And of course you can look at the packages ?combstruct and ?combinat

The general meaning has been explained already. (I suppose that this was a result from `dsolve` or something, where _C1 is an "arbitrary" parameter.)

Here's a tiny little more detail: some Maple routines (such as `int`) have been augmented to allow you to request that results depending on parameters be returned in piecewise form. But for output that is not in that form, you can sometimes make a conversion yourself.

> signum(-8*ln(2)+_C1)*infinity;
                signum(-8 ln(2) + _C1) infinity

> convert(%,piecewise);
                        / -infinity      _C1 < 8 ln(2)
                        |                             
                       <  undefined      _C1 = 8 ln(2)
                        |                             
                        \ infinity       8 ln(2) < _C1

Also, regarding Georgios's and Robert's notes: the term "undefined" unfortunately does double meaning in Maple. Sometimes it denotes that no meaningful answer exists, and sometimes it denotes that there may be an answer but that not enough information is present to specify what value it is. Sometimes Maple loses its way, because of this schism.

You've made a common mistake.

> sum('weight'(m+2), m = 0 .. 0);
                               1
                               -
                               2

> add(weight(m+2), m = 0 .. 0);
                               1
                               -
                               2

It happens because `sum` acts like most of Maple and evaluates its arguments up front. In contrast, `add` has special evaluation rules and delays evaluation of its first argument until an actual value for the dummy is attained. Another other way to do it, as in the first workaround above, is to delay the evaluation of the function call weight(m+2) by using single-right quotes (sometimes called "uneval" quotes).

In your usage, `sum` sees this result of 1 and not the as-yet-unevaluated function call as its first argument.

> weight(m+2);
                               1

It is a FAQ.

On a somewhat related note, `add` is the more appropriate command for adding up a finite number of terms. The `sum` command is more for symbolic summation (where the end-points of the range are symbols, not numbers). That is, `sum` can do this next one, while `add` cannot since `n` is unknown

> sum(m+1/2, m=0..n);
                           1        2
                           - (n + 1) 
                           2         

> add(m+1/2, m=0..n);
Error, unable to execute add
> restart:

> with(combinat, setpartition) :

> P := {$1..12}:

> ans := setpartition(P, 6):

> interface(elisiontermsbefore=1):
> interface(elisiontermsafter=1):

> `+`(op(ans));
        {{1, 2, 3, 4, 5, 6}, {7, 8, 9, 10, 11, 12}}

           + [...460 terms...]

           + {{1, 8, 9, 10, 11, 12}, {2, 3, 4, 5, 6, 7}}

The Standard GUI also has mouse-clicky ways to control it, using Tools->Options from the menubar and then the Precision tab. I suspect that only the values in that Tools->Option setting (and not the values that those typed commands return) are used when cut'n'pasting.

You could look at the Student:-Calculus1 package. In particular, consider the VolumeOfRevolution and SurfaceOfRevolution commands from that package's Visualization section, both of which accept an 'output'=plot option.

Ok, so you have installed Maple on 64bit Windows 7. But did you install the 32bit or the 64bit version of Maple 12? What does the Maple command kernelopts(version) return?

I see this, on a Windows 7 64bit machine with 6GB of RAM. First with Maple 14:

> restart:
> kernelopts(version);
    Maple 14.00, X86 64 WINDOWS, Apr 5 2010, Build ID 479326

> kernelopts(bytesalloc);
                            1572576

> Matrix(25000,25000,datatype=float[8]):

> kernelopts(bytesalloc);
                           5001577968

> evalf(convert(%,units,bytes,gibibytes));
                          4.658082470

And now with Maple 12.02:

> restart:

> kernelopts(version);
          Maple 12.02, X86 64 WINDOWS, Dec 10 2008 Build ID 377066

> kernelopts(bytesalloc);
                                   786288

> Matrix(25000,25000,datatype=float[8]):

> kernelopts(bytesalloc);
                                 5000922728

> evalf(convert(%,units,bytes,gibibytes));
                                 4.657472230

In other words, no problem with using RAM above 2GB. I was able to allocate even more, although after exceeding 6GB the OS did becomes sluggish -- presumably swapping to virtual memory.

Those numbers above were confirmed by the Windows Task Manager and some other utilities. The only discrepency was with the status bar of the Standard GUI (which somehow doesn't surprise me) which appeared stuck at 2.386GB.

My best guess is that you inadvertantly installed a 32bit version of Maple, which 64bit Windows 7 also allows.

First 26 27 28 29 30 31 32 Last Page 28 of 48