Ask Your Question

MaybE_Tree's profile - activity

2022-01-20 09:17:58 +0100 received badge  Popular Question (source)
2021-02-25 21:16:49 +0100 received badge  Student (source)
2021-02-25 20:07:47 +0100 asked a question Evaluate constants in symbolic expression?

Hello. If I have a symbolic expression where all of the variables are known, I can use numerical_approx to evaluate it:

var('a b')
x = a / b
x(a=1, b=3)
> 1/3
x(a=1, b=3).numerical_approx()
> 0.333333333333333

However, if there is an unknown variable, numerical_approx fails:

var('a b c')
x = a / b * c
x(a=1, b=3)
> 1/3*c
x(a=1, b=3).numerical_approx()
> TypeError: cannot evaluate symbolic expression numerically

Is there a way to approximate the values of all constants / coefficients in a symbolic expression? Essentially, something like

var('a b c')
x = a / b * c
x(a=1, b=3).numerical_approx_constants()
> 0.33333333333*c

Thank you in advance.