acer

32333 Reputation

29 Badges

19 years, 320 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Yes, that's one of the main points about "loading" a package using the with command. It rebinds the names of its exports.

You can still access the original "global" name by using the colon-dash syntax in your own entered/parsed code. For example,

restart;

f := x^11 + 2*x^9 + 2*x^8 + x^6 + x^5 + 2*x^3 + 2*x^2 + 1;

x^11+2*x^9+2*x^8+x^6+x^5+2*x^3+2*x^2+1

g := 2*x^10 + x^7 + 2*x^4 + x;

2*x^10+x^7+2*x^4+x

Gcd(f, g) mod 3;

x^9+2*x^6+x^3+2

with(Algebraic);

[Content, ConvertRootOf, Degree, Divide, Expand, ExtendedEuclideanAlgorithm, Gcd, Gcdex, GetAlgebraics, GreatestCommonDivisor, MakeMonic, Normal, PrimitivePart, PseudoDivision, Quotient, Reduce, Remainder, Resultant, Squarefree]

Gcd(f, g) mod 3;

x^6+1

:-Gcd(f, g) mod 3;

x^9+2*x^6+x^3+2

Download pkg_rebinding.mw

Note that instances of the name Gcd in procedures already (before the rebinding) saved in a .mla archives are not affected -- they were saved with the original name, whose value you have not reassigned. So merely loading the package doesn't change the value of the instances of the these global names inside the procedures of, say, stock Maple commands.

ps. I changed your query from a Post into a Question.

Is this the kind of this you're after?

I ran this in Maple 16.02, but perhaps you are running Maple 12?

The 3D plot seems to show that (for any value of Zstub in its given range) the maximal value of Gamma is attained at one of the end-points: either f=f1 or f=f2. And you seem to want to find the Zproc that minimizes that maximum. That seems to occur at Zstub=Z[N]. But, even so, you may still wish to compute that via the nested optimization, as opposed to merely observing where it occurs on the 3D plot.

restart:
with(plots):
Digits := 15:
with(linalg):
j := sqrt(-1):

RL := 26; #dB
Gamma_m := evalf(10^(-RL/20)); #unitless, min req'd
f1 := 1.9;
f2 := 6.3;
f0 := evalf((f1+f2)/2);
BW := evalf((f2-f1)/f0);
ZS := 50/16;
ZL := 50;

26

0.501187233627272e-1

1.9

6.3

4.10000000000000

1.07317073170732

25/8

50

Chebyshev

 

# A NEW WAY OF FINDING 'N'
theta_m := 'theta_m':
N := 'N':
theta_m := solve(BW=2-4*theta_m/Pi,theta_m);
BW := evalf(2-4*theta_m/Pi);  # used at the end to find shoulders (could maybe use 0..f0 and f0..f2+f0/2 instead
N := solve(sec(theta_m)=cosh((1/N)*arccosh(abs(ln(ZL/ZS)/(2*Gamma_m)))),N);
printf("N = %g yields RL = %g\n", floor(N),
  20*log10(abs(fsolve(sec(theta_m)=cosh((1/floor(N))*arccosh(abs(ln(ZL/ZS)/(2*Gamma)))),Gamma=Gamma_m))));
printf("N = %g yields RL = %g\n", ceil(N),
  20*log10(abs(fsolve(sec(theta_m)=cosh((1/ceil(N))*arccosh(abs(ln(ZL/ZS)/(2*Gamma)))),Gamma=Gamma_m))));

.727930005100072

1.07317073170732

5.00158254780052

N = 5 yields RL = -25.989
N = 6 yields RL = -32.9555

N := ceil(N);
# calculate new resulting Gamma_m
Gamma_m := abs(solve(sec(theta_m)=cosh((1/floor(N))*arccosh(abs(ln(ZL/ZS)/(2*Gamma)))),Gamma)[1]);

6

0.225022725352146e-1

# ONLY NEEDED IF GAMMA_M SOLUTION FAILS ABOVE
#plot([sec(theta_m),cosh((1/floor(N))*arccosh(abs(ln(ZL/ZS)/(2*Gamma))))],Gamma=0..2);

