Bug report: sqrt(), i

Bug report: sqrt(), i

Postby tbabcock123 » Sun Mar 31, 2013 8:43 am

The radical function (sqrt) does not work. The cell will show red with the function and argument displayed inside. Also, the value i is available and when squared gives -1, however the square root of -1 (available as -1^0.5) evaluates to NaN. This is inconsistent ( and wrong).

reply: discovered the error for the first problem. had inadvertently created a mech with the name 'sqrt'. this caused a conflict within the system. renaming the mech fixed the problem. :o
Last edited by tbabcock123 on Sun Mar 31, 2013 2:29 pm, edited 1 time in total.
tbabcock123
 
Posts: 3
Joined: Sat Mar 30, 2013 8:54 am

Re: Bug report: sqrt(), i

Postby joe » Sun Mar 31, 2013 10:23 am

Thanks for the bug report.

For the first problem what is the argument you are using?

As for the 2nd problem:

Actually, the SQRT function used to work as you described. In order for that to work however the SQRT function had to return a complex number. Which is fine if one is working with complex numbers, however most of the time people are just using reals. Many functions and Mechs don't work with complex numbers.

I tried to resolve this issue by detecting if the result contained an imaginary component and casting it to real if it didn't. However, this cast was done only at the end of a calculation. So if a person used the SQRT function in the middle of the equation, problems would persist.

I finally decided, that I really just needed two versions of the SQRT function. One for reals and one for complex numbers. In your case you are getting the SQRT for reals when you want the SQRT for complex numbers. The way to tell Oovium which one you want is through the input data type.

If you want the real sqrt use a real input. If you want the complex sqrt use a complex input.

In your case for the number -1 there are two ways to cast it to complex. One is you can add 0i to it, for example: sqrt(-1+0*i). Or you can use the Complex constructor like this: sqrt(Complex(-1,0)).

Let me know if any of this isn't clear. Also, any other feedback on using complex numbers is much appreciated. Shockingly, (to me at least) this is the first report I have ever gotten in the last 4 years of someone using the complex number feature in Oovium. So, it's good to know it's getting some use!
User avatar
joe
Site Admin
 
Posts: 241
Joined: Thu Jul 16, 2009 3:19 am

Re: Bug report: sqrt(), i

Postby tbabcock123 » Mon Apr 01, 2013 9:03 pm

see reply in original post regarding silly error.
tbabcock123
 
Posts: 3
Joined: Sat Mar 30, 2013 8:54 am

Re: Bug report: sqrt(), i

Postby joe » Tue Apr 02, 2013 1:41 pm

Ok cool.. thanks.

Actually, I would probably still consider that a bug. I really need to handle that situation better. Perhaps the best is to just prevent a user from overriding a standard equation.

However, in general I have some work to do in handling function conflicts considering the possibility of multiple libraries containing the same Mech names and such.

Ultimately, each aether should be consider a new namespace with possibly the standard functions existing in their own namespace.

At any rate, thanks again for the feedback.
User avatar
joe
Site Admin
 
Posts: 241
Joined: Thu Jul 16, 2009 3:19 am

Re: Bug report: sqrt(), i

Postby tbabcock123 » Tue Apr 02, 2013 6:21 pm

in matlab if you name a function the same as a native function, that function takes precedence (until you clear the custom function). that concept extends to constants. so if you rename e to something other than the natural logarithm then it retains that value until you clear it.
tbabcock123
 
Posts: 3
Joined: Sat Mar 30, 2013 8:54 am

Re: Bug report: sqrt(), i

Postby joe » Tue Apr 02, 2013 6:42 pm

Yes, I think that is the correct way to do it. (And I think what I would have in mind with namespaces)

The local aether would take precedence over imported aethers and built in equations, but you could still access them using dot notation perhaps.

sqrt()
Library.sqrt()
Oovium.sqrt()

At any rate, I need to do some work in order to get that up and running.
User avatar
joe
Site Admin
 
Posts: 241
Joined: Thu Jul 16, 2009 3:19 am


Return to Oovium

Who is online

Users browsing this forum: No registered users and 1 guest

cron