pagan

5147 Reputation

23 Badges

17 years, 125 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

A more challenging problem is to find all such numbers.

There are at least these:

{217800000002178217800000002178, 217800217821780021782178002178,
217821999782178217821999782178, 219782197821978219782197821978,
219978219978219978219978219978, 219999997821999999782199999978,
219999999999978219999999999978, 217821782178219978217821782178}

Generated with a program, of course. That Optimization ILP code produces a pair of stems of length 5 and 6, {21978, 219978}. Simple code finds length 10 and 15 stems {2178002178, 2199999978, 217800000002178, 217821999782178, 219999999999978}. Slightly harder is generating length 30 stems like {217821782178219978217821782178}.

The following amended version should work for both "Extended" and "Maple Standard" Typesetting levels, in Maple 12.02

for i from 1 to 5 do
  cat(`#mscripts(mi(\"x\"),none(),none(),none(),none(),none(),mn(\"`,i,`\"))`);
end do;
for i from 1 to 5 do
  cat(`#mscripts(mi(\"x\"),none(),none(),none(),none(),none(),mn(`,i,`))`);
end do;

The easier and more efficient way is to use indexed assignment.

See ?rtable_indexing and in particular the section entitled "Modifying Elements: Assigning Subblocks"

> L := [1,2,3,4,5,6]:

> (parse@cat@op)(L);
                             123456

> %/2;
                             61728

Of course, this does not work when elements in L are negative integers. But it can be handy, if you are trying to "undo" the kinds of list obtained from convert/base.

If there are no longer any internal references to M or L in the Maple session then the memory used for them will become re-usable by Maple following the next garbage collection. You can invoke garbage collection using the gc command.

