acer

32405 Reputation

29 Badges

19 years, 349 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

You can even get a nice closed form for the expression that represents this curve, in terms of either variable.

restart;

f3:=-1/(((-qh-1)*Tch+qc+1)*deltac+(qh+1)*Tch)*(6*alpha^2*(alpha-1)*(alpha+1)*(((-qh-1)*Tch+qc+1)^2*deltac^2+((-7/3*(qh^2)-10/3*qh-1)*Tch^2+(2*(qh+1))*(qc+1)*Tch+(1/3)*qc^2-2*qc*(1/3)-1)*deltac+4*qh*Tch^2*(qh+1)*(1/3)))=0:

params:=[qh=0.64,deltac=0.5,deltah=0.5,alpha=0.8,gamma=0.1,M=1.6205];

[qh = .64, deltac = .5, deltah = .5, alpha = .8, gamma = .1, M = 1.6205]

Eq1:=eval(collect(f3,[Tch,qc]), params);

1.3824*(0.27333334e-1*Tch^2+(.8200*qc+.8200)*Tch+.4166666667*qc^2+.1666666667*qc-.25)/(.820*Tch+.5*qc+.5) = 0

plots:-implicitplot(Eq1, qc=0..1, Tch=0..1);

S1:=solve({(lhs-rhs)(eval(f3,convert(params,rational)))=0,
                qc>0, Tch>0}, [qc,Tch]);

[[qc < 3/5, 0 < qc, Tch = -15*qc-15+(10/41)*(3526*qc^2+7462*qc+3936)^(1/2)]]

S2:=solve({(lhs-rhs)(eval(f3,convert(params,rational)))=0,
                qc>0, Tch>0}, [Tch,qc]);

[[Tch < -15+(40/41)*246^(1/2), 0 < Tch, qc = -(123/125)*Tch-1/5+(2/125)*(3526*Tch^2-6150*Tch+2500)^(1/2)]]

indets([S1,S2],`<`);
evalf(%);

{0 < Tch, 0 < qc, Tch < -15+(40/41)*246^(1/2), qc < 3/5}

{0. < Tch, 0. < qc, Tch < .30184111, qc < .6000000000}

Download 1_6_ac.mw

The range qc=0.34..0.5Tch=0.01..0.05 that you were using doesn't contain what you're after. It just misses the curve where the expression is zero...

plots:-implicitplot(Eq1, qc=0.34..0.5, Tch=0.01..0.1, rangeasview);

You could augment the convert command.

restart;

`convert/sinc` := proc(ee)
   evalindets(
     evalindets(
       evalindets(ee,
                  specfunc(sin),x -> op(x)*sinc(op(x))),
       specfunc(cos),x -> (op(x)+Pi/2)*sinc(op(x)+Pi/2)),
     specfunc(tan),x -> op(x)*sinc(op(x))/(op(x)+Pi/2)/sinc(op(x)+Pi/2));
end proc:

 

convert(sin(s), sinc);

s*sinc(s)

convert(cos(s), sinc);

(s+(1/2)*Pi)*sinc(s+(1/2)*Pi)

convert(tan(s), sinc);

s*sinc(s)/((s+(1/2)*Pi)*sinc(s+(1/2)*Pi))

Download conv_sinc_ex.mw

And you could also make such a convert(...,sinc) call for a compound expression involving a mix of sin&cos&tan, naturally.

ps. I changed your Post into a Question.

pps. You could also handle csc/sec/cot , in a few ways, eg. by converting to sincos as intermediate form.

ppps. It's possible to simply replace name sin/cos/tan by your operators, under eval. I deliberately used evalindets instead, to target only function calls of those names, and not any (other) instances of the bare names. Examples where is might matter could be rare, and possibly look contrived...

An Explore example, using your attachment g1.mw .

