acer

32405 Reputation

29 Badges

19 years, 350 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Is this the kind of thing that you are trying to do?

note: here, you may compare,
   CharacteristicPolynomial(A,lambda);
   Determinant(A-lambda);

restart;

with(LinearAlgebra):

 

A := <<3|2>,<-1|4>>;
CharacteristicPolynomial(A,lambda);
Determinant(A-lambda);
eval(%,lambda=A);

Matrix(2, 2, {(1, 1) = 3, (1, 2) = 2, (2, 1) = -1, (2, 2) = 4})

lambda^2-7*lambda+14

lambda^2-7*lambda+14

Matrix(%id = 36893628834902374868)

A:= <<2|1>,<-3|-1>>;
CharacteristicPolynomial(A,lambda);
eval(%,lambda=A);

Matrix(2, 2, {(1, 1) = 2, (1, 2) = 1, (2, 1) = -3, (2, 2) = -1})

lambda^2-lambda+1

Matrix(%id = 36893628834902364276)

A := <<2|1|-1>,<0|1|0>,<-1|0|1>>;
CharacteristicPolynomial(A,lambda);
eval(%,lambda=A);

Matrix(3, 3, {(1, 1) = 2, (1, 2) = 1, (1, 3) = -1, (2, 1) = 0, (2, 2) = 1, (2, 3) = 0, (3, 1) = -1, (3, 2) = 0, (3, 3) = 1})

lambda^3-4*lambda^2+4*lambda-1

Matrix(%id = 36893628834902356084)

A := <<-2|1|-1>,<0|1|5>,<-1|5|2>>;
CharacteristicPolynomial(A,lambda);
eval(%,lambda=A);

Matrix(3, 3, {(1, 1) = -2, (1, 2) = 1, (1, 3) = -1, (2, 1) = 0, (2, 2) = 1, (2, 3) = 5, (3, 1) = -1, (3, 2) = 5, (3, 3) = 2})

lambda^3-lambda^2-30*lambda-40

Matrix(%id = 36893628834902348252)

Download cpoly.mw

(check for typos)

restart;

ps := PolyhedralSets:-PolyhedralSet([[1,1,0],[-1,1,0],[-1,-1,0],
                                     [-1/2,0,1],[1/2,-1/2,0]],[x,y,z]):

 

PolyhedralSets:-Volume(ps);

1

PolyhedralSets:-Plot(ps);

Relations(ps);

[-z <= 0, y+z <= 1, (1/2)*z-x <= 1, x+(5/2)*z-3*y <= 2, -(1/3)*y+(7/6)*z+x <= 2/3]

Download ps_volume.mw

It's not clear whether you want, say, one of the edges of the result to be along a common ray as one of the edges of the original.

It's also unclear whether you want to produce only the transformed result directly, or whether you want to produce both (transforming the original into the result).

For example, using an orientation so as to get a view down onto the triangles,

restart;

P := plot3d(v^3,u=0..1-v, v=0..1,
            orientation=[-90,0,0], style=surface);

plots:-display(
  plottools:-transform((x,y,z)->[x+y/2,y*sqrt(3)/2,z])(P),
  view=[0..1,0..1,0..1], labels=[u,v,""],
  orientation=[-90,0,0], style=surface);

 

Download 3d_tri_transf.mw

Of course you can still rotate those; they are 3d plots of surfaces.

What you've stated about reading in names containing such characters is not true. Code with assignments to such can be read in via .mpl files.

But you can run into difficulties when you try to refer to them in new input lines in the GUI. In a roundabout way you can access those assigned names, and their values, via anames(user).

However, what will usually happen is that if you copy&paste such a name into the GUI what will actually be input are more like the names,
   `&zeta;X1``&zeta;X2`

So, when you write, "...shows as unassigned" be careful that you're actually using/entering the name you intend to access. Having difficult entering the intended names does not mean that the names are unassigned.

Now, those specially formed ASCII names also happen to both pretty-print in output in the manner you've shown, in the GUI, with typeset Greek prefixes.

You can even enter those in the GUI without having to make all those extra keystrokes, by using the appropriate GUI palette for the Greek letter while in 2D Input mode.

So, one solution is to use the names like `&zeta;X1` for your plaintext .mpl files, instead of utf-8 unicode.

In other words, use the intended mechanisms that the GUI supports and is designed for.

