DuncanA

698 Reputation

8 Badges

15 years, 144 days

MaplePrimes Activity


These are answers submitted by DuncanA

This gives the same result as your example

Matrix(3, (i,j) -> `if`(i <= j, Matrix(2, [seq(x[i,j], k = 1 .. 4)]), Matrix(2)));

Matrix(3, (i,j) -> `if`(i <= j, Matrix(2, [seq(x[i,j], k = 1 .. 4)]), Matrix(2)))

Duncan

Nextprime is one possibility n := 300; p := x^n; p := Nextprime(p, x) mod 2; while Primitive(p) mod 2 = false do p := Nextprime(p, x) mod 2; end do; Primitive(p) mod 2; Randprime is another possibility n := 20: p := Randprime(n, x) mod 2; while Primitive(p) mod 2 = false do p := Randprime(n, x) mod 2; end do; Primitive(p) mod 2;

The LinearAlgebra package provides the SubVector command to construct a subvector of a Vector:

v := <9,8,5,7>:
n := 4:
v2 := LinearAlgebra:-SubVector(v, [1 .. n-1, n+1 .. -1]); # remove the n'th entry
                                        [9]
                                        [ ]
                                  v2 := [8]
                                        [ ]
                                        [5]

To remove several entries at once:

A:=<4,5,3,0,8,12>:
elim := [2,3,5]: 
idx := [$ 1 .. LinearAlgebra:-Dimension(A)]; # The indices of 'A' in increasing order

                          idx := [1, 2, 3, 4, 5, 6]

keep := subsop(seq(i=NULL, i in elim), idx);
                              keep := [1, 4, 6]

v3 := LinearAlgebra:-SubVector(A, keep);
                                       [ 4]
                                       [  ]
                                 v3 := [ 0]
                                       [  ]
                                       [12]

The "save" command can be used to save assigned names to a file. The help page for this command can be found by typing

?save

at a command prompt. The "read" command can be used to read a saved file. "writeto" and "appendto" may also be useful.

The Import command from the ExcelTools package can be used to import an Excel worksheet into Maple.
The function should be defined as f:=x->1-abs(x); instead of f(x):=1-abs(x); and the font options (labelfont and font) used in the plot command should be uppercase, e.g., [HELVETICA, BOLD, 12]. Duncan
The literal translation of Integral{f(t)*Jn(s*t)*t dt, t:0->inf} into Maple code is int(f(t) * BesselJ(0, s*t) * t, t = 0 .. infinity);. For f(t)=exp(-Pi*t^2), int(exp(-Pi*t^2) * BesselJ(0, s * t) * t, t = 0 .. infinity); gives (1/2)*exp(-(1/4)*s^2/Pi)/Pi. To reduce the number of factors of 2*Pi, an alternative version of the transform is 2 * Pi * int(exp(-Pi*t^2) * BesselJ(0, 2 * Pi * s * t) * t, t = 0 .. infinity);

If you are a Windows user you can download Microsoft Visual C++ 2008 Express Edition free from Microsoft's website and configure it to edit .mpl files and call Command-line Maple with your .mpl files as an argument.

After installing MSVC++  Express Edition, select Tools > External Tools from the menu system. In the resulting pop-up box, click the "Add" button to add a new menu item then enter the following.

   Title:    &Maple

   Command:    C:\Program Files\Maple 12\bin.win\cmaple.exe   (or whatever the path is to your Command-line Maple executable)

   Arguments:    $(ItemFileName)$(ItemExt)

   Initial directory:    $(ItemDir)

Then click "Ok"

This will add a "Maple" menu item to the Tools menu. You can then edit .mpl files in the editor. After saving, select Tools > Maple from the menu system and the .mpl file will execute in Command-line Maple.

Duncan

5 6 7 Page 7 of 7