nm

11353 Reputation

20 Badges

13 years, 20 days

MaplePrimes Activity


These are questions asked by nm

Why when trying to substitute a term in denominator, subs does not work, when this term is product. But it works when this term is single variable?

subs((x*y)=t,1/(x*y));

does not work. i.e. it does not return 1/t

But this works

subs(z=t,1/z);

and returns 1/t

algsubs does not work either on the first example above. 

Just wondering why, that is all.

 

I do not think Maple help on the subject is easy to follow as the exampels are not clear. I was hoping someone can give a very simple example.  

Now, I run long script, over say 1,000 problems. This takes long time each time I run it. Since each problem is completely independent of others, and there is no shared data at all (for each problem, its output is written to separate file), I am thinking of using the parallel programming in Maple, and hoping this will speed it up. I have an intel PC, with modern CPU. I think it has may be 10 or 16 cores, not sure now, so in theory it should be faster to complete.

For a very basic example, suppose I have this sequential program

foo:=proc(i::integer)
   return i^2;
end proc;

for i from 1 to 10 do
   foo(i);
od;

Where foo() is now called 10 times, one after the other. How would one change the above to make it run in parallel?

I know I need to call Threads:-Task:-Start and then use Threads:-Task:-Continue 

But I am not sure how to use Threads:-Task:-Continue to tell it to call foo in parallel passing each task 1,2,3,.... in turn, and wait until they are all done. This is the part not clear to me how to do even after looking at the help example under Task Programming Model

Could someone show how to do the above for this simple example?   

Since I have 1,000 problems, do I need to create 1,000 tasks at once, one for each problem and wait for them to all be done? what if I have 10,000 problems, creating 10,000 tasks at once might not work, would it? or will Maple handle this internally by queuing the creation of tasks as needed? This part is also not clear to me.

 

thanks

 

Maple seems to suffer from too many levels of recursion issues. Here is another just found

restart;
current_solution:=y(x)-3/2 = 1/(x+2)^4*(-(x+2)^5*RootOf(-2+(x^5*C[1]^5+10*x^4*C[1]^5+40*x^3*C[1]^5+80*x^2*C[1]^5+80*x*C[1]^5+32*C[1]^5)*_Z^25+(5*x^5*C[1]^5+50*x^4*C[1]^5+200*x^3*C[1]^5+400*x^2*C[1]^5+400*x*C[1]^5+160*C[1]^5)*_Z^20)^20*C[1]^5+1)/RootOf(-2+(x^5*C[1]^5+10*x^4*C[1]^5+40*x^3*C[1]^5+80*x^2*C[1]^5+80*x*C[1]^5+32*C[1]^5)*_Z^25+(5*x^5*C[1]^5+50*x^4*C[1]^5+200*x^3*C[1]^5+400*x^2*C[1]^5+400*x*C[1]^5+160*C[1]^5)*_Z^20)^20/C[1]^5;

candidate_sol := limit(current_solution,C[1] = infinity);

Error, (in depends) too many levels of recursion

The problem with these is that they can not be cought by a try/catch. So the whole program/script comes to halt since error can not be cought.

Similar ones I found can be found here

https://www.mapleprimes.com/questions/229988-Error-in-Toolsmap-Too-Many-Levels
Error, (in tools/map) too many levels of recursion

https://www.mapleprimes.com/questions/229872-Error-in-Discontzero-Too-Many-Levels
Error, (in discont/zero) too many levels of recursion

https://www.mapleprimes.com/questions/229951-Random-Error-Error-in-EngineDispatch
Error, (in Engine:-Dispatch) too many levels of recursion

 

I am  not sure why these happen too often. Maple 2020.1 on windows 10. Physics version 724

 

 

 

restart;
expr:=a^2*(2*a^2*p^3-a^2*((p^2+1)^2*(a^2-1))^(1/2)-((p^2+1)^2*(a^2-1))^(1/2)*p^2+2*p*a^2-2*p^3+((p^2+1)^2*(a^2-1))^(1/2)-2*p)/((p^2+1)^2*(a^2-1))^(1/2)/(p^3-((p^2+1)^2*(a^2-1))^(1/2)+p)/(a^2-p^2-1);
int(expr,p)

Gives

why does Maple give division by zero?

Here is the result from integration package on Mathematica

ClearAll[a, p];
expr = a^2*(2*a^2*p^3 - 
       a^2*((p^2 + 1)^2*(a^2 - 1))^(1/2) - ((p^2 + 1)^2*(a^2 - 1))^(1/
           2)*p^2 + 2*p*a^2 - 2*p^3 + ((p^2 + 1)^2*(a^2 - 1))^(1/2) - 
       2*p)/((p^2 + 1)^2*(a^2 - 1))^(1/
        2)/(p^3 - ((p^2 + 1)^2*(a^2 - 1))^(1/2) + p)/(a^2 - p^2 - 1)
<< Rubi`
Int[expr, p]

Which it can integrate. Result is a little long. (removed since looks too long)

But my question really is not why Maple could not integrate it, but why the division by zero? 

Maple 2020.1

This is a programming question.

The goal is to solve an equation such as eq:=x^2+2*x-1=0; and obtain the solution as list with x= on each solution, like this

                       sol := [x = sqrt(2) - 1, x = -1 - sqrt(2)]

The command  to start with is sol:=solve(eq,x) which gives 

                       sol := sqrt(2) - 1, -1 - sqrt(2)

But to have x= show up, the command is modifed to be sol:=solve(eq,{x}) by adding {} around the variable to solve for, and now Maple gives 

                       sol := {x = sqrt(2) - 1}, {x = -1 - sqrt(2)}

Which is not yet the goal.. Changing the command to sol:=[solve(eq,{x})]  gives 

                       sol := [{x = sqrt(2) - 1}, {x = -1 - sqrt(2)}]

Which is still not the goal. Changing the command to sol:=solve(eq,[x])  gets closer to the goal.  it gives

                      sol := [[x = sqrt(2) - 1], [x = -1 - sqrt(2)]]

To remove the extra pair [ ] the list is Flattened like this

eq:=x^2+2*x-1=0;
sol:=solve(eq,[x]);
sol:=ListTools:-Flatten(sol)

Which gives me what I want, which is one list (not list of lists), and with x= in there

                             sol := [x = sqrt(2) - 1, x = -1 - sqrt(2)]

Is there a better way to obtain the above form of result than what I have above?

 

First 119 120 121 122 123 124 125 Last Page 121 of 199