## 447 Reputation

6 years, 219 days

## MaplePrimes Activity

### These are answers submitted by MapleMathMatt

Hi @carriewong,

It looks like you just need to re-arrange some options, and load DEtools for the phaseportrait() command:

```pendsys := { diff(x(t),t) = 1 - x(t) - b * x(t) + x(t)^2 * y(t), diff(y(t),t) = b * x(t) - x(t)^2 * y(t) };
vars := { x(t), y(t) };
tr, xr, yr := t=0..50, x=0..5, y=0..5;
br := b=0.5..3;
ic := [ [x(0)=0,y(0)=0], [x(0)=2,y(0)=3] ];
opts := linecolor=[black,green], numpoints=75, dirgrid=[30,30];
plots:-animate( DEtools:-phaseportrait, [ pendsys, vars, tr, ic, xr, yr, opts ], br );
```

## Try '&.' instead of '.'...

Hi @mapleatha,

I suggest using '&.' instead of '.', which keeps the multiplication inert:

```restart;
with( LinearAlgebra ):

n := 2;
A, B := RandomMatrix( n, n ), RandomMatrix( n, n );
C := A . B;

A %. B = C;```

Hi @nunavutpanther,

Another possibility would be to use the command Physics:-Library:-Add():

```restart;

mondeg := proc( X :: Or(name,list(name)), d :: posint )

local n:

if type(X,name) or numelems(X) = 1 then
return [ op(X)^d ]:
end if:

# number of variables
n :=  numelems(X):

# UsePhysics:-Library:-Add() to get sum, and then extract individual monomials
return [ op( Physics:-Library:-Add( mul( X[j]^i[j], j=1..n ), add( i[j], j=1..n ) = d ) ) ]:

end proc:

mondeg( x, 2 ); # [x^2]
mondeg( [x], 2 ); # [x^2]
mondeg( [x,y], 2 ); # [x^2,x*y,y^2]
mondeg( [x,y], 3 ); # [x^3,x^2*y,x*y^2,y^3]```

## Is this what you're after?...

Hi @basha 666,

This seems to work for me:

``````restart;

# system
de := (1-p) * diff( f(x), x\$3 ) + p * ( diff( f(x), x\$3 ) + 1/2 * f(x) * diff( f(x), x\$2 ) );
ibvc := f(0), D(f)(0), D(f)(5) - 1;

# order and series for perturbation solution
n := 2;
F := unapply( add( b[k](x) * p^k, k=0..n ), x );

# differential equation in terms of perturbation solution
DE := series( eval( de, f=F ), p=0, n+1 );

# IBVC in terms of the coefficient functions b[k](x)
C := map( coeffs, eval( [ ibvc ], f=F ), p );

# successively determine the coefficient functions b[k](x)
for k from 0 to n do
IBVC := select( has, C, b[k] ):
s := dsolve( { coeff( DE, p, k ), op( IBVC ) } ):
b[k] := unapply( rhs(s), x ):
end do:

# perturbation solution
'F(x)' = F(x) + O(p^(n+1));``````

## Try 'combine()' command...

Hi @minhhieuh2003,

I suggest the combine() command with the power option:

```f := sqrt(2) * sqrt(3); # sqrt(2) * sqrt(3)
g := combine( f, power ); # sqrt(6)```

 1 2 3 Page 3 of 3
﻿