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

@Kevin Dragnet For fun, you can create a pair of utilities that allow you to flexibly set/unset the behaviour according to some supplied form(s).

restart

Enable := proc (f, vars, form) options operator, arrow; assign(cat('`print/`', f), unapply(form, vars)) end proc; Disable := proc (f) options operator, arrow; unassign(cat('`print/`', f)) end proc

 

Enable(`#mover(mi("U"),mo("∼"))`, [x, y, z], `#mover(mi("U"),mo("∼"))`[z](x, y))

 

`#mover(mi("U"),mo("∼"))`(v1, v2, w)

`#mover(mi("U"),mo("∼"))`(v1, v2, w)

`#mover(mi("U"),mo("∼"))`(a, b, c)

`#mover(mi("U"),mo("∼"))`(a, b, c)

Disable(`#mover(mi("U"),mo("∼"))`)

 

`#mover(mi("U"),mo("∼"))`(v1, v2, w)

`#mover(mi("U"),mo("∼"))`(v1, v2, w)

 

Enable(`#mover(mi("U"),mo("∼"))`, [x, y, z], (('InertForm:-Display')(`#mover(mi("U"),mo("∼"))`^`%.`(x, y), 'inert' = false))(z))

`#mover(mi("U"),mo("∼"))`(v1, v2, w)

`#mover(mi("U"),mo("∼"))`(v1, v2, w)

`#mover(mi("U"),mo("∼"))`(a, b, c)

`#mover(mi("U"),mo("∼"))`(a, b, c)

Disable(`#mover(mi("U"),mo("∼"))`)

`#mover(mi("U"),mo("∼"))`(v1, v2, w)

`#mover(mi("U"),mo("∼"))`(v1, v2, w)

Download printf_ext_gen01.mw

Sometimes the unevaluated "form" may be slightly tricky to concoct. (Using 2D Input doesn't make it easier...)

@Kevin Dragnet If you know that your function call will only ever have exactly three arguments then you can make it shorter:

restart

`print/#mover(mi("U"),mo("∼"))`:=
  (a,b,c)->`#mover(mi("U"),mo("∼"));`[c](a,b):

 

`#mover(mi("U"),mo("∼"))`(v1, v2, v3)

`#mover(mi("U"),mo("∼"))`(v1, v2, v3)

`#mover(mi("U"),mo("∼"))`(x, y, z)

`#mover(mi("U"),mo("∼"))`(x, y, z)

Download printf_sub_ex3.mw

 

And the above looks complicated mostly because it's hard-coded for that typeset U-tilde.

A pair of commands to enable/disable such a rule according to the name of the function (zeroth operand), would be quite simple. But you didn't address my earlier queries about what exactly you might want along those lines.

@Kevin Dragnet I have amended my Answer to include a solution for your followup query.

I don't really understand why you wouldn't describe what you actually wanted at the outset.

Perhaps you are actually looking for a more general mechanism that can,
1) enable a particular rule for pretty-printing of unevaluated function calls to any name you supply (eg. U, f, U-tilde, etc).
2) disable such a previously enabled rule, given a name you supply.
If that is your goal then you should explicitly specify the rule you want, eg,
  i) f(a[1],...a[n]) displays like f[a[n]](a[1],...a[n-1]) for any posint n.
or, say,
  ii) f(a[1],a[2],a[3]) displays like f[a[3]](a[1],a[2]) and all other calls to f display as usual,
or,
  iii) something else as yet unexplained.
If you are looking to implement something more general like that then you really ought to explain the requirements in full.

@Oliveira The link you provided downloads as an empty file (zero bytes).

The GUI's ability to recover from a corrupted .mw file is sometimes problematic. Sometimes it is unable to recover as much as possible of the content.

So, if your recovery doesn't go well, you could also try uploading the errant file and attaching a link to it here.

Why haven't you attached your complete example, with tightly specific details about what you actually wanted, to this Question itself?

It seems that calling is or coulditbe on this example does in fact make use of SMTLIB:-Satisfiable (Maple 2022.2), but not in a manner that gets the result.

I will submit the example.

[edit] The following kludge allows is to get a result, very slowly. Alas it doesn't try any early pass-off of the whole system to SMTLIB:-Satisfiable, which we know can handle the whole system quickly.

restart;
kernelopts(version);
   Maple 2022.2, X86 64 LINUX, Oct 23 2022, Build ID 1657361

