sursumCorda

1194 Reputation

15 Badges

2 years, 115 days

MaplePrimes Activity


These are questions asked by sursumCorda

For instance, here is a list of valid "rules" (given as equations): 

(* restart; *)
rules := [g = d, e = a, a = b, f = d, c = g, b = b, d = c, c = f, a = e]:

But these rules can be represented more compactly as a list of "cycles": 

cycles := [[g, d, c], [e, a], [f, d, c], [b]]:

Is there a efficient way to convert into ? 

Let a, b be arbitrary real parameters. I intend to compute something like: (with exact piecewise output) 

Optimization:-Maximize(8*x + 7*y, {5*y <= 6 - 9*b, -6*x - 4*y <= 8 - 5*a - 7*b, -4*x + 7*y <= -1 - 2*a - 7*b, -x + y <= 6 + 4*a - 5*b, 7*x + 5*y <= a + 4*b}, variables = {x, y}): # Error
Optimization:-Minimize((x - 1)^2 + (2*y - 1)^2, {x - 2*y <= 2*a - b + 1, x + 2*y <= a + b, 2*x - y <= a - b + 1}, variables = {x, y}): # Error

Unfortunately, these Maple codes are virtually invalid, and the relevant commands minimize, maximize, extrema, and Student[MultivariateCalculus][LagrangeMultipliers] do not support general inequality constraints. Is it possible to tackle these small-scale constrained parametric problems in Maple?

For instance, I'd like to find the integer solutions of the following system (unknowns: k[1], k[2], k[3], k[4], k[5], and k[6]): 

eqs:=eval~(k[1]*x^3+k[2]*x^2*y+k[5]*x^2*z+k[3]*x*y^2+k[6]*x*y*z+k[8]*x*z^2+k[4]*y^3+k[7]*y^2*z+k[9]*y*z^2+k[10]*z^3,{{x=1,y=1,z=1},{x=RootOf(_Z^3-4*_Z^2+_Z+1,index=1),y=RootOf(_Z^3-4*_Z^2+_Z+1,index=2),z=RootOf(_Z^3-4*_Z^2+_Z+1,index=3)},{x=RootOf(_Z^3-4*_Z^2+_Z+1,index=2),y=RootOf(_Z^3-4*_Z^2+_Z+1,index=3),z=RootOf(_Z^3-4*_Z^2+_Z+1,index=1)},{x=RootOf(_Z^3-4*_Z^2+_Z+1,index=3),y=RootOf(_Z^3-4*_Z^2+_Z+1,index=1),z=RootOf(_Z^3-4*_Z^2+_Z+1,index=2)}}):
{isolve}(eqs=~0);

It seems that the isolve command cannot solve such a system of linear equations, but its integer solutions do exist: 

sol := [k[1] = _Z1, k[2] = _Z2, k[3] = _Z3, k[4] = _Z4, k[5] = _Z5, k[6] = _Z1 + 2*_Z3 + 2*_Z4 + _Z5 + 3*_Z6, k[7] = 2*_Z1 + _Z3 + 8*_Z4 - _Z6, k[8] = -21*_Z1 + 2*_Z2 - _Z4 - 4*_Z5 + _Z6, k[9] = 24*_Z1 - 4*_Z2 - 5*_Z3 - 12*_Z4 + 3*_Z5 - 4*_Z6, k[10] = -7*_Z1 + _Z2 + _Z3 + 2*_Z4 - _Z5 + _Z6]: (*results from Mathematica*)
evala(subs(sol, eqs));
 = 
                              {0}

Here _Z1, _Z2, _Z3, _Z4, _Z5, and _Z6 are integer parameters. However, how do I get this result in Maple?

[I split this off from here into a separate question. dharr]

@dharr Thanks. For the second one, an output is . Is it possible to compel Maple to attempt to simplify the second algebraic number to a less complicated expression automatically? 
Its minimal polynomial can be computed. However, this is not so convenient for the specific purpose. Actually, I want something like this: 

evalA(-4*RootOf(_Z^3 - 3*_Z^2 - 10*_Z - 1)^2 + 19*RootOf(_Z^3 - 3*_Z^2 - 10*_Z - 1) + 3);
 = 
                       /  3        2           \
               5 RootOf\_Z  + 10 _Z  + 3 _Z - 1/

Mathematica has an additional function RootReduce to do so directly, but I cannot find such functionality in Maple.

Remark. A fairly complicated one: 

