Product Tips & Techniques

Tips and Tricks on how to get the most about Maple and MapleSim

I was asked if I would put together a list of top resources to help students who are using Maple for the first time.  An awful lot of students will be cracking Maple open in the next few weeks (the ones who are keeping up with their assignments, at least – for others, it sometimes takes little longer :-), so it seemed like a good idea.

So then I had to decide what to do. I know Top N lists are very popular (Ten Things that Will Shock You about Your Math Software!), and there are tons of Maple training resources available to fill such a list without any difficulties.  But personally, I don’t always like Top N lists. What are the chances that there are exactly N things you need to know, for nice values of N? And how often you are really interested in all N items? I just want to get straight to the points I care about.

I decided I’d try a matrix. So here you go: a mini “choose your own adventure” guide for getting to know Maple.  Pick the row that corresponds to what you want to do, and the column for how you want to do it.  All on a single, page, and ad-free!

And best of luck for the new school year.

 

 

I like words

I like videos

Just let me try it

Product Overview

Inside Maple, from the Help menu, select Take a Tour of Maple then click on the Ten Minute Tour button.

 

(Okay, even though I like words, too, you might also want to watch the video in the next column. The whole “picture is worth a thousand words” does have some truth to it, much as I don’t always like to admit it. J)

Watch Clickable Math

 

Keep in mind that if you prefer to use commands instead of these Clickable Math tools, you can do that too.  Personally, I mix and match.

You’ll figure it out.

Getting Started Info

Read the Maple Quick Start Tutorial Guide, as a PDF, or from the Help system. To access this guide from within Maple, start Maple, click on the Getting Started icon the left, then select the Quick Start Guide (first icon in the second row).

Watch the Maple Quick Start Tutorial Video.

The most important things to remember are

  1. Right click on your math expression to bring up a menu of things you can do, like plotting or integrating or solving your expression
  2. If you have just entered an exponent or the denominator of a fraction, use the right arrow key to get out of it.

How do I? Essentials

Look at the “How do I” section of the Maple Portal (Start Maple, click on the Getting Started icon, click on the Maple Portal icon; or search for “MaplePortal” in the help system).  Also look at the Maple Portal for Students, using the button from the Maple Portal.

Check out the dozens of videos in the Maple Training Video collection.

You can do a lot with the context menus and the various tools you’ll find on the Tools menu. But when in doubt, look at the list of “How do I” tasks from the Maple Portal described in the “words” column and pull out what you need from there.

What now?

The help system is your friend. Not only does it have help pages for every feature and every command, but it includes both the Maple User Manual and the Maple Programming Guide (also available as PDFs).

Check out the collection of videos on the Maplesoft YouTube channel.  (And the help system is your friend, too. We can’t make videos to cover every last thing, and if we did, you wouldn’t have time to watch them all!)

Maple comes with many examples and applications you can look at and modify.  You can browse through the Start page resources, or search for “examples,index” in the help system to see the full list.

 

And yes, the help system is your friend, too.  But don’t worry, no one is going to make you read the manual.

 

 

 

I'm back from presenting work in the "23rd Conference on Applications of Computer Algebra -2017" . It was a very interesting event. This fourth presentation, about "The FunctionAdvisor: extending information on mathematical functions with computer algebra algorithms", describes the FunctionAdvisor project at Maple, a project I started working during 1998, where the key idea I am trying to explore is that we do not need to collect a gazillion of formulas but just core blocks of mathematical information surrounded by clouds of algorithms able to derive extended information from them. In this sense this is also unique piece of software: it can derive properties for rather general algebraic expressions, not just well known tabulated functions. The examples illustrate the idea.

At the end, there is a link to the presentation worksheet, with which one could open the sections and reproduce the presentation examples.
 

The FunctionAdvisor: extending information on mathematical functions

with computer algebra algorithms

 

Edgardo S. Cheb-Terrab

Physics, Differential Equations and Mathematical Functions, Maplesoft

 

Abstract:

A shift in paradigm is happening, from: encoding information into a database, to: encoding essential blocks of information together with algorithms within a computer algebra system. Then, the information is not only searchable but can also be recreated in many different ways and actually used to compute. This talk focuses on this shift in paradigm over a real case example: the digitizing of information regarding mathematical functions as the FunctionAdvisor project of the Maple computer algebra system.

The FunctionAdvisor (basic)

   

Beyond the concept of a database

 
  

" Mathematical functions, are defined by algebraic expressions. So consider algebraic expressions in general ..."

Formal power series for algebraic expressions

   

Differential polynomial forms for algebraic expressions

   

Branch cuts for algebraic expressions

   

The nth derivative problem for algebraic expressions

   

Conversion network for mathematical and algebraic expressions

   

References

   


 

Download FunctionAdvisor.mw

Download FunctionAdvisor.pdf

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

I'm back from presenting work in the "23rd Conference on Applications of Computer Algebra - 2017" . It was a very interesting event. This second presentation, about "Differential algebra with mathematical functions, symbolic powers and anticommutative variables", describes a project I started working in 1997 and that is at the root of Maple's dsolve and pdsolve performance with systems of equations. It is a unique approach. Not yet emulated in any other computer algebra system.

At the end, there is a link to the presentation worksheet, with which one could open the sections and reproduce the presentation examples.
 

Differential algebra with mathematical functions,

symbolic powers and anticommutative variables

 

Edgardo S. Cheb-Terrab

Physics, Differential Equations and Mathematical Functions, Maplesoft

 

Abstract:
Computer algebra implementations of Differential Algebra typically require that the systems of equations to be tackled be rational in the independent and dependent variables and their partial derivatives, and of course that A*B = A*B, everything is commutative.

 

It is possible, however, to extend this computational domain and apply Differential Algebra techniques to systems of equations that involve arbitrary compositions of mathematical functions (elementary or special), fractional and symbolic powers, as well as anticommutative variables and functions. This is the subject of this presentation, with examples of the implementation of these ideas in the Maple computer algebra system and its ODE and PDE solvers.

 

 

restartwith(PDEtools); interface(imaginaryunit = i)

