acer

32313 Reputation

29 Badges

19 years, 312 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

The final step can also be accomplished using the collect command.

restart:

PowerBalanceEq := 0 = e1(t) * i1(t) + e2(t) * i2(t) + e3(t) * i3(t);

0 = e1(t)*i1(t)+e2(t)*i2(t)+e3(t)*i3(t)

eq_i1 := i1(t) = solve(PowerBalanceEq, i1(t));

i1(t) = -(e2(t)*i2(t)+e3(t)*i3(t))/e1(t)

n21eq := e2(t) / e1(t) = n21;

e2(t)/e1(t) = n21

eq_i2 := algsubs(n21eq, expand(eq_i1));

i1(t) = -i2(t)*n21-e3(t)*i3(t)/e1(t)

collect(eq_i2, i2(t));

i1(t) = -i2(t)*n21-e3(t)*i3(t)/e1(t)

eq_i4 := simplify(eq_i1, {e2(t) / e1(t) = n21});

i1(t) = (-i2(t)*n21*e1(t)-e3(t)*i3(t))/e1(t)

collect(eq_i4, i2(t));

i1(t) = -i2(t)*n21-e3(t)*i3(t)/e1(t)

desired := i1(t) = -n21*i2(t) - e3(t)*i3(t)/e1(t);

i1(t) = -i2(t)*n21-e3(t)*i3(t)/e1(t)

 

Download Q20210316_ac.mw

I also adjusted your use of algsubs to obtain your intended alternate, eq_i2, which had its first argument's lhs and rhs reversed. (I recall our covering that aspect previously.)

You can get rid of the warning by explicitly declaring the name as local to the procedure.

While the 2D Input parser has not yet been updated to recognize the local declaration within a procedure entered as an operator in the arrow style, you can still enter it in the proc()...end proc way.

For example, in either 2D or 1D input modes,

    f := proc(t) local n; seq(t^n, n = 0 .. 3); end proc

or, if you'd like the immediate output of the printed procedure to appear in arrow notation,

    f := proc(t) option operator, arrow; local n; seq(t^n, n = 0 .. 3); end proc

 

kernelopts(version);

     Maple 2020.1, X86 64 LINUX, Jun 8 2020, Build ID 1474533

4 %+ 3 %* 2;

            4 %+ (3 %* 2)

op(0,%), [ op(%) ];

            %+, [4, 3 %* 2]

In Maple 2019.2 it produced your cited result.

Several people had previously and independently reported the problem.

A table has last-name evaluation rules.

restart;

i := table([]);
a := 0;
for x in eval(i,1) do
        a := a + 1
end do:
a;

table( [ ] )

0

0

i := table([p=q, r=s, b=c]);
a := 0;
for x in eval(i,1) do
        a := a + 1
end do:
a;

table( [( r ) = s, ( b ) = c, ( p ) = q ] )

0

3

restart;

i := table([]);
a := 0;
for x in eval(i) do
        a := a + 1
end do:
a;

table( [ ] )

0

0

i := table([p=q, r=s, b=c]);
a := 0;
for x in eval(i) do
        a := a + 1
end do:
a;

table( [( r ) = s, ( b ) = c, ( p ) = q ] )

0

3

 

Download table_and_loop_acc.mw

You could apply rationalize or evala to the integrand, before calling int.

restart;

kernelopts(version);

    Maple 2020.1, X86 64 LINUX, Jun 8 2020, Build ID 1474533

B:=sqrt( (-4*u^(1/3)+1)*u^(4/3)):
A:=1/(-12*u+3*u^(2/3)-3*B):

foo:=int(rationalize(A),u);

  1/2*(-(4*u^(1/3)-1)*u^(4/3))^(1/2)/u^(2/3)/(-4*u^(1/3)+1)^(1/2)*arctanh((-4*u^(1/3)+1)^(1/2))-1/12*ln(u)

simplify(foo) assuming u>0;

                    /               (1/2)\           
           1        |/    (1/3)    \     |   1       
           - arctanh\\-4 u      + 1/     / - -- ln(u)
           2                                 12      

foo:=int(evala(A),u);

  1/2*(-(4*u^(1/3)-1)*u^(4/3))^(1/2)/u^(2/3)/(-4*u^(1/3)+1)^(1/2)*arctanh((-4*u^(1/3)+1)^(1/2))-1/12*ln(u)

simplify(foo) assuming u>0;

                    /               (1/2)\           
           1        |/    (1/3)    \     |   1       
           - arctanh\\-4 u      + 1/     / - -- ln(u)
           2                                 12      

And, if you prefer, you can also apply simplify to those modified integrands, before calling int.

foo:=int(simplify(evala(A)),u):
simplify(foo) assuming u>0;

foo := int(simplify(rationalize(A)),u):
simplify(foo) assuming u>0;

An alternative here for simplifying the integration result foo under the assumption that u>0 is,

simplify(combine(foo,symbolic));

