Using roots() and poly() for multivariable functions

3 visualizaciones (últimos 30 días)
KG573
KG573 el 22 de Feb. de 2023
Comentada: Dyuman Joshi el 23 de Feb. de 2023
How would I go about using poly() and roots() to solve the roots for this multivariable function?
This is my attempt
syms z1 z2
p = poly([1 -.5 -.25 -.25])
p = 1×5
1.0000 0 -0.6875 -0.2812 -0.0312
r = root(p,z1,z2)
Error using sym/root
First argument must be scalar.
  5 comentarios
Walter Roberson
Walter Roberson el 22 de Feb. de 2023
Odd. Notice that when you solve for z_2 that it singles out z2 = -1/2 as a specific solution that is always true, but that when you solve for z_1 that it singles out z2 = -1/2 as a specific case in which the z1 solution does not apply.... even though there is no mathematical problem with z2 = -1/2 ...
syms z_1 z_2
Eqn = 1 - 1/2*1/z_1 - 1/4*(1/z_1*1/z_2) - 1/4*1/z_2^2;
sol1 = solve(Eqn, z_1, 'returnconditions', true)
sol1 = struct with fields:
z_1: z_2/(2*z_2 - 1) parameters: [1×0 sym] conditions: z_2 ~= -1/2 & z_2 ~= 1/2
sol1.conditions
ans = 
sol2 = solve(Eqn, z_2, 'returnconditions', true)
sol2 = struct with fields:
z_2: [2×1 sym] parameters: [1×0 sym] conditions: [2×1 sym]
sol2.z_2
ans = 
sol2.conditions
ans = 
simplify(sol2.conditions)
ans = 
Dyuman Joshi
Dyuman Joshi el 23 de Feb. de 2023
Walter, for z_2 = -1/2, the equation becomes null, and thus we can't solve for z_1
syms z_1 z_2
Eqn = 1 - 1/2*1/z_1 - 1/4*(1/z_1*1/z_2) - 1/4*1/z_2^2
Eqn = 
subs(Eqn,z_2,-1/2)
ans = 
0

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 22 de Feb. de 2023
[N D] = numden(Eqn)
sol = root(N, z_1)
You will get
root(4*z_1*z_2^2 - z_1 - z_2 - 2*z_2^2, z_1)
But you would have followed your requirements that root() specifically be involved in the process.

Categorías

Más información sobre Symbolic Math Toolbox 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