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

Using space " " is not reliable here, in my experience.

In the past, I've resorted to using one of:
           thin space
           en space
           em space


IIRC, I was not able to get those as named HTML entities, eg.        

Here are three ways. (There are others.)

restart

y := x+1

Explore(InertForm:-Display(%y, inert = false) = y, x = 0 .. 5, echoexpression = false)

Explore(`#mi("y");` = y, x = 0 .. 5, echoexpression = false)

F := proc (X) options operator, arrow; 'y' = eval(y, x = X) end proc; Explore(F(x), x = 0 .. 5, echoexpression = false)

Explore_with_Inert_Form_of_display_ac.mw

ps. I suspect that the uneval-quoting didn't work because Explore makes an effort (in order to overcome its special evaluation rules, sigh...) to resolve assigned names.

The m in the denominator of 200*Unit(kg)/m^3 was not entered as units.

It's just the name m. The visual cue of that is that it was rendered in italics in your output.

Below, I entered in as the unit m, instead.

restartNULL

Pi

Pi

"(->)"

3.1415926535897932385

 ``

Dyson[Inside] := 355016117130*Unit('ft')NULL

NULLDyson[Outside] := 355016117280*Unit('ft')

355016117280*Units:-Unit(ft)

NULLNULL

Vol[Dyson] := (4/3)*Pi*Dyson[Outside]^3-(4/3)*Pi*Dyson[Inside]^3 = 75621866085188578208340000*Pi*Units:-Unit(ft)^3"(->)"0.23757309894397957472e27*Units:-Unit(ft)^3

   

Total_Weight := 200*Unit('kg')*Vol[Dyson]/Unit('m')^3

15124373217037715641668000000*Units:-Unit(kg)*Pi*Units:-Unit(ft)^3/Units:-Unit(m)^3

"(=)"

(6691789940422039289112993734304/15625)*Pi*Units:-Unit(kg)

"(->)"

0.13454641994365413638e28*Units:-Unit(kg)NULL

Download Q_for_Dyson_Shell_Weight_ac.mw

Are you trying for one of these?

nprintf("#mrow(%a,mo(\"=\"),%a,mo(\"=\"),%a)",
        Typesetting:-Typeset(P(X <= 5)),
        Typesetting:-Typeset(P(-5 <= -X)),
        Typesetting:-Typeset(P(E(X)-5 <= E(X)-X)));
 

`#mrow(Typesetting:-mrow(Typesetting:-mi("P"),Typesetting:-mo("&ApplyFunction;"),Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("X"),Typesetting:-mo("&le;"),Typesetting:-mn("5")))),mo("&equals;"),Typesetting:-mrow(Typesetting:-mi("P"),Typesetting:-mo("&ApplyFunction;"),Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mn("&uminus0;5"),Typesetting:-mo("&le;"),Typesetting:-mrow(Typesetting:-mo("&uminus0;"),Typesetting:-mi("X"))))),mo("&equals;"),Typesetting:-mrow(Typesetting:-mi("P"),Typesetting:-mo("&ApplyFunction;"),Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mi("E"),Typesetting:-mo("&ApplyFunction;"),Typesetting:-mfenced(Typesetting:-mi("X"))),Typesetting:-mo("&minus;"),Typesetting:-mn("5")),Typesetting:-mo("&le;"),Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mi("E"),Typesetting:-mo("&ApplyFunction;"),Typesetting:-mfenced(Typesetting:-mi("X"))),Typesetting:-mo("&minus;"),Typesetting:-mi("X"))))))`

`And`(P(X <= 5) = P(-5 <= -X),
      P(-5 <= -X) = P(E(X)-5 <= E(X)-X));
 

And(P(X <= 5) = P(-5 <= -X), P(-5 <= -X) = P(E(X)-5 <= E(X)-X))

`%and`(P(X <= 5) = P(-5 <= -X),
       P(-5 <= -X) = P(E(X)-5 <= E(X)-X));
  

%and(P(X <= 5) = P(-5 <= -X), P(-5 <= -X) = P(E(X)-5 <= E(X)-X))

Download ts_inert_ex.mw

Note that the latter two are inert, ie. not merely unevaluated by quotes (which might be subsequently ruined by inadvertant evaluation if passed around as arguments, etc).

Is this the kind of thing you're after?

It's not entirely clear what precisely you mean by, "...if R is not zero". Do you mean just when R is not a 4x4 Matrix with all zero as entries, or do you mean whenever R is some other 4x4 Matrix, or when R is any other size Matrix, or when R<>0 (scalar), or something else...?

restart;

 

p := proc(R)
  if R::'Matrix(4,4)' and LinearAlgebra:-Norm(R)=0 then
      A;
  else
      B;
  end if;
end proc:

 