# ONLY NEEDED IF GAMMA_M SOLUTION FAILS ABOVE
#Gamma_m := abs(fsolve(sec(theta_m)=cosh((1/floor(N))*arccosh(abs(ln(ZL/ZS)/(2*Gamma)))),Gamma=0..2));

theta_m := solve(sec(theta)=cosh((1/N)*arccosh(abs(ln(ZL/ZS)/(2*Gamma_m)))),theta);

.727930005100076

G := 'G':
n := 0:
Gamma :=
  `if`(
    type(N,odd),
    eval(2*exp(-I*N*theta)*(sum('G[n]*cos((N-2*n)*theta)','n'=0..(N-1)/2-1)+G[(N-1)/2]*cos(theta))),
    eval(2*exp(-I*N*theta)*(sum('G[n]*cos((N-2*n)*theta)','n'=0..N/2-1)+G[N/2]/2))
  ):

Tsc := combine(simplify(ChebyshevT(N,sec(theta_m)*cos(theta)),'ChebyshevT')):

Gamma/exp(-I*N*theta)=Gamma_m*Tsc:  # note Gamma_m = |A|

G := 'G':
eq1 := Gamma/exp(-I*N*theta):
eq2 := Gamma_m*Tsc:
for n from 0 to trunc(N/2)-1 do
  G[n] := solve(coeff(Gamma/exp(-I*N*theta),cos((N-2*n)*theta))=coeff(Gamma_m*Tsc,cos((N-2*n)*theta)),
              G[n]);
  eq1 := eq1-coeff(Gamma/exp(-I*N*theta),cos((N-2*n)*theta))*cos((N-2*n)*theta);
  eq2 := eq2-coeff(Gamma_m*Tsc,cos((N-2*n)*theta))*cos((N-2*n)*theta);
end do:
G[trunc(N/2)] := solve(eq1=eq2,G[trunc(N/2)]):
for n from trunc(N/2)+1 to N do
  G[n] := G[N-n];
end do:
'Gamma[n]' = seq(G[n],n=0..N);

Gamma[n] = (0.649877859143785e-1, .172604292049981, .287211372499400, .336687460192378, .287211372499400, .172604292049981, 0.649877859143785e-1)

Z := 'Z':
#Z[1] := solve(ln(Z[1])=ln(ZS)+2*G[0],Z[1]):
Z[1] := evalf(exp(ln(ZS)+2*G[0])):
seq(assign(Z[n],solve(ln(Z[n])=ln(Z[n-1])+2*G[n-1],Z[n])),n=2..N);
'Z[n]' = seq(Z[n],n=1..N);
# GETS Z1 CLOSE, BUT ZN IS BAD <-- 9/15/09 - is this comment old or still valid?

Z[n] = (3.55875176303013, 5.02596984406875, 8.92664999631936, 17.5037668178350, 31.0885271594686, 43.9058440724061)

# tuning limits for optimizer
chvZtunlim := [sqrt(ZS*Z[1]),seq(sqrt(Z[n]*Z[n+1]),n=1..N-1),sqrt(Z[N]*ZL)];

[3.33483121903781, 4.22920548608316, 6.69813956931755, 12.5000000000001, 23.3273729791691, 36.9454736862906, 46.8539454434768]

Zin := ZL:
Zin_save := ZL:
for i from 0 to N-1 do
  Zin := simplify(Z[N-i]*(Zin_save+I*Z[N-i]*tan(E))/(Z[N-i]+I*Zin_save*tan(E))):
  Zin_save := Zin: # used for iteration when just plugging Zin back in doesn't work
end do:

#Zin; # should be univariate function of E

E := (Pi/2)*(f/f0): # assuming vp has no strong f-dependence
Gamma := abs((Zin-ZS)/(Zin+ZS)):

# THIS STEP COMMENTED OUT BECAUSE IT TAKES EXTREMELY LONG TO COMPUTE
# ATTEMPTING TO CALCULATE AND PLOT RESPONSE OF FILTERS WITH N > 4 MAY
# CAN SOMETIMES CAUSE MAPLE TO CRASH OR RUN OUT OF MEMORY
#if f0*(1-BW) < 0 then
#  plot(20*log10(Gamma),f=0..f0*(1+BW),y=-50..0,labels=["freq [GHz]","Gamma [dB]"],labeldirections=[horizontal,vertical])
#else
#  plot(20*log10(Gamma),f=f0*(1-BW)..f0*(1+BW),y=-50..0,labels=["freq [GHz]","Gamma[dB]"],labeldirections=[horizontal,vertical])
#end if;

 

