MaplePrimes Questions

I have made a document to give the results for a problem in table form and graph form.

The tables work out well. The graph results also come out well when I have that section alone in the document. But it does not give the updated curve here. Please correct me where I made mistake.
 

``

 

 

restart

 

Cost in $:     

Present Value:   

Interest in % per year:         ``

``

 Period in years:  

````

``

Additional Months

``

 

 

NULL

NULL

 

Principal $

NULL

Interest % per year

NULL

Year

Present value at the year end

0

``

1

``

2

``

3

``

4

``

5

``

 

 

 

UpdateExpr procedure does not update equation, instead turns out a value on LHS

 

 

Cost:  

Interest % per year (float)  

``

``

 

 

 

``

NULL


Startup Code Region contains all the codes.

Download Doubt_x_symbolic_required.mw

Thanks.

​​​​

RC-Circuit:         (dv_c)/dt=((V(t)-v_c ))/RC 

 

Assume thatV(t)=2 cos⁡(3t),R=4 ,C=0.5 . Use Euler’s method with a step size ofΔt=0.1to approximate the solution of IVP with initial conditionv_c (0)=2over the interval0≤t≤10 .

I can't find anything online on how to use Maple to solve this question, I have attempted it but want to make sure I did it correctly. 

 

Use Maple to plot the approximate solution, the slope field, and (if possible) the exact solution on the same axes. Also compute the error between the approximate solution obtained from Euler’s Method and the exact solution at the right end-point of the given interval.

 1.      dy/dt=(3-y)(y+1)   ,   y(0)=4 ,        0≤t≤5 ,        Δt=1.0

 

 

LP_Matrix.pdf

Hello!

I'm missing something basic here, I'm sure, and would love to know how to proceed.

I have extracted solutions to a particular optimization problem using LPSolve and have obtained the binary solutions in matrix form, for matrices, say .. X and Y.

The solutions are obtained using the routine in the attached pdf; these outputs are sufficient for the basic problem.

Now, I wish to use directed graphs to illustrate the solutions, so I need to take the output matrices to draw the graphs. However, I cannot seem to find a way to do this. The solutions are given, in this case, by 'X' and 'Y'. 

Can anyone advise me on how to extract the matrices that can be used to draw the graphs using with(Graph Theory)?

Thanks in advance ...

Hello,

I use MapleSim to model the dynamics of motorcycles.
I have been at MapleSim2018 for a few months and I have a problem of simplifying the equations generated by MapleSim from my model.
In MapleSim2018, he tells me:

Processing Equations...
SelectCompiler: Check for installed compiler successful
Simplifying system with 8919 equations
DSN/ix1lite: Warning, equation size increased past 100000 while performing equation simplification. Model will be simulated in partially unsimplified form
Simplification removed 8428 equations. Remaining equations: 491
Generating simulation code

 

the same model (exactly the same) in MapleSim2016, he tells me :

Processing Equations...
Simplifying system with 8942 equations
Simplification removed 8494 equations. Remaining equations: 448
Generating simulation code

When I generate code from two versions of Maple (2016 and 2018) and compile it into an executable, the MapleSim 2018 executable runs 20% slower than the MapleSim 2016 version of the executable (the results and the behavior of both models are equivalent)

It is very strange that a new version of MapleSim generates a slower code than the old version. it may be due to the limitation of DSN / ix1lite in MapleSim2018 ... while MapleSim2016 does not have this limitation (with more equations to simplify!).

I need help, if it is possible to activate the complete simplification in DSN / ix1lite?

it is a big problem for me, the use of MapleSim2018 is not possible because of that. My model does not pass in real time.

thanks.

 