The signifant first change here is to remove the fixed view option from the plot3d call (since the surface's scale changes so much with the parameters) and to supply the adaptview=false option to Explore so that it allow each frame to get its own view independently. See magenta text edits.

g1_ac.mw

restart

_local(gamma)

M := 2*sqrt(7*a^6*alpha[4]^2-8*a^4*l^2*alpha[4]*alpha[5]+a^2*l^4*alpha[5]^2+12*a^5*alpha[3]*alpha[4]-8*a^3*l^2*alpha[1]*alpha[4]-6*a^3*l^2*alpha[3]*alpha[5]+2*a*l^4*alpha[1]*alpha[5]+10*a^4*alpha[2]*alpha[4]+5*a^4*alpha[3]^2-6*a^2*l^2*alpha[1]*alpha[3]-4*a^2*l^2*alpha[2]*alpha[5]+l^4*alpha[1]^2-8*a^4*alpha[4]+8*a^3*alpha[2]*alpha[3]+2*a^2*l^2*alpha[5]-4*a*l^2*alpha[1]*alpha[2]-6*a^3*alpha[3]+3*a^2*alpha[2]^2+2*a*l^2*alpha[1]-4*a^2*alpha[2]+a^2)

G := proc( alpha__1,alpha__2,alpha__3,alpha__4,alpha__5 )
   global last;
   last := [[:-alpha[1] = alpha__1,:-alpha[2] = alpha__2,:-alpha[3] = alpha__3,
             :-alpha[4] = alpha__4,:-alpha[5] = alpha__5],
            eval(M, [:-alpha[1] = alpha__1,:-alpha[2] = alpha__2,:-alpha[3] = alpha__3,
                     :-alpha[4] = alpha__4,:-alpha[5] = alpha__5])];
   plot3d(Im(eval(last[2])), a = -10 .. 10, l = -10 .. 10,
          #view = -10 .. 10,
          grid = [100, 100],
          colorscheme="turbo",
          style = surface, adaptmesh = false, size = [500, 500]); end proc:

last := 'last'; Explore(G(`&alpha;__1`, `&alpha;__2`, `&alpha;__3`, `&alpha;__4`, `&alpha;__5`), `&alpha;__1` = -5.00000001 .. 5.000000001, `&alpha;__2` = -5.00000001 .. 5.000000001, `&alpha;__3` = -5.00000001 .. 5.000000001, `&alpha;__4` = -5.00000001 .. 5.000000001, `&alpha;__5` = -5.00000001 .. 5.000000001, initialvalues = [`&alpha;__1` = 1, `&alpha;__2` = 1, `&alpha;__3` = 1, `&alpha;__4` = 1, `&alpha;__5` = 5], placement = right, adaptview = false)

 

 

 

 

alpha__1

 

 

 

 

alpha__2

 

 

 

 

alpha__3

 

 

 

 

alpha__4

 

 

 

 

alpha__5

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The following tests that the first indices (yours have just one) of the elements are four distinct values.
 

L:=[ [F[1], F[2], F[3], F[4]],
     [F[1], F[2], F[3], M[1]],
     [F[1], F[2], F[3], M[2]],
     [F[1], F[2], F[3], M[3]],
     [F[1], F[2], F[3], M[4]],
     [F[1], F[2], F[4], M[1]],
     [F[1], F[2], F[4], M[2]],
     [F[1], F[2], F[4], M[3]],
     [F[1], F[2], F[4], M[4]],
     [F[1], F[2], M[1], M[2]] ]:

 

select(LL->nops({map2(op,1,LL)[]})=4,L);

[[F[1], F[2], F[3], F[4]], [F[1], F[2], F[3], M[4]], [F[1], F[2], F[4], M[3]]]


Download map_op_ex.mw

You haven't stated explicitly that all the lists in L will always have elements that are indexed by at least one value, but I have presumed it so.

ps. I didn't see dharr's Answer before posting my own. The fact that they are so similar is really because it's a natural way to approach it.
[edit] dharr's Answer seems to have gone missing. But it was fine, IMO, (presuming all elements have exactly one index, which is also reasonable in the absence of stated details),
    select(x->nops({map(op,x)[]})=4,L);

[edit] Some explanation of the steps, so that next time you might build your own,

Turn the inner lists of indexed items into
lists of just their indices.

map( LL -> map2(op,1,LL), L );

[[1, 2, 3, 4], [1, 2, 3, 1], [1, 2, 3, 2], [1, 2, 3, 3], [1, 2, 3, 4], [1, 2, 4, 1], [1, 2, 4, 2], [1, 2, 4, 3], [1, 2, 4, 4], [1, 2, 1, 2]]

But now also make them sets of the indices, to
get rid of duplicates.

map( LL -> {map2(op,1,LL)[]}, L );

[{1, 2, 3, 4}, {1, 2, 3}, {1, 2, 3}, {1, 2, 3}, {1, 2, 3, 4}, {1, 2, 4}, {1, 2, 4}, {1, 2, 3, 4}, {1, 2, 4}, {1, 2}]

But now take the nops of those sets, and set equal to 4.

map( LL -> nops({map2(op,1,LL)[]})=4, L );

[4 = 4, 3 = 4, 3 = 4, 3 = 4, 4 = 4, 3 = 4, 3 = 4, 4 = 4, 3 = 4, 2 = 4]

Now use those equations as boolean valued tests,
in order to select with this action.

select(LL->nops({map2(op,1,LL)[]})=4,L);

[[F[1], F[2], F[3], F[4]], [F[1], F[2], F[3], M[4]], [F[1], F[2], F[4], M[3]]]

Similarly, but without using select.

map( LL -> ifelse(nops({map2(op,1,LL)[]})=4, LL, NULL), L );

[[F[1], F[2], F[3], F[4]], [F[1], F[2], F[3], M[4]], [F[1], F[2], F[4], M[3]]]

I'm guessing that you'd prefer to have the Product call be shown with the assigned name, rather than with the Vector or list to which that name is assigned.

Here is something that gets that, for Vector or list, in Maple 2021.

restart;

kernelopts(version);

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

with(Statistics):

Dist := proc(N::{posint, name}, alpha::evaln)
  local K;
  uses Statistics;

  K := numelems(eval(alpha));
  
  Distribution( ':-PDF' = (z -> Product(('alpha'[k]+z[k])^N, k=1..K)) )
end proc:

P := Vector(3, [13,2,4]);

Vector(3, {(1) = 13, (2) = 2, (3) = 4})

X := RandomVariable(Dist(N, P)):

res1 := PDF(X, x);

Product((P[k]+x[k])^N, k = 1 .. 3)

eval(res1,1);

Product((P[k]+x[k])^N, k = 1 .. 3)

value(eval(res1,1));

(13+x[1])^N*(2+x[2])^N*(4+x[3])^N

L := [3,17,22];
X2 := RandomVariable(Dist(N, L)):

[3, 17, 22]

res2 := PDF(X2, y);

Product((L[k]+y[k])^N, k = 1 .. 3)

value(eval(res2,1));
value(res2);

(3+y[1])^N*(17+y[2])^N*(22+y[3])^N

(3+y[1])^N*(17+y[2])^N*(22+y[3])^N

eval(res2,1);
res2;

Product((L[k]+y[k])^N, k = 1 .. 3)

Product(([3, 17, 22][k]+y[k])^N, k = 1 .. 3)

V := Vector([1/2,1/3,1/4]):
subs('P'='V', eval(res1,1));
value(eval(%,1));

Product((V[k]+x[k])^N, k = 1 .. 3)

(1/2+x[1])^N*(1/3+x[2])^N*(1/4+x[3])^N

Download Product_error_ac.mw

and a variant on that: Product_error_ac2.mw

Here is something that behaves ok for a list (but not Vector), in Maple 2015: Product_error_ac_2015_list.mw

With a little effort one can guard against collision of the textplots.

restart

L := [sin(x), sin(x)^2, sin(x)^3, sin(x)^4, sin(x)^5, sin(x)^6, surd(sin(x), 2), surd(sin(x), 3), surd(sin(x), 4), surd(sin(x), 5), surd(sin(x), 6)]

Typesetting:-mrow(Typesetting:-mi("clist", italic = "true", mathvariant = "italic"), Typesetting:-mo("&coloneq;", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("plots", italic = "true", mathvariant = "italic"), Typesetting:-mo(":-", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("setcolors", italic = "true", mathvariant = "italic"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi(""), Typesetting:-ms("Niagara"), Typesetting:-mi("")), mathvariant = "normal"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("")), mathvariant = "normal", open = "[", close = "]"), Typesetting:-mo(",", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.3333333em"), Typesetting:-ms("Black"), Typesetting:-mi("")), mathvariant = "normal", open = "[", close = "]"), Typesetting:-mo(":", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("if", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("not", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("nops", italic = "true", mathvariant = "italic"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("L", italic = "true", mathvariant = "italic")), mathvariant = "normal"), Typesetting:-mo("&leq;", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mi("nops", italic = "true", mathvariant = "italic"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("clist", italic = "true", mathvariant = "italic")), mathvariant = "normal"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("then", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("error", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-ms("add more colors to clist"), Typesetting:-mo(";", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.2777778em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("end", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("if", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(";", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.2777778em"))

plots:-animate(proc (T) local i, j, TL; TL := []; for i to nops(L) do if 0.5e-1 < min(100, seq(eval(abs(L[i]-rhs(TL[j])), x = T), j = 1 .. nops(TL))) then TL := [TL[], i = L[i]] end if end do; plots:-display(plot(L, x = 0 .. T, ':-thickness' = 2.5, ':-color' = clist), ifelse(0.1e-2 < T and T < Pi-0.1e-2, seq(plots:-textplot([T, eval(rhs(TL[i]), x = T), rhs(TL[i])], ':-align' = ':-right', ':-color' = clist[lhs(TL[i])]), i = 1 .. nops(TL)), NULL), ':-xtickmarks' = ':-piticks') end proc, [x], x = 0 .. Pi, frames = 100, size = [800, 500])

NULL

Download Animation_Trigo_ac.mw

Your curves don't change much for such small changes in E1, it seems.

AGM_method_single_line_plot_ac.mw

There's quite a bit of duplicated effort in your approaches (which I didn't try to improve, though I showed a couple or alternative syntax blobs).

