pagan

5032 Reputation

23 Badges

13 years, 250 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

plot3d(piecewise(x^2+y^2<=1,4*x^2-y^2,undefined),x=-2..2,y=-2..2,axes=box);

Throw in the `grid` option, to refine the resolution. Eg, toss grid=[50,50] in as another optional argument to that plot3d() call.

isolate(alpha*x - conjugate(alpha)*x=1, x);

x = 1/(alpha-conjugate(alpha))

In the concepts section: RootOf, types vs properties, operator precedence, (dotm?).

A significant portion of  the original list are items relating specifically to procedures. They might be grouped together, accordingly. The evaluation rules inside procedures, of global, locals, and params, are good to know about. (..and so, earlier, global vs local names.)

But what about modules? They share some items with procedures. There is also overloading, ModuleApply, ModuleLoad, module locals (which have 'global' value), etc.

The original list mentioned rtables. But maybe it should be: sets, lists, rtables, and tables -- what is different about each, and when should you use them, etc. (There's at least one other, which is common but not always recognized -- the unevaluated function call.)

Btw, where do piecewise and series belong?

We might not all be big fans of the programming facilities for Embedded Components, but their interaction with each other forms another programming methodology for Maple users who are producing something for wider consumption. What actions are asynchronous, and which not?

Even if you don't intend on using 2D Math the very fact that there exists both a 1D and a 2D Maple language is a must-know to anyone programming in Maple.

And then there is i/o..

As Joe mentions, the most natural and easiest way is to use dsolve. But it's a fun exercise to try and automate the steps (if only to help appreciate how much subtlety there must be within dsolve).

restart:

eq := A = B*x*diff(y(x),x);

                               / d      \
                       A = B x |--- y(x)|
                               \ dx     /

eq := expand(eq/x); # how to automate this? frontend?

                        A     / d      \
                        - = B |--- y(x)|
                        x     \ dx     /

map(int, eq, x=x1..x2, continuous) assuming x1>0, x2>x1;

           -A ln(x1) + A ln(x2) = -B y(x1) + B y(x2)

eval(%,[y(x1)=y1, y(x2)=y2]);

              -A ln(x1) + A ln(x2) = -B y1 + B y2

combine(%) assuming x1>0, x2>x1 ;

                        /x2\               
                    A ln|--| = -B y1 + B y2
                        \x1/               

simplify(%, size);

                        /x2\               
                    A ln|--| = -B (y1 - y2)
                        \x1/               

collect(sort(%, B), B);

                        /x2\               
                    A ln|--| = B (-y1 + y2)
                        \x1/               

The Cholesky factor symmetric positive definite Matrix is triangular in shape. It won't be symmetric unless it is (also) diagonal in shape.

It is true that a positive symmetric Matrix S has a (lower or upper) triangular Cholesky factorization S=L.L' =U'U. And such a Matrix also has a "square root" Matrix R such that S=R.R but R is not the same thing as the Cholesky factor L (or U).

restart:

Cov := Matrix([[.1, .2], [.2, 1.3]]);

                                     [0.1  0.2]
                              Cov := [        ]
                                     [0.2  1.3]

R:=LinearAlgebra:-MatrixPower(convert(Cov,rational),1/2);

                              [1  (1/2)   1   (1/2)]
                              [- 2        -- 2     ]
                              [5          10       ]
                         R := [                    ]
                              [1   (1/2)  4  (1/2) ]
                              [-- 2       - 2      ]
                              [10         5        ]

evalf(R.R);

                        [0.1000000000  0.2000000000]
                        [                          ]
                        [0.2000000000   1.300000000]

R:=LinearAlgebra:-MatrixPower(Cov,1/2);

                           [0.2828427125  0.1414213562]
                      R := [                          ]
                           [0.1414213562   1.131370850]

evalf(R.R);

                   [0.100000000000000  0.200000000000000]
                   [                                    ]
                   [0.200000000000000   1.30000000000000]

L := LinearAlgebra:-LUDecomposition(Cov,method=Cholesky);

                      [0.316227766016838                 0.]
                 L := [                                    ]
                      [0.632455532033676  0.948683298050514]

R - R^%T;

                                  [0.  0.]
                                  [      ]
                                  [0.  0.]

L.L^%T;

                   [0.100000000000000  0.200000000000000]
                   [                                    ]
                   [0.200000000000000   1.30000000000000]

L - L^%T;

                   [               0.  -0.632455532033676]
                   [                                     ]
                   [0.632455532033676                  0.]

If you only need to know whether they are all distinct, then you could test

nops({a,b,c,d});

since sets are uniquified. I mean, since duplicates are removed from set constructed using {} brackets, then you can test whether the number of elements in the resulting set is equal (or less) than the number of variables.

This gets sticky,if the variables have float values like, 12.00, 12.0000, 12.00000, etc.

Or, do you need to know which clumps all share a value?

Granted, this involves some manually made choices for _B1 and _Z1 (the parameters of the solution, which you can run getassumptions against).

restart:

e := 4*cos(t)+2*cos(2*t)=0:

sol:=solve([e, 0 <= t, t <= 2*Pi], t,
            AllSolutions, Explicit):

#plot(lhs(e),t=0..2*Pi,tickmarks=[decimalticks,default]);

s1:=eval(convert({sol},`global`),[`_B1~`=0,`_Z1~`=0])
    union eval(convert({sol},`global`),[`_B1~`=0,`_Z1~`=1]):

s1:=select(type,map(rhs@op,s1),realcons):

select(z->is(z>=0 and z<=2*Pi), s1);

      /             /1  (1/2)   1\        /1  (1/2)   1\\ 
     { 2 Pi - arccos|- 3      - -|, arccos|- 3      - -| }
      \             \2          2/        \2          2// 

evalf(%);

                   {1.196061894, 5.087123414}

Why do you give MainFDerivative option `system`?

Do you make that unapply call before of after you define MainF? Hopefully, it is made after.

Is MainFDerivative a procedure that will compute under the evalhf interpreter? If so, then you could try an evalhf-callback instead of an eval-callback. (I forget the name of the evalhf-callback fcn, but you should be able to find it in the API.)

There is much broken functionality on this site. Sometimes things get fixed, and then they break again, being broken more often than working.

Inlining images into posts is broken right now. Inlining worksheets into posts is broken right now. Reputation plots are broken. Maple output cut'n'paste produces nonsense like you show above.

The particular problem you show has been present, on and off (mostly on), for over a month.

The number of contributors of interesting posts (as opposed to tech-support level questions) and discussions has been steadily decreasing on this site for several years. I attribute this mostly to the dysfunction of the site.

You can delay evaluation using so-called uneval (single right-) quotes. Or you can use `add` which has special evaluation rules.

restart:

eval( sum( binomial(5,k)*a^k*b^(5-k) , k=0..5 ), b=0 );
                                5
                               a 

b:=0;
                               0

add( binomial(5,k)*a^k*b^(5-k) , k=0..5 );
                                5
                               a 

eval( sum( 'binomial(5,k)*a^k*b^(5-k)' , k=0..5) );
                                5
                               a 

The Description of the help page for `add` also has a little to say, re `sum` and `add` and explicit versus indefinite or symbolic summation.

I suppose that you mean for floating-point, not for the exact symbolic case.

It uses the singular value decomposition. See also the first application example described here.

You can view the code that accomplishes this. Using Maple 15

showstat((LinearAlgebra::LA_Main)::`MatrixInverse/pseudo`,34..57);

In Maple 11, the relevent code can be seen by issuing these commands

kernelopts(opaquemodules=false):
showstat(LinearAlgebra:-LA_Main:-`MatrixInverse/pseudo`,34..57);

The code looks more complicated than it is, just because some care is being taken to keep down unnecessary copies in various cases like n>m, m>n, etc.

It also computes a "proviso" of correctness. This is computed as a ratio of the r'th ordered singular value and the largest singular value, where r the rank of the Matrix is determined according to how many of the ordered singular values have a ratio w.r.t the largest that is greater than some tolerance that depends upon Digits. This is akin to how the Rank command determines r for float Matrices.

Use `remove` for this kind of thing, since doing it in a loop is unnecessarily inefficient. You want to have maple walk the list just the once, and to have it internally construct just the single result (instead of many temporary lists as collectible garbage).

> f:=rand(-10..10):
> A:=[seq(f(),i=1..17)];

       [-7, 8, -7, -5, -7, -7, -1, -3, -9, 5, -9, 0, 10, 4, 0, -8, -6]

> remove(t -> t < 0 and t > -7, A); # just an example

               [-7, 8, -7, -7, -7, -9, 5, -9, 0, 10, 4, 0, -8]

You could also use evalf inside the predicate (the first argument of the remove command). Eg,

   t -> evalf(t) < 0 and evalf(t) > -7

[edit] Forgot to use your actual example.

> A := [[0, 1], [2, 2], [4, 5], [-1, -2]]:

> remove( x -> 2*evalf(x[1]) > evalf(x[2]), A );

                             [[0, 1], [-1, -2]]

Both `remove` and `map` are efficient for this kind of thing, relative to iterating (with a loop).

If you want the units to automatically combine, for your arithmetic expressions involving them, then add this line to the start of your Document.

with(Units:-Standard):

You could also put that into the Document's "Startup Code" section (see Edit->Startup Code from the GUI's top menu bar).

L1:=[1,2,3,4,5]:
L2:=[1,4,9,16,25]:
L3:=[1,8,27,64,125]:

plot( [ <<L1>|<L2>>, <<L1>|<L3>> ] );

plots:-display( plots:-pointplot(L1,L2,style=line,color=red),
                plots:-pointplot(L1,L3,color=green,style=line)
               );

Use it like this

1 &+- 2

and not like this (as you have it above)

1 + `&+-`(2)

Also, you'll be better off in the long run if you set it up explicitly, like

  `&+-` := (a,b)->ScientificErrorAnalysis:-Quantity(a,b):

instead of

  with(ScientificErrorAnalysis):
  ...
  .....
  `&+-` := (a,b)->Quantity(a,b):
First 9 10 11 12 13 14 15 Last Page 11 of 48