Procedure


Use shift-enter to make new line.

functionname := proc()
local a;
   a := 1/2;
   evalf(a/2);
end proc;

to see build in procedure use, for example to see build in least common multiple (lcm)  use the follow command:

> interface(verboseproc = 2):
> print(lcm);

From exercises

  1. Assign the integers 12321, 23432, and 34543 to the names a, b, and c. Use these names to find the sum and difference of each pair of numbers.
     ex1 := proc()
       local a, b, c, sum;
       a := 12321:
       b := 23432:
       c := 34543:
       sum := a + b + c;
    end proc:
  2. Write two procedures. The first requires two inputs and finds their sum. The second requires two inputs and finds their product. Use these procedures to add and multiply pairs of numbers. How could you use these procedures to add and multiply three numbers?
     ex21 := proc(a,b)
       local sum;
       sum := a+b;
    end proc:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s