sys := [diff(xi(x, y), y, y) = 0, -6*(diff(xi(x, y), y))*y+diff(eta(x, y), y, y)-2*(diff(xi(x, y), x, y)) = 0, -12*(diff(xi(x, y), y))*a^2*y-9*(diff(xi(x, y), y))*a*y^2-3*(diff(xi(x, y), y))*b-3*(diff(xi(x, y), x))*y-3*eta(x, y)+2*(diff(eta(x, y), x, y))-(diff(xi(x, y), x, x)) = 0, -8*(diff(xi(x, y), x))*a^2*y-6*(diff(xi(x, y), x))*a*y^2+4*(diff(eta(x, y), y))*a^2*y+3*(diff(eta(x, y), y))*a*y^2-4*eta(x, y)*a^2-6*eta(x, y)*a*y-2*(diff(xi(x, y), x))*b+(diff(eta(x, y), y))*b-3*(diff(eta(x, y), x))*y+diff(eta(x, y), x, x) = 0]

 

declare((xi, eta)(x, y))

xi(x, y)*`will now be displayed as`*xi

 

eta(x, y)*`will now be displayed as`*eta

(1)

for eq in sys do eq end do

diff(diff(xi(x, y), y), y) = 0

 

-6*(diff(xi(x, y), y))*y+diff(diff(eta(x, y), y), y)-2*(diff(diff(xi(x, y), x), y)) = 0

 

-12*(diff(xi(x, y), y))*a^2*y-9*(diff(xi(x, y), y))*a*y^2-3*(diff(xi(x, y), y))*b-3*(diff(xi(x, y), x))*y-3*eta(x, y)+2*(diff(diff(eta(x, y), x), y))-(diff(diff(xi(x, y), x), x)) = 0

 

-8*(diff(xi(x, y), x))*a^2*y-6*(diff(xi(x, y), x))*a*y^2+4*(diff(eta(x, y), y))*a^2*y+3*(diff(eta(x, y), y))*a*y^2-4*eta(x, y)*a^2-6*eta(x, y)*a*y-2*(diff(xi(x, y), x))*b+(diff(eta(x, y), y))*b-3*(diff(eta(x, y), x))*y+diff(diff(eta(x, y), x), x) = 0

(2)

casesplit(sys)

`casesplit/ans`([eta(x, y) = 0, diff(xi(x, y), x) = 0, diff(xi(x, y), y) = 0], [])

(3)

NULL

Differential polynomial forms for mathematical functions (basic)

   

Differential polynomial forms for compositions of mathematical functions

   

Generalization to many variables

   

Arbitrary functions of algebraic expressions

   

Examples of the use of this extension to include mathematical functions

   

Differential Algebra with anticommutative variables

   


 

Download DifferentialAlgebra.mw

Download DifferentialAlgebra.pdf

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

 

We have just released an update to Maple. Maple 2017.2 includes updated translations for Japanese, Traditional Chinese, Simplified Chinese, Brazilian Portuguese, French, and Spanish. It also contains improvements to the MapleCloud, physics, limits, and PDEs. This update is available through Tools>Check for Updates in Maple, and is also available from our website on the Maple 2017.2 download page.

 Eithne

It appears google doesn't know about the haversine formula.  Huh?  Well at least google can't draw the proper path for it.  I typed in google "distance from Pyongyang to NewYork city"  and got 10,916km.  Ok that's fine but then it drew a map

The map path definitely did not look right.  Pulled out my globe traced a rough path of the one google showed and I got 13 inches (where 1 inch=660miles) -> 8580 miles = 13808 km .. clearly looks like google goofed. 

So we need Maple to show us the proper path.
 

with(DataSets):
with(Builtin):
m := WorldMap();
AddPath(m, [-74.0059, 40.7128], [125.7625, 39.0392]):
Display(m):

Ok so you say that really doesn't look like the shortest path.  Well, lets visualize that on the globe projection

Display(m, projection = Globe, orientation = [-180, 0, 0])

Ah, now it is clear
Pyonyang_to_NewYork.mw

 

Yahoo Finance recently discontinued their (largely undocumented) historical stock quote API.

Previously, you simply send a HTTP:-Get request like this…

