acer

17617 Reputation

29 Badges

14 years, 190 days

On google groups. (comp.soft-sys.math.maple and sci.math.symbolic)

On stackoverflow.

On math.stackexchange.com.

MaplePrimes Activity


These are answers submitted by acer


When you call fsolve on the multivariate system then it does use Newton's method. See below. You can choose any t value you want below (not just 0 or 1).

You can also obtain explicit solutions in terms of t, symbolically, using solve. These can also be evaluated at specific values of t.

restart;

eq1:= (1/2)*x[0]*sqrt(3)-(1/2)*x[1]*sqrt(3) = ((1/2)*x[0]*(t+(1/3)*sqrt(3))*sqrt(3)-(1/2)*x[1]*(t-(1/3)*sqrt(3))*sqrt(3))*(1-(1/6)*y[0]*(t+(1/3)*sqrt(3))*sqrt(3)+(1/6)*y[1]*(t-(1/3)*sqrt(3))*sqrt(3)-(1/8)*y[0]*(5*sqrt(3)*(1/12)-1/4+t)*sqrt(3)+(1/8)*y[1]*(-(1/4)*sqrt(3)-1/4+t)*sqrt(3)-(1/8)*y[0]*((1/4)*sqrt(3)-1/4+t)*sqrt(3)+(1/8)*y[1]*(-5*sqrt(3)*(1/12)-1/4+t)*sqrt(3))-5*t^3*(1/2)+49*t^2*(1/12)+17*t*(1/12)-23/6:
eq2:= (1/2)*y[0]*sqrt(3)-(1/2)*y[1]*sqrt(3) = ((1/2)*y[0]*(t+(1/3)*sqrt(3))*sqrt(3)-(1/2)*y[1]*(t-(1/3)*sqrt(3))*sqrt(3))*(-2+(1/2)*x[0]*(t+(1/3)*sqrt(3))*sqrt(3)-(1/2)*x[1]*(t-(1/3)*sqrt(3))*sqrt(3)+(1/4)*(-(1/12)*sqrt(3)-3/4)*((1/2)*x[0]*(5*sqrt(3)*(1/12)-1/4+t)*sqrt(3)-(1/2)*x[1]*(-(1/4)*sqrt(3)-1/4+t)*sqrt(3))+(1/4)*((1/12)*sqrt(3)-3/4)*((1/2)*x[0]*((1/4)*sqrt(3)-1/4+t)*sqrt(3)-(1/2)*x[1]*(-5*sqrt(3)*(1/12)-1/4+t)*sqrt(3)))+15*t^3*(1/8)-(1/4)*t^2+3*t*(1/8)-1:
eq3:=(1/2)*x[0]+(1/2)*x[1] = 1:
eq4:=(1/2)*y[0]+(1/2)*y[1] = 0:

fsolve(eval({eq1,eq2,eq3,eq4},t=0));

{x[0] = -.7079945458, x[1] = 2.707994546, y[0] = -.5773502690, y[1] = .5773502690}

fsolve(eval({eq1,eq2,eq3,eq4},t=1));

{x[0] = .7816742684, x[1] = 1.218325732, y[0] = .2184568586, y[1] = -.2184568586}

S:=subs((t=t)=NULL,[solve({eq1,eq2,eq3,eq4},{x[0],y[0],x[1],y[1]},explicit)]):

remove(has,map(u->evalf(map(limit,u,t=0.0)),S),Float(undefined));

[{x[0] = -.707994547, x[1] = 2.707994547, y[0] = -.5773502693, y[1] = .5773502693}]

remove(has,map(u->evalf(map(limit,u,t=1.0)),S),Float(undefined));

[{x[0] = .7816742678, x[1] = 1.218325732, y[0] = .2184568586, y[1] = -.2184568586}]

 

Download RFs.mw

My usual experience is different from what you describe.

When the computational kernel crashes in the GUI then I am usually still able to save the worksheet by closing the GUI using the top corner icon (window decoration button from the OS, which often looks like an X). When I do this the GUI still offers me the choice to save the worksheet, even though the kernel has crashed.

Of course that doesn't include instances when the GUI itself has frozen. By far the most common cause of that is an attempt at printing an extremely large result.

The .m (dotm) structure does not support modules completely. (It never has and I doubt it ever will.) And objects are modules.

Trying to save an object to a single .m file is user-error, in my opinion.

Additionally, two MultiSets constructed with the same elements are still two MultiSets. The documentation states that explicitly. It also states that they can be compared directly with `=` under evalb.

