Maple 2021 Questions and Posts

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

Maple uses \begin{array}...\end{array} for the latex of a Matrix, which is all good. But for an empty matrix, it does not generate the column specification c or and so the latex when compiled gives an error. Here is an example

W:=Matrix([[]]);
latex(W)

#which gives

\left[\begin{array}{}
{}
\end{array}\right]

Compare to 

W:=Matrix([[1]]);
latex(W)

#gives

\left[\begin{array}{c}
1 
\end{array}\right]

Because the c is missing in the first example, this generates an error

\documentclass[12pt]{book}
\usepackage{amsmath}

\begin{document}   
\[
\left[\begin{array}{}
{}
\end{array}\right]
\]

\end{document}
>lualatex foo.tex
This is LuaHBTeX, Version 1.13.2 (TeX Live 2021)
 restricted system commands enabled.
(./foo.tex
LaTeX2e <2021-11-15>
 L3 programming layer <2021-11-12>
(/usr/local/texlive/2021/texmf-dist/tex/latex/base/book.cls
Document Class: book 2021/10/04 v1.4n Standard LaTeX document class
(/usr/local/texlive/2021/texmf-dist/tex/latex/base/bk12.clo))
(/usr/local/texlive/2021/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2021/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2021/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2021/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2021/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2021/texmf-dist/tex/latex/l3backend/l3backend-luatex.def)
(./foo.aux) (/usr/local/texlive/2021/texmf-dist/tex/latex/base/ts1cmr.fd)
! Missing # inserted in alignment preamble.
<to be read again>
\cr
l.6 \left[\begin{array}{}

?

Adding the `c` fixes the Latex.

This came up with my code generated an empty  matrix from some computation.

May be this could be corrected for future version of Maple?

Thank you.

Maple 2021.2 on windows 10.  

Hello Maple gurus!

I have two questions related to working with operands:

Question 1

I often find myself in a situation where I have a non-trivial expression for instance containing double integrals with complex exponentials, and want to perform some operation on a heavily nested operand like the exponent to a specific exponential inside the double integral. Usually what I do is use a list argument with the op() or subsop() to operate on the nested operator by finding specific operand numbers.

However, the problem with this is that I am hard-coding the operand number(s) for the operator, and this expression can be located in the middle of a large worksheet. If something above these op() or subop() calls changes and the changes trickle down, the operands might change number and the commands are no longer valid.

Does Maple have any commands that will let me 'find' an operand like one does in by-hand calculations? For example, there might be an exponent nested in a double integral that has 'a*b' in it. What I want is to operate on the operand containing 'a*b' rather than specifying the actual operand number. Is there anything like this?

Question 2

Somewhat related to the above, I sometimes want to do a single function on multiple operands. I tried applyop but that seems to apply a function to each operand individually. What if, for example, I want to run combine() on 2 specific operands, assuming these operands are heavily nested, to combine just those two operands.

Thank you!

When I convert Maple expression to Latex, before calling Latex, I replace some math names by strings in order to keep them as is in the generated Latex instead of using Maple own shortened name when conversion to latex().

Later on, in the Latex file, I add \DeclareMathOperator on each long name. This way the long math names remain and it is more clear.

This has been working well for years. Same code. No problems. All my Latex was generated this way.

Except just now, I hit a case where Maple's latex() gives an error when the math has WeierstrassP in it. latex() generates exception. 

I will email this also to Maplesoft. But thought to also post it here in case someone can see what the problem is.

interface(version);
Physics:-Version();

`Standard Worksheet Interface, Maple 2021.2, Windows 10, November 23 2021 Build ID 1576349`

`The "Physics Updates" version in the MapleCloud is 1165 and is the same as the version installed in this computer, created 2022, March 7, 23:42 hours Pacific Time.`

restart;

#interface(warnlevel=4);
#kernelopts('assertlevel'=2):
interface(typesetting=standard); #to prevent bug. see https://www.mapleprimes.com/questions/232450-Why-Maple-Writes-The-Equation-Like-This
 

extended

r:=11/("\\WeierstrassPPrime"(x,a,b)+"\\WeierstrassP"(x,a,b)^2)*"\\WeierstrassP"(x,a,b)*"\\WeierstrassPPrime"(x,a,b)-6/("\\WeierstrassPPrime"(x,a,b)+"\\WeierstrassP"(x,a,b)^2)*"\\WeierstrassP"(x,a,b)^2+1/2*a/("\\WeierstrassPPrime"(x,a,b)+"\\WeierstrassP"(x,a,b)^2)

11*("\WeierstrassP")(x, a, b)*("\WeierstrassPPrime")(x, a, b)/(("\WeierstrassPPrime")(x, a, b)+("\WeierstrassP")(x, a, b)^2)-6*("\WeierstrassP")(x, a, b)^2/(("\WeierstrassPPrime")(x, a, b)+("\WeierstrassP")(x, a, b)^2)+(1/2)*a/(("\WeierstrassPPrime")(x, a, b)+("\WeierstrassP")(x, a, b)^2)

latex(r)

Error, (in latex) unable to proceed; could you please report this problem at physics@maplesoft.com

interface(typesetting=extended);

standard

latex(r)

Error, (in TypeTools/nc_var_local) invalid input: member received MathematicalFunctionsNames, which is not valid for its 2nd argument, s

 

Download march_8_2021_latex.mw

I am getting an exception divide by zero using solve. The problem is that when using kernelopts('assertlevel'=2):  I am no longer able to catch the exception in a catch try.

Removing kernelopts('assertlevel'=2):  I can catch the exception.

But I need to use kernelopts('assertlevel'=2): in my program.   

Is there a way to keep kernelopts('assertlevel'=2): and still catch exception thrown by solve?

Is this a bug in solve? And why using kernelopts('assertlevel'=2): prevents catching the exception?

Using Maple 2021.2 on windows 10. Worksheet attached.

 exception generated

 

 

restart;

trial_solution_constants:=[A[1]];
eq:=-A[1]-exp(x^2)*exp(-x^2) = 0;
solve(identity(eq,x),trial_solution_constants)

[A[1]]

-A[1]-exp(x^2)*exp(-x^2) = 0

Error, (in unknown) numeric exception: division by zero

Using assertlevel, now unable to catch exception

 

restart;

interface(warnlevel=4);
kernelopts('assertlevel'=2):

3

try
   trial_solution_constants:=[A[1]];
   eq:=-A[1]-exp(x^2)*exp(-x^2) = 0;
   solve(identity(eq,x),trial_solution_constants)
catch:
   print("error happend ",lastexception);
end try;
print(" I am here");

[A[1]]

-A[1]-exp(x^2)*exp(-x^2) = 0

Error, (in unknown) assertion failed

" I am here"

Not Using assertlevel now can catch exception

 

restart;

interface(warnlevel=4);

3

try
   trial_solution_constants:=[A[1]];
   eq:=-A[1]-exp(x^2)*exp(-x^2) = 0;
   solve(identity(eq,x),trial_solution_constants)
catch:
   print("error happend ",lastexception);
end try;
print(" I am here");

[A[1]]

-A[1]-exp(x^2)*exp(-x^2) = 0

"error happend ", unknown, "numeric exception: division by zero"

" I am here"

 

Download march_8_2021_solve.mw

 

Update Sept 7,2022

FYI, here is another internal exception generated by solve which shows only when kernelopts('assertlevel'=2): is set, and which can not be trapped using try/catch. May be this could be fixed in future version of Maple. 

Worksheet attached.


 

interface(version);

`Standard Worksheet Interface, Maple 2022.1, Windows 10, May 26 2022 Build ID 1619613`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1314 and is the same as the version installed in this computer, created 2022, September 2, 15:54 hours Pacific Time.`

restart;

interface(warnlevel=4);
kernelopts('assertlevel'=2):

3

eq:=1 = -X*(-(Y^2*exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)+2*exp(X*Y)*y0*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*Y+exp(X*Y)*y0^2*exp(X*y0)*exp(x0*Y)*exp(x0*y0))/(exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*X+exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*x0+2*Y+2*y0)+(exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*Y+exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*y0+1)/(exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*X+exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*x0+2*Y+2*y0)^2*(Y*exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*X+exp(X*Y)*y0*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*X+exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)+Y*exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*x0+exp(X*Y)*y0*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*x0))/Y/(-(Y*exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*X+exp(X*Y)*y0*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*X+exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)+Y*exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*x0+exp(X*Y)*y0*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*x0)/(exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*X+exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*x0+2*Y+2*y0)+(exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*Y+exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*y0+1)/(exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*X+exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*x0+2*Y+2*y0)^2*(X^2*exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)+2*exp(X*Y)*exp(X*y0)*x0*exp(x0*Y)*exp(x0*y0)*X+exp(X*Y)*exp(X*y0)*x0^2*exp(x0*Y)*exp(x0*y0)+2)):


try
     sol:=solve(identity(eq,X),[x0, y0]);
catch:
     print("exception");
end try;

Error, (in unknown) assertion failed

 


 

Download solve_exception.mw

 

 

 

Hello, can someone explain why something like this fails? The help page for 'isolate' says the second argument can be 'any algebraic expression'. Thanks.

I simplified a vector column using side relations. Then I wanted to evaluate using

eval( equation,  [x1=3,  x2=5......})

But side relations uses the reverse order i.e. after evaluation

[3=x1, 5=x2......]

So then the internals of the list need to be swaped tto work with eval.That is easy. I am just wondering is there a neater way to achieve this?

restart

NULL

P1 := Vector(3, {(1) = -(y[1]-y[3])*(y[2]-y[3])*((x[2]^2-x[2]*x[3]+x[3]^2)*x[1]^2-x[2]*x[3]*(x[2]+x[3])*x[1]+x[2]^2*x[3]^2)*(y[1]-y[2]), (2) = -(x[1]-x[3])*(x[2]-x[3])*(x[1]-x[2])*((y[2]^2-y[2]*y[3]+y[3]^2)*y[1]^2-y[2]*y[3]*(y[2]+y[3])*y[1]+y[2]^2*y[3]^2), (3) = ((-y[1]^2*y[2]+(3*y[2]*y[3]-y[3]^2)*y[1]-y[2]^2*y[3])*x[2]+x[3]*(y[1]^2*y[3]+y[2]*(y[2]-3*y[3])*y[1]+y[2]*y[3]^2))*x[1]^2+((y[1]^2*y[3]+y[2]*(y[2]-3*y[3])*y[1]+y[2]*y[3]^2)*x[2]^2+3*x[3]*(y[2]-y[3])*(y[1]-y[3])*(y[1]-y[2])*x[2]-x[3]^2*(y[1]^2*y[2]+(-3*y[2]*y[3]+y[3]^2)*y[1]+y[2]^2*y[3]))*x[1]-x[3]*((y[1]^2*y[2]+(-3*y[2]*y[3]+y[3]^2)*y[1]+y[2]^2*y[3])*x[2]-x[3]*(y[1]^2*y[3]+y[2]*(y[2]-3*y[3])*y[1]+y[2]*y[3]^2))*x[2]})

eqns := {(x[1]-x[2])*(x[2]-x[3])*(x[3]-x[1]) = R, (y[1]-y[2])*(y[2]-y[3])*(y[3]-y[1]) = S, x[1]^2*x[2]^2-x[1]^2*x[2]*x[3]+x[1]^2*x[3]^2-x[1]*x[2]^2*x[3]-x[1]*x[2]*x[3]^2+x[2]^2*x[3]^2 = Y, y[1]^2*y[2]^2-y[1]^2*y[2]*y[3]+y[1]^2*y[3]^2-y[1]*y[2]^2*y[3]-y[1]*y[2]*y[3]^2+y[2]^2*y[3]^2 = X, x[1]^2*x[2]+x[1]^2*x[3]+x[1]*x[2]^2-6*x[1]*x[2]*x[3]+x[1]*x[3]^2+x[2]^2*x[3]+x[2]*x[3]^2 = Z, y[1]^2*y[2]+y[1]^2*y[3]+y[1]*y[2]^2-6*y[1]*y[2]*y[3]+y[1]*y[3]^2+y[2]^2*y[3]+y[2]*y[3]^2 = W}

P1new := simplify(P1, eqns)

Vector[column](%id = 36893490132854572084)

(1)

values := {x[1] = 3, x[2] = 5, x[3] = 7, y[1] = 2, y[2] = -11, y[3] = 13}

{x[1] = 3, x[2] = 5, x[3] = 7, y[1] = 2, y[2] = -11, y[3] = 13}

(2)

vals1 := eval(eqns, values)

{-3432 = S, 16 = R, 120 = Z, 316 = Y, 2018 = W, 22753 = X}

(3)

eval(P1new, vals1)

Vector[column](%id = 36893490132854572084)

(4)

vals1swap := [seq(rhs(vals1[i]) = lhs(vals1[i]), i = 1 .. nops(vals1))]

[S = -3432, R = 16, Z = 120, Y = 316, W = 2018, X = 22753]

(5)

eval(P1new, vals1swap)

Vector[column](%id = 36893490132849052116)

(6)

eval(P1, values)

Vector[column](%id = 36893490132871267020)

(7)

``

NULL

``

Download Q_6-03-2022_side_rels_and_eval.mw

I was wondering if it is possible to write Maple code in 2D notation inside .mpl and have it converted automatically to standard Maple 1D math.

For example, suppose I have A.mpl file with the content


#--- this is inside A.mpl file

ode:=y''(x)+y'(x)=sin(x);
ic:=y(0)=1,y'(0)=0;
dsolve([ode,ic],y(x));

Right now, reading this file in worksheet or even in document mode gives error:

        read "A.mpl"

Error, on line 1, syntax error, unexpected single forward quote:
ode:=y''(x)+y'(x)=sin(x);

But in document mode, one can type this in, and Maple will accept it. 

Since I do not use document mode and most of my code is in mpl files, I was wondering if one can write y'(x) instead of diff(y(x),x) and have maple automatically convert the code as it reads it somehow?

I find it much easier and more natural to write   y''(0)=1  than (D@@2)(y)(0)=1  for example.

I do understand the technical problems parsing this as has special meaning in Maple. But Maple does handle this input OK if typed in by hand in document 2D mode. It just needs to extend this to reading it from mpl files.

May be a future release of Maple will support this (using some switches or option when reading the file?)

Is it possible to open or import, and execute Maple Flow documents in Maple 2021?

My OS is Linux/Fedora 35.

Without knowing that Feodra is sadly no more officially supported (it used to be the case a few years ago as I was using it on Fedora) I purchased a standalone license of Maple 2021 and  downloaded the Linux installer but am unable to run the file

Maple2021.2LinuxX64Installer.run

from command line (typing 

% sh ./Maple2021.2LinuxX64Installer.run

produces the error "can't execute a binary file") or by clicking on it ("no software installed to run this file").

Before returning the product, I looked at this page to find a possible workaround:

https://faq.maplesoft.com/s/article/Maple-is-not-activating-on-64-bit-Linux?language=en_US

where some tips to install Maple on non-officially supported Linux  os.

I installed lsb packages so that typing:

lsb_relase -a

outputs

LSB Version:    :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID:    Fedora
Description:    Fedora release 35 (Thirty Five)
Release:    35
Codename:    ThirtyFive

Anyone has succeeded to install Maple 2021 on Fedora? Thank you in advance.

When trying to evaluate the following line with values where units are attached Maple chrashes.

(add(eval(F, {x = XY[n, 1], y = XY[n, 2]})^2, n = 1 .. 4), location)

Problem_units.mw

What is the problem here

Dear helpfull community. I stumbled over a problem which I cloud not sort out even after hours of trying to find the error I do. 
A simple IF statement does not work when I attach a unit to a value.

tt := 80*Unit('knot');
if tt < 100*Unit('knot') then
    lprint(got*it);
end if;

Surprisingly Maple can evalue the expression if a use a = instead of the <. File should be attached.

Please can anyone tell me what I did wrong.

NULL`~`[unassign](`<,>`(anames(user)))

with(LinearAlgebra); with(Optimization); Restart

NULLNULL

NULL

Problem 1 ( If Statement with units)

 

The if statement could not evealuated with the logical operator < or > when a unit is attached to the value

 

tt := 80*Unit('knot'); if tt < 100*Unit('knot') then lprint(got*it) end if

Error, cannot determine if this expression is true or false: 100*Units:-Unit(knot) < 80*Units:-Unit(knot)

 

 

 

But it works if the logical operator " = "

 

tt := 80*Unit('knot'); if tt = 80*Unit('knot') then lprint(got*it) end if

got*it

 

 

Anyone an idea why.

``

 

 

NULL

 

 

NULL

NULL

Download Problem_IF.mw

I have my code in mla. Using try/catch, I am able to capture an error that happend deep in some call chain. But it is hard to know the exact location where this error happened.

I use StringTools:-FormatMessage( lastexception[2..-1] inside the catch clause to print the exception. But this only prints the message. It does not tell me exactly which line/function/module this happened.

Is there a way to display these information?  Using debugger and stoperror all did not help at all. It does not stop at the line where the error happened. not sure why. I tried it many times. may be I am not using it correctly?

Is it possible to display may be the trace of the calls inside the catch of the try? To know the actual statement that generated the error? Now each time I get an exception, I have to step into the debugger line by line until  I get to the place where the error was which is time consuming. Here is a MWE

 

restart;
A:=module()  
  local B:=module()
     export foo:=proc(n)
         1/n;
     end proc;
  end module;

  export main:=proc()
    try
       B:-foo(0);
    catch:
      print("error happened", StringTools:-FormatMessage( lastexception[2..-1] ));
    end try;
  end proc;

end module;

And now

    A:-main()

                "error happened", "numeric exception: division by zero"

I'd like to get more information than the above as I said. Line number/proc name/module name or stacktrace showing the calls made up to where the exception started (similar to output from where command in debugger).

The above was done in worksheet. My actual code in inside .mla build from lots of .mpl files.

Maple 2021.2 on windows

Here is short description of the problem with code MWE below.

Short version of the question

I want to change

parent:=module()
  local foo:=proc()
     NULL;
  end proc;

  local child:=module()    
     export boo:=proc()
        foo(); #call works as is
     end proc;
  end module;

end module;

To

parent:=module()
  local foo:=proc()
     NULL;
  end proc;

  local child:=module()    
     export boo:=proc()

         #now call no longer works. Maple wants foo exported
         #I want to add parent:- to the call to remind me where foo((
         #lives but do not want to make foo() in parent exported

         parent:-foo();

     end proc;
  end module;
end module;

Longer version of the question

I have a parent module with one child local module inside it. In the child module, there is a proc which wants to call parent's local proc named foo().

As is, the child module can just call the parent's local proc foo() by typing foo() without the need to do parent:-foo() this is because child module has access to parent local proc's and maple knows which foo() by searching the scope from bottom up.

The problem comes when I added a proc also called foo() (by mistake) in the child module without noticing there is one with same name in the parent's.

Now the call foo() will end up calling the child's module foo() and not the parent's foo() becuase that is the "closest" one with this name in the scope. All of this makes sense so far.

The problem comes when the child module wants to really call the parent's foo().

One solution is to change the call to parent:-foo() to explicitly says which foo() to call.

This however now fail, since the parent foo() is local ! And Maple when it sees call to parent:-foo() it now insist it be exported proc (even though the call is being made from inside, i.e. from the child).

I do not want to make the parent's foo() exported just so the child can call it.  I want to keep parent's foo() local, as it is meant to be used only inside the parent and by its children.

You might ask, why not then change the name of the child's foo() to some other name so it does not clash with the parent's local proc name. Yes, I can do this. But for large modules in different files with many procs(), there is a always a chance  a local proc can be added by mistake with happend to be the same name as one in the parent and having to manually keep checking names does not look like the right solution.

My question is: How can a child module call parent's local proc() explicitly, but without making the parent proc exported?  Is there is different syntax to use?

Here is a MWE

 

restart;
parent:=module()

  export main:=proc()
     child:-boo();
  end proc;

  local foo:=proc()
     print("in parent:-foo() proc");
  end proc;

  local child:=module()     
     export boo:=proc()
        print("in child:-boo() proc");
        foo(); #this works. It called parent's local foo()
     end proc;
  end module;

end module;

Now doing parent:-main() works as expected. Notice parent's foo is local to parent module.

Now I changed the child module and did this

parent:=module()

  export main:=proc()
     child:-boo();
  end proc;

  local foo:=proc()
     print("in parent:-foo() proc");
  end proc;

  local child:=module()
     local foo:=proc() #added this using same name by mistake
        print("in child:-boo()");
     end proc;

     export boo:=proc()
        print("in child:-boo() proc");
        foo(); #now this calls the child's foo() ofcourse. But it was meant to call the parents's
     end proc;
  end module;

end module;

The fix is to change the call from the child to becomes    parent:-foo() but now Maple will give an error saying parent does not export foo().

Since the child have access to parent's local proc's, is there a different way to tell Maple I want to call parent's foo() and not my own foo() without making parent's foo() exported? 

For example , in Python one call call parent's method expliclity using super().foo() 

Maple 2021.2

how to transform this program using LinearAlgebra instead of linalg  ?

restart;
with(plots);
unprotect(gamma, D);
interface(rtablesize = 10): _EnvHorizontalName := 'x': _EnvVerticalName := 'y':
f := (x, y) -> 4*x^2 + 4*y*x + y^2 - 8*x + 16*y - 17: (for instance)
NULL;
Fg := proc(P::polynom, v::set, V::list, N::list) 
local C, M, i, j; 
C := coeffs(f(x, y), v, M); seq(`if`(member(op(i, [M]), N, 'j'), op(j, V) = op(i, [C]), NULL), i = 1 .. nops([M])); end proc:
Fg(f(x, y), {x, y}, [A, B, C, D, E, F], [x^2, y*x, y^2, x, y, 1]):
assign(%);
Delta := -4*A*C + B^2:
var := [x, y]:
with(linalg):
AA := matrix([seq([seq(diff(f(x, y), var[i], var[j])/2, j = 1 .. 2)], i = 1 .. 2)]):
vp := sort([eigenvals(AA)]):
print(`Valeur propres de AA ` = vp):
DD := jordan(AA, 'P11'):
print(`Matrice diagonale semblable à AA:   DD` = evalm(DD)):
G := map(normalize, GramSchmidt([col(P11, 1 .. 2)])):
PP := map(simplify, concat(op(G))):
print(`Matrice de passage orthogonale:   PP` = evalm(PP)):
print(`Directions principales de la conique:`):
print(`I1 ` = col(PP, 1), ` J ` = col(PP, 2)):
alpha := 1/2*arctan(B/(A - C)):
print('alpha' = evalf(%)):                 

M1 := matrix(1, 2, [X, Y]):
M2 := matrix(2, 1, [X, Y]):
multiply(M1, AA, M2):
N := matrix(1, 2, [D, E]):
multiply(M1, AA, M2) + multiply(N, M2):
multiply(M1, transpose(PP), AA, PP, M2) + multiply(N, PP, M2):

NULL;
The parabola in the new base is Y`^2 =X*(8*sqrt(5))/5 , <sqrt(5), -2*sqrt(5)>, <sqrt(5), 2*sqrt(5)>

I am using GenerateMatrix to construct a matrix out of a set of 6 equations with 6 variables.  The output of Generate Matrix is not sorted correctly.  Where am I going wrong? Is this a bug?

restart

NULL``

with(LinearAlgebra)

NULL

NULL

The command GenerateMatrix is not sorting my set of equations properly.

NULL

NULL

Define a set of 6 equations.

equation_set := [5964.000000-770.0000000*T__1+750.0000000*T__2 = 0, 20*T[1]-770.0000000*T[2]+750.0000000*T[3]+100.0000000 = 0, 20*T[2]-770.0000000*T[3]+750.0000000*T[4]+100.0000000 = 0, 20*T[3]-770.0000000*T[4]+750.0000000*T[5]+100.0000000 = 0, 20*T[4]-770.0000000*T[5]+750.0000000*T[6]+100.0000000 = 0, 5900.787944-770.0000000*T[6]+750.0000000*T[5] = 0]

[5964.000000-770.0000000*T__1+750.0000000*T__2 = 0, 20*T[1]-770.0000000*T[2]+750.0000000*T[3]+100.0000000 = 0, 20*T[2]-770.0000000*T[3]+750.0000000*T[4]+100.0000000 = 0, 20*T[3]-770.0000000*T[4]+750.0000000*T[5]+100.0000000 = 0, 20*T[4]-770.0000000*T[5]+750.0000000*T[6]+100.0000000 = 0, 5900.787944-770.0000000*T[6]+750.0000000*T[5] = 0]

(1)

NULL

NULL

NULL

This is what each one looks like individually.

equation_set[1]

5964.000000-770.0000000*T__1+750.0000000*T__2 = 0

(2)

equation_set[2]

20*T[1]-770.0000000*T[2]+750.0000000*T[3]+100.0000000 = 0

(3)

equation_set[3]

20*T[2]-770.0000000*T[3]+750.0000000*T[4]+100.0000000 = 0

(4)

equation_set[4]

20*T[3]-770.0000000*T[4]+750.0000000*T[5]+100.0000000 = 0

(5)

equation_set[5]

20*T[4]-770.0000000*T[5]+750.0000000*T[6]+100.0000000 = 0

(6)

equation_set[6]

5900.787944-770.0000000*T[6]+750.0000000*T[5] = 0

(7)

NULL

The variables used in the above set of equations.

variables_set := [T[1], T[2], T[3], T[4], T[5], T[6]]

[T[1], T[2], T[3], T[4], T[5], T[6]]

(8)

variables_set[1]

T[1]

(9)

A, b := GenerateMatrix(equation_set, variables_set)

Matrix(%id = 36893490238808803916), Vector[column](%id = 36893490238808803796)

(10)

This output seems wrong because a row of zeros appears in A``.  The first entry of the column vector contains the full equation. Thus, it seems GenerateMatrix didn't sort the set of equation properly.  I tried re-writing the  offending equation  as 5964.000000-770.0000000*T__1+750.0000000*T__2 = 0,but maple just changes it back on evaluation.NULL


 I think the output should look like:


A, b := Matrix(6, 6, {(1, 1) = -770.0000000, (1, 2) = 750.0000000, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (1, 6) = 0, (2, 1) = 20, (2, 2) = -770.0000000, (2, 3) = 750.0000000, (2, 4) = 0, (2, 5) = 0, (2, 6) = 0, (3, 1) = 0, (3, 2) = 20, (3, 3) = -770.0000000, (3, 4) = 750.0000000, (3, 5) = 0, (3, 6) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 20, (4, 4) = -770.0000000, (4, 5) = 750.0000000, (4, 6) = 0, (5, 1) = 0, (5, 2) = 0, (5, 3) = 0, (5, 4) = 20, (5, 5) = -770.0000000, (5, 6) = 750.0000000, (6, 1) = 0, (6, 2) = 0, (6, 3) = 0, (6, 4) = 0, (6, 5) = 750.0000000, (6, 6) = -770.0000000}), Vector(6, {(1) = -5964.000000, (2) = -100.0000000, (3) = -100.0000000, (4) = -100.0000000, (5) = -100.0000000, (6) = -5900.787944})

NULL

I rename the matrix and column vector and use LinearSolve to find a solution for T.

AA := Matrix(6, 6, {(1, 1) = -770.0000000, (1, 2) = 750.0000000, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (1, 6) = 0, (2, 1) = 20, (2, 2) = -770.0000000, (2, 3) = 750.0000000, (2, 4) = 0, (2, 5) = 0, (2, 6) = 0, (3, 1) = 0, (3, 2) = 20, (3, 3) = -770.0000000, (3, 4) = 750.0000000, (3, 5) = 0, (3, 6) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 20, (4, 4) = -770.0000000, (4, 5) = 750.0000000, (4, 6) = 0, (5, 1) = 0, (5, 2) = 0, (5, 3) = 0, (5, 4) = 20, (5, 5) = -770.0000000, (5, 6) = 750.0000000, (6, 1) = 0, (6, 2) = 0, (6, 3) = 0, (6, 4) = 0, (6, 5) = 750.0000000, (6, 6) = -770.0000000})

Matrix(%id = 36893490238866723772)

(11)

``

bb := Vector(6, {(1) = -5964.000000, (2) = -100.0000000, (3) = -100.0000000, (4) = -100.0000000, (5) = -100.0000000, (6) = -5900.787944})

Vector[column](%id = 36893490238885708252)

(12)

NULL

NULL

T := LinearSolve(AA, bb)

Vector[column](%id = 36893490238857651132)

(13)

NULL

Download GenerateMatrix_Improper_Sorting.mw

First 16 17 18 19 20 21 22 Last Page 18 of 40