HTTP:-Get(“http://ichart.yahoo.com/table.csv?s=AAPL&a=00&b=1&c=2016&d=00&e=1&f=2017&g=d&ignore=.csv")

…and get historical OHLCV (open, high, low, close, trading volume) data in your worksheet (in this case for AAPL between 1 January 2016 and 1 January 2017).

This no longer works! Yahoo shut the door on this easy-to-use and widely disseminated API.

You can still download historical stock quotes from Yahoo Finance into Maple, but the process is now somewhat more involved. My complete code in this worksheet but I'll step through the process below.

If you visit the updated Yahoo Finance website and download historical data for a ticker, you see a URL like this in the status bar of your browser

https://query1.finance.yahoo.com/v7/finance/download/AAPL?period1=1497727945&period2=1500319945&interval=1d&events=history&crumb=C9luNcNjVkK

Let's examine how ths URL is constructed.

  • period1 and period2 are Unix time stamps for your start and end date
  • interval is the data retrieval interval (this can be either 1d, 1w or 1m)
  • crumb is an alphanumeric code that’s periodically regenerated every time you download new historical data from from the Yahoo Finance website using your browser. Moreover, crumb is paired with a cookie that’s stored by your browser.

Here’s how to extract and supply the cookie-crumb pair to Yahoo Finance so you can still use Maple to retrieve historical stock quotes

Send a dummy request to get a cookie-crumb pair

res:=HTTP:-Get("https://finance.yahoo.com/lookup?s=bananas"):

Grab the crumb from the response

i:=StringTools:-Search("CrumbStore\":{\"crumb\":\"",res[2]):
crumbValue := res[2][i+22..i+32]
                  crumbValue := "btW01FWTBn3"

Store the cookie from the response

cookieHeader:=res[3]["Set-Cookie"]
    cookieHeader := "B=702eqhdcmq7cl&b=3&s=0t; expires=Mon,17-Jul-2018 20:27:01 GMT; path=/; domain=.yahoo.com

Construct the URL

  • Your desired start and end dates have to be defined as Unix time stamps. Converting a human readable date (like 1st January 2017) to a Unix timestamp is simple, so I won't cover it here.
  • The previously retrieved crumb has to be added to the URL.
ticker:="AAPL":
p1 := 1497709183:
p2 := 1500301183:
url:=cat("https://query1.finance.yahoo.com/v7/finance/download/",ticker,"?period1=",p1,"&period2=",p2,"&interval=1d&events=history&crumb=", crumbValue):

Send the request to Yahoo Finance, including the cookie in the header

data:=HTTP:-Get(url,headers = ["Cookie" = cookieHeader])

Your historical data is now returned

The historical data is now easily parsed into a matrix.

Please note that any use of Yahoo Finance has to be consistent with their terms of service.

We have just released the 3rd edition of the Mathematics Survival Kit – Maple Edition.

The Math Survival Kit helps students get unstuck when they are stuck. Sometimes students are prevented from solving a problem, not because they haven’t understood the new concept, but because they forget how to do one of the steps, like completely the square, or dealing with log properties.  That’s where this interactive e- book comes in. It gives students the opportunity to review exactly the concept or technique they are stuck on, work through an example, practice as much (or as little) as they want using randomly generated, automatically graded questions on that exact topic, and then continue with their homework.

This book covers over 150 topics known to cause students grief, from dividing fractions to integration by parts. This 3rd edition contains 31 additional topics, deepening the coverage of mathematical topics at every level, from pre-high school to university.

See the Mathematics Survival Kit for more information about this updated e-book, including the complete list of topics.

eithne

This post is the answer to this question.

The procedure named  IntOverDomain  finds a double integral over an arbitrary domain bounded by a non-selfintersecting piecewise smooth curve. The code of the procedure uses the well-known Green's theorem.

Each section in the border should be specified by a list in the following formats :    
1. If a section is given parametrically, then  [[f(t), g(t)], t=t1..t2]    
2. If several consecutive sections of the border or the entire border is a broken line, then it is sufficient to set vertices of this broken line  [ [x1,y1], [x2,y2], .., [xn,yn] ] (for the entire border should be  [xn,yn]=[x1,y1] ).

Required parameters of the procedure:  f  is an expression in variables  x  and  y , L  is the list of all the sections. The sublists of the list  L  must follow in the positive direction (counterclockwise).

The code of the procedure:

restart;
IntOverDomain := proc(f, L) 
local n, i, j, m, yk, yb, xk, xb, Q, p, P, var;
n:=nops(L);
Q:=int(f,x);  
for i from 1 to n do 
if type(L[i], listlist(algebraic)) then
m:=nops(L[i]);
for j from 1 to m-1 do
yk:=L[i,j+1,2]-L[i,j,2]; yb:=L[i,j,2];
xk:=L[i,j+1,1]-L[i,j,1]; xb:=L[i,j,1];
p[j]:=int(eval(Q*yk,[y=yk*t+yb,x=xk*t+xb]),t=0..1);
od;
P[i]:=add(p[j],j=1..m-1) else
var := lhs(L[i, 2]);
P[i]:=int(eval(Q*diff(L[i,1,2],var),[x=L[i,1,1],y=L[i,1,2]]),L[i,2]) fi;
od; 
add(P[i], i = 1 .. n); 
end proc:

 

Examples of use.

1. In the first example, we integrate over a quadrilateral:

with(plottools): with(plots):
f:=x^2+y^2:
display(polygon([[0,0],[3,0],[0,3],[1,1]], color="LightBlue"));  
# Visualization of the domain of integration
IntOverDomain(x^2+y^2, [[[0,0],[3,0],[0,3],[1,1],[0,0]]]);  # The value of integral

 

2. In the second example, some sections of the boundary of the domain are curved lines:

display(inequal({{y<=sqrt(x),y>=sin(Pi*x/3)/2,y<=3-x}, {y>=-2*x+3,y>=sqrt(x),y<=3-x}}, x=0..3,y=0..3, color="LightGreen", nolines), plot([[t,sqrt(t),t=0..1],[t,-2*t+3,t=0..1],[t,3-t,t=0..3],[t,sin(Pi*t/3)/2,t=0..3]], color=black, thickness=2));
f:=x^2+y^2: L:=[[[t,sin(Pi*t/3)/2],t=0..3],[[3,0],[0,3],[1,1]], [[t,sqrt(t)],t=1..0]]:
IntOverDomain(f, L);

 

3. If  f=1  then the procedure returns the area of the domain:

IntOverDomain(1, L);  # The area of the above domain
evalf(%);

 

IntOverDomain.mw

Edit.

Do you have Maple content that you want to protect from editing and viewing, while still allowing others to execute the code within and obtain results? In Maple, worksheets can be password protected so the users of your Maple application can benefit from the specialized routines you've created while the details remain hidden.


The password protection feature can be useful for a variety of situations, such as:

  • • Providing a Maple-based solution while protecting the intellectual property embodied in your algorithms
  • • Ensuring the users of your application can not accidentally make changes that break your code

 

To learn more about this feature in Maple, you can download the free Tips & Techniques from the Application Center.

We have just released an update to Maple, Maple 2017.1.  It includes improvements to the display on high resolution monitors for the debugger, MapleCloud, and help system table of contents. It also contains a variety of small improvements to the math engine, including in limit, series, Physics, typesetting, and PackageTools. This update is available through Tools>Check for Updates in Maple, and is also available from our website on the Maple 2017.1 download page.

eithne

 

Physics

 

 

Maple provides a state-of-the-art environment for algebraic and tensorial computations in Physics, with emphasis on ensuring that the computational experience is as natural as possible.

 

The theme of the Physics project for Maple 2017 has been the consolidation of the functionality introduced in previous releases, together with significant enhancements and new functionality in General Relativity, in connection with classification of solutions to Einstein's equations and tensor representations to work in an embedded 3D curved space - a new ThreePlusOne  package. This package is relevant in numerical relativity and a Hamiltonian formulation of gravity. The developments also include first steps in connection with computational representations for all the objects entering the Standard Model in particle physics.

Classification of solutions to Einstein's equations and the Tetrads package

 

In Maple 2016, the digitizing of the database of solutions to Einstein's equations  was finished, added to the standard Maple library, with all the metrics from "Stephani, H.; Kramer, D.; MacCallum, M.; Hoenselaers, C.; and Herlt, E., Exact Solutions to Einstein's Field Equations". These metrics can be loaded to work with them, or change them, or searched using g_  (the Physics command representing the spacetime metric that also sets the metric to your choice in one go) or using the command DifferentialGeometry:-Library:-MetricSearch .


In Maple 2017, the Physics:-Tetrads  package has been vastly improved and extended, now including new commands like PetrovType  and SegreType  to classify these metrics, and the TransformTetrad  now has an option canonicalform to automatically derive a transformation and put the tetrad in canonical form (reorientation of the axis of the local system of references), a relevant step in resolving the equivalence between two metrics.

Examples

 

Petrov and Segre types, tetrads in canonical form

   

Equivalence for Schwarzschild metric (spherical and Kruskal coordinates)

 

Formulation of the problem (remove mixed coordinates)

   

Solving the Equivalence

   

The ThreePlusOne (3 + 1) new Maple 2017 Physics package

 

ThreePlusOne , is a package to cast Einstein's equations in a 3+1 form, that is, representing spacetime as a stack of nonintersecting 3-hypersurfaces Σ. This 3+1 description is key in the Hamiltonian formulation of gravity as well as in the study of gravitational waves, black holes, neutron stars, and in general to study the evolution of physical system in general relativity by running numerical simulations as traditional initial value (Cauchy) problems. ThreePlusOne includes computational representations for the spatial metric gamma[i, j] that is induced by g[mu, nu] on the 3-dimensional hypersurfaces, and the related covariant derivative, Christoffel symbols and Ricci and Riemann tensors, the Lapse, Shift, Unit normal and Time vectors and Extrinsic curvature related to the ADM equations.

 

The following is a list of the available commands:

 

ADMEquations

Christoffel3

D3_

ExtrinsicCurvature

gamma3_

Lapse

Ricci3

Riemann3

Shift

TimeVector

UnitNormalVector

 

 

The other four related new Physics  commands:

 

• 

Decompose , to decompose 4D tensorial expressions (free and/or contracted indices) into the space and time parts.

• 

gamma_ , representing the three-dimensional metric tensor, with which the element of spatial distance is defined as  `#mrow(msup(mi("dl"),mrow(mo("&InvisibleTimes;"),mn("2"))),mo("&equals;"),msub(mi("&gamma;",fontstyle = "normal"),mrow(mi("i"),mo("&comma;"),mi("j"))),mo("&InvisibleTimes;"),msup(mi("dx"),mi("i")),mo("&InvisibleTimes;"),msup(mi("dx"),mi("j")))`.

• 

Redefine , to redefine the coordinates and the spacetime metric according to changes in the signature from any of the four possible signatures(− + + +), (+ − − −), (+ + + −) and ((− + + +) to any of the other ones.

• 

EnergyMomentum , is a computational representation for the energy-momentum tensor entering Einstein's equations as well as their 3+1 form, the ADMEquations .

 

Examples

 

restart; with(Physics); Setup(coordinatesystems = cartesian)

`Default differentiation variables for d_, D_ and dAlembertian are: `*{X = (x, y, z, t)}

 

`Systems of spacetime Coordinates are: `*{X = (x, y, z, t)}

 

[coordinatesystems = {X}]

(2.1.1)

with(ThreePlusOne)

`Setting lowercaselatin_is letters to represent space indices `

 

0, "%1 is not a command in the %2 package", ThreePlusOne, Physics

 

`Changing the signature of spacetime from `(`- - - +`)*` to `(`+ + + -`)*` in order to match the signature customarily used in the ADM formalism`

 

[ADMEquations, Christoffel3, D3_, ExtrinsicCurvature, Lapse, Ricci3, Riemann3, Shift, TimeVector, UnitNormalVector, gamma3_]

(2.1.2)

Note the different color for gamma[mu, nu], now a 4D tensor representing the metric of a generic 3-dimensional hypersurface induced by the 4D spacetime metric g[mu, nu]. All the ThreePlusOne tensors are displayed in black to distinguish them of the corresponding 4D or 3D tensors. The particular hypersurface gamma[mu, nu] operates is parameterized by the Lapse  alpha and the Shift  beta[mu].

The induced metric gamma[mu, nu]is defined in terms of the UnitNormalVector  n[mu] and the 4D metric g[mu, nu] as

gamma3_[definition]

Physics:-ThreePlusOne:-gamma3_[mu, nu] = Physics:-ThreePlusOne:-UnitNormalVector[mu]*Physics:-ThreePlusOne:-UnitNormalVector[nu]+Physics:-g_[mu, nu]

(2.1.3)

where n[mu] is defined in terms of the Lapse  alpha and the derivative of a scalar function t that can be interpreted as a global time function

UnitNormalVector[definition]

Physics:-ThreePlusOne:-UnitNormalVector[mu] = -Physics:-ThreePlusOne:-Lapse*Physics:-D_[mu](t)

(2.1.4)

The TimeVector  is defined in terms of the Lapse  alpha and the Shift  beta[mu] and this vector  n[mu] as

TimeVector[definition]

Physics:-ThreePlusOne:-TimeVector[mu] = Physics:-ThreePlusOne:-Lapse*Physics:-ThreePlusOne:-UnitNormalVector[mu]+Physics:-ThreePlusOne:-Shift[mu]

(2.1.5)

The ExtrinsicCurvature  is defined in terms of the LieDerivative  of  gamma[mu, nu]

ExtrinsicCurvature[definition]

Physics:-ThreePlusOne:-ExtrinsicCurvature[mu, nu] = -(1/2)*Physics:-LieDerivative[Physics:-ThreePlusOne:-UnitNormalVector](Physics:-ThreePlusOne:-gamma3_[mu, nu])

(2.1.6)

The metric gamma[mu, nu]is also a projection tensor in that it projects 4D tensors into the 3D hypersurface Σ. The definition for any 4D tensor that is also a 3D tensor in Σ, can thus be written directly by contracting their indices with gamma[mu, nu]. In the case of Christoffel3 , Ricci3  and Riemann3,  these tensors can be defined by replacing the 4D metric g[mu, nu] by gamma[mu, nu] and the 4D Christoffel symbols GAMMA[mu, nu, alpha] by the ThreePlusOne GAMMA[mu, nu, alpha] in the definitions of the corresponding 4D tensors. So, for instance

Christoffel3[definition]

Physics:-ThreePlusOne:-Christoffel3[mu, nu, alpha] = (1/2)*Physics:-ThreePlusOne:-gamma3_[mu, `~beta`]*(Physics:-d_[alpha](Physics:-ThreePlusOne:-gamma3_[beta, nu], [X])+Physics:-d_[nu](Physics:-ThreePlusOne:-gamma3_[beta, alpha], [X])-Physics:-d_[beta](Physics:-ThreePlusOne:-gamma3_[nu, alpha], [X]))

(2.1.7)

Ricci3[definition]

Physics:-ThreePlusOne:-Ricci3[mu, nu] = Physics:-d_[alpha](Physics:-ThreePlusOne:-Christoffel3[`~alpha`, mu, nu], [X])-Physics:-d_[nu](Physics:-ThreePlusOne:-Christoffel3[`~alpha`, mu, alpha], [X])+Physics:-ThreePlusOne:-Christoffel3[`~beta`, mu, nu]*Physics:-ThreePlusOne:-Christoffel3[`~alpha`, beta, alpha]-Physics:-ThreePlusOne:-Christoffel3[`~beta`, mu, alpha]*Physics:-ThreePlusOne:-Christoffel3[`~alpha`, nu, beta]

(2.1.8)

Riemann3[definition]

Physics:-ThreePlusOne:-Riemann3[mu, nu, alpha, beta] = Physics:-g_[mu, lambda]*(Physics:-d_[alpha](Physics:-ThreePlusOne:-Christoffel3[`~lambda`, nu, beta], [X])-Physics:-d_[beta](Physics:-ThreePlusOne:-Christoffel3[`~lambda`, nu, alpha], [X])+Physics:-ThreePlusOne:-Christoffel3[`~lambda`, upsilon, alpha]*Physics:-ThreePlusOne:-Christoffel3[`~upsilon`, nu, beta]-Physics:-ThreePlusOne:-Christoffel3[`~lambda`, upsilon, beta]*Physics:-ThreePlusOne:-Christoffel3[`~upsilon`, nu, alpha])

(2.1.9)

When working with the ADM formalism, the line element of an arbitrary spacetime metric can be expressed in terms of the differentials of the coordinates dx^mu, the Lapse , the Shift  and the spatial components of the 3D metric gamma3_ . From this line element one can derive the relation between the Lapse , the spatial part of the Shift , the spatial part of the gamma3_  metric and the g[0, j] components of the 4D spacetime metric.

For this purpose, define a tensor representing the differentials of the coordinates and an alias  dt = `#msup(mi("dx"),mn("0"))`

Define(dx[mu])

`Defined objects with tensor properties`

 

{Physics:-ThreePlusOne:-D3_[mu], Physics:-Dgamma[mu], Physics:-Psigma[mu], Physics:-ThreePlusOne:-Ricci3[mu, nu], Physics:-ThreePlusOne:-Shift[mu], Physics:-d_[mu], dx[mu], Physics:-g_[mu, nu], Physics:-ThreePlusOne:-gamma3_[mu, nu], Physics:-gamma_[i, j], Physics:-ThreePlusOne:-Christoffel3[mu, nu, alpha], Physics:-KroneckerDelta[mu, nu], Physics:-LeviCivita[alpha, beta, mu, nu], Physics:-ThreePlusOne:-Riemann3[mu, nu, alpha, beta], Physics:-ThreePlusOne:-TimeVector[mu], Physics:-ThreePlusOne:-ExtrinsicCurvature[mu, nu], Physics:-ThreePlusOne:-UnitNormalVector[mu], Physics:-SpaceTimeVector[mu](X)}

(2.1.10)

"alias(dt = dx[~0]):"

The expression for the line element in terms of the Lapse  and Shift   is (see [2], eq.(2.123))

ds^2 = (-Lapse^2+Shift[i]^2)*dt^2+2*Shift[i]*dt*dx[`~i`]+gamma_[i, j]*dx[`~i`]*dx[`~j`]

ds^2 = (-Physics:-ThreePlusOne:-Lapse^2+Physics:-ThreePlusOne:-Shift[i]*Physics:-ThreePlusOne:-Shift[`~i`])*dt^2+2*Physics:-ThreePlusOne:-Shift[i]*dt*dx[`~i`]+Physics:-gamma_[i, j]*dx[`~i`]*dx[`~j`]

(2.1.11)

Compare this expression with the 3+1 decomposition of the line element in an arbitrary system. To avoid the automatic evaluation of the metric components, work with the inert form of the metric %g_

ds^2 = %g_[mu, nu]*dx[`~mu`]*dx[`~nu`]

ds^2 = %g_[mu, nu]*dx[`~mu`]*dx[`~nu`]

(2.1.12)

Decompose(ds^2 = %g_[mu, nu]*dx[`~mu`]*dx[`~nu`])

ds^2 = %g_[0, 0]*dt^2+%g_[0, j]*dt*dx[`~j`]+%g_[i, 0]*dt*dx[`~i`]+%g_[i, j]*dx[`~i`]*dx[`~j`]

(2.1.13)

The second and third terms on the right-hand side are equal

op(2, rhs(ds^2 = dt^2*%g_[0, 0]+dt*%g_[0, j]*dx[`~j`]+dt*%g_[i, 0]*dx[`~i`]+%g_[i, j]*dx[`~i`]*dx[`~j`])) = op(3, rhs(ds^2 = dt^2*%g_[0, 0]+dt*%g_[0, j]*dx[`~j`]+dt*%g_[i, 0]*dx[`~i`]+%g_[i, j]*dx[`~i`]*dx[`~j`]))

%g_[0, j]*dt*dx[`~j`] = %g_[i, 0]*dt*dx[`~i`]

(2.1.14)

subs(%g_[0, j]*dt*dx[`~j`] = %g_[i, 0]*dt*dx[`~i`], ds^2 = dt^2*%g_[0, 0]+dt*%g_[0, j]*dx[`~j`]+dt*%g_[i, 0]*dx[`~i`]+%g_[i, j]*dx[`~i`]*dx[`~j`])

ds^2 = %g_[0, 0]*dt^2+2*%g_[i, 0]*dt*dx[`~i`]+%g_[i, j]*dx[`~i`]*dx[`~j`]

(2.1.15)

Taking the difference between this expression and the one in terms of the Lapse  and Shift  we get

simplify((ds^2 = dt^2*%g_[0, 0]+2*dt*%g_[i, 0]*dx[`~i`]+%g_[i, j]*dx[`~i`]*dx[`~j`])-(ds^2 = (-Physics:-ThreePlusOne:-Lapse^2+Physics:-ThreePlusOne:-Shift[i]*Physics:-ThreePlusOne:-Shift[`~i`])*dt^2+2*Physics:-ThreePlusOne:-Shift[i]*dt*dx[`~i`]+Physics:-gamma_[i, j]*dx[`~i`]*dx[`~j`]))

0 = (Physics:-ThreePlusOne:-Lapse^2-Physics:-ThreePlusOne:-Shift[i]*Physics:-ThreePlusOne:-Shift[`~i`]+%g_[0, 0])*dt^2+2*dx[`~i`]*(%g_[i, 0]-Physics:-ThreePlusOne:-Shift[i])*dt-dx[`~i`]*dx[`~j`]*(Physics:-gamma_[i, j]-%g_[i, j])

(2.1.16)

Taking coefficients, we get equations for the Shift , the Lapse  and the spatial components of the metric gamma3_

eq[1] := coeff(coeff(rhs(0 = (Physics:-ThreePlusOne:-Lapse^2-Physics:-ThreePlusOne:-Shift[i]*Physics:-ThreePlusOne:-Shift[`~i`]+%g_[0, 0])*dt^2+2*dx[`~i`]*(%g_[i, 0]-Physics:-ThreePlusOne:-Shift[i])*dt-dx[`~i`]*dx[`~j`]*(Physics:-gamma_[i, j]-%g_[i, j])), dt), dx[`~i`]) = 0

2*%g_[i, 0]-2*Physics:-ThreePlusOne:-Shift[i] = 0

(2.1.17)

eq[2] := coeff(rhs(0 = (Physics:-ThreePlusOne:-Lapse^2-Physics:-ThreePlusOne:-Shift[i]*Physics:-ThreePlusOne:-Shift[`~i`]+%g_[0, 0])*dt^2+2*dx[`~i`]*(%g_[i, 0]-Physics:-ThreePlusOne:-Shift[i])*dt-dx[`~i`]*dx[`~j`]*(Physics:-gamma_[i, j]-%g_[i, j])), dt^2)

Physics:-ThreePlusOne:-Lapse^2-Physics:-ThreePlusOne:-Shift[i]*Physics:-ThreePlusOne:-Shift[`~i`]+%g_[0, 0]

(2.1.18)

eq[3] := coeff(coeff(rhs(0 = (Physics:-ThreePlusOne:-Lapse^2-Physics:-ThreePlusOne:-Shift[i]*Physics:-ThreePlusOne:-Shift[`~i`]+%g_[0, 0])*dt^2+2*dx[`~i`]*(%g_[i, 0]-Physics:-ThreePlusOne:-Shift[i])*dt-dx[`~i`]*dx[`~j`]*(Physics:-gamma_[i, j]-%g_[i, j])), dx[`~i`]), dx[`~j`]) = 0

-Physics:-gamma_[i, j]+%g_[i, j] = 0

(2.1.19)

Using these equations, these quantities can all be expressed in terms of the time and space components of the 4D metric g[0, 0] and g[i, j]

isolate(eq[1], Shift[i])

Physics:-ThreePlusOne:-Shift[i] = %g_[i, 0]

(2.1.20)

isolate(eq[2], Lapse^2)

Physics:-ThreePlusOne:-Lapse^2 = Physics:-ThreePlusOne:-Shift[i]*Physics:-ThreePlusOne:-Shift[`~i`]-%g_[0, 0]

(2.1.21)

isolate(eq[3], gamma_[i, j])

Physics:-gamma_[i, j] = %g_[i, j]

(2.1.22)

References

 
  

[1] Landau, L.D., and Lifshitz, E.M. The Classical Theory of Fields, Course of Theoretical Physics Volume 2, fourth revised English edition. Elsevier, 1975.

  

[2] Alcubierre, M., Introduction to 3+1 Numerical Relativity, International Series of Monographs on Physics 140, Oxford University Press, 2008.

  

[3] Baumgarte, T.W., Shapiro, S.L., Numerical Relativity, Solving Einstein's Equations on a Computer, Cambridge University Press, 2010.

  

[4] Gourgoulhon, E., 3+1 Formalism and Bases of Numerical Relativity, Lecture notes, 2007, https://arxiv.org/pdf/gr-qc/0703035v1.pdf.

  

[5] Arnowitt, R., Dese, S., Misner, C.W., The Dynamics of General Relativity, Chapter 7 in Gravitation: an introduction to current research (Wiley, 1962), https://arxiv.org/pdf/gr-qc/0405109v1.pdf

  

 

Examples: Decompose, gamma_

 

restartwith(Physics)NULL

Setup(mathematicalnotation = true)

[mathematicalnotation = true]

(2.2.1)

Define  now an arbitrary tensor A

Define(A)

`Defined objects with tensor properties`

 

{A, Physics:-Dgamma[mu], Physics:-Psigma[mu], Physics:-d_[mu], Physics:-g_[mu, nu], Physics:-KroneckerDelta[mu, nu], Physics:-LeviCivita[alpha, beta, mu, nu]}

(2.2.2)

So A^mu is a 4D tensor with only one free index, where the position of the time-like component is the position of the different sign in the signature, that you can query about via

Setup(signature)

[signature = `- - - +`]

(2.2.3)

To perform a decomposition into space and time, set - for instance - the lowercase latin letters from i to s to represent spaceindices and

Setup(spaceindices = lowercase_is)

[spaceindices = lowercaselatin_is]

(2.2.4)

Accordingly, the 3+1 decomposition of A^mu is

Decompose(A[`~mu`])

Array(%id = 18446744078724512334)

(2.2.5)

The 3+1 decomposition of the inert representation %g_[mu,nu] of the 4D spacetime metric; use the inert representation when you do not want the actual components of the metric appearing in the output

Decompose(%g_[mu, nu])

Matrix(%id = 18446744078724507998)

(2.2.6)

Note the position of the component %g_[0, 0], related to the trailing position of the time-like component in the signature "(- - - +)".

Compare the decomposition of the 4D inert with the decomposition of the 4D active spacetime metric

g[]

g[mu, nu] = (Matrix(4, 4, {(1, 1) = -1, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (2, 1) = 0, (2, 2) = -1, (2, 3) = 0, (2, 4) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = -1, (3, 4) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = 1}))

(2.2.7)

Decompose(g_[mu, nu])

Matrix(%id = 18446744078724494270)

(2.2.8)

Note that in general the 3D space part of g[mu, nu] is not equal to the 3D metric gamma[i, j] whose definition includes another term (see [1] Landau & Lifshitz, eq.(84.7)).

gamma_[definition]

Physics:-gamma_[i, j] = -Physics:-g_[i, j]+Physics:-g_[0, i]*Physics:-g_[0, j]/Physics:-g_[0, 0]

(2.2.9)

The 3D space part of -g[`~mu`, `~nu`] is actually equal to the 3D metric "gamma[]^(i,j)"

"gamma_[~,definition];"

Physics:-gamma_[`~i`, `~j`] = -Physics:-g_[`~i`, `~j`]

(2.2.10)

To derive the formula  for the covariant components of the 3D metric, Decompose into 3+1 the identity

%g_[`~alpha`, `~mu`]*%g_[mu, beta] = KroneckerDelta[`~alpha`, beta]

%g_[`~alpha`, `~mu`]*%g_[mu, beta] = Physics:-KroneckerDelta[beta, `~alpha`]

(2.2.11)

To the side, for illustration purposes, these are the 3 + 1 decompositions, first excluding the repeated indices, then excluding the free indices

Eq := Decompose(%g_[`~alpha`, `~mu`]*%g_[mu, beta] = Physics[KroneckerDelta][beta, `~alpha`], repeatedindices = false)

Matrix(%id = 18446744078132963318)

(2.2.12)

Eq := Decompose(%g_[`~alpha`, `~mu`]*%g_[mu, beta] = Physics[KroneckerDelta][beta, `~alpha`], freeindices = false)

%g_[0, beta]*%g_[`~alpha`, `~0`]+%g_[i, beta]*%g_[`~alpha`, `~i`] = Physics:-KroneckerDelta[beta, `~alpha`]

(2.2.13)

Compare with a full decomposition

Eq := Decompose(%g_[`~alpha`, `~mu`]*%g_[mu, beta] = Physics[KroneckerDelta][beta, `~alpha`])

Matrix(%id = 18446744078724489454)

(2.2.14)

Eq is a symmetric matrix of equations involving non-contracted occurrences of `#msup(mi("g"),mrow(mn("0"),mo("&comma;"),mn("0")))`, `#msup(mi("g"),mrow(mi("j"),mo("&comma;"),mo("0")))` and `#msup(mi("g"),mrow(mi("j"),mo("&comma;"),mi("i")))`. Isolate, in Eq[1, 2], `#msup(mi("g"),mrow(mi("j"),mo("&comma;"),mo("0")))`, that you input as %g_[~j, ~0], and substitute into Eq[1, 1]

"isolate(Eq[1, 2], `%g_`[~j, ~0]);"

%g_[`~j`, `~0`] = -%g_[i, 0]*%g_[`~j`, `~i`]/%g_[0, 0]

(2.2.15)

subs(%g_[`~j`, `~0`] = -%g_[i, 0]*%g_[`~j`, `~i`]/%g_[0, 0], Eq[1, 1])

-%g_[0, k]*%g_[i, 0]*%g_[`~j`, `~i`]/%g_[0, 0]+%g_[i, k]*%g_[`~j`, `~i`] = Physics:-KroneckerDelta[k, `~j`]

(2.2.16)

Collect `#msup(mi("g"),mrow(mi("j"),mo("&comma;"),mi("i")))`, that you input as %g_[~j, ~i]

collect(-%g_[0, k]*%g_[i, 0]*%g_[`~j`, `~i`]/%g_[0, 0]+%g_[i, k]*%g_[`~j`, `~i`] = Physics[KroneckerDelta][k, `~j`], %g_[`~j`, `~i`])

(-%g_[0, k]*%g_[i, 0]/%g_[0, 0]+%g_[i, k])*%g_[`~j`, `~i`] = Physics:-KroneckerDelta[k, `~j`]

(2.2.17)

Since the right-hand side is the identity matrix and, from , `#msup(mi("g"),mrow(mi("i"),mo("&comma;"),mi("j")))` = -`#msup(mi("&gamma;",fontstyle = "normal"),mrow(mi("i"),mo("&comma;"),mi("j")))`, the expression between parenthesis, multiplied by -1, is the reciprocal of the contravariant 3D metric `#msup(mi("&gamma;",fontstyle = "normal"),mrow(mi("i"),mo("&comma;"),mi("j")))`, that is the covariant 3D metric gamma[i, j], in accordance to its definition for the signature `- - - +`

gamma_[definition]

Physics:-gamma_[i, j] = -Physics:-g_[i, j]+Physics:-g_[0, i]*Physics:-g_[0, j]/Physics:-g_[0, 0]

(2.2.18)

NULL

References

 
  

[1] Landau, L.D., and Lifshitz, E.M. The Classical Theory of Fields, Course of Theoretical Physics Volume 2, fourth revised English edition. Elsevier, 1975.

Example: Redefine

   

Tensors in Special and General Relativity

 

A number of relevant changes happened in the tensor routines of the Physics package, towards making the routines pack more functionality both for special and general relativity, as well as working more efficiently and naturally, based on Maple's Physics users' feedback collected during 2016.

New functionality

 
• 

Implement conversions to most of the tensors of general relativity (relevant in connection with functional differentiation)

• 

New setting in the Physics Setup  allows for specifying the cosmologicalconstant and a default tensorsimplifier


 

Download PhysicsMaple2017.mw

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

While preparing for a recent webinar, I ran across something that didn't behave the same way in Maple 2017 as it did in previous releases. In particular, it was the failure of the over-dot notation for t-derivatives to display with the over-dot. Turns out that this is due to a change in behavior of typesetting that was detailed in the What's New page for Maple 2017, a page I had looked at many times in the last few months, but apparently didn't comprehend fully. The details are below.

Prior to Maple 2017, under the aegis of extended typesetting, the following two lines of code would alert Maple that the over-dot notation for t-derivatives should be used in the output display.

However, this changed in Maple 2017. Extended typesetting is now the default, but these two lines of code are no longer sufficient to induce Maple to display the over-dot in output. Indeed, we would now have

as output. The change is documented in the following paragraph

lifted from the help page 

Thus, it now takes the additional command

to induce Maple to display the over-dot notation in output.

I must confess that, even though I pored over the "What's New" pages for Maple 2017, I completely missed the import of this change to typesetting. I stumbled over the issue while preparing for an upcoming webinar, and frantically sent out help calls to the developers back in the building. Fortunately, I was quickly set straight on the matter, but was disappointed in my own reading of all the implications of the typesetting changes in Maple 2017. So perhaps this note will alert other users to the changes, and to the help page wherein one finds those essential bits of information needed to complete the tasks we set for ourselves.

And one more thing - I was cautioned that the "= true" was essential. Without it, the command would act as a query, echoing the present state of the setting, and not making the desired change to the setting.
 

Let us consider the help to RectangleWindow SignalProcessing-RectangleWindow.pdf SignalProcessing-RectangleWindow.mw.
Let us execute the example, taking N:=4 (in order to display the outputs).

with(SignalProcessing):
N := 4;
a := GenerateUniform(N, -1, 1);
         Matrix(1, 4, [[.396167882718146, -.826878267806025, -0.908376742154361e-2, .324899681378156]])         
RectangleWindow(a);
         Vector[row](4, [.396167882718146, -.826878267806025, -0.908376742154361e-2, .324899681378156])      
c := Array(1 .. N, 'datatype' = 'float'[8], 'order' = 'C_order'):
RectangleWindow(Array(1 .. N, 'fill' = 1, 'datatype' = 'float'[8], 'order' = 'C_order'), 'container' = c);
              Vector[row](4, [1., 1., 1., 1.])
u := `~`[log](FFT(c)):
plots:-display(Array([plots:-listplot(Re(u)), plots:-listplot(Im(u))]));



We see an uncommented code which (intentionally or unintentionally) produces two empty plots.
The questions arise:

  • What is the aim of the RectangleWindow command which does nothing 
    but the conversion of a Matrix(1,N,...) /Array(1..N,...) to a Vector[row](N,...)? 
  • Could such help be called friendly to Maple users?

There are many questions to Maplesoft and there are no answers from them: strategic silence.
RectangleWindow.mw

 

In the creation of this animation the technique from here  was used.

 

                    

 

The code of this animation:

with(plots): with(plottools):
SmallHeart:=plot([1/20*sin(t)^3, 1/20*(13*cos(t)/16-5*cos(2*t)/16-2*cos(3*t)/16-cos(4*t)/16), t = 0 .. 2*Pi], color = "Red", thickness=3, filled):
F:=t->[sin(t)^3, 13*cos(t)/16-5*cos(2*t)/16-2*cos(3*t)/16-cos(4*t)/16]:
Gf:=display(translate(SmallHeart, 0,0.37)):
Gl:=display(translate(SmallHeart, 0,-1)):
G:=t->display(translate(SmallHeart, F(t)[])):
A:=display(seq(display(op([Gf,seq(G(-Pi/20*t), t=3..k),seq(G(Pi/20*t), t=3..k)]))$4,k=2..17),display(op([Gf,seq(G(-Pi/20*t), t=3..17),seq(G(Pi/20*t), t=3..17),Gl]))$30, insequence=true, size=[600,600]):
B:=animate(textplot,[[-0.6,0.25, "Happy"[1..round(n)]],color="Orange", font=[times,bolditalic,40], align=right],n=0..5,frames=18, paraminfo=false):
C:=animate(textplot,[[-0.2,0, "Valentine's"[1..round(n)]],color=green, font=[times,bolditalic,40], align=right],n=1..11,frames=35, paraminfo=false):
E:=animate(textplot,[[-0.3,-0.25, "Day!"[1..round(n)]],color="Blue", font=[times,bolditalic,40], align=right],n=1..4,frames=41, paraminfo=false):
T:=display([B, display(op([1,-1,1],B),C), display(op([1,-1,1],B),op([1,-1,1],C),E)], insequence=true):
K:=display(A, T, axes=none):
K;


The last frame of this animation:

display(op([1,-1],K), size=[600,600], axes=none);  # The last frame

                          

 

ValentinelDay.mw
 

Edit. The code was edited - the number of frames has been increased.

Let us consider the linear integer programming problem:

A := Matrix([[1, 7, 1, 3], [1, 6, 4, 6], [17, 1, 5, 1], [1, 6, 10, 4]]):
 n := 4; z := add(add(A[i, j]*x[i, j], j = 1 .. n), i = 1 .. n):
restr := {seq(add(x[i, j], i = 1 .. n) = 1, j = 1 .. n), seq(add(x[i, j], j = 1 .. n) = 1, i = 1 .. n)}:
 sol := Optimization[LPSolve](z, restr, assume = binary);

Error, (in Optimization:-LPSolve) no feasible integer point found; 
use feasibilitytolerance option to adjust tolerance

sol1 := Optimization[LPSolve](z, restr, assume = binary, feasibilitytolerance = 100, integertolerance = 1);

Error, (in Optimization:-LPSolve) no feasible integer point found;
 use feasibilitytolerance option to adjust tolerance

That was OK in Maple 16, outputting

.

The bug in one of the principal Maple commands lasts since Maple 2015, where the above code causes "Kernel connection has been lost". The SCRs about it were submitted three times (see http://www.mapleprimes.com/questions/204750-Bug-In-LPSolve-In-Maple-20151).

First 13 14 15 16 17 18 19 Last Page 15 of 64