acer

32358 Reputation

29 Badges

19 years, 331 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

sol := {x=12.0005, y=4.65}:

eval(x, sol);

eval(y, sol);

eval(x^2+y/5, sol);
restart;

expr := (M/(L*T))^a*(M/L^3)^b*(L^2)^c:

ans:=simplify(expr) assuming L>0, T>0:

ans;

               (-a - 3 b + 2 c)  (-a)  (a + b)
              L                 T     M

combine(expand(expr)) assuming L>0, T>0;

               (-a - 3 b + 2 c)  (-a)  (a + b)
              L                 T     M

combine(expand(expr)) assuming a::integer, b::integer, c::integer;

               (-a - 3 b + 2 c)  (-a)  (a + b)
              L                 T     M

combine(expand(expr)) assuming a::integer, L>0;

               (-a - 3 b + 2 c)  (-a)  (a + b)
              L                 T     M

eval([expr,ans],[a=1,b=1,c=1/4,M=1,T=1,L=-2.0]);

               [0.08838834762, 0.08838834765 I]

It is coincidence that op(0,e) happens to be the capitalized instance of the name of a type, for e being of numeric type such as integer, float.

Rather, op(0,e) for such things is the name of a constructor, such that op(0,e)( op(e) ) constructs e itself.

Eg,

op(0, 35.4);
                        Float

op(35.4);
                       354, -1

Float( 354, -1 );
                         35.4

op(0, 35.4)( op(35.4) )
                         35.4

op(0, 2/3);
                        Fraction

op(2/3);   
                          2, 3

Fraction( 2, 3 );
                           2/3

op(0, 2/3)( op(2/3) );
                           2/3

The construction calls Integer( -34 ) and op(0, -34)( -34 ) both produce 34 itself. That may not seem very exciting, but it is consistent with the other examples above.

op(0, -34);
                           Integer

op(-34);
                             -34

Integer( -34 );
                             -34

op(0, -34)( op(-34) );
                             -34

It is not the case that all expressions can be reconstructed like e = op(0,e)( op(e) ), but that is the case for the other types you mentioned: Vector, Array, Matrix, `+`.

Just because there is a constructing procedure that happens to produce an expression doesn't mean that it has to also be a type. It looks like you've simply made an incorrect interpretation of such things.

You might also look at the command whattype .

[edit] I finished this Answer before I saw Kitonum's Answer (which I've up-voted).

So you are using a call to Plotter from the Maplets[Elements] subpackage?

And you tried to pass

display(seq(S[n]$5, n=1..10), insequence=true)

as its first argument?

You could try this instead, as the first argument to Plotter.

PLOT(ANIMATE(seq([op(S[n])]$5, n=1..10)))

[edited] Since you mentioned the plots:-animate command, another possibility for that first argument to Maplets[Element][Plotter] might be something (clunkier) like say,

plots:-animate(plots:-display, [S[trunc(n)]$5],
               n=1..10, frames=50, paraminfo=false)

It happens because the usual evaluation rules (evaluation "up front" of arguments to procedure calls) would be too strong for mutable things like Vector/Array/Matrix which one sometimes wants to be acted upon "in-place".

That is to say, the eval which gets applied to procedure arguments does not have its usual effect on the entries of a Vector/Matrix/Array argument. That aspect is by design.

It gets slightly confusing because the printing mechanism for rtables (Vector/Matrix/Array) does the full evaluation on the entries. But don't be mislead by what gets shown by `print/rtable`. By using lprint we can get a more clear picture of what's going on.

The command rtable_eval does the kind of full evaluation (acting upon elements) that you might have been hoping for.

restart;

v := <a,b>;

_rtable[18446884341270794238]

a := 3: b := 4:

lprint(v);

Vector[column](2, {1 = a, 2 = b}, datatype = anything, storage = rectangular, order = Fortran_order, shape = [])

lprint( eval(v) );

Vector[column](2, {1 = a, 2 = b}, datatype = anything, storage = rectangular, order = Fortran_order, shape = [])

lprint( rtable_eval(v) );

Vector[column](2, {1 = 3, 2 = 4}, datatype = anything, storage = rectangular, order = Fortran_order, shape = [])

convert(eval(v), list);
 

[a, b]

convert(rtable_eval(v), list);

[3, 4]

 


Download rtable_eval.mw

It happens because GAMMA(n,1) is returning a result with exp(-1) rather than 1/exp(1).

The product of terms exp(1) * 1/exp(1) would simplify (even automatically). But the mathematically equivalent product exp(1) * exp(-1) requires an explicit simplifying step such as a call to simplify or combine.

