Maple 2015 Questions and Posts

These are Posts and Questions associated with the product, Maple 2015

I want to create a matrix (B) from entries of other matrices (A) with a helper-function (helper). The helper function is defined such that it returns a certain matrix depending on the index variables. This is necessary because the inner matrices are constructed with another function.

Since the helper-function returns matrices, the big matrix is of datatype=matrix. Unfortunately, creating the big matrix with the correct size and forcing the datatype=float, does not yield the desired result. However, the manual definition using the constructor with a list of matrices does create the desired matrix.

How do I resolve a matrix of matrices?

Note: I know that I could write a convert function that copies the entries to a corresponding matrix, though this seems to be unnecessary effort to me.

This might not be minimal but shows the issue. (Compare B and test)

MWE_matrix_of_matrices.mw

restart;
with(LinearAlgebra):

size_A := 2;
size_B := 3;

2

 

3

(1)

helper2 := proc(i::integer,j::integer);
  if i=j then
    a;
  elif i=j-1 or i=j+1 then
    b;
  else
    c;
  end if;
end proc:

helper3 := proc(i::integer,j::integer);
  if i=j then
    Matrix(size_A,size_A,helper2);
  elif i=j-1 or i=j+1 then
    -IdentityMatrix(size_A);
  else
    Matrix(size_A);
  end if;
end proc:

A := Matrix(size_A, size_A, helper2);
B := Matrix(size_B, size_B, helper3);
B := Matrix(size_B,size_B, helper3, datatype = float);
B := Matrix(size_B*size_A, size_B*size_A,[Matrix(size_B,size_B,helper3)], datatype = float)

A := Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a})

 

B := Matrix(3, 3, {(1, 1) = Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a}), (1, 2) = Matrix(2, 2, {(1, 1) = -1, (1, 2) = 0, (2, 1) = 0, (2, 2) = -1}), (1, 3) = Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 0, (2, 2) = 0}), (2, 1) = Matrix(2, 2, {(1, 1) = -1, (1, 2) = 0, (2, 1) = 0, (2, 2) = -1}), (2, 2) = Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a}), (2, 3) = Matrix(2, 2, {(1, 1) = -1, (1, 2) = 0, (2, 1) = 0, (2, 2) = -1}), (3, 1) = Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 0, (2, 2) = 0}), (3, 2) = Matrix(2, 2, {(1, 1) = -1, (1, 2) = 0, (2, 1) = 0, (2, 2) = -1}), (3, 3) = Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a})})

 

Error, (in Matrix) unable to store 'Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a})' when datatype=float[8]

 

Error, (in Matrix) unable to store 'Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a})' when datatype=float[8]

 

test := Matrix(4, 4, [
                [Matrix([[1,2],[0,9]]), Matrix([[3,6],[0,9]])],
                [Matrix([[3,4],[7,8]]), Matrix([[7,6],[5,5]])]
               ]); # is converted to a matrix of floats

test := Matrix(4, 4, {(1, 1) = 1, (1, 2) = 2, (1, 3) = 3, (1, 4) = 6, (2, 1) = 0, (2, 2) = 9, (2, 3) = 0, (2, 4) = 9, (3, 1) = 3, (3, 2) = 4, (3, 3) = 7, (3, 4) = 6, (4, 1) = 7, (4, 2) = 8, (4, 3) = 5, (4, 4) = 5})

(2)


rather than last time saved file result?

When I open maple script file, it display the result which file created.

however, not the latest result 

it need to move cursor to the end of script and press enter again.

hi

how i can solve nonlinear differential equations with shooting method in maple?ω in equation is unknown...

thanks

eq.mw

dsys3 := {-0.326905829596411e-2*g(x)-(diff(g(x), x, x))-(diff(s(x), x))*(diff(s(x), x, x))-(4/3)*omega^2*g(x), -s(x)*omega^2-(-0.573628192993074e-1*sin(0.571756792348295e-1*x)-0.163452914798206e-2*cos(0.571756792348295e-1*x))*(diff(s(x), x))-(1.00327307112014*cos(0.571756792348295e-1*x)-0.285878396174148e-1*sin(0.571756792348295e-1*x)-1)*(diff(s(x), x, x))+0.220893539279189e-4*(diff(s(x), x, x, x, x))-(9/8)*(diff(s(x), x, x))*(diff(s(x), x))^2-(3/4)*(diff(s(x), x, x))*(diff(g(x), x))-(3/4)*(diff(s(x), x))*(diff(g(x), x, x)), (D(g))(1)+(1/2)*(D(s))(1)^2 = 0, g(0) = 0, s(0) = 0, (D(s))(0) = 0, ((D@@2)(s))(1) = 0, ((D@@3)(s))(1) = 0}