Normally, garbage collection occurs automatically, according to the setting of kernelopts(gcfreq). But it sometimes happens that you wish to clear a large Matrix pretty much immediately. (For example, you might wish to create another, new large Matrix and wish to re-use the old Matrix's memory for it, without necessarily requiring additional new memory to be allocated.)

Note that simply unassigning them (using either of your two methods, bot of which are OK) is not enough to remove all references to them (even at Maple's top-level). That is because they may still be referenced under %, %%, or %%%. So you could try this,

M:='M':
L:='L':
dummy1: dummy2: dummy3: gc();

That may do better, by allowing %, %%, and %%% to take on mere dummy values.

I suppose that you could invoke the commands kernelopts(gcbytesavail) and kernelopts(gcbytesreturned) both before and after all that, to see any effect.

Compare these:

> restart;
> M:=Matrix(2000,datatype=float[8]):
> kernelopts(gcbytesavail),kernelopts(gcbytesreturned);
0, 0

> M:='M':
> gc();
> kernelopts(gcbytesavail),kernelopts(gcbytesreturned);
330648, 12872

> restart;
> M:=Matrix(2000,datatype=float[8]):
> kernelopts(gcbytesavail),kernelopts(gcbytesreturned);
0, 0

> M:='M':
> dummy1: dummy2: dummy3:
> gc();
> kernelopts(gcbytesavail),kernelopts(gcbytesreturned);
32330756, 32012956

Keep in mind that it may not be possible to utilize the memory cleared for immediately creating some new large(r) Matrix. That is because float[8] Matrices have contiguous blocks of memory for their data. The memory alongside some recovered block may still be in use. In that case, an entirely new block may be required in order to assign a new Matrix. This is a memory fragmentation issue. Maple does not have a simple equivalent of Matlab's pack command.

I see only an ad hoc solution so far. Something like this:

F:=LinearAlgebra:-DiagonalMatrix([exp(-J[3]/2),exp(J[3]/2),exp(J[3]/2),exp(-J[3]/2)]):

combine(convert~(expand(p.F),trigh)).F^(-1);

That depended on the factors of exp(J[3]/2) being the same across each row. You could program it to construct F automatically, but even still that might need to know that it was "looking for" factors of exp(J[3]/2) and not those based on some other name. Hence I call that "ad hoc" (and so not generally re-usable.)

Apart from the comments of hirnyk, I notice two interesting bits here.

The first is that simplify/symbolic does not happen to apply the particular radical combining that (I suspect) underlies this issue. Namely,

> restart:

> Q:=(1-a^2)^(1/2)*(1-a)^(1/2);

(1/2)
/ 2\ (1/2)
\1 - a / (1 - a)

> combine(Q,symbolic);

(1/2)
// 2\ \
\\-1 + a / (a - 1)/

> radnormal(eval(%,a=2));

(1/2)
3

> simplify(Q,symbolic);

(1/2)
/ 2\ (1/2)
\1 - a / (1 - a)

> radnormal(eval(Q,a=2));

(1/2)
-3

So, for lack of a better word, could we say that simplify/symbolic is just "lucky" to not get into the same branch cut issues as does combine/symbolic for this particular problem?

The other curiosity is why simplify cannot conjoin these next results. It might be because of the exception at x=1/2,-1/2. But if that is so then why does it succeed under the non-strict inequality assumptions!?

> restart:
> a := (2*x-1)/sqrt(1-4*x^2):
> b := sqrt(1-2*x)/sqrt(1+2*x):

> simplify(a/b) assuming x>=1/2; # better than expected
-1

> simplify(a/b) assuming x<=1/2; # better than expected
-1

> limit(a/b,x=1/2);
-1

> simplify(a/b) assuming x>-1/2; # wow, as this includes x=1/2 !
-1

> simplify(a/b) assuming x::real; # ok

(1/2) (1/2)
(1 - 2 x) (1 + 2 x)
- -----------------------------
(1/2)
/ 2\
\1 - 4 x /

> simplify(a/b) assuming Or(x>1/2,x<-1/2); # darn

(1/2) (1/2)
(1 - 2 x) (1 + 2 x)
- -----------------------------
(1/2)
/ 2\
\1 - 4 x /

So I don't see why simplify "got" the first pair above, but not the last pair.

A bug report on Maple going away "for ever" on this sounds like a good this to submit.

The ability to write a program to export many automatically generated plots, with typeset 2D captions, sounds important. If it really cannot be done, that sounds like it deserves a (separate) submission too.

The (Nelder-Mead) method=nonlinearsimplex option of NLPSolve may work for you.

It does not require numerical derivatives, such as an explicit gradient of the objective. It does not seem to suffer the problem for which that cited workaround is devised. It allows an initial point to be specified (as you have done). And you have no bounds or constraints (which it does not allow).

You wouldn't have to use "operator form" with it, either.

You should start a new thread (New Post) insteda of tacking your question onto an earlier thread like this.

You don't need the `abs`, since you are taking squares. Those `abs` seems to make it harder for `solve`, so below I get rid of it by a trick of substituting it with the identity operator and evaluating. (You could also just type it out again, without the `abs`.)

> restart:

> eq := {-2*b[2]*B+b[3]*J+b[5]*J-lambda[2]*b[2] = 0, 
>           -2*b[5]*B+b[2]*J+b[4]*J-lambda[2]*b[5] = 0, 
>           -lambda[2]*b[3]-2*b[3]*B+b[4]*J+b[2]*J = 0, 
>           -lambda[2]*b[4]+b[3]*J-2*b[4]*B+b[5]*J = 0, 
>            abs(b[2])^2+abs(b[3])^2+abs(b[4])^2+abs(b[5])^2-1 = 0}:

>  v := {lambda[2], seq(b[i], i = 2 .. 5)}:

>  ans:=solve(eq,v);
Warning, solutions may have been lost
                                ans :=

> sol:=[solve(eval(eq,abs=(x->x)),v,Explicit)];

[ /                         (1/2)                
[ |         1 /       2    \                     
[< b[2] = - - \-4 b[5]  + 2/     , b[3] = -b[5], 
[ |         2                                    
[ \                                              

                         (1/2)                               \   
         1 /       2    \                                    |   
  b[4] = - \-4 b[5]  + 2/     , b[5] = b[5], lambda[2] = -2 B >, 
         2                                                   |   
                                                             /   

   /                       (1/2)                
   |       1 /       2    \                     
  < b[2] = - \-4 b[5]  + 2/     , b[3] = -b[5], 
   |       2                                    
   \                                            

                           (1/2)                               \   
           1 /       2    \                                    |   
  b[4] = - - \-4 b[5]  + 2/     , b[5] = b[5], lambda[2] = -2 B >, 
           2                                                   |   
                                                               /   

   /       -1         1         -1         1  
  { b[2] = --, b[3] = -, b[4] = --, b[5] = -, 
   \       2          2         2          2  

                        \    /       1         -1         1  
  lambda[2] = -2 J - 2 B }, { b[2] = -, b[3] = --, b[4] = -, 
                        /    \       2         2          2  

         -1                        \    /       1         1  
  b[5] = --, lambda[2] = -2 J - 2 B }, { b[2] = -, b[3] = -, 
         2                         /    \       2         2  

         1         1                       \    /       -1  
  b[4] = -, b[5] = -, lambda[2] = 2 J - 2 B }, { b[2] = --, 
         2         2                       /    \       2   

                                                          ]
         -1         -1         -1                       \ ]
  b[3] = --, b[4] = --, b[5] = --, lambda[2] = 2 J - 2 B }]
         2          2          2                        / ]
                                                          ]

> [seq(simplify(eval(eq,S)), S in sol)];

[ /       |      2    |           2        \   
[{ 0 = 0, |2 b[5]  - 1| + 2 |b[5]|  - 1 = 0 }, 
[ \                                        /   

   /       |      2    |           2        \                     
  { 0 = 0, |2 b[5]  - 1| + 2 |b[5]|  - 1 = 0 }, {0 = 0}, {0 = 0}, 
   \                                        /                     

                  ]
  {0 = 0}, {0 = 0}]
                  ]

> simplify(%) assuming b[5]::real, b[5]^2<1/2;
     [{0 = 0}, {0 = 0}, {0 = 0}, {0 = 0}, {0 = 0}, {0 = 0}]

You can plot a sequence of surfaces, coloured by the value of r.

sphericalplot:=proc(expr::algebraic,
        r::symbol=range(realcons),
        {theta::range(realcons):=0..2*Pi/3},
        {phi::range(realcons):=0..2*Pi/3},
        {numsurface::posint:=10},
        {transparency::numeric:=0.7},
        $)
 local R,n,x,a,b,N;
 N:=numsurface;
 (a,b):=op(rhs(r));
 x:=op(1,indets(expr,name) minus {constants});
 plot3d([seq(eval(expr,x=R),R in [seq(a+(b-a)*n/N,n=0..N-1)])],
        ':-theta'=theta, ':-phi'=phi, ':-coords'=':-spherical',
        ':-style'=':-patchnogrid',
        ':-color'=[seq([0.2,R/N,R/N], R in [$1..(N)])],
        ':-axes'=':-boxed',':-transparency'=transparency,
        ':-scaling'=':-constrained'):
end proc:


sphericalplot( exp(-(r-1.6)^2/4), r=0..5);


sphericalplot( exp(-(r-1.7)^2/4), r=0..5, theta=0..Pi/2, phi=0..Pi,
   numsurface=20, transparency=0.01);

So, you are using 32bit Maple 11 on Windows, yes?

Do you need to use a 32bit JDK with that?

Without more detail, the best I can do is guess at your issue.

In Maple there is a distinction between int() and Int(). The former attempts to solve an integral exactly or symbolically. The latter is an "inert" form, that just represents the integral concept.

The plot functions will call evalf on either. If you have lowercase `int` in your plotted expression then this results in attempt like evalf(int(..)), where something in either the integrand or the range-of-integration may vary w.r.t. the plotting dummy variables. At each point to be plottted, Maple will try to compute the integral int(..) exactly or symbolically. If it succeeds then the constant expression result is hit with evalf, to get the float result for plotting. But if the exact integration failed then evalf will do numeric quadrature instead.

If, on the other hand, your expression (to be plotted) contained uppercase Int(..) then no attempt is made under `plot` to do the exact integration. In this case, Maple calls evalf(Int(...)) which immediately dispatches to numeric quadrature routines.

In other words, an exact integral may fail while numeric integration may succeed.

So, if the symbolic integration attempts are all going to fail anyway (perhaps they may not even be "doable") then you may as well use Int instead of int when forming the expression to be plotted. Doing so, in that case, will save a lot of otherwise wasted time attempting symbolic integrals.

The situation is cloudier if you use the palettes to insert your integrals into the expression. The "expression palette" contains only lowercase `int`. You can see this by allowing your mouse pointer "hover over" the palette entry, if "Tool tips" are enabled in the GUI options under Tools->Options-Interface. In 2D Math you can distinguish between prettyprinted 2D input Int vs int, once inserted in the Worksheet or Document, because the former is a lighter gray integral sign while the latter is more a dark gray/black symbol.

If you really like your integrals to appear as 2D Math input, and if you want to insert a nice 2D inert Int() call, then you can use command-completion instead of the palettes to insert them.

The help page ?fsolve,details says that you cannot set the `variables` option if you supply the `starting values` option.

Also, fsolve will not like that you have more equations in N than there are variables.

Having said that...

> fsolve(N[1 .. 12],
>        {Zeta1,Zeta2,Zeta3,Zeta4,Zeta5,Zeta6,
>         lambda1,lambda2,lambda3,R0=10,a=0.1e-3,b=0.1e-3});

{R0 = -50.58199437, a = 8.226341070, b = 1.395907074, 

  Zeta1 = 10.09705600, Zeta2 = 0.01000000000, 

  Zeta3 = 19.10950601, Zeta4 = 231.9280000, Zeta5 = 25.93439900, 

  Zeta6 = 419.5270000, lambda1 = 0., lambda2 = 0., lambda3 = 0.}

First 23 24 25 26 27 28 29 Last Page 25 of 48