But *nowhere* does it state that they are the same or identical and would therefore be treated as such under evalb when compared in any nondirect manner (ie. contained in any other structure).There is nothing in the Help page of evalb that suggests that, and it is a mistake to infer it.

The command DocumentTools:-Layout:-Equation will pick up and make use of the current typesetting level during its construction.

You can also override that by passing the option typesetting=extended to that Equation command.

(nb. I've also wrapped your argument to Table within a Textfield, which Maple 2019 seems to like, although Maple 2015 works without it. You can also give that Textfield the alignment=left option if you don't want it centered by default. So this attachment work in both versions.)

Equation_typesetting.mw

[edited] I am aware that the piecewise pretty-prints as 2D in regular output, regardless of the interface(typesetting) level. In the context of Layout:-Equation this just means that the naming of the permitted values for its typesetting option are somewhat misnamed. But the details above should still suffice to resolve the OP's question.

You can enforce runtime type-checking for assignments to locals of procedures. You can do this by setting the assertion level.

Note that type(y,integer) will not return true (below) while y is still unassigned.

restart;

kernelopts(assertlevel=2):

p := proc()
  local y::integer;
  y := 1.2;
end proc:

p();

Error, (in p) assertion failed in assignment, expected integer, got 1.2

local z::integer;

z

z:=1.2;

1.2

 

Download local_type_assertion.mw

One additional problem here is that your original qN_ep doesn't guard against fsolve possibly returning NULL.

I'll answer the same way as your previous question, using operator form instead of the awkward/confusing multiple unevalution quotes.

I also reduce Digits from 100 to 20, since it produces similar plots but doesn't take as long.

NLPSolve_test_ac1.mw

 

There are two issues.

Your original call to plot3d suffers from premature evaluation. One way to deal with that is by using additional unevaluation quotes (as Carl and Kitonum showed). I find that approach slightly awkward and slightly confusing since, as you say, you don't understand just how it works.

Another way to deal with that evaluation issue for the plot3d call is to use operator form for its arguments. I show that in the attachment below. This also deals with the ugly and awkward need to keep unassigning epsilon,m,n, etc.