p( Matrix(4,4) );

A

p( Matrix(4,4,12.3) );

B

# adjust code if you'd rather this threw error, or other
p( Matrix(2,2) );

B

Download Matrix_type_chk.mw

I believe that you have your target expression slightly wrong, missing one additive term in its denominator so that it's not actually equivalent to your starting R1/R2 expression.

But R1/R2 can be reformulated in a similar overall form as your cited target expression:

restart;

Hi := -Delta*S1^2 - J*S1*S2:

R1 := S1*exp(-beta*Hi):

R1 := add(R1, S1 = [-2, -1, 0, 1, 2]):

R2 := exp(-beta*Hi):

R2 := add(R2, S1 = [-2, -1, 0, 1, -2]):

R1/R2;

(-2*exp(-beta*(2*J*S2-4*Delta))-exp(-beta*(J*S2-Delta))+exp(-beta*(-J*S2-Delta))+2*exp(-beta*(-2*J*S2-4*Delta)))/(1+2*exp(-beta*(2*J*S2-4*Delta))+exp(-beta*(J*S2-Delta))+exp(-beta*(-J*S2-Delta)))

F1 := collect(convert(expand(R1*exp(-4*Delta*beta)),trig,{J*S2*beta}),
              exp,combine@simplify@expand@combine):

F2 := collect(convert(expand(R2*exp(-4*Delta*beta)),trig,{J*S2*beta}),
              exp,combine@simplify@expand@combine):

cand2 := combine(F1/F2,power);

(4*sinh(2*J*S2*beta)+2*sinh(J*S2*beta)*exp(-3*Delta*beta))/(2*cosh(2*J*S2*beta)-2*sinh(2*J*S2*beta)+2*cosh(J*S2*beta)*exp(-3*Delta*beta)+exp(-4*Delta*beta))

simplify(cand2 - R1/R2);

0

Download Barcellos_2a.mw

Simplifying the difference between cand2 and R1/R2 produces zero, ie. they are mathematically equivalent.

As mentioned earlier, this cited target result is not right,

(4*sinh(2*J*S2*beta) + 2*sinh(J*S2*beta)*exp(-3*Delta*beta))/(2*cosh(2*J*S2*beta) + 2*cosh(J*S2*beta)*exp(-3*Delta*beta) + exp(-4*Delta*beta))

It ought to have been something like the following (computed by the code in the attachment),

(4*sinh(2*J*S2*beta) + 2*sinh(J*S2*beta)*exp(-3*Delta*beta))/(2*cosh(2*J*S2*beta) - 2*sinh(2*J*S2*beta) +
2*cosh(J*S2*beta)*exp(-3*Delta*beta) + exp(-4*Delta*beta))

Numeric checking by substitution of random numeric values for the variables corroborates the equivalence of R1/R2 and cand2, but not of the cited target expression.

Here is one numeric way to show the plots of the space-curve intersection of 3D surfaces implied by the two equations, over the same (small, 0..1) y- and z-range. It runs in a reasonable amount of time, though I did not optimize.

Note that you didn't tell us what ranges you were interested in, for y and z.

Note that I set this up only to find one y-z solution for each x-value. It's not clear to me what you mean by "first" when you write, "I need to find the first 3 or 5 solutions".

You might also find that you can successfuly alter the ranges for x,y,z. I wasn't entirely sure what you wanted there.

restart;

expr1 := z*(1/150-2*y)*exp(-2*Pi*x*y)+1/5*((z^2-y^2)*sin(2*Pi*x*z)-2*y*z*cos(2*Pi*x*z));

z*(1/150-2*y)*exp(-2*Pi*x*y)+(1/5)*(-y^2+z^2)*sin(2*Pi*x*z)-(2/5)*y*z*cos(2*Pi*x*z)

expr2 := (z^2-y^2+1/150*y-1)*exp(-2*Pi*x*y)+1/5*((z^2-y^2)*cos(2*Pi*x*z)+2*y*z*sin(2*Pi*x*z));

(z^2-y^2+(1/150)*y-1)*exp(-2*Pi*x*y)+(1/5)*(-y^2+z^2)*cos(2*Pi*x*z)+(2/5)*y*z*sin(2*Pi*x*z)

G := proc(X) local s;
  s := fsolve(eval({expr1,expr2},x=X),{y=0..1,z=0..1});
  if s::set then eval([X,y,z],s);
  else [X,undefined,undefined]; end if;
end proc:

L := [seq(G(x), x=0..1, 0.01)]:

PC := plots:-pointplot3d(L, color="Red", symbol=solidcircle, symbolsize=10):

PI := plots:-implicitplot3d([expr1,expr2],x=0..1,y=0..1,z=0..1,
                            style=surface, color=[green,blue], transparency=0.8):

