A How to use the Newton-Raphson method while keeping the sum constant?

AI Thread Summary
The discussion focuses on using the Newton-Raphson method to solve high-dimensional equations while maintaining a constant sum of solutions. The user has attempted various methods, including normalizing the solution vector and extending the matrix to incorporate the constraint, but has not achieved success. It is suggested that adding the constant sum as an unknown variable may help avoid issues with having more equations than unknowns. Additionally, using SciPy's existing root-finding methods could simplify the process, as they offer options for handling Jacobians. The conversation emphasizes the importance of clearly defining the problem and considering step size adjustments for better results.
K-Manu
Messages
7
Reaction score
0
Question: How to find solutions using Newton-Raphson method with keeping the sum of solutions?

I am currently working on solving a high-dimensional equation to obtain accurate solutions using the Newton-Raphson method, which I have implemented in Python.
However, my problem requires that the sum of the solutions must equal a constant value, z, which I set. Despite trying several approaches to enforce this constraint, I have not yet achieved the desired result.
For example, I attempted the following methods:
  1. Ensuring that the sum of the updates sum(dx) → 0
  2. Normalizing the solution vector by setting x/sum(x)*z
  3. Extending the matrix to incorporate the constraint (as shown in my Python code, which I discussed here: Stack Overflow link).
Unfortunately, these approaches have not yielded the expected results.
Any mathematical insights or tips would be greatly appreciated.
 
Mathematics news on Phys.org
Please explain "the sum of the solutions". If you mean <br /> \left.\begin{array}{c}<br /> f_1(x_1, \dots, x_n) = 0 \\<br /> \vdots \\<br /> f_n(x_1, \dots, x_n) = 0<br /> \end{array}\right\}\mbox{ subject to }\sum_{i=1}^n x_i = z then that is n + 1 equations in n unknowns, which might not have any solutions; you can avoid that issue by adding z as an unknown and starting with an initial guess with z equal to your chosen value. But again, there may just not be any solutions for that value of z, or the choice of initial guess for the other x_i might be in the domain of attraction of a fixed point which does not satisfy your constraint. Adding z as an unknown is equivalent to solving <br /> g_i(x_1, \dots, x_{n-1}, z) = f_i(x_1, \dots, x_{n-1}, z - (x_1 + \dots + x_{n-1})) = 0 which can be done using standard methods.

SciPy already has a library of root finding methods (see scipy.optimize); you don't need to write your own. Those methods which require the jacobian will allow you to either supply a function which computes is analytically, or indicate that the objective function returns both the function value and the jacobian, or you can not supply one and the method will use its own numerical approximation. O you can use one of the methods which don't require the jacobian att all.

If you tell us the exact problem you are trying to solve, we may be able to provide better advice.
 
Last edited:
Have you played with the step size?

Finer steps often lead to better results.

Does the problem meet the criteria for using a Newton-Raphson approach?

I know in the case of Euler numerical approaches, we choose the method based on whether the system oscillates or not, as some methods introduce errors over time, and this error manifests as energy added or subtracted from the system.
 
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...
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...
Thread 'Imaginary Pythagoras'
I posted this in the Lame Math thread, but it's got me thinking. Is there any validity to this? Or is it really just a mathematical trick? Naively, I see that i2 + plus 12 does equal zero2. But does this have a meaning? I know one can treat the imaginary number line as just another axis like the reals, but does that mean this does represent a triangle in the complex plane with a hypotenuse of length zero? Ibix offered a rendering of the diagram using what I assume is matrix* notation...
Back
Top