MaplePrimes Announcement

VerifyTools is a package that has been available in Maple for roughly 24 years, but until now it has never been documented, as it was originally intended for internal use only. Documentation for it will be included in the next release of Maple. Here is a preview:

VerifyTools is similar to the TypeTools package. A type is essentially a predicate that a single expression can either satisfy or not. Analogously, a verification is a predicate that applies to a pair of expressions, comparing them. Just as types can be combined to produce compound types, verifications can also be combined to produce compund verifications. New types can be created, retrieved, queried, or deleted using the commands AddType, GetType (or GetTypes), Exists, and RemoveType, respectively. Similarly in the VerifyTools package we can create, retrieve, query or delete verifications using AddVerification, GetVerification (or GetVerifications), Exists, and RemoveVerification.

The package command VerifyTools:-Verify is also available as the top-level Maple command verify which should already be familiar to expert Maple users. Similarly, the command VerifyTools:-IsVerification is also available as a type, that is,

VerifyTools:-IsVerification(ver);

will return the same as

type(ver, 'verification');

The following examples show what can be done with these commands. Note that in each example where the Verify command is used, it is equivalent to the top-level Maple command verify. (Also note that VerifyTools commands shown below will be slightly different compared to the Maple2024 version):

with(VerifyTools):

Suppose we want to create a verification which will checks that the length of a result has not increased compared to the expected result. We can do this using the AddVerification command:

AddVerification(length_not_increased, (a, b) -> evalb(length(a) <= length(b)));

First, we can check the existence of our new verification and get its value:

Exists(length_not_increased);

true

GetVerification(length_not_increased);

proc (a, b) options operator, arrow; evalb(length(a) <= length(b)) end proc

For named verifications, IsVerification is equivalent to Exists (since names are only recognized as verifications if an entry exists for them in the verification database):

IsVerification(length_not_increased);

true

On the other hand, a nontrivial structured verification can be checked with IsVerification,

IsVerification(boolean = length_not_increased);

true

whereas Exists only accepts names:

Exists(boolean = length_not_increased);

Error, invalid input: VerifyTools:-Exists expects its 1st argument, x, to be of type symbol, but received boolean = length_not_increased

The preceding command using Exists is also equivalent to the following type call:

type(boolean = length_not_increased, verification);

true

Now, let's use the new verification:

Verify(x + 1/x, (x^2 + 1)/x, length_not_increased);

true

Verify((x^2 + 1)/x, x + 1/x, length_not_increased);

false

Finally, let's remove the verification:

RemoveVerification(length_not_increased);

Exists(length_not_increased);

false

GetVerification(length_not_increased);

Error, (in VerifyTools:-GetVerification) length_not_increased is not a recognized verification

GetVerifications returns the list of all verifications known to the system:

GetVerifications();

[Array, FAIL, FrobeniusGroupId, Global, Matrix, MultiSet, PermGroup, RootOf, SmallGroupId, Vector, address, after, approx, array, as_list, as_multiset, as_set, attributes, boolean, box, cbox, curve, curves, dataframe, dataseries, default, default, dummyvariable, equal, evala, evalc, expand, false, float, function, function_bounds, function_curve, function_shells, greater_equal, greater_than, in_convex_polygon, indef_int, interval, less_equal, less_than, list, listlist, matrix, member, multiset, neighborhood, neighbourhood, normal, permute_elements, plot, plot3d, plot_distance, plotthing_compile_result, polynom, procedure, ptbox, range, rational, record, relation, reverse, rifset, rifsimp, rtable, set, sign, simplify, sublist, `subset`, subtype, superlist, superset, supertype, symbol, table, table_indices, testeq, text, true, truefalse, type, undefined, units, vector, verifyfunc, wildcard, xmltree, xvm]

Download VerificationTools_blogpost.mw

Austin Roche
Software Architect
Mathematical Software
Maplesoft

Featured Post

Hello!

I present a simple work-up of rolling a plane curve along a fixed plane curve in 2d space. Maple sources are attached.

Kind regards!

Source.zip

Featured Post

In this post, I would like to share some exercises that I recently taught to an undergraduate student using Maple. These exercises aimed to deepen their understanding of mathematical concepts through computational exploration and visualization. With its powerful symbolic computation capabilities, Maple proved to be an excellent tool for this purpose. Below, I present a few of the exercises and the insights they provided. Interestingly, the student found Maple to be more user-friendly and efficient compared to the software he usually uses for his studies. Below, I present a few of the exercises and the insights they provided.

One of the first topics we tackled was the Fourier series. We used Maple to illustrate how the Fourier series approximates a given function as more terms are added. We explored this through both static plots and interactive animations.

To help the student understand the behavior of different types of functions, we defined piecewise functions using Maple's piecewise command. This allowed us to model functions that behave differently over various intervals, such as the following cubic function exercise

