1 years, 81 days

## How to use sequence in a procedure...

Maple 18

Please how can I define two sequences in a procedure with two arguments?

ans:= Array([seq( [j, doCalc(j, u)], j=-2..0, 0.006, u=1..334)]):

The procedure is doCalc(j,u)  and I received this error: invalid input: seq expects between 1 and 3 arguments, but received 4

Find attached my complete code.Seq_Proc.mw

## How to find the minimum value of the rea...

Maple 18

Please, how do I find the minimum of the real part of a complex function? I tried min ( ) function it didn't work.

Find attached the fileFinding_min_zero.mw

Import packages

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

Parameters

 > gamma1 := .1093: alpha3 := -0.1104e-2: k[1] := 6*10^(-12): d:= 0.2e-3: xi:= -0.01: theta0:= 0.1e-3: eta[1]:= 0.240e-1: alpha:= 1-alpha3^2/(gamma1*eta[1]): c:= alpha3*xi*alpha/(eta[1]*(4*k[1]*q^2/d^2-alpha3*xi/eta[1])): theta_init:= theta0*sin(Pi*z/d): n:= 10:

Assign g for q and plot g

 > g := q-(1-alpha)*tan(q)-c*tan(q): plot(g, q = 0 .. 3*Pi, view = [DEFAULT, -30.. 10]);

Set q as a complex

Assume  and subsitute the result into g and equate the real and complex part to zero, and solve for x and y.

 > f := subs(q = x+I*y, g): b1 := evalc(Re(f)) = 0: b2 := evalc(Im(f)) = 0:

Compute the Special Asymptotes

This asymptote is coming from the  from the definition of

 > qstar := (fsolve(1/c = 0, q = 0 .. infinity)):

Compute Odd asymptote

First, Since , then an asymptote occurs at  In general, we have

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 := abs(`~`[`-`](OddAsymptotes, qstar)); qstarTemporary := min(ModifiedOddAsym); indexOfqstar2 := SearchAll(qstarTemporary, ModifiedOddAsym); qstar2 := OddAsymptotes(indexOfqstar2);
 (4.2.1)

Compute x and y

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

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

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 := sort(Vector[row]([OddAsymptotes, qstar])); if AreThereComplexRoots then gg := [qcomplex1, qcomplex2, op(Roots(g, q = 0.1e-3 .. AllAsymptotes[1])), seq(op(Roots(g, q = AllAsymptotes[i] .. AllAsymptotes[i+1])), i = 1 .. n)]; elif not AreThereComplexRoots then gg := [op(Roots(g, q = 0.1e-3 .. AllAsymptotes[1])), seq(op(Roots(g, q = AllAsymptotes[i] .. AllAsymptotes[i+1])), i = 1 .. n)]; end if:
 (4.4.1)

Remove the repeated roots if any

 > qq := MakeUnique(gg):

Redefine n

 > m := numelems(qq):

Compute the 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;
 (4.7.1)

Minimum of the Re()

 > for i to m do p[i] := min(Re(gamma1*alpha/(4*k[1]*qq[i]^2/d^2-alpha3*xi/eta[1]))); end do;
 (4.7.1.1)
 > ## I expected 0.20459 but return all the entries in the list.

## Francis QR algorithm...

Maple 18

I have tried a code in python for Francis QR algorithm but didn't desire the result. I don't know if it is possible to code in maple.

Given that A^0 = [[3.0, 1.0, 4.0], [1.0, 2.0, 2.0], [0., 13.0, 2]].

1. Write a little program that computes 1 step of Francis QR and test your program by starting from

A^0 = [[3.0, 1.0, 4.0], [1.0, 2.0, 2.0], [0., 13.0, 2]]  and compute A^1, A^2 ...A^6.

I expected to get:

A^0 = [[3.0, 1.0, 4.0], [1.0, 2.0, 2.0], [0., 13.0, 2]],

A^1 = [[3.5,  -4.264, 0.2688], [-9.206, 1.577, 9.197], [0., -1.41, 1.923]],

