by: Maple 2020

## Misinterpretation flattening the US log graph...

Maple

Something a while ago made me wonder if people were interpretting the results of flattening the covid19 curve wrong.  Log graphs are good way to display a wide range of data in a compact way, but if you can't interpret it properly then you might as well think apples are oranges.  There was something someone said not to long ago that I didn't believe.  That person was Dr. Fauci, an American physician and immunologist who served as the director of the National Institute of Allergy and Infectious Diseases since 1984.  On April 9, 2020 he said, on the final death toll of the U.S. for Coronavirus, and I quote "looks more like 60,000 than the 100,000 to 200,000" U.S. officials had previously estimated ...  Back then I thought he was wrong, and actually now, he is wrong.

Some people just don't understand log graphs and I believe a lot of people are misinterpretting them.  Take a linear graph increasing in time and put it on a log scale and you naturally get a "flattening" curve without even doing anything.  But let's see what Dr. Fauci was seeing, and how he and likely many others, are misinterpretting the graphs.

Taking data from Worldometers.info/coronavirus we gather the total deaths

We will graph the data from when there were more than 100 deaths and up until April 9th when he made his prediction.

 (1)

 (2)

 (3)

Just by looking at the graph you  can imagine Dr. Fauci saying look at that graph starting to level off and he would extrapolate an imaginary line that could if you wanted to level off around where he said 60,000.  And that's the confusion people have with these log graphs - people misinterpret them.

Here's what it looks like today

 (4)

 (5)

One still could think and interpret that graph at levelling off to maybe 100,000.  I sense another Dr. Fauci prediction?

Let's take a look at the linear graph

 (6)

 (7)

My guess is it was Dr. Fauci's hope that it would only go to 60,000 but it was also his interpretation of the log graph.  It could start to round a peak at some point and it will eventually, however based on the way people behave in North America and there will apparently be no complete lockdown, in my humble opinion, that graph is going to keep on sailing well passed 100,000.

## A triangle of maximum area inscribed in an ellipse...

by: Maple 17

One of the forums asked a question: what is the maximum area of a triangle inscribed in a given ellipse x^2/16 + y^2/3 - 1 = 0? It turned out to be 9, but there are infinitely many such triangles. There was a desire to show them in one of the possible ways. This is a complete (as far as possible) set of such triangles.
(This is not an example of Maple programming; it is just an implementation of a Maple-based algorithm and the work of the Optimization package).
MAX_S_TRIAN_ANINATION.mw

## Simulation of the DNA with Maple

Maple 2020

This app shows the modeling and simulation of DNA carried out entirely in Maple. The mathematical model is inserted through the combination of trigonometric functions. It shows the graphs of the curvature vs time for its interpretation. Made for engineering and health science students.

Lenin Araujo Castillo

## Maple for Beginners

by: Maple

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

## Vectors in Spherical Coordinates using Tensor...

by: Maple

Vectors in Spherical Coordinates using Tensor Notation

Edgardo S. Cheb-Terrab1 and Pascal Szriftgiser2

(2) Laboratoire PhLAM, UMR CNRS 8523, Université de Lille, F-59655, France

(1) Maplesoft

The following is a topic that appears frequently in formulations: given a 3D vector in spherical (or any curvilinear) coordinates, how do you represent and relate, in simple terms, the vector and the corresponding vectorial operations Gradient, Divergence, Curl and Laplacian using tensor notation?

The core of the answer is in the relation between the - say physical - vector components and the more abstract tensor covariant and contravariant components. Focusing the case of a transformation from Cartesian to spherical coordinates, the presentation below starts establishing that relationship between 3D vector and tensor components in Sec.I. In Sec.II, we verify the transformation formulas for covariant and contravariant components on the computer using TransformCoordinates. In Sec.III, those tensor transformation formulas are used to derive the vectorial form of the Gradient in spherical coordinates. In Sec.IV, we switch to using full tensor notation, a curvilinear metric and covariant derivatives to derive the 3D vector analysis traditional formulas in spherical coordinates for the Divergence, Curl, Gradient and Laplacian. On the way, some useful technics, like changing variables in 3D vectorial expressions, differential operators, using Jacobians, and shortcut notations are shown.