In the following worksheet, I read in the code you showed from a plaintext file which I named "foo.mpl". This is just an illustration of the fact that the names you originally gave can indeed (contrary to your claim) be read in via .mpl text format and assigned to.

restart;

read "foo.mpl";

nms := anames(user);

`&zeta;X2`, `&zeta;X1`

nms;

(1/3)*Pi, 0

lprint(eval(nms,1));

`ζX2`, `ζX1`

`&zeta;X2`, `&zeta;X1`

`&zeta;X2`, `&zeta;X1`

eval(nms,1)[1];

`&zeta;X2`

These are not the same thing.

`&zeta;X2` - eval(nms,1)[1];

`&zeta;X2`-`&zeta;X2`

Download uni_nms.mw

Some earlier postings by you indicated that you might still be using Maple 2022.

The following works in Maple 2022.2 (and several earlier versions as well, including Maple 2018.2 and Maple 16.02).

expr := sin(theta)^(A - 2)*cos(theta)^2
        - sin(theta)^(A - 2) + sin(theta)^A:

 

simplify(expand(expr));

0

Download trig_simp_ex2.mw

In Maple 2023.0 your example is handled directly by the simplify command.

If it's of interest, one can observe why expanding wrt powers helps here. After the expand, the result can be factored, with one of the factors being zero by simple Pythagorean trig identity.

expr := sin(theta)^(A - 2)*cos(theta)^2
        - sin(theta)^(A - 2) + sin(theta)^A:

expand(expr);

sin(theta)^A*cos(theta)^2/sin(theta)^2-sin(theta)^A/sin(theta)^2+sin(theta)^A

factor(%);

sin(theta)^A*(sin(theta)^2+cos(theta)^2-1)/sin(theta)^2

You could make the following kinds of checks, using the is command.

restart;

is( -7.5 in RealRange(Open(-10),-5) )

true

is( -7.5 in RealRange(Open(-6),infinity) )

false

is( -7.5 in Or(RealRange(Open(-6),infinity),
               RealRange(Open(-10),-5)) );

true

is( A in Or(RealRange(Open(-6),infinity),
               RealRange(Open(-10),-5)) )
  assuming A>-9;

true

is( A in Or(RealRange(Open(-6),infinity),
               RealRange(Open(-10),-5)) )
  assuming A>-11;

false

coulditbe( A in Or(RealRange(Open(-6),infinity),
               RealRange(Open(-10),-5)) )
  assuming A>-11;

true

coulditbe( A in Or(RealRange(Open(-6),infinity),
               RealRange(Open(-10),-5)) )
  assuming A<-11;

false

Download RR_is.mw

You could also assign your disjunction (or other logical operator construction) to a name, and re-use it. Eg,

Dis := Or(RealRange(Open(-6),infinity),
          RealRange(Open(-10),-5)):

 

is( -7 in Dis );

true

is( A in Dis ) assuming A<-11;

false

is( A::Dis ) assuming A>-9;

true

 

It is unfortunate that Maple 2023.0 does not have cross-reference links from the Help page for topic RealRange to the Help pages with topics assume (is) and property.

Let's suppose that you have a worksheet with some Startup Code.

The "Maple Code Editor Diagnostics" panel shows syntax errors and some basic kinds of potential issues that might arise when the code is executed. A syntax error is different from an error raised when the code is executed.

If the code is executed using the Startup Code region's menu then runtime errors get reported to the "Maple Code Editor Console".

Those distinctions are why these appear in two separate bullet points in the Startup Code documentation; they relate to two different kinds of messages.

• 

The Diagnostics panel at the bottom of the Startup Code Editor window displays the output from code analysis done on any Maple code entered into the code editor.

• 

The Console panel displays output from the code entered in the Startup Code Editor. The Console can be used for prototyping and testing your code. To clear the Console, from the View menu, select Clear Console.


A simple (single, say) pass through the code may allow the code analyzer (here, mint, underneath) to deduce a few common and simple kinds of potential runtime problems -- procedure locals used before being initialized, unattainable code blocks, locals assigned values but then not used, etc. These kinds of issue are reported to the Diagnostics panel.

But these diagnostics don't execute the code in full. And hence they will certainly not find all kinds of future runtime error, since doing so without actual execution is logically impossible. Runtime error message get reported to the Console panel, if executed by the Startup Code's menu.

Code can be run under the debugger. Doing so can require learning its techniques.