But you also asked about why the 2D plots differ between Maple 2017 and Maple 2019. In Maple 2019 the call to fsolve inside your qN_ep can return a value at which its expression is very close to zero (yet the expression's slope is also near zero). I suspect that what you want instead is the earlier root that passes through zero without small slope. See the attachment.

The plot3d call takes a while because you have Digits=100. I'm not sure that you need to set it so very high. Try it at 20.

plot3d_test_ac1.mw

In addition to what Kitonum has already mentioned, you might find the following of interest.

restart;

with(RealDomain):

(-p^7)^(1/7);

-signum(p)*abs(p)

simplify((-p^7)^(1/7));

-p

restart;

RealDomain:-`^`(-p^7, 1/7);

-signum(p)*abs(p)

RealDomain:-simplify(%);

-p

restart;

RealDomain:-surd(-p^7, 7);

-signum(p)*abs(p)

RealDomain:-simplify(%);

-p

restart;

surd(-p^7, 7);

surd(-p^7, 7)

RealDomain:-simplify(%);

-p

restart;

simplify((-p^7)^(1/7), symbolic);

p*(-1)^(1/7)

subsindets(%,numeric^numeric,evalc);

p*(cos((1/7)*Pi)+I*sin((1/7)*Pi))

 

Download surd.mw

The typesetting level matters here.

restart;

kernelopts(version);

`Maple 2019.2, X86 64 LINUX, Oct 30 2019, Build ID 1430966`

 

Note that here the typesetting level is set to standard (as Stretto describes his).

 

interface(typesetting=standard):

with(InertForm):

expr := a %/ b * c;
Display(expr, inert=false);
value(expr);

`%/`(a, b)*c

Typesetting:-_Hold([`%/`(a, b)])*c

a*c/b

expr := `%/`(a,b)*c;
Display(expr, inert=false);
value(expr);

`%/`(a, b)*c

Typesetting:-_Hold([`%/`(a, b)])*c

a*c/b

expr := (3^3)%/3;
Display(expr, inert=false);
value(expr);

`%/`(27, 3)

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

9

 

Now let's set the typesetting level to extended (its default in Maple 2019).

Note that the fraction bar is rendered in gray (since it is inert).

 

interface(typesetting=extended):

expr := a %/ b * c;
value(expr);

`%/`(a, b)*c

a*c/b

expr := `%/`(a,b)*c;
value(expr);

`%/`(a, b)*c

a*c/b

expr := (3^3)%/3;
value(expr);

`%/`(27, 3)

9

 

Here's an alternative, with the typesetting level kept as standard.

We can redefine the way that calls to `%/` are printed. This gets the same effect as when using InertForm:-Display, but automatically.

 

interface(typesetting=standard):

`print/%/` := proc()
   InertForm:-Display(`%/`(args),
                      ':-inert'=false);
end proc:

expr := a %/ b * c;
value(expr);

`%/`(a, b)*c

a*c/b

 

Download inert_div.mw

The very first request's target (expected result) has the c4 factored out but not nurdel. That is not consistent with the later examples' expected results.

I am not seeing a consistent definition of how the OP expects the input expressions to be handled, so I don't see a common approach. Have I missed a consistent definition of the treatment?

restart;

ee := c4*dnub*kpbr*ksr*nur*nurdel + c4*dnur*kpbr*ksr*nub*nurdel + (c4*nus0 + c5)*dnub+dnub;

c4*dnub*kpbr*ksr*nur*nurdel+c4*dnur*kpbr*ksr*nub*nurdel+(c4*nus0+c5)*dnub+dnub

targee := c4*kpbr*ksr*nurdel*(dnub*nur + dnur*nub) + (c4*nus0 + c5+1)*dnub:
targee;

c4*kpbr*ksr*nurdel*(dnub*nur+dnur*nub)+(c4*nus0+c5+1)*dnub

collect(ee,[ksr,kpbr],simplify);
evalb(%=targee);

c4*kpbr*ksr*nurdel*(dnub*nur+dnur*nub)+(c4*nus0+c5+1)*dnub

true

ff := c4*dnub*kpbr*ksr*nur*nurdel + c4*dnur*kpbr*ksr*nub*nurdel + nub;

c4*dnub*kpbr*ksr*nur*nurdel+c4*dnur*kpbr*ksr*nub*nurdel+nub

targff := c4*kpbr*ksr*nurdel*(dnub*nur + dnur*nub)+nub:
targff;

c4*kpbr*ksr*nurdel*(dnub*nur+dnur*nub)+nub

collect(ff,[ksr,kpbr],simplify);
evalb(%=targff);

c4*kpbr*ksr*nurdel*(dnub*nur+dnur*nub)+nub

true

 

The OP's expected result (target expression) for this next example (his original) doesn't treat nurdel consistent with the other examples.

 

gg := c4*dnub*kpbr*ksr*nur*nurdel + c4*dnur*kpbr*ksr*nub*nurdel;

c4*dnub*kpbr*ksr*nur*nurdel+c4*dnur*kpbr*ksr*nub*nurdel

targgg := c4*kpbr*ksr*(dnub*nur*nurdel+dnur*nub*nurdel):
targgg;

c4*kpbr*ksr*(dnub*nur*nurdel+dnur*nub*nurdel)

collect(gg,[ksr,kpbr,c4]);
evalb(%=targgg);

c4*kpbr*ksr*(dnub*nur*nurdel+dnur*nub*nurdel)

true

 

For the latter two examples these also suffice.

 

collect(ee,[nurdel],simplify);
evalb(%=targee);

c4*kpbr*ksr*nurdel*(dnub*nur+dnur*nub)+(c4*nus0+c5+1)*dnub

true

collect(ff,[nurdel],simplify);
evalb(%=targff);

c4*kpbr*ksr*nurdel*(dnub*nur+dnur*nub)+nub

true

 

Download collect_examples.mw

The use of unapply on an applied function call (involving name x, or a picked-off parameter name) -- where the application serves no other purpose -- is madness. If the particular names of the procedure's parameters matter, then the approach seems wrong.

Your examples may well not illustrate precisely all or what you're trying to achieve.

But this may cover some of it. Note that the foldl example illustrates calling the iterating procedure, not constructing it. 

restart;

Q := sin@@3;
                  Q := @@(sin, 3)

Q(0.25);
                   0.2424474664

K:=proc(F,X,L2,n)
     foldl(L->F(L,op(_rest)),X,L2$n);
end proc:

for k from 0 to 3 do
    K(f, a, [b,c], k);
end do;
                        a
                    f(a, b, c)
               f(f(a, b, c), b, c)
           f(f(f(a, b, c), b, c), b, c)

Do you have other, more involved examples that you haven't shown us yet, which have additional demands?

My concerns are not just that I think that the names of the parameters of a procedure ought to act like dummy names (ie. the particular name choice should largely not matter). You should also be careful that a methodology which extracts the parameter names doesn't break just because, say, the global names have already been assigned values. (I mean where the construction breaks because some procedure's parameter names like x have been assigned.)