Maple's Explore command was an effective tool for creating an interactive learning environment. We used it to create sliders that allowed the student to vary parameters, such as the number of terms in a Fourier series, and see the immediate impact on the plot.

restart; with(plots)

" F(x):={[[-1,-1<x<0],[1,0<x<1]];  "

proc (x) options operator, arrow, function_assign; piecewise(-1 < x and x < 0, -1, 0 < x and x < 1, 1) end proc

(1)

p1 := plot(piecewise(-3 < x and x < -1, F(x+2), -1 < x and x < 1, F(x), 1 < x and x < 3, F(x-2)), x = -3 .. 3, color = blue)

 

L := 2; a__0 := (int(F(x), x = -(1/2)*L .. (1/2)*L))/L

0

(2)

a__n := proc (n) options operator, arrow; 2*(int(F(x)*cos(2*n*Pi*x/L), x = -(1/2)*L .. (1/2)*L))/L end proc

proc (n) options operator, arrow; 2*(int(F(x)*cos(2*n*Pi*x/L), x = -(1/2)*L .. (1/2)*L))/L end proc

(3)

b__n := proc (n) options operator, arrow; 2*(int(F(x)*sin(2*n*Pi*x/L), x = -(1/2)*L .. (1/2)*L))/L end proc

proc (n) options operator, arrow; 2*(int(F(x)*sin(2*n*Pi*x/L), x = -(1/2)*L .. (1/2)*L))/L end proc

(4)

" #` Fourier series function`  `F__fourier`(x,N):=`a__0`+(&sum;)(`a__n`(n)&lowast;cos(2 * n * Pi * x / L) +`b__n`(n)&lowast;sin(2* n * Pi * x / L));"

proc (x, N) options operator, arrow, function_assign; a__0+sum(a__n(n)*cos(2*n*Pi*x/L)+b__n(n)*sin(2*n*Pi*x/L), n = 1 .. N) end proc

(5)

p2 := plot([F__fourier(x, 40)], x = -3 .. 3, numpoints = 200, color = [purple])

display([p1, p2])

 

Explore(plot([piecewise(-3 < x and x < -1, F(x+2), -1 < x and x < 1, F(x), 1 < x and x < 3, F(x-2)), F__fourier(x, N)], x = -3 .. 3, color = [blue, purple], numpoints = 200), N = 1 .. 40, title = "Fourier Series Approximation with N Terms")

restart; with(plots)

" #` Define the piecewise function`  F(x):={[[0,-1<x<0],[x^(2),0<x<1]];  "

proc (x) options operator, arrow, function_assign; piecewise(-1 < x and x < 0, 0, 0 < x and x < 1, x^2) end proc

(6)

p3 := plot(piecewise(-3 < x and x < -1, F(x+2), -1 < x and x < 1, F(x), 1 < x and x < 3, F(x-2)), x = -3 .. 3, color = blue)

 

L := 2; a__0 := (int(F(x), x = -(1/2)*L .. (1/2)*L))/L

1/6

(7)

a__n := proc (n) options operator, arrow; 2*(int(F(x)*cos(2*n*Pi*x/L), x = -(1/2)*L .. (1/2)*L))/L end proc

proc (n) options operator, arrow; 2*(int(F(x)*cos(2*n*Pi*x/L), x = -(1/2)*L .. (1/2)*L))/L end proc

(8)

b__n := proc (n) options operator, arrow; 2*(int(F(x)*sin(2*n*Pi*x/L), x = -(1/2)*L .. (1/2)*L))/L end proc

proc (n) options operator, arrow; 2*(int(F(x)*sin(2*n*Pi*x/L), x = -(1/2)*L .. (1/2)*L))/L end proc

(9)

" #` Fourier series function`  `F__fourier`(x,N):=`a__0`+(&sum;)(`a__n`(n)&lowast;cos(2 * n * Pi * x / L) +`b__n`(n)&lowast;sin(2* n * Pi * x / L));"

proc (x, N) options operator, arrow, function_assign; a__0+sum(a__n(n)*cos(2*n*Pi*x/L)+b__n(n)*sin(2*n*Pi*x/L), n = 1 .. N) end proc

(10)

p4 := plot([F__fourier(x, 40)], x = -3 .. 3, numpoints = 200, color = [purple])

display([p3, p4])

 

Explore(plot([piecewise(-3 < x and x < -1, F(x+2), -1 < x and x < 1, F(x), 1 < x and x < 3, F(x-2)), F__fourier(x, N)], x = -3 .. 3, color = [blue, purple], numpoints = 200), N = 1 .. 40, title = "Fourier Series Approximation with N Terms")

restart; with(plots)

" #` Define the piecewise function`  F(x):={[[x+2,-2<x<0],[2-2 x,0<x<2]]; "

proc (x) options operator, arrow, function_assign; piecewise(-2 < x and x < 0, x+2, 0 < x and x < 2, 2-2*x) end proc

(11)

