Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

For any symbolic expression like

y = s + (a/b)*log((a+c/b)); 

I want to extract all possible sub-expressions which have one operator operating on exact two operands.
    

subExpression1 = a/b; # any operatoin(+,-,*,/ involving exact two variables)
subExpression2 = c/b;

 

Note: I need an sub-expression which is part of main expression. Above expression is an example. I have quite complex expressions where I need to extract these sub-expressions.  I need to scan my expression at all operators and see on what operands its working on
 

a+c/b # here + is acting on a and c/b clearly it is out of my interest

Maple users frequently solve differential equations. If you want to use the results later in Maple, you need to deconstruct the solution, and then assign the functions -- something that isn't done automatically in Maple. We wrote a multi-purpose routine to help you out. For instance, suppose you solve a simple linear system of equations:

restart;

eqs := { x + y = 3, x - y = 1 };
soln := solve( eqs ); # { x = 2, y = 1 }
x, y; # plain x and y

To assign the values from the solution to the corresponding variables:

assign( soln );
x, y; # 2, 1

This won't work for solutions of differential equations:

restart;

sys := { D(x)(t) = y(t), D(y)(t) = -x(t), x(0) = 1, y(0) = 0 };
soln := dsolve( sys ); # { x(t) = cos(t), y(t) = -sin(t) }
assign( soln );
x(s), y(s); # plain x(s) and y(s)

To make this work, we wrote this multi-purpose routine:

restart;

# Type for a variable expression, e.g. x=5.
TypeTools:-AddType( 'varexpr', u -> type( u, 'And'('name','Non'('constant'))='algebraic' ) ):

# Type for a function expression, e.g. f(x)=x^2.
TypeTools:-AddType( 'funcexpr', u -> type( u, 'function'('And'('name','Non'('constant')))='algebraic' ) ):

# Procedure to assign variable and function expressions.
my_assign := proc( u :: {
        varexpr, 'list'(varexpr), 'rtable'(varexpr), 'set'(varexpr),
        funcexpr, 'list'(funcexpr), 'rtable'(funcexpr), 'set'(funcexpr)
}, $ )

        local F, L, R, V:       

        # Map the procedure if input is a data container, or apply regular assign(), where applicable.
        if not u :: {'varexpr','funcexpr'} then
               map( procname, u ):
               return NULL:
        elif u :: 'varexpr' then
               assign( u ):
               return NULL:
        end if:       

        L, R := lhs(u), rhs(u):
        F := op(0,L): 
        V := [ indets( L, 'And'( 'name', 'Non'('constant') ) )[] ]:    

        map( assign, F, unapply( R, V ) ):
        return NULL:

end proc:

# Example 1.

eqs := { x + y = 3, x - y = 1 };
my_assign( solve( eqs ) );
'x' = x, 'y' = y; # x=1, y=2

# Example 2.

unassign( 'x', 'y' ):
E := [ f(x,y) = x + y, g(x,y) = x - y ];
my_assign( E );
'f(u,v)' = f(u,v), 'g(u,v)' = g(u,v); # f(u,v)=u+v, g(u,v)=u-v

# Example 3.

sys := { D(x)(t) = y(t), D(y)(t) = -x(t), x(0) = 1, y(0) = 0 };
soln := dsolve( sys );
my_assign( soln ):
'x(s)' = x(s); # x(s)=cos(s)
'y(s)' = y(s); # y(s)=-sin(s)

With Maple 18.02 and 2017.2 on OSX 10.13.6: 

restart: 
int( exp(a*exp(I*x)) ,x=-Pi..Pi); 
                               0 

but we get the correct answer for numerical a, e.g. 

restart: 
int( exp(1*exp(I*x)) ,x=-Pi..Pi); 
                              2 Pi 

Is this fixed in version 2018.1? 
 

‏‏‏‏I want to solve partial differential equation by adomian decomposition method, I have a mistake  in define the nonlinear term, then  the calculations of integral does not display , can anyone help me please

‏‏ADM_1.mw


 

restart

" S3:=proc(psi) [[[cos(psi),-sin(psi),0],[sin(psi),cos(psi),0],[0,0,1]]]:  end  proc ;   S1:=proc(`ϕ`)  [[[1,0,0],[0,cos(`ϕ`),-sin(`ϕ`)],[0,sin(`ϕ`),cos(`ϕ`)]]]:   end proc;"

