MaplePrimes Questions

Search Questions:

Dear all, I tried to run the test.java example in the Eclipse IDE but receive the following error message:

Error: Unable to initialize main class examples.test2
Caused by: java.lang.NoClassDefFoundError: com/maplesoft/externalcall/MapleException

May be there is s.o. who has an idea.

Thanks

If we have the system of difference equations

xn=yn-1xn-1+2,             yn=0.5 xn-1+yn-1+1,      n=1,2,...,

 where x0 and y0 are positive initial valyes.

How can I plot the solution {xn,yn} ??

The usual ODE must be solved:
y´´*(y^3-y)+y´^2 *(y^2+1)=0
"Dangerous places" of the definition domain must be described: Where are the general solution y(x) and its derivatives continuous?

This is probably asked before but can't find it. 

After making a plot, then RIGHT-CLICKing on it, option menu comes up that allows one to modify the plot (like adding gridlines, or change the line style).

How does one find the Maple command after doing such changes, so one can use the command in the code?

Here is an example. I modified a little acers plot in this answer and added the points to the plot

eq:=-0.0004*x^2 - 2.7680*10^(-28)*x^12 - 2.1685*10^(-43)*x^18 - 1.3245*10^(-37)*x^16 - 1.6917*10^(-32)*x^14 + 0.7650 + 6.6773*10^(-18)*x^8 - 2.5543*10^(-23)*x^10 - 8.0002*10^(-13)*x^6 + 3.6079*10^(-8)*x^4 = 0:
the_roots:=fsolve(eq):	
the_roots:=map(X->[X,0],[the_roots]):
p1:=plot(lhs(eq),x=-210..210,size=[500,200]):
p2:=plot(the_roots,style=point, color=red, symbol=solidcircle, symbolsize=20):
plots:-display(p1,p2)

 

I was lazy to look up the grid option syntax. So right clicked on the plot and found option to add gridline. So said, great. And the above is the result.

But now I'd like to see the command used so I know where the grid option goes and how its syntax is. There does not seem to be option in the interface to display the Maple command used.

How would one find it?

Maple 2024.1 on windows 10

 

hi...

how can I just find the real roots of this equation in Maple:

eq:=-0.0004*x^2 - 2.7680*10^(-28)*x^12 - 2.1685*10^(-43)*x^18 - 1.3245*10^(-37)*x^16 - 1.6917*10^(-32)*x^14 + 0.7650 + 6.6773*10^(-18)*x^8 - 2.5543*10^(-23)*x^10 - 8.0002*10^(-13)*x^6 + 3.6079*10^(-8)*x^4 = 0:

I want to solve it first with fsolve (with options) command and second other command than fsolve. 

tnx...

I am trying to plot the shearforce of a hollow section circular beam along the hight of the cross section.

I don't seem to be able to solve the equation. I get the message:"Warning, solutions may have been lost"
Can anyone help?

The tricky part is the distance of the "point of grafity of the area above y' to the 'point of grafity of the cross section (y=0)'. This distance is a function of y and is called y_

this is de code: M_V_as_function_of_hight_cc__temporary.mw

restart: with(LinearAlgebra): with(plots, textplot, display): #Digits :=5: evalf(%): with(RealDomain):
Rout:=168.3/2:
Rin :=Rout-12.5:

T:=V*Q/(II*b):
Q:=A_*y_:
bout:=2*sqrt(Rout**2 - y**2):
bin:=piecewise( y<Rin,2*sqrt(Rin**2 - y**2)  ,  y>=Rin,0):
#bin:=Re(2*sqrt(Rin**2 - y**2)):
b:=bout-bin;
A_ :=piecewise(  y<=0,0   ,    y<Rin,evalf( int(b ,  y=y..Rout ) ) ,    y>=Rin,int(bout , y=y..Rout)    ,    y>=Rout,0);
y:=y_: AA_:=A_;
y:='y':
eq1:=2*AA_ = A_:
sol1:=solve(eq1, y_ );
y_ := sol1:
y_;
#plot(y_,y=0..Rout);