> solve({lambda[2]*mu[2]^2*(lambda[2]+mu[2])*lambda[1]/(4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)+lambda[2]*mu[2]*(mu[2]^2+mu[2]*lambda[2]+lambda[2]^2)*lambda[1]/(4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)+mu[2]^4*lambda[2]*lambda[1]/((lambda[1]+mu[2])*(4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4))+(1/2)*(mu[2]^3*lambda[1]+mu[2]^3*lambda[2]+lambda[1]*lambda[2]*mu[2]^2+mu[2]^2*lambda[2]^2+mu[2]*lambda[2]^3+mu[2]*lambda[1]*lambda[2]^2+lambda[1]*lambda[2]^3)*lambda[2]*lambda[1]/((lambda[1]+mu[2])*(4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4))+3*mu[2]^4*lambda[1]/(4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)+mu[1]*mu[2]^4*lambda[1]/((4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)*(lambda[2]+mu[1]))+mu[2]^4*lambda[2]*lambda[1]/((4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)*(lambda[2]+mu[1]))+mu[2]^3*lambda[2]*lambda[1]/(4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)+(1/2)*(mu[2]^3*lambda[1]+mu[2]^3*lambda[2]+lambda[1]*lambda[2]*mu[2]^2+mu[2]^2*lambda[2]^2+mu[2]*lambda[2]^3+mu[2]*lambda[1]*lambda[2]^2+lambda[1]*lambda[2]^3)*lambda[2]*lambda[1]/(4*mu[2]^5+4*mu[2]^4*lambda[1]+4*mu[2]^4*lambda[2]+4*mu[2]^3*lambda[1]*lambda[2]+3*mu[2]^3*lambda[2]^2+3*lambda[1]*lambda[2]^2*mu[2]^2+2*mu[2]^2*lambda[2]^3+2*lambda[1]*lambda[2]^3*mu[2]+mu[2]*lambda[2]^4+lambda[1]*lambda[2]^4)-3*mu[1]*mu[2]^4/(4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)+mu[1]*mu[2]^4*lambda[2]/((4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)*(lambda[2]+mu[1]))+mu[1]^2*mu[2]^4/((4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)*(lambda[2]+mu[1])) < 0}, [lambda[1]]);
Warning, solutions may have been lost
 

Hi, 

Here's a problem that's been bothering me for a long time:

The Statistics[Distribution] help page describes the way to construct one's own Random Variable (RV).
All the examples construct a distribution foo := Distribution(...) next used to define the RV X by typing
X := RandomVariable(foo)

On the other way, constructing a RV Y from predefined Maple's distributions writes 
Y := RandomVariable(bar(sequence of parameters))

The "user defined RV feature" (MyRV := RandomVariable(foo)) seems to be restricted to distributions where all the parameters are numerically instanciated, contrary to "Maple's defined distributions" where these parameters can be kept formal).
So my question: Is it possible to define your own Distribution (module foo) in such a way that the definition of the RV X writes
X := RandomVariable(foo(sequence of parameters))

The attached file contains an example for the Levy distribution (the second part is just a workaround where a substitution is used to balance my inability to define a RV the way above)


 

restart:

with(Statistics):

A particular Levy distribution

Levy Distribution  Levy(m=0, s=1)
m : location parameter
s := dispersion parameter

m := 0:
s := 1:

pdf := unapply(piecewise(x<0, 0, sqrt(s/2/Pi)*exp(-s/2/(x-m))/(x-m)^(3/2)), x);
cdf := unapply(erfc(sqrt(s/2/(x-m))), x);


samplingMethod := proc(N)
                     m +~ s /~ ( Quantile~(Normal(0, 1), Sample(Uniform(1/2, 1), N)) )^~2
                  end proc;

proc (x) options operator, arrow; piecewise(x < 0, 0, (1/2)*2^(1/2)*exp(-(1/2)/x)/(Pi^(1/2)*x^(3/2))) end proc

 

proc (x) options operator, arrow; erfc((1/2)*2^(1/2)*(1/x)^(1/2)) end proc

 

proc (N) `~`[:-`+`](m, ` $`, `~`[:-`/`](s, ` $`, `~`[:-`^`](`~`[Statistics:-Quantile](Normal(0, 1), Statistics:-Sample(Uniform(1/2, 1), N)), ` $`, 2))) end proc

(1)

