acer

32313 Reputation

29 Badges

19 years, 313 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@OliverB If I recall correctly, the undefined values were posing a difficulty for implicitplot, which is why I put in a fallback extreme numeric value.

@MaPal93 I didn't see anything in your example that made me worry about continuing to use subs.

@lcz I added an alternative in my Answer, which for me produces a tabbed space between the columns of the exported file.

The file ends up looking like this, for me,

{{1, 6}, {2, 7}, {2, 8}, {4, 5}, {4, 6}, {5, 6}, {5, 7}, {5, 8}, {7, 8}}        3       infinity                                                                                                                           
{{1, 2}, {1, 4}, {2, 5}, {3, 4}, {3, 5}, {3, 6}, {5, 7}, {6, 8}, {7, 8}}        5       4                                                                                                                                  
{{1, 2}, {1, 7}, {2, 3}, {2, 4}, {3, 4}, {3, 8}, {4, 5}, {6, 8}, {7, 8}}        3       4                                                                                                                                  
{{1, 6}, {1, 7}, {2, 3}, {2, 8}, {3, 7}, {4, 7}, {4, 8}, {5, 8}, {7, 8}}        3       4                                                                                                                                  
{{1, 3}, {2, 6}, {2, 8}, {3, 6}, {3, 7}, {4, 7}, {4, 8}, {5, 7}, {7, 8}}        3       3                                                                                                                                  
{{2, 4}, {2, 7}, {2, 8}, {3, 4}, {3, 5}, {4, 6}, {4, 7}, {6, 7}, {6, 8}}        3       infinity                                                                                                                           
{{1, 3}, {1, 4}, {1, 5}, {1, 8}, {2, 4}, {2, 6}, {3, 6}, {4, 5}, {4, 8}}        3       infinity                                                                                                                           
{{1, 2}, {1, 6}, {2, 4}, {2, 6}, {3, 4}, {3, 5}, {3, 6}, {3, 8}, {4, 8}}        3       infinity                                                                                                                           
{{1, 2}, {1, 7}, {2, 4}, {3, 5}, {3, 8}, {4, 5}, {4, 8}, {5, 6}, {6, 7}}        4       4                                                                                                                                  
{{1, 2}, {1, 4}, {1, 7}, {2, 3}, {3, 8}, {4, 8}, {5, 6}, {5, 7}, {6, 8}}        5       3

@MaPal93 I'm still thinking about the `solve`. I might be busy for a few days, though.

As far as your last indets query goes, you could also do,

   indets(Eqs,And(name,Not(constant),Not(RandomVariable)))

if you want to exclude the _R, _R0, etc.

I also remembered something that I forgot to mention earlier. In my Answer's attachment I used subs instead of 2-argument eval to substitute placeholder names, because at some point I had noticed the eval was generating duplicates of the _R,_R0,.. names. But now I wonder whether it was because what was actually being used was RealDomain:-eval which might be more buggy. In any event, any other instance of such oddness would likely need a correction.

Because I'd mentioned the possibility of using densityplot...

fff := proc(x, y) local res, r;
 if not [x, y]::list(numeric) then
   return 'procname'(_passed);
 end if;
 r := y^2 + x^2;
 if 169.5^2 < r or r < 10000 then
   return undefined;
 end if;
 res := f(x, y);
 if not res::numeric then undefined;
 else res; end if;
end proc:

NN := 301:
P := plots:-densityplot(fff, -200 .. 200, -200 .. 200, style = surface, grid = [NN, NN], colorscheme = ["zgradient", ["Blue", "Red"], colorspace = "HSV"]):

AA := op([2], indets(P, specfunc(COLOR))[1]):
AA[..,..,3] := Array(1..NN,1..NN,1.0):

Pnew := subsindets(P, specfunc(COLOR), () -> COLOR(HSV, AA)):

plots:-display(Pnew, Tubeout, Tubein, Coreout);

And merging that with your other parts,

GraphTest.zip

@MaPal93 If you read the Help page for the indets command then you should see a bullet point in the Description section, that goes something like this:

    The argument expr is viewed as a rational expression (an expression
    formed by applying only the operations +, -, *, / to its subexpressions).
    Therefore, expressions such as sin(x), f(x, y), and  sqrt(x) are treated
    as indeterminates.

The point is that your calling indets(Eqs) without any options is not going to return only the unassigned names. If you want only names then you could call it as, say, indets(Eqs,name). Or, even more targeted (avoiding names like Pi, etc),
   indets(Eqs,And(name,Not(constant)))

Which reminds me to ask: you've used the name gamma. Did you intend that as some free name, or did you intend it as Euler's constant as Maple does by default. If the former then you could declare it at the start of your worksheet,
   local gamma;

I would not use the RealDomain package in involved computation. It's not very useful or robust, IMO. Instead I either make my assumptions (real, positive, etc) up front with assume or (my preference) pass them with assuming. I sometimes assign a sequence of the relevant assumptions to some name, so that I can easily re-use it for multiple assuming calls.

Reducing intermediate expression swell can sometimes be quite beneficial, lessening the burder on some commands (eg, solve, sometimes).

