Ask Your Question
0

Problem with plotting "lambda" functions

asked 2020-03-13 12:20:28 -0500

albi7 gravatar image

The following code returns AttributeError

F(x, k) = gamma_inc_lower(k/2, x/2) / gamma(k/2)
plot((lambda k: find_root(F(x, k) - 1/2, 0, 100)), (k, 1, 10))

I think there is some problem with coercion of Python function to Sage function, but I have no idea how to solve it in an elegant way.

Any solution, please?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2020-03-13 16:51:30 -0500

rburing gravatar image

You need more lambdas! When you're doing numerical stuff you usually want to work with Python functions rather than symbolic expressions, like so:

plot((lambda k: find_root(lambda x: F(x, k) - 1/2, 0, 100)), (k, 1, 10))

This ensures that x and k are numbers when you write F(x,k), so it will evaluate to a number (as desired).

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2020-03-13 12:20:28 -0500

Seen: 51 times

Last updated: Mar 13