I would prefer to pass {x} rather than unadorned x as the second argument to solve, for consistency of output, and then fix up the conversions to RealRange.

I don't know whether you'd prefer sets or Or to be used to denote logical disjunction. Having it be denoted by mere sequences seems dodgy to me, because more involved multiple solutions could become wrongly conflated. (I don't much like T1 below returning a mere sequence...)

I also don't know whether you'd want to handle univariate examples with names other than x. It's hardcoded in T3 at present. (Also, you can't sensibly have nameless RealRanges for multivariate examples, naturally.)

I also don't know what other, future, less trivial examples you'd want to handle.

restart;

#interface(prettyprint=0):

 

with(RealDomain):

 

RealRange(-infinity,infinity):='RealRange(-infinity,infinity)':

 

T1 := ()->subsindets([args],`<>`,u->(lhs(u)<rhs(u),lhs(u)>rhs(u)))[]:

T2 := ()->subsindets([args],And(name=name,':-satisfies'(evalb)),
                    RealRange(-infinity,infinity))[]:

T3 := ()->subsindets([args],`::`(identical(x),anything),rhs)[]:

A := ()->T3(convert(T2(T1([args])), RealRange)[]):

 

A( solve(x-1 > 0, {x}) );

{RealRange(Open(1),infinity)}

A( solve(1/x^2 > 0, {x}) );

{RealRange(-infinity,Open(0)), RealRange(Open(0),infinity)}

A( solve(1/(x^2-1) > 0, {x}) );

{RealRange(-infinity,Open(-1))}, {RealRange(Open(1),infinity)}

A( solve(x^2+1 > 0, {x}) );

{RealRange(-infinity,infinity)}

A( solve(x^2+1 < 0, {x}) ); # NULL

 

Download solve_RR.mw

You are trying to use an exact solving methodology on an expression containing float exponents. (That can make solving fully over the complex numbers be quite a demand.)

Using fsolve is more suitable here.

fsolve(.2894606222 = .4090662520/((1+0.1481289280e-2*x)^5.034901366
                                  *(1/(1+0.1481289280e-2*x)^5.034901366)^.1986136226),
       x);

          60.41863487

Also note that converting to rationals (even "exactly") and forcing it through solve doesn't really help much to getting an accurate floating-point  result here.

expr := .2894606222 = .4090662520/((1+0.1481289280e-2*x)^5.034901366
                                  *(1/(1+0.1481289280e-2*x)^5.034901366)^.1986136226):

 

eval(solve(subsindets(expr,float,__K),
           {x}),
     __K=(x->x));

{x = (3125000000/4629029)*exp(.2478375329*ln(2045331260/1447303111))-675.0875832}

evalf(%);
evalf[10](evalf[50](%%));

{x = 60.4186348}

{x = 60.41863484}

eval(solve(subsindets(expr,float,
                      u->__K(convert(u,rational,exact))),
           {x}),
     __K=(x->x));

{x = (3125000000/6699608072609219)*2045331260^(2500000000000000000/10087253415662628821)*1447303111^(7587253415662628821/10087253415662628821)-3125000000/4629029}

evalf(%);
evalf[10](evalf[50](%%));

{x = 60.4186350}

{x = 60.41863487}

fsolve(expr);

60.41863487

evalf[10](evalf[50](fsolve(expr)));

60.41863487

Download fs_1.mw

Here is a brief way to do that.

   L := [seq(cos(x), x=0.1 .. 10.0, 0.1)];
   S := sort(L);
   S[35];

which produces -0.5885011173 as its last result.

Here's a slightly longer way, that shows a bit more. (figured that you're trying to learn some Maple. You could try and work out for yourself what these commands do...)

L := [seq([x,cos(x)], x=0.1 .. 10.0, 0.1)]:


Here is the list of 100 entries, cos(0.1) to cos(10.0)

L[..,2];