Levy := Distribution(
                      PDF=(x->pdf(x)),
                      CDF= (x->cdf(x)),
                      RandomSample = (N->samplingMethod(N))
                    );

_m4561537536

(2)

X := RandomVariable(Levy):
PDF(X, x);
Sample(X, 5);

piecewise(x < 0, 0, (1/2)*sqrt(2)*exp(-1/(2*x))/(sqrt(Pi)*x^(3/2)))

 

Vector[row]([.569870365734461, .357020836498979, 39.1445163385190, .340597592385078, 1.23209867072410])

(3)


How should I define a formal Levy distribution in such a way that, as for any predefined RV in Maple,
a particular instance is defined by  X := RandomVariable(Levy(M, S))  
where M and S are numerical values?

m := 'm':
s := 's':

pdf := unapply(piecewise(x<0, 0, sqrt(s/2/Pi)*exp(-s/2/(x-m))/(x-m)^(3/2)), x);
cdf := unapply(erfc(sqrt(s/2/(x-m))), x);
samplingMethod := proc(N)
                     m +~ s /~ ( Quantile~(Normal(0, 1), Sample(Uniform(1/2, 1), N)) )^~2
                  end proc;

proc (x) options operator, arrow; piecewise(x < 0, 0, (1/2)*2^(1/2)*(s/Pi)^(1/2)*exp(-(1/2)*s/(x-m))/(x-m)^(3/2)) end proc

 

proc (x) options operator, arrow; erfc((1/2)*2^(1/2)*(s/(x-m))^(1/2)) end proc

 

proc (N) `~`[:-`+`](m, ` $`, `~`[:-`/`](s, ` $`, `~`[:-`^`](`~`[Statistics:-Quantile](Normal(0, 1), Statistics:-Sample(Uniform(1/2, 1), N)), ` $`, 2))) end proc

(4)

Levy := Distribution(
                      PDF=(x->pdf(x)),
                      CDF= (x->cdf(x)),
                      RandomSample = (N->samplingMethod(N))
                    ):

X := RandomVariable(Levy):
PDF(X, x);
print();

# here is an inelegant workaround

ms := {m=0, s=1};
subs(ms, PDF(X, x));
 

piecewise(x < 0, 0, (1/2)*sqrt(2)*sqrt(s/Pi)*exp(-(1/2)*s/(x-m))/(x-m)^(3/2))

 

NULL

 

ms := {m = 0, s = 1}

 

piecewise(x < 0, 0, (1/2)*2^(1/2)*(1/Pi)^(1/2)*exp(-(1/2)/x)/x^(3/2))

(5)

u := Sample(X, 2);

# The substitution doesn't work

subs(ms, u);

u := Vector[row](2, {(1) = m+HFloat(1.7545213270590625)*s, (2) = m+HFloat(0.332342758403606)*s})

 

Vector[row]([m+1.75452132705906*s, m+.332342758403606*s])

(6)

# just a copy-paste of lprint(u): the substitution does work


lprint(u);

subs(ms, Vector[row](2, {1 = m+HFloat(2.49542958430755446)*s, 2 = m+HFloat(4.80772083491271562)*s}, datatype = anything, storage = rectangular, order = Fortran_order, shape = []))

Vector[row](2, {1 = m+HFloat(.529024707466874800)*s, 2 = m+HFloat(1.50334452451578438)*s}, datatype = anything, storage = rectangular, order = Fortran_order, shape = [])

 

Vector[row]([2.49542958430755, 4.80772083491272])

(7)

 


 

Download My-own-random-variable.mw

Suppose that we have a set of differential equations as follows

and we want to write the above equation as a matrix form  ( for convenience, Let upper limit of summations be 2, not infinity )

 

 

QUESTION: How to find the coefficients of Matrix Dif. equations (matrices M, C, K, f, D) by MAPLE? MY TRY: question.mw

We can find the matrices by hand as follows: (But how to derive the matrices directly from the equation in the first picture by Maple)


 

 

 

 

restart:with(LinearAlgebra):with(plots):interface(rtablesize=36):  
with(Physics): #for KroneckerDelta
   
