MapleMathMatt

427 Reputation

9 Badges

6 years, 141 days

MaplePrimes Activity


These are answers submitted by MapleMathMatt

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]

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));

 

 

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