Optimization

 

# ADDED 3/28/22
# assumes Lstub = Pi/2
with(Optimization):
ZSp := (1/ZS+1/Zstub*(1+exp(-2*j*Pi/2*f/f0))/(1-exp(-2*j*Pi/2*f/f0)))^(-1); # create parallel connection of stub and inputs

1/(8/25+(1+exp(-(.243902439024390*I)*Pi*f))/(Zstub*(1-exp(-(.243902439024390*I)*Pi*f))))

# INSERT STUB INTO CURRENT TRANSFORMER STRUCTURE
Zin := ZSp:
Zin_save := ZSp:
for i from 1 to N do
  Zin := simplify(Z[i]*(Zin_save+I*Z[i]*tan(E))/(Z[i]+I*Zin_save*tan(E))):
  Zin_save := Zin: # used for iteration when just plugging Zin back in doesn't work
#  print(evalf(subs(Zstub=Z[2],f=f1,Zin)));
end do:
#Zin;

# NEW GAMMA, WITH STUB
Gamma := abs((Zin-ZL)/(Zin+ZL)):

#plot(abs(subs(Zstub=Z[2],Zin)),f=f1..f2);

# QUICK VISUAL ON HOW IT LOOKS, SHOULD ZERO AT MID-BAND
if f0*(1-BW) < 0 then
  plot([seq(subs(Zstub=Z[k],20*log10(Gamma)),k=1..N)],f=0..f0*(1+BW),labels=["freq [GHz]","Gamma [dB]"],
    labeldirections=[horizontal,vertical],legend=[seq(k,k=1..N)])
else
  plot([seq(subs(Zstub=Z[k],20*log10(Gamma)),k=1..N)],f=f0*(1-BW)..f0*(1+BW),labels=["freq [GHz]","Gamma [dB]"],
    labeldirections=[horizontal,vertical],legend=[seq(k,k=1..N)])
end if;

# original check of internal optimization
NLPSolve(subs(Zstub=Z[2],Gamma),f=f1..f2,maximize);

[HFloat(0.37527715549854496), [f = HFloat(1.9000000131130221)]]

Gammaproc := unapply(Gamma,[f,Zstub],numeric):

bandpeak := proc(p)

  local f, sol:
  if not p::numeric then return 'procname'(p); end if;

  sol := NLPSolve(Gammaproc(f,p),f=f1..f2,
                        #'evaluationlimit'=100,
                        'method'=':-branchandbound','maximize'
                        );
  if sol[1]::numeric then

    return sol[1];
  else
    return Float(undefined);
  end if;

end proc:

bandpeak(5);

.376658504439654651

sol := NLPSolve(bandpeak(Zstub), Zstub=Z[1]..Z[N],
                      method=sqp, initialpoint = [Zstub=Z[2]]);

Warning, limiting number of evaluations reached

Warning, limiting number of evaluations reached

Warning, limiting number of evaluations reached

Warning, limiting number of evaluations reached

Warning, limiting number of evaluations reached

Warning, limiting number of evaluations reached

Warning, limiting number of evaluations reached

Warning, limiting number of evaluations reached

Warning, limiting number of evaluations reached

[.111740781972700001, [Zstub = HFloat(43.9058440724061)]]

bandpeak(eval(Zstub,sol[2]));

.111740781972700085

temp := NLPSolve(Gammaproc(f,eval(Zstub,sol[2])),f=f1..f2,
                         'method'=':-branchandbound','maximize',
                         'evaluationlimit'=100);

[.111740781972700085, [f = HFloat(1.9)]]

plot(bandpeak, Z[1]..Z[N], adaptive=false,
      view=0.1..0.5, gridlines=true);

optpt := eval([f,Zstub],[sol[2][],temp[2][]]);

[HFloat(1.9), HFloat(43.9058440724061)]

display(
  pointplot3d([[optpt[], Gammaproc(optpt[])]], color=red,
                   symbol=solidcircle,symbolsize=30),
  plot3d(Gammaproc(f,Zstub),f=f1..f2,Zstub=Z[1]..Z[N],
                             color=grey),
  axes=box, labels=[f,Zstub,"Gamma"]);

 

 