plots:-display(PC,PI,size=[400,400]);

plots:-display(PC,orientation=[-90,0,0],size=[300,300],labels=[x,y,""]);

plot(L[..,[1,2]], labels=[x,y], view=[0..1,0..1]);

plots:-display(PC,orientation=[-90,90,0],size=[300,300],labels=[x,"",z]);

plot(L[..,[1,3]], labels=[x,z], view=[0..1,0..1]);

 

Download impl_3d_inter.mw

[edit] I just noticed that your Question is tagged Maple 2019, in which the size option was not available for 3D plots. The following attachment is the same, but run and saved in Maple 2019.2 and without using that option. The rest looks the same.
impl_3d_inter_M2019.mw

There was an errant closing </Font> XML tag that didn't seem to have a corresponding opening tag.

Does the following attachment contain most of your document's original contents (or at least more than the Maple 2023 GUI itself recovers)?

Chemistry-Cheatsheet-Ramz_edition_Week_7-12_1_1_acc.mw

In your followup comment it seems as if your are trying to approximate an n-sided die by using (several, possibly n, possibly more?) 6-sided dice.

You tried unsuccessfully to do that (in a comment) by using mod. You could try mod (or irem) on a weighted sum.

restart;

randomize():

 

n := 20;

20

f:=rand(1..6):

 

G := [seq(1+irem(add(i*f(),i=1..n),n),j=1..50000)]:

 

Statistics:-Histogram(G,frequencyscale=absolute,discrete=true);

Statistics:-Tally(G);

[1 = 2427, 2 = 2446, 3 = 2528, 4 = 2513, 5 = 2524, 6 = 2509, 7 = 2447, 9 = 2484, 8 = 2554, 11 = 2577, 10 = 2458, 13 = 2476, 12 = 2557, 15 = 2473, 14 = 2448, 18 = 2545, 19 = 2469, 16 = 2464, 17 = 2508, 20 = 2593]

Download rand_die.mw


Your problem in your Question's original example is due to the sum of 3 calls to rand(1..6)() being automatically simplified to 3*rand(1..6)(), before evaluation of the rand(1..6)() calls happens.

In the code above I get around that premature evaluation by using add, which has special evaluation rules.

This is the kind of automatic simplification that you were seeing.

f := rand(1..6):

'f()+f()+f()';

3*f()

'rand(1..6)()+rand(1..6)()+rand(1..6)()';

3*(rand(1 .. 6))()

Download auto_simp_eh.mw

By the way, it's not efficient to invoke rand(1..6)() each and every time. And, as you saw originally, it doesn't prevent the automatic simplifcation problem. I assign f:=rand(1..6), then call f for each instance: for efficiency. But it's not the aspect that fixes your automatic simplification problem.

I also changed your inefficient repeated list-concatenation into a seq call, for efficiency.

restart;

V := exp(lambda*S) = S^4*a4 + S^3*a3 + S^2*a2 + S*a1 + a0:


By simplifying after solving (but before converting to trigh) we can
avoid requiring any fortuitous order of the specifed solve-variables.

raw := convert(combine(expand(solve({seq(V,S=[2,1,0,-1,-2])}))),trigh);

{a0 = 1, a1 = -(1/6)*sinh(2*lambda)+(4/3)*sinh(lambda), a2 = -(1/12)*cosh(2*lambda)+(4/3)*cosh(lambda)-5/4, a3 = (1/6)*sinh(2*lambda)-(1/3)*sinh(lambda), a4 = (1/12)*cosh(2*lambda)-(1/3)*cosh(lambda)+1/4, lambda = lambda}


Get rid of the trivial lambda=lambda result.

raw := remove(evalb, raw);

{a0 = 1, a1 = -(1/6)*sinh(2*lambda)+(4/3)*sinh(lambda), a2 = -(1/12)*cosh(2*lambda)+(4/3)*cosh(lambda)-5/4, a3 = (1/6)*sinh(2*lambda)-(1/3)*sinh(lambda), a4 = (1/12)*cosh(2*lambda)-(1/3)*cosh(lambda)+1/4}


The OP also queried about statements which make these assignments.

assign~(raw):

 

a0;

1

a1;

-(1/6)*sinh(2*lambda)+(4/3)*sinh(lambda)

a2;

-(1/12)*cosh(2*lambda)+(4/3)*cosh(lambda)-5/4

a3;

(1/6)*sinh(2*lambda)-(1/3)*sinh(lambda)

a4;

(1/12)*cosh(2*lambda)-(1/3)*cosh(lambda)+1/4

Automatic simplification avoidance. This is just for display purposes,
to show the numeric coefficients exactly as was asked.