The computation below is reproducible in Maple 2020 using the Maplesoft Physics Updates v.640 or newer.

Start setting the spacetime to be 3-dimensional, Euclidean, and use Cartesian coordinates

 >
 >
 (1)

I. The line element in spherical coordinates and the scale-factors

In vector calculus, at the root of everything there is the line element , which in Cartesian coordinates has the simple form

 >
 (1.1)

To compute the line element   in spherical coordinates, the starting point is the transformation

 >
 (1.2)
 >
 (1.3)

Since in  are just symbols with no relationship to start transforming these differentials using the chain rule, computing the Jacobian of the transformation (1.2). In this Jacobian J, the first line is , ,

 >

So in matrix notation,

 >
 (1.4)

To complete the computation of   in spherical coordinates we can now use ChangeBasis , provided that next we substitute (1.4) in the result, expressing the abstract objects  in terms of .

In two steps:

 >
 (1.5)

The line element

 >
 (1.6)

This result is important: it gives us the so-called scale factors, the key that connect 3D vectors with the related covariant and contravariant tensors in curvilinear coordinates. The scale factors are computed from (1.6) by taking the scalar product with each of the unit vectors , then taking the coefficients of the differentials  (just substitute them by the number 1)

 >
 (1.7)

The scale factors are relevant because the components of the 3D vector and the corresponding tensor are not the same in curvilinear coordinates. For instance, representing the differential of the coordinates as the tensor , we see that corresponding vector, the line element in spherical coordinates , is not  constructed by directly equating its components to the components of , so

The vector  is constructed multiplying these contravariant components  by the scaling factors, as

This rule applies in general. The vectorial components of a 3D vector in an orthogonal system (curvilinear or not) are always expressed in terms of the contravariant components  the same way we did in the line above with the line element, using the scale-factors , so that

where on the right-hand side we see the contravariant components  and the scale-factors . Because the system is orthogonal, each vector component satisfies

The scale-factors  do not constitute a tensor, so on the right-hand side we do not sum over j.  Also, from

it follows that,

where on the right-hand side we now have the covariant tensor components .

 • This relationship between the components of a 3D vector and the contravariant and covariant components of a tensor representing the vector is key to translate vector-component to corresponding tensor-component formulas.

II. Transformation of contravariant and covariant tensors

Define here two representations for one and the same tensor:  will represent A in Cartesian coordinates, while  will represent A in spherical coordinates.

 >
 (2.1)

Transformation rule for a contravariant tensor

We know, by definition, that the transformation rule for the components of a contravariant tensor is , that is the same as the rule for the differential of the coordinates. Then, the transformation rule from  to computed using TransformCoordinates should give the same relation (1.4). The application of the command, however, requires attention, because, as in (1.4), we want the Cartesian (not the spherical) components isolated. That is like performing a reversed transformation. So we will use

where on the left-hand side we get, isolated, the three components of A in Cartesian coordinates, and on the right-hand side we transform the spherical components , from spherical  (4th argument) to Cartesian  (3rd argument), which according to the 5th bullet of TransformCoordinates  will result in a transformation expressed in terms of the old coordinates (here the spherical ). Expand things to make the comparison with (1.4) possible by eye

 >
 (2.2)

We see that the transformation rule for a contravariant vector is, indeed, as the transformation (1.4) for the differential of the coordinates.

Transformation rule for a covariant tensor

For the transformation rule for the components of a covariant tensor , we know, by definition, that it is , so the same transformation rule for the gradient , where  and so on. We can experiment this by directly changing variables in the differential operators , for example

 >
 (2.3)

This result, and the equivalent ones replacing x by y or z in the input above can be computed in one go, in matricial and simplified form, using the Jacobian of the transformation computed in . We need to take the transpose of the inverse of J (because now we are transforming the components of the gradient   )

 >
 >
 (2.4)

