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

@RezaZanjirani Your last Reply has no attachment.

@RezaZanjirani In my code I made it take the first solution from solve.

Your situation might be better handled as an optimization problem, ie. maximize this new (as yet unstated) objective function, with the original equalities/inequalities as constraints. And, for speed, it might be formulated as a floating-point numeric problem.

Prior to this, you've created several separate Question threads on this (or very close) topic. Please don't spawn any more wholly separate new Question threads on this. Duplicate Question threads get flagged as such and may be deleted.

You could add your followup queries and details to this or an earlier relevant Question. I suggest providing as complete and detailed a description as you can of your eventual goal and motivating example as you can, even if you don't yet have prototype Maple code to solve it. That'd be much more useful than, say, slowly approaching your actual goal by a set of partial reveals of details & code attempts.

@RezaZanjirani You could construct the legend entries programmatically, as some function of the delta values. For example, HmaxProc_ac2.mw

Or you could simply construct them separately, by hand.

I don't know whether your "TEXT" has to vary with the delta values, and if so, how.

IIRC the X11_defaults/Maple file was used by the Classic GUI, which isn't really available any more for Linux.

There is a resources file used by the Java GUI, named like (version specific),
    ~/.maple/2023/maplerc
but I don't think that allows for much color configuration aside from the line like,
HelpBGColor=255 255 255
which I think specifies the background color for the main window portion of the Help viewer.

I have deleted yet another duplicate Question thread on this doCalc procedure.

If the OP has further followup queries or details on this then they can be added here, instead of in wholly separate new Question threads.

@minhthien2016 

with(Typesetting): with(InertForm):

mrow(Display(%sqrt(8) + %sqrt(32), inert=false),
     mo("="),
     Display(sqrt(2%*2%^2) + sqrt(2%*4%^2), inert=false),
     mo("="),
     Display(2 %* %sqrt(2) + 4 %* %sqrt(2), inert=false),
     mo("="),
     Display(6*sqrt(2)));

%sqrt(8)+%sqrt(32) = sqrt(`%*`(2, `%^`(2, 2)))+sqrt(`%*`(2, `%^`(4, 2))) and sqrt(`%*`(2, `%^`(2, 2)))+sqrt(`%*`(2, `%^`(4, 2))) = `%*`(2, %sqrt(2))+`%*`(4, %sqrt(2)) and `%*`(2, %sqrt(2))+`%*`(4, %sqrt(2)) = 6*sqrt(2)

Download inert_exa.mw

@minhthien2016 

F := proc(ee,LL)
  uses InertForm, Typesetting;
  mrow(Typeset(Display(eval(eval(MakeInert(factor(ee)),[`%*`=`*`])
                                 =MakeInert(subs(b=MakeInert(b*y)/y,
                        a=MakeInert(a*x)/x,p)),[a,b]=~LL),
                       inert=false)),
       mo("="),Typeset(eval(ee,[a,b]=~LL)))
end proc:

p := (a*x)^2 - 2*a*x*b*y + (b*y)^2:

L := [[2,3],[2,5],[2,7]];

[[2, 3], [2, 5], [2, 7]]

ans := F~(p, L):

print~(ans):

`%^`(`%+`(2*x, -3*y), 2) = `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, `%*`(2, x), `%*`(3, y)), `%^`(`%*`(3, y), 2)) and `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, `%*`(2, x), `%*`(3, y)), `%^`(`%*`(3, y), 2)) = 4*x^2-12*x*y+9*y^2

`%^`(`%+`(2*x, -5*y), 2) = `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, `%*`(2, x), `%*`(5, y)), `%^`(`%*`(5, y), 2)) and `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, `%*`(2, x), `%*`(5, y)), `%^`(`%*`(5, y), 2)) = 4*x^2-20*x*y+25*y^2

`%^`(`%+`(2*x, -7*y), 2) = `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, `%*`(2, x), `%*`(7, y)), `%^`(`%*`(7, y), 2)) and `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, `%*`(2, x), `%*`(7, y)), `%^`(`%*`(7, y), 2)) = 4*x^2-28*x*y+49*y^2

Download inert_ex7.mw

(or, in steps as before, inert_ex6.mw)

@minhthien2016 Once you have a process that works on a single data list, you can make it into a reusable procedure to work easily on multiple data lists.

restart;

 

F := proc(ee,LL)
  uses InertForm, Typesetting;
  mrow(Typeset(Display(eval(eval(MakeInert(factor(ee)),[`%*`=`*`])
                                 =MakeInert(map(sort,algsubs(a*x=MakeInert(a*x),ee),
                                                order=plex(b))),[a,b]=~LL),
                       inert=false)),
       mo("="),Typeset(eval(ee,[a,b]=~LL)))
end proc:

 

p := (a*x)^2 - 2*(a*x)*b + b^2:

L := [[2,3],[3,7],[9,10]];

[[2, 3], [3, 7], [9, 10]]

ans := F~(p, L);

[Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⁢"), Typesetting:-mi("x")), Typesetting:-mo("−"), Typesetting:-mn("3")), Typesetting:-_Hold([`%+`(2*x, -3)])))), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(`%+`(2*x, -3), 2)])), Typesetting:-mo("="), Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⋅"), Typesetting:-mi("x")), Typesetting:-_Hold([`%*`(2, x)])))), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(`%*`(2, x), 2)])), Typesetting:-mo("−"), Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⋅"), Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⋅"), Typesetting:-mi("x")), Typesetting:-_Hold([`%*`(2, x)]))), Typesetting:-mo("⋅"), Typesetting:-mn("3")), Typesetting:-_Hold([`%*`(2, `%*`(2, x), 3)])), Typesetting:-mo("+"), Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mn("3")), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(3, 2)]))), Typesetting:-_Hold([`%+`(`%^`(`%*`(2, x), 2), `%*`(-2, `%*`(2, x), 3), `%^`(3, 2))]))), Typesetting:-mo("="), Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mn("4"), Typesetting:-mo("⁢"), Typesetting:-msup(Typesetting:-mi("x"), Typesetting:-mn("2"))), Typesetting:-mo("−"), Typesetting:-mrow(Typesetting:-mn("12"), Typesetting:-mo("⁢"), Typesetting:-mi("x")), Typesetting:-mo("+"), Typesetting:-mn("9"))), Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mn("3"), Typesetting:-mo("⁢"), Typesetting:-mi("x")), Typesetting:-mo("−"), Typesetting:-mn("7")), Typesetting:-_Hold([`%+`(3*x, -7)])))), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(`%+`(3*x, -7), 2)])), Typesetting:-mo("="), Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("3"), Typesetting:-mo("⋅"), Typesetting:-mi("x")), Typesetting:-_Hold([`%*`(3, x)])))), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(`%*`(3, x), 2)])), Typesetting:-mo("−"), Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⋅"), Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("3"), Typesetting:-mo("⋅"), Typesetting:-mi("x")), Typesetting:-_Hold([`%*`(3, x)]))), Typesetting:-mo("⋅"), Typesetting:-mn("7")), Typesetting:-_Hold([`%*`(2, `%*`(3, x), 7)])), Typesetting:-mo("+"), Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mn("7")), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(7, 2)]))), Typesetting:-_Hold([`%+`(`%^`(`%*`(3, x), 2), `%*`(-2, `%*`(3, x), 7), `%^`(7, 2))]))), Typesetting:-mo("="), Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mn("9"), Typesetting:-mo("⁢"), Typesetting:-msup(Typesetting:-mi("x"), Typesetting:-mn("2"))), Typesetting:-mo("−"), Typesetting:-mrow(Typesetting:-mn("42"), Typesetting:-mo("⁢"), Typesetting:-mi("x")), Typesetting:-mo("+"), Typesetting:-mn("49"))), Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mn("9"), Typesetting:-mo("⁢"), Typesetting:-mi("x")), Typesetting:-mo("−"), Typesetting:-mn("10")), Typesetting:-_Hold([`%+`(9*x, -10)])))), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(`%+`(9*x, -10), 2)])), Typesetting:-mo("="), Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("9"), Typesetting:-mo("⋅"), Typesetting:-mi("x")), Typesetting:-_Hold([`%*`(9, x)])))), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(`%*`(9, x), 2)])), Typesetting:-mo("−"), Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⋅"), Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("9"), Typesetting:-mo("⋅"), Typesetting:-mi("x")), Typesetting:-_Hold([`%*`(9, x)]))), Typesetting:-mo("⋅"), Typesetting:-mn("10")), Typesetting:-_Hold([`%*`(2, `%*`(9, x), 10)])), Typesetting:-mo("+"), Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mn("10")), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(10, 2)]))), Typesetting:-_Hold([`%+`(`%^`(`%*`(9, x), 2), `%*`(-2, `%*`(9, x), 10), `%^`(10, 2))]))), Typesetting:-mo("="), Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mn("81"), Typesetting:-mo("⁢"), Typesetting:-msup(Typesetting:-mi("x"), Typesetting:-mn("2"))), Typesetting:-mo("−"), Typesetting:-mrow(Typesetting:-mn("180"), Typesetting:-mo("⁢"), Typesetting:-mi("x")), Typesetting:-mo("+"), Typesetting:-mn("100")))]

print~(ans):

`%^`(`%+`(2*x, -3), 2) = `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, `%*`(2, x), 3), `%^`(3, 2)) and `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, `%*`(2, x), 3), `%^`(3, 2)) = 4*x^2-12*x+9

`%^`(`%+`(3*x, -7), 2) = `%+`(`%^`(`%*`(3, x), 2), `%*`(-2, `%*`(3, x), 7), `%^`(7, 2)) and `%+`(`%^`(`%*`(3, x), 2), `%*`(-2, `%*`(3, x), 7), `%^`(7, 2)) = 9*x^2-42*x+49

`%^`(`%+`(9*x, -10), 2) = `%+`(`%^`(`%*`(9, x), 2), `%*`(-2, `%*`(9, x), 10), `%^`(10, 2)) and `%+`(`%^`(`%*`(9, x), 2), `%*`(-2, `%*`(9, x), 10), `%^`(10, 2)) = 81*x^2-180*x+100

