Using roots() and poly() for multivariable functions

3 views (last 30 days)
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 Comments
Walter Roberson
Walter Roberson on 22 Feb 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 on 23 Feb 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

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 22 Feb 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.

Categories

Find more on Symbolic Math Toolbox 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!