evalA(-45658*RootOf(37*_Z^6 - 382*_Z^5 + 1388*_Z^4 - 2188*_Z^3 + 1475*_Z^2 - 406*_Z + 37, index = 6)^5 + 417257*RootOf(37*_Z^6 - 382*_Z^5 + 1388*_Z^4 - 2188*_Z^3 + 1475*_Z^2 - 406*_Z + 37, index = 6)^4 - 1252087*RootOf(37*_Z^6 - 382*_Z^5 + 1388*_Z^4 - 2188*_Z^3 + 1475*_Z^2 - 406*_Z + 37, index = 6)^3 + 1463384*RootOf(37*_Z^6 - 382*_Z^5 + 1388*_Z^4 - 2188*_Z^3 + 1475*_Z^2 - 406*_Z + 37, index = 6)^2 - 558475*RootOf(37*_Z^6 - 382*_Z^5 + 1388*_Z^4 - 2188*_Z^3 + 1475*_Z^2 - 406*_Z + 37, index = 6) + 69230);
 = 
            /
17991 RootOf\

       6         5          4          3          2                
  37 _Z  - 406 _Z  + 1475 _Z  - 2188 _Z  + 1388 _Z  - 382 _Z + 37, 

           \
  index = 4/


 

The help page solve/details claims that solve(x^2-1,{x}, useassumptions) assuming x>0; is equivalent to solve({x^2-1, x>0},{x});. But the following example perplexes me again.

Considering a multi-variable polynomial: 

expr := 36*a^3*b^3+8*a^2*b^2*(9*(a+b+1)^2+4*(a*b+a+b))*(a+b+1)+((a-b)^2-2*(a+b)+1)^2*(a+b+1)^5+a*b*((a-b)^2-2*(a+b)+1)*(17*(a+b+1)^2+4*(a*b+a+b))*(a+b+1)^2: # assuming nonnegative

I intend to find the nonnegative real roots of it. 

solve({expr = 0, (a, b) >= ~ 0}, [a, b], allsolutions);
solve(expr = 0., [a, b], useassumptions, allsolutions) assuming (a, b) >= ~ 0;
solve({expr = 0., (a, b) >= ~ 0}, [a, b], allsolutions);

all return six solutions, but curiously, 

solve(expr = 0, [a, b], useassumptions, allsolutions) assuming (a, b) >= ~ 0;

only returns four solutions. Why???

In addition, as you can see, the first output (i.e., sol1) is thoroughly less meaningful. Can't it be more readable?? 
 

restart;

expr := 36*a^3*b^3+8*a^2*b^2*(9*(a+b+1)^2+4*(a*b+a+b))*(a+b+1)+((a-b)^2-2*(a+b)+1)^2*(a+b+1)^5+a*b*((a-b)^2-2*(a+b)+1)*(17*(a+b+1)^2+4*(a*b+a+b))*(a+b+1)^2

