Useful commands: 
a small exercise by Ryan Renn

The following commands can be time savers. The goal here is to save you time from your computational dirty work.  To get a feel for these symbolic commands, enter the commands listed below and see what they do:

Maple commands

  1. Function Definition
    >  
    f(x):=x->C*x^n;
    (This defines a function, f(x) = C* x^n.)
  2. Function Evaluation
    >  
    f(2);
    >  
    f(t); 
  3. Symbolic derivatives
    diff(x^2,x);
    diff(diff(f(x),x),x);
  4. Symbolic integrals
    >   int(f(t),t);
  5. Solve
    >   
    solve(x+2=4,x);
    >   
    solve(cos(x)=0,x);
  6. Hideous integrals
    >   
    int(cosh(x)^400,x);

Matlab commands

  1. Function Definition
    >>  a='C*x^n'
    (Different from Maple.)
  2. Substitution
    >>  subs(a,'t')
    >>  subs(a,2)
  3. Symbolic derivatives
    >>  diff('x^2','x')
    >>  diff(diff(a,'x'),'x')
  4. "Pretty" code
    I feel that the output for the last statement is repugnant. Try
    >>  pretty(diff(diff(a,'x'),'x'))
  5. Factor
    This is better, but not quite satisfying. Try
    >>  pretty(factor(diff(diff(a,'x'),'x')))
  6. Symbolic integrals
    >>  int(a,'x')
  7. Solve 
    >>  solve('x+2=4','x')
  8. Running Maple commands through Matlab
    You are on a computer that runs Matlab, but alas, it doesn't run Maple. But you are crafty, and aware of Matlab's "maple" command:
    >>  maple('expand((x+2)^5)')
    Try also

    >>  maple('y:=t->A*cos(.5*t)+B*sin(.5*t)+C*t*cos(.5*t)+D*t*sin(.5*t);')
    >>  maple('diff(diff(y(t),t),t)+.25*y(t);')

 

 e-mail: renn@purdue.edu