{-0.326905829596411e-2*g(x)-(diff(diff(g(x), x), x))-(diff(s(x), x))*(diff(diff(s(x), x), x))-(4/3)*omega^2*g(x), -s(x)*omega^2-(-0.573628192993074e-1*sin(0.571756792348295e-1*x)-0.163452914798206e-2*cos(0.571756792348295e-1*x))*(diff(s(x), x))-(1.00327307112014*cos(0.571756792348295e-1*x)-0.285878396174148e-1*sin(0.571756792348295e-1*x)-1)*(diff(diff(s(x), x), x))+0.220893539279189e-4*(diff(diff(diff(diff(s(x), x), x), x), x))-(9/8)*(diff(diff(s(x), x), x))*(diff(s(x), x))^2-(3/4)*(diff(diff(s(x), x), x))*(diff(g(x), x))-(3/4)*(diff(s(x), x))*(diff(diff(g(x), x), x)), (D(g))(1)+(1/2)*(D(s))(1)^2 = 0, g(0) = 0, s(0) = 0, (D(s))(0) = 0, ((D@@2)(s))(1) = 0, ((D@@3)(s))(1) = 0}

(1)

``

 

Download eq.mw

hi.how i can determind  eignvalue of matrix in the form parametric?

thanks1.mw

T := Matrix(5, 5, {(1, 1) = -b*beta*k/(c*u)-d, (1, 2) = 0, (1, 3) = -beta*lambda*c*u/(b*beta*k+c*d*u), (1, 4) = 0, (1, 5) = 0, (2, 1) = b*beta*k/(c*u), (2, 2) = -s*(lambda*c*k*beta/(b*beta*k+c*d*u)-a)/P-a, (2, 3) = beta*lambda*c*u/(b*beta*k+c*d*u), (2, 4) = -s*b/c, (2, 5) = r*(s-p)/s, (3, 1) = 0, (3, 2) = k, (3, 3) = -u, (3, 4) = 0, (3, 5) = 0, (4, 1) = 0, (4, 2) = -s*(lambda*c*k*beta/(b*beta*k+c*d*u)-a)/P, (4, 3) = 0, (4, 4) = -s*b/c-b, (4, 5) = r*(s+c)/s, (5, 1) = 0, (5, 2) = s*(lambda*c*k*beta/(b*beta*k+c*d*u)-a)/P, (5, 3) = 0, (5, 4) = s*b/c, (5, 5) = -r})

Matrix(5, 5, {(1, 1) = -b*beta*k/(c*u)-d, (1, 2) = 0, (1, 3) = -beta*lambda*c*u/(b*beta*k+c*d*u), (1, 4) = 0, (1, 5) = 0, (2, 1) = b*beta*k/(c*u), (2, 2) = -s*(lambda*c*k*beta/(b*beta*k+c*d*u)-a)/P-a, (2, 3) = beta*lambda*c*u/(b*beta*k+c*d*u), (2, 4) = -s*b/c, (2, 5) = r*(s-p)/s, (3, 1) = 0, (3, 2) = k, (3, 3) = -u, (3, 4) = 0, (3, 5) = 0, (4, 1) = 0, (4, 2) = -s*(lambda*c*k*beta/(b*beta*k+c*d*u)-a)/P, (4, 3) = 0, (4, 4) = -s*b/c-b, (4, 5) = r*(s+c)/s, (5, 1) = 0, (5, 2) = s*(lambda*c*k*beta/(b*beta*k+c*d*u)-a)/P, (5, 3) = 0, (5, 4) = s*b/c, (5, 5) = -r})

(1)

``

 

Download 1.mw

 

