acer

32363 Reputation

29 Badges

19 years, 332 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

The intpakX package's export init does with(plots). That really shouldn't ever be done inside a procedure. I believe that it all worked in M9.5.1 because at that time the plots package was table-based rather than module-based.

Issuing with inside a proc was never guaranteed to work properly, as far as I know. If that's true, then it's not clear that this is a regression bug. (One should not rely on undocumented features...)

Now that the plots package is a module itself in modern Maple, the intpakX code should be rewritten to either use plots:-diplay explicitly, or to use use or uses.

There may well be other plots routines used by intpakX. If that's the case, then issuing only  with(plots,display) done up front, before the module definition, won't fix all those other routine calls. One could instead issue a quick and dirty with(plots) outside and before the module definition, or one could do it properly as outlined above (use, uses, or explicit plots's export calls).

acer

The intpakX package's export init does with(plots). That really shouldn't ever be done inside a procedure. I believe that it all worked in M9.5.1 because at that time the plots package was table-based rather than module-based.

Issuing with inside a proc was never guaranteed to work properly, as far as I know. If that's true, then it's not clear that this is a regression bug. (One should not rely on undocumented features...)

Now that the plots package is a module itself in modern Maple, the intpakX code should be rewritten to either use plots:-diplay explicitly, or to use use or uses.

There may well be other plots routines used by intpakX. If that's the case, then issuing only  with(plots,display) done up front, before the module definition, won't fix all those other routine calls. One could instead issue a quick and dirty with(plots) outside and before the module definition, or one could do it properly as outlined above (use, uses, or explicit plots's export calls).

acer

> y := (-Pi-1/2)*I:

> simplify( y ); evalf(%);

                               -1/2 I (2 Pi + 1)
 
                                -3.641592654 I
 
> simplify( ln(exp( y )) ); evalf(%);

                               1/2 I (2 Pi - 1)
 
                                 2.641592654 I
 
> simplify( ln(exp( x )) ) assuming x::real;
                                       x
See also Alec's response above with simplify(...,symbolic).

acer

> y := (-Pi-1/2)*I:

> simplify( y ); evalf(%);

                               -1/2 I (2 Pi + 1)
 
                                -3.641592654 I
 
> simplify( ln(exp( y )) ); evalf(%);

                               1/2 I (2 Pi - 1)
 
                                 2.641592654 I
 
> simplify( ln(exp( x )) ) assuming x::real;
                                       x
See also Alec's response above with simplify(...,symbolic).

acer

I wish that there were something for Standard that were as useful and as easy to use (without a mouse) as the X11_defaults/Maple file is for Classic.

ps. There's an anti-aliasing toggle under the Tools->Options-Display menutab. (Why is there an entry to that drop-down box labelled "Default", without indicating whether the default is to have anti-aliasing enabled or disabled?)

acer

Come up with another example yourself, and work through it. Otherwise you'll just be copying, and you won't really learn it.

If you want a third equation in two variables, then add a linear combination of the two that you already have. (In the example below, the third equation is just the first minus the second. But you could also do, say, 5 times the first plus 2 times the second.)

> with(LinearAlgebra):

> A,b := GenerateMatrix([2*x-2*y=-2,-x+2*y=3,3*x-4*y=-5],[x,y]):
 
> S := Matrix([A,b]); # augmented Matrix, represents system
                                  [ 2    -2    -2]
                                  [              ]
                             S := [-1     2     3]
                                  [              ]
                                  [ 3    -4    -5]
 
> RowOperation(S,[2,1]); # exchange 1st and 2nd rows
                               [-1     2     3]
                               [              ]
                               [ 2    -2    -2]
                               [              ]
                               [ 3    -4    -5]
 
> RowOperation(%,1,-1); # scale 1st row by -1
                                [1    -2    -3]
                                [             ]
                                [2    -2    -2]
                                [             ]
                                [3    -4    -5]
 
> RowOperation(%,[2,1],-2); # add -2 times 1st row to 2nd row
                                [1    -2    -3]
                                [             ]
                                [0     2     4]
                                [             ]
                                [3    -4    -5]
 
> RowOperation(%,[3,1],-3);
                                [1    -2    -3]
                                [             ]
                                [0     2     4]
                                [             ]
                                [0     2     4]
 
> RowOperation(%,2,1/2);
                                [1    -2    -3]
                                [             ]
                                [0     1     2]
                                [             ]
                                [0     2     4]
 
> RowOperation(%,[3,2],-2);
                                [1    -2    -3]
                                [             ]
                                [0     1     2]
                                [             ]
                                [0     0     0]
 
> RowOperation(%,[1,2],2);
                                 [1    0    1]
                                 [           ]
                                 [0    1    2]
                                 [           ]
                                 [0    0    0]
 
> %[1..2,3];
                                      [1]
                                      [ ]
                                      [2]
 
> LinearSolve(A,b);
                                      [1]
                                      [ ]
                                      [2]

acer

Come up with another example yourself, and work through it. Otherwise you'll just be copying, and you won't really learn it.

If you want a third equation in two variables, then add a linear combination of the two that you already have. (In the example below, the third equation is just the first minus the second. But you could also do, say, 5 times the first plus 2 times the second.)

> with(LinearAlgebra):

> A,b := GenerateMatrix([2*x-2*y=-2,-x+2*y=3,3*x-4*y=-5],[x,y]):
 
> S := Matrix([A,b]); # augmented Matrix, represents system
                                  [ 2    -2    -2]
                                  [              ]
                             S := [-1     2     3]
                                  [              ]
                                  [ 3    -4    -5]
 
> RowOperation(S,[2,1]); # exchange 1st and 2nd rows
                               [-1     2     3]
                               [              ]
                               [ 2    -2    -2]
                               [              ]
                               [ 3    -4    -5]
 
> RowOperation(%,1,-1); # scale 1st row by -1
                                [1    -2    -3]
                                [             ]
                                [2    -2    -2]
                                [             ]
                                [3    -4    -5]
 
> RowOperation(%,[2,1],-2); # add -2 times 1st row to 2nd row
                                [1    -2    -3]
                                [             ]
                                [0     2     4]
                                [             ]
                                [3    -4    -5]
 
> RowOperation(%,[3,1],-3);
                                [1    -2    -3]
                                [             ]
                                [0     2     4]
                                [             ]
                                [0     2     4]
 
> RowOperation(%,2,1/2);
                                [1    -2    -3]
                                [             ]
                                [0     1     2]
                                [             ]
                                [0     2     4]
 
> RowOperation(%,[3,2],-2);
                                [1    -2    -3]
                                [             ]
                                [0     1     2]
                                [             ]
                                [0     0     0]
 
> RowOperation(%,[1,2],2);
                                 [1    0    1]
                                 [           ]
                                 [0    1    2]
                                 [           ]
                                 [0    0    0]
 
> %[1..2,3];
                                      [1]
                                      [ ]
                                      [2]
 
> LinearSolve(A,b);
                                      [1]
                                      [ ]
                                      [2]

acer

> simplify(M1-N1);
                                       0

For the substitution, you could try something like this,

eval(M1,[s1=sqrt(mu1*epsilon1*kappa^2+v^2+u^2),
         s2=sqrt(mu2*epsilon2*kappa^2+v^2+u^2)]);

acer

p1:=plots:-pointplot(<<1,2,3,4,5>|<1,3,5,7,9>>):
p2:=plots:-pointplot(<<1,2,3,4,5>|<1,4,9,16,25>>):
plots:-display([p1,p2]);

acer

p1:=plots:-pointplot(<<1,2,3,4,5>|<1,3,5,7,9>>):
p2:=plots:-pointplot(<<1,2,3,4,5>|<1,4,9,16,25>>):
plots:-display([p1,p2]);

acer

The expressions assigned to M1 and N1 are not equal.

That's the central problem. Assign M1 and N1 those long expressions without the attempt to subs for s1^2 and s2^2. Then, it is easy to find a set of values for which they are not equal.

> eval(M1-N1,[s1=sqrt(3),s2=sqrt(3),xp=1,mu1=1,mu2=1,
>             epsilon1=1,epsilon2=1,kappa=1,v=1,u=1,w=1,a=1]);

The other problem is trying to substitute s1^2=... and expecting it to replace all instances of s1. Maybe you could consider substituting s1=sqrt(...), etc, using eval instead of subs, and simplify with assumptions on the range/realness of the variables? That might be a means to show the equality, given the the bigger problem were fixed and they were actually equal.

acer

That datatype float[8] rtable (Array, Vector, etc) should be created with enough storage to hold the result.

> restart:
> arrB_GSL := define_external(
>     'gsl_sf_bessel_jl_steed_array','lmax'::integer[4],
>     'x'::float[8],
>     'jl_x_array'::ARRAY(datatype=float[8]),
> 'RETURN'::integer[4],
> LIB="/usr/lib64/libgsl.so"):
>
> jl:=Vector[row](10,datatype=float[8]):
> arrB_GSL(2,3.1,jl);
                                       0
 
> jl;
[0.0134131169139646862, 0.326628473286207754, 0.302678954008171852, 0., 0., 0.,
 
    0., 0., 0., 0.]
 
> jl:=Vector[row](10,datatype=float[8]):
> arrB_GSL(5,3.1,jl);
                                       0
 
> jl;
[0.0134131169139647330, 0.326628473286207810, 0.302678954008171908,
 
    0.161563388017295251, 0.0621415995792689718, 0.0188477075354211120, 0., 0.,
 
    0., 0.]

Axel, your example show code in which that Array would be created with no allocated space.

> steedArr:=Array(datatype=float[8], order=C_order);
steedArr :=
 
    Array({}, datatype = float[8], storage = rectangular, order = C_order)

If there is not enough space in the passed array then the GSL function may attempt to write the data outside the bounds of that array in memory. That would lead to a seg-fault or corruption of other data in Maple's own memory space. (This would certainly happen, if the array had no allocated storage at all, as in the original code posted.)

acer

The interesting bits may not be in what gets assigned to dsol, but rather what gets assigned to an internal structure that dsol accesses.

Suppose instead that the method being asked about was dverk78. That uses a 7-8 order scheme to create piecewise polynomial interpolants, which each can be used to approximate the solution over a subrange. Now, one might possibly wish to extract those. (The purpose of that is still a little dubious, since plotting by utilizing them may be better done by DEplot. What else would one do with them?) How to find and recognize the data that describes those interpolants, in this next lot, is murky.

restart:
kernelopts(opaquemodules=false):
interface(verboseproc=3):
dsol := dsolve({diff(x(t),t)=sin(t), x(0)=0}, 'numeric', method=dverk78):
T:=eval(`dsolve/numeric/data/modules`[1]);
eval(T:-Data);

For the rosenbrock method, it's perhaps less clear (to me) what one would want to find and extract. But you can mostly examine it in a similar way.

restart:
kernelopts(opaquemodules=false):
interface(verboseproc=3):
dsol := dsolve({diff(x(t),t)=sin(t), x(0)=0}, 'numeric', method=rosenbrock):
T:=eval(`dsolve/numeric/data/modules`[1]);
eval(T:-Data);
op(op(3,eval(T)))["soln_procedure"];

So, what exactly is the data stored inside the local variable _dtbl of that procedure? Can it be extracted easily (without resorting to something like ToInert)?

One can see it printed, inside the debugger. one can also follow its workings, step by step.

> f := op(op(3,eval(T)))["soln_procedure"]:
> stopat(f):
> f(4);
f:
   1*  _xout := _xin;
 
DBG> next
4
f:
   2   _pars := [];
 
DBG> next

acer

The interesting bits may not be in what gets assigned to dsol, but rather what gets assigned to an internal structure that dsol accesses.

Suppose instead that the method being asked about was dverk78. That uses a 7-8 order scheme to create piecewise polynomial interpolants, which each can be used to approximate the solution over a subrange. Now, one might possibly wish to extract those. (The purpose of that is still a little dubious, since plotting by utilizing them may be better done by DEplot. What else would one do with them?) How to find and recognize the data that describes those interpolants, in this next lot, is murky.

restart:
kernelopts(opaquemodules=false):
interface(verboseproc=3):
dsol := dsolve({diff(x(t),t)=sin(t), x(0)=0}, 'numeric', method=dverk78):
T:=eval(`dsolve/numeric/data/modules`[1]);
eval(T:-Data);

For the rosenbrock method, it's perhaps less clear (to me) what one would want to find and extract. But you can mostly examine it in a similar way.

restart:
kernelopts(opaquemodules=false):
interface(verboseproc=3):
dsol := dsolve({diff(x(t),t)=sin(t), x(0)=0}, 'numeric', method=rosenbrock):
T:=eval(`dsolve/numeric/data/modules`[1]);
eval(T:-Data);
op(op(3,eval(T)))["soln_procedure"];

So, what exactly is the data stored inside the local variable _dtbl of that procedure? Can it be extracted easily (without resorting to something like ToInert)?

One can see it printed, inside the debugger. one can also follow its workings, step by step.

> f := op(op(3,eval(T)))["soln_procedure"]:
> stopat(f):
> f(4);
f:
   1*  _xout := _xin;
 
DBG> next
4
f:
   2   _pars := [];
 
DBG> next

acer

These aren't really different techniques. They're just ways of getting various effects, and may be used together or not.

You can save both procedures and modules to library archives ("repositories").

And you can keep distinct procedures' sources in separate text files, or in separate worksheets. The same goes for whole modules.

But you cannot keep the source of different module members (individual exports or locals of the same module) in separate worksheets if you intend to merge them using $include. (You might be able to use `read`, but then you could not use $define.) You can, however, keep those individual module members' sources in separate text files and merge them with those preprocessor directives.

Those directives are thus most useful for managing sources of large modules, if one wants to keep all individual members' sources separate.

You also mentioned wanting to "define" some variable's value in a separate file. For that, $define and $include are great. Also, these serve very well to keep common definitions centrally defined (just like C header files can do).

The stuff about text files being safer against corruption, and better for revision control, still holds I believe. That's not important for everyone, perhaps. And plaintext can be shared/viewed even when Maple is not available. That too, may not be important to everyone.

With the commandline interface, you can load/save sources in batch mode, or do other nifty shell scripty things to them.

acer

First 505 506 507 508 509 510 511 Last Page 507 of 592