[.9950041653, .9800665778, .9553364891, .9210609940, .8775825619, .8253356149, .7648421873, .6967067093, .6216099683, .5403023059, .4535961214, .3623577545, .2674988286, .1699671429, 0.7073720167e-1, -0.2919952230e-1, -.1288444943, -.2272020947, -.3232895669, -.4161468365, -.5048461046, -.5885011173, -.6662760213, -.7373937155, -.8011436155, -.8568887534, -.9040721420, -.9422223407, -.9709581651, -.9899924966, -.9991351503, -.9982947758, -.9874797699, -.9667981926, -.9364566873, -.8967584163, -.8481000317, -.7909677119, -.7259323042, -.6536436209, -.5748239465, -.4902608213, -.4007991721, -.3073328700, -.2107957994, -.1121525269, -0.1238866346e-1, 0.8749898344e-1, .1865123694, .2836621855, .3779777427, .4685166713, .5543743362, .6346928759, .7086697743, .7755658785, .8347127848, .8855195169, .9274784307, .9601702867, .9832684384, .9965420970, .9998586364, .9931849188, .9765876257, .9502325920, .9143831482, .8693974903, .8157251001, .7539022543, .6845466664, .6083513145, .5260775174, .4385473276, .3466353178, .2512598426, .1533738620, 0.5395542056e-1, -0.4600212564e-1, -.1455000338, -.2435441537, -.3391548610, -.4313768450, -.5192886541, -.6020119027, -.6787200473, -.7486466456, -.8110930141, -.8654352092, -.9111302619, -.9477216021, -.9748436214, -.9922253255, -.9996930420, -.9971721562, -.9846878558, -.9623648798, -.9304262721, -.8891911526, -.8390715291]

S := sort( L, key=(u->op(2,u)) ):


Here is the sorted list.

S[..,2];

[-.9996930420, -.9991351503, -.9982947758, -.9971721562, -.9922253255, -.9899924966, -.9874797699, -.9846878558, -.9748436214, -.9709581651, -.9667981926, -.9623648798, -.9477216021, -.9422223407, -.9364566873, -.9304262721, -.9111302619, -.9040721420, -.8967584163, -.8891911526, -.8654352092, -.8568887534, -.8481000317, -.8390715291, -.8110930141, -.8011436155, -.7909677119, -.7486466456, -.7373937155, -.7259323042, -.6787200473, -.6662760213, -.6536436209, -.6020119027, -.5885011173, -.5748239465, -.5192886541, -.5048461046, -.4902608213, -.4313768450, -.4161468365, -.4007991721, -.3391548610, -.3232895669, -.3073328700, -.2435441537, -.2272020947, -.2107957994, -.1455000338, -.1288444943, -.1121525269, -0.4600212564e-1, -0.2919952230e-1, -0.1238866346e-1, 0.5395542056e-1, 0.7073720167e-1, 0.8749898344e-1, .1533738620, .1699671429, .1865123694, .2512598426, .2674988286, .2836621855, .3466353178, .3623577545, .3779777427, .4385473276, .4535961214, .4685166713, .5260775174, .5403023059, .5543743362, .6083513145, .6216099683, .6346928759, .6845466664, .6967067093, .7086697743, .7539022543, .7648421873, .7755658785, .8157251001, .8253356149, .8347127848, .8693974903, .8775825619, .8855195169, .9143831482, .9210609940, .9274784307, .9502325920, .9553364891, .9601702867, .9765876257, .9800665778, .9832684384, .9931849188, .9950041653, .9965420970, .9998586364]

S[35];

[2.2, -.5885011173]


The 35th term of the sorted list is -.5885011173, which
comes from cos(2.2)

cos(2.2);

-.5885011173

plots:-display(
  plots:-listplot(S[..,2], size=[500,200]),
  plots:-pointplot([[35,S[35][2]]],color=red,
                   symbol=solidcircle,symbolsize=15),
  axis[1]=[tickmarks=[seq(10..100,10)],
           gridlines=[[seq(5..100,10)]]]);

Download sort_cos_list.mw

You may have noticed that lists L and S each contain both the x-values as well as the cos(x) values. I only did it that way because I thought that it'd be fun/interesting to be able to immediately get the corresponding x-value which produced the 35th greatest cos-value, without doing any additional computation.

You've already assigned ics itself as a set., ie.
   ics := {V(0) = -65, h(0) = 0.6, m(0) = 0.05, n(0) = 0.32}

Having done that, you could pass either,
    {eq1, eq2, eq3, eq4} union ics
or,
    {eq1, eq2, eq3, eq4, op(ics)}
to dsolve.

That merges the differential equations and initial conditions together into a single (flat) set. 

Or you could assign only the expression sequence of conditions to ics (and not itself a set), ie,
   ics := V(0) = -65, h(0) = 0.6, m(0) = 0.05, n(0) = 0.32;