Oh, hang on... this is RealDomain:-simplify, not :-simplify, which is duplicating the names _R0, etc.

Do you have some special reason to be loading the whole RealDomain package?

The RealDomain:-simplify command may be the cause of the errant appearance of multiple different names _R0, etc.

@MaPal93 When simplify acts on some of your expressions containing names of type RandomVariable (here, appearing as _R, _R0, _R1, _R2) the results contain different versions of those names.

note: those names have attributes on them, one of which starts as a module or the name of one.

That might also mess up the solve, ie. it might see various _R0 names present in the Eqs as being distinct, etc, and not be able to work properly in consequence.

You might try the following: make all the preliminary calls to Mean & Variance, generate the unsimplified expressions, replace those problematic names without some innocuous names, then simplify, then assemble the Eqs and call solve, etc.

To show the nastiness, running the following in your code (right after the assignments to Exp_nu1_S & Exp_nu2_S):

foo:=Mean(nu[2]) + Sigma__vs[2] . MatrixInverse(Sigma__ss) . (S - Mean~(S)):
map(nm->print(nm,addressof(nm)),indets(foo,RandomVariable)):
"and...";
map(nm->print(nm,addressof(nm)),indets(simplify(foo),RandomVariable)):
"and...";
map(nm->print(nm,addressof(nm)),indets(simplify(foo),RandomVariable)):
                    _R, 36893627906852826684

                   _R0, 36893627906824461084

                   _R1, 36893627906689103900

                   _R2, 36893627906689104572

                            "and..."

                    _R, 36893627904561785564

                   _R0, 36893627904561779740

                   _R1, 36893627904561781532

                   _R2, 36893627904558314012

                            "and..."

                    _R, 36893627904773265372

                   _R0, 36893627904773259548

                   _R1, 36893627904773261340

                   _R2, 36893627904773263132

map(nm->print(nm,addressof(nm)),indets(add(S),RandomVariable)):
"and...";
map(nm->print(nm,addressof(nm)),indets(simplify(add(S)),RandomVariable)):
                    _R, 36893627906852826684

                   _R0, 36893627906824461084

                   _R1, 36893627906689103900

                   _R2, 36893627906689104572

                            "and..."

                    _R, 36893627904819602812

                   _R0, 36893627904819604540

                   _R1, 36893627904819598076

                   _R2, 36893627904819599804

@OtherAlloyMonkey Could explain in more detail -- or demonstrate, or explain explicitly -- why you think that the determinant of your Matrix AA , evaluated at omega=1, say, should not be zero?

Also, do you intend gamma to be just some name, or is it your intention to use it (as Maple does) as Euler's constant?

It's very difficult to provide best advice here since you haven't provided the actual example. You haven't even indicated how many unknowns you have.

You question, "Is there a limit to the matrix size on which the Determinant(A) can operate?" is not sensibly posed in the absence of some additional details. Useful answers depend on some of them.

@OliverB Something like this?

Adding to your prior code,

ff := proc(x, y)
  local res;
  if not [x, y]::list(numeric) then
    return 'procname'(_passed);
  end if;
  res := f(x, y);
  if not res::numeric then -1000; else res; end if;
end proc;

vlo, vhi := 100, 900;
ContPlotimpl := plots:-display(
  seq(plots:-implicitplot(ff(x, y) = v, x = -200 .. 200, y = -200 .. 200,
                          color = ColorTools:-Color("HSV", [0.667*(1 - (v - vlo)/(vhi - vlo)), 1, 1]),
                          legend = v), v = vlo .. vhi, 50));

plots:-display(ContPlotimpl, Tubeout, Tubein, Coreout);

ps. Workbooks are awkward to use here (and I find them awkward altogether). If possible, I'd much prefer to get a .mw file. (Thanks)

@ControlLaw Is there some special reason that you cannot show us your actual expression?

@OliverB Having the actual data would be useful.

@OliverB Yes, in Maple 2021 the contourplot command does not itself have any direct options for providing a rainbow of colors (eg. via colorscheme).

It could still be done by programmatically manipulating the resulting structure returned by your version's contourplot command. That's not terribly difficult, but I'm afraid that I don't have time to write that today.

One alternative might be to simply call implicitplot for each color and contour value pair that you want, and plots:-display the results together.

Another alternative might be to call densityplot instead of implicitplot (with a piecewise? that is undefined out of bounds, perhaps, or disabled extrapolation?, or a bounding hull?), with the desired color effect.

What do you mean by this?

   log/(x__3^(1/2)*x__4)

Are you trying to call the log command on something?

What do you mean by,

   F5 := 1/sqrt(x__3) = -2*log(2.51)/(F3*sqrt(x__3));

if you've already assigned an equation to F3, ie.

   F3 := 0.1*p*x__4/u = 0.1*p*x__4/u;

It doesn't make sense if you're making things with a form like,

   F5  :=  blah = blech*( foo = bar )

since that's an equation with another equation on its right-hand side. That's not just a problem for Maple; it doesn't make much sense mathematically.

First 74 75 76 77 78 79 80 Last Page 76 of 591