mmcdara

5284 Reputation

17 Badges

7 years, 120 days

MaplePrimes Activity


These are replies submitted by mmcdara

@acer 

Thank you for your answer.

Here is the result obtained with Maple 2015.2
Maple2015.mw
Thereare no problem ar all

I know how the key option works and this was not the subject of my question.
My question was about content which, I thought, was a kind of "option" of sort.

Finally I found out myself what content does.

@dharr @acer

Thank you both.
Your answer made me realize that I had a complete wrong conception of what addressof returns.
I thought it was the address of an "object" (here the element V[2]) as it is in fact the address of the value of this element (@dharr : do I understand correctly tour reply?).

@acer 

I guess the key content exists only in "recent" versions os Maple? 
What does it do?

@kambiz1199 

There are probably a lot of other ways to do this.
The procedure sort accepts any sorting function, for instance

L := [x, x/2, x/3];
sort(L, key=(z -> -denom(z)));
            [(1/3)*x, (1/2)*x, x]

Or this one

L := [x, x/2, 2*x, x/3]:
sort(L, key=(z -> coeff(z, x)))
                       [1    1          ]
                       [- x, - x, x, 2 x]
                       [3    2          ]

@acer 

Hi, 

By the way, I incidentaly saw that  the adresses of the elements of a vector (for instance) are identical when all the elements of this vector are equal. 

V := Vector[row](3, symbol=s); 
addressof(V[1]);
addressof(V[2]);
addressof(V[3]);
                      18446744078250275630
                      18446744078250275654
                      18446744078250275678
V := Vector[row](3, 1); 
addressof(V[1]);
addressof(V[2]);
addressof(V[3]);
                      18446744073709551617
                      18446744073709551617
                      18446744073709551617