Download transformer_with_short_(Primes)_ac.mw

Yes, different forms of an expression can have different amounts of numeric error (eg, loss of precision).

It is quite common in numeric models of evaluation in scientific computing, and is not specific to Maple.

One way to deal with it is to raise working precision (either using the Digits environment variable, or more locally via the manner of calling the evalf command).

restart;

values := {m = 1400, d = 1/2 * 1.225*0.74, xpr = 27+7/9,
           A = -94.25, B = 4096, C = -2699, D = 131947,
           u0 = 0.1, P_max = 9705, u = 0.5}:

Pa_R := ((((A*D - B*C)*(sqrt(4*A^2*d*u*xpr^2 + 4*A*d*(A*D - B*C)*xpr
                        + (A*D - B*C)^2) + (2*d*xpr + D)*A - C*B))/(2*A^2*d)
          + u*xpr^2)*(-A*D + C*B - sqrt(4*A^2*d*u*xpr^2
                      + 4*A*d*(A*D - B*C)*xpr + (A*D - B*C)^2)))/(2*A*d);

(1/2)*((1/2)*(A*D-B*C)*((4*A^2*d*u*xpr^2+4*A*d*(A*D-B*C)*xpr+(A*D-B*C)^2)^(1/2)+(2*d*xpr+D)*A-B*C)/(A^2*d)+u*xpr^2)*(-A*D+B*C-(4*A^2*d*u*xpr^2+4*A*d*(A*D-B*C)*xpr+(A*D-B*C)^2)^(1/2))/(A*d)

Pa_R2 := simplify(Pa_R);

-(1/4)*(A*D-B*C+(4*A^2*d*u*xpr^2+4*A*d*(A*D-B*C)*xpr+(A*D-B*C)^2)^(1/2))*((A*D-B*C)*(4*A^2*d*u*xpr^2+4*A*d*(A*D-B*C)*xpr+(A*D-B*C)^2)^(1/2)+(2*d*u*xpr^2+2*D*d*xpr+D^2)*A^2-2*B*C*(d*xpr+D)*A+B^2*C^2)/(A^3*d^2)

eval(Pa_R, values);

9717.251005

eval(Pa_R2, values);

9314.704850

evalf[15](eval(Pa_R, values));

9717.30008417060

evalf[15](eval(Pa_R2, values));

9717.30163215298

for dd from 10 to 15 do
  forget(evalf):
  printf("   %a, %a\n", dd, evalf[dd](eval(Pa_R, values)));
end do;

   10, 9717.251005
   11, 9722.0166015
   12, 9717.25243950
   13, 9717.347726855
   14, 9717.3048483735
   15, 9717.30008417060

for dd from 10 to 15 do
  forget(evalf):
  printf("   %a, %a\n", dd, evalf[dd](eval(Pa_R2, values)));
end do;

   10, 9314.704850
   11, 9763.1922855
   12, 9714.89360302
   13, 9717.308535045
   14, 9717.3085321810
   15, 9717.30163215298

 

Download num_examp.mw

There are ways to gauge the amount of accrued numeric error. For example the precision of those supplied values for the parameters could be quantified (as tolerances, or intervals, etc), which could allow one to gauge accuracy of the resulting evaluation (as a function of the variable working precision).

Are you trying to multiply both numerator and denominator by the conjugate of the denominator?

Perhaps you also want to follow that up with simplification, and to illustrate doing it step by step?

Is the name x supposed to represent an unknown purely real quantity?

restart;

interface(typesetting=extended):

 

expr := (8*x+3*I)/(5*x-I);

(8*x+3*I)/(5*x-I)

n := numer(expr)/sign(numer(expr));

8*x+3*I

d := denom(expr)/sign(numer(expr));

5*x-I

f := conjugate(d) assuming x::real;

5*x+I

(n %* f) / (d %* f);

`%*`(8*x+3*I, 5*x+I)/`%*`(5*x-I, 5*x+I)

expand(n*f) / expand(d*f);

(40*x^2+(23*I)*x-3)/(25*x^2+1)


Alternatively,

rationalize(expr);

