Maple 2015 Questions and Posts

These are Posts and Questions associated with the product, Maple 2015

Dear all!

Hope everything going fine with you. I am facing problem to integrate the attached file in this file we need the result of z[1] and others like y[1]. I am waiting your quick answer.

Help.mw

With my best regards and sincerely.

Muhammad Usman

School of Mathematical Sciences 
Peking University, Beijing, China

Email: muhammadusman@pku.edu.cn

Mob #: 0086-13001903838

 

I have written a C++ program which I feed in an input from Maple which has been converted using the CodeGeneration package in Maple and stored in a text file. For it to be processed in C++ I need to remove the cg = at the start of the Maple output expression. An example of this is as follows:

C(x^2+y^2+z^2);

cg = x * x + y * y + z * z

C++ cannot process the cg= at the start of the string and so I have found ways around it by using Bash or C++ itself to remove or ignore the cg = but I was wondering if it was possible to just not have Maple print it to begin with?

- Yeti

Consider a simple differential equation:

f1 := t -> sin(t);
f2 := t -> cos(t);
dsys := {diff(x(t), t) = x(t)*f1(t)+f2(t), x(0) = 3};
solution_procedure := dsolve(dsys, type = numeric, output = listprocedure);

If initial condition is given like this: x(0)=3, then it compiles. But if I define x(0)=f1(3) then it gives an error:

Error, (in dsolve/numeric/process_input) invalid specification of initial conditions, got HFloat(3.0) = sin(3)

How can I handle this?

I'm trying to make 3D-animation and the procedure takes an enormous amount of time to make frames for it. It took over 10 minutes to create animation consisting of 50 frames (over t=0..1000). If I increase the number of frames or range of time, it just wouldn't reach the end of calculation (keeps evaluating till I lose patience or my faith in Maple)

Is there a way to somehow precompute data for animation (maybe store it somewhere) so that it could gather it from there and the animation construction itself would be faster?

Here's the code: ClassicalTrajectoriesH2X_harm.mw (animation is in the end of the file)

P.S. I have Asus X555LJ; Intel Core i5-5200U, 2.2GHz; 12Gb RAM, for the last few months it presented itself as a rather fast piece of machinery. 

I'm trying to numerically integrate components of the procedure-vector.

interim:=t->evalf(int(r1_lab_deriv(x)[1],x=0..t));

interim(5);

Getting this type of error:

Error, (in r1_rot_deriv) invalid input: fdiff expects its 2nd argument, N, to be of type {integer, name, list(integer), list(name), list(name = constant), set(name), set(name = constant), name = constant}, but received t = x

 A bit of googling gave me an impression that integration of procedures can be rather quirky.

File: ProcIntergration.mw (Problem occurs in the last lines of the file.)

how to fasten dsolve and is it possible to timeout faster if it know no solution earlier?

i split into near 500 blocks of nested for loop, total around 42 billions trials

i run in cmaple, 

i see it run the first 4 blocks of code and output to files,  which are daff001, daff002, daff003 and daff004

it seems that it can run parallel intelligently though i write in serial lines.

but it run a very long time, still running near first 4000 records

window 10 use 3.4GB memory, only 4GB memory rest

but 4000 records use more than 4GB memory

i just hope to run 1000 records every day, hope 1000 records can be finished within a few hours

and plan to run around 500days

 

restart:
read "D:\\daff2039mm.m":
with(combinat):
appendto("D:\\daff001.txt");
for ii from 1 to 1 do
for jj from 1 to 1 do
for kk from 1 to 1 do
if ii < jj and jj < kk then
if mm[ii] <> mm[jj] and mm[jj] <> mm[kk] then
sol := dsolve([mm[ii] , mm[jj] , mm[kk] ],[a(t), b(t), c(t)]);
if nops([sol]) = 1 then
print([mm[ii], mm[jj], mm[kk]]);
print(sol);
print(" * **");
end if:
end if:
end if:
od:
gc();
od:
od:

restart:
read "D:\\daff2039mm.m":
with(combinat):
appendto("D:\\daff002.txt");
for ii from 1 to 1 do
for jj from 1 to 1 do
for kk from 1 to 1001 do
if ii < jj and jj < kk then
if mm[ii] <> mm[jj] and mm[jj] <> mm[kk] then
sol := dsolve([mm[ii] , mm[jj] , mm[kk] ],[a(t), b(t), c(t)]);
if nops([sol]) = 1 then
print([mm[ii], mm[jj], mm[kk]]);
print(sol);
print(" * **");
end if:
end if:
end if:
od:
gc();
od:
od:

restart:
read "D:\\daff2039mm.m":
with(combinat):
appendto("D:\\daff003.txt");
for ii from 1 to 1 do
for jj from 1 to 1 do
for kk from 1001 to 2001 do
if ii < jj and jj < kk then
if mm[ii] <> mm[jj] and mm[jj] <> mm[kk] then
sol := dsolve([mm[ii] , mm[jj] , mm[kk] ],[a(t), b(t), c(t)]);
if nops([sol]) = 1 then
print([mm[ii], mm[jj], mm[kk]]);
print(sol);
print(" * **");
end if:
end if:
end if:
od:
gc();
od:
od:

restart:
read "D:\\daff2039mm.m":
with(combinat):
appendto("D:\\daff004.txt");
for ii from 1 to 1 do
for jj from 1 to 26 do
for kk from 2001 to 2001 do
if ii < jj and jj < kk then
if mm[ii] <> mm[jj] and mm[jj] <> mm[kk] then
sol := dsolve([mm[ii] , mm[jj] , mm[kk] ],[a(t), b(t), c(t)]);
if nops([sol]) = 1 then
print([mm[ii], mm[jj], mm[kk]]);
print(sol);
print(" * **");
end if:
end if:
end if:
od:
gc();
od:
od:

restart:
read "D:\\daff2039mm.m":
with(combinat):
appendto("D:\\daff005.txt");
for ii from 1 to 1 do
for jj from 26 to 51 do
for kk from 2001 to 2001 do
if ii < jj and jj < kk then
if mm[ii] <> mm[jj] and mm[jj] <> mm[kk] then
sol := dsolve([mm[ii] , mm[jj] , mm[kk] ],[a(t), b(t), c(t)]);
if nops([sol]) = 1 then
print([mm[ii], mm[jj], mm[kk]]);
print(sol);
print(" * **");
end if:
end if:
end if:
od:
gc();
od:
od:

i have already release memory with gc() in the most inner for loop ]

,but it still use up my memory

once it printed two lines each time, actually it can release memory

but why it still use up memory

read "D:\\hello.m":
with(combinat):
appendto("D:\\gogogo.txt");
for ii from 1 to 2040 do
for jj from 1 to 2040 do
for kk from 1 to 2040 do
if ii < jj and jj < kk then
if mm[ii] <> mm[jj] and mm[jj] <> mm[kk] then
sol := dsolve([mm[ii],mm[jj],mm[kk]],[a(t),b(t),c(t)]);
print([mm[ii],mm[jj],mm[kk]]);
print(sol);
print("***");
end if:
end if:
od:
gc();
od:
od:

 

i can only think

use c# to generate code with file write, nested for loop every 1000 records 

is it the only way to do?

 

int counter = 0;
for (int i=1; i<=2040; ++i)
{
for (int j = 1;j <= 2040; ++j)
{
for (int k = 1; k <= 2040; ++k)
{
if(counter % 1000 == 0)
{
Console.Write(i.ToString() + ","+j.ToString() + ","+k.ToString());
Console.Write("\r\n");
}
counter = counter + 1;
}
}
}

 

Is it possible to create several animation windows and run them simultaneously? 

I'm feeling that the answer to this question will be no, so I explain my problem. I have an animation of rotating object and I have some quantity that relates to the rotation. I want to see the rotation of object and the propagation of the graph of the quantity simultaneously. Maybe there is a way to somehow split the plot window in two, so in the left would be the rotation animation, and in the right would be the function animation.

I'm trying to plot the lines that are based on eigenvectors of the matrix. (Functions r1(t),r2(t), q(t) are defined earlier. I can upload file if necessary)

