Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Dear Community,

I have a four compartment flow model described with the following system of linear ODEs:

diff(L[1](t), t) = L[2](t)/T[21] - L[1](t)/T[12]

diff(L[2](t), t) = L[1](t)/T[12] - L[2](t)/T[21] + L[3](t)/T[32] - L[2](t)/T[23] + Q(t)

diff(L[3](t), t) = L[2](t)/T[23] - L[3](t)/T[32] + L[4](t)/T[43] - L[3](t)/T[34]

diff(L[4](t), t) = L[3](t)/T[34] - L[4](t)/T[43]

(For easier readability I’ve also described the problem in the attached FourCompartmentModelDescription.docx Word file.)

 

The time constants are as follows:

T12 = 23.1481 d

T21 = 5.4537 d

T23 =  9.752 d

T32 = 14.9007 d

T34 = 8.8235 d

T43 = 363.7255 d

Initial conditions are as follows:

L1(0) = 2500.

L2(0) = 589.

L3(0) = 900.

L4(0) = 37100.

Simulation should run from 0 to 400 d.

Could you pls. help me, to solve it numerically in Maple? As a solution I would need L1(t), L2(t), L3(t) and L4(t) both numerically and graphically. I used Maple to solve ODEs previously, but this time I don’t know, how to correctly specify the problem with an external, tabulated source. I’ve also prepared and attached a Maple worksheet, but did not try to run it yet. (FourCompartments.mw). The external Q(t) source for compartment 2 is attached as Source.xlsx. Should I've forgotten something, pls. let me know.

Your kind help is appreciated in advance,

best regards

Andras

 

MaplePrimesFourCompartmentModelDescription.docx

FourCompartments.mw

Source.xlsx

I'm trying to put image in my maplet interface.

I use this following code

Label(Image(cat(currentdir(),"\\Image Folder\File name.png")))

The code work as well when i run the code in worksheet. But it doesn't work since i export the worksheet to .maplet file.

Please help. Thank you

Hello,

I would like to know if it is possible to Fit data to an expression using NonlinearFit, but in this expression there is a variable that is the result of dsolve and the contains parameters I need to identify.

with(LinearAlgebra):
tensF:=Matrix([[lambdaTrig,0,0],[0,1/sqrt(lambdaTrig),0],[0,0,1/sqrt(lambdaTrig)]]):
tensdF:=diff(tensF,t):
tensFDev:=tensF-(1/3)*Trace(tensF)*Matrix(3,shape=identity):
tensB:=Multiply(tensF,Transpose(tensF)):
tensL:=Multiply(tensdF,MatrixInverse(tensF)):
tensD:=(1/2)*(tensL+Transpose(tensL)):
tensBe:=Matrix([[Be11(t),0,0],[0,1/sqrt(Be11(t)),0],[0,0,1/sqrt(Be11(t))]]):
tensdBe:=diff(tensBe,t):
tensBeDev:=tensBe-(1/3)*Trace(tensBe)*Matrix(3,shape=identity):

Above are the tensors I need in the expression.

Then there is the equation to solve. I tried something with "proc", I found on Maple Help Page.

ode:=tensdBe[1,1]=-(2/3)*tensBe[1,1]*Trace(tensD)+Multiply(tensL[1,1],tensBe[1,1])+Multiply(tensBe[1,1],Transpose(tensL[1,1]))-(2/eta)*a*Multiply(tensBeDev[1,1],tensBe[1,1]): ivp:=[ode,Be11(0)=1]: 
ode_sol:=dsolve(ivp,numeric,parameters=[a,eta]); 
ode_sol(parameters=[a=1,eta=0.1]); 
Be11Num:=proc(aValue,etaValue) global ode_sol,a,eta,t; ode_sol('parameters'=[a=aValue,eta=etaValue]); end proc;

Then I built the expression I need to fit :

tensTemp1:=2*C1*tensB+4*C2*(Trace(tensB)-3)*tensB+6*C3*(Trace(tensB)-3)*tensB-2*C4*MatrixInverse(tensB):
tensTemp1Dev:=tensTemp1-(1/3)*Trace(tensTemp1)*Matrix(3,shape=identity):
tensBe:=Matrix([[Be11Num,0,0],[0,1/sqrt(Be11Num),0],[0,0,1/sqrt(Be11Num)]]):

