mapj

183 Reputation

9 Badges

13 years, 257 days

MaplePrimes Activity


These are replies submitted by mapj

@Carl Love 

Thanks Carl. Your solution works in both versions of Maple.

@tomleslie 

Thanks for confirming the effect and thanks to everyone else for your input.

My setup is Maple 2015 on 32bit Win7. I was shutting down the Maple session between runs. Running the tests again gave somewhat different results but still with the same effect. This may be due to the fact that I had another and different worksheet open (but not running) when I did the original tests.

This effect is surprising since I wrongly assumed that the memory usage wouldn't change with n since the variables are always overwritten in the procedures. The results suggest that the values of y and yi for different i are being stored (at least for a while) as the procedure is called continuously.

I modified the program to do a gc() inside the loop and this keeps the memory under control, although the run time soars.

Since my real code has memory problems after many loops, I'll try a periodic gc() to see if this helps, although the help system discourages calling gc().

Markiyan Hirnyk: I don't really need these integrals. It was just an example to show the effect I was getting with my real code that involves a lot of integrations in a loop with a procedure used to calculate the integral terms.

 

Thanks all.

 

@Carl Love 

I read the test code into a Maple worksheet and run it. The memory figures are what Maple reports on the bottom right corner of the worksheet (along with the run time).

Thanks.

@Carl Love 

Sigh. It looks like we both had the same idea. Yours is a more elegant solution.

 

We may be able to help if you provide some basic information. What is the mathematical formulation of your problem?

@Carl Love

Thanks Carl.

However I find it strange that [] is needed here since we are just reading one value at a time in rather than making a list, unless I'm missing something.

 

 

@tomleslie 

Where is the effect of the [] in the line A[i,j]:=fscanf( fname, "%a")[]: documented?

I see that if I leave it out the terms have extra [] around them.

Thanks.

 

Thanks Acer and Tom. Tom's solution is what I need.

@Alejandro Jakubi 

Thanks for your two alternate suggestions.

@Carl Love 

Great. This will avoid accidental errors.

Thanks again.

 

@Carl Love 

I will avoid L(x*f(x)) and use a nonlinear N(x*f(x)) in this case. It would be good if you could use something like a "a::name except x" syntax in the definition of L to avoid accidental mistakes.

Thanks.

 

 

 

@Carl Love 

To answer my own question, this works.

define(L,orderless,multilinear,
L(a::name*b::function,c::function) = a*L(b,c),
L(a::name*b::function,c::name*d::function) = a*c*L(b,d)
);

val:=L(c*y1(x)+d*y2(x), e*z1(x)+f*z2(x));
diff(val,c);

Thanks for your help Carl.

 

 

@Carl Love 

The constant command works but then c..f can't be treated as variables. So the following gives an error in the diff command while the expansion is ok.

constants:=constants,c,d,e,f;
val:=L(c*y1(x)+d*y2(x), e*z1(x)+f*z2(x));
diff(val,c);

Presumably c..f need to be allowed to vary.

Thanks.

 

 

 

 

@Carl Love 

 

Thanks Carl.

However,

L(c*y1(x)+d*y2(x), e*z1(x)+f*z2(x));

with c to f as algebraic doesn't expand.

 

@Carl Love 

Thanks for the great exaplanation. It helps to learn new commands and how they work.

I didn't know about the selectremove command and was using a clumsy loop with an if assigned test.

 

1 2 3 4 5 Page 3 of 5