With time = money (or resources - CPU time, cash, space, etc.), it is impossible to succeed if too much of a limited resource is expended in non-productive ways. Any engineering project depends on control of all four of these aspects - methods, materials, money, and people. ![]() Joe - TIME is of the essence in these competitions. Admittedly, using this method is somewhat like climbing down the chimney because the doors are locked, but at least it will get you in the house. I am not a Pbasic programmer, so I can’t say how best to do the translation, but I know that there are plenty of clever FIRST people out there. If it works for values of a near -1, 0, and 1, it is probably OK. The easiest way to settle the matter is to code it up and run it. Frankly, I have not given sufficient thought to the ramifications of this to be able to state in advance how it will affect the calculations. The last remaining problem I can see in the translation of this algorithm to Pbasic is that language’s use of “two’s complement” arithmetic for negative values. This value can be adjusted to converge to a sufficiently accurate value in a reasonable time. Here I have used a constant, epsilon, with a small value (1E-7) to determine when the value of X is sufficiently close to the true value that the iteration may be stopped. Repeat x := x - (sin(x)-a)/cos(x) until (abs(sin(x)-a) <= epsilon) Īgain, note that the value of x returned is in radians, Here is an example of a function written in Pascal to calculate the arcsin of a given value. Both x and a must be expressed in radians the arcsin function takes values between -pi/2 and pi/2 only (-90° to 90°). In fact, for small values of a, this is very close to the true value of X. Because the sine function is “well behaved” - it does not have asymptotes and imaginary roots - a good initial value is X0 = a. The remaining part of the problem to be determined is the value of the “initial guess” X0. In this case we have defined f(X) = sin (X) - a, and so we can calculate Newton’s Method is an iterative formula for numeric determination of the “zeroes” of a differentiable function f(X), starting from an initial value X0 sufficiently close to the true value of X : The problem is now to determine the value of X that makes this statement true. Restate the problem as sin(X) = a (by taking the sine of both sides), and define a function f(X) = sin(X) - a = 0. An Algorithm for Calculating the Inverse Sine of a Given Valueīecause the Pbasic program does not support an inverse sine function, the calculation of the inverse sine of a given number a, where -1 <= a <= 1, requires development of an algorithm that can be translated into a Pbasic function.Ĭonsider that the problem can be stated : Find the value of X such that X = arcsin(a).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |