85 Reputation

2 Badges

0 years, 328 days

MaplePrimes Activity

These are replies submitted by ijuptilk


Hi Tom,

Please could help me to explain what each of these codes does? Sorry, I like said I'm using maple for such for the first time. 

[ seq( `if`( member( complex(extended_numeric), whattype~({entries(ans[j,5], nolist)})), ans[j,1], NULL), j=1..op([2,1,2], ans))];

member( complex(extended_numeric)
whattype~({entries(ans[j,5], nolist)})) 
ans[j,1], NULL)

Also, how do I get the correspond imaginary p_n for the list the xi-values which return complex entries?


Hi Tom,

Please, how can extract all the xi that give complex values of p_n?


Kindly disregard the last question I asked. I understand now. 

Thank you so much for your assistance. 



In the procedure, you returned 3 outputs: 

min(Re), theta_int , vol_sol;

On plotting min(Re) vs xi, you used 

ans:= Array([seq( [j, doCalc(j)], j=-10..10, 0.4)]):

plot(convert(ans[..,1],list), convert(ans[..,2],list))

If doCalc(j) corresponds to convert(ans[..,2]), and convert(ans[..,2]) corresponds to min(Re).
Why did you use index 2 to access the returned value instead of 1, since min(Re) is the first entry in the return list?


Hi Tomleslie,

Thank you so much. This is exactly what I wanted Please, how can learn, maple at the advanced level?



I want it evaluated for several values of 't' and plotted over a range of z-values, thus producing mulitple curves in a single 2D plot. If so what are the t-values? You plot for t =1..10 with size of 0.1.



The plot theta_int is perfect because it doesn't depend on \xi. My major concern is actually plotting theta_sol and vol_sol.  The theta_sol and v_sol are functions of (z,t). Don't worry about the complex you see, because is the complex and its conjugate, which is real. I will appreciate it if you could plot theta_sol or v_sol for a particular value of \xi. tried to run the code after the changed theta_int to theta_sol. 


Hi Tomleslie,

Thank I really understand how the procedure works now. 

But,  please how do include a plot in the procedure? I have added another code to the earlier codes. I want to plot theta_sol and v_sol  in the code below. I also what the procedure to return Real and Imaginary instead of the only real part.  


Sorry for bugging you. 


Thank you so muc for your assistance


Thank you for your reply. This is my first to using maple extensively, that's why I have to take it bit by bit.  I tried to use

x :=[(seq(0.1*i, i=-10..12))];

pp_min:= [seq (min( seq( Re(gamma1*alpha/(4*k[1]*qq[i]^2/d^2-alpha3*x[j]/eta[1])), i=1..m) ), j= 1..m)];
display(plot(x, pp_min));

to sort the problem. 

However, my supervisor said that is not correct, because I only use one value of xi in qq[i]. So I had to result to define xi using sequence from the beginning and use the result to compute qq[i]. However, I encounter a challenge. I received an error on studentcalculus ().

Find attached the problem:



Import packages


restart: with(ArrayTools): with(Student:-Calculus1): with(LinearAlgebra): with(ListTools):with(RootFinding):with(ListTools):



n:= 5:
gamma1 := .1093:
alpha3 := -0.1104e-2:
k[1] := 6*10^(-12):
d:= 0.2e-3:
x:=[(seq(0.4*i, i=-2..n))];
theta0:= 0.1e-3:
eta[1]:= 0.240e-1:
alpha:= 1-alpha3^2/(gamma1*eta[1]):
c:= seq(alpha3*x[i]*alpha/(eta[1]*(4*k[1]*q^2/d^2-alpha3*x[i]/eta[1])),i=1..n):
theta_init:= theta0*sin(Pi*z/d):

[-.8, -.4, 0., .4, .8, 1.2, 1.6, 2.0]


Assign g for q and plot


g := seq(q-(1-alpha)*tan(q)-c[i]*tan(q), i=1..n):
plot(g[1], q = 0 .. 3*Pi, view = [DEFAULT, -30.. 30]):

Set q as a complex


Assume q = x+I*y and subsitute the result into g and equate the real and complex part to zero, and solve for x and y.

f := seq(subs(q= x+I*y, g[i]), i=1..n ):
b1 := seq(evalc(Re(f[i])) = 0, i=1..n):
b2 := seq(evalc(Im(f[i])) = 0, i=1..n):

Compute the Special Asymptotes


This asymptote is coming from the c from the definition of "q."NULL

qstar := Vector[row]([seq(fsolve(1/c[i] = 0, q = 0 .. infinity),i=1..n), Vector[row](n,shape=zero)]);NULL

Vector[row](%id = 18446744073892603774)



Compute Odd asymptote


First, Since tan*q = sin*q*(1/(cos*q)), then an asymptote occurs at cos*q = 0. In general, we have
"q= ((2 k+1)Pi)/(2). "
Next, we compute the entry of the Oddasymptotes that is close to qstar (special asymptote) as assign it to
ModifiedOaddAsym, and then find the minimum of the ModifiedOaddAsym. Searchall Function returns

the index of an entry in a list.

OddAsymptotes := Vector[row]([seq(evalf((1/2*(2*j+1))*Pi), j = 0 .. n)]);
ModifiedOddAsym := seq(abs(`~`[`-`](OddAsymptotes, qstar[j])),j=1..n);
qstarTemporary := seq(min(ModifiedOddAsym[i]),i=1..n);
indexOfqstar2 := seq(SearchAll(qstarTemporary[i], ModifiedOddAsym[i]),i=1..n);
qstar2 := seq(OddAsymptotes(indexOfqstar2[i]), i=1..n);

OddAsymptotes := Vector[row](6, {(1) = 1.570796327, (2) = 4.712388981, (3) = 7.853981635, (4) = 10.99557429, (5) = 14.13716694, (6) = 17.27875960})


Vector[row](%id = 18446744073892604134), Vector[row](%id = 18446744073892604374), Vector[row](%id = 18446744073892604614), Vector[row](%id = 18446744073892604854), Vector[row](%id = 18446744073892605094)


0.22421550e-1, .825360260, 1.570796327, 1.570796327, 1.570796327


3, 2, 1, 1, 1


7.853981635, 4.712388981, 1.570796327, 1.570796327, 1.570796327


Compute x and y


Here, we solve for xand y within the min. and max. of qstar2 and qstar, and substitute the results into q.

AreThereComplexRoots := type(true, 'truefalse');
   soln1:= fsolve({b1, b2}, {x = seq(min(qstar2[i], qstar[i]) .. max(qstar2[i], qstar[i]), i=1..n), y = 0 .. infinity});
   soln2:= fsolve({b1, b2}, {x = seq(min(qstar2[i], qstar[i]) .. max(qstar2[i], qstar[i]), i=1...n), y = -infinity .. 0});
   qcomplex1 := subs(soln1, x+I*y);
   qcomplex2 := subs(soln2, x+I*y);
   AreThereComplexRoots := type(FAIL, 'truefalse');
end try;






Compute the rest of the Roots


In this section we compute the roots between each asymptotes.

OddAsymptotes := Vector[row]([seq(evalf((1/2)*(2*j+1)*Pi), j = 0 .. n)]);
AllAsymptotes := seq(sort(Vector[row]([OddAsymptotes, qstar[i]])),i=1..n);
if AreThereComplexRoots then
gg := seq([qcomplex1, qcomplex2, op(Roots(g, q = 0.1e-3 .. AllAsymptotes[1])), seq(op(Roots(g[j], q = AllAsymptotes[i] .. AllAsymptotes[i+1])), i = 1 .. n)], j=1..n);
elif not AreThereComplexRoots then
gg := seq([op(Roots(g[i], q = 0.1e-3 .. AllAsymptotes[1])), seq(op(Roots(g[i], q = AllAsymptotes[i] .. AllAsymptotes[i+1])), i = 1 .. n)], j=1..n);
end if;


