acer

32333 Reputation

29 Badges

19 years, 326 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@sand15 One can use the numframes option of Explore for that, yes.

Eg,  numframes=300  will make it run slower, at a finer granularity.

(Also, the checkboxes can toggle on/off the animation of either parameter. There are other Explore calling sequences, eg. to have any parameter not have such a toggle, or to flip on recording of the frames, etc.)

An example with recording (after the exploration gets played):
Explore_anim_ex2.mw

@Carl Love Is it the case that the assumptions might be passed to the call, here, rather than being baked into the procedure?

restart;

 

Simp:= (q::`=`)-> local e:= factor((lhs-rhs)(q));
    `if`(e::`*`, remove(f-> is(f<>0), e), e) = 0
:

 

eq:= diff(v(x),x,x)*exp(x^2) = 0;

(diff(diff(v(x), x), x))*exp(x^2) = 0

Simp(eq) assuming real;

diff(diff(v(x), x), x) = 0

eq2:= diff(v(x),x,x)*exp(abs(x)) = 0;

(diff(diff(v(x), x), x))*exp(abs(x)) = 0

Simp(eq2);

diff(diff(v(x), x), x) = 0

Download simpprodzero.mw

@dharr Your approach may be modified for 2D Input,

restart

M := Matrix(4, 3, {(1, 1) = 34, (1, 2) = 67, (1, 3) = 1, (2, 1) = 35, (2, 2) = 80, (2, 3) = 1, (3, 1) = 45, (3, 2) = 45, (3, 3) = 2, (4, 1) = 56, (4, 2) = 99, (4, 3) = 2})

Search column 3 for values 2 and return corresponding rows

M[[seq(`if`(M[i, 3] = 2, i, NULL), i = 1 .. upperbound(M)[1])]]

Matrix(%id = 36893627990679325620)

Search row 3 for values 45 and return corresponding columns

M[() .. (), [seq(`if`(M[3, i] = 45, i, NULL), i = 1 .. upperbound(M)[2])]]

Matrix(%id = 36893627990679308516)

Download search_2d.mw

The behavioral difference you show is not due specifically to Specialize, but rather to the fact that you're using distinct random variables (albeit with common distribution).

restart

with(Statistics):

 

X := RandomVariable(Normal(-3, 1)):
Y1 := RandomVariable(Normal(3, 1)):
Y2 := RandomVariable(Normal(3, 1)):
B1 := RandomVariable(Bernoulli(1/2)):
B2 := RandomVariable(Bernoulli(1/2)):

Mix2 := B1*X + (1-B2)*Y1;

_R2*_R+(1-_R3)*_R0

Variance(Mix2);
Histogram(Sample(Mix2, 10^4), size=[300,200])

11/2

 

Mix1 := B1*(X - Y1) + Y2;

_R2*(_R-_R0)+_R1

Variance(Mix1);
Histogram(Sample(Mix1, 10^4), size=[300,200])

11

 

Download Specialize_ac.mw

I have deleted a duplicate of this Question thread.

In future please put your followup queries for this in Replies here, instead of spawning wholly separate new Question threads for such.

If you want to plot a compound expression involving the functions in the S1 solution you can use the same technique as you've already been shown in the prior Answer below. For example,

   expr := u[0](y) + varepsilon*exp(`&omega;t`)*u[1](y);
   odeplot(S1,[y,eval(expr, parameters)],0..inf);

New_2_ac2.mw

If you need a re-usable procedure which you can call for numeric y-values (outside of odeplot, say), then you could do something like this: New_2_ac.mw

@fnavarro This problematic example has been reported on the Maplesoft Beta forum and entered into the bug database.

Preben, if I'm not mistaken then in Maple 2023.2 the following causes the plot command to behave as if adaptive=true were default; ie. avoid adaptive=geometric unless it is explicitly supplied as option.

   _EnvUsePlotThing := false:

I mention it because IIRC you previously had some interest in an override, eg. something that could go in a personal initialization file.

(I found that environment variable set in the source of `plots/animate`, I suppose for construction speed.)

@WD0HHU AFAIK there is no property of a slider (even hidden) which controls the size of the font of the mark values on a Slider.

@dharr I agree it's special (only three distinct roots), but I'm not sure how far the coincidence runs. I was wondering whether any of the special-ness relates to allvalues(u1) going awry.

(Also, it isn't clear to me whether the OP's image is complete or chopped, nor why/how the OP might consider the root in the image to be The One.)

For interest,

restart;

u1 := RootOf(4*_Z^2 + (4*RootOf(60*_Z^3 - 60*_Z^2 + 15*_Z - 1) - 4)*_Z
             + 4*RootOf(60*_Z^3 - 60*_Z^2 + 15*_Z - 1)^2
             - 4*RootOf(60*_Z^3 - 60*_Z^2 + 15*_Z - 1) + 1):

 