(8*x+3*I)*(5*x+I)/(25*x^2+1)

simplify(expand(%));

(40*x^2+(23*I)*x-3)/(25*x^2+1)

simplify(evalc(expr));

(40*x^2+(23*I)*x-3)/(25*x^2+1)

Download rtnz.mw

See the CodeTools:-Usage or the time commands.

With the time command, you may wish also to utilize assign, eg,

    time[real]( assign('ans', somecomputation) );

It depends on whether you want the timing to be merely printed, or accessible programmatically as a returned value.

You could assign the string (full and explicit name of the .mla file, with path) to a Maple name. Then you could pass that very same name to both commands, and in doing so avoid mismatch mistakes.

For example,

filenm := "C:\\Home\\Maple projects\\Test_package\\test.mla":
LibraryTools:-Create(filenm);
LibraryTools:-Save('testSavelib', filenm);

The above correction would also work in your original code, and avoid your mismatch between the your two lines related to the extra whitespace (that the second line had, while the first did not).

Regardless of the nature of your particular problem, I think that using LibraryTools:-Save is generally better (less error prone) than using savelib.

Why aren't you using fsolve for this?

CodeTools:-Usage(fsolve(1 + 0.15 = (1 + r__x)^1.28858));
memory used=1.33MiB, alloc change=0 bytes, cpu time=16.00ms, real time=16.00ms, gc time=0ns

              0.1145625357

Is there a numeric value for parameter a?

From your grainy image it looks like you may have accidentally only made the equation,

   a = 1

instead of doing the assignment,

   a := 1

It's more useful to upload and attach your actual worksheet (green up-arrow in the Mapleprimes editor) than it is to show only an image of your code.

Are you hoping to utilize all of those equations rC1,rC2,rf1,rA,rh to substitute for all of C1,C2,f1,A, and h?

restart

with(plots):

``

psi := I*(C1*exp(A)-C2*exp(-A))*exp(-I*t*(1/2))/f1;

I*(C1*exp(A)-C2*exp(-A))*exp(-((1/2)*I)*t)/f1

rf1 := f1 = sqrt(h^2-1);

f1 = (h^2-1)^(1/2)

rh := h = f^2+1;

h = f^2+1

rA := `assuming`([A = simplify(subs(rh, sqrt(h^2-1)*(x+I*h*t)))], [f > 0]);

A = f*(f^2+2)^(1/2)*(I*f^2*t+I*t+x)

rC1 := `assuming`([C1 = simplify(subs(rf1, rh, sqrt(h-f1)))], [f > 0]);

C1 = (f^2+1-f*(f^2+2)^(1/2))^(1/2)

rC2 := `assuming`([C2 = simplify(subs(rf1, rh, sqrt(h+f1)))], [f > 0]);

C2 = (f^2+1+f*(f^2+2)^(1/2))^(1/2)

psi_f := eval[recurse](psi, [rC1, rC2, rf1, rA, rh]);

I*((f^2+1-f*(f^2+2)^(1/2))^(1/2)*exp(f*(f^2+2)^(1/2)*(I*f^2*t+I*t+x))-(f^2+1+f*(f^2+2)^(1/2))^(1/2)*exp(-f*(f^2+2)^(1/2)*(I*f^2*t+I*t+x)))*exp(-((1/2)*I)*t)/((f^2+1)^2-1)^(1/2)

simplify(limit(psi_f, f = 0, right));

exp(-((1/2)*I)*t)*((2*I)*x-I-2*t)

simplify(limit(psi_f, f = 0, left));

-exp(-((1/2)*I)*t)*((2*I)*x-I-2*t)

 

NULL

Download limit1.mw

At lower (and default) working precision this example can encounter enough numeric round-off error that the symbolic solve command finds spurious roots if you perform non-inert symbolic solving and integration on the expression containing floating-point coefficients.

I suggest:
1) don't use RealDomain (it's not doing what you think, anyway, in your example).
2) use fsolve for numeric root-finding instead of solve here.
3) Don't introduce floating-point values instead of exact rationals if you can practically avoid doing so, especially if you intend on attempting symbolic integration or solving. (Symbolic integration/solving of an expression containing floats can sometimes do worse than trying to solve it numerically, or trying to solve an exact problem.)

