acer

30787 Reputation

29 Badges

19 years, 16 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@minhthien2016 Using that same procedure F from my last response above,

restart;

F := proc(ee, LL)
  local Hx,Hy;
  if LL[1]=1 and LL[2]=1 then
    eval(factor(ee)=ee,`=`~([a, b], LL));
  else
  Hx := ifelse(LL[1]=1, x,
               ifelse(LL[1]=-1, `#mfenced(mrow(mo("&uminus0;"),mi("x")))`,
               nprintf(`#mfenced(mrow(%a,mo("⁢"),mi("x")));`,
                       Typesetting:-Typeset(Typesetting:-EV(LL[1])))));
  Hy := ifelse(LL[2]=1, y,
              ifelse(LL[2]=-1, `#mfenced(mrow(mo("&uminus0;"),mi("y")))`,
              nprintf(`#mfenced(mrow(%a,mo("⁢"),mi("y")));`,
                      Typesetting:-Typeset(Typesetting:-EV(LL[2])))));
 Typesetting:-mrow(InertForm:-Typeset(InertForm:-Display(eval(eval(InertForm:-MakeInert(factor(ee)), [`%*` = `*`]) = InertForm:-MakeInert(sort(algsubs(b*y = Hy, algsubs(a*x = Hx, ee)), order = plex(Hx,Hy))), `=`~([a, b], LL)), inert = false)), Typesetting:-mo("="), InertForm:-Typeset(eval(ee, `=`~([a, b], LL))));
  end if;
end proc:

 

F(eval(expand((a*x+b*y)^2),[x=1,y=1]), [x,3]);

`%^`(`%+`(x, 3), 2) = `%+`(`%^`(x, 2), `%*`(2, x, 3), `%^`(3, 2)) and `%+`(`%^`(x, 2), `%*`(2, x, 3), `%^`(3, 2)) = x^2+6*x+9

sort(t-k,order=plex(t)):
F(eval(expand((a*x+b*y)^2),[x=t,y=-k]), [1,1]);

(t-k)^2 = k^2-2*k*t+t^2

# alternatively
F(eval(expand((a*x+b*y)^2),y=1), [1,3]);

`%^`(`%+`(x, 3), 2) = `%+`(`%^`(x, 2), `%*`(2, 3, x), `%^`(3, 2)) and `%+`(`%^`(x, 2), `%*`(2, 3, x), `%^`(3, 2)) = x^2+6*x+9; "_noterminate"


Download minhthien_ts2b.mw


ps. Since you haven't provided an explicit characterization of the goal then I'm finished here.

Here is slightly different handling for the cases of coefficients of 1 or -1.

restart;

F := proc(ee, LL)
  local Hx,Hy;
  if LL[1]=1 and LL[2]=1 then
    eval(factor(ee)=ee,`=`~([a, b], LL));
  else
  Hx := ifelse(LL[1]=1, x,
               ifelse(LL[1]=-1, `#mfenced(mrow(mo("&uminus0;"),mi("x")))`,
               nprintf(`#mfenced(mrow(%a,mo("⁢"),mi("x")));`,
                       Typesetting:-Typeset(Typesetting:-EV(LL[1])))));
  Hy := ifelse(LL[2]=1, y,
              ifelse(LL[2]=-1, `#mfenced(mrow(mo("&uminus0;"),mi("y")))`,
              nprintf(`#mfenced(mrow(%a,mo("⁢"),mi("y")));`,
                      Typesetting:-Typeset(Typesetting:-EV(LL[2])))));
 Typesetting:-mrow(InertForm:-Typeset(InertForm:-Display(eval(eval(InertForm:-MakeInert(factor(ee)), [`%*` = `*`]) = InertForm:-MakeInert(sort(algsubs(b*y = Hy, algsubs(a*x = Hx, ee)), order = plex(Hx,Hy))), `=`~([a, b], LL)), inert = false)), Typesetting:-mo("="), InertForm:-Typeset(eval(ee, `=`~([a, b], LL))));
  end if;
end proc:

p := a^3*x^3 + 3*a^2*b*x^2*y + 3*a*b^2*x*y^2 + b^3*y^3;

a^3*x^3+3*a^2*b*x^2*y+3*a*b^2*x*y^2+b^3*y^3