... A^6 = [[8.056,  1.596, 8.584], [0.3596, -2.01, -7.86], [0., 2.576*10^(-16), 0.9542]].

But didn't get the same results.

Here is my python code:

# Import packages
import numpy as np
from numpy.linalg import qr # QR from Linear Algebra Library
import scipy.linalg   # SciPy Linear Algebra Library

A = np.array([[3.0, 1.0, 4.0], [1.0, 2.0, 2.0], [0., 13.0, 2]])
p = [1, 2, 3, 4, 5, 6]
for i in range(30):
q, r = qr(A)
a = np.dot(r, q)
if i+1 in p:
print("Iteration {i+1}")
print(A)

I would really appreciate your help.

Thank you.

## How use maple to find all roots...

Maple 18

Please, how can I find all the roots  of: (H/(Hc))^2 -(4*q^2)/Pi^2*((tan(q)- q/(1-alpha))/(tan(q)-q)) with q=(i-1)*Pi+Pi/2..i*Pi+Pi/2 for n=20.

See my attempt below:

```restart:with(RootFinding):
a[1] := .1093; k[3] := 7.5*10^(-12); k[2] := 3.8*10^(-12); d := 0.2e-3; eta[1] := 0.240e-1; alpha[2] := -.1104; alpha[3] := -0.1104e-2; eta[2] := .1361; xi := 1.219*10^(-6); alpha := 1-alpha[3]^2/(a[1]*eta[1]); theta[0] := 0.5e-1;
Hc := (Pi/d)*sqrt(k[2]/xi):

H := 5.5*Hc;
lambda := a[1]/(xi*H^2);

RootFinding:-NextZero(proc (q) options operator, arrow; (H/(Hc))^2 -(4*q^2)/Pi^2*((tan(q)- q/(1-alpha))/(tan(q)-q)) end proc, 0);

for j to 9 do RootFinding:-NextZero(proc (q) options operator, arrow; H^2/Hc^2-4*q^2*(tan(q)-q/(1-alpha))/(Pi^2*(tan(q)-q)) end proc, %) end do;```

Error, invalid input: RootFinding:-NextZero expects its 2nd argument, zz, to be of type numeric, but received FAIL

## How to use seq to generate upper triangu...

Maple

restart;
with(LinearAlgebra):
a := .1093;
b[3] := -0.1104e-2;
k[1] := 3.8*10^(-12);
d := 0.2e-3;
xi := -1;
theta0 := 0.1e-3;
eta[1] := 0.240e-1;
alpha := 1-b[3]^2/(a*eta[1]);
c := b[3]*xi*alpha/(eta[1]*(4*k[1]*q^2/d^2-b[3]*xi/eta[1]));

f:= q-(1-alpha)*tan(q)- c*tan(q) ;
plot(f,q=0..4*Pi,view=[DEFAULT,-1..10]):

n:=3:
q[1]:=fsolve(f,q=(0..Pi/2)):
for i from 2 to n do
q[i]:=fsolve(f,q=(2*i-3)*Pi/2..(2*i-1)*Pi/2): ##q[n]
od:

printlevel := 2;
for i from 2 to n+1 do for j from i+1 to n do b[i, j] := int((cos(q[i]-2*q[i]*z/d)-cos(q[i]))*(cos(q[j]-2*q[j]*z/d)-cos(q[j])), z = 0 .. d); b[j, i] := b[i, j] end do end do;

for i from 2 to n do a[i, i] := int((cos(q[i]-2*q[i]*z/d)-cos(q[i]))*(cos(q[i]-2*q[i]*z/d)-cos(q[i])), z = 0 .. d) end do;

for i from 2 to n do f[i] := theta0*(int(cos(q[i]-2*q[i]*z/d)-cos(q[i]), z = 0 .. d)) end do;

## I have generated a matrix using the a[i,i] above
A := Matrix([seq([seq(a[i, j], i = 2 .. n)], j = 2 .. n)]);

b := Vector([seq(f[i], i = 2 .. n)]);

#Please, how do I generate an upper triangular matrix using b[i,j] above?

 1 2 3 4 5 Page 5 of 5
﻿