N:=2:
p:=2:
A:=Matrix(N,1):
B:=Matrix(N,1):
for n from 1 to N do 
A(n,1):=diff(phi[n](t),t,t)+2*gamma*add(sin(n*Pi*v0*tau)*sin(j*v0*Pi*tau)*diff(phi[j](tau),tau,tau),j=1..N)+4*gamma*Pi*v0*add(j*sin(n*Pi*v0*tau)*cos(j*v0*Pi*tau)*diff(phi[j](tau),tau),j=1..N)+n^4*Pi^2*phi[n]-2*gamma*add( (j*Pi*v0^2)*sin(n*Pi*v0*tau)*sin(j*v0*Pi*tau)* phi[j](tau),j=1..N):
end do: 
B:=Matrix(N,1):
for n from 1 to N do 
B(n,1):=gamma*Pi^3/2*sin(n*Pi*v0*tau)+add( U[i](tau)*sin(n*Pi*eta[i]),i=1..p):
end do:
# in order to make ensure, let's look backwards

r:=2:

M:=Matrix(r,r):
C:=Matrix(r,r):
K:=Matrix(r,r):
for n from 1 to r do
for j from 1 to r do  
M(n,j):=KroneckerDelta[n,j]+2*gamma*sin(n*Pi*v0*tau)*sin(j*Pi*v0*tau);
C(n,j):=4*gamma*Pi*v0*j*sin(n*Pi*v0*tau)*cos(j*Pi*v0*tau):
K(n,j):=n^4*Pi^2*KroneckerDelta[n,j]-2*gamma*(j*Pi*v0)^2*sin(n*Pi*v0*tau)*sin(j*Pi*v0*tau):
end do:
end do:
f:=Matrix(r,1):
X:=Matrix(r,1):
U:=Matrix(r,1):
for n from 1 to r do
f(n,1):=gamma*Pi^3/2*sin(n*Pi*v0*tau);
X(n,1):=phi[n](tau):
U(n,1):=u[n](tau):
end do:
DD:=Matrix(r,p):
for n from 1 to r do
for i from 1 to p do 
DD(n,i):=sin(n*Pi*eta[i]);
end do:
end do:  
 M*diff(X,tau,tau)+ C*diff(X,tau)+ K*X=f+DD.U;

quest.mw

Hi, I'm stuck on how to create a procedure, 'Arrange' that sorts a list of integers so that the numbers go from smallest to largest. So if I have a list such as: [3,6,1,9,0,4] ,

Arrange([3,6,1,9,0,4]) = [0,1,3,4,6,9]

I have a procedure that produces a sequence where we denote 'x' as the first number in the list, and returns: a list of all the numbers in the list less than x, x, a list of all the numbers greater than x.

i.e. returns: [1, 0], 3, [6, 9, 4]

Arrange := proc(L)
local L1,L2,n,x,i;
L1:=[];
L2:=[];
n:=nops(L):
if n=0 then
print('NULL')
elif n=1 then 
return L[1];
elif n>1 then
x:= L[1];

for i from 2 to n do 
if L[i] < x then
L1:=[L1[],L[i]]:
else 
L2:=[L2[],L[i]]:

end if:
end do:
end if:
return L1,x,L2;

end proc:

could anyone help on how I can expand on this to get the procedure that I want?

 

p.s. I know that there is already an inbuilt 'sort' function in Maple, but I'm trying to create the procedure myself!
 

Good day.

I have a problem with the numerical approximation of incomplete elliptic integrals of the first kind in the case when the argument and the modulus are complex numbers. 

Let's consider an incomplete elliptic integral of the first kind EllipticF((a+I*b)*x, c+I*d), where a,b,c,d are arbitrary real numbers and x is very large number. Here is the code:

restart;
R0 := EllipticF((a+I*b)*x, c+I*d);
with(MultiSeries, series):
R1 := series(R0, x = infinity, 2);
a := .5; b := 1.75; c := 10; d := 12.5; x := 10^6;
evalf(R0); evalf(R1);

