## Maple 2015 Questions and Posts

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

Ok, so i have this functions

where f(x) represent urban population and g(x) represent the rural population.

And i have to implement an algortihm in Maple to find out after what period of time x the rural population will be with 20% bigger than urban population.

I'm new in Maple and is a little bit hard for me to implement algorithms in this program.If you can help me with any idea, i will really apreciate.Thank you :).

## Finding and printing the sequence of prime number...

Is there a built-in function in Maple 2015 that identifies and prints prime numbers in a specified integer range?

## how to solve a system of trigonometric equations i...

Hi everybody,

I'm kind of new to Maple and i'm trying to solve a system of trigonometric equations inequality as follow:

f:= {((2*a*sin(S)*cos(S)^(2)))/(1-sin(S)^(3))<1,90> S>-90,a>1};

solve(f,{a,S});
Error, (in PiecewiseTools:-Convert) unable to convert

How can I solve the system?

Thanks a lot.

## Remove quote symbols when printing string to file...

I have a code that outputs a long string of mathematics after various string replacements which I save into a file in the format of a Python function. Here is the code (for a 1 x 1 matrix):

restart:
Size:=1:
## This is the matrix which is generated in a string format
mat1:="Matrix(1, 1, [[-1/2*(A^8*hh*m3+6*A^7*B*hh*m3-2*A^7*hh*m3*z3+16*A^6*B^2*hh*m3-14*A^6*B]])":
## Open up file
filename2:=fopen(cat("Matrix", Size, "x", Size,"HH.py"),WRITE,TEXT):

## Format file
fprintf(filename2,"import numpy as np\ndef myfuncHH(A,B):\n    z3 = 2\n    m3 = float('inf')\n    Mat_size = %a", Size):
fprintf(filename2,"\n    arr = np.array([%a",mat1):
fprintf(filename2,"],dtype=np.float64)"):
fprintf(filename2,"\n    shape = ( Mat_size, Mat_size )\n    HH=arr.reshape( shape )\n    return HH"):
fclose(filename2):


This generates almost the exact output that is required:

import numpy as np
def myfuncHH(A,B):
z3 = 2
m3 = float('inf')
Mat_size = 1
arr = np.array(["Matrix(1, 1, [[-1/2*(A^8*hh*m3+6*A^7*B*hh*m3-2*A^7*hh*m3*z3+16*A^6*B^2*hh*m3-14*A^6*B]])"],dtype=np.float64)
shape = ( Mat_size, Mat_size )
HH=arr.reshape( shape )
return HH

The part I want to remove is the "Matrix(1, 1, [   "Maths in here"   ])"]

I can use stringtools to tidy up most of this, but I am having trouble getting rid of the quotes of the string itself. I have tried escaping them and that does nothing. Is there a simple way to do this or will a regex have to be made?

- Yeti

## Transform arbitrary ODE system into first order fo...

Imagine we have an ODE system

odeSys := {diff(x(t),t$2)+diff(x(t),t)+x(t)=f(t),diff(y(t),t$2)+2*diff(y(t),t)+3*y(t)=g(t)};

It is easy to transform this system into a first order form by hand. But for larger systems, the procedure by hand becomes very error prone. Is there an intelligent way to transform a system of n scalar ODEs (order m) into a first order system? I know that the first order form is not unique. It is only important to reduce the system to a system of first order equations.

## Integral of complex function ...

I need to calculate the following complex integral:

oint_C { [(z^4exp(2z)+1)/(z+i)^3] - [(z^3+z)/{(z-2i)(z-5)}] + 8*Pi*exp } dz,

Where C is the circumference |z-1| = sqrt(11/2), positively oriented.

Someone can help me, I already researched but I can not integrate.

## In evaluating an integral Maple outputs a function...

What is the Phi function.  And more importantly how do I find out in general waht a symbol represents.  I input Phi in help menu, nothing useful comes up.  I use Function advisor, don't see a Phi symbol or anything beginning with Phi.  Isn't there a way I can select the symbol in the output and get help on it by pressing a F key?

Ok so I try FunctionAdvisor(describe Phi) - it gives me general Lerch Phi function.  But when I go to help page on LerchPhi, nowhere does it use Greek letter Phi to describe the function.  So I finally figured it out as I was composing this question.  But in why does the help page not use the symbol for the function that is displayed in the worksheet?

## System of partial differential equations with boun...

Hello,

I am trying to solve analytically a simple system of partial differential equations with boundary conditions and I am not able to do it. Even in the very simple case of

pdsolve([diff(u(x, y, t), y, y) = 0, diff(p(x, y, t), y) = 0, u(x, 0, t) = 1, (D[2](u))(x, 1, t) = 0, p(x, 1, t) = 2], [p(x, y, t), u(x, y, t)]);

I don't get any answer.  However if I remove the boundary conditions I get the right answer

pdsolve([diff(u(x, y, t), y, y) = 0, diff(p(x, y, t), y) = 0], [{p(x, y, t), u(x, y, t)}]);
{p(x, y, t) = _F3(x, t), u(x, y, t) = _F1(x, t) y + _F2(x, t)}

