Joe Riel

9048 Reputation

23 Badges

16 years, 345 days

MaplePrimes Activity


These are answers submitted by Joe Riel

The easy way to handle this is to input the expression as a piecewise expression then use convert/Heaviside to convert it to an expression with unit steps (Heaviside functions). Finally use inttrans[laplace] to find its Laplace transform:
f1 := piecewise(t <= 1, 0, t<=4, cos(Pi*t), 0):
f2 := convert(f1,Heaviside);
              f2 := cos(Pi t) Heaviside(-1 + t) - cos(Pi t) Heaviside(-4 + t)
inttrans[laplace](f2, t, s);
                    -s*(exp(-s)+exp(-4*s))/(s^2+Pi^2)
To input a less-than sign (<), use the html construct &lt; (the semicolon is necessary).
There shouldn't be any problem pasting multiple lines, the real issue, I suspect, is that Maple won't accept the 2D output as input. A simple way to workaround that is to use lprint (or set interface(prettyprint=1)). The output of lprint is in 1D notation, which can be pasted into an input line. If you do not want any line breaks in the output, call interface(screenwidth=infinity) before issuing lprint. You don't normally want screenwidth = infinity because it breaks Maple's normal output (which trys to center on the screenwidth). That isn't an issue with lprint, since it prints flush left. You can write a simple procedure to temporarily reassign screenwidth and print the expression in 1D format, flush left: Lprint := proc() local width; width := interface('screenwidth' = infinity); lprint(args); interface('screenwidth' = width); NULL end proc:
This is a classic case of premature evaluation. In the plot3d statement, the expression Shape(x,y) is evaluated as is, that is, with the symbolic constants x and y as arguments to Shape. Because their values are themselves, Maple cannot evaluate the conditional. There are a few ways to handle this. The simplest might be to just pass the procedure Shape to plot3d: plot3d(Shape, -100..100, -100); Note that the x and y ranges are passed as ranges, not as equations. Another possibility is to modify Shape to return an unevaluated function call to Shape when x and y are not numeric: Shape := proc(x,y) if x::numeric and y::numeric then `if`(x^2 + y^2 < (Diameter/2)^2, 1, 0); else 'Shape'(args); end if; end proc: A somewhat more robust approach would also check whether Diameter is numeric.
I'm unclear on what you are asking. Do you want the unevaluated function call myproc(x,y) to display as `x whatever y'? You can more or less accomplish that by creating a `print/myproc` procedure and using a neutral operator (see ?print and ?neutral for details).
`print/myproc` := proc(a,b) a &whatever b end proc:
myproc(a,b);
                  a &whatever b
Try using combine/power: y := 12/b/(b^s)*s/sin(Pi*b)^2*Pi^2; combine(y, power); 12/b^(s+1)*s/sin(Pi*b)^2*Pi^2

In html input mode, use &lt; and &gt; to input < and >, respectively. For an ampersand, use &

Just add the independent variables as arguments to a function call: y1(u1,u2), y2(u1,u2). A slightly nicer way to do this is to use the alias command (see ?alias for details): alias(y1=y1(u1,u2), y2=y2(u1,u2) ): J := (y1-y10)^2+(y2-Y20)^2+k*(u1)^2+k*(u2)^2: diff(J,u1); 2*(y1-y10)*(diff(y1, u1))+2*(y2-Y20)*(diff(y2, u1))+2*k*u1
Use the frontend command; it freezes various subexpressions.
z := a*f(x)+b*g(y)+c*x+d*y:
frontend(diff, [z,f(x)]);
                     a
frontend(diff, [z, x]);
                     c
The arguments of an unevaluated function call, which is what your exp(I*theta) is, can be extracted, as an expression sequence, using the op command:
op(exp(I*theta));
            exp*theta
Use op with an integer to extract a particular argument:
op(2, f(a,b,c));
                 b
Be aware that the Maple structure array has been largely superceded by Array. A simple procedure that does generates an Array, indexed from 0 to n and initialized with corresponding values 0 to n, is
MyArray := proc(n::nonnegint) Array(0..n, [seq(0..n)] ) end proc:
If you want to start the indexing from 1, you might use a Vector, which is, more or less, a one-dimensional Array with an index that starts from unity:
MyVector := proc(n::nonnegint) Vector([seq(0..n)]) end proc:
The problem is with the formal parameters. Indexed variables (the subscripted variables) don't work as formal parameters. Nor does the imaginary unit (by default `I'). It is, by the way, an appropriate place to ask.
For a few ideas, possibly not relevant to your application, you might look at a package I created quite a while ago, called manifold. It's written for Maple V R4, so is quite dated and rather crude. However, the documentation isn't too bad (there is a postscript of the typeset source code). It isn't limited to three dimensions and can integrate forms over manifolds. I don't have a local copy, but it is available here.
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);
                19683
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));
           4.528500000*Unit(min)
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);
od;
fclose(filename);
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)),{%});
  remove(`=`,%,{});
  map(curry(map,parse),%);
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.
First 105 106 107 108 109 110 Page 107 of 110