I defined a procedure, OrderB(0,b,c), that essentially determines the order of a group that is defined by 2 parameters (the first parameter is always zero), so the output is an integer and the procedure is defined for every integer value of both parameters. I wanted to structure the outputs into a matrix with columns that represent one parameter and rows that represent the other. However, whenever I try to apply a method of defining the matrix, Maple returns the values of the procedure and then gives me an empty matrix.

>f:=proc (i, j) -> OrderB(0, i, j+3);
>Matrix(3, f);
                               1
                               4
                               1
                               1
                               4
                               1
                               1
                               4
                               1
               [NULL,NULL...]


I tried a second method where I defined a set s such that:

s:={(0,0)=OrderB(0,0,0) , (0,1)=OrderB(0,0,1).....}

but upon execution, maple returns:

1
4
1
....
s:={(0,0)=( ), (0,1)=( )...}

Please Help. I don't know what I'm mising in the code that is keeping Maple from putting the outputs of my procedure into the matrix.

Been working on a diffy q project, new to maple here. Any help is appreciated. Keep getting a similar error.

 

"Error, (in dsolve/numeric/type_check) insufficient initial/boundary value information for procedure defined problem"

I thought I gave it initial values?

link to screenshot of the error bellow:

http://i.imgur.com/YVE1x7e.jpg

how to convert system of differential equations to differential form for evalDG?

 

[a(t)*(diff(c(t), t))+b(t), a(t)*(diff(b(t), t))+c(t)*(diff(b(t), t)), a(t)*(diff(c(t), t))+a(t)*(diff(b(t), t))+b(t)];

when i try eliminate dt which is the denominator

eliminate([a(t)*dc(t) + b(t)*dt,a(t)*db(t)+dt*c(t)*db(t),a(t)*dc(t)+a(t)*db(t)+b(t)*dt],dt);

[{dt = -a(t)/c(t)}, {a(t)*(c(t)*dc(t)-b(t)), a(t)*(db(t)*c(t)+c(t)*dc(t)-b(t))}]

 

i got two solutions, which one is correct?

a(t)*(c(t)*dc(t)-b(t)), a(t)*(db(t)*c(t)+c(t)*dc(t)-b(t))

does it mean that two have to use together to form a differential form?

 

update1

with(DifferentialGeometry):
DGsetup([a,b,c], M);
X := evalDG({a*(c*D_c-b), a*(D_b*c+c*D_c-b(t))});
Flow(X,t);
Flow(X, t, ode = true);

got error when run with above result

 

This is the first of three blog posts about working with data sets in Maple.

In 2013, I wrote a library for Maple that used the HTTP package to access the Quandl data API and import data sets into Maple. I was motivated by the fact that, when I was downloading data, I often used multiple data sources, manually updated data when updates were available, and cleaned or manipulated the data into a standardized form (which left me spending too much time on the data acquisition step).

Simply put, I needed a source for data that would provide me with a searchable, stable data API, which would also return data in a form that did not require too much post-processing.

My initial library had really just scratched the surface of what was possible.

Maple 2015 introduced the new DataSets package, which fully integrated a data set search into core library routines and made its functionality more discoverable through availability in Maple’s search bar.

Accessing online data suddenly became much easier. From within Maple, I could now search through over 12 million time series data sets provided by Quandl, and then automatically import the data into a format that I could readily work with.

If you’re not already aware of this online service, Quandl is an online data aggregator that delivers a wide variety of high quality financial and economic data. This includes the latest data on stocks and commodities, exchange rates, and macroeconomic indicators such as population, inflation, unemployment, and so on. Quandl collects both open and proprietary data sets from many sources, such as the US Federal Reserve System, OECD, Eurostat, The World Bank, and Open Data for Africa. Best of all, Quandl's powerful API is free to use.

One of the first examples for the DataSets package that I constructed was in part based on the inspirational work of Hans Rosling. I was drawn in by his ability to use statistical visualizations to break down complex multidimensional data sets and provide insight into underlying patterns; a key example investigating the correlation between rising incomes and life expectancy.

As well as online data, the DataSets package had a database for country data. Hence it seemed fitting to add an example that explored macroeconomic indicators for several countries. Accordingly, I set out to create an example that visualized variables such as Gross Domestic Product, Life Expectancy, and Population for a collection of countries.

I’ll now describe how I constructed this application.