Below you can see that answers are different

.1680611942+.2058775337*I
-0.4563467782e-1-.3592094173*I+O(1/1000000000000000000)

While the same code for an incomplete elliptic integral of the second kind gives the correct approximation:

restart;
R00 := EllipticE((a+I*b)*x, c+I*d);
R11 := series(R00, x = infinity, 2);
a := .5; b := 1.75; c := 10; d := 12.5; x := 10^6;
evalf(R00); evalf(R11);
-1.687498740*10^7+2.374999011*10^7*I
-1.687501260*10^7+2.375000989*10^7*I+O(1/1000000)

What is the difference?
 

I have a question that concerns visualising the output of a simple matrix. For instance, take a 4 x 10 matrix in the example attached (rows are denoted by i and columns, j) with entries either 0 or 1. This gives the on/off relationship between any i and j. Let i and j denote 2-dimensional locations whose coordinates are known. The matrix gives the connections (1's) between both locations; 0's otherwise.

Can Maple output a map that visually represents the connections between nodes?

In the example here, I wish to plot location 2 (in i) connected to location 3 (in j), location 3 (in i) connected to location 1 (in j), and so on. Can I output a plot / map that presents the nodes with radiating / connecting arrows?

I'm hoping someone can help, since the matrix form is not quite appealing for a large number of entries.

 

Thanks for reading!
 

restart

A := Matrix(4, 10, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (1, 6) = 0, (1, 7) = 0, (1, 8) = 0, (1, 9) = 0, (1, 10) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 1, (2, 4) = 1, (2, 5) = 0, (2, 6) = 1, (2, 7) = 0, (2, 8) = 0, (2, 9) = 0, (2, 10) = 1, (3, 1) = 1, (3, 2) = 1, (3, 3) = 0, (3, 4) = 0, (3, 5) = 1, (3, 6) = 0, (3, 7) = 1, (3, 8) = 1, (3, 9) = 1, (3, 10) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = 0, (4, 5) = 0, (4, 6) = 0, (4, 7) = 0, (4, 8) = 0, (4, 9) = 0, (4, 10) = 0})

 

``


 

Download Matrix_Plot_Question.mw

 

Hello dear freinds

when i solve the ode i found exponential solutions.i want to find trignometric solutions of an ode.

I am attaching maple file..

Thanks for ur cooperation.file.mw

Hi,

the foolowing code is for contour plot at Delta =-12.71 but there is somthing coulnd understand not works

I dont know why this not work

 

restart:
with(plots):

Omega:=0:lambda:=1:
gamma1:=8*Pi:
gamma2:=0.002*Pi:
x1:=100*Pi:
omega2:=200*Pi:
gamma0:=0.2*Pi:
G:=20*Pi:

lambda1:=(1/(2*Pi))*(G*Omega*gamma0/(2*(0.25*gamma0^2+Delta^2))):
lambda2:=(1/(2*Pi))*(-G*Omega*Delta/((0.25*gamma0^2+Delta^2))):
lambda3:=(1/(2*Pi))*gamma1+lambda1:
lambda4:=(1/(2*Pi))*(lambda*Delta-G^2*Delta/(0.25*gamma0^2+Delta^2)):
lambda5:=(1/(2*Pi))*(2*x1^2*omega2/((omega2^2+gamma2^2))):
f:=epsilon=(lambda1+sqrt(-lambda2^2+Y^2*(lambda3^2+(lambda4-lambda5*Y^2)^2))):

implicitplot3d(f, epsilon=0..20,Y = 0 .. 1,Delta=-40*Pi..40*Pi, labels=[epsilon,X,Delta],tickmarks=[3,3,3],style=surface);

contourplot(solve(f,Delta),epsilon=-20..20,Y=0..1,contours=[-12.71],axes=boxed,thickness=2,color=black,font=[1,1,18],tickmarks=[2, 2],linestyle=1, numpoints=50000);

First 593 594 595 596 597 598 599 Last Page 595 of 2308