The corresponding transformation equations relating the tensors  and  in Cartesian and spherical coordinates is computed with TransformCoordinates  as in (2.2), just lowering the indices on the left and right hand sides (i.e., remove the tilde ~)

 >
 (2.5)

We see that the transformation rule for a covariant vector  is, indeed, as the transformation rule (2.4) for the gradient.

To the side: once it is understood how to compute these transformation rules, we can have the inverse of (2.5) as follows

 >
 (2.6)

III. Deriving the transformation rule for the Gradient using TransformCoordinates

Turn ON the CompactDisplay  notation for derivatives, so that the differentiation variable is displayed as an index:

 >

The gradient of a function f in Cartesian coordinates and spherical coordinates is respectively given by

 >
 (3.1)
 >
 (3.2)

What we want now is to depart from (3.1) in Cartesian coordinates and obtain (3.2) in spherical coordinates using the transformation rule for a covariant tensor computed with TransformCoordinates in (2.5). (An equivalent derivation, simpler and with less steps is done in Sec. IV.)

Start changing the vector basis in the gradient (3.1)

 >
 (3.3)

By eye, we see that in this result the coefficients of  are the three lines in the right-hand side of (2.6) after replacing the covariant components  by the derivatives of f with respect to the jth coordinate, here displayed using indexed notation due to using CompactDisplay

 >
 (3.4)
 >
 (3.5)

So since (2.5) is the inverse of (2.6), replace A by ∂ f in (2.5), the formula computed using TransformCoordinates, then insert the result in (3.3) to relate the gradient in Cartesian and spherical coordinates. We expect to arrive at the formula for the gradient in spherical coordinates (3.2) .

 >
 (3.6)
 >
 (3.7)

Simplifying, we arrive at (3.2)

 >
 (3.8)
 >
 (3.9)

IV. Deriving the transformation rule for the Divergence, Curl, Gradient and Laplacian, using TransformCoordinates and Covariant derivatives

 • The Divergence

Introducing the vector A in spherical coordinates, its Divergence is given by

 >
 (4.1)
 >
 (4.2)
 >
 (4.3)

We want to see how this result, (4.3), can be obtained using TransformCoordinates and departing from a tensorial representation of the object, this time the covariant derivative . For that purpose, we first transform the coordinates and the metric introducing nonzero Christoffel symbols

 >
 (4.4)

To the side: despite having nonzero Christoffel symbols, the space still has no curvature, all the components of the Riemann tensor are equal to zero

 >
 (4.5)

Consider now the divergence of the contravariant tensor, computed in tensor notation

 >
 (4.6)
 >
 (4.7)

To the side: the covariant derivative  expressed using the D_  operator can be rewritten in terms of the non-covariant d_  and Christoffel  symbols as follows

 >
 (4.8)

Summing over the repeated indices in (4.7), we have

 >
 (4.9)

How is this related to the expression of the  in (4.3) ? The answer is in the relationship established at the end of Sec I between the components of the tensor and the components of the vector , namely that the vector components are obtained multiplying the contravariant tensor components by the scale-factors . So, in the above we need to substitute the contravariant  by the vector components  divided by the scale-factors

 >
 (4.10)
 >
 (4.11)

Comparing with (4.3), we see these two expressions are the same:

 >
 (4.12)
 • The Curl

The Curl of the the vector  in spherical coordinates is given by

 >
 (4.13)

One could think that the expression for the Curl in tensor notation is as in a non-curvilinear system

But in a curvilinear system  is not a tensor, we need to use the non-Galilean form , where  is the determinant of the metric. Moreover, since the expression has one free covariant index (the first one), to compare with the vectorial formula (4.12) this index also needs to be rewritten as a vector component as discussed at the end of Sec. I, using

The formula (4.13) for the vectorial Curl is thus expressed using tensor notation as

 >
 (4.14)
 >
 (4.15)

followed by replacing the contravariant tensor components  by the vector components  using (4.10). Proceeding the same way we did with the Divergence, expand this expression. We could use TensorArray , but Library:-TensorComponents places a comma between components making things more readable in this case

 >
 (4.16)

