Ask Your Question
1

how to define symbolic function on functions?

asked 2021-03-24 01:03:05 +0200

Performant Data gravatar image

I recently started using Sage in earnest, and was trying to define a function on functions. But:

inner_product(f,g) = integral(f(x) * g(x), (x,0,1))
inner_product

returns:

(f, g) |--> 1/3

Not surprisingly, trying to use it, it behaves as described:

e1(x) = 1
inner_product(e1,e1)

returns:

1/3

And curiously:

inner_product(f,g) = integral(f(x) * 1, (x,0,1))
inner_product

returns:

(f, g) |--> 1/2

What's going on here?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-03-24 02:42:35 +0200

cav_rt gravatar image

Your expressions are ill defined. A python function does the job

def inner_product(f,g): return integral(f*g, (x,-pi,pi))

Thus

inner_product(sin(3*x),sin(3*x))

returns $\pi$.

See here for symbolic computation.

edit flag offensive delete link more

Comments

Thanks, I'll have a look. But what I really want to know is why I got the above results.

Performant Data gravatar imagePerformant Data ( 2021-03-24 03:08:54 +0200 )edit

I looked over your symbolic computation link but don't see anything there relevant to my question.

Performant Data gravatar imagePerformant Data ( 2021-03-24 18:03:09 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-03-24 01:03:05 +0200

Seen: 58 times

Last updated: Mar 24