restart;

r := rsolve({u(n)=n*(u(n-1)+1), u(0)=0}, u);

GAMMA(n+1)*(Sum((n1+1)/GAMMA(n1+2), n1 = 0 .. n-1))

R:=unapply(simplify(value(r)),n);

proc (n) options operator, arrow; n*exp(1)*GAMMA(n, 1) end proc

seq(R(i), i=0..5);

0, exp(1)*exp(-1), 4*exp(1)*exp(-1), 15*exp(1)*exp(-1), 64*exp(1)*exp(-1), 325*exp(1)*exp(-1)

 

S:=unapply('combine'(simplify(value(r)),exp),n);

proc (n) options operator, arrow; combine(n*exp(1)*GAMMA(n, 1), exp) end proc

seq(S(i), i=0..5);

0, 1, 4, 15, 64, 325

 


Download exp_combine.mw

I started and finished my Answer before I saw vv's fine Answer. I figured that I'd submit anyway (because I had an explanation), while up-voting `vv`.

There are several ways to show that this particular expression equals zero, step-by-step using Maple. Here's one:

restart;

 

ee:=-3*(sqrt(10+4*sqrt(5)))+sqrt(50+20*sqrt(5))+sqrt(10-4*sqrt(5))+sqrt(50-20*sqrt(5));

-3*(10+4*5^(1/2))^(1/2)+(50+20*5^(1/2))^(1/2)+(10-4*5^(1/2))^(1/2)+(50-20*5^(1/2))^(1/2)

# These are all the terms in the sum.
[op(ee)];

[-3*(10+4*5^(1/2))^(1/2), (50+20*5^(1/2))^(1/2), (10-4*5^(1/2))^(1/2), (50-20*5^(1/2))^(1/2)]

# Pick one.
op(3,ee);

(10-4*5^(1/2))^(1/2)

# Multiply each term by that.
map(u->op(3,ee)*u, [op(ee)]);

[-3*(10-4*5^(1/2))^(1/2)*(10+4*5^(1/2))^(1/2), (10-4*5^(1/2))^(1/2)*(50+20*5^(1/2))^(1/2), 10-4*5^(1/2), (10-4*5^(1/2))^(1/2)*(50-20*5^(1/2))^(1/2)]

# Combine radicals.
map(combine, %);

[-6*((5-2*5^(1/2))*(5+2*5^(1/2)))^(1/2), 2*5^(1/2)*((5-2*5^(1/2))*(5+2*5^(1/2)))^(1/2), 10-4*5^(1/2), 2*5^(1/2)*(5-2*5^(1/2))]

# Expand the products within the radicals.
map(expand, %);

[-6*5^(1/2), 10, 10-4*5^(1/2), 10*5^(1/2)-20]

# These are all the original terms, scaled.
op(%);

-6*5^(1/2), 10, 10-4*5^(1/2), 10*5^(1/2)-20

# Add them together.
`+`(%);

0

 

 

rad.mw

The numerators of the values of A4[3,3] and A4[4,4] are not the integer 1. They are both a so-called Atomic Variable (atomic identifier, or name) that merely looks like a 1.

If I delete those two entries are instead re-type both as -1/TW then the Eigenvalues command returns complex floating-point results as one would normally expect for A4 a floating-point Matrix.

Eignevalues_1.mw

I'm not sure how you managed to get those numerators for be that name (which displays like 1, but which is not actually an integer.) Presumably it was not due to some deliberate action of your own. I suspect a bug/quirk in the Matrix palette (which you appear to have used to get the typeset 2D Input for the Matrix entry). There were some bugs related to the Matrix palette in the earlier point-releases of Maple 2017 (eg, 2017.0, etc). Your attachment was last saved using Maple 2017.3 so I guess you've already updgraded and perhaps there may still be some issues with the Matrix palette. Do you recall doing anything different for entering those Matrix elements?

Here in the attached worksheet is one way, using different names for the 3 points used for each triangle. This way will allow you to operate with the triangles stored as tabl[i] without having to immediately draw them (producing actual, distinct plots right away).

tri.mw

Another way involves giving up on storing them as mere triangle things (rather than as final plots) in the tabl[i], and storing their respective plots instead. (I use a different table name, P instead of tabl, just to make it a little more clear).

tri2.mw

This homework/coursework question has been asked and answered recently by others. See here for one explanation.

I showed a similar thing here, using the events functionality of numeric dsolve.

(I also showed it there using Optimization:-Minimize.)

Every call to DocumentTools:-InsertContent entirely replaces any content in the sole Task Region that an Execution Group can have.