It's not clear what your definition of "simplify" is here.

But there are several ways to rationalize the denominator (including just using the rationalize command...).

restart;

expr:=(2500*I*w)/(1+5*I*w)+(200*I*w)/(1-10*I*w)+5;

(2500*I)*w/(1+(5*I)*w)+(200*I)*w/(1-(10*I)*w)+5

rationalize(expr);

-5*(-4850*w^2-(535*I)*w-1)*((5*I)*w+50*w^2+1)/(2500*w^4+125*w^2+1)

map(factor,rationalize(expr));

5*(-4850*w^2-(535*I)*w-1)*(-10*w+I)*(5*w+I)/((25*w^2+1)*(100*w^2+1))

Download rat_ex.mw

I notice that converting the DE to sincos form allows both to work in stock Maple 2025.1.

This makes me suspect that it might not be a hard fix.

restart;

kernelopts(version);

          Maple 2025.1, X86 64 LINUX, Jun 12 2025, Build ID 1932578

ode:=diff(y(x),x) = (2*sin(2*x)-tan(y(x)))/x/sec(y(x))^2:

dsolve(convert(ode,sincos));

    y(x) = -arctan((cos(2*x)-2*c__1)/x)

dsolve(convert(ode,sincos),implicit);

    -c__1+x*tan(y(x))+cos(2*x) = 0

