+ 1

Please help me!

I have created this code for calculating a^n-b^n but I am getting wrong output:- from sympy import * a,b,z=symbols('a b z') epn=lambda w,x,y: (w-x)*summation (w**(y-z)*x**z,(z,0,y-1)) print(epn(a,b,1/2).subs(a,4).subs(b,2)) print(epn(4,2,1/2)) Desired output:-0.58... Getting output:-2.34.... 2.34.... why is that happening?

16th Jul 2017, 7:59 AM
Prabhakar Dev
Prabhakar Dev - avatar
1 Respuesta
0
try again with brackets for every operation , there's a lot going on in a single statement
21st Jul 2017, 12:10 PM
Kedar Kale
Kedar Kale - avatar