Author Topic: Trig Challenge....  (Read 7186 times)

0 Members and 1 Guest are viewing this topic.

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Trig Challenge....
« Reply #15 on: March 27, 2011, 09:59:56 pm »
Oops, messed that interval up. Looks like I'll have to redo the regression... :P
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Trig Challenge....
« Reply #16 on: March 27, 2011, 10:42:34 pm »
Isn't just abs(V)+abs(W) close enough?  Its a perfect approximation for angles close to 0 and 90 degrees and only off by about 40% in the worst case of 45 degrees.

Another way you can do this is to store you vector as a magnitude and angle.  It might make some other math complicated, but it makes it super easy to read off the magnitude (its just r).  It depends more on how you plan to use this vector.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline phenomist

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 132
  • Rating: +46/-3
    • View Profile
Re: Trig Challenge....
« Reply #17 on: March 27, 2011, 11:52:42 pm »
Assuming that the angle can be anywhere from 0 to 90 degrees, uniformly distributed, using a bit of calculus we get that the ratio is on average pi/4, or .785398. 11/14 is a sufficient approximation for this. So (abs(V)+abs(W))*11/14 provides a fairly good approximation, erring at most by 10% for angles between 10 and 80 degrees.

If you need a linear approximation that reduces the error necessary, the constant that you are looking for is e^(2C/pi-ln(2)/2) (C being Catalan's constant), or about .789348. 15/19 is a sufficient approximation for this.
« Last Edit: March 27, 2011, 11:59:13 pm by phenomist »
Level Designer for Graviter

[Disclaimer: I can't program for my life.]