Efficient Algorithm for Calculating (n^x)/d

  • Thread starter Thread starter Atran
  • Start date Start date
AI Thread Summary
The discussion presents an efficient algorithm for calculating (n^x)/d using a recursive approach. It demonstrates the process with an example where n=46, x=5, and d=13, breaking down the division into manageable components. The algorithm utilizes the quotient and remainder from the division to simplify the calculations for higher powers of n. The method emphasizes a structured recursive formula to handle the exponentiation and division efficiently. Overall, the algorithm aims to optimize the computation of (n^x)/d for large values of n and x.
Atran
Messages
93
Reaction score
1
Hi, I've recently found the following algorithm and I'm willing to share it:

For example, given an integer n=46, an exponent x=5, and d=13, we have 465/13.
First, we set the equation, n = q*d + r = q*13 + r
We have, 46 = 3*13 + 7
Thus, [q=3, r=7, d=13]
And: 465/13 = 3*464 + 7*(3*463 + 7*(3*462 + 7*(3*461 + 7*(46/13))))

Let [q, r, d] and we have (n^4)/d, then:
(n^4)/d = q*n^(4-1) + r*(q*n^(4-2) + r*(q*n^(4-3) + r*(n/d)))

I don't know if it's interesting to you or not, but what are your thoughts about it?
 
Mathematics news on Phys.org
Perhaps you'll get more comments if you write the expression in a less computationally efficient manner.

\frac{(qd + r)^5}{d} = q(qd+r)^4 + rq(qd+r)^3 + r^2q(qd+r)^2 + r^3q(qd+r) + r^4\frac{(qd+r)}{d}
 
Thread 'Video on imaginary numbers and some queries'
Hi, I was watching the following video. I found some points confusing. Could you please help me to understand the gaps? Thanks, in advance! Question 1: Around 4:22, the video says the following. So for those mathematicians, negative numbers didn't exist. You could subtract, that is find the difference between two positive quantities, but you couldn't have a negative answer or negative coefficients. Mathematicians were so averse to negative numbers that there was no single quadratic...
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Thread 'Unit Circle Double Angle Derivations'
Here I made a terrible mistake of assuming this to be an equilateral triangle and set 2sinx=1 => x=pi/6. Although this did derive the double angle formulas it also led into a terrible mess trying to find all the combinations of sides. I must have been tired and just assumed 6x=180 and 2sinx=1. By that time, I was so mindset that I nearly scolded a person for even saying 90-x. I wonder if this is a case of biased observation that seeks to dis credit me like Jesus of Nazareth since in reality...

Similar threads

Back
Top