If you left out RealDomain, and used exact rationals, then the spurious solutions from solve (due to floating-point round-off error) could be avoided by raising Digits. But it'd be better and faster to simply use a numeric root-finder for this problem which likely doesn't even have an explicit symbolic solution.

restart

f := proc (x) options operator, arrow; 6-sqrt(-x^2+8*x+9) end proc

eq := 10 = int(f(x), x = 0 .. L)

10 = -6-(25/2)*arcsin(4/5)+6*L-(1/2)*(-L^2+8*L+9)^(1/2)*L+2*(-L^2+8*L+9)^(1/2)-(25/2)*arcsin((1/5)*L-4/5)

fsolve(eq, L)

6.810993081

fsolve(eq, L = -10 .. 10, maxsols = 5)

6.810993081

Download Working_ac.mw

 

If you really want to see more of the specifics of how it went wrong...

restart

f := proc (x) options operator, arrow; 6-sqrt(-x^2+8*x+9) end proc

proc (x) options operator, arrow; 6-sqrt(-x^2+8*x+9) end proc

eq := 10 = int(f(x), x = 0 .. L)

10 = -6-(25/2)*arcsin(4/5)+6*L-(1/2)*(-L^2+8*L+9)^(1/2)*L+2*(-L^2+8*L+9)^(1/2)-(25/2)*arcsin((1/5)*L-4/5)

oof := 10 = int(evalf(f(x)), x = 0 .. L)

10 = -17.59119023+6.*L-.5000000000*(-1.*L^2+8.*L+9.)^(1/2)*L+2.*(-1.*L^2+8.*L+9.)^(1/2)-12.50000000*arcsin(.2000000000*L-.8000000000)

feq := evalf(eq)

10. = -17.59119022+6.*L-.5000000000*(-1.*L^2+8.*L+9.)^(1/2)*L+2.*(-1.*L^2+8.*L+9.)^(1/2)-12.50000000*arcsin(.2000000000*L-.8000000000)

solve(eq, L)

5*sin(RootOf(25*(cos(_Z)^2)^(1/2)*sin(_Z)-60*sin(_Z)+25*_Z+25*arcsin(4/5)-16))+4

RealDomain:-solve(feq, L)

8.855609656, -.4725737212, 6.810993078

solve(feq, L)

8.855609656, -.4725737212, 6.810993078, -.7764912837+15.69863487*I, 8.138450513-15.36358890*I, -.7764912837-15.69863487*I, 8.138450513+15.36358890*I, 2.341723694-6.481846912*I, 2.341723694+6.481846912*I, 13.34312523-18.81939387*I, -5.700438002+19.09985409*I, 13.34312523+18.81939387*I, -5.700438002-19.09985409*I, 16.71699261-17.45692870*I, -9.003420055+17.75423373*I, 16.71699261+17.45692870*I, -9.003420055-17.75423373*I

If we approximate eq at higher working precision then terms like arcsin(4/5) don't incur as must loss of accuracy (which propagates forward as greater inaccuracy, leading to spurious solutions).
Digits := 30; solve(evalf(eq))

6.81099308113251113676562942220

NULL

Download Not_working_ac.mw

You can call fsolve to compute a root between each of those.

But don't try and do it by appending (to a list, or Vector). That's a poor way to program, and habitually leads to unnecessary inefficiency in programs as they scale.

Instead, you could simply use seq (or map) to form the list. Or you could use Vector with a constructor operator.

restart

gamma1 := .1093:

f := q-(1-alpha)*tan(q)-c*tan(q)

q-0.4646295e-3*tan(q)-0.2298931352e-4*tan(q)/(0.3800000000e-3*q^2-0.2300000000e-4)

n := 10:

Asymptotes

fOdd := proc (j) options operator, arrow; (1/2)*(2*j+1)*Pi end proc; OddAsymptotes := Vector[row](n, fOdd)

fOdd := proc (j) options operator, arrow; (j+1/2)*Pi end proc

OddAsymptotes := Vector[row](10, {(1) = (3/2)*Pi, (2) = (5/2)*Pi, (3) = (7/2)*Pi, (4) = (9/2)*Pi, (5) = (11/2)*Pi, (6) = (13/2)*Pi, (7) = (15/2)*Pi, (8) = (17/2)*Pi, (9) = (19/2)*Pi, (10) = (21/2)*Pi})