with(LinearAlgebra):
x1:=t->-r1(t)*cos(Pi/2-q(t)/2):
y1:=t->-r1(t)*sin(Pi/2-q(t)/2):
z1:=t->0:
x2:=t->r2(t)*cos(Pi/2-q(t)/2):
y2:=t->-r2(t)*sin(Pi/2-q(t)/2):
z2:=t->0:
Ixx:=t->m*(y1(t)^2+z1(t)^2)+m*(y2(t)^2+z2(t)^2):
Iyy:=t->m*(x1(t)^2+z1(t)^2)+m*(x2(t)^2+z2(t)^2):
Izz:=t->m*(x1(t)^2+y1(t)^2)+m*(x2(t)^2+y2(t)^2):
Ixy:=t->-m*x1(t)*y1(t)-m*x2(t)*y2(t):
Ixz:=t->-m*x1(t)*z1(t)-m*x2(t)*z2(t):
Iyz:=t->-m*y1(t)*z1(t)-m*y2(t)*z2(t):

InertiaTensor:=t-><<Ixx(t),Ixy(t),Ixz(t)>|<Ixy(t),Iyy(t),Iyz(t)>|<Ixz(t),Iyz(t),Izz(t)>>:

 Here I define the matrix as a function of time. 

EV:=t->Eigenvectors(InertiaTensor(t));
V1:=t->Column(Re(EV(t)[2]),1);
V2:=t->Column(Re(EV(t)[2]),2);

Producing two eigenvectors also as functions of time.

InertiaAxis1 := t->plot(x, V1(t)[2]*x/V1(t)[1], x = -2 .. 2);
InertiaAxis2 := t->plot(x, V2(t)[2]*x/V2(t)[1], x = -2 .. 2);

InertiaAxis1(1);

And here I've got an error:

Error, (in plot) unexpected options: [-HFloat(7.378655652881484e-6)*x, x = -2 .. 2]

I tried to set "datatype=float"-option in plot function, to evaluate the coefficient by eval-function, it wouldn't help. What does this error mean exactly? 

I am interested in the behaviour of a system of equations close to the origin- these equations are quite long, and there are a lot of them so i would like to have commands that i can use to assume products of variables are zero. 

here are the first two polynomials:


alpha*k[a1]*B[1]^2+(-alpha*k[a1]-alpha*k[a2])*B[2]*B[1]+2*alpha*k[a1]*B[1]*B[11]+alpha*k[a1]*B[12]*B[1]+2*alpha*k[a1]*B[1]*B[211]+alpha*k[a1]*B[221]*B[1]+2*alpha*k[a1]*B[1]*B[2211]+(-alpha*R[b]*k[a1]-k[d1])*B[1]+2*B[11]*k[d1]+B[12]*k[d2]+k[d1]*B[211]+k[d2]*B[221]

(-alpha*k[a1]-alpha*k[a2])*B[2]*B[1]+alpha*k[a2]*B[2]^2+2*alpha*k[a2]*B[2]*B[22]+alpha*B[2]*B[12]*k[a2]+alpha*k[a2]*B[2]*B[211]+2*alpha*k[a2]*B[2]*B[221]+2*alpha*k[a2]*B[2]*B[2211]+(-alpha*R[b]*k[a2]-k[d2])*B[2]+B[12]*k[d1]+2*B[22]*k[d2]+k[d1]*B[211]+k[d2]*B[221]

the varables are the terms with B and a subsript and everything else is a parameter.

My intuition was to use coeffs but I couldn't get anything helpful

You have three cakes, with diameters 15cm, 20cm and 25cm (same width). You want to share the cakes equally among your four customers. How do you do it?
What if you want the cakes sliced into the minimum total number of pieces?


The answer is to cut the cakes in half, but five pieces is the minimum.

What I want is a procedure for a more general case.

m cakes (different diameters) divided equally amongst n people. what is the minimum number of cuts or pieces to achieve this.

cuts.mw

I'm modeling the interaction between rotation and vibration in water molecule. I've come up with the solution functions, but I wanted to make some illustrative animations to fully understand what is going on. I made an animation (in the very end of the attached file) showing vibration of molecule and I want the trajectory of each (of two) particles to be traced after it, how could it be done? Also I want to have the movement of the angular momentum vector (vector with components [Jx=J*cos(varphi)*sin(theta), Jy=J*sin(varphi)*sin(theta), Jz=J*cos(theta)]) be animated simultaneously with the vibration of molecule (on the same plot). Is it hard to achieve?

File: ClassicalTrajectoriesH2X_morse.mw

 

First 36 37 38 39 40 41 42 Last Page 38 of 71