Questions tagged [elementary-functions]

14 questions
15
votes
3 answers

Why does table-based sin approximation literature always use this formula when another formula seems to make more sense?

The literature on computing the elementary function sin with tables refers to the formula: sin(x) = sin(Cn) * cos(h) + cos(Cn) * sin(h) where x = Cn + h, Cn is a constant for which sin(Cn) and cos(Cn) have been pre-computed and are available in a…
Pascal Cuoq
  • 79,187
  • 7
  • 161
  • 281
8
votes
4 answers

How to compute correctly rounded trigonometric functions in degrees?

How could I define trigonometric functions that take arguments in degrees instead of the usual radians, and compute correctly rounded results for these arguments? Multiplying the argument by M_PI/180.0 before passing it to the corresponding function…
Pascal Cuoq
  • 79,187
  • 7
  • 161
  • 281
7
votes
1 answer

Apparent error in Matlab's perms function

p = perms([0:2]) p = 2 1 0 2 0 1 1 2 0 1 0 2 0 1 2 0 2 1 This function is supposed to display the permutations of a vector in reverse lexicographical order. Hence, I would expect the last…
1
vote
1 answer

initial point in CORDIC algorithm

I am trying to reduce number of iterations required to calculate multiplication using the CORDIC algorithm because I am using this algorithm in a continuous function to calculate square function. Here is the algorithm assuming -1
1
vote
1 answer

Algorithm for computing base-10 logarithm in Python

I have tried to create a program to calculate the base-10 logarithm based on the Taylor series-based algorithm described in "The Mathematical-Function Computation Handbook" (I found an online copy via my University's library). A similar algorithm is…
A.G.
  • 37
  • 8
1
vote
2 answers

how to loop over the elementary arithmetic symbols

I want to check if 7 digits can get to 100 when putting elementary arithmetic symbols between them. def is_hundred(n1,n2,n3,n4,n5,n6,n7): p = [+,-,*,/] for p1 in p: for p2 in p: for p3 in p: for p4 in p: …
1
vote
1 answer

clojure: filtering a vector of maps by keys existence and values

I have a vector of maps like this one (def map1 [{:name "name1" :field "xxx"} {:name "name2" :requires {"element1" 1}} {:name "name3" :consumes {"element2" 1 "element3" 4}}]) I'm trying to define a functions that…
Sovos
  • 3,330
  • 7
  • 25
  • 36
0
votes
1 answer

What purpose is the lookup table serving in this code?

Below I have adapted code from William Kahan and K.C. Ng (look at the comment block on the bottom) written in 1986 to produce an approximation of 1 / sqrt(x) where x is an IEEE-754 double precision floating point number. It is this code that Cleve…
0
votes
1 answer

PHP : No readable output, when I use the less than symbol, in combination with the var_dump() function

Why is in PHP this code snippet returning no readable output, $string = "Hello World!"
0
votes
1 answer

Is there any operator which I can use to attach 2 calculations?

I'm doing some homework where I use only elementary operations. I need to code a function which given a positive number, calculates the whole half of that number. My problem is at: int half(int x, int y) { return x == 0 ? y : half(x-1-1, y+1) ,…
vunax
  • 11
  • 5
0
votes
1 answer

IEEE-754 double precision and splitting method

When you compute elementary functions, you apply constant modification. Specially in the implementation of exp(x). In all these implementations any correction with ln(2) is done in two steps. ln(2) is split in two numbers: static const double ln2p1 …
0
votes
2 answers

How to define what is the elementary operation in an algorithm?

I always thought that the elementary operation from an algorithm was the operation located inside the most inner loop. I found very little detail about this in books and online articles, maybe because it was supposed to be something trivial, but the…
0
votes
1 answer

cant quite understand CORDIC algorithm for computing exponantial functions

I read a paper or two about CORDIC but can not quite understand it. however i download a code from internet that calculate exponential functions using this algorithm. it was very useful and help me impelenet a exponential term of a function on the…
-9
votes
2 answers

Java programming issue

Can anyone help me to solve this issue . I do not understand where I can put the number of the area. Also what exactly this expression mean: in.nextInt(); Here is the program: Write a Java program that reads an integer value representing the…
ayhasan20
  • 1
  • 1