In other words, each time through your loop the InsertContent call will wipe out whatever was inserted the previous call.

You cannot work around this with the kind of looped call to InsertContent call that you have.

You can only work around it by inserting xml content which itself contains all the augmented content.

Eg, hyperlink_do-loop_1.mw

So you can use a seq call within the construction. But you cannot succeed doing any looped call to InsertContent.

You have other choices, about what to enclose within such a seq call. It needn't be of the form seq(Group(Input(...)),...) but instead could be different hyperlinks in a sequence of Cells in a Row, or a particular Cell in each of a sequence of Rows in a Table, or a particular Cell in a sequence of subTables within whatever, etc.

My personal preference for such tasks is to try and target any actions by expand, simplify, combine, etc, to only those which are necessary, in as much as that might be possible.

Restricting use of simplify can be more important, since it can turn ln,exp to arctrig,trig form.

This version also separates factors which do not contain any of the names, or those which are not separable. It handles 1, 2, or more arbitrary names.

restart;

F:=proc(ee,vars::list,{pullcontent::truefalse:=false})
  local Finner;
  Finner:=proc(ee,i::posint,vars::list)
    local p1,p2,K;
    if i>nops(vars) then return ee; end if;
    K := [(u->`if`(u::`*`,op(u),u))(subsindets(ee,{`^`,'specfunc(exp)'},
                                               expand))];
    p1,p2 := selectremove(u->has(u,vars[i]) and {seq(has(u,v),
                                  v=[vars[..i-1][],
                                     vars[i+1..][]])}={false},K);
    p1 := `if`(nops(p1)=0,1,`if`(nops(p1)=1,``(op(p1)),``(`*`(op(p1)))));
    p2 := `if`(nops(p2)=0,1,`if`(nops(p2)=1,op(p2),`*`(op(p2))));
    if nops(vars)>i then
      p2 := procname(p2,i+1,vars);
    end if;
    p1*`if`(i=nops(vars) and p2<>1,``(p2),p2);
  end proc;
  if ee::`*` then `*`(Finner(ee,1,vars)); else ee; end if;
end proc:

expr := a/b^2;

a/b^2

F( expr, [a,b] );

``(a)*``(1/b^2)

expr := exp(a)*13.5/b;

13.5*exp(a)/b

F( expr, [a,b] );

``(exp(a))*``(1/b)*``(13.5)

expr := (x^2+1)*y^3*exp(-x-y);

(x^2+1)*y^3*exp(-x-y)

F( expr, [x,y] );

``((x^2+1)/exp(x))*``(y^3/exp(y))

expr := -(x^2+1)*y^3*exp(-x-y);

-(x^2+1)*y^3*exp(-x-y)

F( expr, [x,y] );

``((x^2+1)/exp(x))*``(y^3/exp(y))*``(-1)

expr := -Pi*(1-cos(x)^2)*sin(y)^3/exp(1);

-Pi*(1-cos(x)^2)*sin(y)^3/exp(1)

F( expr, [x,y] );

``(1-cos(x)^2)*``(sin(y)^3)*``(-Pi/exp(1))

expr := (x^2+1)*z^3*exp(-x-y+h(y))*3/4*cos(x+a)/g(z);

(3/4)*(x^2+1)*z^3*exp(-x-y+h(y))*cos(x+a)/g(z)

F( expr, [x,y,z] );

``((x^2+1)*cos(x+a)/exp(x))*``(exp(h(y))/exp(y))*``(z^3/g(z))*``(3/4)

expr := (x^2+1)*y^3*p^(-x-y+b+z)*2*z/3*exp(x*q)*(1-sin(a)^2)*ln(abs(x)*abs(a));

(2/3)*(x^2+1)*y^3*p^(-x-y+b+z)*z*exp(x*q)*(1-sin(a)^2)*ln(abs(x)*abs(a))

F( expr, [x,y,z] );

``((x^2+1)*exp(x*q)*ln(abs(x)*abs(a))/p^x)*``(y^3/p^y)*``(p^z*z)*``((2/3)*p^b*(1-sin(a)^2))

 


Download splitprod.mw

No, that is not offered through Maple for that computation (ie. grinding it out via `isprime`, as opposed to lookup via NumberTheory:-IsMersenne).

Let me know if you'd really rather have the phi details inside the plot (which could be done using a fancy textplot).

restart