There was quite a lot of invalid syntax in your code attempt.

But, here is one way.

restart;

kernelopts(version);

`Maple 2015.2, X86 64 LINUX, Dec 20 2015, Build ID 1097895`

with(plots):

aa := 4: bb := 2:  

f := -(x^2/(aa^2)+y^2/(bb^(2))-1) * aa^2*bb^2/(aa^2+bb^2);

-(1/5)*x^2-(4/5)*y^2+16/5

ell := (2*x/aa)^2 + (2*y/bb)^2 <= 1;

(1/4)*x^2+y^2 <= 1

plot3d(f, x = 0 .. sqrt(-4*y^2+4), y = 0 .. bb/(2),
       axes = boxed,style = patchcontour, grid = [50, 50],
       orientation = [-115, 70], shading = zhue,
       title = "f(x,y) over quarter ellipse domain",
       labels=[x,y,"f"]);

contourplot(f, x = 0 .. sqrt(-4*y^2+4), y = 0 .. bb/(2),
            contours = 15, filled = true, coloring = [blue, green],
            axes = boxed, title = "Contour plot over quarter ellipse",
            grid = [100,100]);

Download Usman_contplot1.mw

Is this the kind of effect you're after?

[edited]

restart

with(PDEtools, declare); with(PDEtools, undeclare)

undeclare(prime, quiet)

declare(u(x, y, t), quiet); declare(v(x, y, t), quiet)

pde1 := diff(u(x, y, t), t)+diff(u(x, y, t), `$`(x, 3))+diff(u(x, y, t)*v(x, y, t), x)

diff(u(x, y, t), t)+diff(diff(diff(u(x, y, t), x), x), x)+(diff(u(x, y, t), x))*v(x, y, t)+u(x, y, t)*(diff(v(x, y, t), x))