Replace now the components of the tensor  by the components of the 3D vector  using (4.10)

 >
 (4.17)
 >
 (4.18)

We see these are exactly the components of the Curl (4.13)

 >
 (4.19)

Once the problem is fully understood, it is easy to redo the computations of Sec.III for the Gradient, this time using tensor notation and the covariant derivative. In tensor notation, the components of the Gradient are given by the components of the right-hand side

 >
 (4.20)

where on the left-hand side we have the vectorial Nabla  differential operator and on the right-hand side, since  is a scalar, the covariant derivative  becomes the standard derivative .

 >
 (4.21)

The above is the expected result (3.2)

 >
 (4.22)
 • The Laplacian

Likewise we can compute the Laplacian directly as

 >
 (4.23)

In this case there are no free indices nor tensor components to be rewritten as vector components, so there is no need for scale-factors. Summing over the repeated indices,

 >
 (4.24)

Evaluating the  Vectors:-Laplacian on the left-hand side,

 >
 (4.25)

On the right-hand side we see the dAlembertian , in curvilinear coordinates; rewrite it using standard diff  derivatives and expand both sides of the equation for comparison

 >
 (4.26)

This is an identity, the left and right hand sides are equal:

 >
 (4.27)

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

## Š¯oles on an implicit plot

by: Maple 17

A way of cutting holes on an implicit plot. This is from the field of numerical parameterization of surfaces. On the example of the surface  x3 = 0.01*exp (x1) / (0.01 + x1^4 + x2^4 + x3^4)  consider the approach to producing holes. The surface is locally parameterized in some suitable way and the place for the hole and its size are selected. In the first example, the parametrization is performed on the basis of the section of the initial surface by perpendicular planes. In the second example, "round"  parametrization. It is made on the basis of the cylinder and the planes passing through its axis. Holes can be of any size and any shape. In the figures, the cut out surface sections are colored green and are located above their own holes at an equidistant to the original surface.
HOLE_1.mwHOLE_2.mw

## How high is your chance to die for CoViD19 once...

by: Maple 2015

Hi,

The present work is aimed to show how bayesian inference methods can be used to infer (= to assess) the probabilility that a person detected infected by the SARS-Cov2  has to die (remark I did not write "has to die if it" because one never be sure of the reason of the death).
A lot of details are avaliable in the attached pdf file (I tried to be pedagogic enough so that the people not familiar with bayesian inference can get a global understanding of the subject, many links are provided for quick access to the different notions).

In particular, I explain why simple mathematics cannot provide a reliable estimate of this probability of death (sometimes referred to as the "death rate") as long as the epidemic continues to spread.

Even if the approach presented here is rather original, this is not the purpose of this post.
Since a long time I had in mind to post here an application concerning bayesian methods. The CoVid19 outbreak has only provided me with the most high-profile topic to do so.
I will say no more about the inference procedure itself (all the material is given in the attached pdf file) and I will only concentrate on the MAPLE implementation of the solution algorithm.

Bayesian Inference uses generally simple algorithms such as MCMC (Markov Chain Monte Carlo) or ABC (Approximate Bayesian Computation) to mention a few, and their corresponding pseudo code writes generally upon a few tens of lines.
This is something I already done with other languages but I found the task comparatively more difficult with Maple. Probably I was to obsess not to code in Maple as you code in Matlab or R for instance.
At the very end the code I wrote is rather slow, this because of the allocated memory size it uses.
In a question I posed weeks ago (How can I prevent the creation of random variables...) Preben gave a solution to limit the burst of the memory: the trick works well but I'm still stuked with memory size problems (Acer also poposed a solution but I wasn't capable to make it works... maybe I was too lazzy to modify deeply my code).

