Question: How to define a function with result of simplify(..) without copy and paste?


 

I need a function like this:

 

    f := proc (n) options operator, arrow; sum(i, i = 1 .. n) end proc

proc (n) options operator, arrow; sum(i, i = 1 .. n) end proc

(1)

But I know that the sum actually simplifes.

simplify(sum(i, i = 1 .. n))

(1/2)*n^2+(1/2)*n

(2)

So I actually want define my function as

f := proc (n) options operator, arrow; (1/2)*n^2+(1/2)*n end proc

proc (n) options operator, arrow; (1/2)*n^2+(1/2)*n end proc

(3)

Is there any way to do this with programming instead of copying the result of simplify manually?


 

Download define-functions.mw

Please Wait...