Application Center - Maplesoft

# My Useful Functions

You can switch back to the summary page by clicking here.

 An Introduction to Maple        The following was implemented in Maple by Marcus Davidsson (2009) davidsson_marcus@hotmail.com

Input text

click on "Text" and start typing

Input Math

click on "Math" and start typing

How to split the window in two

click on "Insert" and  "Table"

 (1)

 (2)

 (3)

 (4)

 (5)

 (6)

How to draw a figure

click on "Insert" and "Canvas"

How to define a variable

 (7)

 (8)

How to undefine a variable

 (9)

Clear definitions

 (10)

Subscript

press SHIFT and  _

 (11)

Superscript

press SHIFT ^

 (12)

Round to the Nearest Integer

 (13)

How to solve for two unknowns in two equations

 (14)

Launch Help

From String " " to float and from float to String ""

 (15)

Number of occurrences in a list

 (16)

Where is the worksheet located ?

 (17)

Check Equality

 (18)

A random number between -1 and 1

 (19)

Procedures

 (20)

or as:

 (21)

or as:

 (22)

or constructing factorials as follows:

 (23)

How to print

 (24)

How to print with Spacing

 (25)

or as follows:

 (26)

or as follows:

 (27)

Check type

 (28)

 (29)

 (30)

Display Precision

 (31)

 (32)

Change Default TypeSet plus Default Size