tensTemp2Dev:=2*G*tensBe-(1/3)*Trace(2*G*tensBe)*~Matrix(3,shape=identity):
sigma:=tensTemp1Dev+tensTemp2Dev-p*~Matrix(3,shape=identity):
p:=sigma[2,2]+p: 
sigma:=tensTemp1Dev+tensTemp2Dev-p*~Matrix(3,shape=identity): 
PK:=sigma.Transpose(MatrixInverse(tensF)):
PK:=PK[1,1]: #expression  to fit

Then I tried to fit

NonlinearFit(PK,t1Expe,PK1Expe,t,output=[parametervalues,residualsumofsquares]);

The problem is that the result is

[[Be11Num = 1.00001503587671, C1 = 0.588252936860393, C2 = 6091.63136742778, C3 = -4061.11176413018, C4 = -0.494824008942008, G = 1409.06089189383], 17.90514021]

It's computing the solution Be11 but I can't get the value of the parameters a and eta. Moreover Be11 is depending on t, so it seems I only get the last value.

What do you think, is it possible to do what I just explained ?

Thnak you in advance,

Manon

interface(prettyprint=2):
with(ListTools):
with(StringTools):
for xx from 1 to 2 do
xx := 1:
Source := FileTools[Text][ReadFile](cat("C:\\hello\\probability1-200-26042020\\home\\probability",xx,"\\probability",xx,".txt")):
openindex := [SearchAll("[",Source)]:
endindex := [SearchAll("]",Source)]:
beforefiltered := []:
for mm from 1 to nops(openindex) do
if mm > 27 then
beforefiltered := [op(beforefiltered), Chop(substring(Source, openindex[mm]..endindex[mm]))]:
end if:
od:
afterfiltered := []:
for mm in beforefiltered do
if Has(mm,"--") or Has(mm,"|") or Has(mm,"{") or Has(mm,"}") then
dummy := 0:
elif Has(mm,"Root") then
dummy := 0:
else
afterfiltered := [op(afterfiltered),mm]:
end if:
od:
afterfiltered[1];

however after chop still has new line, can not make a beautiful csv format, 

"[b(t,k)+ a
(t,k)*
x(t,k)]"

# I try to export to text first and then use Excel to use "|" as delimiter instead comma as delimiter,
#because b(t,k) has comma "," will separate to open a new column

appendto("C:\\Users\\Student\\Documents\\IQ1-200csv.txt"):
for mm in afterfiltered do
AA := parse(mm):
lprint(xx,"|","hello := [","|",AA[1],"|",AA[2],"|","]:");
od:
od:

Expect csv in format
1,b(t,k)+a(t,k)*x(t,k)
2,a(t,k)+s(t,k)*z(t,k)

I have an integral of a sum

Int(Sum(-(Nb*t-n*t__rev)*exp((1/2)*(L+sqrt(-4*C*L*R^2+L^2))*t/(L*R*C)-(1/2)*(Nb*t-n*t__rev)^2/(Nb^2*sigma__b^2)), n = 0 .. Nb-1), t);

that I want to convert into a sum of integrals since Maple will not integrate the sum but it will integrate the summands. I tried IntegrationTools, but none of these tools seem to do it. It is a part of a larger expression so doing this by hand is not a real option.

Mac Dude.

General question: I write integer sequences in Maple (often with your help).
 

Once I have a working code, able to output any chosen number of terms, is there a standard way to modify the code so as to get a graph (eg linear linear or linear log, etc...)? 
 

Here is an example : 

 

A[1]:=1: P:=0; Q:=0; # P counts primes, Q non primes.

for n from 1 to 100 do

if not isprime(A[n]) then

Q:=Q+1;

A[n+1]:=Q;

else P:=P+1;

A[n+1]:=P;

fi

od:

[seq(A[i], I=1..1000)];

1,1,2,1,3,2,3,4,4,5,5,6,67,7,8,8,9,10,11,9....

The code gets the right data and I would like to make graphs of it. Is it possible to modify the code for this?

Thanks in advance

David.

I'm trying to compute a sliding average for a pulse width modulated signal. The code starts with an example for a signal x.

---

x:=10+1.5*t+3*sin(30*t+2);   #This is an example signal