p5 := plot(piecewise(-3 < x and x < -1, F(x+2), -1 < x and x < 1, F(x), 1 < x and x < 3, F(x-2)), x = -3 .. 3, color = blue)

 

L := 2; a__0 := (int(F(x), x = -(1/2)*L .. (1/2)*L))/L

5/4

(12)

a__n := proc (n) options operator, arrow; 2*(int(F(x)*cos(2*n*Pi*x/L), x = -(1/2)*L .. (1/2)*L))/L end proc

proc (n) options operator, arrow; 2*(int(F(x)*cos(2*n*Pi*x/L), x = -(1/2)*L .. (1/2)*L))/L end proc

(13)

b__n := proc (n) options operator, arrow; 2*(int(F(x)*sin(2*n*Pi*x/L), x = -(1/2)*L .. (1/2)*L))/L end proc

proc (n) options operator, arrow; 2*(int(F(x)*sin(2*n*Pi*x/L), x = -(1/2)*L .. (1/2)*L))/L end proc

(14)

" #` Fourier series function`  `F__fourier`(x,N):=`a__0`+(&sum;)(`a__n`(n)&lowast;cos(2 * n * Pi * x / L) +`b__n`(n)&lowast;sin(2* n * Pi * x / L));"

proc (x, N) options operator, arrow, function_assign; a__0+sum(a__n(n)*cos(2*n*Pi*x/L)+b__n(n)*sin(2*n*Pi*x/L), n = 1 .. N) end proc

(15)

p6 := plot([F__fourier(x, 40)], x = -3 .. 3, numpoints = 200, color = [purple])

display([p5, p6])

 

Explore(plot([piecewise(-3 < x and x < -1, F(x+2), -1 < x and x < 1, F(x), 1 < x and x < 3, F(x-2)), F__fourier(x, N)], x = -3 .. 3, color = [blue, purple], numpoints = 200), N = 1 .. 40, title = "Fourier Series Approximation with N Terms")

restart; with(plots)

F := proc (x) options operator, arrow; piecewise(-1 < x and x < 1, x-x^3, 0) end proc

proc (x) options operator, arrow; piecewise(-1 < x and x < 1, x-x^3, 0) end proc

(16)

p7 := plot(piecewise(-3 < x and x < -1, F(x+2), -1 < x and x < 1, F(x), 1 < x and x < 3, F(x-2)), x = -3 .. 3, color = blue)

 

L := 2; a__0 := (int(F(x), x = -(1/2)*L .. (1/2)*L))/L

0

(17)

a__n := proc (n) options operator, arrow; 2*(int(F(x)*cos(2*n*Pi*x/L), x = -(1/2)*L .. (1/2)*L))/L end proc

proc (n) options operator, arrow; 2*(int(F(x)*cos(2*n*Pi*x/L), x = -(1/2)*L .. (1/2)*L))/L end proc

(18)

b__n := proc (n) options operator, arrow; 2*(int(F(x)*sin(2*n*Pi*x/L), x = -(1/2)*L .. (1/2)*L))/L end proc

proc (n) options operator, arrow; 2*(int(F(x)*sin(2*n*Pi*x/L), x = -(1/2)*L .. (1/2)*L))/L end proc

(19)

b__n(n)

-4*(n^2*Pi^2*sin(n*Pi)+3*cos(n*Pi)*Pi*n-3*sin(n*Pi))/(n^4*Pi^4)

(20)

" #` Fourier series function`  `F__fourier`(x,N):=`a__0`+(&sum;)(`a__n`(n)&lowast;cos(2 * n * Pi * x / L) +`b__n`(n)&lowast;sin(2* n * Pi * x / L));      #` Plot the Fourier series approximation`  p8:=plot([`F__fourier`(x,40)],x = -3.. 3 ,numpoints=200, color=[red]) :"

proc (x, N) options operator, arrow, function_assign; a__0+sum(a__n(n)*cos(2*n*Pi*x/L)+b__n(n)*sin(2*n*Pi*x/L), n = 1 .. N) end proc

(21)

display([p7, p8])

 

Explore(plot([piecewise(-3 < x and x < -1, F(x+2), -1 < x and x < 1, F(x), 1 < x and x < 3, F(x-2)), F__fourier(x, N)], x = -3 .. 3, color = [blue, purple], numpoints = 200), N = 1 .. 40, title = "Fourier Series Approximation with N Terms")

NULL

Download Fourier_Series.mw



Lost in the terrain

Maple 2024 asked by Alfred_F 80 Yesterday

plot of a solution

Maple 2020 asked by Raafat 10 October 04

Maple & Eclipse

Maple asked by goebeld 55 October 04

square side wanted

Maple 2024 asked by Alfred_F 80 Yesterday

.m files.

Maple asked by Christian... 1585 Yesterday

3D plot, Matlab export

Maple 2021 asked by salim-barz... 105 October 05

Little ODE for Puzzles

Maple 2024 asked by Alfred_F 80 October 04