9 years, 51 days

These are answers submitted by acer


18 hours ago acer 10531
2 0

How you go about it may depend on whether you want to be able to programmatically access any displayed values after manually updating them in the tabulated representation.

If you insert a DataTable Embedded Component from the palettes then you can associate that with a Matrix or Array. This includes the functionality that if you update the Matrix then the DataTable entry reflects that. And vice versa. Also, you can put customized row and column headers on the Component. There is no command at present to insert such a DataTable via a command. (I suspect that it might be done with some very low level XML manipulation, but it is not straightforward and the insertion may be buggy.)

If you only need to display the data and not to interact with it (as you've stated is the case) then there are some undocumented routines that can accomplish this. (These are evident by inspectng the Explore:-ModuleApply and ImageTools:-Embed library procedures.) Of course your success might be limited, with undocumented routines. For example, using Maple 18.01, with the purely numeric entries of data being represented as strings,


makegrid := proc(M::Matrix)
  uses DocumentTools:-Layout;
  local i,j,m,n,wks;
  m,n := op(1,M);
  wks := Worksheet(Table(alignment=center,width=20,
end proc:



In Maple 17 the following seems possible. This makes a little effort at weighting the width of the columns according to string length. (That weighting will break down if the entries are long enough to line-wrap, I think.)


grid := proc(M::Matrix)
  uses DocumentTools:-Layout;
  local i,j,Ms,m,n,wks;
end proc:



The mechanism used above is not in Maple 16 or earlier, so this won't work there.


expression or procedure/operator?

November 18 2014 acer 10531
1 1

You wrote that f(t) is a "function". It's not clear whether you mean an expression such as t*sin(t) or an operator (or procedure) such as t->t*sin(t).

Several others have show you different ways of mapping an operator/procedure `f` across a list of values. If your `f` is already a procedure or operator then Carls' and Kitonum's Answers should work fine.

However you also used the word `subs`. So it seems to me that you might possibly have an expression rather than a procedure. If that is in fact your situation then you could do one of the following:

1) Use `unapply` to obtain an operator from the expression, then follow the other suitable Answers.


2) produce a sequence involving `f` with `t` taken from the list. Eg,

T := [0,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1]:
f := t^2: 

[ seq( f, t=T ) ];

              [0, 0.04, 0.09, 0.16, 0.25, 0.36, 0.49, 0.64, 0.81, 1]


3) (awkwardly, IMO) map 2-argument eval across the list via a custom operator, Eg,

map( x->eval(f,t=x), T );

              [0, 0.04, 0.09, 0.16, 0.25, 0.36, 0.49, 0.64, 0.81, 1]