and then pass your original formulation to dsolve, ie.,
   {eq1, eq2, eq3, eq4, ics}

Adjust the rest, as desired. I didn't look to see if your system and the results made sense.

restart

Cm := 1.0; ENa := 50.0; EK := -77.0; ELeak := -54.387; gNa := 120.0; gK := 36.0; gLeak := .3

1.0

50.0

-77.0

-54.387

120.0

36.0

.3

II := piecewise(`and`(t >= 10, t <= 40), 10.0, 0.); alpha_m := proc (V) .1*(V+40.0)/(1.0-exp((-1)*(V+40.0)/10.0)) end proc; beta_m := proc (V) 4.0*exp((-1)*(V+65.0)/18.0) end proc; alpha_h := proc (V) 0.7e-1*exp((-1)*(V+65.0)/20.0) end proc; beta_h := proc (V) 1.0/(1.0+exp((-1)*(V+35.0)/10.0)) end proc; alpha_n := proc (V) 0.1e-1*(V+55.0)/(1.0-exp((-1)*(V+55.0)/10.0)) end proc; beta_n := proc (V) .125*exp((-1)*(V+65.0)/80.0) end proc

piecewise(10 <= t and t <= 40, 10.0, 0.)

proc (V) .1*(V+40.0)/(1.0-exp((-1)*(V+40.0)/10.0)) end proc

proc (V) 4.0*exp((-1)*(V+65.0)/18.0) end proc

proc (V) 0.7e-1*exp((-1)*(V+65.0)/20.0) end proc

proc (V) 1.0/(1.0+exp((-1)*(V+35.0)/10.0)) end proc

proc (V) 0.1e-1*(V+55.0)/(1.0-exp((-1)*(V+55.0)/10.0)) end proc

proc (V) .125*exp((-1)*(V+65.0)/80.0) end proc

eq1 := diff(V(t), t) = (II-gNa*m(t)^3*h(t)*(V(t)-ENa)-gK*n(t)^4*(V(t)-EK)-gLeak*(V(t)-ELeak))/Cm; eq2 := diff(m(t), t) = alpha_m(V(t))*(1-m(t))-beta_m(V(t))*m(t); eq3 := diff(h(t), t) = alpha_h(V(t))*(1-h(t))-beta_h(V(t))*h(t); eq4 := diff(n(t), t) = alpha_n(V(t))*(1-n(t))-beta_n(V(t))*n(t); ics := {V(0) = -65, h(0) = .6, m(0) = 0.5e-1, n(0) = .32}

diff(V(t), t) = 1.000000000*piecewise(10 <= t and t <= 40, 10.0, 0.)-120.0000000*m(t)^3*h(t)*(V(t)-50.0)-36.00000000*n(t)^4*(V(t)+77.0)-.3000000000*V(t)-16.31610000

diff(m(t), t) = .1*(V(t)+40.0)*(1-m(t))/(1.0-exp(-.1000000000*V(t)-4.000000000))-4.0*exp(-0.5555555556e-1*V(t)-3.611111111)*m(t)

diff(h(t), t) = 0.7e-1*exp(-0.5000000000e-1*V(t)-3.250000000)*(1-h(t))-1.0*h(t)/(1.0+exp(-.1000000000*V(t)-3.500000000))

diff(n(t), t) = 0.1e-1*(V(t)+55.0)*(1-n(t))/(1.0-exp(-.1000000000*V(t)-5.500000000))-.125*exp(-0.1250000000e-1*V(t)-.8125000000)*n(t)

{V(0) = -65, h(0) = .6, m(0) = 0.5e-1, n(0) = .32}

sol := dsolve(`union`({eq1, eq2, eq3, eq4}, ics), {V(t), h(t), m(t), n(t)}, numeric)

plots:-odeplot(sol, [t, h(t)], t = 0 .. 60)

plots:-odeplot(sol, [t, m(t)], t = 0 .. 60)

plots:-odeplot(sol, [t, n(t)], t = 0 .. 60)

plots:-odeplot(sol, [t, V(t)], t = 0 .. 60)

Download Question1_ac.mw

Here's one way, collecting wrt the global :-diff.

The colon-minus prefix makes it refer to the global name diff rather than the Physics export going by the similar name.

restart;

Run the code with Physics loaded and it does not collect in diff but if you put a # infront of physics it works fine.

with(Physics):

CompactDisplay(varphi(X),psi(X))