L := 7; with(plots); Digits := 30; rf := 997.1; cpf := 4179; kf := .613; bf := 21; sf := 0.5e-1; rs := 8933; cps := 385; ks := 400; bs := 1.67; ss := 5.96*10^7; a[1] := 0; a[2] := 2; a[3] := 5; a[4] := .6; a[5] := 4; a[6] := 6; phi := .1; lambda := .2; Ha := 1; Gr := 2; alpha := .5; Rd := .5; Ecy := 2; Pr := 3.97; Ecx := .3; A := 1; HA := [a[1], a[2], a[3]]

Ha := Pram; Eq1 := (diff(F(eta), eta, eta, eta))/((1-phi+rs*phi/rf)*(1-phi)^2.5)+(F(eta)+G(eta))*(diff(F(eta), eta, eta))-(2*(diff(F(eta), eta)+diff(G(eta), eta)))*(diff(F(eta), eta))+4*lambda*(diff(G(eta), eta))+(1-phi+rs*bs*phi/(rf*bf))*Gr*H(eta)/(1-phi+rs*phi/rf)-Ha^2*(1+(3*(ss/sf-1))*phi/(ss/sf+2-(ss/sf-1)*phi))*(diff(F(eta), eta))/(1-phi+rs*phi/rf) = 0; Eq2 := (diff(G(eta), eta, eta, eta))/((1-phi+rs*phi/rf)*(1-phi)^2.5)+(F(eta)+G(eta))*(diff(G(eta), eta, eta))-(2*(diff(F(eta), eta)+diff(G(eta), eta)))*(diff(G(eta), eta))-4*lambda*(diff(F(eta), eta))+(1-phi+rs*bs*phi/(rf*bf))*Gr*H(eta)/(1-phi+rs*phi/rf)-Ha^2*(1+(3*(ss/sf-1))*phi/(ss/sf+2-(ss/sf-1)*phi))*(diff(G(eta), eta))/(1-phi+rs*phi/rf) = 0; Eq3 := (ks+(m-1)*kf-(m-1)*(kf-ks)*phi)*(diff(H(eta), eta, eta))/(Pr*(ks+(m-1)*kf+(kf-ks)*phi))+(1-phi+rs*cps*phi/(rf*cpf))*((F(eta)+G(eta))*(diff(H(eta), eta))-A*(diff(F(eta), eta)+diff(G(eta), eta))*H(eta))+Ecx*Ecy*((diff(F(eta), eta, eta))^2+(diff(G(eta), eta))^2)/(1-phi)^2.5 = 0

IC1 := F(0) = 0, (D(F))(0) = 1, G(0) = 0, (D(G))(0) = alpha, H(0) = 1, (D(F))(L) = 0, (D(G))(L) = 0, H(L) = 0
params := {B111 = .2}

[0, 2, 5]

for k to nops(HA) do P || k := plots:-odeplot(dsolve(eval({Eq1, Eq2, Eq3, IC1}, `union`(params, {Pram = HA[k], m = 3})), numeric), [[eta, diff(F(eta), eta)]], linestyle = [dashdot, spacedash, dash, longdash][k], color = [blue, blue, blue, blue][k], labels = [eta, f], thickness = 3); Q || k := plots:-odeplot(dsolve(eval({Eq1, Eq2, Eq3, IC1}, `union`(params, {Pram = HA[k], m = 6.3698})), numeric), [[eta, diff(F(eta), eta)]], linestyle = [dashdot, spacedash, dash, longdash][k], color = [green, green, green, green][k], labels = [eta, theta], thickness = 3); R || k := plots:-odeplot(dsolve(eval({Eq1, Eq2, Eq3, IC1}, `union`(params, {Pram = HA[k], m = 16.1576})), numeric), [[eta, diff(F(eta), eta)]], linestyle = [dashdot, spacedash, dash, longdash][k], color = [red, red, red, red][k], labels = [eta, theta], thickness = 3) end do; f1 := plots:-display(P || (1 .. nops(HA))); f2 := plots:-display(Q || (1 .. nops(HA))); f3 := plots:-display(R || (1 .. nops(HA)))

display(f1, f2, f3, axes = boxed, size = [400, 460], labels = [eta, "&phi;(&eta;)"], labelfont = ["Arial", 10, Bold], labeldirections = [horizontal, vertical], axesfont = ["ROMAN", 10], plot([-1, -1, -1], 3 .. 4, color = [blue, green, red], legend = [typeset('phi' = 3), typeset('phi' = 6), typeset('phi' = 13)], legendstyle = [font = ["ROMAN", bold, 10], location = top]), plots:-textplot([1.5, .8, typeset('delta' = .1, .3, .5)], font = ["ROMAN", bold, 10]), view = [default, 0 .. 1])

``

 

 

Legend_1.mw

First 186 187 188 189 190 191 192 Last Page 188 of 336