English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

using only multiplication, add , sub opperations

Thanks

2006-11-16 19:14:21 · 3 answers · asked by garikll 1 in Science & Mathematics Mathematics

3 answers

If you want an analytical method, use a Taylor series.
If you want an iterative method (successive approximation, to arbitrary precision), use the CORDIC algorithm.
There are surely heaps of other methods.

Taylor series:
arcsin z = z + (1/2) z^3/3 + (1*2)/(3*4) z^5/5 + (1*3*5)/(2*4*6) z^7/7 + ...
See http://en.wikipedia.org/wiki/Arcsin#Infinite_series

CORDIC algorithm:
CORDIC is an iterative (not analytical) method involving shift-and-add/subtract, and some table lookup.
It doesn't even use multiplication! It's very efficient for both hardware and software implementations.
http://en.wikipedia.org/wiki/CORDIC

As to gp4rts's comment, by "division" I presume you mean the hard kind, i.e. floating-point division esp. by a variable not an integer constant. 1/(2*4*6) is pretty trivial stuff.
For what it's worth both logarithms and square-rooting require either division and/or iterative methods (http://en.wikipedia.org/wiki/Division_%28electronics%29).

So the bottom line is if you want to avoid *all* division, even the easy integer stuff, use CORDIC. CORDIC is commonly used in chips today, it's a very compact implementation whose speed is good-enough for many applications, and can be pipelined.

2006-11-16 19:22:18 · answer #1 · answered by smci 7 · 0 0

The Taylor series requires division to compute the coefficients. There is a logarthmic form but it involves imaginary nos and a square root.

2006-11-16 19:36:36 · answer #2 · answered by gp4rts 7 · 0 0

The code 'ip.c.2 != 0' exams if the quantity is weird and wonderful, which isn't what you prefer. you ought to try this: bool ispow2(int j) { int bits=0, i; for(i=0; i<=j; i) if((j&i)!=0) bits++; return bits==a million; } then you definately can use: if(!ispow2(i)) proceed; The code counts the form of bits set in the quantity. Powers of two have purely one bit set.

2016-10-22 05:58:03 · answer #3 · answered by ? 4 · 0 0

fedest.com, questions and answers