Maple 2022 Questions and Posts

These are Posts and Questions associated with the product, Maple 2022

I was looking for rewriting some expression in simpler forms and ened up getting wrong values from maple

Is something wrong on how I'm using it or is this a bug ?

This is the code with the output:

> NumericStatus(invalid_operation=false):
> simplify(sum(
>         (A-B)
>         *(-1+combinat:-binomial(N-2,i))
>         *(A)^(i)
>         *(B)^(N-2-i)
>     ,i=0..N-2));
                                                    (N - 1)    (N - 1)
                                                   B        - A



> NumericStatus(invalid_operation);
                                                          false

 

This is the wrong answer, is missing the part with the binomial, somehow its set to zero but the NumericStatus is still telling that everythig is fine.
It has not issues when one replaces the N-2 with N,

> simplify(sum(
>         (A-B)
>         *(-1+combinat:-binomial(N,i))
>         *(A)^(i)
>         *(B)^(N-i)
>     ,i=0..N));
                                          (N + 1)    (N + 1)                  N
                                         B        - A        + (A - B) (A + B)

> NumericStatus(invalid_operation);
                                                          false

 

If I drop the (-1) in front I get the right contribution from the binomial regardless of using N or N-2

> simplify(sum(
>         (A-B)
>         *(combinat:-binomial(N-2,i))
>         *(A)^(i)
>         *(B)^(N-2-i)
>     ,i=0..N-2));
                                                   /A + B\N          N
                                                   |-----|  (A - B) B
                                                   \  B  /
                                                   -------------------
                                                               2
                                                        (A + B)

> NumericStatus(invalid_operation);
                                                          false

which is equal to (A+B)^(N-2)*(A-B)

If I use assume(N>2) it still gives the same result but this time is flagged ad an invalid operation (which is not supposed to).
Interesting enough also if I set assume(N>0) in the second example gives me invalid_operation=true but return the correct result.

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?

I run the following command.

$ maple2022/bin/maple -q problem.mpl

where problem.mpl is the following:

with(Student[Calculus1]):
ShowSolution(Diff(ln(x),x));

I get the following output.

Differentiation Steps
    Diff(ln(x),x)
▫    1. Apply the natural logarithm rule
        ◦ Recall the definition of the natural logarithm rule
        Diff(ln(x),x) = x^(-1)
    This gives:
    x^(-1)

I want the solver to use 1/x instead of x^(-1) in the output. How can I achieve this?

P.S. I require the output to be parsable, so using output=print to show fractions in a multi-line fashion is not a solution for me.

Hi! 

I've been working on a file in Maple, and saved it yesterday - but now I am not able to open it, as it is corrupted. I have been able to find the back up file, HOWEVER I am not able to load half of the file as Maple comes up with a "there was a problem loading your file....". Is there anything I can do to repair the back up file? 

Any help is greatly appreciated!

Back up file is here: C_Users_jonas_OneDrive_Skrivebord_Mat_B-A_Hjemmeopgavesæt_Opgavesæt_1115_MAS_-_Kopi.mw

I'm having trouble performing a direct operation, involving DotProduct, in the piecewise function. Attached is a document. I appreciate any contribution.

Regards,

Oliveira

Example2.mw

Hi,

I am new to Maple and I couldn't really find anything about this problem. Why doesn't Maple automatically simplify the last expression in the following? (see for example the first and last terms, as well as other terms)

total := (((((D^2/(alpha^2*mu^2) + D^2*exp(2*(-t + t1)*alpha*mu)/(alpha^2*mu^2)) + D^2*exp(2*(-t + t1)*alpha*mu)/(alpha^2*mu^2)) + D1*D/((alpha*mu*tau0 + 1)*alpha^2*mu^2) - (-alpha*mu*tau0*exp((-t + t1)*(alpha*mu*tau0 + 1)/tau0) + exp(2*(-t + t1)*alpha*mu))*D*D1/(mu^2*alpha^2*(alpha^2*mu^2*tau0^2 - 1)) + (alpha*mu*tau0*exp((-t + t1)*(alpha*mu*tau0 + 1)/tau0) - exp(2*(-t + t1)*alpha*mu))*D1*D/(alpha^2*mu^2*(alpha^2*mu^2*tau0^2 - 1))) - (-alpha*mu*tau0*exp((-t + t1)*(alpha*mu*tau0 + 1)/tau0) + exp(2*(-t + t1)*alpha*mu))*D*D1/(mu^2*alpha^2*(alpha^2*mu^2*tau0^2 - 1))) + (alpha*mu*tau0*exp((-t + t1)*(alpha*mu*tau0 + 1)/tau0) - exp(2*(-t + t1)*alpha*mu))*D1*D/(alpha^2*mu^2*(alpha^2*mu^2*tau0^2 - 1)) + D1*D/((alpha*mu*tau0 + 1)*alpha^2*mu^2) + D1^2/((alpha*mu*tau0 + 1)^2*alpha^2*mu^2) - (alpha*mu*tau0*exp(-(-t + t1)*(alpha*mu*tau0 - 1)/tau0) + alpha*mu*tau0*exp((-t + t1)*(alpha*mu*tau0 - 1)/tau0) - alpha^2*mu^2*tau0^2 - 1)*D1^2/(alpha^2*mu^2*(alpha^4*mu^4*tau0^4 - 2*alpha^2*mu^2*tau0^2 + 1))) - (alpha*mu*tau0*exp(-(-t + t1)*(alpha*mu*tau0 - 1)/tau0) + alpha*mu*tau0*exp((-t + t1)*(alpha*mu*tau0 - 1)/tau0) - alpha^2*mu^2*tau0^2 - 1)*D1^2/(alpha^2*mu^2*(alpha^4*mu^4*tau0^4 - 2*alpha^2*mu^2*tau0^2 + 1))