Can maple 2015 solve analytically systems of partial differential equations with boundary conditions? I have not been able to find any example anywhere.

Thanks a lot for your help.

Javier

## Error, unable to parse ('local' command)...

Hi, i'm working with some spectral acceleration data and i'm having troubles with a 'local' command on a Newmark method code i found on the internet. I'm not a maple expert so i wish someone could help me. i'm ussing maple 2015. Greetings

Newmark=proc(z0,u0,F0);  local beta,  dt, c, kg,a,b, N, i, dF, dz, du, dw, T, m, k ;        dt:=0.01;    T:=4;    N:=T/(dt);    gam:=0.5;    beta:=0.25;      m:=0.320;    k:=435;    c:=2;   z(0):=z0;   u(0):=u0;   F(0):=F0;   w(0):=(1/(m))*(F0-k*z0-c*u0);        t=vector(i,1);    t[1,1]=0;      for i from 2 to N do :  t(i,1)=t(i-1,1)+dt:  end do:           kg:=k+(gam*c)/(beta*dt)+m/(beta*dt*dt);    a:=m/(beta*dt)+(gam*c)/(beta);    b:=  (0.5*m)/(beta)+dt*((0.5*gam)/(beta)-1)*c;       for i from 2 to N do  dF(i):=diff(F,t)+a*u(i)+b*w(i);    dz(i):=(dF(i))/(kg);    du(i):=((gam*dz(i))/(beta*dt))-((gam*u(i-1))/(beta))+dt*(1-gam/(2*beta))*w(i-1);    dw(i):=((du(i))/(beta*dt*dt))-((u(i-1))/(beta*dt))-((w(i-1))/(2*beta));     z(i+1)=dz(i)+z(i);    u(i+1):=du(i)+u(i);    w(i+1):=dw(i)+w(i);     od;       plot([z(i), u(i), w(i)],x=0..50,y=-50..50);       end;

## AFactor doesn't factor a (supposedly) reducible po...

I have the following Polynomial F. Computing the genus shows that this curve has negative genus and thus is reducible. But using AFactor doesn't produce a factorization. Any ideas?

with(algcurves):
F := z^9+(-3/2+(3/2*I)*sqrt(3))*y^3*z^6+(-3/2-(3/2*I)*sqrt(3))*x^3*z^6+(-3/2-(3/2*I)*sqrt(3))*y^6*z^3+(-3/2+(3/2*I)*sqrt(3))*x^6*z^3+y^9+(-3/2-(3/2*I)*sqrt(3))*x^3*y^6+(-3/2+(3/2*I)*sqrt(3))*x^6*y^3+x^9-3*(x*y*z)^3:
z:=1:
genus(F, x, y);
evala(AFactors(F));


Hello,

I have two simple module's:

1) ------------------------------------------------------------------------

Point := proc(xx::float,yy::float)     return module()         local x := xx,y := yy;         export ShowPoint,GetX,GetY;                  ShowPoint := proc()             printf("Point X,Y -> [%f,%f]",x,y);         end proc;

        GetX := proc()             return x;         end proc;                 GetY := proc()             return y;         end proc;         end module: end proc:

2) ------------------------------------------------------------------------

PointMath := module()     option package;       export +;          + := proc(a::Point(float,float),b::Point(float,float))         option overload;         Point(a:-GetX()+b:-GetX(),a:-GetY()+b:-GetY());     end proc; end module: 

------------------------------------------------------------------------

Next I use first module:

p1:=Point(1.2,1.4);

p2:=Point(1.0,2.0);

Finally I want to add above two points:

with(PointMath)

p2:=p1+p2

The results is:

p2:=p1+p2

Why is not called operator '+' and two points are not added?

Best,

Rariusz

## Monte Carlo simulation of one dimensional harmonic...

I want to use maple2015 to perform a Monte-Carlo simulation of a one dimensional Harmonic Oscillator.

Consider a particle having displacements, x=na where n is an integer, i.e 0 plus minus one, etc.

The potential energy of the particle is given by U(x)= 1/2 kx^2 = 1/2 ka^2 n^2.

For this simulation will choose ka^2 = 0.01 k_B T where k_B is Boltzmann's constant, and T is the temprature in Kelvin.

So we should perform a Monte-Carlo simulation starting from x(0)=20a, and perfroming individual steps by selecting an attmept to move x=+-a ,with equal probability, and choose whether to make the actual step according to energy change expected in that step.

I need to draw particle's position and x(t), and particle's energy E(t).

After that I need to calculate and draw the autocorrelation functions \phi_x(t) and \phi_E(t).

I found some code that might help me, but I am nor sure how to implement the above two lines on maple; your help is appreciated.

http://pubs.acs.org/doi/suppl/10.1021/ed100414p/suppl_file/ed100414p_si_001.pdf

## For and percent...

Each day
a:=a+5% of a -(0.1% of a+b)-10

b:=b+5%of b -(0.1% of a+b)-10
In how many days i have a+b=0?

## How do i modify 3d plot axis?...

All the 3d plot in my maple are upside down.....the tickmarks..the numbering even the lebeling are also upside down...how do i solve it....plz help