Arccos function

NMODL and the Channel Builder.
Post Reply
Eleftheria Pissadaki

Arccos function

Post by Eleftheria Pissadaki »

Dear Forum,

I am looking for the arccos function, any suggestions?

Thanks in advance,

Eleftheria
ted
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Arccos function

Post by ted »

atan is built in. If you need arccos, you can write your own using atan.
Eleftheria Pissadaki

Re: Arccos function

Post by Eleftheria Pissadaki »

Thank you very much Ted, for the record this is the function I used:

Code: Select all

func acos() {
   denom = 1 - $1 * $1
   if (denom == 0.0) {
       return PI/2
   } else{
       return PI/2 - atan($1 / sqrt(denom))
    }
}
Moderator's note: message edited to insert code markup.
ted
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Arccos function

Post by ted »

I think you meant this:

Code: Select all

func acos() {
  if ($1==0) {
    return PI/2
  } else {
    return atan(sqrt(1-$1^2)/$1)
  }
}
Post Reply