Maple 2023 Questions and Posts

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

According to the documentation of MmaTranslator:-Mma:-PolynomialReduce, this command yields . However, 

restart;
MmaTranslator:-Mma:-PolynomialReduce(x**2+y**2,{x-y,y+a});
 = 
                       [         2    2]
                       [[0, 0], x  + y ]

In[1]:= PolynomialReduce[x^2+y^2,{x-y,y+a}](*Mathematica*)

Out[1]= {{x + y, -2 a + 2 y}, 2 a^2}

In SymPy and in MuPAD: 

The output of both is the same as that of Mma; only the result given by Maple is inconsistent with Mathematica's. 

The example above is so simple that the desired result can be found simply by hand. Here is a larger example: 
Given two polynomials .txt and .txt, as well as a list of polynomials .txt, I would like to evaluate 

# Suppose that one has downloaded these three files. 
poly1, poly2 := fscanf("poly1.txt", "%a")[], fscanf("poly2.txt", "%a")[]:
pList := MmaTranslator:-Mma:-ReadList("pList.txt"):
MmaTranslator:-Mma:-PolynomialReduce((a - poly1)*(a - poly2), pList);

 But its result is just “[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ]”, while when a=0 it should be “[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 1, 1, 1, 1, 0, 0, 0, 1, 2, 1, 0, 2, 2, 3, 1, 1, 1, 2, 1, 0, 0, 0, 1, 1, 2, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0], 0]”.
So why does  return a distinct value?

How would I solve for the product of two terms ( s*V or s^2*V). This is a simple example but I would be applying this on much higher order equations.

     V = Vx/(a*s^2 + b*s + c)

Hi:

I am using solve(...,allsolutions)

and Maple is giving me the default "_Z1~" as part of the solution. No problem.

But when I go back and run the same statement again without a restart, it gives me "_Z2~" and my program fails because it is looking to substitute a value for "_Z1".

How do I reset the naming convention without restarting so I can get the same output each time I run the same statement. (BTW: The same thing happens with Veil where it increments the indices of the Veil symbol each time you run the same statement)..

Thank you.

I am really confused by this behavior. Should the solution be different when calling dsolve(ode) vs. dsolve(ode,[x(t),y(t)]) where here ode is list of two coupled first order ode's?

Maple shows the solutions in reverse order in one case vs. the other. I do not see why adding [x(t),y(t)] should make x(t) solution now y(t)'s and y(t) solution now x(t)'s.  Here is an example

Here is worksheet. I just find the out changing very confusing. Should not the same solution for x(t) and y(t) remain the same regardless of adding the second option as list of not? What is the logic behaind this change or order, and how it one to know which is the correct one as they look different.

``

interface(version);