L := [[2, 3], [-3,1], [1, 2], [-1, -1], [1, 1], [1/3, -sqrt(2)]];

[[2, 3], [-3, 1], [1, 2], [-1, -1], [1, 1], [1/3, -2^(1/2)]]

ans := F~(p, L):

print~(ans):

`%^`(`%+`(2*x, 3*y), 3) = `%+`(`%^`(`#mfenced(mrow(Typesetting`:-`mn("2"),mo("⁢"),mi("x")));`, 3), `%*`(3, `%^`(`#mfenced(mrow(Typesetting`:-`mn("2"),mo("⁢"),mi("x")));`, 2), `#mfenced(mrow(Typesetting`:-`mn("3"),mo("⁢"),mi("y")));`), `%*`(3, `#mfenced(mrow(Typesetting`:-`mn("2"),mo("⁢"),mi("x")));`, `%^`(`#mfenced(mrow(Typesetting`:-`mn("3"),mo("⁢"),mi("y")));`, 2)), `%^`(`#mfenced(mrow(Typesetting`:-`mn("3"),mo("⁢"),mi("y")));`, 3)) and `%+`(`%^`(`#mfenced(mrow(Typesetting`:-`mn("2"),mo("⁢"),mi("x")));`, 3), `%*`(3, `%^`(`#mfenced(mrow(Typesetting`:-`mn("2"),mo("⁢"),mi("x")));`, 2), `#mfenced(mrow(Typesetting`:-`mn("3"),mo("⁢"),mi("y")));`), `%*`(3, `#mfenced(mrow(Typesetting`:-`mn("2"),mo("⁢"),mi("x")));`, `%^`(`#mfenced(mrow(Typesetting`:-`mn("3"),mo("⁢"),mi("y")));`, 2)), `%^`(`#mfenced(mrow(Typesetting`:-`mn("3"),mo("⁢"),mi("y")));`, 3)) = 8*x^3+36*x^2*y+54*x*y^2+27*y^3

`%^`(`%+`(-3*x, y), 3) = `%+`(`%^`(`#mfenced(mrow(Typesetting`:-`mn("&uminus0;3"),mo("⁢"),mi("x")));`, 3), `%*`(3, `%^`(`#mfenced(mrow(Typesetting`:-`mn("&uminus0;3"),mo("⁢"),mi("x")));`, 2), y), `%*`(3, `#mfenced(mrow(Typesetting`:-`mn("&uminus0;3"),mo("⁢"),mi("x")));`, `%^`(y, 2)), `%^`(y, 3)) and `%+`(`%^`(`#mfenced(mrow(Typesetting`:-`mn("&uminus0;3"),mo("⁢"),mi("x")));`, 3), `%*`(3, `%^`(`#mfenced(mrow(Typesetting`:-`mn("&uminus0;3"),mo("⁢"),mi("x")));`, 2), y), `%*`(3, `#mfenced(mrow(Typesetting`:-`mn("&uminus0;3"),mo("⁢"),mi("x")));`, `%^`(y, 2)), `%^`(y, 3)) = -27*x^3+27*x^2*y-9*x*y^2+y^3

`%^`(`%+`(x, 2*y), 3) = `%+`(`%^`(x, 3), `%*`(3, `%^`(x, 2), `#mfenced(mrow(Typesetting`:-`mn("2"),mo("⁢"),mi("y")));`), `%*`(3, x, `%^`(`#mfenced(mrow(Typesetting`:-`mn("2"),mo("⁢"),mi("y")));`, 2)), `%^`(`#mfenced(mrow(Typesetting`:-`mn("2"),mo("⁢"),mi("y")));`, 3)) and `%+`(`%^`(x, 3), `%*`(3, `%^`(x, 2), `#mfenced(mrow(Typesetting`:-`mn("2"),mo("⁢"),mi("y")));`), `%*`(3, x, `%^`(`#mfenced(mrow(Typesetting`:-`mn("2"),mo("⁢"),mi("y")));`, 2)), `%^`(`#mfenced(mrow(Typesetting`:-`mn("2"),mo("⁢"),mi("y")));`, 3)) = x^3+6*x^2*y+12*x*y^2+8*y^3