(print@InertForm:-Display)~((u->`if`(rhs(u)::constant, rhs(u),
                                     content(rhs(u))%*(rhs(u)/content(rhs(u)))))~(raw),
                            'inert'=false):

1

0, "%1 is not a command in the %2 package", _Hold, Typesetting

0, "%1 is not a command in the %2 package", _Hold, Typesetting

0, "%1 is not a command in the %2 package", _Hold, Typesetting

0, "%1 is not a command in the %2 package", _Hold, Typesetting

Download solve_trigh.mw

You've probably also noticed that when you open your corrupted file in Maple 2022 you only get two Sections. It seems that the Maple 2022.2 GUI doesn't recover a large portion of your document.

The attachment below contains five Sections (Lecture 4 and Lecture 5 are expanded and fully visible).

Exercises_all_lectures_1_acc.mw

Unfortunately Section three (Lecture 3) appears to be quite short. But there does not seem to be very much in the file in that Section, after the text "...and we have...".

If you have it available to you, I suggest that you upgrade to Maple 2023, as it seems to have fewer reported incidents of these problems.

Here are two more ways.

The second uses a piece of manipulation that I've used before... (with different divisors, of course).

expr := 2*A*B/(A*m+m)+C^2+D^2;

2*A*B/(A*m+m)+C^2+D^2

First way:

collect(expr,[B,m],u->content(u)*1/expand(content(u)/u));

2*B/((1+1/A)*m)+C^2+D^2

Second way, using a little procedure I've needed many times before...

divid := (u,F) -> expand(numer(u)/F)/expand(denom(u)/F):

 

map(divid, expr, A*m);

2*B/((1+1/A)*m)+C^2+D^2

Download ut.mw

I would prefer Maple's own fnormal (regardless of whether Chop were to act as you'd like).

But you could target Chop at the (complex) floats, if you'd prefer.

restart;

ode:=[diff(x(t), t) = -3*x(t) + 4*y(t), diff(y(t), t) = 5*x(t) + 9*z(t), diff(z(t), t) = y(t) + 6*z(t)];
sol:=dsolve(ode):

[diff(x(t), t) = -3*x(t)+4*y(t), diff(y(t), t) = 5*x(t)+9*z(t), diff(z(t), t) = y(t)+6*z(t)]

temp := evalf[16](sol):

simplify(fnormal(temp),zero);

{x(t) = .8172764111*c__1*exp(1.894304969*t)-1.150854760*c__2*exp(-6.475677505*t)+.3780227930*c__3*exp(7.581372536*t), y(t) = c__1*exp(1.894304969*t)+c__2*exp(-6.475677505*t)+c__3*exp(7.581372536*t), z(t) = -.2435641207*c__1*exp(1.894304969*t)-0.8015596745e-1*c__2*exp(-6.475677505*t)+.6323620634*c__3*exp(7.581372536*t)}

subsindets(temp,complex(float),MmaTranslator:-Mma:-Chop);

{x(t) = .8172764111*c__1*exp(1.894304969*t)-1.150854760*c__2*exp(-6.475677505*t)+.3780227930*c__3*exp(7.581372536*t), y(t) = c__1*exp(1.894304969*t)+c__2*exp(-6.475677505*t)+c__3*exp(7.581372536*t), z(t) = -.2435641207*c__1*exp(1.894304969*t)-0.8015596745e-1*c__2*exp(-6.475677505*t)+.6323620634*c__3*exp(7.581372536*t)}

Download chop_fnormal.mw

If n>1 and m+3=n then m+3>1.

restart;

kernelopts(version);

`Maple 2023.1, X86 64 LINUX, Jul 07 2023, Build ID 1723669`

rel := n -> (n-3)^(n/(n-1))*2^(n/(n-1))
            -((n-1)*2^(n/(n-1))-4*2^(1/(n-1)))*(n-3)^(1/(n-1)):

simplify(factor(expand(rel(m+3)))) assuming m+3>1;

0

simplify(factor(expand(rel(m+3)))) assuming m<>-2;

0

Download Prove_It_True_ac.mw

(Also shown above for m<>-2, ie. n<>1)

ps. I will submit a report against this weakness is simplify (as well as your original).

expr := -2^((2*m + 5)/(m + 2)) + 4*2^(1/(m + 2)):

simplify(expr) assuming m<>-2;

-2^((2*m+5)/(m+2))+4*2^(1/(m+2))

simplify(factor(expand(expr))) assuming m<>-2;

0

Download Prove_It_True_acc.mw

Your procedure assigns W to W1.

That makes W1 be the very same Matrix as W, not a copy. The two names then point to the same Matrix.

Then the procedure acts inplace on the first column of W1, which means that W has changed.

What you probably want your procedure to do instead is,

   local W1 := copy(W);

First 33 34 35 36 37 38 39 Last Page 35 of 336