Look at the Help for the randomize command.

Compare what happens when you run these several times:

restart;
f:=rand(1..100):
seq(f(),i=1..10);

restart;
randomize():
f:=rand(1..100):
seq(f(),i=1..10);

The randomize command has a similar effect on Random Number Generators (RNGs) in the Statistics and RandomTools packages.

You don't need to implement your own RNGs simply to get different random sequences from different sessions.

Here are two ways, using your original assignments to SOLNSuy.

restart;

SOLNSuy[1, 1] := 2.5872902469406659197*10^(-20)-.65694549571241255901*y
+1.9708364871372376767*y^2-1.3138909914248251176*y^3-1.6010739356637904911*10^(-19)*y^4:

SOLNSuy[2, 1] := -4.002204462000*10^(-20)-1.7879176897079605225*y
+5.3637530691192141414*y^2-3.5758353794044226250*y^3-6.8309939211286845440*10^(-12)*y^4:

SOLNSuy[3, 1] := -1.1953264450000*10^(-19)-3.2481690589079594122*y
+9.7445071767154794599*y^2-6.4963381177952273213*y^3-1.2292726248071398400*10^(-11)*y^4:

SOLNSuy[4, 1] := -2.6720465500000*10^(-19)-4.9239979672954025921*y
+14.771993901873204315*y^2-9.8479959345587718955*y^3-1.9029826928878336000*10^(-11)*y^4:

SOLNSuy[5, 1] := 3.416928541000*10^(-20)-6.7268498492441931137*y
+20.180549547714413714*y^2-13.453699698443639810*y^3-2.6580790570532587008*10^(-11)*y^4:

SOLNSuy[6, 1] := -2.554122292000*10^(-20)-8.5884528335125514887*y
+25.765358500514014457*y^2-17.176905666966875698*y^3-3.4587270427710613504*10^(-11)*y^4:

SOLNSuy[7, 1] := -9.206107680000*10^(-20)-10.456823708331499352*y
+31.370471124965259849*y^2-20.913647416590986491*y^3-4.2774005353527132160*10^(-11)*y^4:

SOLNSuy[8, 1] := 1.9644186790000*10^(-19)-12.293003938471349390*y
+36.879011815379230436*y^2-24.586007876856948223*y^3-5.0932823222176363520*10^(-11)*y^4:

SOLNSuy[9, 1] := -3.775112769000*10^(-19)-14.068404975282556550*y
+42.205214925807397100*y^2-28.136809950465931724*y^3-5.8908824448577377280*10^(-11)*y^4:

SOLNSuy[10, 1] := 1.146281780000*10^(-19)-15.762658869974768890*y
+47.287976609878780960*y^2-31.525317739837422477*y^3-6.6589592851037286400*10^(-11)*y^4:

plots[animate](plot, [SOLNSuy[floor(A), 1], y = 0 .. 1], A = 1 .. 10, frames=10);

L:=[seq(plot(SOLNSuy[A,1],y=0..1),A=1..10)]:
plots:-display(L,insequence=true);

 

Download usman_anim.mw

It's not a big deal, but you could also use trunc rather than floor in the first approach above. However I find the second approach -- using seq -- more natural. (A pun for the year's end.)

Are you looking for one of these?

plot(x-floor(x/3)*3, x=-5..5);

plot(fmod(x,3), x=-5..5);

(Note that they are not the same.)

That Example unfortunately shows only how to have text use the current Style that is set for Hyperlinks, rather than an actual hyperlink.

There is a Hyperlink constructor exported from DocumentTools:-Layout, but it is not documented. It's also not a package export, so its name is not rebound by with. But it can still be called by its full name.

with(DocumentTools):
with(DocumentTools:-Layout):
F := Font("Official NORAD Santa Tracker", size=12, color=blue, style=:-Hyperlink):
H := DocumentTools:-Layout:-Hyperlink(F,linktarget="https://www.noradsanta.org/"):
InsertContent(Worksheet(Group(Input(Textfield("Track Santa at the ",H))))):
5 6 7 8 9 10 11 Last Page 7 of 205