The three key variables are Gross Domestic Product at Power Purchasing Parity, Life Expectancy, and Population. Having browsed through Quandl’s website for available data sets, the World Bank and Open Data for Africa projects seemingly had the most available relevant data; therefore I chose these as my data sources.

Pulling data for a single country from one of these sources was pretty straight forward. For example, the DataSets Reference for the Open Data for Africa data set on GDP at PPP for Canada is:

DataSets:-Reference("quandl", "ODA/CAN_PPPPC"));

In this command, the second argument is the Quandl data set code. If you are on Quandl’s website, this is listed near the top of the data set page as well as in the last few characters of the web address itself: https://www.quandl.com/data/ODA/CAN_PPPPC . Deconstructing the code, “ODA” stands for Open Data for Africa and the rest of the string is constructed from the three letter country code for Canada, “CAN”, and the code for the GDP and PPP. Looking at a small sample of other data set codes, I theorized that both of the data sources used a standardized data set name that included the ISO-3166 3-letter country code for available data sets. Based on this theory, I created a simple script to query for available data and discovered that there was data available for many countries using this standardized code. However, not every country had available data, so I needed to filter my list somewhat in order to pick only those countries for which information was available.

The script that I had constructed required three letter country codes. In order to test all available countries, I created a table to house the country names and three-letter country codes using data from the built-in database for countries:

ccdata := DataSets:-Builtin:-Reference("country")[.., "3 Letter Country Code"];
cctable := table([seq(op(GetElementNames(ccdata[i])) = ccdata[i, "3 Letter Country Code"], 
i = 1 .. CountRows(ccdata))]):

My script filtered this table, returning a subset of the original table, something like:

Countries := table( [“Canada” = “CAN”, “Sweden” = “SWE”, … ] );

You can see the filtered country list in the code edit region of the application below.

With this shorter list of countries, I was now ready to download some data. I created three vectors to hold the data sets by mapping in the DataSets Reference onto the “standardized” data set names that I pulled from Quandl. Here’s the first vector for the data on GDP at PPP.

V1 := Vector( [ (x) -> Reference("quandl", cat("ODA/", x, "_PPPPC"))
                   ~([entries(Countries, nolist, indexorder)])]):
#Open Data for Africa GDP at PPP

Having created three data vectors consisting of 180 x 3 = 540 data sets, I was finally ready to visualize the large set of data that I had amassed.

In Maple’s Statistics package, BubblePlots can use the horizontal axis, vertical axis and the relative bubble size to illustrate multidimensional information. Moreover, if incoming data is stored as a TimeSeries object, BubblePlots can generate animations over a common period of time.

Putting all of this together generated the following animation for 180 available countries.

This example will be included with the next version of Maple, but for now, you can download a copy here:DataSetsBubblePlot.mw

*Note: if you try this application at home, it will download 540 data sets. This operation plus the additional BubblePlot construction can take some time, so if you just want to see the finished product, you can simply interact with the animation in the Maple worksheet using the animation toolbar.

A more advanced example that uses multiple threads for data download can be seen at the bottom of the following page: https://www.maplesoft.com/products/maple/new_features/maple19/datasets_maple2015.pdf You can also interact with this example in Maple by searching for: ?updates,Maple2015,DataSets

In my next post, I’ll discuss how I used programmatic content generation to construct an interactive application for data retrieval.

I am using a stoiciometric matrix to generate a system of differential equations (this makes them easier to check). There are 13 chemical species and 16 reactions so I need to make and display vectors of length 13 and 16; as well as a 13x16 matrix.

When I make Vectors of this size they don't get displayed; I just get information about the vector (Fortran order etc) and this is the same for the matrix.

How do i make/edit/display Matrixes nd Vectors of this size?

Hi,

I am trying to calculate the commutator $[v,w]:=vw-wv$.

For the sake of simplicity lets say

$$v=\dfrac{\partial}{\partial x}$$
and

$$w=x\dfrac{\partial}{\partial t}$$

I know how to calculate the commutator by hand, but I would like to learn how I can do these kind of calculations with maple.

**In this example the calculations by hand look like:**

