MaplePrimes Questions

How can this alteration occur by itself and what is the point of doing so? How do I change it back to $\cup$ and $\cap$?

I use "cat" to concatinate greek letters but the output is not correct.test_cat.mw
 

restart; with(linalg); QPT := proc (q) local nc, qp, qpp, i, p, pp; nc := vectdim(q); qp := Vector(nc); qpp := Vector(nc); for i to nc do qp[i] := cat(p, q[i]); qpp[i] := cat(pp, q[i]) end do; return qp, qpp end proc

q := convert([alpha, beta], Vector); QPT(q)

q := Vector(2, {(1) = alpha, (2) = beta})

 

Vector(2, {(1) = palpha, (2) = pbeta}), Vector(2, {(1) = ppalpha, (2) = ppbeta})

(1)

``


 

Download test_cat.mw

 

hi

i have expression like

z:=f0(x) + f1(x)*diff(y(x),x) + f2(x)*diff(y(x),x,x) + f4(x)*diff(y(x),x,x,x,x) ... etc ;

always linear terms diff((y(x),x) etc, never like diff((y(x),x)^2

want vector with coeffs of diff((y(x),x) etc in order low to high so want

<f1(x), f2(x), 0, f4(x) ...>

if z:=f0(x) + f2(x)*diff(y(x),x,x) + f4(x)*diff(y(x),x,x,x,x) ... etc ; want <0, f2(x), 0, f4(x) ...>

first term in vector always for diff((y(x),x)

how to do thanks

 

 

 

 

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);
 

First 384 385 386 387 388 389 390 Last Page 386 of 2308