How can i solve this equation?

2 visualizzazioni (ultimi 30 giorni)
Yigit
Yigit il 1 Feb 2023
Modificato: John D'Errico il 1 Feb 2023
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 Commento
Dr. JANAK TRIVEDI
Dr. JANAK TRIVEDI il 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);

Accedi per commentare.

Risposte (1)

Sam Chak
Sam Chak il 1 Feb 2023
Modificato: Sam Chak il 1 Feb 2023
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)
Norm of First-order Trust-region Iteration Func-count f(x) step optimality radius 0 3 0.156966 2.22 1 1 6 0.12467 0.35606 2.07 1 2 9 4.36636e-05 0.0524068 0.0371 1 3 12 9.40002e-12 0.00110673 1.72e-05 1 4 15 4.47496e-25 5.28618e-07 3.75e-12 1 Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient.
x = 1×2
-0.7297 -0.8411
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 Commento
John D'Errico
John D'Errico il 1 Feb 2023
Modificato: John D'Errico il 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.

Accedi per commentare.

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by