Why is my function giving non-real results?

For the discussion of math. Duh.

Moderators: gmalivuk, Moderators General, Prelates

User avatar
Mathmagic
It's not as cool as that Criss Angel stuff.
Posts: 2926
Joined: Thu Nov 30, 2006 12:48 am UTC
Location: In ur fora posting in teh threads

Why is my function giving non-real results?

Postby Mathmagic » Wed Sep 24, 2008 8:01 pm UTC

I'm working on an assignment for school right now, and I have come across a hiccup in one of the functions I've come up with. The background details aren't relevant to the problem, but all you need to know is this:

My four functions are -

[imath]\phi_1(x)=\arccos{\frac{-x}{\sqrt{x^2+10000}}}[/imath]

[imath]\phi_2(x)=\arccos{\frac{\frac{200}{\tan{\pi/3}} - x}{\sqrt{(\frac{200}{\tan{\pi/3}} - x)^2 + 90000}}}[/imath]

[imath]\phi_3(x)=\arccos{\frac{20-x}{\sqrt{(20-x)^2+10000}}}[/imath]

[imath]\phi_4(x)=\arccos{\frac{20+\frac{200}{\tan{\pi/3}} - x}{\sqrt{(20+\frac{200}{\tan{\pi/3}} - x)^2 + 90000}}}[/imath]

Now here's the problem:

functionsgraphdiverge.JPG
functionsgraphdiverge.JPG (9.08 KiB) Viewed 1200 times


That is the plot of all four functions, where all but ONE of the functions behave as you would expect within the domain I need (that is, [-500,500]), but one of them, [imath]\phi_2(x)[/imath], does not. It seems to terminate at around [imath]x=-200[/imath], and as it turns out, becomes a complex value.

What's even more confusing is that all the functions have the same limit (as I would expect), but like I said, one of them decides to give complex values for a certain (and currently unknown) range of x-values. This range of values turns out to be [imath](-\infty,~-200][/imath].

So I come to you asking if there is a rhyme or reason for this behaviour, based on the functions I have shown you.

I can scan in the diagram where I derived these functions from if it would help diagnose the issue. To put it simply, these are values of the angle the horizontal makes with a vector pointing to a set of four fixed points, with a variable point along the horizontal as the origin of each of the four vectors. I derived these expressions using a simple scalar product (a unit vector of (1,0) dotted with four different unit vectors, each dependent on x).

Thanks in advance for your help. :)

EDIT: I've discovered that [imath]\phi_2(x)[/imath] becomes complex-valued for ALL values less than ~-200. This is why [imath]\lim_{x\rightarrow -\infty} \phi_2(x)=0[/imath]; there is no REAL part of the value left, as it's completely complex.
Last edited by Mathmagic on Wed Sep 24, 2008 8:18 pm UTC, edited 1 time in total.
Axman: That, and have you played DX 10 games? It's like having your corneas swabbed with clits made out of morphine.
Pathway: cocks cocks cocks

User avatar
crazyjimbo
Posts: 887
Joined: Fri Apr 20, 2007 11:45 pm UTC
Location: Durham, England
Contact:

Re: Why is my function giving non-real results?

Postby crazyjimbo » Wed Sep 24, 2008 8:16 pm UTC

Graphing your first and second functions I get the following:

Screenshot.png
phi_1 and phi_2
Screenshot.png (42.19 KiB) Viewed 1179 times


Is it possible you entered the second function into your grapher wrongly? Or did I?

Token
Posts: 1481
Joined: Fri Dec 01, 2006 5:07 pm UTC
Location: London

Re: Why is my function giving non-real results?

Postby Token » Wed Sep 24, 2008 8:18 pm UTC

I think the function was entered incorrectly. [imath]\left|\frac{a}{\sqrt{a^2+90000}}\right|[/imath] can never be greater than 1, no matter what the value of a.
All posts are works in progress. If I posted something within the last hour, chances are I'm still editing it.

User avatar
Mathmagic
It's not as cool as that Criss Angel stuff.
Posts: 2926
Joined: Thu Nov 30, 2006 12:48 am UTC
Location: In ur fora posting in teh threads

Re: Why is my function giving non-real results?

Postby Mathmagic » Wed Sep 24, 2008 8:36 pm UTC

@crazyjimbo: I definitely didn't enter it incorrectly -

F1F2Graph.JPG
F1F2Graph.JPG (18.36 KiB) Viewed 1140 times


@Token: That's what confused me the most. I checked to make sure my domain wasn't restricted, and it all checked out just fine.

What's even more weird is that when I evaluate the second function "manually" within Mathematica (i.e. by writing out the expression explicitly with the values in place of x instead of as a function of x), I get a real value as expected. However, when I evaluate the VERY SAME expression, but by typing F2[-500] instead of explicitly typing out the expression with "-500" instead of "x", I get a complex value.

This is starting to seem like a software bug to me...

EDIT: Well... this is awkward. It turns out that somewhere along the line, I had entered in the wrong formula for the second function, but then at another time, corrected it to the right one. Despite this, Mathematica reassigned the text of the function, but had kept the actual value of the function the same (that being the *wrong* function).

Man, I feel stupid. I'm just getting used to using Mathematica (as well as MATLAB and TeX language), so I can't really recognize these issues as easily as other people.

Thanks for all your help guys! :)
Axman: That, and have you played DX 10 games? It's like having your corneas swabbed with clits made out of morphine.
Pathway: cocks cocks cocks


Return to “Mathematics”

Who is online

Users browsing this forum: No registered users and 9 guests