Transcendental equation in two variables
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a transcendental equation in two variables x and y as (x^2-y^2)*(-y^2+1+0.015*x^4)*xi*besselj(1,xi)+y^2*0.005*besselj(0,xi))-0.0091x^2*y^2*besselj(1,xi)*xi=0, where xi=sqrt(0.041*y^2-x^2), y varies from 0 to 3. I want to solve this equation numerically such that I can get the purely real x, purely imaginary x and complex x. And each type of roots have four or five branches. I tried to solve it using fsolve but I am not getting the solutions separately.
1 commentaire
Torsten
le 27 Déc 2023
And each type of roots have four or five branches. I tried to solve it using fsolve but I am not getting the solutions separately.
Given a value for y, you expect four or five different solutions for x ? And you don't get them all in one call to fsolve ? Or what exactly do you mean here ?
Réponses (1)
Hassaan
le 27 Déc 2023
Déplacé(e) : Torsten
le 27 Déc 2023
To run this code in MATLAB:
- Save the function in a .m file, for example, complex_root_finding.m.
- Execute the function in MATLAB command window by typing complex_root_finding.
This script defines a function complex_trans_eq that computes the real and imaginary parts of the transcendental equation and uses fsolve to find the roots. The results will be printed to the MATLAB command window. The initial guess z0 may need to be adjusted based on the specifics of the equation to ensure proper convergence.
complex_root_finding()
function complex_root_finding
% Define the range for y
y_values = linspace(0, 3, 100);
% Store the solutions
solutions = [];
% Options for fsolve
options = optimoptions('fsolve', 'Display', 'none');
% Loop over the range of y values
for y = y_values
% Define the system of equations for real and imaginary parts
fun = @(z) complex_trans_eq(z, y);
% Initial guess: Change this if necessary
z0 = [0, 0];
% Solve the system of equations using fsolve
[z_sol, fval, exitflag] = fsolve(fun, z0, options);
% If a solution is found, store it
if exitflag > 0 % Solution converged
solutions = [solutions; [z_sol, y]];
end
end
% Display the solutions
disp('Solutions (x_real, x_imag, y):');
disp(solutions);
end
function F = complex_trans_eq(z, y)
x_real = z(1);
x_imag = z(2);
x = x_real + 1i * x_imag;
xi = sqrt(0.041*y^4*x^2 - x^2);
% Real part of the function
F_real = real((x^2 - y^2)*(y^2 + 1 + 0.015*x^4)*x*besselj(1, xi) + ...
y^2*0.005*besselj(0, xi) - 0.0091*x^2*y^2*besselj(1, xi));
% Imaginary part of the function
F_imag = imag((x^2 - y^2)*(y^2 + 1 + 0.015*x^4)*x*besselj(1, xi) + ...
y^2*0.005*besselj(0, xi) - 0.0091*x^2*y^2*besselj(1, xi));
% Return a vector of the real and imaginary parts
F = [F_real; F_imag];
end
Code may need to be adjusted as per your needs. Thank you.
-----------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
0 commentaires
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!