acer

32313 Reputation

29 Badges

19 years, 312 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@dharr One of the difficulties here is the expansion, which can be undesirable -- possibly only because unnecessary, but also because it can increase the leaf-count.

With a very slightly different example, the expansion due to calling numer or denom can produce a result that is not best. (This is part of why I mentioned expand in my comment to the Question.)

restart;

cancel := proc(eq::`=`);
  local lhseq, rhseq, nums, dens;
  lhseq := factor(lhs(eq));
  rhseq := factor(rhs(eq));
  if lhseq = 0 or rhseq = 0 then return lhseq = rhseq end if;
  nums := factor(numer(lhseq)/numer(rhseq));
  dens := factor(denom(lhseq)/denom(rhseq));
  simplify(numer(nums)/numer(dens),size) = denom(nums)/denom(dens);
end proc:

eq := ((y-2*x)^3+x)/((sin(y)-x)^2*(x^2+x)) = a/(x^2*(sin(y)-x)^3)

((y-2*x)^3+x)/((sin(y)-x)^2*(x^2+x)) = a/(x^2*(sin(y)-x)^3)

cancel(eq);

(-8*x^3+12*x^2*y-6*x*y^2+y^3+x)/(x+1) = a/((sin(y)-x)*x)

((y-2*x)^3+x)/(x+1) = a/(x*(sin(y)-x))

((y-2*x)^3+x)/(x+1) = a/((sin(y)-x)*x)

simplify(%-%%);

0 = 0

Download cancel_ex1.mw

The idea of simplifying an equation in this way is not a bad idea.

But it shouldn't be done using that code snippet, which I wrote specifically for the example containing exp calls in the link you gave. I would write a more general (or targeted) version in quite a different manner, especially with regard to expand.

A reasonable place to start is to figure out what domain you want to handle, if only as a beginning. How about rational polynomials?

[edit] Regarding your code mentioned in your Question's Update, I'd mention expansion. The following expansion happens, for an example only slightly different:

eq:= ((y-2*x)^3+x)/( (y-x)^2 * x ) = a/x;
numer(lhs(eq))*denom(rhs(eq)) /  (denom(lhs(eq)) *numer(rhs(eq)))=1;

((y-2*x)^3+x)/((y-x)^2*x) = a/x

(-8*x^3+12*x^2*y-6*x*y^2+y^3+x)/((-y+x)^2*a) = 1

But IMO that numerator on the lhs would be better if it had stayed as the more compact (y-2*x)^3+x.

I fully realize that this difficulty of expansion due to numer & denom is not directly part of your cross-cancellation task. But it's an unpleasant side-effect that's too common in Maple "simplification". It keeps me awake at night. I'd suggest that a simplification enhancement focusing on numerator&denominator cancellations should try and avoid it.

[note: this is in response to a Reply that might since have been moved or deleted.]

@sursumCorda One of my issues with applyrule is that it is idiosyncratic. Another is that it has more weaknesses and bugs than I'd like to see.

The applyrule command attempts to provide an easy and convenient syntax, but ends up with some awkward holes at important corner cases.

Maple is not built up with pattern matching as a fundamental brick. But Maple is built up in important ways upon its powerful and flexible type system. And the indets/subsindets/evalindets commands are designed to be used directly with that type system.

Moreover, the convenience of having indets work with the same "specifier" as subsindets provides a very handy and direct probe.

Of course, there will always be examples (even some short examples) where one approach beats the other for simplicity and terseness. But that's like anecdotal evidence, and is not any indicator of general power, robustness, or flexibility.

In my opinion there are more severe bugs and weakness in applyrule than in the type system. Unless I have a very restricted and special case I almost always reach for the subsindets group before applyrule.

But I do not want this Answer to become any longer conversation of the relative merits, details, or equivalences of these two approaches. Anyone who wants to start that discussion elsewhere is free to do so...

@RezaZanjirani You haven't explained what you want to happen when one of the functions does not return a numeric result while one or two of the other do return such. That's not covered by any of your (i), (ii), or (iii).

How close can the results be from two of your functions, for you to accept them as equivalent (or both the greatest) at a given point?

It's not clear to me what you mean by a "labeled" region. Do you mean you want separate colors for the shared cases? And, labeled via a legend entry or by textplot?

You wrote that plots:-inequal took too long. How long is acceptable for any given individual plot here? 30sec? 1min?

How smooth do you want the edges? How much extra time are you willing to wait for that?

Have you still not considered investigating rewriting your procedures so that they might be more efficient, even after making quite a few postings on this topic?

Your FirmModelPP procedure lacks option remember, which the other two procedures have it. Is there some reason not to have it?

What do you want to happen when any of the three functions is not defined at some point [alpha,delta]? Do you want that left blank, or colored by whichever of the other functions (which might be defined there) is greatest?

What do you want the coloring to be for some point [alpha,delta] when more than one of the three functions shares the greatest value?

ps. Re-executing your attached worksheet didn't produce the same 2nd plot for me as is saved as output in the file.

You might read the Description section on the Help-page for the root command, as well as that of the surd command.

@enderw88 Yes, you could transform a subexpression by referencing its position" (which operand it is), or by its type, by its structural identity, by its mathematical nature, or possibly by a few other means (according to the example...).

Which approach would be more robust and appropriate would depend on the particular example as well as what future examples you'd like to mirror with the same approach.

For your given expression, which term did you want to transform, what aspect makes it the term to transform, and how should it be transformed?

I have deleted a duplicate Question thread, for essentially this same set of ODEs (with parameters slightly differently written).

The followup worksheet was this: Error_(1).mw

Please put your followups here, instead of spawning wholly separate new Question threads for this.

You've already split this off from your original Question thread on this topic ("C1" here).

Please don't spawn yet another wholly separate Question thread just to try and figure out a shorter syntax for this manipulation.

Duplicate Question threads get flagged as such, and may be deleted by some moderator.

@Mikey_W I'll try to write out some clear examples. But it might not be this week.

You have not attached your worksheet.

If you intend on using the name `gamma` like any usual, unassigned name then you might want to declare it local at the top-level.

@NIMA112 You could do something like this in Maple 2020.

Adjust your color choices as you wish.

h1_h2_ok_ac_2020_4_ac.mw

For example (and you could remove the 0.0 value from Clist if its contour bothered you).

Using Maple 2023.2 I can reproduce that crash in the GUI with just this.

restart;
G16 := GF(2, 4, alpha^4 + alpha + 1):
print(GF);

If I set  interface(typesetting=standard)  in an execution group right after the restart then I don't get the crash.

@NIMA112 You seem to have access to Maple 2023 sometimes. How about using the colorbar that plots:-contourplot produces in that version?

First 52 53 54 55 56 57 58 Last Page 54 of 591