pde2 := diff(u(x, y, t), x)-(diff(v(x, y, t), y))

diff(u(x, y, t), x)-(diff(v(x, y, t), y))

V1 := [indets(pde1, And(specfunc(diff), satisfies(proc (fn) options operator, arrow; depends(fn, {t, x, y}) end proc)))[], `~`[apply]([u, v], x, y, t)[]]; Z1 := map(proc (v) options operator, arrow; v = freeze(v) end proc, V1)

[diff(diff(diff(u(x, y, t), x), x), x), diff(diff(u(x, y, t), x), x), diff(u(x, y, t), t), diff(u(x, y, t), x), diff(v(x, y, t), x), u(x, y, t), v(x, y, t)]

pde_linear1,pde_nonlinear1 := thaw([selectremove(type,eval(pde1,Z1)+__f,
                                                 Or(linear(rhs~(Z1)),
                                                    satisfies(f->not depends(f,[rhs~(Z1)[],x,y,t]))))])[]:
pde_linear1:=pde_linear1-__f:

V2 := [indets(pde2, And(specfunc(diff), satisfies(proc (fn) options operator, arrow; depends(fn, {t, x, y}) end proc)))[], `~`[apply]([u, v], x, y, t)[]]; Z2 := map(proc (v) options operator, arrow; v = freeze(v) end proc, V2)

[diff(u(x, y, t), x), diff(v(x, y, t), y), u(x, y, t), v(x, y, t)]

pde_linear2,pde_nonlinear2 := thaw([selectremove(type,eval(pde2,Z2)+__f,
                                                 Or(linear(rhs~(Z2)),
                                                    satisfies(f->not depends(f,rhs~(Z2)))))])[]:
pde_linear2:=pde_linear2-__f:

pde_linear1;
pde_nonlinear1;
pde_linear2;
pde_nonlinear2;

diff(diff(diff(u(x, y, t), x), x), x)+diff(u(x, y, t), t)

(diff(u(x, y, t), x))*v(x, y, t)+u(x, y, t)*(diff(v(x, y, t), x))

diff(u(x, y, t), x)-(diff(v(x, y, t), y))

0

Download linear_ac.mw

