nm

11413 Reputation

20 Badges

13 years, 71 days

MaplePrimes Activity


These are replies submitted by nm

When getting into trouble, the first thing to do is to try to reproduce the problem using a small example. This is the first and most important skill a programmer must learn.

You say Maple does not seem to evaluate the array in a loop. So, I would start by trying to reproduce this using small example with small array instead of trying to figure it out using the large program.

Many times, just in trying to reproduce the problem in small example will show the error you are having in the code, it might be as simple as needing to use an eval somewhere.

 

@Carl Love 

nice solution. I tried subsindents instead of evalindents, but becuase I missed the algsubs, it was not working, but now it works with the 1/TV

collect(subsindets(B,`*`,x->algsubs(1/(T[1]*V[2])=u,x)),u);

(too many Maple functions, too little time)

@Kitonum 

This is the first thing I tried, but I used: algsubs(T[1]*V[2]=U, B); instead of yours algsubs(1/(T[1]*V[2])=U, B) and I could not figure out why the T1V2 in the denominator(s) were not being replaced. I thought it works like Mathematica patterns, but I was wrong.

 

@Carl Love 

thanks, this will work for me. I can select one group at a time (I do not want to merge them, but wanted to move them all to be under a section). So no problem to do one at time, at least I do not have to manually use the mouse now to select large group as before. (I think Mathematica way is much easier. Click on the edge of the cell to select it, but that is ok for now)

But I get this error on some groups

Would you know if there is some setting I can change to make Maple copy this large group? thanks

ps. I found it. It was under enable/RTF copy. I disable this and now I can copy large group. Problem solved. In case someone in the future gets this error:

 

@acer 

thanks for the sincos trick, I did not know about it. It looks like Maple does not know about the power rule in integration, or did not see it in this case. I added note on this in my question to clarify this.

@acer 

thanks! I never knew about CTRL-DEL before, this is a life saver when using Maple worksheet. I'll put it on a yellow stick now and keep it in front of me.

@Carl Love 

Is there a way to apply a patch to a function such as this and update the library locally on my PC or is this something that can't be done?  I tried the fix to Combine and now Combine does the right thing:

I simply changed

'And(DefiniteIntegral,Not(MultipleIntegral))')

with

'And(Or(IndefiniteIntegral,DefiniteIntegral),Not(MultipleIntegral))')

everywhere

---------------------
restart;
with(IntegrationTools): #needed to load the whole package to access DefiniteIntegral types...
ints:=indets(v,'And(Or(IndefiniteIntegral,DefiniteIntegral),Not(MultipleIntegral))'):
x := IntegrationTools:-GetVariable(ints[1]):
input := subsindets[':-flat'](v,'And(Or(IndefiniteIntegral,DefiniteIntegral),Not(MultipleIntegral))',t -> Change(t,GetVariable(t) = X)):
output := combine(input,'int'):
subs(X = x,Change(output,X = x));
----------------------

 

 

 

 

Where does the augment command come from??

It is not a good idea to do with(...) and then use the commands in the code. It better to write

restart:
s := {E[1], E[2], E[3]};
v := {x[1], x[2], x[3]};
A := LinearAlgebra:-GenerateMatrix(s, v);

Since now it is clear where each command/function comes from. Also this makes it easier to put these in a function later on. Inside a function it is not good idea to with(packages) any way. So you'd have to do this later any way.

 ps. why not use LinearAlgebra[LUDecomposition] ?


set in maple is mathematical set. In math, a set by definition has no duplicate elements. See http://en.wikipedia.org/wiki/Set_%28mathematics%29

@Carl Love 

thanks. This worked very well.

@acer 

Your method of checking for op(0,....) does not work for all cases. Sometimes Maple returns partial result, which has "int" inside. i.e. not complete evaluation. How would I check for such cases? I need to check that expression returned is free of "int" any where. But I do not know how to do this in Maple.

Here is an example

restart;
g:=int(exp(m*x)*tan(x)^2,x);

For me, the above is not fully solved. There is an antiderivative for this but maple does not find it. But if I use your method, it says it passed:

if op(0,eval(g,1)) = int then
  print('failed');
else
  print('success');
fi;

                success

I hope there is a method to check for such cases.  Fyi, here is Mathematica result for the above

Integrate[E^(m*x)*Tan[x]^2, x]

@acer 

I find the idea of `int` emitting an error instead of an unevaluated return to be generally poor

The correct API should always return a status code, some kind of indication of success or faliure code. In addition to result if any. I did not mean to just throw an error in place of what is currently done. I should have made this more clear.

For example, one can do   

    g,status = int(sin(x),x)

and one checks for status first, which would indicate success of failure. i.e. if int was able to complete or not, this does not mean the result is mathematically valid, which is another issue. Now the user can check for status, and if indicates success, then they know g will contain the antiderivative. If status is missing, the above becomes the same as currently done.

If the API can't be changed, another option is to set a global symbol, say $STATUS_OF_LAST_CALL, and now once can check on that instead, while the API remain unchanged so older code do not break.

This is very useful for automated regression test scripts, to be able to verify against.

But your method of op(0,eval(g,1)) = int  worked, thank you, so will use this. But my point is that a common approach is need for all commands of this nature, such as dsolve, etc... which works the same instead of having to figure how to check the status case by case depending on the command currently used.

@Axel Vogt 

Thanks, when I saw size option, I tried it on z2 directly and it worked:

simplify(z2,size);

So why did you use combine(%, Int); before that? It works without doing combine.

But I still do not know why simplify worked on z1, but not on term+z1, since "term" did not enter into play at all in all of this.

 

You should post plain text code. How do you expect someone to try your code?? Think about it a little

You need to execute the line

printf("Number of players is %s\n",numplayers);

again to clear the output from last run.

First 78 79 80 81 82 83 84 Last Page 80 of 91