OddAsymptotes := Vector[row](6, {(1) = 1.570796327, (2) = 4.712388981, (3) = 7.853981635, (4) = 10.99557429, (5) = 14.13716694, (6) = 17.27875960})


Vector[row](%id = 18446744073892608710), Vector[row](%id = 18446744073892608950), Vector[row](%id = 18446744073892609190), Vector[row](%id = 18446744073892609430), Vector[row](%id = 18446744073892609670)


Error, (in Student:-Calculus1:-Roots) unexpected option(s): q = 0.1e-3 .. (Vector[row](7, {(1) = 1.570796327, (2) = 4.712388981, (3) = 7.831560085, (4) = 7.853981635, (5) = 10.99557429, (6) = 14.13716694, (7) = 17.27875960}))


#OddAsymptotes := Vector[row]([seq(evalf((1/2)*(2*j+1)*Pi), j = 0 .. n)]);
#AllAsymptotes := seq(sort(Vector[row]([OddAsymptotes, qstar[i]])),i=1..n);
#if AreThereComplexRoots then
#gg := seq([qcomplex1, qcomplex2, op(Roots(g[j], q = 0.1e-3 .. AllAsymptotes[1])), seq(op(Roots(g[j], q = AllAsymptotes[i] .. AllAsymptotes[i+1])), i = 1 .. n)], j=1..n);
#elif not AreThereComplexRoots then
#gg := seq([op(Roots(g[j], q = 0.1e-3 .. AllAsymptotes[1])), seq(op(Roots(g[i], q = AllAsymptotes[i] .. AllAsymptotes[i+1])), i = 1 .. n)], j=1..n);
#end if;


Remove the repeated roots if any


#qq := MakeUnique(gg):

Redefine n


m := numelems(qq);



Compute the `τ_n`time constants


for i to m do
p[i] := gamma1*alpha/(4*k[1]*qq[i]^2/d^2-alpha3*xi/eta[1]);
end do:


Compute θ_n from initial conditions



for i to m do
Efun[i] := cos(qq[i]-2*qq[i]*z/d)-cos(qq[i]);
end do:

Compute integral coefficients for off-diagonal elements θ_n matrix


printlevel := 2:
for i to m do
    for j from i+1 to m do
       b[i, j] := int(Efun[i]*Efun[j], z = 0 .. d);
       b[j, i] := b[i, j];
       aa[i, j] := b[i, j];
       aa[j, i] := b[j, i];
    end do :
end do:

Calculate integral coefficients for diagonal elements in theta_n matrix


for i to m do
aa[i, i] := int(Efun[i]^2, z = 0 .. d)
end do:

Calculate integrals for RHS vector


for i to m do
F[i] := int(theta_init*Efun[i], z = 0 .. d)
end do:





Download Error_student_calculus_package.mw


Hi Tomleslie,

Please, how can I get various pp for different xi, say xi = -2..5, and then plot pp versus xi?


Great, thanks


Thank so much for this. This actually work, I really appreciate your time and help.


Please, I have edited the problem. I have tried to get rid of the bracket in the list qq in the attached file but I couldn't do that? Please help out. I want it to be listed as [1.585329080, 4.712866768, 7.854047225 ...] instead of  [[1.585329080], [4.712866768], [7.854047225] ...]




Sorry, this is the full problem. The one you just did is not okay, because, there is an error coming from me.  In the below file, I need to append qstar_ve to AllAsymptotes. Then append: Append(qVector, Array(Roots(f, q = AllAsymptotes(i) .. AllAsymptotes(i+1)))) to qVector, and I want the result to be vectors without the brackets. Something like [1 2 3 4 5 6 ...]

Another problem I have is that, if xi = positive  (one of the parameters defined in the file), I will get NULL in the list. Please, how do I get reed of the NULL?


3 4 5 6 7 Page 5 of 7