Let us say f(x) is a procedure that can take two possible values for x.
How do I store the stats of CodeTools:-Usage(f(1))  and CodeTools:-Usage(f(2)) for ease of comparison?  Hopefully, I am not missing any help statements/examples.

Hi all
I have a simple problem with the following matrix entries. I probably have a problem with the indices. Because the matrix is ​​not calculated correctly. Anyone have suggestion?

Drear freinds,

I want to simplify f (a long experssion) in the form of f2. How to determine M1^2 and M0^2?

f1.mw

I've been evaluating Threads (since I can use Mutex in it, which is not supported in Grid).

I noticed that when measuring time to evaluate same integral inside thread it takes about 3 times as long as outside thread.

I am using time[real] to measure the time. (is this not the correct way to do this with Threads?)

Still, using threads was faster overall to integrate 10 different integrals than doing these sequentially one by one. 

When integrating 10 _different_ integrals using Threads, the total time was about 19 seconds.  While when done sequentially the overall time was about 50 seconds.  I used different integrals, to make sure Maple does not use result in its cache.

So using Threads was almost 3 times as fast, even when each int() call takes 3 times as long. (Because all the int() calls were done in parallel). 

But It seems there is some overhead to calling library function from inside Thread? (but time is compensated for since everthing is done in parallel now). Is this documented somewhere? It could be, I did not read every help page on Threads. Just started learning in early today.

But my main question is: Why int() takes 3 times as long inside Thread than outside?  I was expecting it to take similar time. Or may be I am not measuring time correctly inside Thread?

Attached test worksheet.

interface(version);