$$[v,w]=\dfrac{\partial}{\partial x}\left( x\dfrac{\partial}{\partial t}\right)-x\dfrac{\partial}{\partial t}\dfrac{\partial}{\partial x}$$
$$=\dfrac{\partial}{\partial t}+x\dfrac{\partial^2}{\partial x \partial t}-x\dfrac{\partial^2}{\partial t \partial x}=\dfrac{\partial}{\partial t}$$

How can I "teach" maple to do this?

 

L(1):=[1,2,3]:

L(2):=[A,B,C]:

sum(nops(L(i)),i=1..2):

 

The real result of the sum is : 6.

Maple's result is : 2.

Yes, Maple gives an error.
But it doesn't matter, Maple is the most extraordinary software of the world !!!

Is it possible to subscript within a plot?

for example I have

this in principle is what I want but, the N is cursive while is O is not (and it's a bit shifted to the right, not right next to the [2] !???

Also I didnt find the meanings of mi(),mn(),mo(),mfenced()... in the help documentation which I stumbled across while googling.

for example in this case:

 

what do I need them for since without the mi it doesnt work?!

Is it possible to use latex notation within the plot options for more convenience?

BTW: When plotting a .ps or .eps the plotting device takes over all the features (like the examples above) but when using png instead it just prints the code behind it ( for example the `#mover(mi("x"),mi("~"))` ) and not would it should lead to

hi.i am a problem for solving this non linear algebric equation.

please help me...thanks

FSOLVE.mw

FSOLVE.mw

 


----------------------------------------------------------------------------------------------------------------------
Introduction

I have a matrix (named DC on the piece of code below) all the elements of which are complex numbers a+b*I with a and b floating point numbers.
I want to obtain the real part of DC.

Obviously, if you do something like :
DC := Matrix(2,2, [1.0+1.0*I, 1.0-1.0*I, -1.0+1.0*I, -1.0-1.0*I];
Re~(DC);

the result corresponds to the desired matrix

----------------------------------------------------------------------------------------------------------------------
Context

In fact this matrix DC comes from some computations  described in the piece of code below

# Purpose :
# Given N points in a plane (here  in [0,1]X[0,1]), compute the matrix DX of distances between these points
#
# Example : if Pi and Pj are two such points, DX[i,j]=DX[j,i] denotes the Euclidian distance between Pi and Pj
#
# As I did not be able to find any single function in MAPLE that would construct DX , I proceed that way :
#   1/ let X the (N,2) matrix that contains the coordinates of the N points
#   2/ I represent these  N points as N complex numbers (vector C)
#   3/ I construct the (N,N) matrix MC = <C | C …..| C>
#   4/ I put MC = C – Transpose(C) :
#   5/ I take the norm DX of each elements of DC : DX := abs~(DC)
#       At this point, DX should contain the desired distances
#       But, due to floating point arithmetics, each element of DX writes a+0.*I where a is some floating point number)
#   6/ Last stage : execute Re~(DX)
#

with(Statistics):
with(LinearAlgebra):

N := 4:
X := Matrix(N,2, convert(Sample(Uniform(0,1), 2*N), list)):  #just an example

C   := X[..,1] +~ X[..,2] *~I;
MC := Multiply(C, Vector[row](N, 1));
DC := MC - Transpose(MC);
DX := abs~(DC);
Re~(DX)


----------------------------------------------------------------------------------------------------------------------
 My observations : 

1/ Maple 2015, Windows XP, 64 bytes
Re~(DX) returns DX and does not remove the imaginary (0.*I) part
But  Matrix(N, N, Re~(convert(DC, list))) does (which is a satisfactory, even if not clever, stopgap)

Why (it is just a question to help me to understand correctly how MAPLE proceeds) Re~(DC) does not (seem) to work here ?


2/ Maple 2015.2, Mac OS X El Capitan
DX := abs~(DC) gives me this strange result :
If (for instance) DC[i, j] = -1 – 2*I, DX[i, j] = +1 + 2*I
According to the compatibility problems between Maple 2015.1 and “El Capitan” (fixed from February), could it remain a few other problems ?

Last but not lesat : Did I do any syntax error ?


 I look forward to your responses

I read in the net that the method used in pdsolve numeric is the theta method, my question: is it the most efficient with regard to rate of convergence of the numerical solution of the PDE?

If not then why is it used as the default method?

 

Thanks.

 

First 44 45 46 47 48 49 50 Last Page 46 of 71