Questions tagged [evalf]

9 questions
2
votes
1 answer

How can I substitute the value of one variable in a multivariate function?

Suppose, I have a function f(x,y)=x2+y2. Now, I would like to substitute x=2, keeping y symbolic. I tried with f.evalf(subs={x:2}) But it is not substituting the value of x, and just giving me the original expression.
1
vote
0 answers

A bug in the symbolic determinant or evalf?

I find a serious but unexplainable bug in the evalf function when evaluating a symbolic determinant of a matrix, see MWE below import sympy z1,z2,z3,mv1,mv2,mv3,R,T,D12,D23,D13,D14,D24,D34,x1,x2,x3 =…
user3196617
  • 156
  • 2
  • 6
1
vote
0 answers

Wrong result of evalf in SymPy but only for some values of the precision

I think I have encountered a bug of Sympy's evalf() method with substitutions passed. By accident, I found an expression that evaluates to a wrong value if I replace the variable x by an integer rather than a Float. The funny thing is that this…
MannyC
  • 288
  • 2
  • 11
1
vote
1 answer

Evaluating coefficients but not exponents in sympy

I'm using sympy to do a nonlinear solve over a set of power laws, and I end up with a bunch of solutions like 20394*sqrt(6)*x**(2/3)*y**(1/4) I want to collapse the numerical coefficients while leaving the rational nature of the exponents exposed,…
user2275987
  • 129
  • 11
0
votes
1 answer

Sympy calculus: when evaluating a sympy expression, python outputs log(2), and e^0.3, as symbols, instead of computing their value

So I have to write a python script for finding the root of a function using Newton's Method, and my code isn't computing a float when evaluating the derivative at a point, it's only evaluating the sin(x) part, leaving e^x and log(2) as they are. I'm…
0
votes
1 answer

How to substitute data frame columns in mathematics equations in python?

I have a issue with sympy, I have a data frame columns which has to be calculated with a formula and the formula is in string format I am using sympy it's taking only one value but not the series value my code import sympy def…
Ram dr
  • 111
  • 5
0
votes
0 answers

evalf is not producing numerical result for a algebraic expression

I have this sympy expression. I am not sure why evalf function doesn't properly evaluate this expression and still I don't get an actual numerical value out of it? value = {t1: _t1, t2: _t2, t3: _t3, x_mid: _x_mid, theta: _theta, focal_length:…
Mona Jalal
  • 34,860
  • 64
  • 239
  • 408
0
votes
1 answer

Error evaluating a derivative on Python (with .subs, .evalf and .lambdify)

I am trying to separately compute the elements of a Taylor expansion and did not obtain the results I was supposed to. The function to approximate is x**321, and the first three elements of that Taylor expansion around x=1 should be: 1 + 321(x-1) +…
0
votes
2 answers

Evaluate as many parameters as possible (SymPy)

I have this code in SymPy: from sympy import * par_amplitude, par_const_force = symbols('Delta_U f') equation = par_amplitude * par_const_force print(equation.evalf(subs={'f':3, 'Delta_U':2})) The output is obviously 6. My problem occurs when I…
alex
  • 10,900
  • 15
  • 70
  • 100