varphi(X)*`will now be displayed as`*varphi

psi(X)*`will now be displayed as`*psi

X:=tau,x,y,z

tau, x, y, z

expr := (6*alpha)*varphi(X)*A^4*1/a(tau)^2 + (-12*diff(Phi(X), tau) - 12*diff(psi(X), tau))*alpha*A^3*1/a(tau)^2 + (-4*diff(diff(Phi(X), x), x) - 4*diff(diff(Phi(X), y), y) - 4*diff(diff(Phi(X), z), z) - 4*diff(diff(psi(X), x), x) - 4*diff(diff(psi(X), y), y) - 4*diff(diff(psi(X), z), z))*alpha*A^2*1/a(tau)^2 + (-(6*varphi(X))*H(tau)^4 - (12*H(tau)^3)*diff(psi(X), tau) + (4*H(tau)^2)*diff(diff(psi(X), x), x) + (4*H(tau)^2)*diff(diff(psi(X), y), y) + (4*H(tau)^2)*diff(diff(psi(X), z), z))*alpha*1/a(tau)^2 - (6*H(tau))*diff(psi(X), tau) + 2*diff(diff(psi(X), x), x) + 2*diff(diff(psi(X), y), y) + 2*diff(diff(psi(X), z), z)

6*alpha*varphi(tau, x, y, z)*A^4/a(tau)^2+(-12*(diff(Phi(tau, x, y, z), tau))-12*(diff(psi(tau, x, y, z), tau)))*alpha*A^3/a(tau)^2+(-4*(diff(diff(Phi(tau, x, y, z), x), x))-4*(diff(diff(Phi(tau, x, y, z), y), y))-4*(diff(diff(Phi(tau, x, y, z), z), z))-4*(diff(diff(psi(tau, x, y, z), x), x))-4*(diff(diff(psi(tau, x, y, z), y), y))-4*(diff(diff(psi(tau, x, y, z), z), z)))*alpha*A^2/a(tau)^2+(-6*varphi(tau, x, y, z)*H(tau)^4-12*H(tau)^3*(diff(psi(tau, x, y, z), tau))+4*H(tau)^2*(diff(diff(psi(tau, x, y, z), x), x))+4*H(tau)^2*(diff(diff(psi(tau, x, y, z), y), y))+4*H(tau)^2*(diff(diff(psi(tau, x, y, z), z), z)))*alpha/a(tau)^2-6*H(tau)*(diff(psi(tau, x, y, z), tau))+2*(diff(diff(psi(tau, x, y, z), x), x))+2*(diff(diff(psi(tau, x, y, z), y), y))+2*(diff(diff(psi(tau, x, y, z), z), z))

map(simplify, collect(expr, :-diff));

-12*alpha*A^3*(diff(Phi(tau, x, y, z), tau))/a(tau)^2-4*alpha*A^2*(diff(diff(Phi(tau, x, y, z), x), x))/a(tau)^2-4*alpha*A^2*(diff(diff(Phi(tau, x, y, z), y), y))/a(tau)^2-4*alpha*A^2*(diff(diff(Phi(tau, x, y, z), z), z))/a(tau)^2-4*(diff(diff(psi(tau, x, y, z), x), x))*(alpha*A^2-H(tau)^2*alpha-(1/2)*a(tau)^2)/a(tau)^2-4*(diff(diff(psi(tau, x, y, z), y), y))*(alpha*A^2-H(tau)^2*alpha-(1/2)*a(tau)^2)/a(tau)^2-4*(diff(diff(psi(tau, x, y, z), z), z))*(alpha*A^2-H(tau)^2*alpha-(1/2)*a(tau)^2)/a(tau)^2-12*(diff(psi(tau, x, y, z), tau))*(alpha*A^3+H(tau)^3*alpha+(1/2)*H(tau)*a(tau)^2)/a(tau)^2+6*alpha*varphi(tau, x, y, z)*A^4/a(tau)^2-6*varphi(tau, x, y, z)*H(tau)^4*alpha/a(tau)^2

collect(expr, :-diff, simplify);