D1^2/((alpha*mu*tau0 + 1)^2*alpha^2*mu^2) + 2*D1*D/((alpha*mu*tau0 + 1)*alpha^2*mu^2) + D^2/(alpha^2*mu^2)

r2r2 := %;
 

total - r2r2;

((((((D^2/(alpha^2*mu^2) + D^2*exp(2*(-t + t1)*alpha*mu)/(alpha^2*mu^2)) + D^2*exp(2*(-t + t1)*alpha*mu)/(alpha^2*mu^2)) + D1*D/((alpha*mu*tau0 + 1)*alpha^2*mu^2) - (-alpha*mu*tau0*exp((-t + t1)*(alpha*mu*tau0 + 1)/tau0) + exp(2*(-t + t1)*alpha*mu))*D*D1/(mu^2*alpha^2*(alpha^2*mu^2*tau0^2 - 1)) + (alpha*mu*tau0*exp((-t + t1)*(alpha*mu*tau0 + 1)/tau0) - exp(2*(-t + t1)*alpha*mu))*D1*D/(alpha^2*mu^2*(alpha^2*mu^2*tau0^2 - 1))) - (-alpha*mu*tau0*exp((-t + t1)*(alpha*mu*tau0 + 1)/tau0) + exp(2*(-t + t1)*alpha*mu))*D*D1/(mu^2*alpha^2*(alpha^2*mu^2*tau0^2 - 1))) + (alpha*mu*tau0*exp((-t + t1)*(alpha*mu*tau0 + 1)/tau0) - exp(2*(-t + t1)*alpha*mu))*D1*D/(alpha^2*mu^2*(alpha^2*mu^2*tau0^2 - 1)) + D1*D/((alpha*mu*tau0 + 1)*alpha^2*mu^2) + D1^2/((alpha*mu*tau0 + 1)^2*alpha^2*mu^2) - (alpha*mu*tau0*exp(-(-t + t1)*(alpha*mu*tau0 - 1)/tau0) + alpha*mu*tau0*exp((-t + t1)*(alpha*mu*tau0 - 1)/tau0) - alpha^2*mu^2*tau0^2 - 1)*D1^2/(alpha^2*mu^2*(alpha^4*mu^4*tau0^4 - 2*alpha^2*mu^2*tau0^2 + 1))) - (alpha*mu*tau0*exp(-(-t + t1)*(alpha*mu*tau0 - 1)/tau0) + alpha*mu*tau0*exp((-t + t1)*(alpha*mu*tau0 - 1)/tau0) - alpha^2*mu^2*tau0^2 - 1)*D1^2/(alpha^2*mu^2*(alpha^4*mu^4*tau0^4 - 2*alpha^2*mu^2*tau0^2 + 1))) - D1^2/((alpha*mu*tau0 + 1)^2*alpha^2*mu^2) - 2*D1*D/((alpha*mu*tau0 + 1)*alpha^2*mu^2) - D^2/(alpha^2*mu^2)
couldnt insert "r2r2" properly...

I am converting some code from Mathematica. In it there is this solution

eqs={2c2+c0==1,6c3+2c1==2,3c2+12c4==1};
FindInstance[eqs,{c0,c1,c2,c3,c4}]

Which gives

{{c0 -> 0, c1 -> 0, c2 -> 1/2, c3 -> 1/3, c4 -> -(1/24)}}

Maple's solve gives

eqs := [2*c2 + c0 = 1, 6*c3 + 2*c1 = 2, 3*c2 + 12*c4 = 1];
sol:=solve(eqs, {c0, c1, c2, c3, c4})

Gives

sol := {c0 = 1/3 + 8*c4, c1 = -3*c3 + 1, c2 = 1/3 - 4*c4, c3 = c3, c4 = c4}

I know that both are correct solutions. But I'am asking if there is a command or an option I overlooked that will generate the same result as the above from FindInstance, which will make it easier for me.

May be there is another solver package or command I could try?

I am not sure what algorithm FindInstance uses. The documentation page does not say.

