Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

TAN to the power of n

  • 14-11-2012 7:19pm
    #1
    Registered Users, Registered Users 2 Posts: 347 ✭✭


    Howdy.

    I'm a reasonably numerate Ecologist (mostly statistics), but it is a long time since I used trigonometry...possibly not since school.

    I am writing a piece of script in R to re-project geographic data points (with lat-long coordinates) to a projected coordinate system (Lambert conformal conic) used for certain types of mapping. I'm pretty ok with all of the concepts behind the coordinates and projections, but in trying to convert my values with a bit of R code I'm hitting a barrier.

    One of the parameters I need to calculate for the projection, is phrased as:

    F = (cos(a) * tan^n(b))n

    R is returning an NaN (not a number), and when I tried to calculate it in excel earlier it was returning an error.

    Is it possible to have this type of argument, where TAN is raised to a power?

    If so, is there some convention for calculating it long-hand, as it is not recognised on the platforms I'm using.

    Thanks.


Comments

  • Registered Users, Registered Users 2 Posts: 6,465 ✭✭✭MOH


    Instead of tan^n(b), try tan(b)^n. Or possibly (tan(b))^n.

    Using tan^n is trying to raise the name of the function to a power, rather than the result of the function. If that makes sense.


  • Registered Users, Registered Users 2 Posts: 347 ✭✭Mr. Boo


    MOH wrote: »
    Instead of tan^n(b), try tan(b)^n. Or possibly (tan(b))^n.

    Using tan^n is trying to raise the name of the function to a power, rather than the result of the function. If that makes sense.

    Thanks MOH. Yeah, that makes perfect sense. I was just wary of whether I was performing the correct operation. I'll give it a lash later on and see how it goes...


  • Registered Users, Registered Users 2 Posts: 347 ✭✭Mr. Boo


    So the problem may be deeper than just the phrasing of the equation in R....

    It appears that due to the order of operations, an NaN is returned. I think this has something to do with having a negative function to the power of n.

    So, for example:
    (3-8)^1.2, returns NaN

    I kind of understand why this is, and I have found some mention of it online.

    The suggested fix is to convert the function to a complex number?

    i.e. (3-8+0i)^1.2

    But I really don't understand the logic behind this, or the outputs...

    Any ideas?


Advertisement