Alejandro Jakubi

MaplePrimes Activity


These are answers submitted by Alejandro Jakubi

This error message is generated by disassemble:

disassemble(0);
Error, object at address is invalid

And it is called by Typesetting:-Typeset:-Tdisplay[true] :

Typesetting:-Typeset:-Tdisplay[true](0);
Error, (in Typeset:-Tdisplay[true]) object at address is invalid
tracelast;
 Typeset:-Tdisplay[true] called with arguments: 0
 #(Typesetting:-Typeset:-Tdisplay[true],5): t1 := [disassemble(expr)];
Error, (in Typeset:-Tdisplay[true]) object at address is invalid
 locals defined as: expr = 0, flag = true, prefun = false, bds = bds, lbds = lbds, dotm = dotm, overname = overname, arr = arr, t1 = t1, t2 = t2, t3 = t3, t4 = t4, t5 = t5, t6 = t6, s1 = s1, 
i = i, j = j, k = k

From a generic point of view, the Standard GUI includes extra layers of software: the Typesetting package, the 2D parser, the Java kernel, etc. They add chances of bugs. I find safer avoiding them altogether.

You may see this thread for options about reading source files into the GUI. And you may see here about reading source files into the CLI.

It can be done conveniently by using the package LargeExpressions and a rule for the transformation cosh(a)-sinh(a)->exp(-a):

with(LargeExpressions):
hyptoexp2:=cosh(a::algebraic)-sinh(a::algebraic)=exp(-a):
A:=-1/2*Phi*(variphi*sigma*sinh(l*S0)*cosh(l)-variphi*sigma*sinh(l*S0)*sinh(l)-
variphi*sigma*sinh(l*S0)*R1*cosh(l)+variphi*sigma*sinh(l*S0)*R1*sinh(l)+
cosh(l*S0)*l*N_1*cosh(l)-cosh(l*S0)*l*N_1*sinh(l))/l/(-R1*R2*cosh(-l+l*S0)*sinh(l*S0)+
sinh(-l+l*S0)*cosh(l*S0)):

Then, collect the numerator after its repeated symbols and function calls, and Veil the denominator with a name, C[1] say:

(((x->collect(x,[Phi,variphi,sigma,N_1,cosh,sinh]))@numer)/(Veil[C]@denom))(A):

factor and transform the coefficients after the rule hyptoexp2:

evalindets(%,Or(`&*`(algebraic,identical(sigma),identical(variphi)),
`&*`(algebraic,identical(N_1))),(x->applyrule(hyptoexp2,x))@factor):

collect after the exponential and Unveil the denominator:

collect(%,exp,Unveil[C]);

        1/2 (-sinh(l S0) (R1 - 1) sigma variphi + cosh(l S0) l N_1) Phi

        exp(-l)/(l (R1 R2 cosh(-l + l S0) sinh(l S0) - sinh(-l + l S0) cosh(l S0)))

It is a regress. But the previous answer x=19 was also wrong without conditions on a, e.g:

eq:=(a^(x+2))^(1/3)  =  (a^(x-5))^(1/2):
evalf(subs(a=-1,x=19,eq));
                  0.5000000001 + 0.8660254037 I = 1.

For serious programming it is better to use an external editor.

Indeed:

exp2sinh:=conditional(A::algebraic*exp(a::algebraic)+B::algebraic*exp(b::algebraic)=
2*A*sinh((a-b)/2)*exp((a+b)/2),_verify(A+B,0,equal)):

r2:=1/2 * exp(I*k*theta - 1/2*k^2*sigma^2)* sigma*sqrt(A) - 
1/2 * exp(-I*k*theta - 1/2*k^2*sigma^2)* sigma*sqrt(A): applyrule(exp2sinh,r2); 2 2 1/2 k sigma sigma A sin(k theta) exp(- ---------) I 2

Compare:

evalc(r2);
              2      2
             k  sigma                           1/2
  -1/2 exp(- ---------) sin(k theta) sigma | A |    (1 - signum(A))
                 2

                        2      2
                       k  sigma                           1/2
         + 1/2 I exp(- ---------) sin(k theta) sigma | A |
                           2

        (1 + signum(A))

Most formulas you would use by hand, in general those you can find in the tables, can be implemented as explicit rules. Unless you hit a bug in applyrule, this technique is very useful as an easy method for going beyond the transformations currently implemented in library routines, or for making similar transformations in a more controlable way.

You can install 32-bit Maple, including Classic GUI, under 64-bit. It is a workaround for other issues as well.

If you have got to the point of having to handle expressions of this size, no generic routine (like simplify alone or with some option) will likely be able to produce automatically (or "magically") a sensible simplification. Rather, observation of patterns plus interactively controled simplification will be much more effective. Note, however, that preventing expression swell by earlier simplification, if possible, would be even better.