[seq(fsolve(f, q = OddAsymptotes[i] .. OddAsymptotes[i+1]), i = 1 .. n-1)];

[7.853797468, 10.99548650, 14.13711266, 17.27872097, 20.42032239, 23.56192056, 26.70351698, 29.84511237, 32.98670709]

Vector[row](n-1, proc (i) options operator, arrow; fsolve(f, q = OddAsymptotes[i] .. OddAsymptotes[i+1]) end proc)

Vector[row](9, {(1) = 7.853797468, (2) = 10.99548650, (3) = 14.13711266, (4) = 17.27872097, (5) = 20.42032239, (6) = 23.56192056, (7) = 26.70351698, (8) = 29.84511237, (9) = 32.98670709})

 

``

Download Asymptotes_acc.mw

Isn't this a repeat of one of your previous Questions?

For larger (symmetric) examples you will get a result more quickly by computing the eigenvalues of the Matrix (cast suitably to float[8] datatype, symmetric indexing function, etc).

You wrote in a followup comment, "In general, the matrices I encounter are real symmetric", so below I'll focus on code for that case.

Here's code for doing it via Eigenvalues, and an example where the SingularValues computation takes about 3.2 times as much wall-clock time, on my Linux machine. (That slowdown ratio could typically grow, as the Matrix size increases, but it can depend on the nature of the Graph data.)

SR := proc(G::Graph)
  local M := GraphTheory:-AdjacencyMatrix(G);
  max(abs~(LinearAlgebra:-Eigenvalues(
    rtable(`if`([rtable_indfns(M)]=[':-symmetric'],
           ':-symmetric',NULL), M,
           'datatype'=':-hfloat','storage'=':-rectangular',
           'order'=':-Fortran_order'))));
end proc:

M22:= GraphTheory:-SpecialGraphs:-M22Graph();

   M22 := Graph 1: an undirected unweighted graph with
          77 vertices and 616 edge(s)

CodeTools:-Usage(SR(M22), iterations=100);

memory used=270.28KiB, alloc change=38.59MiB, cpu time=1.84ms,
real time=1.86ms, gc time=110.19us

            16.0000000000000

G := GraphTheory:-SpecialGraphs:-CirculantGraph(2345,[1,2]);

    G := Graph 2: an undirected unweighted graph with
         2345 vertices and 4690  edge(s)

CodeTools:-Usage(SR(G));

memory used=242.85MiB, alloc change=107.52MiB, cpu time=5.75s,
real time=2.73s, gc time=312.03ms

            4.00000000000000

SpectralRadius_ac.mw

If you know certain additional qualities of the Graph up front (eg. Bipartite) then you might be able to attain even better speed by computing just the "first" selected eigenvalue. I had an old post on computing only selected eigenvectors/values. But it's not helpful if you have to call it twice to compute first and last (largest-positive and smallest-negative). I'm not sure whether this is workable.

These are all using external calling to LAPACK for dense matrix operations. ie. not sparse stuff.

Are you asking about how to get the exploration to appear in a new document, in a separate GUI tab? If so, then it can be done by using the Explore command explicitly, instead using rigght-click context-menu.

For example,

restart;

Explore(plot(sin(a*x)*x^2 + cos(b*x),
             x = -2*Pi .. 2*Pi, view = -30 .. 30),
        a = 1.0 .. 10.0, b = 1.0 .. 10.0,
        animate, newsheet, showbanner = false);

 

If you mean something else then you really ought to explain it more clearly. What do you mean by "save", and "extension file"?

That particular accent you've chosen may be getting parsed (in 2D Input) as conjugate(a). So you might be seeing a 2D Input version of this:

conjugate(a):=3;

3

conjugate(a)+2;

conjugate(a)+2

Download conjugate_sigh.mw

The same kind of thing seems to happen in the 2D Input parsing if I utilize the Layout palette (for "Over") and the Punctuation palette for inserting the "macr" over-bar. That is, I get a call to conjugate as the parsed meaning.

You could get the expected behaviour using the "Over" item from the Layout palette and then some other kind of over-bar from the Punctuation palette, eg. the "mdash", "minus", or "ndash" items. As over-bars those don't seem to make the names get parsed as calls to conjugate, instead parsing as distinct (typeset) names that behave more as you'd expected.

