7707 Reputation

14 years, 87 days

Use sort...

p := (n+2 -k)*(n+1-k): sort(collect(p,k),k,ascending); 2 (n + 2) (n + 1) + (-2 n - 3) k + k The k^0 term is not shown.

Is this what you mean?...

I'm not sure what you want. Something like the following, where x is the variable name and 1,2,3, and 4 are sample indices (this doesn't render very well in html: 12x34. I don't believe that is any good way to do this in Maple, particularly the indices at the 1 and 2 slots. You can fake the index at the 3 slot using a power, however, that invariably causes problems. I believe we are stuck with subscripted indices only.

use fsolve...

One approach is to use fsolve. Its default is to restrict the solution to the real axis.
fsolve(subs(U(t)=x,e1), x);
2.018196123

That is a good question. The call to sum returns 0 because it is summing 0. That is, the call to G is evaluated before it is passed to sum. With symbolic arguments i and j G returns 0. There are two ways to avoid that: (1) modify G so that it returns unevaluated unless its arguments are numeric; and (2) modify the usage of G so that it doesn't get fully evaluated until being passed to sum. Let's tackle these in order. Modify G Modifying G is the more useful technique. Change it so that it returns an unevaluated call to itself when it arguments are not numeric.
G := proc(i,j)
if not [args]::list(numeric) then return 'G'(i,j) fi;
if [i,j]::list(even) then return 1 else return 0 end if;
end proc:
sum( sum( G(i,j), i=0..5 ), j=0..5 );
9
Modify the call to sum The usual way to do this is to enclose the argument in forward quotes. At the user level you will need two pairs of forward quotes:
G := (i,j) -> if is(i,even) and is(j,even) then 1; else 0; end if;
sum( sum( ''G''(i,j), i=0..5 ), j=0..5 );
9
You might be wondering why sum isn't designed to work like add, which avoids these problems. Add is able to avoid them because it uses special evaluation rules. Doing the equivalent with sum would not be useful, the reason being that sum is intended to evaluate summations and must be able to operate on expression generated outside the sum function. The summation index is not local to the sum. To see the problem do
proc()
local y,i;
y := i^2;
return [add,sum](y, i = 1..3);
end proc();
2
[3 i , 14]
The sum returns the intended value, the add does not. Joe

hidden fields...

There are opportunities to embed information within an mws file, however, as Alec mentions, it is not clear that this buys you much. For example, one possibility is to create an unnamed and unused paragraph/character style and give it unique identifier. Working on the file won't delete this style, so it should show up in the returned worksheet. Of course, the clever student (who is undoubtedly reading MaplePrimes) will know of your ploy and be able to circumvent it.

Look at inttrans...

Check out ?inttrans, specifically ?inttrans,laplace and ?inttrans,invlaplace

changing background color...

No, it currently is not possible with the Standard GUI. It is possible to change the help page background color (see my blog). It is also possible to change the background color in the Classic GUI. You could try to change the background color of all the fonts; however, the result is not pleasing---that doesn't include a lot of area.

compiler flags...

See ?define_external(COMPILE_OPTIONS). The easy way to find that is to do a text search for flag in the help browser; that page is the second hit.

syntax is wrong...

You are using what appears to be Mathematica functional syntax. Maple uses parentheses to delimit functional arguments. You want sqrt(x^2-0.2^2)/sqrt(x^2-0.3^2)*(0.3/x). Note that this is an expression, not a procedure. You also wont get a numerical result unless x has been assigned a value.

saving...

There is more than one way to do this. Probably the most useful is to save the procedures/modules to a Maple repository. The easiest way to do that is to use the LibraryTools procedure. For example, restart; myproc := proc() print("it worked"); NULL end proc: mylib := "/home/joe/tmp/mylib.mla": LibraryTools:-Save('myproc',mylib): restart; mylib := "/home/joe/tmp/mylib.mla": libname := libname,mylib: myproc(); "it worked" Note that for maple to find the library, it (or the directory in which it is located) needs to be part of libname. A word of caution. If the archive (repository) is not specified, Maple uses whatever is assigned to savelibname. If that isn't assigned I believe it uses the first library in libname. That may be the main Maple library. You should verify that the main Maple library is write-protected. I don't know what the default is on Windows systems. This isn't, of course, the whole story. If you are developing modules, say, and repeatedly save them to an existing repository, at some point you will want to clean up that repository. Actually, I've found that it is frequently easier to just delete it, however, that might not be possible if you are storing procedures from other sources in it. Look at the help page for march, the Maple archive utility. Also, check out the worksheet,reference,initialization help page. It describes how to create a Maple initialization file. You can set libname in there so that all subsequent interactions with Maple have access to your library without having to explicity reassign libname.

