Borrar filtros
Borrar filtros

Transcendental equation in two variables

11 visualizaciones (últimos 30 días)
RAJAT
RAJAT el 27 de Dic. de 2023
Comentada: Torsten el 27 de Dic. de 2023
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 comentario
Torsten
Torsten el 27 de Dic. de 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 ?

Iniciar sesión para comentar.

Respuestas (1)

Hassaan
Hassaan el 27 de Dic. de 2023
Movida: Torsten el 27 de Dic. de 2023
To run this code in MATLAB:
  1. Save the function in a .m file, for example, complex_root_finding.m.
  2. 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()
Solutions (x_real, x_imag, y): 0 0 0 0 0 0.0303 0 0 0.0606 0 0 0.0909 0 0 0.1212 0 0 0.1515 0 0 0.1818 0 0 0.2121 0 0 0.2424 0 0 0.2727 0 0 0.3030 0 0 0.3333 0 0 0.3636 0 0 0.3939 0 0 0.4242 0 0 0.4545 0 0 0.4848 0 0 0.5152 0 0 0.5455 0 0 0.5758 0 0 0.6061 0 0 0.6364 0 0 0.6667 0 0 0.6970 0 0 0.7273 0 0 0.7576 0 0 0.7879 0 0 0.8182 0 0 0.8485 0 0 0.8788 0 0 0.9091 0 0 0.9394 0 0 0.9697 0 0 1.0000 0 0 1.0303 0 0 1.0606 0 0 1.0909 0 0 1.1212 0 0 1.1515 0 0 1.1818 0 0 1.2121 0 0 1.2424 0 0 1.2727 0 0 1.3030 0 0 1.3333 0 0 1.3636 0 0 1.3939 0 0 1.4242 0 0 1.4545 0 0 1.4848 0 0 1.5152 0 0 1.5455 0 0 1.5758 0 0 1.6061 0 0 1.6364 0 0 1.6667 0 0 1.6970 0 0 1.7273 0 0 1.7576 0 0 1.7879 0 0 1.8182 0 0 1.8485 0 0 1.8788 0 0 1.9091 0 0 1.9394 0 0 1.9697 0 0 2.0000 0 0 2.0303 0 0 2.0606 0 0 2.0909 0 0 2.1212 0 0 2.1515 0 0 2.1818 0 0 2.2121 0 0 2.2424 0 0 2.2727 0 0 2.3030 0 0 2.3333 0 0 2.3636 0 0 2.3939 0 0 2.4242 0 0 2.4545 0 0 2.4848
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.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by