If you already have an operator like f=t->t^2 then going the route of turning that into an expression by invoking f(t) say, and then doing 2) above, requires having a free dummy variable. (I never understand why people create operators simply to invoke then one single time. Yet it's quite common to see people start with an expression, unapply it, then apply it as the argument to `plot`, etc.)



November 18 2014 acer 10531
0 1

You have not indicated very clearly in your question whether you will accept F or G appearing in the representation of B/A and C/A, or not. I am supposing that it is ok for them to appear. You give only a somewhat inarticulate hint that F,G are to be treated differently than `kappa`, `k`,  and `a`, in my opinion.

You can eliminate A,B and C from the four equations. The eliminate command can so that, for this example, as well as provide an additional result (which will still hold for the remaining F and G).


eq1 := A+B=F+G:
eq2 := k*(A-B)=kappa*(F-G):
eq3 := F*exp(I*kappa*a)+G*exp(-I*kappa*a)=C*exp(I*k*a):
eq4 := kappa*F*exp(I*kappa*a)-kappa*G*exp(-I*kappa*a)=k*C*exp(I*k*a):

S := {eq1,eq2,eq3,eq4}:

Q := eliminate( S, {A,B,C} ):

B/A = eval(B/A,Q[1]);

                      B   F k - F kappa + G k + G kappa
                      - = -----------------------------
                      A   F k + F kappa + G k - G kappa

C/A = eval(C/A,Q[1]);

               C   2 (F exp(I kappa a) + G exp(-I kappa a)) k
               - = ------------------------------------------
               A   exp(I k a) (F k + F kappa + G k - G kappa)

# The second part of the result Q from `eliminate` indicates a remaining
# restriction on the remaining names F,G,a,k, and kappa. If you wish, you can solve this
# for F (or G) for this example. But you don't have to. The elements of the set
# Q[2] are implicitly equal to zero (though below I explicitly make an equation
# of it, just to make the point).


     {F exp(I kappa a) k - kappa F exp(I kappa a) + G exp(-I kappa a) k

        + kappa G exp(-I kappa a) = 0}

That remaining restriction on F,G,a,k, and kappa can be used to remove F and G from the representation above for B/A and C/A.

R := solve(Q[2],F);
normal( eval( eval(B/A,Q[1]), R ) );
normal( eval( eval(C/A,Q[1]), R ) );

As Carl's showed, if you don't want F and G to appear then you might as well just do a single `solve` for {A,B,C,F}. Or you could use eliminate with 4 names,

T := eliminate( S, {A,B,C,F} ):
B/A = eval(B/A,T[1]);
C/A = eval(C/A,T[1]);

In some other example it may happen than you can eliminate A,B, and C but not all other instances of some specific subset of the remaining names.



November 18 2014 acer 10531
1 0

It may not always help. but it quite often comes up that there is some benefit to preventing `evalf/int` from poking too hard at the integrand as an expression. One way to get that is to make the integrand an operator rather than an expression.

I suppose you realize that this is a nasty looking integral. It is very small for most of x=0..1, and then up around the range 0.93..1 it becomes very large. Well, it becomes larger than fits within the range of double-precision. Hence it may be beneficial to prevent `evalf/int` from using `evalhf` and concluding that the answer is Float(infinity).

As mentioned, this kind of approach is not going to always work. Nothing will always work. However, for this particular example,


y := 1: z := 2 + x + y: s := 1/2:
m2 := 5325: m1 := 5279: mz := 106055/10:

igrand := 1/z^3 *(x + y + 2* x*y)* (1 + s^2/(2 *m2^2* z))
          *exp(-(m2^2*x + m1^2*y)/s^2 + (mz^2 *(x + y + 2 *x*y))/(2* s^2* z)):

evalf(Int(unapply(igrand,x), 0..1.0, digits=136, epsilon=1e-10)):
                             8.629559550 10     

With regard to your broader question, you could try saving your partial results before problematic calls, if you know what they are.



November 17 2014 acer 10531
1 0

Your guess is right, the procedure normally sees only the evaluated argument and not the name (to which it was assigned) that is used in the call.

However, there are some other ways to go about it.

One way is to call the procedure with an invocation using unevaluation quotes on the arguments. This works easily without having the procedure's parameters be specified (by type, or in number). This has the benefit (if I understand your wish rightly) of not requiring knowledge of the number of arguments at the time the procedure is defined.


  local x;
  for x in [_passed] do
  end do;
end proc:


p( 'A', 'B[1]' );
                                   A, [4]
                                  B[1], [7]

Another couple of ways involve using the uneval or evaln modifiers of parameters of a procedure. Unfortunately those cannot be used directly with the seq modifier, so it's not simple to be able to pass a sequence of such (whose number is not known in advance of defining the procedure).

Using A and B[1] from above,

p2 := proc( y::uneval, w::uneval)
  local x;
  for x in [y,w] do
    print( eval(x,1), eval(x,2) );
  end do;
end proc:

p2( A, B[1] );
                                   A, [4]
                                  B[1], [7]

p3 := proc( y::evaln, w::evaln )
  local x;
  for x in [y,w] do
    print( eval(x,1), eval(x,2) );
  end do;
end proc:

p3( A, B[1] );
                                   A, [4]
                                  B[1], [7]



November 14 2014 acer 10531
1 0

Firstly, it is spelled with a capital J. It is Jacobian, not jacobian.

Secondly, make sure that you are not entering rsin(t) when you meant r*sin(t). otherwise you'll just get the single name rsin. The same goes for rcos.

Thirdly, it appears that you already have the name r assigned to something else (a failed call to RandomMatrix, without loading the LinearAlgebra package?). You can undo that using the unassign command, or by issuing the command r:='r'. Or don't make that assignment before your current example.

Fourthly, make sure that you have either loaded the package using the command with(VectorCalculus) or you are calling it by its long-form name. Eg,

VectorCalculus:-Jacobian([r*cos(t), r*sin(t), r^2*t], [r, t]);

                             [cos(t)    -r sin(t)]
                             [                   ]
                             [sin(t)    r cos(t) ]
                             [                   ]
                             [              2    ]
                             [2 r t        r     ]


jre 1.6?

November 10 2014 acer 10531
1 1

Which java runtime do you have? It's possible to have multiple java runtimes even on OSX, I believe. If it is java 7 then could you try adding the JRE 1.6 (required for Maple 18) runtime obtained from Apple (legacy Java SE 6?)?

If you already have that java version then sorry, I don't have another suggestion.



November 09 2014 acer 10531
2 5

Your preamble loads the Physics package, etc, which rebinds `.`.

Those invocations of `.` result in z1 being a Physics:-`*` function call (in stock Maple 18.01).


Physics:-Setup(mathematicalnotation = true): 
Physics:-Setup(anticommutativeprefix = psi):
ap1 := Physics:-Creation(psi, 1, notation = explicit):
am1 := Physics:-Annihilation(psi, 1, notation = explicit): 
ap2 := Physics:-Creation(psi, 2, notation = explicit):
am2 := Physics:-Annihilation(psi, 2, notation = explicit):

z1 := ap1 . am1 . ap2:

type(z1, specfunc(anything, Physics:-`*`));



before writing?

November 05 2014 acer 10531
0 1

Why not substitute before writing to the file?

f := x-> arcsin(x):

str := StringTools:-Substitute(sprintf("%a",f(1)),"Pi","pi"):


file := cat(kernelopts(homedir),"/Documents/foo.txt"):





it ought to..

November 05 2014 acer 10531
1 6

It ought to be able to do that. See the Student[NumericalAnalysis][LinearSolve] command.



November 04 2014 acer 10531
0 2

For this example the result T below of a simple call to `solve` produces results which involve inequalities of only rational polynomials. And those are accepted by solve(...,x,parametric).

ee := 1/x < abs((x+4)/(x*a+2)):

T := [ solve(ee) ];


The last result is a sequence of separate solutions, which might be considered together.

Stitching all the solutions back together after appropriate re-interpretation (Or, And, NULL, or what have you) , and simplifying, might be an irksome amount of bookkeeping. I don't know whether it's reasonable to attempt using `solve` to do that too.

In other words it seems as if your example is one which solve,parametric can be used to handle manually (even though it's not in the class which solve,parametric accepts outright). 



November 04 2014 acer 10531
1 0

Your scheme works for me if the semicolons are escaped in the strings. Ie, the data file having as its first line,

c "a:=1\;" -c "b:=2\;" -c "c:=3\;"

You could also use Maple's ability to do multiple assignment in a single statement, ie,

-c "a,b,c:=1,2,3\;"

If you want to get fancier with scripting (on a unix-like system such as Linux, say), you could look at this old thread.



November 04 2014 acer 10531
2 1
applyrule( n::posint*F(K,L) = F(n*K,n*L), 2*F(K,L) );

                          F(2 K, 2 L)

Your original will match in the first of the following cases (but apparently you want it to match according to a specific typed pattern).

Observe the differences,

applyrule( n*F(K,L) = F(n*K,n*L), n*F(K,L) );

                          F(n K, n L)

applyrule( n*F(K,L) = F(n*K,n*L), p*F(K,L) );

                           p F(K, L)

applyrule( n::name*F(K,L) = F(n*K,n*L), p*F(K,L) );

                          F(p K, p L)


numeric event handler

October 31 2014 acer 10531
2 1

You could define your own numeric event handler, to trap this situation and then (internal to that handler procedure) it could set a global flag which let you know that something specific happened.

A numeric event may not always be trapped with try...catch.



October 31 2014 acer 10531
1 0

A symmatric `table` has this property. A nice flexibilty of a `table` is that you don't need to set explicit finite limits on the bounds, up front. And it can be indexed by non-numeric symbolic index values.

T[i,j,k,l], T[j,k,i,l];

                        T[i, j, k, l], T[i, j, k, l]

T[2,3,1,U] := 4:



For a (two dimensional) Matrix, there is the `shape=symmetric` option, which gives the same effect but needs explicit finite bounds for the indices which begin at 1 (one).

For higher dimension Arrays it is not difficult to write a custon indexing-function with the same properties. (I saw someone do it once, forget who... If you want I could recreate it.) This too would be for explicit finite index bounds.


1 2 3 4 5 6 7 Last Page 1 of 102