evalc([solve(evala(Minpoly(u1, x)), x)]);

[(1/3)*cos((1/3)*arctan(3/4))+1/3, -(1/6)*cos((1/3)*arctan(3/4))+1/3-(1/6)*3^(1/2)*sin((1/3)*arctan(3/4)), -(1/6)*cos((1/3)*arctan(3/4))+1/3+(1/6)*3^(1/2)*sin((1/3)*arctan(3/4))]

evalf(%);

[.6590276223, .1090390090, .2319333686]

 

p := evala(Minpoly(u1, x));

x^3-x^2+(1/4)*x-1/60

solve(p, x, explicit=false); # that friend

RootOf(60*_Z^3-60*_Z^2+15*_Z-1)

Download RO_exB.mw

@dharr I don't see that this Answer's results are correct.

@dharr I plan to submit one bug report for that weakness in simplify (of the form with the pesky sqrts), and another for the failure of allvalues on the original RootOf.

So is it the case that you want to find values of the parameters sU and sV such that u(bV)=betaU and v(bV)=betaV?

You have some coding miskakes. eg. you don't provide a mechanism to force shootNL to return just one of u(bV) or v(bV), upon request. Such mistakes can be corrected, but I think perhaps you ought to provide an extra detais:

1) How close to u(bV) and v(bV) have to be to betaU and betaV, for you to accept the parameter values?

2) Why do you think that there is a solution in the narrow ranges you gave?

@C_R For plot3d an alternative to the color option is the colorscheme option. It has some fancy functionality, as well as some simple things such as using just a ColorTools Palette name (Maple 2023),

plot3d(argument(re+I*im), re=-2..2, im=-2..2,
       colorscheme="turbo", grid=[100,100],
       style=surfacecontour, lightmodel=none,
       labels=[Re(z),Im(z),``], orientation = [-90, 0, 0]);

I'm not sure whether your forced orientation is because you want only a 2D effect. If that's so then in Maple 2023 you could also do something like,

with(plots):
display(
  densityplot(argument(re+I*im), re=-2..2, im=-2..2,
              restricttoranges=true, grid=[100,100],
              colorscheme="turbo", style=surface),
  contourplot(argument(re+I*im), re=-2..2, im=-2..2,
              grid=[100,100], thickness=0.5,
              color=black, colorbar=false),
       labels=[Re(z),Im(z)], axes=box, size=[550,500]);

ps. Unfortunately densityplot doesn't accept style=surfacecontour, hence the accompanying call to contourplot.

@Art Kalb I don't know what kinds of expression you might have in general, ie. whether there might be other symbolic powers or functions of xi. But the case discussed so far can have a K*xi^0 term handled as follows.

restart;

 

expr := a*xi^2 - b*xi^4 - c + d/xi^4;

a*xi^2-b*xi^4-c+d/xi^4

map(t->H(degree(t,xi))*t, expr);

H(2)*a*xi^2-H(4)*b*xi^4-H(0)*c+H(-4)*d/xi^4


If you actually wanted to see the inert powers:

F := proc(t) local d:=degree(t,xi);
       H(d)*coeff(t,xi,d)*xi%^d;
     end proc:

 

alt := map(F, expr);

H(2)*a*`%^`(xi, 2)-H(4)*b*`%^`(xi, 4)-H(0)*c*`%^`(xi, 0)+H(-4)*d*`%^`(xi, -4)

value(alt);

H(2)*a*xi^2-H(4)*b*xi^4-H(0)*c+H(-4)*d/xi^4


If expr were not a sum of terms, ie.  type(expr,`+`)=false
then one could apply the transformer to it direrctly.

Download repl_ex4.mw

The dummy mechanism I used for my applyrule approach could be used also for the subsindets approach (instead of freeze/thaw).

As mentioned, I did it two ways on purpose.

expr := xi - xi^2 + 1/xi^3 - 1/xi;

xi-xi^2+1/xi^3-1/xi

eval(subsindets(expr,identical(xi)^integer,
                u->(H*__P)(op(2,u))),
     [xi=H(1)*xi,__P=(u->xi^op(u))])

H(1)*xi-H(2)*xi^2+H(-3)/xi^3-H(-1)/xi

Carl's idea to use temp name for xi is shorter than my use of temp __P calls for storing k the exponent. And such a modification can also shorten my earlier applyrule solution:

expr := xi - xi^2 + 1/xi^3 - 1/xi;

xi-xi^2+1/xi^3-1/xi

eval(applyrule([xi^(k::integer)=H(k)*__P^k],expr),
     __P=xi);

H(1)*xi-H(2)*xi^2+H(-3)/xi^3-H(-1)/xi

The temporary name (whether __P or %xi or what have you) is used to avoid the infinite recursion.

First 51 52 53 54 55 56 57 Last Page 53 of 592