1. Open Format -> Styles, scrolled down to C 2D Input, selected it, clicked 'Modify' then modified as I'd like. Note that the leading `C' stands for `character'.2. Repeat with C 2D Output3. Open Format -> Manage Styles. Select the 'User Define Style Set' radio button.  Click the New Style Set button. Click 'Select All' then 'Ok'. A menu will open that allows you to save this file.  Doing this makes it the default style. After the save you are returned to the Manage Styles box. Click Ok.4. Exit Maple.  Restart.  It should come up with your new defaults.

Output from previous row

 (33)

 (34)

Output 2 rows back

 (35)

 (36)

 (37)

Extract operander from expression

 (38)

 (39)

Substitute

 (40)

 (41)

for more algebraic substitutions we should use the command algsubs or the command applyrule

 (42)

Hide output

Permutations

 (43)

Pascal Triangle Maple

How to enter commands that are executed together

 (44)

Note that after we have entered c: we press SHIFT ENTER to get a new row

Define variables by using subscript notation

 (45)

 (46)

Note that a and b are inputed by typing x_a and x_b

Define a function

 (47)

 (48)

Sequence in a list [  ]

 (49)

Acess list elements

 (50)

 (51)

How to Simulate One Column with Random Numbers

 (52)

How to Simulate Many Columns with Random Numbers

 (53)

How to simulate a random numbers and store in list

 (54)

Time derivative

 (55)

or as

 (56)

Note that we put the dot on top of x by pressing SHIFT, CTRL and " after the variable x

Differentiate a variable

 (57)

or as

 (58)

Differentiate an expression

 (59)

Differentiate f(x(t)) with respect to x(t)

 (60)

 (61)

Differentiate f ( x, y ) with respect to the first variable x

 (62)

 (63)

Differentiate f ( x, y ) with respect to the second variable y

 (64)

 (65)

Differentiate a function (chain rule)

 (66)

 (67)

Differentiate a function of a function (chain rule)

 (68)

 (69)

Differentiate a function of a function of a function (chain rule)

 (70)

 (71)

 (72)

 (73)

or as

 (74)

Apply a procedure to each operand of an expression

 (75)

 (76)

Isolate an expression

 (77)

 (78)

Solve for a variable

 (79)

 (80)

or as

 (81)

 (82)

Combine Power Symbolic

 (83)

 (84)

 (85)

 (86)

Expand Power Symbolic ( The opposite of Combine)

 (87)

 (88)

 (89)

Simplify an expression

 (90)

 (91)

 (92)

Note that e does not work

 (93)

Simplify an expression symbolicaly

 (94)

 (95)

 (96)

 (97)

Collect terms

 (98)

 (99)

Sort terms

 (100)

 (101)

Select Prime Numbers

 (102)

 (103)

Remove Prime Numbers

 (104)

 (105)

Maximum in List

 (106)

 (107)

Minimum in List

 (108)

 (109)

How to call a module (package)

 (110)

 (111)

or as

 (112)

How to extract operandor from list

 (113)

How to make a drawing from a normaldistribution with mean zero and standard deviation equal to 1

 (114)

How to calculate the expected value

 (115)

 (116)

How to calculate the standard deviation

 (117)

 (118)

How to calculate returns

 (119)

 (120)

How to Extract a PDF from a Set

 (121)

How to view the code for any Maple library routine

The function blackscholes computes the present value of a call option

blackscholes(amount, exercise, rate, nperiods, sdev , hedge)

amount   - current stock price     exercise - exercise price of the call option     rate     - risk-free interest rate per period, (continuously compounded)     nperiods - number of periods     sdev     - standard deviation per period of the continuous return on the stock     hedge    - (optional name) hedge ratio

 (122)

 (123)

How to Calculate Probabilites from an Empirical Distribution-1

 (124)

Plot a Graph for Data and for a Function

We can plot data as follows

or as follows

or as follows:

We can plot a function as follows:

or as

How to plot a horizontal straight line

How to plot a vertical straight lines

Plot a graph given x and y-observations

 (125)

 (126)

How to plot multiple plots-1

How to plot multiple plots-2

Dual Axis Plot

How to plot side by side-1

How to plot side by side-2

Horizontal Binomial Tree

Vertical Binomial Tree

Random Tree Structure

Solve and plot recursive equations

 (127)

Plot 3D Equations

How to plot a Unit Root and 50 period Moving Average in Maple

PointPlot with Labels

Animations in Maple

Lagrange in Maple

 (128)

Regression in Maple

we can also simulate some data and run a regression

 (129)

Multiple Regression in Maple

 (130)

How to plot a system of differential equations

ChiSquare Test : Are two Samples drawn from the same distribution ?

 Chi-Square Test for Goodness-of-Fit ----------------------------------- Null Hypothesis: Observed sample does not differ from expected sample Alt. Hypothesis: Observed sample differs from expected sample Categories:              6 Distribution:            ChiSquare(5) Computed statistic:      5 Computed pvalue:         0.41588 Critical value:          11.07049741 Result: [Accepted] There is no statistical evidence against the null hypothesis

Normality Test = Shapiro and Wilk's W-Test

 Shapiro and Wilk's W-Test for Normality --------------------------------------- Null Hypothesis: Sample drawn from a population that follows a normal distribution Alt. Hypothesis: Sample drawn from population that does not follow a normal distribution Sample size:             100 Computed statistic:      0.941602 Computed pvalue:         0.000364451 Result: [Rejected] There exists statistical evidence against the null hypothesis

Remove duplicates in a list

 (131)

 (132)

or as

 (133)

How to make a comment in the code without problems

 (134)

How to launce Debugger

Insert DEBUG(): anywhere in the text to launce the debugger window

How to count list elements

 (135)

 (136)

How to remove numerical range in a list

 (137)

 (138)

 (139)

 (140)

 (141)

 (142)

 (143)

 (144)

How to multiply list elements with each other

 (145)

 (146)

How to multiply list elements with a variable

 (147)

 (148)

 (149)

Sum and multiply list elemets with a variable

 (150)

 (151)

 (152)

How to apply a procedure to each operand of an expression ( ie Logarithm transformation )

 (153)

Integrals and Integration

 (154)

 (155)

 (156)

We can have found this results by noting that

 (157)

 (158)

 (159)

 (160)

 (161)

 (162)

 (163)

 (164)

 (165)

 (166)

 (167)

Which is the same result we had previously

How to create a list

 (168)

 (169)

How to create a set

 (170)

Note that duplicates are removed in set

 (171)

How to create a row vector

 (172)

 (173)

or as

 (174)

 (175)

How to create a column vector

 (176)

 (177)

or as

 (178)

 (179)

How a column vector into seperate column vectors

 (180)

 (181)

 (182)

How to sort one column vector descending and record a second column

 (183)

 (184)

 (185)

 (186)

How to split a Row Vector into Two Rows

 (187)

 (188)

 (189)

How to create a matrix

 (190)

or as:

 (191)

Symmetrical Matrix

 (192)

 (193)

How to view a large Matrix

 (194)

 (195)

Double sum of a Matrix

 (196)

 (197)

Double sum of a Covariance Matrix

 (198)

Double sum of a Covariance Matrix with Weights

 (199)

How to turn multiple sequences into a column matrix

 (200)

 (201)

How to turn output from a loop into a Column Matrix

 (202)

Matrix Dimensions: Number of Rows and Number of Columns

 (203)

How Update a Variable with a Slider

How Update a Correlation Matrix with a Slider

How to get a random drawing with an button

How to simulate and plot a series of random numbers with an button

How to simulate a unit root with an button-2

How Retrive a Value from a Slider

 (204)

How to control multiple plots with an slider

How to create a Column Matrix form a Lists

 (205)

The difference between Matrix and Vector Index

 (206)

 (207)

How to create a matrix of vector rows

 (208)

 (209)

How to create a matrix of vector columns

 (210)

 (211)

How to delete a row in a matrix

 (212)

 (213)

How to delete a column in a matrix

 (214)

 (215)

How to add a row in a matrix

 (216)

 (217)

 (218)

How to add a column in a matrix

 (219)

 (220)

 (221)

How to add a specific columns to a matrix

 (222)

 (223)

or as

 (224)

 (225)

 (226)

or as

 (227)

Columns of Columns

 (228)

 (229)

 (230)

Row of Row

 (231)

 (232)

 (233)

Test for equality

 (234)

 (235)

 (236)

 (237)

 (238)

 (239)

Vector subtraction

 (240)

 (241)

 (242)

Scalar multiplication

 (243)

 (244)

Matrix multiplication-1

 (245)

 (246)

 (247)

Matrix multiplication-2

 (248)

 (249)

 (250)

Matrix multiplication-3

 (251)

 (252)

 (253)

or as

 (254)

Matrix multiplication-4

 (255)

 (256)

 (257)

Conditional if-loop and for-loop

 (258)

Ordinary if-loop and for-loop

 (259)

If-loop and for-loop with Multiple If-commands

 (260)

or as

 (261)

or as

 (262)

Do-loop (repeats section for printing)

 (263)

Do-loop (repeats section and store results in a list)

 (264)

can also be solved by using a procedure

 (265)

Double for-loop

 (266)

How to loop though and test values from a list

 (267)

For/Do Loops and Break Points

 (268)

another example

 (269)

another example

 (270)

While Loops

 (271)