`%^`(`%+`(-x, -y), 3) = `%+`(`%^`(`#mfenced(mrow(mo("&uminus0;"),mi("x")))`, 3), `%*`(3, `%^`(`#mfenced(mrow(mo("&uminus0;"),mi("x")))`, 2), `#mfenced(mrow(mo("&uminus0;"),mi("y")))`), `%*`(3, `#mfenced(mrow(mo("&uminus0;"),mi("x")))`, `%^`(`#mfenced(mrow(mo("&uminus0;"),mi("y")))`, 2)), `%^`(`#mfenced(mrow(mo("&uminus0;"),mi("y")))`, 3)) and `%+`(`%^`(`#mfenced(mrow(mo("&uminus0;"),mi("x")))`, 3), `%*`(3, `%^`(`#mfenced(mrow(mo("&uminus0;"),mi("x")))`, 2), `#mfenced(mrow(mo("&uminus0;"),mi("y")))`), `%*`(3, `#mfenced(mrow(mo("&uminus0;"),mi("x")))`, `%^`(`#mfenced(mrow(mo("&uminus0;"),mi("y")))`, 2)), `%^`(`#mfenced(mrow(mo("&uminus0;"),mi("y")))`, 3)) = -x^3-3*x^2*y-3*x*y^2-y^3

(x+y)^3 = x^3+3*x^2*y+3*x*y^2+y^3

`%^`(`%+`((1/3)*x, -sqrt(2)*y), 3) = `%+`(`%^`(`#mfenced(mrow(Typesetting`:-`mfrac(Typesetting`:-`mn("1"),Typesetting`:-`mn("3")),mo("⁢"),mi("x")));`, 3), `%*`(3, `%^`(`#mfenced(mrow(Typesetting`:-`mfrac(Typesetting`:-`mn("1"),Typesetting`:-`mn("3")),mo("⁢"),mi("x")));`, 2), `#mfenced(mrow(Typesetting`:-`mrow(Typesetting`:-`mo("&uminus0;"),Typesetting`:-`msqrt(Typesetting`:-`mn("2"))),mo("⁢"),mi("y")));`), `%*`(3, `#mfenced(mrow(Typesetting`:-`mfrac(Typesetting`:-`mn("1"),Typesetting`:-`mn("3")),mo("⁢"),mi("x")));`, `%^`(`#mfenced(mrow(Typesetting`:-`mrow(Typesetting`:-`mo("&uminus0;"),Typesetting`:-`msqrt(Typesetting`:-`mn("2"))),mo("⁢"),mi("y")));`, 2)), `%^`(`#mfenced(mrow(Typesetting`:-`mrow(Typesetting`:-`mo("&uminus0;"),Typesetting`:-`msqrt(Typesetting`:-`mn("2"))),mo("⁢"),mi("y")));`, 3)) and `%+`(`%^`(`#mfenced(mrow(Typesetting`:-`mfrac(Typesetting`:-`mn("1"),Typesetting`:-`mn("3")),mo("⁢"),mi("x")));`, 3), `%*`(3, `%^`(`#mfenced(mrow(Typesetting`:-`mfrac(Typesetting`:-`mn("1"),Typesetting`:-`mn("3")),mo("⁢"),mi("x")));`, 2), `#mfenced(mrow(Typesetting`:-`mrow(Typesetting`:-`mo("&uminus0;"),Typesetting`:-`msqrt(Typesetting`:-`mn("2"))),mo("⁢"),mi("y")));`), `%*`(3, `#mfenced(mrow(Typesetting`:-`mfrac(Typesetting`:-`mn("1"),Typesetting`:-`mn("3")),mo("⁢"),mi("x")));`, `%^`(`#mfenced(mrow(Typesetting`:-`mrow(Typesetting`:-`mo("&uminus0;"),Typesetting`:-`msqrt(Typesetting`:-`mn("2"))),mo("⁢"),mi("y")));`, 2)), `%^`(`#mfenced(mrow(Typesetting`:-`mrow(Typesetting`:-`mo("&uminus0;"),Typesetting`:-`msqrt(Typesetting`:-`mn("2"))),mo("⁢"),mi("y")));`, 3)) = (1/27)*x^3-(1/3)*sqrt(2)*x^2*y+2*x*y^2-2*sqrt(2)*y^3; "_noterminate"


Download minhthien_ts2.mw

I don't know what other special cases you might want handled, because you haven't stated requirements explicitly (or even where this code arose).