proc (psi) Matrix(3, 3, {(1, 1) = cos(psi), (1, 2) = -sin(psi), (1, 3) = 0, (2, 1) = sin(psi), (2, 2) = cos(psi), (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 1}) end proc

 

proc (`ϕ`) Matrix(3, 3, {(1, 1) = 1, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = cos(psi), (2, 3) = -sin(psi), (3, 1) = 0, (3, 2) = sin(psi), (3, 3) = cos(psi)}) end proc

(1)

``

S3(uu)

Matrix([[cos(uu), -sin(uu), 0], [sin(uu), cos(uu), 0], [0, 0, 1]])

(2)

S1(uu)

Matrix([[1, 0, 0], [0, cos(psi), -sin(psi)], [0, sin(psi), cos(psi)]])

(3)

``


 

Download test3.mw

Way i get the wrong output with procedure S1(uu)
 

How can I get the vlaue of matric c?

Thanks for your help


restart;
with(Student[LinearAlgebra]);
a := Matrix(2, 2, [[1, 2], [3, 4]]);
                               [1  2]
                          a := [    ]
                               [3  4]
b := Matrix(2, 2, [[2, 4], [6, 2]]);
                               [2  4]
                          b := [    ]
                               [6  2]
c := multiply(a, b);
                              /[1  2]  [2  4]\
                 c := multiply|[    ], [    ]|
                              \[3  4]  [6  2]/
evalm(c);
           [        /   [2  4]\          /   [2  4]\]
           [multiply|1, [    ]|  multiply|2, [    ]|]
           [        \   [6  2]/          \   [6  2]/]
           [                                        ]
           [        /   [2  4]\          /   [2  4]\]
           [multiply|3, [    ]|  multiply|4, [    ]|]
           [        \   [6  2]/          \   [6  2]/]
 

This is my first problem with Maple but i am pretty confused as to why it would struggle with these steps.

Just using a standard worksheet, here is what i have:

> f:=(4^x)+1

>g:=x^4

> solve(g=f,x)

now, i would just expect this to come back with 3 answers, but instead i get 

Warning, solutions may have been lost
                     RootOf(-4^_Z - 1 + _Z^4)

if I do:

>fsolve(g=f,x)

It comes back with only one of the answers(2.094012853), instead of all three.

What am I doing wrong?

I mean, for example,

solve({4*x1+7*x2+6*x3 = 186, floor((1/2)*x1)+floor((1/5)*x2)+floor((1/3)*x3) = 18, 
floor((1/5)*x1)+floor((1/2)*x2)+floor((1/4)*x3) = 21});
Warning, solutions may have been lost

A finite number of the solutions can be found by DirectSearch

DirectSearch:-SolveEquations([floor((1/2)*x1)+floor((1/5)*x2)+floor((1/3)*x3) = 18, 
floor((1/5)*x1)+floor((1/2)*x2)+floor((1/4)*x3) = 21, 4*x1+7*x2+6*x3 = 186], 
{x1 >= -100, x2 >= -100, x3 >= -100, x1 <= 100, x2 <= 100, x3 <= 100}, 
AllSolutions, solutions = 3, number = 1000);

Matrix(3, 4, [[0., Vector[column](3, [0., 0., 0.]),
 [x1 = 74.18778903830886, x2 = 58.93905207777524, x3 = -87.22075344961036], 185], 
[0., Vector[column](3, [0., 0., 0.]),
 [x1 = 71.22714241634635, x2 = 56.43467122661542, x3 = -82.32521137528222], 164],
 [0., Vector[column](3, [0., 0., 0.]), 
[x1 = 73.6407870507502, x2 = 58.33738250527096, x3 = -86.15413762331626], 165]])

I don't see a way to obtain the MMA answer (in Maple notation)

(155/2 < x1 and x1 < 78 and 744/7-4*x1*(1/7) < x2 and x2 < 62 or 72 <= x1 and x1 <= 73 and
 102-4*x1*(1/7) < x2 and x2 < 62 or 73 < x1 and x1 <= 147/2 and 102-4*x1*(1/7) < x2 and
 x2 <= 726/7-4*x1*(1/7) or 147/2 < x1 and x1 < 74 and 60 <= x2 and x2 <= 726/7-4*x1*(1/7) or
 74 <= x1 and x1 < 75 and 726/7-4*x1*(1/7) < x2 and x2 < 62 or 153/2 < x1 and x1 < 78 and
 726/7-4*x1*(1/7) < x2 and x2 < 60 or x1 = 72 and 58 <= x2 and x2 < 60 or 72 < x1 and x1 < 74 and
 58 <= x2 and x2 <= 708/7-4*x1*(1/7) or 75 <= x1 and x1 < 76 and 102-4*x1*(1/7) < x2 and x2 < 60 or
 x1 = 74 and 442/7 < x2 and x2 < 64 or 74 < x1 and x1 < 75 and 738/7-4*x1*(1/7) < x2 and 
x2 <= 744/7-4*x1*(1/7) or 74 <= x1 and x1 < 75 and 708/7-4*x1*(1/7) < x2 and x2 <= 102-4*x1*(1/7) or 
151/2 < x1 and x1 < 76 and 708/7-4*x1*(1/7) < x2 and x2 < 58 or 157/2 < x1 and x1 < 80 and
 762/7-4*x1*(1/7) < x2 and x2 < 64 or 68 <= x1 and x1 < 137/2 and 56 <= x2 and x2 <= 666/7-4*x1*(1/7) or
 x1 = 137/2 and x2 = 56 or x1 = 70 and 56 < x2 and x2 < 58 or 70 < x1 and x1 <= 71 and 56 <= x2 and
 x2 < 58 or 71 < x1 and x1 < 72 and 56 <= x2 and x2 <= 690/7-4*x1*(1/7) or 70 <= x1 and x1 <= 281/4 and
 54 <= x2 and x2 < 55 or 281/4 < x1 and x1 < 72 and 54 <= x2 and x2 <= 666/7-4*x1*(1/7)) and
 x3 = 31-2*x1*(1/3)-7*x2*(1/6)

PS. MMA_solution.pdf MMA_solution.mw

I have 2 same integrals, but there is difference between  them at the end.WHy?


 

``

restart

N := 8:

I__1 := add(int(zt*ro[i], zt = Z[i] .. Z[i+1]), i = 1 .. N)

(1/2)*ro[1]*(-Z[1]^2+Z[2]^2)+(1/2)*ro[2]*(-Z[2]^2+Z[3]^2)+(1/2)*ro[3]*(-Z[3]^2+Z[4]^2)+(1/2)*ro[4]*(-Z[4]^2+Z[5]^2)+(1/2)*ro[5]*(-Z[5]^2+Z[6]^2)+(1/2)*ro[6]*(-Z[6]^2+Z[7]^2)+(1/2)*ro[7]*(-Z[7]^2+Z[8]^2)+(1/2)*ro[8]*(-Z[8]^2+Z[9]^2)

(1)

ro := Vector(8, {(1) = 2051.904, (2) = 2051.904, (3) = 2051.904, (4) = 2051.904, (5) = 2051.904, (6) = 2051.904, (7) = 2051.904, (8) = 2051.904})

Z := Vector(9, {(1) = -0.4998720000e-6, (2) = -0.3749040000e-6, (3) = -0.2499360000e-6, (4) = -0.1249680000e-6, (5) = 0, (6) = 0.1249680000e-6, (7) = 0.2499360000e-6, (8) = 0.3749040000e-6, (9) = 0.4998720000e-6})

I__2 := add(int(zt*ro[i], zt = Z[i] .. Z[i+1]), i = 1 .. N)

0.1e-19

(2)

I__1-I__2

-0.1e-19

(3)

``

``

``

``

``

``

``


 

Download Ajib.mw

I am trying to solve a set of differential equations in maple. The maple code:

de1:=diff(u1(x,t),x)=-h*(u1(x,t))+i*exp(-i*t)*(u2(x,t));
              d
       de1 := -- u1(x, t) = -h u1(x, t) + i exp(-i t) u2(x, t)
              dx

> de2:=diff(u1(x,t),t)=(-h-i/2)*u1(x,t)-h*exp(-i*t)*u2(x,t);

         d
  de2 := -- u1(x, t) = (-h - 1/2 i) u1(x, t) - h exp(-i t) u2(x, t)
         dt

> dsolve({de1,de2},{u1(x,t),u1(x,t)});
 

However, when I execute it, maple show "Warning: system is consistent". How to remove it

Fourteen year old Lazar Paroski is an exceptional student. Not only is he an overachiever academically, but he has a passion to help struggling students, and to think of innovative ways to help them learn. Lazar is particularly fond of Math, and in his interactions with other students, he noticed how students have a hard time with Math.

Putting on his creative cap, Lazar came up with the idea of an easily accessible “Math Wall” that explains simple math concepts for students in a very visual way.

“The Music Wall on Pinterest was my inspiration,” says Lazar. “I thought I can use the same idea for Math, and why not a Math Wall”?

"The math wall is basically all the tools you'll have on the wall in your classroom outside," said Lazar. Making the Math Wall and getting it set up, took time and effort. But he had help along the way, which, fueled by his passion and enthusiasm, helped turn his creative dream into reality. Lazar received a grant of $6000 from the local government to implement the project; his teachers, principal and family helped promote it; and the community of parents provided encouragement.

The Math Wall covers fundamental math concepts learnt in grades 1 to 6. Lazar engaged with over 450 students in the community to understand what would really be helpful for students to see in this Math Wall, and then he carefully picked the top themes he wanted to focus on.

The three meter Math Wall is located in the Morrison community park, and was officially inaugurated by the Mayor of Kitchener in July 2018. Many students have already found it to be useful and educative. Parents who bring their children to the park stop by to give their kids a quick math lesson.

At Maplesoft, we love a math story like this! And that too in our backyard! We wanted to appreciate and encourage Lazar and his efforts in making math fun and easy and accessible to students. So we invited Lazar to our offices, gifted him a copy of Maple, and heard more about his passion and future plans. “In many ways, Lazar embodies the same qualities that Maplesoft stands for – making it easy for students to understand and grasp complex STEM concepts,” said Laurent Bernardin, Maplesoft’s Chief Operating Officer. “We try to impress upon students that math matters, even in everyday life, and they can now use advanced, sophisticated technology tools to make math learning fun and efficient.”

We wish Lazar all the very best as he thinks up new and innovative ways to spread his love for math to other kids. Well done, Lazar!

 

 

I have a matrix 50*500000 was computed through a loop. when I double click on it I faced with the following error.

Rtable browser error

unable to display structured data

 

What the problem is?

Hi,

I would like to translate a set of ODEs from Maple to FORTRAN and optimize them. The problem is that even I have all the equations in one file the maple uses some names in optimizations same as what it has used before. How can I fixed it?

for Example:

with(codegen, optimize, makeproc, cost, prep2trans):

Fortran(eq_dP_5, optimize, resultname = fp1);
      t2 = int(z5 ** 2)
      t3 = int(t2 ** 2)
      t5 = int(z4 ** 2)
      t6 = int(x ** 2)
      t8 = x - 1
      t9 = t8 ** 2
      t10 = 1 / t9
      t11 = t10 * t6 * t5
      t13 = int(mTh ** 2)
      t23 = 2 * z2 * x + z4 * x - 2 * z2
      t26 = 1 / z4
      t32 = Az5 ** 2
      t38 = int(z6 ** 2)
      fp1 = -dble(z4) / dble(t23) / dble(t8) * (dble(t11 * t3 * LmdSF) +
     # dble(2 * t11 * t13 * t2) + dble(2 * t26 / Az5 * t23 * Bz5 * z6 *
     #t8) - 0.16D2 * dble(t10) * t32 * z1 * dble(t6) * dble(t5) * 0.3141
     #592654D1 - dble(2 * t26 * t38 * t23 * t9 * x) + dble(4 / x * t26 *
     # t8 * z2)) * (z1 + valrho) / 0.4D1

Fortran(eq_dmu_5, optimize, resultname = fmu2);
      t1 = z6 ** 2
      t2 = z4 / 0.2D1
      t5 = x ** 2
      t6 = t5 ** 2
      t28 = z5 ** 2
      t29 = t28 ** 2
      t32 = Az5 ** 2
      t35 = mTh ** 2
      t39 = z4 ** 2
      t49 = (x - 1) ** 2
      t50 = t49 ** 2
      fmu2 = (t1 * (z2 + t2) * t6 * dble(x) - 0.5D1 * t1 * (z2 + 0.2D1 /
     # 0.5D1 * z4) * t6 + 0.10D2 * (z2 + 0.3D1 / 0.10D2 * z4) * t1 * t5
     #* dble(x) - 0.10D2 * (z2 + z4 / 0.5D1) * t1 * t5 + ((0.5D1 * z2 +
     #t2) * t1 + 0.4D1 * (LmdSF * t29 / 0.16D2 + t32 * 0.3141592654D1 *
     #valrho + t35 * t28 / 0.8D1) * t39 * z4) * dble(x) - z2 * t1) * dbl
     #e(x) / dble(t50)

 

 

I get this message everytime I am trying to open my worksheet: "Recover Corrupt File and Save As"

2.G_anden_aflevering.mw

Is there a simple (i.e. without using of op( ), coeff( ), etc.)  way to force Maple to put a common constant out of brackets in the expression like 2*a+2*b -> 2(a+b)? The task seems as very simple. But I can't find a solution

First 641 642 643 644 645 646 647 Last Page 643 of 2097