how I solve the two equation and two unknown variables using 'levenberg-marquardt' method?

7 views (last 30 days)
I wnat to solve follow two equations.
F = @(X) [d(1,3).*(abs(X(1)./(X(2).^2.*ar))+d(2,3).*(X(1)./(X(2).^2.*ar))).^d(3,3).*(bg_loc_M)+d(4,3).*(X(2)).^d(5,3)-l./X(2);
abs(c(1,3)).*(bg_loc_M).^c(2,3).*X(2).^c(3,3).*(ar).^c(4,3).*exp(-abs(c(5,3)).*abs(X(1)+c(6,3).*abs(X(1))).^abs(c(7,3)))-foc];
here, I don't know X(1) & X(2), and kown others
how I solve the X(1) and X(2)?
I want to use levenberg-marquardt method.
I did follow.
F = @(X) [d(1,3).*(abs(X(1)./(X(2).^2.*ar))+d(2,3).*(X(1)./(X(2).^2.*ar))).^d(3,3).*(bg_loc_M)+d(4,3).*(X(2)).^d(5,3)-l./X(2);
abs(c(1,3)).*(bg_loc_M).^c(2,3).*X(2).^c(3,3).*(ar).^c(4,3).*exp(-abs(c(5,3)).*abs(X(1)+c(6,3).*abs(X(1))).^abs(c(7,3)))-foc];
x0=[0 l];
opts.Algorithm = 'levenberg-marquardt';
opts.TolX = 1e-10;
recal=fsolve(F,x0,opts);
But, results of X(1) & X(2) are different real value.....
I need your advice.

Answers (1)

Nipun
Nipun on 31 May 2024
Hi SungMin,
I understand that you want to solve the following system of equations using the Levenberg-Marquardt method in MATLAB, but the results for 𝑋(1) and 𝑋(2) are not as expected.
Here's a revised approach to ensure you correctly use the fsolve function with the Levenberg-Marquardt algorithm:
% Define the function
F = @(X) [d(1,3)*(abs(X(1)/(X(2)^2*ar))+d(2,3)*(X(1)/(X(2)^2*ar)))^d(3,3)*(bg_loc_M)+d(4,3)*(X(2))^d(5,3)-l/X(2);
abs(c(1,3))*(bg_loc_M)^c(2,3)*X(2)^c(3,3)*(ar)^c(4,3)*exp(-abs(c(5,3))*abs(X(1)+c(6,3)*abs(X(1)))^abs(c(7,3)))-foc];
% Initial guess
x0 = [0, l];
% Set options for fsolve
opts = optimoptions('fsolve', 'Algorithm', 'levenberg-marquardt', 'TolX', 1e-10, 'Display', 'iter');
% Solve the system of equations
[X, fval, exitflag, output] = fsolve(F, x0, opts);
% Display the results
disp(['X(1) = ', num2str(X(1))]);
disp(['X(2) = ', num2str(X(2))]);
% Check the output status
if exitflag <= 0
disp('The solver did not converge to a solution.');
else
disp('The solver converged to a solution.');
end
Ensure that the initial guess x0 is close to the expected solution and that all parameters (d, ar, bg_loc_M, l, c, foc) are correctly defined.
You can refer to the MathWorks documentation for more details on fsolve and its options: https://www.mathworks.com/help/optim/ug/fsolve.html
Hope this helps.
Regards,
Nipun

Categories

Find more on Mathematics in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!