For interactive simplification, the classical labels facility is a great aid, despite of its limitations. As its functionality is severely limited in Standard GUI (see acer's article in the linked thread), I find this GUI close to useless for this purpose and I prefer Classic GUI.

So, what follows is a brief account of how classical labels, routines of the package LargeExpressions, collect, applyrule, etc, may be used for reducing this "huge output" to an expression of about five lines on my screen, plus some equations for symbols representing frequent subexpressions. Note also that the form of this particular simplified expression depends on the specific choice of the statements, and its usefulness will depend strongly on the purpose or context (not stated by the OP). 

My first observation in the output of huge_output was that a pair of square roots appear very frequently: sqrt(%2/%1) and sqrt(%3/%1), where these were the lablel assignments:

%1:=4*Pi^2+beta^2-4*beta^2*Q*Pi+4*beta^2*Q^2*Pi^2
%2:=-4*Pi^2-beta^2+4*beta^2*Q^2*Pi^2+8*I*Pi^2*beta*Q
%3:=-4*Pi^2-beta^2+4*beta^2*Q^2*Pi^2-8*I*Pi^2*beta*Q

 For better handling of these subexpressions, these square root terms are replaced with actual names:

with(LargeExpressions):
h1:=subsindets(huge_output,And(sqrt,Not(constant)),Veil[K]):

They are actually four constants K[1] to K[4] because the inverses are also counted as they are syntactically different. But their relationship can be seen here:

Unveil[K]([K[3]-1/K[1],K[4]-1/K[2]]);
                                [0, 0]

Hence it is better to substitute for just two constants:

h1a:=subs([K[3]=1/K[1],K[4]=1/K[2]],h1):

The next steps are collecting for some symbols and function calls. Here, the form of the output is very sensitive to the form of the collect statement, in particular to the collecting list. Hence experimentation is required for approaching to the desired target. And sometimes the usage of transformation rules as shown here may help a lot:

r:=[a::algebraic/beta^4+b::algebraic/beta^4=(a+b)/beta^4,
a::algebraic/beta^4+b::algebraic/beta^3=(a/beta+b)/beta^3,
a::algebraic/beta^3+b::algebraic/beta^3=(a+b)/beta^3]:
collect(h1a,[t,beta,K[1],K[2],sigma,exp,cos],factor):
h2:=applyrule(r,%):

Its output contains seven labels for repeated subexpressions. Again, they are substituted with names, and sum terms are collected for them:

h2a:=subsindets(%,{identical(%1),identical(%2),identical(%3),identical(%4),identical(%5),
identical(%6),identical(%7)},Veil[C]): h3:=evalindets(h2a,`+`,x->collect(x,[seq(C[i],i=0..7)],distributed)); h3 := 1/4*2^(1/2)*exp(-1/2*x^2/sigma^2)*(K[2]^2*(1/4*Pi*(2*Pi+beta*I)+
1/2*Q*Pi^2*(Pi+beta*I)*cos(k*psi)+(-1/4*Pi*(2*Pi+beta*I)-
1/2*Q*Pi^2*(Pi+beta*I)*cos(k*psi))*exp(-1/2*sigma^2*k^2))/beta/C[2]/C[3]/C[4]*C[1]+
K[1]*K[2]*(Q*Pi^2*(Pi-I*beta)*cos(k*psi)/beta-1/2*I*Pi+
(-Q*Pi^2*(Pi-I*beta)*cos(k*psi)/beta+1/2*I*Pi)*exp(-1/2*sigma^2*k^2))/C[4]/C[2]+
K[2]/K[1]*(-1/2*Pi-Q*Pi^2*cos(k*psi)+(Q*Pi^2*cos(k*psi)+
1/2*Pi)*exp(-1/2*sigma^2*k^2))/beta/C[3]/C[4]^2*C[5]/C[1]+K[1]^2*(-1/4*Pi*
(2*Pi-I*beta)-1/2*Q*Pi^2*(3*Pi-I*beta)*cos(k*psi)+(1/4*Pi*(2*Pi-I*beta)+
1/2*Q*Pi^2*(3*Pi-I*beta)*cos(k*psi))*exp(-1/2*sigma^2*k^2))/beta/C[4]*C[3]/C[1]/C[2]+
K[1]/K[2]*(-1/2*Pi-Q*Pi^2*cos(k*psi)+(Q*Pi^2*cos(k*psi)+1/2*Pi)*exp(-1/2*sigma^2*k^2))/
beta/C[3]*C[6]/C[1]/C[2]^2+(2*Pi^2+4*Q*Pi^3*cos(k*psi)+(-2*Pi^2-4*Q*Pi^3*cos(k*psi))*
exp(-1/2*sigma^2*k^2))/beta/C[2]^2/C[3]^2/C[4]^2*C[7]/C[1]^2)/beta^3/Pi^(3/2)/sigma*t

And the equations for these names C[1] to C[7] are:

seq( C[i] = Unveil[C](C[i]), i=1..LastUsed[C]);

  C[1] = -2 Q beta Pi + beta + 2 I Pi,
  C[2] = -2 Q beta Pi + 2 I Pi - beta,
  C[3] = 2 Q beta Pi - beta + 2 I Pi,
                                                        3  2     2
        C[4] = 2 Q beta Pi + 2 I Pi + beta, C[5] = 12 Pi  Q  beta

                 2     3  2       3          2                 2
         - 4 I Pi  beta  Q  + 8 Pi  - 12 I Pi  beta - 6 Pi beta

               3                3  2     2         2     3  2       3
         + beta  I, C[6] = 12 Pi  Q  beta  + 4 I Pi  beta  Q  + 8 Pi

                  2                 2       3               6
         + 12 I Pi  beta - 6 Pi beta  - beta  I, C[7] = beta

                  4   2        6        4     2         6  4     4
         + 12 beta  Pi  + 64 Pi  + 48 Pi  beta  + 256 Pi  Q  beta

                  6  6   6         6  2     2       2     6  2
         + 96 beta  Q  Pi  + 224 Pi  Q  beta  - 2 Pi  beta  Q

                4  4     6        4  2     4
         - 32 Pi  Q  beta  - 16 Pi  Q  beta

I find remarkable that some of the tools that I have found most useful here, like the Classic GUI, classical labels, and applyrule, count among those largely unmaintained for years.

You may see ?member and ?membertype.

@Christopher2222 You may try running HTMSTRIP on your html file.

In the menu: More > Submit Software Change Request.

For such calculations, it is better to keep R as a symbolic function call R(X,Y,Z) and use rules for evaluating its derivatives in the Jacobian. For a toy example:

f:=2*R(X,Y,Z)*cos(t):
J:=VectorCalculus:-Jacobian([f],[X,Y,Z,t]);
  J :=

        [  /d            \            /d            \
        [2 |-- R(X, Y, Z)| cos(t) , 2 |-- R(X, Y, Z)| cos(t) ,
        [  \dX           /            \dY           /

          /d            \                              ]
        2 |-- R(X, Y, Z)| cos(t) , -2 R(X, Y, Z) sin(t)]
          \dZ           /                              ]

dR:=%diff(R(X,Y,Z),x::name)=x/R(X,Y,Z):
map2(applyrule,dR,subs(diff=%diff,J));

    [2 X cos(t)   2 Y cos(t)   2 Z cos(t)                       ]
    [---------- , ---------- , ---------- , -2 R(X, Y, Z) sin(t)]
    [R(X, Y, Z)   R(X, Y, Z)   R(X, Y, Z)                       ]

Note that an inert version of the differentiation command like %diff is needed so as an error in the rule dR is avoided. And more compact output, by hiding the functional dependence or R, can be obtained by using PDETools:-declare:

PDETools:-declare(R(X,Y,Z),quiet):
map2(applyrule,dR,subs(diff=%diff,J));

       [2 X cos(t)    2 Y cos(t)    2 Z cos(t)               ]
       [----------    ----------    ----------    -2 R sin(t)]
       [    R             R             R                    ]

The documentation in ?define and ?examples,define deals only with ordinary derivatives. And inspection of the code shows that partial derivatives are not supported. So, if a rule-based way is wanted, I would do it with applyrule and the inert %diff, like:

der:=[ %diff( f(x::name,y::name) , x::name ) = f1x(x,y) , 
%diff( f(x::name,y::name) , y::name ) = f1y(x,y) ]:

applyrule(der,%diff( f(x,y) , x ));
                              f1x(x, y)

applyrule(der,%diff( f(x,y) , y ));
                              f1y(x, y)

The problem with define is that it assigns to the name `diff/f` a wrong procedure extension of diff when acting upon the function f, in the case of two (or more) independent variables. Basically it generates a chain rule factor like diff(x,y), hence the 0:

restart:
define( f , diff( f(x,y) , x ) = f1x(x,y) , diff( f(x,y) , y ) = f1y(x,y) );
showstat(`diff/f`);
`diff/f` := proc(expr, var)
   1   subs(op(2,lhs((diff(f(x,y),y) = f1y(x,y)))) = expr,rhs((diff(f(x,y),y) = f1y(x,y))))
*diff(expr,var) end proc

So, the alternative is assigning by hand a correct procedure to `diff/f`, as Robert has done.

 

It retuns FAIL for the case of a ratio as it checks in property/LinearProgr that the object holding properties is nonlinear:

> stopat(`property/LinearProgr`):
> assume(q, integer, w, integer): > coulditbe(q/w < 1); `property/LinearProgr`: 1* if type(obj,{('Non')(('polynom')('numeric')), ('Non')('linear')}) or not type(prop,{'numeric', 'RealRange'}) or select(type,eqns,{('Non')(('polynom')('numeric')), ('Non')('linear')} = ('anything')) <> [] then ... end if; > into `property/LinearProgr`: 2 return FAIL > next FAIL `coulditbe/internal`: 96 if r = true then ... end if; > next FAIL `coulditbe/internal`: 98 r := `is/solve`(nobj,eqns,inds,prop); > next [3, PropRange(integer,rational)] `coulditbe/internal`: 99 if r[1] = 1 or r[1] = 4 then ... elif r[1] = 3 then ... else ... end if > next FAIL

Extracting the summand with applyrule:

y := Sum(a[n]*x^(n-2)*(n-1)*n, n = 0 .. infinity):
summand:=Sum(a::algebraic,e::equation)=a:
applyrule(summand,y); (n - 2) a[n] x (n - 1) n
First 26 27 28 29 Page 28 of 29