Mac Dude

1571 Reputation

17 Badges

13 years, 108 days

MaplePrimes Activity


These are questions asked by Mac Dude

I have a Matrix of data points I am plotting using plots:-listdensityplot. That works fine.

However, the axes are labeled by row and column number of the Matrix (e.g. 1..20 or whatever). In reality, these are of course some parameters the range of which has been mapped onto the rows and columns of the Matrix.

How can I display the axes using the values of the original parameters? I know the transformation from Matrix row or column to the actual parameters (and in this case it is linear).

TIA,

Mac Dude

 

I have a Maple program that fits a nonlinear function with 9 parameters to a dataset that contains multiple records; each record gets fitted separately. The records are ordered by a certain experimental variable (an angle of a target). The initial parameters for each fit are the solutions of the previous fit; in this case I get relatively good initial estimates and not too much trouble fitting. I use Statistics:-NonLinearFit to do the actual fitting.

Since this is a bit time consuming and I need to do this a fair amount of times, I'd like to see if I can't speed his up by employing parallel programming.

One way to speed up a fit is to compute the sum of residuals in parallel; is there a way to do this in Maple?

Another way would be to run several fits at the same time. The problem I have with that in this case is that I use the results of the previous fit as starting values for the next fit. I might be able to increase the stride of this scheme; i.e. for 4 processes, use the result of fit 1 as starting point for fit 5; fit 2 for fit 6 etc. But before I embark on this non-trivial change; can Statistics:-NonLinearFit even be used in this way (i.e. is it thread safe)?? My fitting function is an actual function (as opposed to a procedure with local variables) so I don't think the function itself would cause trouble.

I could also contemplate the Grid package; except that I am concerned about the overhead moving the data over to each node (although it would all sit on one machine with 4 processors).

I realize that I may have to do some experimentation by myself, but if there is any experience out there I'd like to know about it...

Mac Dude

In order to make worksheets more interactive in a teaching environment I have begun playing around with the Tables the standard GUI provides. The idea is that in the left column is the script we are working through while in the right column is space a student can work with the equations and formulae from the left side to, e.g., plot, change parameters etc. without affecting the script too much.

To build the tables I copy-pasted code from a normal worksheet (in document mode) into the left column, creating rows of appropriate length to have a logically coherent section in one row. Usually one row is one Section (in the technical sense of Maple Sections). The student gets to play in the right column.

In principle this seems to work quite well in my preliminary testing. I did find out rather quickly that on the right side one needs to be in 1-d input mode with a prompt for anything to be calculated interactively. Ok, actually probably easier to do. The table is set to evaluate by row so the right-left correspondence is preserved.

A potential issue I am facing however is with equation numbering: I use equation numbers extensively to reference back to upstream results. In the Table, it appears that equation numbers are not unique; in each row of the Table, eq. numbers start as (1.1), (1.2) etc. I am able to reference back to results from a prior row, even though the same equation number will show up again later in the new row. But I am concerned that eventually this all ends up in a big mess and my references point to the wrong expression or equation. Non-unique line numbers seem like a Really Bad Idea, and I'd like to avoid that if possible.

Does anyone know how the lines numbers work for code in Tables and how I make sure they are unique? I suppose I could explicitly assign results I need in other rows to names, but that does not prevent a reference to an eq. number from pulling in the wrong one from a prior row (assuming for the moment that Maple will never look forward to resolve a reference).

Thanks,

Mac Dude

I am having an issue with Physics[Vectors] in Maple 17, specifically an interference with PDEtools:-dchange. My apologies, this post is lengthy & a bit messy. I did upload a worksheet with the code; link at the end. The upload exhibits the UNWANTED behaviour in Maple 17.

Here are a few lines of code that exhibit the WANTED behaviour (change of variable and solving a de). it is run in Maple17 with Physics loaded but NOT Physics[Vectors]. The paste into Mapleprimes looks too messy to be useful so I am just showing the relevant lines; the file has everything:

-(diff(E1_(x, y, z, t), x, x))-(diff(E1_(x, y, z, t), y, y))-(diff(E1_(x, y, z, t), z, z)) = -mu*epsilon*(diff(E1_(x, y, z, t), t, t));

PDEtools:-dchange({x = r*cos(theta), z = r*sin(theta)}, -(diff(diff(E1_(x, y, z, t), x), x))-(diff(diff(E1_(x, y, z, t), y), y))-(diff(diff(E1_(x, y, z, t), z), z)) = -mu*epsilon*(diff(diff(E1_(x, y, z, t), t), t)), simplify);

subs(E1_(r, theta, y, t) = R(r)*exp(I*(-k*y+omega*t)), -((diff(diff(E1_(r, theta, y, t), y), y))*r^2+(diff(diff(E1_(r, theta, y, t), r), r))*r^2+(diff(E1_(r, theta, y, t), r))*r+diff(diff(E1_(r, theta, y, t), theta), theta))/r^2 = -mu*epsilon*(diff(diff(E1_(r, theta, y, t), t), t)));

dsolve((5));

So far this is all as expected.

Now I rerun this thing with Physics[Vectors] loaded rather than just Physics. Everything looks the same until I get to the line starting with subs(E1_ :

subs(E1_(r, theta, y, t) = R(r)*exp(I*(-k*y+omega*t)), -((diff(diff(E1_(r, theta, y, t), y), y))*r^2+(diff(diff(E1_(r, theta, y, t), r), r))*r^2+(diff(E1_(r, theta, y, t), r))*r+diff(diff(E1_(r, theta, y, t), theta), theta))/r^2 = -mu*epsilon*(diff(diff(E1_(r, theta, y, t), t), t)));

plus many more lines of expressions. I am not sure what is going wrong; but after the dchange the code behaves funky: I have had simplify producing similarly weird expressions etc.

Note that on Maple 15 this all works as expected and no issues show up for me. If the version of Physics I have on Maple 17.02 is bad; how do I change that? (I have not tried to update Physics separately, and it isn't obvious to me where to find it for Maple 17). It is sort-of an issue as I want to use this as a demo for students, who in fact will be running Maple 18... but I am stuck at 17 (and often using 15 at home) so I need this to work there (17), too.

TIA,

Mac Dude

dchangeTest.mw

 

Sometimes Maple can be endlessly frustrating!!

A recent question of mine on how to distribute integrals into a sum was answered:

http://www.mapleprimes.com/questions/201500-Integral-Of-A-Sum--Sum-Of-Integrals-In-Maple

Now I need the same thing, except (as part of a solution) Maple chose to use Intat rather than Int.

So I modify the rule I have to look like this:

ToSumInt:=Intat(A::algebraic*Sum(v::algebraic,r::{name,equation})*B::algebraic,u::{name,equation})=Sum(Intat(A*v*B,u),r);

.. and for the heck of it I cannot get Maple to accept this, no matter what type I make u to be. The error message always looks the same:

Error, invalid input: Intat expects its 2nd argument, dx_at_t, to be of type symbol = algebraic, but received u::{name, equation}

and you may replace the u::{name,equation} with any other u::type you care to think of.

Any help would be appreciated.

M.D.

Edit: Also, useInt will not replace the Intat (in the expression I want to apply the rule to) with Int.

First 10 11 12 13 14 15 16 Last Page 12 of 23