-12*alpha*A^3*(diff(Phi(tau, x, y, z), tau))/a(tau)^2-4*alpha*A^2*(diff(diff(Phi(tau, x, y, z), x), x))/a(tau)^2-4*alpha*A^2*(diff(diff(Phi(tau, x, y, z), y), y))/a(tau)^2-4*alpha*A^2*(diff(diff(Phi(tau, x, y, z), z), z))/a(tau)^2+(-4*alpha*A^2/a(tau)^2+4*H(tau)^2*alpha/a(tau)^2+2)*(diff(diff(psi(tau, x, y, z), x), x))+(-4*alpha*A^2/a(tau)^2+4*H(tau)^2*alpha/a(tau)^2+2)*(diff(diff(psi(tau, x, y, z), y), y))+(-4*alpha*A^2/a(tau)^2+4*H(tau)^2*alpha/a(tau)^2+2)*(diff(diff(psi(tau, x, y, z), z), z))+(-12*alpha*A^3/a(tau)^2-12*H(tau)^3*alpha/a(tau)^2-6*H(tau))*(diff(psi(tau, x, y, z), tau))+6*alpha*varphi(tau, x, y, z)*(A^4-H(tau)^4)/a(tau)^2

Download CollectDiff_ac.mw

The following replaces all names of the form `x` followed by a positive integer.

It handles your set of names assigned to t, and it doesn't matter how many such names there are.

It also allows you to make such replacements within expressions more generally.

restart;

t:={seq(x||i,i=1..100)};

{x1, x10, x100, x11, x12, x13, x14, x15, x16, x17, x18, x19, x2, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, x3, x30, x31, x32, x33, x34, x35, x36, x37, x38, x39, x4, x40, x41, x42, x43, x44, x45, x46, x47, x48, x49, x5, x50, x51, x52, x53, x54, x55, x56, x57, x58, x59, x6, x60, x61, x62, x63, x64, x65, x66, x67, x68, x69, x7, x70, x71, x72, x73, x74, x75, x76, x77, x78, x79, x8, x80, x81, x82, x83, x84, x85, x86, x87, x88, x89, x9, x90, x91, x92, x93, x94, x95, x96, x97, x98, x99}

subsindets(t, 'suffixed(x,posint)',
           nm->cat('y',String(nm)[2..]));

{y1, y10, y100, y11, y12, y13, y14, y15, y16, y17, y18, y19, y2, y20, y21, y22, y23, y24, y25, y26, y27, y28, y29, y3, y30, y31, y32, y33, y34, y35, y36, y37, y38, y39, y4, y40, y41, y42, y43, y44, y45, y46, y47, y48, y49, y5, y50, y51, y52, y53, y54, y55, y56, y57, y58, y59, y6, y60, y61, y62, y63, y64, y65, y66, y67, y68, y69, y7, y70, y71, y72, y73, y74, y75, y76, y77, y78, y79, y8, y80, y81, y82, y83, y84, y85, y86, y87, y88, y89, y9, y90, y91, y92, y93, y94, y95, y96, y97, y98, y99}

expr := x1*x2 + x5^2 + sin(x117);

x1*x2+x5^2+sin(x117)

subsindets(expr, 'suffixed(x,posint)',
           nm->cat('y',String(nm)[2..]));

y1*y2+y5^2+sin(y117)

Download subsind_ex.mw

If you know that there are just that particular 100 such names then you could do it more tersely like, say,

   subs('x||i=y||i'$i=1..100,t);
or,
   subs('x||i=y||i'$i=1..100,expr);

Or, using it more than once,

   S:='x||i=y||i'$i=1..100:
   subs(S,t);
   subs(S,expr);

Don't make the assignment to C if you want it to remain as an unassigned name.

It looks as if you wanted to use only an equation involving C, not an assignment.

restart;

rho := `&rho;g`*ng + `&rho;p`*np + `&rho;w`*nw;

`&rho;g`*ng+`&rho;p`*np+`&rho;w`*nw

B := np/Kp + nw/Kw + ng/Kg;

np/Kp+nw/Kw+ng/Kg

eqn := C = (B/rho)^(1/2);

C = ((np/Kp+nw/Kw+ng/Kg)/(`&rho;g`*ng+`&rho;p`*np+`&rho;w`*nw))^(1/2)

isolate( eqn, ng );

ng = -Kg*(`&rho;p`*C^2*Kp*Kw*np+`&rho;w`*C^2*Kp*Kw*nw-Kp*nw-Kw*np)/(Kw*Kp*(`&rho;g`*C^2*Kg-1))

Download isol.mw

You wrote of expressing them in terms of each other.