F1 := a + b + c + d > 0
      and
      a*b + a*c + a*d + b*c + b*d + c*d > a^2 + b^2 + c^2 + d^2:
F2 := d*c*b*a > 0
      and
      a*b*c + a*b*d + a*c*d + b*c*d > 0:
if convert(kernelopts(version),string)[7..12]="2022.2" then

  `is/internal/SMTLIB`:=FromInert(subsop([5,7,1,2,5,1,1,2,1,2,1,2,1]=10,
                                  ToInert(eval(`is/internal/SMTLIB`)))):

  _EnvTry := hard:

  CodeTools:-Usage(print( is( not( F1 and not F2 ) ) )) assuming real;

end if:
                              true

memory used=15.57GiB, alloc change=361.50MiB, cpu time=3.34m, real time=2.97m, gc time=32.51s

@Carl Love Thank you; it was early and while I had other equivalent forms ok I was blind to this one.
    is( not( F1 and not F2 ) )

And if I correct it then I get FAIL, as I did for a valid equivalent form with disjunction, etc. (I was suspicious because the "success" stood out.

@dharr The fact that both 1 and undefined are both of type algebraic is not a sufficient reason to expect that neither would be applied to the index pairs as arguments.

Every symbol is of type algebraic. Like the number 1 and the name undefined, the symbol `^` is also a name of type algebraic.

Matrix(2,2,`^`);

                [1  1]
                [    ]
                [2  4]

The help-page for topic Matrix states:

"expression of type algebraic
The expression is evaluated as a function (or procedure) which takes a pair of positive integers as arguments (i.e., Matrix indices) and returns the value of the corresponding entry of the Matrix.
"

Kitonum's Answer explains what has happened: the name undefined is of type algebraic, and so it gets applied to the index pairs. This is an example covered by the cited paragraph above.

Here's something relevent to your example of using the number 1 as third argument. Anything of type numeric or complex(numeric) returns itself when applied to something:

17(2,5);

             17

-37.23(11,2);

           -37.23

(3/7)(8,3);

              3
              -
              7

In a related way, consider,

   Matrix(2,2,f);
   eval(%, f=3.4);
   Matrix(2,2,3.4);

(I'm not saying that the Matrix command actually goes to all the effort of appling a numeric 3rd argument to all the index pairs. It may well know that it doesn't have to bother. The behaviour is consistent with its doing so, which is what matters here.)

@zenterix The code snippet you just posted appears to be fundamentally the same kind of thing that the Explore command does, ie. it simply embeds a Plot Component and then pushes the various pointplot3d results to it. Those lines of code are essentially what Explore does, yet less simple and straightforward.

Except Carl's use of Explorepointplot3d contains some additional kernel/Library-side memory optimizations.

There doesn't appear to be anything in the code snippet you just gave that would help in any additional way with the memory clog in the Java GUI that Carl described.

It does not necessarily follow that y1 has been assigned an expression sequence with seven elements.

Upload a worksheet that replicates the issue, or at the very least show us what lprint(y1) gives.

@Mike Mc Dermott The Matrix help page's Description bullet point for that calling sequence does not match your expectation.

Which documented calling sequence of the Matrix command are you considering, when you refer to the third argument as the "initial value"?

@sursumCorda My main point was that is and coulditbe are the primary commands under which I'd hope first to find this functionality. But I was mostly getting FAIL.

I am planning to submit a software change request against them here. I would add in a note that SMTLIB might be better leveraged to improve their functionality (though, doing so would require adjustments to the case-switching and dispatch mechanisms, which might be involved).

After is and coulditbe, it's possible that simplify might also be able to leverage it.

In all of this it might be that and/not/or might be handled before, say, &implies. I'm not sure how much more involved it would be to support the logical implication via assuming, as opposed to a logical equivalent of and.

@MigMRF One idea is that you could try doing what I (and many others) do, and avoid using 2D Input altogether. I use 1D (plaintext) Maple Notation in a Worksheet, and not 2D Input in a Document.

Do you inline images in your Documents? Do you use a foreign language in it (eg. Danish). That pair, combined, neems to be a common theme of corrupted Documents as reported in this forum.

As far as you attachments go, it's tricky for me to know what you actually enter (as 2D Input) in the input areas whose equations might become corrupted.

First 86 87 88 89 90 91 92 Last Page 88 of 591