I would have thought that each element has a different address.
Can you explain to me what is going on here (I can open a new thread if you think it's more appropriate) ?

@dharr 

Ok, sorry for the misunderstanding

@MaPal93 

No, you open the file, remove the # charracter at the begining of the last line and execute the whole by clicking on the !!! icon of the menu bar.
Once these last solve command end, the next instruction (save) will save MySolution in the m-file.
If the fullpath of the file (wich is the concatenation of currentdir() and "/SOLUTION_complex.mw") doesn't suit you, change it.

SO, DO NOT INTERRUPT THE SOLVING PROCESS OR YOU WILL GET AGAIN THE WARNING YOU GOT

"However, I still read sqrt(Sigma__0jk) and sqrt(Sigma__0ki) as params (in addition to Sigma__0jk and Sigma__0ki, as expected). Why?"

I don't know, check the code and change the names it contains but the names you want.
Somewhere there those two lines

nu__jk := RandomVariable(Normal(q__0jk, sqrt(Sigma__0jk))):
nu__ki := RandomVariable(Normal(q__0ki, sqrt(Sigma__0ki))):

Change them.
I suppose you can do that by yourself?

@Muhammad_Qozeem  Here-----------------------------------------------------v

@MaPal93 

"Why your equations are like these (i.e., set of expressions implicitly equaled to 0):"

For a very simple reason: at the begining of our exchanges I delivered you thow worksheets, one for the simple case, the other for the complex one. In both of them (the second being for a large part a copy-paste of the first one)  I had replaced yuour syntsax of the form 

solve({eval(eqmujk, %[]), eval(eqljk1, %[]), ...}, {………})

by

solve({eqmujk, eqljk1, ...}, {………})

.

After that you defined the correct equations this way:

solve({eqmujk=mu__jk, eqljk1=lambda__jk1, ...}, {………})

We used so many files since the beginning if your first question that I mistakenly used my initial "complex case file" to start from.

I've seen you changed MyEqs by the correct definition in your last: well done;
Even with MyEqs instanciated with data_1 the computational time remains (IMO)  unberable (17 minutes).
If you give Sigma and sigma numerical values (floating point values, NOT INTEGER NOR RATIONAL values) the solution will be obtained more quickly, but you will lost the formal characterization of the solution.

Could you please remove the # character at the beginning of the last line, execute it, and send me the file SOLUTION_complex.m with the extension changed to pdf ?

"You also wrote: "Try and analyze the system to see if you can solve one subsystem, then the other, and insert the solution into the first's)." How to do this systematically?"
There is no systematic way to do that, only ad hoc ways.
Here are a few hints (look the lines after SUPPLEMENTARY MATERIAL)
250323_complex.mw

First thing to is to load your worksheet using the big green arrow.

@MaPal93 

Why did I proposed you to use a "m file" which contains the solution ?
On my computer it takes between 5 and 10 minutes for MySolution to be constructed. So I found interesting to save it into a m file in order to be able to use it in a simple way for future computations.

I guess this worksheet will help you understand this (in my case this worksheet is in the same directory than the m file, thus the path cat(currentdir(), "/MySolution.m" in the read statement don(t forget to adjust this to your own situation).

restart:

# Right now there are no user variables aleready defined:

anames(user)

read cat(currentdir(), "/SOLUTION.m")

# What are the user variables now?

anames(user)

MySolution

(1)

# You see that the new user variable MySolution appears: it has been
# "created" by the read statement.
# If you look to the last worksheet I sent you there is this line
#     save MySolution, fic;
# This command has saved the variable MySolution (and its content)
# into file "fic".
# When you read this same file read assigns the variable MySolution 
# with  its content.
#
# You can visualize MySolution (a lengthy output) or display the names
# it contains.
# Firstly check the type of MySolution (here it is exprseeq, which means
# MySolution is of the form  MySolution := A, B, ...

whattype(MySolution);

# Here are the indets of MySolution:

indets([MySolution], name);
 

exprseq

 

{mu__jk, mu__ki, q__0jk, q__0ki, Sigma__0jk, Sigma__0ki, lambda__jk, lambda__ki, rho__XX__23, sigma__ujk, sigma__uki}

(2)

# For convenience convert MySolution into a list, then
# replace rho__XX__23 by rho__nu

MySolution := eval(MySolution, rho__XX__23=rho__nu):
indets([MySolution], name);

{mu__jk, mu__ki, q__0jk, q__0ki, rho__nu, Sigma__0jk, Sigma__0ki, lambda__jk, lambda__ki, sigma__ujk, sigma__uki}

(3)

# Here is an example of calibration data

data_1 := [
  Sigma__0jk  = Sigma,
  Sigma__0ki  = Sigma,
  sigma__uji  = sigma,
  sigma__ujk  = sigma,
  sigma__uki  = sigma,
  rho__nu     = 0,
  q__0jk      = 0,
  q__0ki      = 0
]:
  
 

# And the solution is...

CAL_1 := eval(MySolution, data_1):
simplify(allvalues~([CAL_1]), size);

[{mu__jk = 0, mu__ki = 0, lambda__jk = 8^(1/2)*(Sigma/sigma^2)^(1/2)*(9*Sigma+8)/(48*Sigma-128), lambda__ki = (1/8)*8^(1/2)*(Sigma/sigma^2)^(1/2)}, {mu__jk = 0, mu__ki = 0, lambda__jk = (-9*Sigma-8)*8^(1/2)*(Sigma/sigma^2)^(1/2)/(48*Sigma-128), lambda__ki = -(1/8)*8^(1/2)*(Sigma/sigma^2)^(1/2)}, {mu__jk = mu__ki, mu__ki = mu__ki, lambda__jk = (1/8)*Sigma*8^(1/2)/((Sigma/sigma^2)^(1/2)*sigma^2), lambda__ki = (1/8)*8^(1/2)*(Sigma/sigma^2)^(1/2)}, {mu__jk = mu__ki, mu__ki = mu__ki, lambda__jk = -(1/8)*Sigma*8^(1/2)/((Sigma/sigma^2)^(1/2)*sigma^2), lambda__ki = -(1/8)*8^(1/2)*(Sigma/sigma^2)^(1/2)}]

(4)

combine~(%, radical) assuming sigma::positive:

[{mu__jk = 0, mu__ki = 0, lambda__jk = 2*(9*Sigma+8)*2^(1/2)*Sigma^(1/2)/((48*Sigma-128)*sigma), lambda__ki = (1/4)*2^(1/2)*Sigma^(1/2)/sigma}, {mu__jk = 0, mu__ki = 0, lambda__jk = 2*(-9*Sigma-8)*2^(1/2)*Sigma^(1/2)/((48*Sigma-128)*sigma), lambda__ki = -(1/4)*2^(1/2)*Sigma^(1/2)/sigma}, {mu__jk = mu__ki, mu__ki = mu__ki, lambda__jk = (1/4)*2^(1/2)*Sigma^(1/2)/sigma, lambda__ki = (1/4)*2^(1/2)*Sigma^(1/2)/sigma}, {mu__jk = mu__ki, mu__ki = mu__ki, lambda__jk = -(1/4)*2^(1/2)*Sigma^(1/2)/sigma, lambda__ki = -(1/4)*2^(1/2)*Sigma^(1/2)/sigma}]

(5)

 

Download How_to_use_the_already_buit_solution.mw

This should answer your first question.
About your "complex" case: here is the file with the corrected syntax errors.
The solving process of the last 8 by 8 system has been stopped after 18 minutes having given no solution.
Maybe you have a more powerful computer than mine?
Try and let me know.

If you fail to get a solution, you have two options:

  1. Try and analyze the system to see if there is a better solving strategy (for example, solve one subsystem, then the other, and insert the solution into the first's).
    But the result is not guaranted and this task can prove very difficult to handle.
  2. Instanciate MyEqs with som calibration data BEFORE attempting to solve the.

250323_complex.mw

@MaPal93 

When I told you to write 

read "/..../SOLUTION_copie.m"

"/.../SOLUTION_copie.m" was a shortcut for "the full path of SOLUTION_copie.m".
For instance  "/Users/mmcdara/Desktop/SOLUTION_copie.m"

@MaPal93 

Sure, see you tomorrow.
Have a good night.

Meanwhile I did a bit of extra work:

  • here is a worksheet with 4 different calibration data, 
  • and a file named SOLUTION_copie.pdf which is in fact a "m file" (a binary MAPLE file, that Mapleprimes doesn't allow to load, thus the change of its extension to "pdf") which contains MySolution defined by
MySolution := solve(MyEqs, MyVars):

To use it this m file:

  • load the file in some folder,
  • change its extension to "m",
  • in the worksheet, replace the line of code above by this piece of code and execute it
    Already_Computed := true:
    if Already_Computed then
      read "/..../SOLUTION_copie.m"
    else
      MySolution := solve(MyEqs, MyVars):
    end if:

    Now MySolution is known in your worksheet and you can use it as you want.

  • Oh, last thing, comment the line 

    save MySolution, fic;

240323_simple_calibration.mw
SOLUTION_copie.pdf

First 11 12 13 14 15 16 17 Last Page 13 of 113