I believe that the above also produces the simpler result in 2021.0, but you could check.

eqs := [(a*x1+b*x2)/x3+c*x1^2/(e*x2+d)=f];

               [                   2      ]
               [a x1 + b x2    c x1       ]
        eqs := [----------- + -------- = f]
               [    x3        e x2 + d    ]

(numer@(lhs-rhs))~(eqs);

   [a*e*x1*x2+b*e*x2^2+c*x1^2*x3-e*f*x2*x3+a*d*x1+b*d*x2-d*f*x3]

This did not also use the normal command.

Does the RealRange output appear as you want, if you first issue this command?

   interface(typesetting=extended):

Note that command can be placed near the top of a Worksheet or Document, but it should be placed in its own Execution Group or Document Block, ie. not in the same one as a restart.

I do it for at least these two reasons:

1) So that I can re-run the whole sheet by just clicking the !!! button. Ie. I don't have to also click the restart button.

2) When I write a worksheet for someone else I ensure that they'll get a clean restart if they re-run using only the !!! button. (This leads to less confusion.)

Unfortunately the plots:-listcontplot command doesn't (yet) offer easy options for specifying the ranges of the X and Y data, in the way that the plots:-surfdata command does. And the 2D usage of the surfdata command doesn't allow style=contour or style=surfacecontour.

So here are three approaches. (I concocted a procedure so that I could get some Z data with which to work.)
1) plot3d and a forced orientation so as to appear like a 2D plot.
2) contourplot using an interpolating object (made from the data)
3) listcontplot and a rescaling of the result. [Also possible here are forced tickmarks, but I didn't do that because it uses similar formulas and IMO it's slightly inferior to solve an issue by faking tickmarks. You could also refine Z by interpolating it using ArrayInterpolation, and then use listcontplot. But since that still leaves the tickmarks issue it just seems like unnecessarily more effort than approach 2).]

matrix_cont_plot.mw

If the approach of generating such smooth, interpolated contours is ok for you, then note that there are additional options and choices to control the interpolation scheme. I leave that aside for now.

Are you aiming for a pde33 result something like this?

de_subst.mw

Using Maple 2020.1,

filenm:="https://www.gw-openscience.org/GW150914data/P150914/fig2-unfiltered-template-reconstruction-H.txt":

M:=ImportMatrix(filenm,source=Matlab,skiplines=1):

plot(M[..,[1,3]]);

You can add various options for the plotting command (eg. axis labels, color, line style, etc).

You can use the commands Create and Save from the LibraryTools package to create a new .mla (Maple Library Archive) file and store your procedures or modules.

You can then make the contents of that .mla file available to any new session by augmenting libname. with the location of that .mla file. (Don't put it inside Maple's installation directory; that's a poor choice.)

You can code that augments libname into a personal initialization file. Alternatively you could put the .mla file in a specially named toolbox folder so that libname is augmented automagically. (Ask if you want details on doing that. Or see chapter 11 or section 11.4 of the Programming Guide.) If you do either of those then you don't need to explicitly adjust libname in each session/worksheet.

See the attached worksheet for reusable procedure(s).

atomic_subsup.mw

Three procedures are included.

The first is simple, but inflexible wrt italics (mi vs mo), and doesnt typeset sub/superscripts. (It's close to dharr's procedure.)

The second accomodates those issues by typesetting both sub/superscript.

The third is more general. It turns most any expression into a so-called atomic identifier (ie. name), via TypeMK. The effect is similar to what the right-click menu does, but programmatic.

Don't use 0.5 as an exponent if you could use 1/2 instead. The former can introduce roundoff issues when manipulating the expression.

Here is something (in Maple 2015 as you used), first solving for x and then applying sin.

restart;
kernelopts(version);

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

expr := cos(2*x)-sin(x)*(sin(x)^2+1)^(1/2)
        +cos(x)^2*sin(x)/(sin(x)^2+1)^(1/2):

convert([solve(expr)],
        compose, radical, arcsin);

        [       /1   (1/2)\         /1   (1/2)\      ]
        [ arcsin|- 12     |, -arcsin|- 12     | + Pi ]
        [       \6        /         \6        /      ]

map(simplify@sin, %);

             [ 1  (1/2)  1  (1/2) ]
             [ - 3     , - 3      ]
             [ 3         3        ]

simpl_sin_isolate.mw

I don't know why I didn't notice this shorter form earlier:

map(sin, [solve(expr)]);

               1/2   1/2
              3     3
             [----, ----]
               3     3

As Tom showed, that can be done even terser as,

sin~([solve(expr)]);

@MapleEnthusiast It is not very surprising that the first 9 digits of pairwaise entries (in each of the two columns) match.

If you want additional digits that illustrate that the two rows are not actually the same, then you may increase the working precision by assigning a value (higher than 15, say) to Digits.

matinv_bad_cond.mw

 

First 92 93 94 95 96 97 98 Last Page 94 of 336