Mini-Course: Computer Algebra for Physicists
This course, used in hands-on workshops at the Perimeter Institute for Theoretical Physics and the Brazilian Center for Research in Physics, is organized as a guided experience, for 2 hours per day during five days, for learning the basics of the Maple language and then using it to formulate algebraic computations that we do in physics with paper and pencil. It is oriented to people not familiar with computer algebra (sections 1-5), as well as to people who are familiar with it but want to learn more about how to use it in physics.
Motivation
Among other things, with computer algebra:
You can concentrate more on the ideas (the model and its formulation) instead of on the algebraic manipulations
You can extend your results with ease
You can explore the mathematics surrounding your problem
You can share your results in a reproducible way - and doing so, collaborate with others around a problem in more productive ways
After you learn the basics, the speed at which algebraic results are obtained with the computer compensates with dramatic advantage the extra time invested to formulate the problem on the computer
All this doesn't mean that we need computer algebra, at all, but it does mean that computer algebra can enrich our work experience in significant ways.
What is computer algebra - and how do you learn to use it?
Computer algebra is just another language for doing the same computations you do with paper and pencil:
There is our math/phys language, that we understand and use when doing computations with paper and pencil
There is a dictionary (the help pages) that translate the computer-algebra language into our math/phys language
We want to express - in the computer algebra language - those algebraic computations we do with paper and pencil using our math/phys language
* For these purposes, it is relevant that the computer algebra language be as close as possible to our math/phys language.
* You only need to know a basic set of words and syntax, and for everything else use the help pages (the dictionary). If the language is useful, with time you will naturally remember more words.
What is this mini-course about?
Below, you will find 10 Sections with computational topics. Sections 1 to 5 are about the basics of computer algebra, a sort of minimum that we need to know. Sections 6 to 10 are dedicated to formulating, on the computer algebra worksheet, some of the typical algebraic computations used in physics. The presentation is not about all you can do with computer algebra but about how to do all the computations you'd normally do with paper and pencil.
Each section starts with a table summarizing it, followed by two subsections: one with examples (the introductory material I present in class, approximately 15 minutes), and one with exercises including their solutions (the material you work on, approximately 1 hour and 15 minutes). You may prefer either to try solving the proposed problems by yourself or, what is frequently more convenient:
Look at the presented solution - in that way getting ideas for a computational approach to the problem.
Close the solution subsection and try to solve the problem yourself. Repeat a and b as many times as you need, until you feel you can solve the problem thinking by yourself and understanding what you are doing.
In a first approach, you can also only just give a look at all the solutions presented, to form a general idea. It is rewarding, however, to try to solve a minimum of one problem per section.
What can you expect from this mini-course?
The number of topics is large; yet the idea is that you can get the minimum necessary to move ahead. The solved exercises help to show how you translate paper and pencil computations into computer algebra computations.
In order to cover the topics proposed, some of the computational ideas and commands are introduced directly within the exercises, and some other ones are only indicated by pointing to help pages (for quick access to help: place the cursor over the command you don't know, then press F2 to open a related help page). You can selectively grab only the information you need, or explore further if you prefer - this is very personal.
At the end of these 5 lectures you will have seen the main ideas behind performing - with computer algebra - the typical algebraic computations of physics. You will also be able to either formulate a problem yourself, or to formulate a more precise question on what part of the computation you feel lost in, and you will be able to make use of any good answer provided to your question.
Summary: Learning the whole language takes more than 5 days, but below you have all that you need to move by yourself and interact with others.
Explore. While learning, having success is a secondary goal: using your curiosity as a compass is what matters - things can be done in so many different ways. Take full permission to make mistakes. Share your insights. All questions are valid even if about a side issue. Computer algebra can transform the algebraic computation part of physics into interesting discoveries and fun.
Edgardo S. Cheb-Terrab Physics, Differential Equations and Mathematical Functions, Maplesoft
1. Arithmetic operations and elementary functions
Operators
+, -, *, /, ^
Functions
exp,ln,sin, cos, tan, csc, sec, cot,arcsin, arccos, arctan, arccsc, arcsec, arccot. For the hyperbolic functions put an h at the end as in sinh, arctanh, etc.
Manipulation commands
Related to numerical evaluation: evalf, Digits
The complex components: Re, Im, conjugate, abs, argument
Related to functions: series, convert (any function to any other one when possible), FunctionAdvisor
Related to plotting: plot, plot3d, plots:-plotcompare
Examples
Blank spaces mean multiplication.
Function application is represented with rounded parenthesis (), as in f⁡x.
Indexation, as used in tensors, is represented with squared brackets [], as in A[mu] displayed as Amu.
Numerical approximation is obtained applying evalf
restart; interfaceimaginaryunit = i:
4+5 i
4+5⁢ⅈ
Re
4
conjugate
4−5⁢ⅈ
evalfPi
3.141592654
Digits
10
evalf50Pi
3.1415926535897932384626433832795028841971693993751
FunctionAdvisor
The usage is as follows: > FunctionAdvisor( topic, function, ... ); where 'topic' indicates the subject on which advice is required, 'function' is the name of a Maple function, and '...' represents possible additional input depending on the 'topic' chosen. To list the possible topics: > FunctionAdvisor( topics ); A short form usage, > FunctionAdvisor( function ); with just the name of the function is also available and displays a summary of information about the function.
FunctionAdvisortopic
* Partial match of "topic" against topic "topics". The topics on which information is available are:
DE,analytic_extension,asymptotic_expansion,branch_cuts,branch_points,calling_sequence,class_members,classify_function,definition,describe,differentiation_rule,function_classes,identities,integral_form,known_functions,periodicity,plot,relate,required_assumptions,series,singularities,special_values,specialize,sum_form,symmetries,synonyms,table
FunctionAdvisorclasses
trig,trigh,arctrig,arctrigh,elementary,GAMMA_related,Psi_related,Kelvin,Airy,Hankel,Bessel_related,0F1,orthogonal_polynomials,Ei_related,erf_related,Kummer,Whittaker,Cylinder,1F1,Elliptic_related,Legendre,Chebyshev,2F1,Lommel,Struve_related,hypergeometric,Jacobi_related,InverseJacobi_related,Elliptic_doubly_periodic,Weierstrass_related,Zeta_related,complex_components,piecewise_related,Other,Bell,Heun,Appell,trigall,arctrigall,Polylog_related,integral_transforms
FunctionAdvisorele
* Partial match of "ele" against topic "elementary". The 26 functions in the "elementary" class are:
arccos,arccosh,arccot,arccoth,arccsc,arccsch,arcsec,arcsech,arcsin,arcsinh,arctan,arctanh,cos,cosh,cot,coth,csc,csch,exp,ln,sec,sech,sin,sinh,tan,tanh
FunctionAdvisoridentities, sin
sin⁡arcsin⁡z=z,sin⁡z=−sin⁡−z,sin⁡z=2⁢sin⁡z2⁢cos⁡z2,sin⁡z=1csc⁡z,sin⁡z=2⁢tan⁡z21+tan⁡z22,sin⁡z=−ⅈ2⁢ⅇⅈ⁢z−ⅇ−ⅈ⁢z,sin⁡z2=1−cos⁡z2,sin⁡z2=12−cos⁡2⁢z2
FunctionAdvisorln
ln
describe
ln=natural logarithm
definition
ln⁡z=z−1⁢∑_k1=0∞⁡1−z_k1_k1+1
z−1<1
classify function
elementary
symmetries
ln⁡−z=ⅈ⁢π+ln⁡z+2⁢ⅈ⁢π⁢−arg⁡z2⁢π
ln⁡−z=ln⁡z−ⅈ⁢π
0<ℑ⁡zorℑ⁡z=0andz<0
ln⁡−z=ln⁡z+ⅈ⁢π
ℑ⁡z<0orℑ⁡z=0and0<z
ln⁡z&conjugate0;=ln⁡z&conjugate0;
notz<0
periodicity
ln⁡z
No periodicity
plot
singularities
No isolated singularities
branch points
z∈0,∞+∞⁢ⅈ
branch cuts
z<0
special values
ln⁡−1=ⅈ⁢π
ln⁡1=0
ln⁡−ⅇ=1+ⅈ⁢π
ln⁡ⅈ=ⅈ2⁢π
ln⁡−ⅈ=−ⅈ2⁢π
ln⁡∞=∞
ln⁡−∞=∞+ⅈ⁢π
ln⁡ⅇn=n
n::real
identities
ln⁡z=ⅈ⁢arg⁡z+ln⁡z
ln⁡ⅇz=z
z::real
ln⁡y+z=ln⁡y+ln⁡12⁢y+z+ln⁡2⁢y+z+2⁢arctanh⁡z2⁢y+z
0<y
ln⁡y⁢z=ln⁡y+ln⁡z
0≤y+z
ln⁡zy=y⁢ln⁡z+2⁢ⅈ⁢π⁢π−ℑ⁡y⁢ln⁡z2⁢π
ln⁡za⁢yb=a⁢ln⁡z+b⁢ln⁡y+2⁢ⅈ⁢π⁢π−ℑ⁡a⁢ln⁡z−ℑ⁡b⁢ln⁡y2⁢π
sum form
series
series⁡ln⁡z,z,4=ln⁡z
asymptotic expansion
asympt⁡ln⁡z,z,4=ln⁡z
integral form
ln⁡z=∫1z1_k1ⅆ_k1
¬z<0
differentiation rule
ⅆⅆzln⁡z=1z
ⅆnⅆznln⁡z=ln⁡zn=0−1n−1⁢n−1!znotherwise
DE
f⁡z=ln⁡z
ⅆⅆzf⁡z=1z
cos⁡x+ⅈ⁢sin⁡x
convert%, exp
ⅇⅈ⁢x
convert%, trig
FunctionAdvisorrelate, arcsin, ln
arcsin⁡z=−ⅈ⁢ln⁡ⅈ⁢z+−z2+1
FunctionAdvisorspecialize, arcsin
arcsin⁡z=z⁢F1⁡12,0,12,32,0,z2,with no restrictions on ⁡z,arcsin⁡z=z⁢F2⁡12,0,12,1,32,0,z2,with no restrictions on ⁡z,arcsin⁡z=z⁢F3⁡0,12,0,12,32,0,z2,with no restrictions on ⁡z,arcsin⁡z=z⁢F4⁡12,12,1,32,0,z2,with no restrictions on ⁡z,arcsin⁡z=z⁢HC⁡0,12,0,0,14,z2z2−1−z2+1,with no restrictions on ⁡z,arcsin⁡z=z⁢HG⁡0,0,12,12,0,12,z2,with no restrictions on ⁡z,arcsin⁡z=π2+am−1⁡arcsec⁡z|1⁢z−1−z−12,ℜ⁡z∈0,π,arcsin⁡z=z⁢π⁢P−1212,−12⁡−2⁢z2+12,with no restrictions on ⁡z,arcsin⁡z=z⁢π⁢−2⁢z2+214⁢P−12−12⁡−2⁢z2+12⁢−2⁢z214,with no restrictions on ⁡z,arcsin⁡z=z⁢G2,21,2⁡−z2|12,120,−122⁢π,with no restrictions on ⁡z,arcsin⁡z=π2−arccos⁡z,with no restrictions on ⁡z,arcsin⁡z=π2+arccosh⁡z⁢z−1−z−12,with no restrictions on ⁡z,arcsin⁡z=π−2⁢arccot⁡z1+−z2+1,with no restrictions on ⁡z,arcsin⁡z=2⁢ⅈ⁢−z2+1+2⁢ⅈ−2⁢z⁢arccoth⁡−ⅈ⁢z1+−z2+1+ⅈ⁢1+−z2+1⁢π⁢−ⅈ⁢z1+−z2+1+12ⅈ⁢z+−z2+1+1,with no restrictions on ⁡z,arcsin⁡z=arccsc⁡1z,with no restrictions on ⁡z,arcsin⁡z=ⅈ⁢arccsch⁡ⅈz,with no restrictions on ⁡z,arcsin⁡z=π2−arcsec⁡1z,with no restrictions on ⁡z,arcsin⁡z=π2+arcsech⁡1z⁢−1+z−1z−12⁢z2,with no restrictions on ⁡z,arcsin⁡z=−ⅈ⁢arcsinh⁡ⅈ⁢z,with no restrictions on ⁡z,arcsin⁡z=2⁢arctan⁡z1+−z2+1,with no restrictions on ⁡z,arcsin⁡z=−2⁢ⅈ⁢arctanh⁡ⅈ⁢z1+−z2+1,with no restrictions on ⁡z,arcsin⁡z=z⁢F12⁡12,12;32;z2,with no restrictions on ⁡z,arcsin⁡z=−ⅈ⁢ln⁡ⅈ⁢z+−z2+1,with no restrictions on ⁡z
Plotting
2D plotting
plotexp
plotsinx x
Complex algebraic expressions F⁡z of a complex variable z can be represented by two 3D plots: the value of ℜ⁡F⁡z and ℑ⁡F⁡z (so the real or imaginary parts of the expression) on the two vertical axes and the real and imaginary parts of the variable z on the two horizontal axes (PlotExpression uses plots[plotcompare] with the option expression_plot)
PlotExpression ≔ f → plots:-plotcomparef, 0, _rest, expression_plot, 5:
PlotExpressionexpz, scale_range = Pi
PlotExpressionlnz, scale_range = Pi
So ln is a multivalued function with a cut over
FunctionAdvisorbranch_cuts,ln
ln⁡z,z<0
epsilon ≔ 10.0−6
ε≔1.000000000×10−6
ln⁡−i ε
−13.81551056−1.570796327⁢ⅈ
lni ε
−13.81551056+1.570796327⁢ⅈ
If you know in advance that z is real (or pure imaginary) then the two 3D plots transform into two 2D plots:
PlotExpressionlnz, scale_range = Pi assuming z∷real
PlotExpressionlnz, scale_range = Pi assuming z∷imaginary
Exercises
Choose one exercise, try to solve it in up to 10 minutes. If there is time, move to the next problem. Or feel free to use the time to explore the help pages about any related topic that is more of your interest.
Use the convert command to express the functions of the following groups in terms of each other
[exp, sin, cos, tan, sec, csc, cot]
[ln, arcsin, arccos, arctan arcsec, arccsc, arccot]
Choose a couple of the relations you have obtained between functions, say A = B, and verify that A and B have the same series expansion
Solution
Remember always to restart to avoid other computations to interfere with the one you are developing
restart
convertexpz, sin
sin⁡I⁢z+π2−I⁢sin⁡I⁢z
convertexpz, trig
cosh⁡z+sinh⁡z
convertexpI⋅z, trig
cos⁡z+I⁢sin⁡z
convertsinz, exp
−I2⁢ⅇI⁢z−ⅇ−I⁢z
explnz
z
sinarcsinz
convertlnz, arcsin
−z2⁢z−1z+1⁢z+1z−1⁢arcsin⁡z2+12⁢z−π2z+I⁢π⁢1−−1−z⁢z−z⁢z+1
convertarcsinz, ln
−I⁢ln⁡I⁢z+−z2+1
seriesarcsinz,z
z+16⁢z3+340⁢z5+O⁡z7
series, z
Plot the sin function between −pi and pi, then: 1. click the plot to select it ; 2. go to the menu Plot → Probe Info → Cursor position to access the probe tool; 3. use the probe to identify the coordinates of points on the plot, as inx__1,y__1,x__2,y__2, ... ,x__n,y__n. 4. search the help system for 'interpolate' and choose a command to interpolate a polynomial approximating sin⁡x between −pi and pi . How many points do you need to obtain an approximation that is more or less acceptable?
Because sin has a symmetry, you only need to investigate the problem in one semiplane - say between 0 and pi
plotsinx, x=0..Pi
Again, because this plot also has a symmetry you only need to probe a few points to the left of pi2 and because we know the value of the function at 0 and pi2 and we are lazy, we only choose probing at two points in between, so at pi8 and pi4; from there we get the values at 3⁢pi4and 7⁢pi8
R ≔ 0,0, Pi8,0.368,Pi4,0.7 ,Pi2,1, 3Pi4, 0.7,7Pi8,0.368,Pi, 0
R≔0,0,π8,0.368,π4,0.7,π2,1,3⁢π4,0.7,7⁢π8,0.368,π,0
CurveFitting:-PolynomialInterpolationR,v
0.003354299730⁢v6−0.005450737062⁢v5⁢π+0.002935012264⁢v4⁢π2−0.0006027257329⁢v3⁢π3+0.00003930819998⁢v2⁢π4−0.01448953438⁢v5+0.01267834258⁢v4⁢π−0.003169585646⁢v3⁢π2+0.0002263989748⁢v2⁢π3+0.08880446333⁢v4−0.03330167375⁢v3⁢π+0.002775139479⁢v2⁢π2−0.3156301048⁢v3+0.03945376310⁢v2⁢π+0.1311733011⁢v2+0.8855926699⁢v
plot, v=0..Pi
From the symmetry of sin, the interpolation from −π to 0 is
−π
−subsv=−v,
−0.003354299730⁢v6−0.005450737062⁢v5⁢π−0.002935012264⁢v4⁢π2−0.0006027257329⁢v3⁢π3−0.00003930819998⁢v2⁢π4−0.01448953438⁢v5−0.01267834258⁢v4⁢π−0.003169585646⁢v3⁢π2−0.0002263989748⁢v2⁢π3−0.08880446333⁢v4−0.03330167375⁢v3⁢π−0.002775139479⁢v2⁢π2−0.3156301048⁢v3−0.03945376310⁢v2⁢π−0.1311733011⁢v2+0.8855926699⁢v
plot, v=−Pi..0
You can now construct the plot between −π to π by putting the two interpolations into a piecewise function
piecewisev≥0,,
0.003354299730⁢v6−0.005450737062⁢v5⁢π+0.002935012264⁢v4⁢π2−0.0006027257329⁢v3⁢π3+0.00003930819998⁢v2⁢π4−0.01448953438⁢v5+0.01267834258⁢v4⁢π−0.003169585646⁢v3⁢π2+0.0002263989748⁢v2⁢π3+0.08880446333⁢v4−0.03330167375⁢v3⁢π+0.002775139479⁢v2⁢π2−0.3156301048⁢v3+0.03945376310⁢v2⁢π+0.1311733011⁢v2+0.8855926699⁢v0≤v−0.003354299730⁢v6−0.005450737062⁢v5⁢π−0.002935012264⁢v4⁢π2−0.0006027257329⁢v3⁢π3−0.00003930819998⁢v2⁢π4−0.01448953438⁢v5−0.01267834258⁢v4⁢π−0.003169585646⁢v3⁢π2−0.0002263989748⁢v2⁢π3−0.08880446333⁢v4−0.03330167375⁢v3⁢π−0.002775139479⁢v2⁢π2−0.3156301048⁢v3−0.03945376310⁢v2⁢π−0.1311733011⁢v2+0.8855926699⁢votherwise
plot,v=−Pi..Pi
A plot superimposing sin⁡v with its interpolation:
plotsinv,,v=−Pi..Pi
You can now click the plot to display the plotting toolbar, and use the scale and translate plot tools to distinguish between these two curves. It is sometimes convenient to duplicate the plot to keep the complete picture
Use plots:-plotcompare to determine for which values of z is 1z≠1z. Try it with the options same_box, assuming z::real and assuming z::imaginary
plots:-plotcompare1sqrtz,sqrt1z, same_box, scale_range = Pi
_P2
So, apparently, these two expressions, 1z,1z are equal, BUT: there is a branch cut .... you need to check the values over the cut, which is located in the same place for the two expressions:
FunctionAdvisorbranch_cuts, sqrt1z
1z,z<0
FunctionAdvisorbranch_cuts, 1sqrtz
For cuts over the real axis, the solution is to plot assuming real
plots:-plotcompare1sqrtz,sqrt1z, same_box, scale_range = Pi assuming z∷real
So: over the negative real axis, the imaginary parts of these two expressions have the same absolute value but different sign
eval1sqrtx, x=−0.3
−1.825741858⁢I
evalsqrt1x, x=−0.3
1.825741858⁢I
2. Algebraic Expressions, Equations and Functions
Algebraic expression
Any mathematical object made up of numbers, symbols and functions combined using arithmetic operations
Equation
A construction using the = sign, typically with algebraic expressions on the left-hand and right-hand sides
Function
It can be a known function (of type 'known') such as ln⁡z or Jn⁡z, or an unknown function (of type 'unknown') such as f⁡x,y,z,t
Mapping
Maps variables into constructions that involve these variables, typically algebraic expressions, for example f≔x,y,z↦x2+y2+z2
To represent function application use (), as in f⁡x
To construct expressions, equations and mappings, use respectively: =, :=, ->, and use unapply to convert an expression into a mapping
Related to expressions: numer, denom, collect, coeff, degree
Related to equations and inequations: =, <>, <=, >=, and to get each side use lhs, rhs
Basic manipulation of expressions and equations: subs, eval, map, collect, isolate, solve
An algebraic expression
restart;
a⁢x2+ⅇxb
Note you can think of the labels, such as (6.1.1) above, as names assigned to any visible output.
You can also give any name to an expression (assign a name to it) in order to refer to it, and also if the expression is not displayed. You do that by using the assign operator :=
f ≔
f≔a⁢x2+ⅇxb
Now you can refer to the expression (6.1.1) using the given name
f
Different from an expression, an equation always has left and right-hand sides with the `=` operator in between. For example
f = 0
a⁢x2+ⅇxb=0
You get each of the sides using the lhs and rhs commands
lhs
rhs
0
You can assign names to everything, including to an equation
h ≔ f = g;
h≔a⁢x2+ⅇxb=g
What we call "the function of x equal to a⁢x2+ⅇxb" is implemented in the computer as a mapping, using the arrow operator →
x →
x↦a⋅x2+ⅇxb
To use a mapping it is also practical to assign a name to it
h ≔ x →
h≔x↦a⋅x2+ⅇxb
hx
x
Note however that the mapping h is not really a function just of x, but also of whatever argument you pass to it, as in
hy
a⁢y2+ⅇyb
h⁡alpha
a⁢α2+ⅇαb
beta
a⁢β2+ⅇβb
You can convert an expression or equation into a mapping using unapply
unapply%, x
unapply, x, a,b
x,a,b↦a⋅x2+ⅇxb
Returning to the expression f
You can get the numerator, denominator or the coefficient of a or of b−1, or compute the maximum and minimum degrees with respect to any variable
numerf
a⁢x2⁢b+ⅇx
denomf
b
coefff, a
x2
coefff, b, −1
ⅇx
degreef,b, ldegreef,b
0,−1
degreef, x
FAIL
degree⁡f,ⅇx
1
frontenddegree,f, x
2
You can substitute into or solve expressions and equations
subsx = 0, f
ⅇ0b
Note the difference with eval: it evaluates the function
evalf, x=0
1b
Most functions automatically return a value for their simplest special cases, as ⅇ0. Inert functions are useful to avoid these automatic simplifications, for example:
%exp0 = exp0, %sin0 = sin0,%cos0 = cos0
%exp⁡0=1,%sin⁡0=0,%cos⁡0=1
You can activate inert functions using the value command
value
1=1,0=0,1=1
The mathematical properties of the inert functions are understood by the system
%sin%cosz
%sin⁡%cos⁡z
diff,z
−sin⁡z⁢cos⁡%cos⁡z
You can solve expressions or equations or systems of them. When solving, an expression is considered an equation with right-hand side equal to zero
isolatef, b
b=−ⅇxa⁢x2
solvef, b
To get all possible solutions, use solve; isolate only returns one solution.
isolatef, x
x=−2⁢W⁡−−1a⁢b2
solvef, x
x=−2⁢W⁡−−1a⁢b2,x=−2⁢W⁡−1a⁢b2
lprint
{x = -2*LambertW(-1/2*(-1/a/b)^(1/2))}, {x = -2*LambertW(1/2*(-1/a/b)^(1/2))}
solvef,x, AllSolutions
x=−2⁢W⁡_Z2,−−1a⁢b2,x=−2⁢W⁡_Z3,−1a⁢b2
PlotExpression ≔ f → plots:-plotcomparef, 0, _rest, 'expression_plot', 5:
PlotExpressionLambertWz
FunctionAdvisorcuts, LambertW
* Partial match of "cuts" against topic "branch_cuts".
W⁡z,z<−1ⅇ,W⁡a,z,a≠0∧z<0∨a=0∧z<−1ⅇ
PlotExpressionlnz
FunctionAdvisordef,LambertWz
* Partial match of "def" against topic "definition".
W⁡z=1+ⅇI2⁢∫0∞ln⁡_k1−I⁢π−ln⁡_k1+ln⁡z_k1+I⁢π−ln⁡_k1+ln⁡z_k1+1ⅆ_k1π⁢−1+ln⁡z,¬z::−1ⅇ,0
1. Consider f⁡x=cos⁡x2+g⁡x
Enter the expression cos⁡x2+g⁡x
Use % to refer to this expression and assign the name F to it
Compute the value of F for x=pi and for x=I⁢a
Transform F into a mapping of x and assign the name G to it
Use the mapping G to compute the values of item c
cos⁡x2+g⁡x
F ≔ %
F≔cos⁡x2+g⁡x
evalF,x=Pi
1+g⁡π
evalF,x=I a
cosh⁡a2+g⁡I⁢a
G ≔ unapplyF,x
G≔x↦cos⁡x2+g⁡x
GPi
GI a
2. Construct a polynomial of 2nd degree taking the product of monomials of the form (x−α__j) where alpha__j are the roots; then, compute the polynomial's maximum and minimum degrees with respect to x, then the coefficients of x to the powers 2,1 and 0, one at a time (coeff) or all at once (coeffs)
P ≔ x−alpha__1⋅x−alpha__2
P≔x−α__1⁢x−α__2
degreeP,x
ldegreeP,x
coeffP,x,0, coeffP,x,1, coeffP,x,2
α__1⁢α__2,−α__1−α__2,1
seqcoeffP,x,j,j=0,1,2
seqcoeffP,x,j,j=0..2
For historical reasons to use 'coeffs' you need to expand the polynomial first - if you don't you hit those computer idiosyncrasies ...
coeffsP,x
Error, invalid arguments to coeffs
expandP
x2−α__1⁢x−x⁢α__2+α__1⁢α__2
coeffs%,x
1,−α__1−α__2,α__1⁢α__2
To avoid these subtleties you can also use the more modern and general Physics:-Coefficients command (which also handles anticommutative variables)
Physics:-CoefficientsP,x
3. Consider the transformation equations between cartesian and spherical coordinates
x = r sinθcosφ, y = r sinθsinφ, z = r cosθ
Use the commands isolate, map and subs - using assuming to specify the domain of r,θ and φ - in order to invert these equations
eq__x ≔ x = r sinthetacosphi
eq__x≔x=r⁢sin⁡θ⁢cos⁡φ
eq__y ≔ y = r sinthetasinphi
eq__y≔y=r⁢sin⁡θ⁢sin⁡φ
eq__z ≔ z = r costheta
eq__z≔z=r⁢cos⁡θ
mapu → u2,eq__x
x2=r2⁢sin⁡θ2⁢cos⁡φ2
mapu → u2,eq__y
y2=r2⁢sin⁡θ2⁢sin⁡φ2
mapu → u2,eq__z
z2=r2⁢cos⁡θ2
++
x2+y2+z2=r2⁢sin⁡θ2⁢cos⁡φ2+r2⁢sin⁡θ2⁢sin⁡φ2+r2⁢cos⁡θ2
simplify%
x2+y2+z2=r2
mapu → u12,%
simplify% assuming r > 0
x2+y2+z2=r
eq__r ≔ rhs = lhs%
eq__r≔r=x2+y2+z2
yx=rhseq__yrhseq__x
yx=sin⁡φcos⁡φ
convert%,tan
yx=tan⁡φ
eq__phi ≔ isolate%,phi
eq__φ≔φ=arctan⁡yx
isolateeq__z,theta
θ=arccos⁡zr
eq__theta ≔ subseq__r,%
eq__θ≔θ=arccos⁡zx2+y2+z2
3. Limits, Derivatives, Sums, Products, Integrals, Differential Equations
Commands
limit, diff and D, sum, product, int, dsolve, pdsolve
PDEtools:-dchange, PDEtools:-casesplit
The inert forms %limit, %int, etc. and the related value command
The commands to compute limits, derivatives, sums and products are limit, diff, sum, product. The D command also represents derivatives - more about this afterwards.
'limit'sin⁡xx,x=0
limx→0⁡sin⁡xx
All Maple commands have an inert version, which represents the mathematical object but does not perform the computation until you require it using the value command. Inert subexpressions always have some part displayed in grey:
%limitsinxx,x=0
%limit⁡sin⁡xx,x=0
subsx=t, %diffgx+expx2,x
%diff⁡g⁡t+exp⁡t2,t
ⅆⅆtg⁡t+2⁢t⁢ⅇt2
Handy: functionality is distributed over the sides of equations, so you can write %sum⁡`/`⁡`^`⁡x,n,factorial⁡n,`=`⁡n,0..∞=ⅇx , directly as
%sum = sumxnn!,n=0..infinity
%sum⁡xnfactorial⁡n,n=0..∞=ⅇx
The family of commands sum, int, solve, dsolve and pdsolve is rather powerful.
In the case of summation, note that it can also be performed in the indefinite case:
∑k⁡f⁡k=g⁡k where gk+1−gk=fk
When entering the following command, you will be asked whether it represents a function definition or a remember table assignment. Choose remember table assignment. To perform an assignment with a function on the left-hand side without being asked questions, enter first Typesetting:-Settings'functionassign=false')
fk ≔k2! k
f≔k↦k2!⁢k
%sumfk,k;
%sum⁡factorial⁡12⁢k⁢k,k
2⁢k2!+2⁢k2+12!
eval,k=k+1 −
2⁢k2+1!−2⁢k2!
k2!⁢k
Results are frequently expressed in terms of not-so-familiar special functions
%intⅇ−x2, x;
%int⁡exp⁡−x2,x
π⁢erf⁡x2
%int1sqrt2 t4−3 t2−2,t=2..3
%int⁡12⁢t4−3⁢t2−2,t=2..3
5⁢F⁡73,555−5⁢F⁡22,555
lprint%
1/5*5^(1/2)*EllipticF(1/3*7^(1/2),1/5*5^(1/2))-1/5*5^(1/2)*EllipticF(1/2*2^(1/2),1/5*5^(1/2))
Most of these commands have options to workaround special cases
int⁡1x,x=a..2
Warning, unable to determine if 0 is between a and 2; try to use assumptions or use the AllSolutions option
∫a21xⅆx
int⁡1x,x=a..2,AllSolutions
undefineda<0∞a=0−ln⁡a+ln⁡20<a
The assuming command is also handy in these cases
assuming a > 0;
−ln⁡a+ln⁡2
assuming a < 0;
undefined
The ordinary and partial differential equation commands have by now concentrated so much solving power that they are themselves used to develop new solving algorithms
PDEtools:-declareyx,prime=x
y⁡x⁢will now be displayed as⁢y
derivatives with respect to⁢x⁢of functions of one variable will now be displayed with '
ode2≔y′⁡x−y⁡x2+y⁡x⁢sin⁡x−cos⁡x=0
diff⁡y⁡x,x−y⁡x2+y⁡x⁢sin⁡x−cos⁡x=0
infoleveldsolve ≔ 5
infoleveldsolve≔5
dsolveode2
Methods for first order ODEs: --- Trying classification methods --- trying a quadrature trying 1st order linear trying Bernoulli trying separable trying inverse linear trying homogeneous types: trying Chini Chini's absolute invariant is: (1/4)*sin(x)^2*(2*cos(x)-1)^2/cos(x)^3 differential order: 1; looking for linear symmetries trying exact Looking for potential symmetries trying Riccati trying Riccati sub-methods: <- Riccati with symmetry of the form [0, exp(-Int(f,x))/P*(y*P-f)^2] successful
y⁡x=−exp⁡−cos⁡x_C1+Int⁡exp⁡−cos⁡x,x+sin⁡x
diffyx,x,x=yx⋅fx
diff⁡diff⁡y⁡x,x,x=y⁡x⁢factorial⁡12⁢x⁢x
ode3≔y′⁡x=x⁢−x−1+x2−2⁢x2⁢y⁡x+2⁢x4x2−y⁡x⁢x+1
diff⁡