@minhthien2016 I expect that it's not hard, using a simple conditional ifelse or other tweak when forming the special Hx and Hy names. But I won't have the time until later in the day.

@C_R He can already construct multi-equations, which is all that's in the link you gave.

What he's trying to do now is sort "polynomials" by the inert terms like 3%*x and 2%*y.

That can be done, as I showed below, by turning those inert products into atomic identifiers, ie. actual Maple names (which sort can handle)..

@Ronan In my experience the maplemint command (an actual Maple language command) provides watered-down and weak access to the standalone mint utility's functionality. 

@minhthien2016 You haven't shown us what you've been attempting. I can't identify your problem without even knowing any explicit details.

Did you use a file path? Or are you relying on currentdir(), and if so did you first set that? Are you sure that you're not accidentally trying to write to Maple's installation folder?

And so on...

Your basic mistake here is not telling us any details.

@Anthrazit 

The Maple code checker mint is available as a stand-alone file.

See the Maple installation folder for location of binaries (like the GUI launcher).

The way that the GUI's code-editing regions access mint is a somewhat recent feature. But it's always been possible from the OS command-line.

Some editors allow you to set up a macro, for a quick way to do acts on a edited file, from within the running editor.

Calling the mint program also allows for your own choice of options. I use -i2 ., but some people also toggle a few off with -tX -tY.

@minhthien2016 As I already wrote (and linked for you with a URL) you can use the fprintf command to write it to a file.

The filename can be a string, optionally with a relative or absolute filename according to your OS. That's all your choice. You can set currentdir(...), or construct the filename, as you see fit.

The methodology could be improved and made more efficient.

The following take 14sec on my machine, compared to 830sec for the original. That's over fifty times faster.

Rolling_an_Ellipse_Along_a_Curve_August_2024_ac1.mw

(please check for correctness.)

It also seems to me a bit odd that the total frame number may affect the granularity of the ellipse itself. I suspect that it could be done faster still, using a single fine construction of ellipse&foci, and then a more efficient rotation&translation (perhaps plottools:-rotate, etc). Alas, I don't have the time for a rewrite.

@Greenwaldian 

I'm not sure that I understand the comment about admin access. IIRC the file in question exists per user, and even on a network install. It might be accessible by the user himself/herself.

You might submit a bug report, here. There's even a chance that a fix might make it into a "point-release".

@mmcdara The relative performance of these might well change if done for (a modest) number of much longer individual lists, or even for a much larger number of modestly sized lists.

So, just as one data point: ListTools_Search_tim.mw

@Greenwaldian That,

ScrollableMathTableOutput=false

is not a Maple command. It is line for the user's GUI preferences files. I don't mean the .ini file that can act as an initialization file. Rather, I mean the (similarly named, but differently located) GUI preferences file. Again, it's not a Maple command.

This file is where the GUI options and preferences are stored. But this particular preference does not appear as an option in the GUI's own popup menu (Options dialogue).

The line might already exist in one's file, but with true instead of false. The GUI would need to be altogether closed, then the file edited and the existing line changed, then the file saved&closed, and then the GUI relaunched.

It's conceivable that disabling the (new to M2024) scrollable Matrix display in the GUI might also revert the PDF export mechanism aspect that produces your ellipsis example. If you haven't yet been able to disable this new rtable/Matrix scrollable display mechanism then you haven't as yet been able to test it as potential workaround.

Which operating system are you using, btw? Perhaps someone else might be able to reproduce the problem.

@Paras31 Please don't spawn wholly separate, new Question threads for other attempts you make at porting this code to Maple.

(Duplicate Question threads get flagged as such and may even be deleted by some moderator.)

@Carl Love If you make the transformed result be something like H(["x"=x,"y"=y]) and run the applyrule under trace then the cause partially reveals itself. It accepts too much for the pattern, in particular the dreaded unit.

Sometimes this can be avoided. One variant:

applyrule((x::nonunit(anything))^(1/2)*(y::nonunit(fraction)) = `%*`(y,x^(1/2)),eq);

The OP didn't provide other examples and expectations, so it's not clear whether (and how) things like 3/(2*p)*sqrt(-2*lambda) might be preferably handled. Variants can be had.

@Thomas Richard Sometimes inconsistencies are not terrible; I'd rather not read code that contained esu or yrt.

2 3 4 5 6 7 8 Last Page 4 of 565