Anyway, the code is there, in case anyone would like to take up the challenge to make it more efficient (in which case I'll take it).

Note 1: this code contains a small "Maplet" to help you choose any country in the data file on which you would like to run the inference.
Note 2: Be careful: doing statistics, even bayesian statistics, needs enough data: some countries have history records ranging over a few days , or no recorded death at all; infering something from so loos date will probably be disappointing

The attached files:

• The pdf file is the "companion document" where all or most of it is explained.It has been written a few days ago for another purpose and the results it presents were not ontained from the lattest data (march 21, 2020 coronavirus)
• xls files are data files, they were loaded yesterday (march 28, 2020) from here coronavirus
• the mw file... well, I guess you know what it is.

Bayesian_inference.pdf

total-cases-covid-19_NF.xls

## Puzzle - cut it into 2 equal parts

by:

The following puzzle prompted me to write this post: "A figure is drawn on checkered paper that needs to be cut into 2 equal parts (the cuts must pass along the sides of the squares.)" (parts are called equal if, after cutting, they can be superimposed on one another, that is, if one of them can be moved, rotated and (if need to) flip so that they completely coincide) (see the first picture below).
I could not solve it manually and wrote a procedure called  CutTwoParts  that does this automatically (of course, this procedure applies to other similar puzzles). This procedure uses my procedure  AreIsometric  published earlier  https://www.mapleprimes.com/posts/200157-Testing-Of-Two-Plane-Sets-For-Isometry  (for convenience, I have included its text here). In the procedure  CutTwoParts  the figure is specified by the coordinates of the centers of the squares of which it consists).

I advise everyone to first try to solve this puzzle manually in order to feel its non-triviality, and only then load the worksheet with the procedure for automatic solution.

For some reason, the worksheet did not load and I was only able to insert the link.

## First equilibrium condition with Maple

Maple 2020

With this application our students of science and engineering in the areas of physics will check the first condition of balance using Maple technology. Only with entering mass and angles we obtain graphs and data for a better interpretation.

First_equilibrium_condition.zip

Lenin AC

by: Maple 2020

So here's something silly but cool you can do with Maple while you're "working" from home.

• Record a few seconds of your voice on a microphone that's close to your mouth (probably using a headset). This is your dry audio.
• On your phone, record a single clap of your hands in an enclosed space, like your shower cubicle or a closet. Trim this audio to the clap, and the reverb created by your enclosed space. This is your impulse response.
• Send both sound files to whatever computer you have Maple on.
• Using AudioTools:-Convolution, convolve the dry audio with the impulse response . This your wet audio and should sound a little bit like your voice was recorded in your enclosed space.

Here's some code. I've also attached my dry audio, an impulse response recorded in my shower (yes, I stood inside my shower, closed the door, and recorded a single clap of my hands on my phone), and the resulting wet audio.

```with( AudioTools ):
wet_audio := Normalize( Convolution( dry_audio, impulse_response ) ):
Write("wet_audio.wav", wet_audio );
```

A full Maple worksheet is here.

AudioSamplesForReverb.zip

## Exploring the CoVid19 outbreak

by: Maple

Hi,

Two weeks ago, I started loading data on the CoVid19 outbreak in order to understand, out of any official communication from any country, what is really going on.

From february 29 to march 9 these data come from https://bnonews.com/index.php/2020/02/the-latest-coronavirus-cases/ and from 10 march until now from https://www.worldometers.info/coronavirus/#repro.In all cases the loading is done manually (copy-paste onto a LibreOffice spreadsheet plus correction and save into a xls file)Â for I wasn't capable to find csv data (csv data do exist here https://github.com/CSSEGISandData/COVID-19, by they end febreuary 15th).
So I copied-pasted the results from the two sources above into a LibreOffice spreadsheet, adjusted the names of some countries for they appeared differently (for instance "United States" instead of "USA"), removed the unnessary commas and saved the result in a xls file.

I also used data from https://www.worldometers.info/world-population/population-by-country/ to get the populations of more than 260 countries around the world and, finally, csv data from https://ourworldindata.org/coronavirus#covid-19-tests to get synthetic histories of confirmed and death cases (I have discovered this site only yesterday evening and I think it could replace all the data I initially loaded).

The two worksheet here are aimed to exploratory and visualization only.
An other one is in progress whose goal is to infer the true death rate (also known as CFR, Case Fatality Rate).

No analysis is presented, if for no other reason than that the available data (except the numbers of deaths) are extremely dependent on the testing policies in place. But some features can be drawn from the data used here.
For instance, if you select country = "China" in file Covid19_Evolution_bis.mw, you will observe very well known behaviour which is that the "Apparent Death Rate", I defined as the ratio of the cumulated number of death at time t by the cumulatibe number of confirmed cases at the same time, is always an underestimation of the death rate one can only known once the outbreak has ended. With this in mind, changing the country in this worksheet from China to Italy seems to lead to frightening  scary interpolations... But here again, without knowing the test policy no solid conclusion can be drawn: maybe Italy tests mainly elder people with accute symptoms, thus the huge "Apparent Death Rate" Italy seems to have?

The work has been done with Maple 2015 and some graphics can be improved if a newer version is used (for instance, as Maple 2015 doesn't allow to change the direction of tickmarks, I overcome this limitation by assigning the date to the vertical axis on some plots).
The second Explore plot could probably be improved by using newer versions or Maplets or Embeded components.

Explore data from https://bnonews.com/index.php/2020/02/the-latest-coronavirus-cases/ and https://www.worldometers.info/coronavirus/#repro
Files to use
Covid19_Evolution.mw
Covid19_Data.m.zip
Population.xls

Explore data from  https://ourworldindata.org/coronavirus#covid-19-tests
Files to use
Covid19_Evolution_bis.mw
daily-deaths-covid-19-who.xls
total-cases-covid-19-who.xls
Population.xls

I would be interested by any open collaboration with people interested by this post (it's not in my intention to write papers on the subject, my only motivation is scientific curiosity).

## Optimizing Mini Golf in MapleSim

Playing mini-golf recently, I realized that my protractor can only help me so far since it can't calculate the speed of the swing needed.  I decided a more sophisticated tool was needed and modeled a trick-shot in MapleSim.

To start, I laid out the obstacles, the ball and club, the ground, and some additional visualizations in the MapleSim environment.

When running the simulation, my first result wasn't even close to the hole (similar to when I play in real life!).

The model clearly needed to be optimized. I went to the Optimization app in MapleSim (this can be found under Add Apps or Templates  on the left hand side).

Inside the app I clicked "Load System" then selected the parameters I wanted to optimize.

For this case, I'm optimizing 's' (the speed of the club) and 'theta' (the angle of the club). For the Objective Function I added a Relative Translation Sensor to the model and attached a probe to the Vector Norm of the output.

Inside the app, I switched to the Objective Function section.  Selecting Probes, I added the new probe as the Objective Function by giving it a weight of 1.

Scrolling down to "Execute Parameter Optimization", I checked the "Use Global Optimization Toolbox" checkbox, and clicked Run Parameter Optimization.

Following a run time of 120 seconds, the app returns the graph of the objective function.

Below the plot, optimal values for the parameters are given. Plugging these back into the parameter block for the simulation we see that the ball does in fact go into the hole. Success!

Mini_golf_Global_Optimization.msim

## A riddle !

by: Maple 2018

Can you guess what P() produces, without executing it?

```P:=proc(N:=infinity) local q,r,t,k,n,l,h, f;
q,r,t,k,n,l,h := 1,0,1,1,3,3,0:
while h<N do
if 4*q+r-t < n*t
then f:=`if`(++h mod 50=0,"\n",`if`(h mod 10=0," ","")); printf("%d"||f,n);
q,r,t,k,n,l := 10*q,10*(r-n*t),t,k,iquo(10*(3*q+r),t)-10*n,l
else q,r,t,k,n,l := q*k,(2*q+r)*l,t*l,k+1,iquo(q*(7*k+2)+r*l,t*l),l+2
fi
od: NULL
end:
```

I hope you will like it (maybe after execution).

## Feynman Diagrams - the scattering matrix in coordi...

by: Maple

Feynman Diagrams
The scattering matrix in coordinates and momentum representation

 Mathematical methods for particle physics was one of the weak spots in the Physics package. There existed a FeynmanDiagrams command, but its capabilities were too minimal. People working in the ar