Some of the Basic Maple commands;
1) Algebraic Expressions Numerical vs. Algebraic Expressions: > 5 / 7; > evalf ( 5 / 7); # Numerical evaluation of 5/7 > sqrt(3), Pi; > evalf ( Pi, 40 ); # Numerical value of Pi with 40 digits of accuarcy Object Oriented Assignments: > y := 4*x - 3; > y^2 + 5*x + 3; # Output is (4x - 3)^2 + 5x + 3 > subs ( x = t, y ); # Output is 4t - 3 > eqn1 := 4*x + 3 = x + 7; # The name of the equation is eqn1 > y := lhs ( eqn1 ); > z := rhs ( eqn1 ); > eqn2 := y - z = 0; # This is equivalent to the following two equations > eqn3 := " + ( 4 = 4 ); # Output is 3x = 4 > eqn4 := " / 3; # Output is x = 4/3 > isolate ( eqn2, x ); # Output is x = 4/3 > solve ( eqn1, x ); # Output is x = 4/3 > subs (eqn4, eqn1 ); # Output is 25/3 = 25/3 Assignments as Functions: > f := (x) -> sqrt ( 9 - x^2 ); > g := (x) -> x - 5; > (f+g)(x), (f/g)(x), (f@g)(x), (f@g@f)(x) > > h := proc ( x ) > if 0 <= x and x <=3 then > x^2 > else > ERROR ( x, `Not in Domain`) > fi > end: > h(0), h(2); # Output 0, 4 > h(4); # Output Error, (in h) 4, Not in Domain > > k := proc ( x ) # piecewise defined function with nested if statements > if -3 <= x and x <= 3 then > x^2 - 2 > elif 3 < x and x <= 5 then > x - 3 > elif x > 5 then > -x^2 + 34 > elif > undefined > fi > end: > plot (k, -10 .. 10 ); > Q := series ( sin (x), x=0, 10 ); # Tenth deg. Taylor polynomial \ > expansion about x=0 > P := convert ( Q, polynom ); # Create an output as a normal polynomial > P_as_function_of_x := makeproc ( P, x ); # Define as a function \ > The procedure 'makeproc' have to be 'student[makeproc]' on some editions > plot(P_as_function_of_x(x), x = -1 .. 1); > P_as_function_of_x ( 1 ); Some Calculus Commands > Limit ( f(x), x = a, right ); # Echo the right hand limit expression > limit ( f(x), x = a, right ); # Find the right hand limit > diff ( f(x), x ); # The first derivative of f(x) w.r.t. x > diff ( f(x), x, x ); # The second derivative of f(x) w.r.t. x > showtangent ( f(x), t = 0, t = -1 .. 1 ); # Show the tangent line and the / > graph > convert(1.5, rational); # Change 1.5 to 3/2 > slope ( [a, f(a)], [b, f(b)] ); # The slope of the line through points > vertical( [a, 0], [a, f(a)] ); # Draw a vertical line from/to Some notes about the plotting an object Sometimes you might run into an error when mixing objects. The following is a problem I ran into last semester in my DE class. The question is an initial value problem. > de := diff(y(x), x) = (x - y(x))/(1+x^2+y(x)^2): > ic := y(0) = 1: > result := dsolve( {de, ic}, y(x), numeric): > result(0); # Output is a list(vector) [x = 0, y(x) = 1.] > result(0) [2]; # This isolates the second component, i.e. y(x) = 1 > # I was trying to use the answer resulted from 'dsolve' command as a function, > # but I could not isolate the second component of the result as a function. So > # I tried, > result(x); # ERROR, this does NOT work > > # To define the solution y(x) which is the second part of result(x), we need > # to define a procedure as follows; > > myproc := proc ( t ) > local t, j, k: > k := result(t): > j := nops ( k ): > for i from 1 to j do > if ( convert(lhs( op(ik k) ), string ) = `y(x)` ) then > RETURN ( rsh(op(i, k) ) ) > fi > od: > end: # The end of this procedure > >plot ( 'myproc(x)', x = 0 .. 3 );