Please check whether you have shown the differential equation, and the value of lambda, correctly. (For example, what do you expect for 4*f(8) = x*f(eta) when x=4 and eta=8?)

As I parse the DE that you've shown, the value of 4*f(8) is only about 3.2 when lambda=0.5. But that doesn't correspond to the red color for the values near 4.0 in your colorbar. So either I've misunderstood the DE, or something else is not right.

Below I use lambda=0.005.

restart;

kernelopts(version);

`Maple 2021.2, X86 64 LINUX, Nov 23 2021, Build ID 1576349`

Typesetting:-Settings(typesetprime=true):
Typesetting:-Suppress(f(x));
interface(typesetting=extended):

de := diff(f(x),x,x,x) + (f(x)*diff(f(x),x,x) - diff(f(x),x)^2)
      - lambda*diff(f(x),x) = 0;

diff(diff(diff(f(x), x), x), x)+f(x)*(diff(diff(f(x), x), x))-(diff(f(x), x))^2-lambda*(diff(f(x), x)) = 0

lambda := 0.005:

desol := dsolve({de, f(0)=0, D(f)(0)=1, D(f)(10)=0}, f(x),
                numeric, output=listprocedure):

fsol := eval(f(x), desol):

4 * fsol(8);

HFloat(3.987786123641983)

plots:-display(
  plots:-densityplot(x*fsol(y), x=0..4, y=0..8,
                     style=surface, restricttoranges,
                     colorscheme=["zcoloring",
                                  z->2/3*(1-z/4)]),
  plots:-contourplot(x*fsol(y), x=0..4, y=0..8,
                     contours=[seq(0..4,0.5)], thickness=0),
  seq(plottools:-line([0,0],[0,0],thickness=10,
                      color=ColorTools:-Color("HSV",[2/3*(4-i)/(4-0),1,1]),
                      legend=sprintf("%.3f",i)),
      i=4..0,-0.5),
  labels=[x,eta], labeldirections=[horizontal,vertical],
  legendstyle=[location=right], axes=box,
  axis[1]=[tickmarks=[seq(0.0..4.0,0.5)]],
  axesfont=[Times,14], size=[500,400]
);

Download de_col.mw

 

[edit] Looking at the OP's previous postings it seems as if he might be using the significantly older Maple 17, in which case some of the above functionality is not available. Here is a revision, for that older version.

My query about the correctness of the DE and value of lambda still applies.

restart;

kerneopts(version);

kerneopts(version)

de := diff(f(x),x,x,x) + (f(x)*diff(f(x),x,x) - diff(f(x),x)^2)
      - lambda*diff(f(x),x) = 0;

diff(diff(diff(f(x), x), x), x)+f(x)*(diff(diff(f(x), x), x))-(diff(f(x), x))^2-lambda*(diff(f(x), x)) = 0

lambda := 0.005:

desol := dsolve({de, f(0)=0, D(f)(0)=1, D(f)(10)=0}, f(x),
                numeric, output=listprocedure):

fsol := eval(f(x), desol):

4 * fsol(8);

HFloat(3.9877861236419827)

plots:-display(
  plots:-densityplot(piecewise( x<-0.75, 0, x<-0.5, 1, x<0, 2/3,
                                2/3*(1 - x*fsol(y)/4) ),
                     x=-1..4, y=0..8,
                     style=patchnogrid,
                     colorstyle=HUE),
  plots:-contourplot(x*fsol(y), x=0..4, y=0..8,
                     contours=[seq(0..4,0.5)], thickness=0),
  seq(plottools:-line([0,0],[0,0],thickness=10,
                      color=ColorTools:-Color("HSV",[2/3*(4-i)/(4-0),1,1]),
                      legend=sprintf("%.3f",i)),
      i=4..0,-0.5),
  labels=[x,eta], labeldirections=[horizontal,vertical],
  legendstyle=[location=right], axes=box, view=[0..4,0..8],
  axis[1]=[tickmarks=[seq(0.0..4.0,0.5)]],
  axesfont=[Times,14]
);

Download de_col17.mw

First 71 72 73 74 75 76 77 Last Page 73 of 336