`Standard Worksheet Interface, Maple 2023.2, Windows 10, October 25 2023 Build ID 1753458`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1592 and is the same as the version installed in this computer, created 2023, November 27, 3:41 hours Pacific Time.`

restart;

20440

ode :=[diff(x(t), t) = (3*x(t))/2 + 2*y(t), diff(y(t), t) = x(t)/2 + y(t)]

[diff(x(t), t) = (3/2)*x(t)+2*y(t), diff(y(t), t) = (1/2)*x(t)+y(t)]

simplify(dsolve(ode,[x(t),y(t)]));

{x(t) = -(1/2)*c__2*(17^(1/2)-1)*exp(-(1/4)*(-5+17^(1/2))*t)+(1/2)*c__1*exp((1/4)*(5+17^(1/2))*t)*(17^(1/2)+1), y(t) = c__1*exp((1/4)*(5+17^(1/2))*t)+c__2*exp(-(1/4)*(-5+17^(1/2))*t)}

simplify(dsolve(ode));

{x(t) = c__1*exp((1/4)*(5+17^(1/2))*t)+c__2*exp(-(1/4)*(-5+17^(1/2))*t), y(t) = -(1/8)*c__2*(17^(1/2)+1)*exp(-(1/4)*(-5+17^(1/2))*t)+(1/8)*c__1*exp((1/4)*(5+17^(1/2))*t)*(17^(1/2)-1)}

#when using SET instead of LIST, then same solutions come out as above
simplify(dsolve(ode,{x(t),y(t)}));

{x(t) = c__1*exp((1/4)*(5+17^(1/2))*t)+c__2*exp(-(1/4)*(-5+17^(1/2))*t), y(t) = -(1/8)*c__2*(17^(1/2)+1)*exp(-(1/4)*(-5+17^(1/2))*t)+(1/8)*c__1*exp((1/4)*(5+17^(1/2))*t)*(17^(1/2)-1)}

 

Download why_solution_changes_nov_27_2023.mw

I want to creat an interactive document for students. When user clicks in a coordinate-system a point shall come up. For this I need the relative (or absolute) coordinates of the actual mouse position. I cannot find the command for this. In other languages it is like getmousex, getmousey. Can anyone help, please?

As a part of my learning curve, I am trying to play with extending Maple's BernsteinBasis, which has only a limited support right now (BernsteinBasis - Maple Help (maplesoft.com)).

My goal is to implement basis operation on polynomials in Bernstein basis, so that derivatives, integrals and products of polynomials in  BernsteinBasis would be again expressed in BernsteinBasis.

While it looks like it is relatively easy to extend diff procedure, by using `diff/BernsteinBasis`, I didn't find anything similar for the int. Is there something like `int/BernsteinBasis`?

The problem is that when I am trying to implement my own int procedure in a module that  would extend standard int, it seems I need to manually implement logic for (at very least) linearity, so that int(p(x) + q(x), x) would decay into int(p(x), x) + int(q(x), x ) (I probably don't need more complex rewriting rules). So before trying this approach, is there any easy way such as with diff?
 

restart;

read("C:\\Users\\Igor\\Maple\\BernsteinPolynomials.mpl");

_m2141342686560

(1)

# General formula
diff(BernsteinBasis(k, n, a, b, x), x);

n*BernsteinBasis(k-1, n-1, a, b, x)/(b-a)-n*BernsteinBasis(k, n-1, a, b, x)/(b-a)

(2)

# In expressions
diff(2*x*BernsteinBasis(1, 2, 0, 1, x) + BernsteinBasis(2, 2, 0, 1, x), x);

2*BernsteinBasis(1, 2, 0, 1, x)+2*x*(2*BernsteinBasis(0, 1, 0, 1, x)-2*BernsteinBasis(1, 1, 0, 1, x))+2*BernsteinBasis(1, 1, 0, 1, x)

(3)

# Convertion to MatrixPolynomialObject works
p := diff(BernsteinBasis(1, 2, 0, 1, x) + BernsteinBasis(2, 2, 0, 1, x), x);
P := convert(p, MatrixPolynomialObject, x);
P:-Value(a);

p := 2*BernsteinBasis(0, 1, 0, 1, x)

 

P := Record(Value = Default[value], Variable = x, Degree = 1, Coefficient = coe, Dimension = [1, 1], Basis = BernsteinBasis, BasisParameters = [1, 0, 1], IsMonic = mon, OutputOptions = [shape = [], storage = rectangular, order = Fortran_order, fill = 0, attributes = []])

 

Matrix(%id = 36893490288797933188)

(4)

# Now, integrataion
with(BernsteinPolynomials);

[int]

(5)

# Still works
int(x^2, x);

(1/3)*x^3

(6)

# Not implemented but will be added later...
int(BernsteinBasis(1, 2, 0, 1, x), x);

"Will be implemented here..."

 

int(BernsteinBasis(1, 2, 0, 1, x), x)

(7)

# This is the problem: how to implement basis properties such as linearity?
int(2 * BernsteinBasis(1, 2, 0, 1, x), x);

int(2*BernsteinBasis(1, 2, 0, 1, x), x)

(8)

 

 

BernsteinPolynomials := module()
    description "Basic operations in Bernstein basis";
	option package;
	global BernsteinBasis, `diff/BernsteinBasis`;
	export int;

	BernsteinBasis := proc(k, n, a, b, x)
		description "Bernstein basis polynomial";
		if k::numeric then
			if k < 0 then 
				return 0;
			end if
		end if;
		if n::numeric then
			if n < 0 then 
				return 0; 
			end if;
			if k::numeric then
				if k > n then
					return 0;
				end if;
			end if;
		end if;
		'procname'(_passed)
	end proc;

	`diff/BernsteinBasis` := proc()
		description "Derivative of the Bernstein basis polynomial in the Bernstein basis";
		if _npassed = 6 then
			if _passed[-1] = _passed[-2] then
				_passed[2] * BernsteinBasis(_passed[1] - 1, _passed[2] - 1, _passed[3], _passed[4], _passed[5]) / (_passed[4] - _passed[3]) -
				_passed[2] * BernsteinBasis(_passed[1], _passed[2] - 1, _passed[3], _passed[4], _passed[5]) / (_passed[4] - _passed[3]);
			end if;
		end if;
	end proc;
	
	int := proc()
		description "Integral of the Bernstein basis polynomial in the Bernstein basis";
		if type(_passed[1], 'specfunc'(anything, BernsteinBasis)) then
		    print("Will be implemented here...");
		end if;
		:-int(_passed)
	end proc;

end module;

Download bernstein.mw

In my code, without knowing what the expression is, other than it has RootOf, the code called allvalues and got internal error 

Error, (in SolveTools:-Basis) invalid input: igcd received 5/7, which is not valid for its 2nd argument

Is this to be expected depending on the input, or is this some internal problem I need to report?

restart;
expr:=RootOf(R^4*b+R^2*a*_Z+2*_Z^2-exp(RootOf(tanh(1/2*(a^2-8*b)^(1/2)*(4*S-_Z)/a)^2*R^4*a^2-8*tanh(1/2*(a^2-8*b)^(1/2)*(4*S-_Z)/a)^2*R^4*b-R^4*a^2+8*R^4*b-8*exp(_Z))))

allvalues(expr)

Error, (in SolveTools:-Basis) invalid input: igcd received 5/7, which is not valid for its 2nd argument

Maple 2023.2 on windows 10

ps.  Reported to Maplesoft

In an old question, @mbras asked for a "partial" `convert/elsymfun`. However, SymPy's sympy.polys.rings.PolyElement.symmetrize seems to provide more examples that cannot be handled by the program that appeared in that question.
For instance, 

>>> from sympy import var
>>> var('x:z,p:r')
(x, y, z, p, q, r)
>>> from sympy.polys.polyfuncs import symmetrize
>>> symmetrize(x**2-(y**2+2**z),[y,x],formal=True,symbols=[p+p,q*q])[0]
-2**z - 4*p**2 + 2*q**2
>>> symmetrize(x*x*y+y*y*z+z*z*x,[y,x,z],formal=True,symbols=[p,q,r])
(0, x**2*y + x*z**2 + y**2*z, [(p, x + y + z), (q, x*y + x*z + y*z), (r, x*y*z)])

Though I can , can't the built-in  be generalized to such expressions (in other words, write the polynomial part of input as a symmetric part and a remainder with (named, if need be) elementary symmetric polynomials)?

Besides, since any symmetric polynomial can also be expressed in terms of the complete symmetric polynomials, is there a similar  command in Maple?

I wonder if this a bug or Am I overlooking something?

I set infolevel[dsolve]:=5; and first time calling dsolve(ode), it works as expected. It prints on the screen the trace and steps it did.  But when I repeat the command dsolve, now it only prints one line and the rest of info that were printed before no longer show.

Should not the same information be printed each time? This is what happens on another example I tried. It seems infolevel does not work the same depending on the ode being solved?  Here is a worksheet attached to show the above.

Is there a workaround to make it display same information each time?

Maple 2023.2 on windows 10.

 

restart;

21424

interface(version);

`Standard Worksheet Interface, Maple 2023.2, Windows 10, October 25 2023 Build ID 1753458`

ode:=[2*diff(x(t),t)+diff(y(t),t)=x(t)+y(t)+t,diff(x(t),t)+diff(y(t),t)=2*x(t)+3*y(t)+exp(t)];
infolevel[dsolve]:=5;
dsolve(ode);

[2*(diff(x(t), t))+diff(y(t), t) = x(t)+y(t)+t, diff(x(t), t)+diff(y(t), t) = 2*x(t)+3*y(t)+exp(t)]

5

-> Solving each unknown as a function of the next ones using the order: [y(t), x(t)]

-> Calling odsolve with the ODE diff(diff(y(x) x) x) = 4*(diff(y(x) x))-y(x)-3*x+1 y(x) singsol = none

Methods for second order ODEs:

--- Trying classification methods ---

trying a quadrature

trying high order exact linear fully integrable

trying differential order: 2; linear nonhomogeneous with symmetry [0,1]

trying a double symmetry of the form [xi=0, eta=F(x)]

-> Try solving first the homogeneous part of the ODE

   checking if the LODE has constant coefficients

   <- constant coefficients successful

   -> Determining now a particular solution to the non-homogeneous ODE

      trying a rational particular solution

      <- rational particular solution successful

<- solving first the homogeneous part of the ODE successful

{x(t) = exp((2+3^(1/2))*t)*c__2+exp(-(-2+3^(1/2))*t)*c__1-3*t-11, y(t) = -(1/2)*exp((2+3^(1/2))*t)*c__2*3^(1/2)+(1/2)*exp(-(-2+3^(1/2))*t)*c__1*3^(1/2)-(3/2)*exp((2+3^(1/2))*t)*c__2-(3/2)*exp(-(-2+3^(1/2))*t)*c__1-(1/2)*exp(t)+2*t+7}

dsolve(ode);

-> Solving each unknown as a function of the next ones using the order: [y(t), x(t)]

{x(t) = exp((2+3^(1/2))*t)*c__2+exp(-(-2+3^(1/2))*t)*c__1-3*t-11, y(t) = -(1/2)*exp((2+3^(1/2))*t)*c__2*3^(1/2)+(1/2)*exp(-(-2+3^(1/2))*t)*c__1*3^(1/2)-(3/2)*exp((2+3^(1/2))*t)*c__2-(3/2)*exp(-(-2+3^(1/2))*t)*c__1-(1/2)*exp(t)+2*t+7}

infolevel[dsolve]:=5;

5

dsolve(ode);

-> Solving each unknown as a function of the next ones using the order: [y(t), x(t)]

{x(t) = exp((2+3^(1/2))*t)*c__2+exp(-(-2+3^(1/2))*t)*c__1-3*t-11, y(t) = -(1/2)*exp((2+3^(1/2))*t)*c__2*3^(1/2)+(1/2)*exp(-(-2+3^(1/2))*t)*c__1*3^(1/2)-(3/2)*exp((2+3^(1/2))*t)*c__2-(3/2)*exp(-(-2+3^(1/2))*t)*c__1-(1/2)*exp(t)+2*t+7}

dsolve(ode);

-> Solving each unknown as a function of the next ones using the order: [y(t), x(t)]

{x(t) = exp((2+3^(1/2))*t)*c__2+exp(-(-2+3^(1/2))*t)*c__1-3*t-11, y(t) = -(1/2)*exp((2+3^(1/2))*t)*c__2*3^(1/2)+(1/2)*exp(-(-2+3^(1/2))*t)*c__1*3^(1/2)-(3/2)*exp((2+3^(1/2))*t)*c__2-(3/2)*exp(-(-2+3^(1/2))*t)*c__1-(1/2)*exp(t)+2*t+7}

ode:=diff(y(x),x$2)+y(x)=sin(x);
dsolve(ode);

diff(diff(y(x), x), x)+y(x) = sin(x)

Methods for second order ODEs:

--- Trying classification methods ---

trying a quadrature

trying high order exact linear fully integrable

trying differential order: 2; linear nonhomogeneous with symmetry [0,1]

trying a double symmetry of the form [xi=0, eta=F(x)]

-> Try solving first the homogeneous part of the ODE

   checking if the LODE has constant coefficients

   <- constant coefficients successful

   -> Determining now a particular solution to the non-homogeneous ODE

      building a particular solution using variation of parameters

<- solving first the homogeneous part of the ODE successful

y(x) = sin(x)*c__2+cos(x)*c__1+(1/2)*sin(x)-(1/2)*cos(x)*x

dsolve(ode);

Methods for second order ODEs:

--- Trying classification methods ---

trying a quadrature

trying high order exact linear fully integrable

trying differential order: 2; linear nonhomogeneous with symmetry [0,1]

trying a double symmetry of the form [xi=0, eta=F(x)]

-> Try solving first the homogeneous part of the ODE

   checking if the LODE has constant coefficients

   <- constant coefficients successful

   -> Determining now a particular solution to the non-homogeneous ODE

      building a particular solution using variation of parameters

<- solving first the homogeneous part of the ODE successful

y(x) = sin(x)*c__2+cos(x)*c__1+(1/2)*sin(x)-(1/2)*cos(x)*x

 


On a side note. the first line of the display is hard to read. Any one know what it is supposed to mean by the space between the 1 and y(x) at the end there?

Download infolevel_stops_working.mw

I have done a complete clean reinstall of windows 10 and all programs on my pc.

In worksheet mode new files do not have the "default" red/brown text coluor ond the font is different. 

Might not be a problem but thought that was the default?

What have I changed or have Maple defaults changed?

restart

``

2+2

4

(1)

NULL

eq := x^3+x-7

x^3+x-7

(2)

NULL

Download 23-11-23_Q_inputs_to_worksheet_not_brown_red_colour.mw

This is strange problem. I have matrix M. when doing latex(M), it works. But when doing latex(simplify(evalf[16](M))) it gives internal Maple error 

Error, (in unknown) invalid input: ^ expects 2 arguments, but received 1

any workaround or ideas why it happens?

Maple 2023.2 on windows 10.

restart;

2848

interface(version)

`Standard Worksheet Interface, Maple 2023.2, Windows 10, October 25 2023 Build ID 1753458`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1590. The version installed in this computer is 1585 created 2023, October 29, 6:31 hours Pacific Time, found in the directory C:\Users\Owner\maple\toolbox\2023\Physics Updates\lib\`

expr:=Matrix(3, 3, [[(-a^2-b^2-c^2)^(1/2),b*c/a,-b*c/a],[0,-(a^2+b^2)/(-a^2-b^2-c^2)^(1/2),c*a/b-c^2/(-a^2-b^2-c^2)^(1/2)],[0,0,0]]);
latex(expr);

Matrix(3, 3, {(1, 1) = sqrt(-a^2-b^2-c^2), (1, 2) = b*c/a, (1, 3) = -b*c/a, (2, 1) = 0, (2, 2) = -(a^2+b^2)/sqrt(-a^2-b^2-c^2), (2, 3) = c*a/b-c^2/sqrt(-a^2-b^2-c^2), (3, 1) = 0, (3, 2) = 0, (3, 3) = 0})

\left[\begin{array}{ccc}
\sqrt{-a^{2}-b^{2}-c^{2}} & \frac{b c}{a} & -\frac{b c}{a}
\\
 0 & -\frac{a^{2}+b^{2}}{\sqrt{-a^{2}-b^{2}-c^{2}}} & \frac{c a}{b}-\frac{c^{2}}{\sqrt{-a^{2}-b^{2}-c^{2}}}
\\
 0 & 0 & 0
\end{array}\right]

expr:=simplify(evalf[16](expr));
latex(expr);

Matrix(3, 3, {(1, 1) = 1.*sqrt(-a^2-b^2-c^2), (1, 2) = b*c/a, (1, 3) = -1.*b*c/a, (2, 1) = 0., (2, 2) = (-1.*a^2-1.*b^2)/sqrt(-a^2-b^2-c^2), (2, 3) = c*a/b-1.*c^2/sqrt(-1.000000000*a^2-1.000000000*b^2-1.000000000*c^2), (3, 1) = 0., (3, 2) = 0., (3, 3) = 0.})

Error, (in unknown) invalid input: ^ expects 2 arguments, but received 1

 

(will send to Maplesoft)

Download latex_problem_after_using_evalf_nov_23_2023.mw

Anteriorly, I had done a question that you answered in the forum and it basically it was about the simplification of a equation. I'm posting the print of the screen and the code because the question of today is similarly, but not completely, because there are something that make more complicate the code that I devolved.

restart;
Hi := -Delta*S1^2 - J*S1*S2;
R1 := S1*exp(-beta*Hi);
R1 := add(R1, S1 = [--1, 0, 1]);
R2 := exp(-beta*Hi);
R2 := add(R2, S1 = [-1, 0, 1]);
S := R1/R2;
S := convert(S, trig, {J*S2});
S := simplify(S);
S := convert(S, exp, {Delta});

In this case I had to put in evidence the therm exp(Delta beta), where I simplified the expression. Now, we have more 2 variables (+2 and -2) to substitute in the equation. The code is:

restart;
Hi := -Delta*S1^2 - J*S1*S2;
R1 := S1*exp(-beta*Hi);
R1 := add(R1, S1 = [-2, -1, 0, 1, 2]);
R2 := exp(-beta*Hi);
R2 := add(R2, S1 = [-2, -1, 0, 1, -2]);
S := R1/R2;
S := convert(S, trig, {J*S2});
S := simplify(S);
S := convert(S, exp, {Delta});

In the last line we had the final equation

What should I change in the code for that my exponential function continue in evidence? This is, for my expression  be

(4*sinh(2*J*S2*beta) + 2*sinh(J*S2*beta)*exp(-3*Delta*beta))/(2*cosh(2*J*S2*beta) + 2*cosh(J*S2*beta)*exp(-3*Delta*beta) + exp(-4*Delta*beta))

Good day to all of you. 

I am working with a differential equation, got a first approximation setting all the constants equal to 1. But at the time to use the real values there appears the error numeric exception: division by zero.

I'll thanks any advice.

best regards

division_by_zero.mw

In the system below, I need to solve the solution algebraically (it is known in advance that from "V3" that a0=1,just open the V3 command).

V := exp(lambda*S) = S^4*a4 + S^3*a3 + S^2*a2 + S*a1 + a0;
V1 := subs(S = 2, V);
V2 := subs(S = 1, V);
V3 := subs(S = 0, V);
V4 := subs(S = -1, V);
V5 := subs(S = -2, V);
fsolve(subs(a0 = 1, {V1, V2, V4, V5}), {a1, a2, a3, a4});

I already know the answers, but I need maple to provide me with the command in the form

a1:=(1/6)*[8*sinh(lambda)-sinh(2*lambda)] and

a2:=(1/12)*[16*cosh(lambda)-cosh(2*lambda)-15],

a3:= ... etc.

What is the best way to do this?

I have this equation:

and I need to do some manipulation to obtain this:

I manage to get it but my manipulation is too long for my liking. Can someone show me a shorter version. I have linked the Maple document.

Manipulating_polynomial.mw

Thank you in advance for your help.

Mario

1 2 3 4 5 6 7 Last Page 1 of 19