How can i solve this equation?
3 views (last 30 days)
Show older comments
hi, i already tried fsolve and Levenberg-Marquart method but non of them worked
√(56,25/(tan(b)^2+1)) + √(56,25/(tan(90-a)^2+1)) = x
√(56,25-√(56,25/(tan(90-a)^2+1))) - √(56,25-√(56,25/(tan(b)^2+1))) = y
olso x and y are known random number from some sensors.
Thanks for the answers already.
1 Comment
Dr. JANAK TRIVEDI
on 1 Feb 2023
If you have tried using fsolve and the Levenberg-Marquardt method and they did not work, you may want to consider using other optimization methods in MATLAB. One alternative method you could try is the trust-region-reflective method, which is available in the Optimization Toolbox in MATLAB.
You can use the following code to solve the system of nonlinear equations using the trust-region-reflective method:
% Define the function
f = @(z) [sqrt(56.25/(tan(z(2))^2 + 1)) + sqrt(56.25/(tan(90 - z(1))^2 + 1)) - x;
sqrt(56.25 - sqrt(56.25/(tan(90 - z(1))^2 + 1))) - sqrt(56.25 - sqrt(56.25/(tan(z(2))^2 + 1))) - y];
% Define the starting point for the optimization
z0 = [30, 60];
% Call the trust-region-reflective method
options = optimoptions('fsolve', 'Algorithm', 'trust-region-reflective');
z = fsolve(f, z0, options);
Answers (1)
Sam Chak
on 1 Feb 2023
Edited: Sam Chak
on 1 Feb 2023
Hi @Yigit
Random numbers may or may not work because the 2D surfaces are trigonometric functions and bounded. If the selected numbers are outside the boundaries, then no solution exists.
In this example, I used the unit radian instead of unit degree. Also note that multiple solutions exist depending the location of the initial guess x0.

fun = @root2d;
x0 = [-1, -1];
options = optimoptions('fsolve', 'Display', 'iter');
x = fsolve(fun, x0, options)
function F = root2d(x)
F(1) = sqrt(56.25/(tan(x(2))^2 + 1)) + sqrt(56.25/(tan(pi/2 - x(1))^2 + 1)) - 10; % assume x = 10
F(2) = sqrt(56.25 - sqrt(56.25/(tan(pi/2 - x(1))^2 + 1))) - sqrt(56.25 - sqrt(56.25/(tan(x(2))^2 + 1))) - 0; % assume y = 0
end
1 Comment
John D'Errico
on 1 Feb 2023
Edited: John D'Errico
on 1 Feb 2023
+1. Good answer. It points out that often, no solution will exist at all. In that case, the method used will not help. But also, when any real valued solution does exist, then infinitely many solutions will exist, AND that the solution you do find will depend on the initial guess. This is true for any optimizer one tries to employ.
See Also
Categories
Find more on Systems of Nonlinear Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!