-1

I wish to find the value of the given equation by substituting the value of the symbolic variable 'x'. However, the output still contains the variable:

import math
from sympy import *

m = var ('x')
x = m
i = 1

while i <= 100:
    m = sin(m)
    i = i + 1

i = 1

while i <= 7:
    k = diff(m,x)
    i = i + 1

print(k.subs(x, 0))  

Output:

cos(x)*cos(sin(x))*cos(sin(sin(x)))*cos(sin(sin(sin(x))))*cos(sin(sin(sin(sin(x)))))*cos(sin(sin(sin(sin(sin(x))))))*cos(sin(sin(sin(sin(sin(sin(x)))))))*cos(sin(sin(sin(sin(sin(sin(sin(x))))))))*cos(sin(sin(sin(sin(sin(sin(sin(sin(x)))))))))*cos(sin(sin(sin(sin(sin(sin(sin(sin(sin(x))))))))))

Thank You in advance!

blhsing
  • 91,368
  • 6
  • 71
  • 106

1 Answers1

0

Answering based on the title, use

k.evalf(subs={x: 0})

But I really think you should work on your code. It is not Pythonic and probably does not serve the purpose you want.

Ta.Da
  • 68
  • 1
  • 10