I'd be interested to know whether your wider investigations might have any use for expressing them all ("compactly") in terms of additional temporary variables.

For example,

restart

t__1 := (`&sigma;__v`[2]^2*(`&rho;__v`[1, 2]^2-1)-`&sigma;__&epsilon;2`^2)*`&sigma;__v`[1]^2/((`&sigma;__v`[2]^2*(`&rho;__v`[1, 2]^2-1)-`&sigma;__&epsilon;2`^2)*`&sigma;__v`[1]^2-`&sigma;__&epsilon;1`^2*(`&sigma;__&epsilon;2`^2+`&sigma;__v`[2]^2))

t__2 := -`&sigma;__v`[1]*`&rho;__v`[1, 2]*`&sigma;__v`[2]*`&sigma;__&epsilon;1`^2/((`&sigma;__v`[2]^2*(`&rho;__v`[1, 2]^2-1)-`&sigma;__&epsilon;2`^2)*`&sigma;__v`[1]^2-`&sigma;__&epsilon;1`^2*(`&sigma;__&epsilon;2`^2+`&sigma;__v`[2]^2))

t__3 := (`&sigma;__v`[1]*`&rho;__v`[1, 2]*`&sigma;__v`[2]*`&sigma;__&epsilon;1`^2*`&nu;__0`[2]-`&nu;__0`[1]*`&sigma;__&epsilon;1`^2*(`&sigma;__&epsilon;2`^2+`&sigma;__v`[2]^2))/((`&sigma;__v`[2]^2*(`&rho;__v`[1, 2]^2-1)-`&sigma;__&epsilon;2`^2)*`&sigma;__v`[1]^2-`&sigma;__&epsilon;1`^2*(`&sigma;__&epsilon;2`^2+`&sigma;__v`[2]^2))

 

a1 := `&sigma;__&epsilon;1`^2

a2 := `&sigma;__&epsilon;2`^2+`&sigma;__v`[2]^2

a3 := (`&sigma;__v`[2]^2*(`&rho;__v`[1, 2]^2-1)-`&sigma;__&epsilon;2`^2)*`&sigma;__v`[1]^2

a4 := 1/(-a1*a2+a3)

a5 := a1*a4

a6 := `&sigma;__v`[1]*`&rho;__v`[1, 2]*`&sigma;__v`[2]

[a3*a4, -a5*a6, a5*(-a2*`&nu;__0`[1]+a6*`&nu;__0`[2])]

[(sigma__v[2]^2*(rho__v[1, 2]^2-1)-`&sigma;__&epsilon;2`^2)*sigma__v[1]^2/((sigma__v[2]^2*(rho__v[1, 2]^2-1)-`&sigma;__&epsilon;2`^2)*sigma__v[1]^2-`&sigma;__&epsilon;1`^2*(`&sigma;__&epsilon;2`^2+sigma__v[2]^2)), -sigma__v[1]*rho__v[1, 2]*sigma__v[2]*`&sigma;__&epsilon;1`^2/((sigma__v[2]^2*(rho__v[1, 2]^2-1)-`&sigma;__&epsilon;2`^2)*sigma__v[1]^2-`&sigma;__&epsilon;1`^2*(`&sigma;__&epsilon;2`^2+sigma__v[2]^2)), `&sigma;__&epsilon;1`^2*(-(`&sigma;__&epsilon;2`^2+sigma__v[2]^2)*nu__0[1]+sigma__v[1]*rho__v[1, 2]*sigma__v[2]*nu__0[2])/((sigma__v[2]^2*(rho__v[1, 2]^2-1)-`&sigma;__&epsilon;2`^2)*sigma__v[1]^2-`&sigma;__&epsilon;1`^2*(`&sigma;__&epsilon;2`^2+sigma__v[2]^2))]

Download rearrangingterms_q2.mw

I made those additional temporary substitutions as assignments. But they could also be formulated as a sequence of equations (for substitution into each other, up the chain).

You could optionally (telescopically) collapse a portion of that sequence of subsitutions, from the top down.  Eg, you could retain only the knowledge in a5 & a6, or what have you.

Also, such a scheme can also support a wider set of operations (expression forms) than just mere polynomials. For polynomials there are various techniques (basis, triangularization, etc) to produce such a substituion chain. But there are also mechanisms for doing it for a wider (non-polynomial) class.

First 44 45 46 47 48 49 50 Last Page 46 of 336