nb. You may wish to apply normal (or expand, possibly frontend'd) first, to get the addends of the DE separated.

The (2) in the pretty-printed output of ifactors if actually the function call  ``(2) , ie. a call to the empty name.

It's easier to work with the result from ifactors, instead.

Or you could use the PrimeFactors command in the NumberTheory package.

You approach missed the special case where there is just one prime factor (of multiplicity > 1), in which case the operands of f are not what was expected.

restart;

 

SumPrimeFactors := proc(n)
    local f,p;
    f := ifactor(n);
    if f=1 then return 0;
    elif f::`^` then return op([1,1],f);
    else
      add(op([1,1], p), p in f);
    end if;
end proc:

 

SPF1 := proc(n) local p;
    add(p[1],p=ifactors(n)[2]);
end proc:

 

SPF2 := n -> add(NumberTheory:-PrimeFactors(n)):

 

seq(SumPrimeFactors(i)-SPF1(i),i=1..28);
seq(SumPrimeFactors(i)-SPF2(i),i=1..28);

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

SumPrimeFactors(360),SPF1(360),SPF2(360)

10, 10, 10

 

ifactor(40);
## the elements in the returned product are powers of
## unevaluated function calls (to an unassigned empty name)
## and their first argument (the base prime) can be retrieved using
## the `op` command.
lprint(%);

``(2)^3*``(5)

``(2)^3*``(5)

op([1], ``(2)^3); lprint(%);
op(1, %);

``(2)

``(2)

2

op([1,1], ``(2)^3);

2

op([1], ``(5)); lprint(%);
op([1,1], ``(5));

5

5

5

Download ifact_fun.mw

It sounds like you're seeing this problem.

I suggest that you use the settings as I described in that previous thread's Answer, but also with (the default),

    interface(typesetting=extended):

The Y[i] in the result from convertsys are not the global names Y[i].

You could instead work with convert(sys0,`global`), as one simple way to replace those names.

带有阻尼的固有频率分析

restart

with(Typesetting); Settings(typesetdot = true)

with(LinearAlgebra); with(linalg); with(plots); with(DEtools)

couple := diff(q(t), `$`(t, 2))+nu*(diff(q(t), t))/omega+q(t)+b*L__1*(diff(x(t), `$`(t, 2)))/L-`&alpha;__11`*L__1*(diff(x(t), t))/(L*omega)-`&alpha;__22`*omega*r*L^2*(diff(q(t), t))^3, diff(eta(t), `$`(t, 2))+nu*(diff(eta(t), t))/omega+eta(t)+b*L__1*(diff(x(t), `$`(t, 2)))/L-`&alpha;__11`*L__1*(diff(x(t), t))/(L*omega)-`&alpha;__22`*omega*r*L^2*(diff(eta(t), t))^3, diff(x(t), `$`(t, 2))+`&nu;__1`*(diff(x(t), t))/omega+(`&omega;__1`/omega)^2*x(t)+g*gamma*L*(diff(q(t), `$`(t, 2)))/L__1+g*gamma*L*(diff(eta(t), `$`(t, 2)))/L__1-`&alpha;__11`*L*(diff(q(t), t))/(omega*L__1)-`&alpha;__11`*L*(diff(eta(t), t))/(omega*L__1)-omega*r*L^3*`&varsigma;`*(diff(q(t), t))^3/L__1-omega*r*L^3*`&varsigma;`*(diff(eta(t), t))^3/L__1

couple1 := seq(remove(has, [couple][i], [(diff(q(t), t))^3, (diff(eta(t), t))^3]), i = 1 .. 3)

NULL

data := nu = 2*xi*`&omega;__2`-(1/2)*a__11*`&rho;__air`*D*h__2*U*p__2^2, `&nu;__1` = 2*xi*`&omega;__1`-(1/2)*a__11*`&rho;__air`*D*h__2*U*p__12^2-(1/2)*a__11*`&rho;__air`*D*h__2*U*p__13^2

eqn := subs(data, [couple1])

with(DEtools)

temp := convertsys({eqn[]}, [], {eta, q, x}, t); sys0 := `~`[rhs](%[1]); vars := `%%`[2]

[Y[1] = eta(t), Y[2] = diff(eta(t), t), Y[3] = q(t), Y[4] = diff(q(t), t), Y[5] = x(t), Y[6] = diff(x(t), t)]

var1 := [seq(Y[i], i = 1 .. 6)]

[Y[1], Y[2], Y[3], Y[4], Y[5], Y[6]]

[indets(var1, specindex({Y}))[]]; map(addressof, %)

[Y[1], Y[2], Y[3], Y[4], Y[5], Y[6]]

[36893628250316374108, 36893628250316374132, 36893628250316374156, 36893628250316374180, 36893628250316374204, 36893628250316374228]

foo := [indets(temp, anyindex(anything))[]][1 .. 6]; map(addressof, %)

[Y[1], Y[2], Y[3], Y[4], Y[5], Y[6]]

[36893628250228598724, 36893628250228598916, 36893628250228599252, 36893628250228599444, 36893628250228599780, 36893628250228599972]

map(addressof, convert(foo, `global`))

[36893628250316374108, 36893628250316374132, 36893628250316374156, 36893628250316374180, 36893628250316374204, 36893628250316374228]

collect(simplify(expand(convert(sys0, `global`))), var1, distributed)

[Y[2], -(1/2)*(b*g*gamma-1)*Y[1]/(b*g*gamma-1/2)+(1/4)*((g*(D*U*a__11*h__2*p__2^2*rho__air-4*xi*omega__2)*gamma+2*alpha__11)*L*b-(D*U*a__11*h__2*p__2^2*rho__air-4*xi*omega__2)*L)*Y[2]/(omega*L*(b*g*gamma-1/2))+(1/2)*b*g*gamma*Y[3]/(b*g*gamma-1/2)+(1/4)*(-g*(D*U*a__11*h__2*p__2^2*rho__air-4*xi*omega__2)*gamma+2*alpha__11)*b*Y[4]/(omega*(b*g*gamma-1/2))-(1/2)*b*L__1*omega__1^2*Y[5]/(L*(b*g*gamma-1/2)*omega^2)+(1/4)*((D*a__11*U*h__2*(p__12^2+p__13^2)*rho__air-4*xi*omega__1)*L__1*b-2*alpha__11*L__1)*Y[6]/(omega*L*(b*g*gamma-1/2)), Y[4], (1/2)*b*g*gamma*Y[1]/(b*g*gamma-1/2)+(1/4)*(-g*(D*U*a__11*h__2*p__2^2*rho__air-4*xi*omega__2)*gamma+2*alpha__11)*b*Y[2]/(omega*(b*g*gamma-1/2))+(1/2)*(-b*g*gamma+1)*Y[3]/(b*g*gamma-1/2)+(1/4)*((g*(D*U*a__11*h__2*p__2^2*rho__air-4*xi*omega__2)*gamma+2*alpha__11)*L*b-(D*U*a__11*h__2*p__2^2*rho__air-4*xi*omega__2)*L)*Y[4]/(omega*L*(b*g*gamma-1/2))-(1/2)*b*L__1*omega__1^2*Y[5]/(L*(b*g*gamma-1/2)*omega^2)+(1/4)*((D*a__11*U*h__2*(p__12^2+p__13^2)*rho__air-4*xi*omega__1)*L__1*b-2*alpha__11*L__1)*Y[6]/(omega*L*(b*g*gamma-1/2)), Y[6], -(1/2)*gamma*g*L*Y[1]/((b*g*gamma-1/2)*L__1)+(1/4)*(g*(D*U*a__11*h__2*p__2^2*rho__air-4*xi*omega__2)*L*gamma-2*alpha__11*L)*Y[2]/(omega*(b*g*gamma-1/2)*L__1)-(1/2)*gamma*g*L*Y[3]/((b*g*gamma-1/2)*L__1)+(1/4)*(g*(D*U*a__11*h__2*p__2^2*rho__air-4*xi*omega__2)*L*gamma-2*alpha__11*L)*Y[4]/(omega*(b*g*gamma-1/2)*L__1)+(1/2)*omega__1^2*Y[5]/((b*g*gamma-1/2)*omega^2)+(1/4)*(4*g*alpha__11*L__1*gamma-(D*a__11*U*h__2*(p__12^2+p__13^2)*rho__air-4*xi*omega__1)*L__1)*Y[6]/(omega*(b*g*gamma-1/2)*L__1)]

 

 

Download nature_frequency_question_ac.mw


ps. I did a similar thing just a few weeks ago, in order to substitute for such names.

There are lots of ways to get such a construction. Here are a few.

restart;

f := x -> x[1]^2 + x[2]^2

proc (x) options operator, arrow; x[1]^2+x[2]^2 end proc

# correction of your attempt
# this inefficiently does the differentations every
# time it gets called.
Gf1 := proc(v::{list,Vector}) local x;
         eval(<diff(f(x),x[1]),diff(f(x),x[2])>,
              [x[1]=v[1], x[2]=v[2]]);
       end proc:

Gf1(<2,3>);

Vector(2, {(1) = 4, (2) = 6})

# this does the differentiations once, up front
# presuming that the procedure f returns the expected
# expression when called with symbolic arguments
Gf2 := unapply(Student:-MultivariateCalculus:-Gradient(f(<x[1],x[2]>),
                                                       [x[1],x[2]]),
               x::{list,Vector}):

Gf2(<2,3>);

Vector(2, {(1) = 4, (2) = 6})

# this does the differentiations once, up front
# presuming that the procedure f returns the expected
# expression when called with symbolic arguments
Gf3 := unapply(<diff(f(x),x[1]),diff(f(x),x[2])>,
               x::{list,Vector}):

Gf3(<2,3>);

Vector(2, {(1) = 4, (2) = 6})

F := (a,b) -> a^2 + b^2;

proc (a, b) options operator, arrow; b^2+a^2 end proc

D[1](F), D[2](F);
D[1](F)(2,3), D[2](F)(2,3);

proc (a, b) options operator, arrow; 2*a end proc, proc (a, b) options operator, arrow; 2*b end proc

4, 6

# this does the differentiations once, up front
# using automatic differentiation of procedure f.
Gf4 := subs( d1f=D[1](F), d2f=D[2](F),
             (v::{list,Vector}) -> <d1f(v[1],v[2]),
                                    d2f(v[1],v[2])> ):

Gf4(<2,3>);

Vector(2, {(1) = 4, (2) = 6})

Download grad_f_ex.mw

1 2 3 4 5 6 7 Last Page 1 of 336