Download inert_ex5.mw

@minhthien2016 Like this?

restart;

with(InertForm): with(Typesetting):

p := (a*x)^2 - 2*(a*x)*b + b^2:

temp1 := eval(MakeInert(factor(p)),[`%*`=`*`]):

temp2 := MakeInert(map(sort,algsubs(a*x=MakeInert(a*x),p),
                       order=plex(b))):

L := [a=2,b=3]:

r1 := Display(eval(temp1=temp2,L),inert=false):

r2 := eval(p,L):

 

mrow(Typeset(EV(r1)),mo("="),Typeset(EV(r2)));

`%^`(`%+`(2*x, -3), 2) = `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, `%*`(2, x), 3), `%^`(3, 2)) and `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, `%*`(2, x), 3), `%^`(3, 2)) = 4*x^2-12*x+9

Download inert_ex4.mw

Please put your close followup examples here, instead of spawning wholly separate new Question threads on the same topic.

An example:

restart;

with(InertForm): with(Typesetting):

 

p := (a*x)^2 - 2*(a*x)*b + b^2;

a^2*x^2-2*a*b*x+b^2

temp1 := eval(MakeInert(factor(p)),[`%*`=`*`]);

`%^`(`%+`(a*x, -b), 2)

temp2 := MakeInert(algsubs(a*x=MakeInert(a*x),p));

`%+`(`%^`(`%*`(a, x), 2), `%*`(-2, b, `%*`(a, x)), `%^`(b, 2))

L := [a=2,b=3];

[a = 2, b = 3]

r1 := Display(eval(temp1=temp2,L),inert=false);

Typesetting:-mrow(Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⁢"), Typesetting:-mi("x")), Typesetting:-mo("−"), Typesetting:-mn("3")), Typesetting:-_Hold([`%+`(2*x, -3)])))), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(`%+`(2*x, -3), 2)])), Typesetting:-mo("="), Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⋅"), Typesetting:-mi("x")), Typesetting:-_Hold([`%*`(2, x)])))), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(`%*`(2, x), 2)])), Typesetting:-mo("−"), Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⋅"), Typesetting:-mn("3"), Typesetting:-mo("⋅"), Typesetting:-mfenced(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("⋅"), Typesetting:-mi("x")), Typesetting:-_Hold([`%*`(2, x)])))), Typesetting:-_Hold([`%*`(2, 3, `%*`(2, x))])), Typesetting:-mo("+"), Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mn("3")), Typesetting:-mn("2"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(3, 2)]))), Typesetting:-_Hold([`%+`(`%^`(`%*`(2, x), 2), `%*`(-2, 3, `%*`(2, x)), `%^`(3, 2))])))

r2 := eval(p,L);

4*x^2-12*x+9

mrow(Typeset(EV(r1)),mo("="),Typeset(EV(r2)));

`%^`(`%+`(2*x, -3), 2) = `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, 3, `%*`(2, x)), `%^`(3, 2)) and `%+`(`%^`(`%*`(2, x), 2), `%*`(-2, 3, `%*`(2, x)), `%^`(3, 2)) = 4*x^2-12*x+9

Download inert_ex3.mw

@tim_finks It was unclear, because your Question here had it as the opposite:

   solve(f=ma,a)

with neither a space nor a multiplication symbol.

Did you enter it as a multiplication, ie. either explicitly as m*a, or implicitly as m space a?

If you entered it as just ma then that's a two-letter name, not a product of two names.

@minhthien2016 You can show the first such equation by,

   Display(temp[1], inert=false) =~ value(temp[1]);

and similarly for the 2nd and 3rd.

You can get all three such equations more directly, in a list, by,

   Display~(temp, inert=false) =~ value(temp);

 

nb. I made a slight ajustment to the original, to utilize Display~ in that elementwise manner, so that its result is still a list.

@Carl Love That multithreaded variant acts in-place on separate portions of the input Array E, which I believe is why there's little-to-no addtional memory usage overhead.

I added option threadsafe to EasterC_Mpl, so that its compiled result EasterC could run in parallel tasks, ie. so its external call was non-blocking. (See ?Compiler) That'd be needed for other kinds of Threads approaches.

I like splitting the tasks with my own routine, so that I can try and tweak the split. Sometimes using numcpus itself seems not quite optimal. Maybe there are also cache effects...

I only mentioned the bookkeeping because I made a slight adjustment to EasterC_Mpl's loop (k from BEGIN to END), and I'd had just the one coffee. That seemed simpler than fiddling with the Array indexing. It seemed reasonably straightforward because EasterC_Mpl already had the useful BEGIN & END parameters.

Your code assigns a procedure to F, so your attempt like invlaplace(F, p, t) doesn't make too much sense.

Did you perhaps intend invlaplace(F(X, Y, p), p, t) instead?

(I mean, after fixing the weird 2D Input issues with the arguments. Try it in 1D Input.)

First 64 65 66 67 68 69 70 Last Page 66 of 591