# Thread: Problems using Math Module

1. ## Problems using Math Module

Hey,

I'm trying to make a simple application that should be able to resolve a second degree equation. The script is working but where it should be displayed the result, it's displaying NaN

So, here is the code:

Code:
```import appuifw
from math import sin,cos,tan,sqrt,log

op=1

#Calculate
while (op!=2):

a = float(appuifw.query(u"A:", "number"))#This number should multiply x^2
b = float(appuifw.query(u"B:", "number"))#This number should multiply x
c = float(appuifw.query(u"C:", "number"))#This number should  be alone

#Example: x^2-x-20=0      a:1  b:-1  c:-20

#Delta

delta=(pow(b,2))-(4*a*c)#Delta formula

if (delta<0):

print (u"Delta Negativo") #The equation is impossible

else:
x1=((b*-1)+sqrt(delta))/2*a #First possibility for X
x2=((b*-1)-sqrt(delta))/2*a #Second possibility for X

#The equation is possible

continueoption=appuifw.popup_menu([u"%.1f" % (x1), u"%.1f" % (x2), u"Quit"])
if(continueoption==1):op=2```

Any ideia of why it's displaying NaN?

http://wiki.forum.nokia.com/index.ph...ple_calculator

Any help will be very useful.

Thanks!!!

2. ## Re: Problems using Math Module

Problem Solved =)

3. ## Re: Problems using Math Module

Hey Rafael T. please tell how did you solve the problem, so that it can be handy for me and everyone if someone encounters same problem.

4. ## Re: Problems using Math Module

I solved by using A,B and C as a text instead of number ... so it can be negative!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•