I am trying to understand the SymmetryGroup returned in the Logic Package. The help page says "The group is a permutation group; its elements are those permutations which preserve the Boolean structure of expr." [my bold], but later the definition is given as "A symmetry of a Boolean expression expr is a mapping f of each variable to some other variable or negated variable, such that the image of expr after applying f to each of its variables is a Boolean formula which is equivalent to expr." Is logically equivalent meant here, or something else? The help page examples don't answer this question.

The following example shows that a group permutation does not lead to a logically equivalent statement as I was expecting - is this a bug, or am I expecting too much here?

restart

with(Logic)

q := `&and`(`&or`(x[1], x[2]), x[3])

Logic:-`&and`(Logic:-`&or`(x[1], x[2]), x[3])

G, L := SymmetryGroup(q, output = [group, expressions]); g1, g2 := Generators(G)[]

_m1897409254784, [x[1], x[2], x[3], Logic:-`&not`(x[1]), Logic:-`&not`(x[2]), Logic:-`&not`(x[3])]

_m1897409280096, _m1897409281184

Exchanging x[1] with x[2], and (not x[1]) with (not x[2]) leads to a logically equivalent expression, so this is indeed a symmetry.

zip(`=`, L, L[convert(g1, permlist, nops(L))]); q1 := eval(q, %); Equivalent(q, q1)

[x[1] = x[2], x[2] = x[1], x[3] = x[3], Logic:-`&not`(x[1]) = Logic:-`&not`(x[2]), Logic:-`&not`(x[2]) = Logic:-`&not`(x[1]), Logic:-`&not`(x[3]) = Logic:-`&not`(x[3])]

Logic:-`&and`(Logic:-`&or`(x[2], x[1]), x[3])

true

Exchanging x[3] with (not x[3]) leads to an expression that perhaps has the same form but is not equivalent

zip(`=`, L, L[convert(g2, permlist, nops(L))]); q2 := eval(q, %); Equivalent(q, q2)

[x[1] = x[1], x[2] = x[2], x[3] = Logic:-`&not`(x[3]), Logic:-`&not`(x[1]) = Logic:-`&not`(x[1]), Logic:-`&not`(x[2]) = Logic:-`&not`(x[2]), Logic:-`&not`(x[3]) = x[3]]

Logic:-`&and`(Logic:-`&or`(x[1], x[2]), Logic:-`&not`(x[3]))

false

NULL

Download LogicTest.mw

dear all:

    here I try to repeat the results as follows:

 (23) is my target

my 2 solving processes are included in the attachment.

using LinearSolve(A, b) and regular solve command can not generate results as (23)

Please take a look.

question_DHT.mw

thanks for your help.

best regards

Hi,

I would like to plot this function from x= 2pi to 4pi.  I entered this into the plotting command, and nothing happened.  How do I plot this from 2pi to 4pi?

plot_from_two_pi_to_4_pi.mw

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

I have only seen big O show up in series solutions, as in 

series(sin(x),x)

I've never seen it before show up in result of solve

restart;
eq:=x=p*(a*ln(p+sqrt(p^2-2))+2*_C1)/(2*sqrt(p^2-2));
sol:=solve(eq,p);

What does it actually mean when the solution has  O(RootOf(....))?  

Should not result of solve be exact? isn't having big O means an approximation?

Maple 2022.2 on windows 10

So for my project, I need to be able to do this integral for different values of "l". Here is the integral I need to evaluate:

Where "R", "Xi", and "l" are all constant. When I try to do it, it gives back an imaginary number. The absolute value of this imaginary number seems to be correct but I'm not sure why it's imaginary. This is a plot of what it should give for various values of "l":

Here is my maple code copy-pasted from the application (I'm new to Maple and this forum and cannot figure out how to attach the file version of my code sorry):

Digits := 30;
E := 3.83*10^14;
                                            14
                  E := 3.8300000000000000 10  

R := 0.1*E;
                                            13
                  R := 3.8300000000000000 10  

l := 0.01*R;
                                            11
                  l := 3.8300000000000000 10  

A := int((-4*E^2 + r^2)^(1/2)*(R^2 - l^2 + r^2)/((R^2 - (l - r)^2)^(1/2)*((l + r)^2 - R^2)^(1/2)), r = abs(l - R) .. l + R)/(Pi*R^2);
             A := 19.9744824651978825998722703010 I

Max := (1 + 4*(E/R)^2)^(1/2);
             Max := 20.0249843945007857276972121483

NULL;

Here is the code when I exported as maple input:

NULL;
Digits := 30;
E := 3.83*10^14;
R := 0.1*E;
l := 0.01*R;
A := int((-4*E^2 + r^2)^(1/2)*(R^2 - l^2 + r^2)/((R^2 - (l - r)^2)^(1/2)*((l + r)^2 - R^2)^(1/2)), r = abs(l - R) .. l + R)/(Pi*R^2);
Max := (1 + 4*(E/R)^2)^(1/2);
NULL;

Thank you in advance!

First 17 18 19 20 21 22 23 Last Page 19 of 43