esandier
esandier

Reputation: 165

How to inhibit evaluation of functions in sympify?

sympify('atan(sqrt(3))') returns pi/3. Same thing for sympify with the evaluate = false tag.

Is it possible to convert the 'atan(sqrt(3))' string to the atan(sqrt(3)) sympy object ?

This is required for online math tests : if a question is 'what is atan(sqrt(3)) ?', the answer 'atan(sqrt(3))' is not acceptable, thus should be distinguishable from 'pi/3'.

Upvotes: 1

Views: 83

Answers (1)

Stelios
Stelios

Reputation: 5531

Based on a previous answer by @asmeurer:

import sympy as sp

with sp.evaluate(False):
    phi = sp.atan(sp.sqrt(3))

print(phi)

atan(sqrt(3))

Upvotes: 1

Related Questions