sol1 := solve({`~`[`>=`](a, b, ` $`, 0), expr = 0}, [a, b], allsolutions) =
[[a = 0, b = 1], [a = 3^(1/2)-1, b = RootOf((-741235976922591048947725497133370413109846163676281959390560108171291511786260537194814187602376638467882392432305864*3^(1/2)+1283858372427879519277780718816094877088966867890478064541174875107114975191197490158346515516574907111238006510832897)*_Z^8+(542622395505288470330055221682724463979120704214196105150614766935823463404936952963532327914198268643355614078527033*3^(1/2)-939849558339893627565395772584016362240571623138367813630505449406759560167584121426096047290555008292409170786084695)*_Z^7+(27663303262730616171732317130828357033086591952430419833222950914496979987637185645479748907213281840470027913754446250*3^(1/2)-47914246756235321853987379290323009935074722268098020072540300747281044857411765919011355938402797296261231903185833860)*_Z^6+(-36848925451143075385294452437991667121840085487125852139251120381482252862356891660819456375517484560073220737684055360*3^(1/2)+63824211085697719773601999676355867125229886950052051470652732444578522019946850568834704346278726602905590979989005206)*_Z^5+(-361541600067355242269699717707379679953498397064818094940691654358197984962782803819129269994590941790029033835785321091*3^(1/2)+626208420366406708672813369852190896907780666621957659007533759258885959287096424079349105562785060297582745252447270847)*_Z^4+(469917886838763314544262854134623783463102170709338866937842556434901449696233730989733509809486602395675273592523379039*3^(1/2)-813921655390140293483357785790922432834508040979560342164969934794994487106266639300148834412459020073129881509269947685)*_Z^3+(2419091701164731099042357448446421888413075728672522494523180828886450053865285232431099171783692236478370266582727759022*3^(1/2)-4189989734585541679787610388006771626857619186946433018568920261866881451820006582050966407487366628715776067639375659568)*_Z^2+(-276526595929812923186277260098945143564039808175960075417091066631428638512893788855336862569832144723039829695578843580*3^(1/2)+478958113794505090444730274771005660986137994458744274847200001817421835204311147220572248669252963586284164359082018778)*_Z-2241557156236496486338463519192106892320755475146925672942972549523504139162741341146795559700763371271548957041603585449*3^(1/2)+3882490882671219790342097523842232566093205006918585285230133334462570311857306952032638288791685675699575851624588398080, index = real[4])], [a = 1, b = 0], [a = 1, b = 3^(1/2)-1], [a = 1, b = 1], [a = 1/2+(1/2)*3^(1/2), b = RootOf((3265859930834838622581170032695923790177759993209560990735389424723672715638564736*3^(1/2)+5656635330609319983539361351500545583607599001912359529744925502462343818424446992)*_Z^8+(12188355192278997228701701416892393163963118988331481511215704351909689249701576464*3^(1/2)+21110850453723155834822232801088862537748477983453402031696019279095705783764588192)*_Z^7+(-16329299654174193112905850163479618950888799966047804953676947123618363578192823680*3^(1/2)-28283176653046599917696806757502727918037995009561797648724627512311719092122234960)*_Z^6+(-47558033069228748234327710008167261759137556448974526775358049368769421447413364728*3^(1/2)-82372929583945025397186856831061837257531071444955446405553455730528485970812729160)*_Z^5+(71016746435016238932635448066739883738739336153617153345258159361269798232579788444*3^(1/2)+123004613013684064253013423478212462789515684702771043974383244940692061281906669908)*_Z^4+(-539074301591972734261861623983834399153978765971327430710378028630584341753429268*3^(1/2)-933704079412004867600664919608623045951401970711134655767859337789085046795723776)*_Z^3+(-8660811640968922793242100644402781523021841461481655906743406226105766029465794376*3^(1/2)-15000965796942156111966381948246207258139974790596863072851606476670777826354805396)*_Z^2+(-30769734905669303241874027457081560634086527346916553595415452889491557012102176442*3^(1/2)-53294744192044789072581100596045559567736905080848045509547703544202848750472876382)*_Z-3181857373467742490740890760219056890779274438575702235481520595135068397863751433*3^(1/2)-5511138633283790175605724430174371395924969988541134171865969654221197707640077992, index = real[4])]]
NULL

sol2 := `assuming`([solve(expr = 0., [a, b], useassumptions, allsolutions)], [`~`[`>=`](a, b, ` $`, 0)]) =
[[a = 0., b = 1.], [a = .7320508076, b = 1.000000000], [a = 1., b = 0.], [a = 1., b = .7320508076], [a = 1., b = 1.], [a = 1.366025404, b = 1.366025404]]
NULL

sol3 := solve({`~`[`>=`](a, b, ` $`, 0), expr = 0.}, [a, b], allsolutions) =
[[a = 0., b = 1.], [a = .7320508076, b = 1.000000000], [a = 1., b = 0.], [a = 1., b = .7320508076], [a = 1., b = 1.], [a = 1.366025404, b = 1.366025404]]
NULL

sol4 := `assuming`([solve(expr = 0, [a, b], useassumptions, allsolutions)], [`~`[`>=`](a, b, ` $`, 0)]) = [[a = 0, b = 1], [a = 1, b = 0], [a = 1, b = 3^(1/2)-1], [a = 1, b = 1]]NULL

_SolutionsMayBeLost;

_SolutionsMayBeLost

(1)

numelems(sol1), numelems(sol2), numelems(sol3), numelems(sol4) = 6, 6, 6, 4NULL

sol5 := [[a = 0, b = 1], [a = sqrt(3)-1, b = 1], [a = 1, b = 0], [a = 1, b = sqrt(3)-1], [a = 1, b = 1], [a = (sqrt(3)+1)*(1/2), b = (sqrt(3)+1)*(1/2)]]

Why did't solve({`~`[`>=`](a, b, ` $`, 0), expr = 0}, [a, b]) return sol5?

map2(evala@eval, expr, sol5);

[0, 0, 0, 0, 0, 0]

(2)

Error, (in type/algext) too many levels of recursion


 

Download solve_details.mw

First 18 19 20 21 22 23 Page 20 of 23