Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Maple (software)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Examples of Maple code== The following code, which computes the factorial of a nonnegative integer, is an example of an [[imperative programming]] construct within Maple: <syntaxhighlight lang="maple"> myfac := proc(n::nonnegint) local out, i; out := 1; for i from 2 to n do out := out * i end do; out end proc; </syntaxhighlight> Simple functions can also be defined using the "maps to" arrow notation: <syntaxhighlight lang="maple"> myfac := n -> product(i, i = 1..n); </syntaxhighlight> ===Integration=== Find :<math>\int\cos\left(\frac{x}{a}\right)dx</math>. <syntaxhighlight lang="maple"> int(cos(x/a), x); </syntaxhighlight> Output: :<math>a \sin\left(\frac{x}{a}\right)</math> ===Determinant=== Compute the determinant of a matrix. <syntaxhighlight lang="maple"> M := Matrix([[1,2,3], [a,b,c], [x,y,z]]); # example Matrix </syntaxhighlight> : <math> \begin{bmatrix} 1 & 2 & 3 \\ a & b & c \\ x & y & z \end{bmatrix} </math> LinearAlgebra:-Determinant(M); : <math>bz-cy+3ay-2az+2xc-3xb</math> ===Series expansion=== <syntaxhighlight lang="maple"> series(tanh(x), x = 0, 15) </syntaxhighlight> :<math>x-\frac{1}{3}\,x^3+\frac{2}{15}\,x^5-\frac{17}{315}\,x^7</math> :<math>{}+\frac{62}{2835}\,x^9-\frac{1382}{155925}\,x^{11}+\frac{21844}{6081075}\,x^{13}+\mathcal{O}\left(x^{15}\right)</math> ===Solve equations numerically=== The following code numerically calculates the roots of a high-order polynomial: <syntaxhighlight lang="maple"> f := x^53-88*x^5-3*x-5 = 0 fsolve(f) -1.097486315, -.5226535640, 1.099074017 </syntaxhighlight> The same command can also solve systems of equations: <syntaxhighlight lang="maple"> f := (cos(x+y))^2 + exp(x)*y+cot(x-y)+cosh(z+x) = 0: g := x^5 - 8*y = 2: h := x+3*y-77*z=55; fsolve( {f,g,h} ); {x = -2.080507182, y = -5.122547821, z = -0.9408850733} </syntaxhighlight> ===Plotting of function of single variable=== Plot <math>x \sin(x)</math> with {{mvar|x}} ranging from -10 to 10: <syntaxhighlight lang="maple"> plot(x*sin(x), x = -10..10); </syntaxhighlight> [[Image:Maple1DPlot.PNG|thumb|center|300px]] ===Plotting of function of two variables=== Plot <math>x^2+y^2</math> with {{mvar|x}} and {{mvar|y}} ranging from -1 to 1: <syntaxhighlight lang="maple"> plot3d(x^2+y^2, x = -1..1, y = -1..1); </syntaxhighlight> [[Image:Maple163DPlot.jpg|thumb|center|300px]] ===Animation of functions=== * Animation of function of two variables :<math>f := \frac{2k^2}{\cosh^2\left(x k - 4 k^3 t\right)}</math> <syntaxhighlight lang="maple"> plots:-animate(subs(k = 0.5, f), x=-30..30, t=-10..10, numpoints=200, frames=50, color=red, thickness=3); </syntaxhighlight> [[File:Bellsoliton2.gif|thumb|center|300px|2D bell solution]] * Animation of functions of three variables <syntaxhighlight lang="maple"> plots:-animate3d(cos(t*x)*sin(3*t*y), x=-Pi..Pi, y=-Pi..Pi, t=1..2); </syntaxhighlight> [[File:3dsincos animation.gif|thumb|center|300px|3D animation of function]] * Fly-through animation of 3-D plots.<ref>[http://www.maplesoft.com/applications/view.aspx?SID=33073&view=html Using the New Fly-through Feature in Maple 13] Maplesoft</ref> <syntaxhighlight lang="maple"> M := Matrix([[400,400,200], [100,100,-400], [1,1,1]], datatype=float[8]): plot3d(1, x=0..2*Pi, y=0..Pi, axes=none, coords=spherical, viewpoint=[path=M]); </syntaxhighlight> [[File:Maple plot3D flythrough.gif|thumb|center|300px|Maple plot3D fly-through]] ===Laplace transform=== * [[Laplace transform]] <syntaxhighlight lang="maple"> f := (1+A*t+B*t^2)*exp(c*t); </syntaxhighlight> :<math> \left(1 + A \, t + B \, t^2\right) e^{c t}</math> <syntaxhighlight lang="maple"> inttrans:-laplace(f, t, s); </syntaxhighlight> :<math>\frac{1}{s-c}+\frac{A}{(s-c)^2}+\frac{2B}{(s-c)^3}</math> * inverse Laplace transform <syntaxhighlight lang="maple"> inttrans:-invlaplace(1/(s-a), s, x); </syntaxhighlight> : <math>e^{ax}</math> ===Fourier transform=== * [[Fourier transform]] <syntaxhighlight lang="maple"> inttrans:-fourier(sin(x), x, w) </syntaxhighlight> :<math>\mathrm{I}\pi\,(\mathrm{Dirac}(w+1)-\mathrm{Dirac}(w-1))</math> ===Integral equations=== Find functions {{mvar|f}} that satisfy the [[integral equation]] :<math>f(x)-3\int_{-1}^1(xy+x^2y^2)f(y)dy = h(x)</math>. <syntaxhighlight lang="maple"> eqn:= f(x)-3*Int((x*y+x^2*y^2)*f(y), y=-1..1) = h(x): intsolve(eqn,f(x)); </syntaxhighlight> :<math>f \left( x \right) =\int _{-1}^{1}\! \left( -15\,{x}^{2}{y}^{2}-3\,xy \right) h \left( y \right) {dy}+h \left( x \right) </math>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)