`Standard Worksheet Interface, Maple 2024.1, Windows 10, June 25 2024 Build ID 1835466`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1815. The version installed in this computer is 1813 created 2024, September 28, 18:14 hours Pacific Time, found in the directory C:\Users\Owner\maple\toolbox\2024\Physics Updates\lib\`

libname;

"C:\Users\Owner\maple\toolbox\2024\Physics Updates\lib", "C:\Program Files\Maple 2024\lib"

restart;

 

doall := proc(mutex_to_use,my_id,T::list)
  local s::string;
  local current_time;
  
  print("mutex is ",mutex_to_use," my id is ",my_id);
  current_time:=time[real]();
  int(T[my_id],x,method=_RETURNVERBOSE);
  print("thread ",my_id," time to integrate is ",time[real]()-current_time);  
 
end proc:

#file_id:=fopen(cat(currentdir(),"/log.txt"),WRITE);

mutex_to_use := Threads[Mutex][Create]();
T:=[sin(2*x)/(a^2+b^2*cos(x)^2),
    sin(3*x)/(a^2+b^2*cos(x)^2),
    sin(4*x)/(a^2+b^2*cos(x)^2),
    sin(5*x)/(a^2+b^2*cos(x)^2),
    sin(6*x)/(a^2+b^2*cos(x)^2),
    sin(7*x)/(a^2+b^2*cos(x)^2),
    sin(8*x)/(a^2+b^2*cos(x)^2),
    sin(9*x)/(a^2+b^2*cos(x)^2),
    sin(10*x)/(a^2+b^2*cos(x)^2),
    sin(11*x)/(a^2+b^2*cos(x)^2)];
print("time=",Calendar:-Format( Calendar:-Today(), "EEEE, MMMM dd, yyyy GG 'at' hh:mm:ss a" ));  
Threads[Wait]( seq( Threads[Create]( doall(mutex_to_use,i,T)), i=1..10)):
print("time=",Calendar:-Format( Calendar:-Today(), "EEEE, MMMM dd, yyyy GG 'at' hh:mm:ss a" ));  
#fclose(file_id);
Threads[Mutex][Destroy]( mutex_to_use );

2

[sin(2*x)/(a^2+b^2*cos(x)^2), sin(3*x)/(a^2+b^2*cos(x)^2), sin(4*x)/(a^2+b^2*cos(x)^2), sin(5*x)/(a^2+b^2*cos(x)^2), sin(6*x)/(a^2+b^2*cos(x)^2), sin(7*x)/(a^2+b^2*cos(x)^2), sin(8*x)/(a^2+b^2*cos(x)^2), sin(9*x)/(a^2+b^2*cos(x)^2), sin(10*x)/(a^2+b^2*cos(x)^2), sin(11*x)/(a^2+b^2*cos(x)^2)]

"time=", "Wednesday, October 02, 2024 AD at 11:08:15 PM"

"mutex is ", 2, " my id is ", 1

"mutex is ", 2, " my id is ", 2

"mutex is ", 2, " my id is ", 3

"mutex is ", 2, " my id is ", 4

"mutex is ", 2, " my id is ", 5

"mutex is ", 2, " my id is ", 6

"mutex is ", 2, " my id is ", 10

"mutex is ", 2, " my id is ", 8

"mutex is ", 2, " my id is ", 7

"mutex is ", 2, " my id is ", 9

"thread ", 7, " time to integrate is ", 15.192

"thread ", 1, " time to integrate is ", 16.540

"thread ", 3, " time to integrate is ", 18.185

"thread ", 5, " time to integrate is ", 18.354

"thread ", 10, " time to integrate is ", 18.367

"thread ", 2, " time to integrate is ", 18.416

"thread ", 9, " time to integrate is ", 18.544

"thread ", 6, " time to integrate is ", 18.581

"thread ", 8, " time to integrate is ", 18.604

"thread ", 4, " time to integrate is ", 18.603

"time=", "Wednesday, October 02, 2024 AD at 11:08:34 PM"

restart;

T:=[sin(2*x)/(a^2+b^2*cos(x)^2),
    sin(3*x)/(a^2+b^2*cos(x)^2),
    sin(4*x)/(a^2+b^2*cos(x)^2),
    sin(5*x)/(a^2+b^2*cos(x)^2),
    sin(6*x)/(a^2+b^2*cos(x)^2),
    sin(7*x)/(a^2+b^2*cos(x)^2),
    sin(8*x)/(a^2+b^2*cos(x)^2),
    sin(9*x)/(a^2+b^2*cos(x)^2),
    sin(10*x)/(a^2+b^2*cos(x)^2),
    sin(11*x)/(a^2+b^2*cos(x)^2)]:

print("time=",Calendar:-Format( Calendar:-Today(), "EEEE, MMMM dd, yyyy GG 'at' hh:mm:ss a" ));  
for item in T do
  current_time:=time[real]():
  int(item,x,method=_RETURNVERBOSE):
  print(" time to integrate is ",time[real]()-current_time);
od:
print("time=",Calendar:-Format( Calendar:-Today(), "EEEE, MMMM dd, yyyy GG 'at' hh:mm:ss a" ));  

"time=", "Wednesday, October 02, 2024 AD at 11:09:03 PM"

" time to integrate is ", 4.869

" time to integrate is ", 4.897

" time to integrate is ", 4.744

" time to integrate is ", 5.049

" time to integrate is ", 4.622

" time to integrate is ", 5.186

" time to integrate is ", 4.694

" time to integrate is ", 5.184

" time to integrate is ", 4.790

" time to integrate is ", 5.138

"time=", "Wednesday, October 02, 2024 AD at 11:09:52 PM"

 


 

Download why_int_timing_different_in_thread.mw

 

How to make Maple not use result of int() on same function it solved before? (this is for testing something else I am doing, and I will not use this in my main code).

I am trying to make some tests to compare things, and I'd like Maple to not remember last result.

But calling forget(int), it still seems to have remembered result it found before.

I also tried

         forget(int,forgetpermanent=true, subfunctions=true, reinitialize=true);

I do not ofcourse want to call restart in middle of loop.

Is there a way to make Maple forget result it obtained, in this example, from int()?

interface(version);

`Standard Worksheet Interface, Maple 2024.1, Windows 10, June 25 2024 Build ID 1835466`

restart;

int_1:=sin(3*x)/(a^2+b^2*cos(x)^2);
int_2:=sin(4*x)/(a^2+b^2*cos(x)^2);

sin(3*x)/(a^2+b^2*cos(x)^2)

sin(4*x)/(a^2+b^2*cos(x)^2)

#first time it is slow
T:=time[real]():
int(int_1,x,method=_RETURNVERBOSE):
print("time used is ",time[real]()-T);

"time used is ", 9.477

T:=time[real](): #now it remembered last result
int(int_1,x,method=_RETURNVERBOSE):
print("time used is ",time[real]()-T);

"time used is ", 0.1e-2

forget(int); #this has no effect. It still complete much faster than first time

 

T:=time[real]():
int(int_1,x,method=_RETURNVERBOSE):
print("time used is ",time[real]()-T);

"time used is ", 0.95e-1

forget(int,forgetpermanent=true, subfunctions=true, reinitialize=true); #also this had no effect

T:=time[real]():
int(int_1,x,method=_RETURNVERBOSE):
print("time used is ",time[real]()-T);

"time used is ", 0.47e-1

#lets try different integral, now it is slow since new integral
T:=time[real]():
int(int_2,x,method=_RETURNVERBOSE):
print("time used is ",time[real]()-T);

"time used is ", 4.810

 


 

Download how_to_forget_without_restart.mw

 

I want a plot of the function & the approx. calculus of integral:

E0 := evalf(int(T2, x = x0 .. x0 + 1.542976947*10^(-13))); it doesn't compute in in normal time...Audion.mw

in the program:

restart;
a := -1.44670357887361*10^(-7);
b := -1.049267156*10^(-9);
c := 1.890440485*10^(-12);
d := -6.233924848*10^(-16);
Ea := 0.00762014687*t + a*t^2 + b*t^3 + c*t^4 + d*t^5;
E1 := diff(Ea, t);
E2 := subs(t = 435, Ea);
E3 := subs(t = 528, Ea);
E4 := subs(t = 2860, Ea);
 

It seems that Maple needs more help than necessary:

restart:

kernelopts(version)

`Maple 2015.2, APPLE UNIVERSAL OSX, Dec 20 2015, Build ID 1097895`

(1)

expr:= A+B*limit(f(x), x=+infinity);
eval(expr, limit(f(x), x=+infinity)=1)

A+B*(limit(f(x), x = infinity))

 

A+B

(2)

expr:= A+B*limit(2*f(x), x=+infinity);

eval(expr, limit(f(x), x=+infinity)=1);     # Shouldn't this return A+2*B
eval(expr, limit(2*f(x), x=+infinity)=2);   # Can I avoid doing this?

A+B*(limit(2*f(x), x = infinity))

 

A+B*(limit(2*f(x), x = infinity))

 

A+2*B

(3)

expr:= A+B*limit(f(x)^2, x=+infinity);

eval(expr, limit(f(x), x=+infinity)=1);     # Shouldn't this return A+B
eval(expr, limit(f(x)^2, x=+infinity)=1);   # Can I avoid doing this?

A+B*(limit(f(x)^2, x = infinity))

 

A+B*(limit(f(x)^2, x = infinity))

 

A+B

(4)

expr:= A+B*limit(2*f(x)^2, x=+infinity);

eval(expr, limit(f(x)^2, x=+infinity)=1);    # Shouldn't this return A+2*B
eval(expr, limit(2*f(x)^2, x=+infinity)=2);  # Can I avoid doing this?

A+B*(limit(2*f(x)^2, x = infinity))

 

A+B*(limit(2*f(x)^2, x = infinity))

 

A+2*B

(5)
 

 

Download limits.mw

Why don't the commands labelled "Shouldn't this return.." do the job?

TIA

It is probably not possible to use mutex with Grid. But I see no other option. 

I need to create a number of nodes in Grid to do parallel processing. But need to also make critical section around few places during execution  in the code (for example, writing to common file, or update SQLite db).

Grid package does not seem to have a command to do this. I found that the Threads package have mutex which is exactly what I wanted in order to make critical section.

But all my attempts to use mutex in the Grid fail. When I make mutex and pass it to Grid:-Launch call to be used by each node, I keep getting errors when it is used inside the node.

I do not know if I am just not passing it correctly, or simply Mutex is not supported in Grid. I tried many things, and none have worked.

If it is not supported, what other mechanism are there to allow one to synchronize access to some shared resource, so only one node is using at a time?

Grid has Wait and Barrier and WaitForFirst, but I do not see how these can be used for this.

Without the ability to be able to create critical section, then Grid package will not work for me.

Below is worksheet I have been using. I hope I am just making silly mistake in using the mutex with Grid.

ps. I prefer to use Grid and not Threads package to do parallel processing.

pps. I can see why mutex would not work in Grid, since mutex is process specific entity, and Grid uses completely separate processes for each node. So it will not work to use for synchronization between separate processes. But what else to use in Maple for this?

interface(version);

`Standard Worksheet Interface, Maple 2024.1, Windows 10, June 25 2024 Build ID 1835466`

restart;

currentdir("C:/tmp"); #change as needed

"G:\public_html\my_notes\solving_ODE\current_version\tests\DB_with_GRID"

doall := proc(userData::list,mutex_to_use)
  local s::string, me:=Grid:-MyNode();
  local PROBLEM_ID::posint;
  local file_id;
  
  PROBLEM_ID:=userData[me+1];
  print("mutex is ",mutex_to_use);
  s:=cat("I'm node ",String(me)," of ",String(Grid:-NumNodes())," I will be processing problem ", String(PROBLEM_ID));
  print(s);

  
  file_id:=fopen(cat(currentdir(),"/log.txt"),APPEND);

  #I need to make sure only ONE node writes to this file
  #so not to lose buffer data
  
  Threads[Mutex][Lock]( mutex_to_use );
  fprintf(file_id,"%s\n",s);
  Threads[Mutex][Unlock]( mutex_to_use );
  
  
  fclose(file_id);
  Grid:-Barrier(); #wait here for all nodes to complete
end proc:

file_id:=fopen(cat(currentdir(),"/log.txt"),WRITE);

0

mutex_to_use := Threads[Mutex][Create]();
print("mutex created is ",mutex_to_use);
userData:=[$1..10];
Grid:-Launch(doall,codeargs=[userData,mutex_to_use],numnodes=5);
fclose(file_id);
Threads[Mutex][Destroy]( mutex_to_use );

2

"mutex created is ", 2

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

"mutex is ", 2

"I'm node 4 of 5 I will be processing problem 5"

"mutex is ", 2

"I'm node 1 of 5 I will be processing problem 2"

Error, (in Threads:-Mutex:-Lock) invalid identifier given, no mutex with id %1

Error, (in Threads:-Mutex:-Lock) invalid identifier given, no mutex with id %1

"mutex is ", 2

"I'm node 2 of 5 I will be processing problem 3"

Error, (in Threads:-Mutex:-Lock) invalid identifier given, no mutex with id %1

"mutex is ", 2

"mutex is ", 2

"I'm node 3 of 5 I will be processing problem 4"

Error, (in Threads:-Mutex:-Lock) invalid identifier given, no mutex with id %1

"I'm node 0 of 5 I will be processing problem 1"

Error, (in Threads:-Mutex:-Lock) invalid identifier given, no mutex with id %1

 

 


 

Download using_mutex_in_grid.mw

 

Hi everyone...

How can the coefficients of below nonlinear equation be obtained?

c1*diff(f(x), x$4) + c2*diff(f(x), x$3)/x +c3*diff(f(x), x$2)/x^2 + c4*diff(f(x), x)/x^3 +c5 *f(x)=0

I want to calculate separately, c1,c2,c3,c4,c5 

tnx...

1 2 3 4 5 6 7 Last Page 1 of 2362