Harry Garst

279 Reputation

6 Badges

19 years, 331 days

MaplePrimes Activity


These are replies submitted by Harry Garst

@Kitonum 

 

Thanks a lot! This is a very interesting solution.

kind regards,

Harry Garst

as I said I looking for a combination of factored polynomials. What I have done so far is to factor subsets of the polynomial. That strategy worked for smaller problems (see attached maple file), but now I would like to find out the most efficient strategy. I guess that this is also a well-known problem for mathematicians (I myself am a psychologist).

yes, indeed. Both replies are extremely helpful. (Although there are good reasons for trying a matrix solution: the expression is an element from a matrix inversion).

 

Thanks a lot.

Harry Garst

@Harry Garst 

 

When I square the denominator in your example both subs and algsubs give the intended result.

subs_versus_algsubs2.mw

@Kitonum 

replacing the first algsubs with subs gives the intended result:

Expr1 := a/(a+b+c);

subs(a+b+c = d, Expr1);

Expr2 := b/(a+b+c);

algsubs(a+b+c = d, Expr2);

Expr3 := c/(a+b+c);

algsubs(a+b+c = d, Expr3);
                                    a    
                       Expr1 := ---------
                                a + b + c
                               a
                               -
                               d
                                    b    
                       Expr2 := ---------
                                a + b + c
                               b
                               -
                               d
                                    c    
                       Expr3 := ---------
                                a + b + c
                               c
                               -
                               d
 

@Kitonum 

 

Thanks al lot!

My only reason for substitutions is to make seemingly complex matrix results so simple that I can understand its structure. Unfortunately, at this moment I am unable to accomplish this in Maple. 

Paradoxically, the 'simplify' command makes things more complicated by expanding all terms out.

the first and the second example are completely the same (except for the indices [1,1] versus [2,1].

I made a new maple file. The second example is a copied version of the first example, but the indices are changed. The output differs.

mapleprimes2.mw

@Preben Alsholm 

Thanks for diving in this issue.

Now it is time for the maple software engineer who wrote the 'forget' function (error message: Error, (in forget) lexically scoped parameter out of context). Strange name for a function. 

best regards,

Harry Garst

error_message.mw

no_error_message.mw 

 

sorry, I hoped it was something obvious I missed from my part.

In the meantime, I switched to the Optimization package, where I did not encounter any problems.

but, I still am curious why that error occurred.

kind regards,

Harry Garst

@Preben Alsholm 

 

Thanks! You are right!

kind regards,

Harrry

Thanks a lot!

I was trying to figure out what the pattern is, but this code is really beautiful.

kind regards,

Harry Garst

@Preben Alsholm 

 

Thanks for your reply. 

Ten years ago I wrote some code to  deals with the weird scientific notation used in the to be imported textfile (D used instead of E). However, now I see that Maple has no problems parsing the data and the following code works.

restart; with(LinearAlgebra); with(FileTools);with(plots);
file1 := "C:/path/ULSlx3.txt";
Lambda := Matrix(5, 1);
for row to RowDimension(Lambda) do
Lambda[row, 1] := Text[ReadNextFloat](file1)
end do;
Lambda;

So I don't need the old code no more.

old code:

Lambdaread:=proc(Lambda::Matrix,B)

local i,j,r,H,v,temp,c,k;
H:=ImportMatrix(B, delimiter="", datatype=string):
v := Vector(0);
ColumnDimension(H); RowDimension(H);
for i to RowDimension(H) do
H[i, 1] := StringTools[SubstituteAll](H[i, 1], "D", "E");
H[i, 1] := StringTools[SubstituteAll](H[i, 1], "+", "");
temp := sscanf(H[i, 1], "%f %f %f %f %f %f");
convert(temp, Vector);
v := Vector([v, temp]) end do;
eval(v); Dimension(v);
r := RowDimension(Lambda); c := ColumnDimension(Lambda); k := 0;
for i to r do for j to c do k := k+1; Lambda[i, j] := v[k] end do end do;
eval(Lambda);
end proc;

@acer 

 

Thanks! now it works as expected.

 

Harry

@acer 

For some statistical software the user can give restrictions for the parameters. Here a mapping of a probability to zero and one (giving 0.5 the benefit of the doubt)

1 2 3 4 5 Page 3 of 5