signum and csgn...

While your integral is unreadable, the signum and csgn functions in the output are maple's way of handling missing information about e and a. To avoid them, you need to tell give maple more information, say, e and a are both positive. You can do this using assuming: int( your_integrand, ...) assuming a::positive, e::positive; Look up ?signum and ?csgn to see what they do.

Here's one approach...

I'm not sure what you want, but will guess that you want to plot three points, with time on the horizontal axis. The only difficulty is converting a general timestamp into a value. I thought Maple had a function for doing this, i.e. generating the epoch from an arbitrary date/time, but couldn't find it, so I rolled my own. It's crude; it ignores subtleties like leap years. restart; toepoch := proc(timestamp::string) local dt; description "convert timestamp to seconds (crudely)"; uses StringTools; dt := ParseTime("%b %e %Y %T", timestamp); dt:-second + 60*(dt:-minute + 60*(dt:-hour + (24*(dt:-yearDay + 365*dt:-year)))) end proc: data := [NULL ,[43.69, "Apr 08 2004 10:41:45 PDT"] ,[40, "Apr 07 2004 22:48:47 PDT"] ,[32.5, "Apr 06 2004 06:13:30 PDT"] ]: pts := map(d -> [toepoch(d),d], data); plot(pts, s_tyle=point, symbol=BOX); The s_tyle should be style, however, the pre tag won't accept the word styleThe horizontal axis is not particularly useful (being in seconds, scaled from two millenia ago).

define inequality for vectors (lists)...

First, you need to define what you mean by, say, [a,b] < [c,d]. Does that mean (a < c) and (b < d)? Assuming so, you could try something like
# This isn't particularly efficient

ListInequality := proc(f,v1::list,v2::list)::truefalse;
evalb(foldl(`and`, zip(f, v1, v2)[]))
end proc:

`&<` := proc(v1,v2) ListInequality(`<`,v1,v2) end proc:

vf := v -> piecewise((3*v) &< [6,1] and v &< [-2,5],  [3,4] + 3*v
,(2*v) &< [8,-4] and (-v) &< [2,-5], [1,9] + 2*v
,(-3*v) &< [-6,-1] and (-2*v) &< [-8,4], [9,5]
,'whatever'
):

vf([-3,0]);
[-6, 4]

printing dsolve output to a file...

The usual technique would be to use fprintf. For example,
restart;
deq1 := (t+1)^2*diff(y(t),t,t) + (t+1)*diff(y(t),t)
+ ((t+1)^2-0.25)*y(t) = 0:
ic1 := (y(0) = 0.6713967071418030
,D(y)(0) = 0.09540051444747446):
dsol1 := dsolve({deq1,ic1}, numeric, range=0..1):

file := "data.txt":
try
fd := fopen(file,'WRITE','TEXT');
for tt from 0 to 1 by 0.1 do
fprintf(fd,"%a %a %a\n"
,eval([t,y(t),diff(y(t),t)],dsol1(tt))[])
od;
finally close(file)
end try:

inputing symbols in maple input mode...

Another way to input the symbol, particularly useful for those of us who prefer maple input format, is to just type `∂`. Note the ampersand and semicolon in the backquotes, they delimit the base name and are displayed as a single symbol in the Standard GUI. You can extend this technique to string together symbols. For example, if you want to create `∂𝔅` type `PartialD;𝔅`, where `𝔅` is the Fraktur "B" (`𝔅`). As a side note, to print `∂𝔅` in this forum, use the <maple> tag: <maple>`∂𝔅`</maple>. Use lprint to find the name of a particular symbol. For example, in maple input mode, go to an empty input line, type ctrl-R (enter 2D math mode), select the symbol of interest from a palette, then hit return. The symbol is displayed. Next, type lprint(%);. That prints the character version of the symbol.
 First 98 99 100 Page 100 of 100
﻿