Joe Riel

9500 Reputation

23 Badges

18 years, 138 days

MaplePrimes Activity

These are answers submitted by Joe Riel

To generate all permutations, do
> with(combinat):
> perms := permute([1$9,2$9,3$9],9): # you don't want to print them
> perms[1];
         [1, 1, 1, 1, 1, 1, 1, 1, 1]
> perms[234];
         [1, 1, 1, 1, 3, 3, 2, 3, 3]
> perms[-1]; # last one
         [3, 3, 3, 3, 3, 3, 3, 3, 3]
To just count the number of permutations, you can do
> numbperm([1$9,2$9,3$9],9);
How long did you wait? Does your loop do anything? On my machine:
convert(90*time(proc() to 10^7 do od end())*Unit(sec), units, Unit(minute));
Maple V R5 is old; I don't have a version that runs on Linux, so can only give some hints. First, read the file as one long text string. One way is to read each line and catenate:
fd := fopen(filename);
input := "";
line := readline(fd);
while line <> 0 do
   input := cat(input,line);
   line := readline(fd);
Now you need to convert `input' to a set of sets of characters. In Maple 10 this can be readily accomplished with
use StringTools in
  RegSplit("[^a-zA-Z]", input);
  map(str -> {op}(Explode(str)),{%});
end use;
With Maple V you have some work to do. You'll need to use the substring command to access each character, then determine whether to convert it to a name (via parse) or to split the string and start a new set. I don't recall whether Maple V has any regular expression matching, I think not. So you might designate just a few characters as `splitters' (comma, space, newline) and check for those individually.
I've always used rpn (first was my dad's HP-35) and struggle with algebraic entry. I've owned an HP-15 since they came on the market (early 80s). About six years ago there was a version of Maple that ran on a handheld device, a Casioppia, I believe. I got to use it for a few months. It proved useful when I was consulting and didn't have a laptop (still don't).
Use the print command. If a copyright is included in the options statetement, you will also need to set interface(verboseproc=2), otherwise, in the gui it is displayed as proc() ... end proc.
Try the following
i := diff(q(t),t);
et := convert(piecewise(t<1,0,t<3,100,0),Heaviside);
odeQ := eval( KirchoffLaw, {E[emf]=et,R=50,C=0.01,L=1});
ics:=q(0)=0, D(q)(0)=0;
Check out the VectorCalculus package (?VectorCalculus). The ?examples,VectorCalculus worksheet gives examples of line integrals.
In the Standard GUI you can create symbols with arrows over them. Open the Layout palette, insert the Symbol with the `b' over the `A', then open the Arrows palette and change the `b' to the desired arrow shape. If you use lprint to print the Maple output, you can see how to create this via typing. The code inserted by the palettes contains optional fields to set the colors. If you are happy with the defaults you can omit them and then do, for example:
xvec := `#mover(mi("x"),mo("&rarr;"))`;
That displays xvec as an x with a right pointing arrow on top. Now, if you actually want to assign a Vector to the fancy x, things get a little tricker. Messing with the palettes gets tedius, so, you could set an alias (see ?alias for details). Using worksheet mode in the Standard GUI you could do
alias(`#mover(mi("x"),mo("&→"))` = xvec):
If you then type
xvec := <1,2,3,4>;
an assignment is displayed with the left side being the x with the arrow over it, the right side being the Vector. This can also be done in Document mode, but because the left side of assignments are normally suppressed, the x with an → over it is not shown, so there isn't much point. To simplify the process you can assign a procedure
MakeVector := x ->  nprintf("#mover(mi(\"%A\"),mo(\"&rarr;\"))", x):
then use it as
alias(MakeVector(x) = xvec, MakeVector(y) = yvec):
xvec := <1,2,3>;
yvec := <4,5,6>;
I'll assume that you are looking for a numeric, rather than symbolic, solution (good luck with the latter). The following works: y := sin(x)/x: dy := diff(y,x): sol := fsolve(dy,{x},0..10); # the third parameter restricts the domain sol := {x = 4.493409458} eval(dy,sol); # check the result 1*10^(-11) eval(y,sol); # evaluate the expression -0.2172336282
Here's one way, probably not the best.
tmp := Int(D[3](F)(x,t,y(x,t),diff(y(x,t),x),diff(diff(y(x,t),t),x))(diff(yv(x,t),t,x)),t):
tmp2 := convert(tmp,D):
indets(tmp2, typefunc(anything, typefunc(identical(yv),specindex(posint,D)))):
                  {diff(yv(x, t), x, t)}

Your observation is correct, collect works with power of integers, not symbolics. For the simple example you gave, factor will do nicely. However, consider

poly := a*x^b + x^b + a*x^(b+1) + c*x^(b+1);

The collect command can also handle unevaluated function calls, so one approach is to convert the monomial terms to function calls, collect, then convert back:

subsindets(poly, identical(x)^anything, () -> f(op(args)));

         a*f(x, b) + f(x, b) + a*f(x, b + 1) + c*f(x, b + 1)


                (a + 1)*f(x, b) + (a + c)*f(x, b + 1)

eval(%, f=`^`);

                 (a + 1)*x^b + (a + c)*x^(b+1)
An easy way to express the surface is in cylindrical coordinates. Thus,
plot3d(1/z, theta=0..2*Pi, z = 1..20, coords=cylindrical);
should do the trick.
It cannot. A 1x1 matrix (or Matrix) is not a scalar. Consider the product of three vectors/covectors: (mx1)(1xn)(nx1). You want to rearrange this as (1xn)(nx1)(mx1). However, if that were done, then associativity wouldn't hold, that is, (nx1)(mx1) is undefined.
Use LinearAlgebra:-Equal to test equality of Matrices (with expressions as elements). For more general testing, you can use verify (with appropriate verification argument).
A := <<1,2>>:
B := Copy(A):

A := <<1,2>>:
B := <<1.001, 1.99>>:

Use exp(x) for e^x
First 109 110 111 112 113 114 Page 111 of 114