X_avg:=1/0.5*int( eval(x,t=tau), tau=(t-0.5)..t );   #This is the computation of the sliding average over a period of 0.5

---

This works fine as in the following figure.

Now I try to create a pulse width modulated (PWM) signal with a duty cycle D_ and a triangular carrier signal as in the following

---

with(DynamicSystems):

s__TR := Triangle(1, 20e3, 1/2, 0, 0, hertz = true);

s__PWM := 1/2*( 1+signum( D_ - s__TR ) );

---

This creates the PWM signal as expected and seen in the following figure.

However, when I ask Maple to compute the sliding average of s__PWM as in the following, it gives me an answer based on the integral. But then when I ask it to plot the result it starts computation and never stops.

---

s__avg := evalf( f*Int( evalf(eval(s,[t=tau])) , tau = (t-1/f)..(t) ) );

plot([ eval(s__TR,[f=20e3]), eval(s__SQ1,[f=20e3,D_=0.2]), eval(s__avg,[f=20e3,D_=0.2]), 0.2], t=0..200e-6, color=[blue,red,green, cyan], legend=["Triangular carrier","PWM signal", "Sliding average", "Duty cycle"]);

---

I've attached a file with the Maple code.

Anybody could help me with suggestions/corrections?

I am trying to create the image shown below in Maple.

I am able to created the nodes and edges fairly easily. I would like to know how to add the labels to each edge, formatted as shown, and more importantly, have the edges decorated with the arrows, also as shown. I've tried playing around with digraphs, but I'm not really getting the desired look. I've attached my attempt and welcome any suggestions as to how to improve what I've done so far, as well as achieve my goal.

network.mw

Hello,

I'm trying to write units in Maple but it seems to not be working for certain things.  For example, I would like to express the quantity of 0.78 kg CO2/ kg.  While kg is recognized, CO2 is not.  Is there some sort of workaround? Other examples include things such as "mol He". 

Thanks

I am trying to plot the equation diff(P(t),t) = P(t)*(7-P(t))-10 on a direction field but I keep getting this error code: Error, (in DEtools/DEplot/CheckDE) extra unknowns found: YP[2].

This is what i have entered in:    

DEplot(diff(P(t),t) = P(t)*(7-P(t))-10,P(t),t=-10..10,P=-10..10,scene=[P,P(t)],conditions,number=1, stepsize=.01);
 

Hello, I found this very strange behavior in Maple and I can't explain why this is not working

A little bit of context first:

1. I placed a polygon as a boundary for a section and then two polygons that correspond to inner holes to the first one.
2. Then I proceed to create a regular mesh that places N x M points spread across the region (OK here)
3. A procedure checks weather or not a Point is inside the region, on the borders or in the inner holes (OK here)
4. Then I want to select the closest (but exterior) ones so I can create a path using the mesh points.
 

Here is where I find the issue. I start at a vertex called V[1,1] and I want to arrive at V[1,2] (in the document they are blue solid points marked they are near-vertices near the original polygons). The procedure that I apply finds a path towards the V[1,2] as I was expecting but when the procedure hits the V[1,2] coordinates the while loop does not stop

The condition I wrote was:    while point<>V[1,2] do  where 'point' is correctly generated by another procedure.

This happens in a 40 by 50 mesh but with other configurations it works properly (there are also another kind of errors but it's inherent to lack of optimization in my procedures).

What baffles me is why doesn't it stop the cycle, if I test the condition outside the loop it DOES recognize the points are indeed equal. Is it something in Maple or is it something in my PC?

Thanks to anyone who can see the error or the problem because I don't understand the nature of the problem.

Not_Working.mw

Hello, I am new to Maple. Can somebody tell me what is the reason of maple being unable to integrate my equation in dsolve on dsolve2? when I try to use dsolve for solve my equation in answer of maple there are expressions of integral that is not calculated, and how to handle it?

 

Thank you

 

At my first steps in vectorcalculus i calculating a scalar line integral, but the concept how to do this is not  yet clear to me 

ecxample_4_-_blz407_toegepaste_wiskunde.mw

https://drive.google.com/file/d/1K5mnfCAB_zSzLGNNz1rkUyjvRhCgpFi4/view?usp=sharing

 

First 378 379 380 381 382 383 384 Last Page 380 of 2097