Borrar filtros
Borrar filtros

finding the remainder of the division of two symbolic variables

51 visualizaciones (últimos 30 días)
Elif Cansu Akoguz
Elif Cansu Akoguz el 1 de Ag. de 2024 a las 12:58
Editada: Walter Roberson el 3 de Ag. de 2024 a las 17:02
I want to get 2*V^2 from the operation below
syms A V
rem(2*V^2+3A,A)
but it seems like rem() function does not work with symbolic variables. Is there a way to achieve this in another way?
  5 comentarios
Elif Cansu Akoguz
Elif Cansu Akoguz el 3 de Ag. de 2024 a las 10:04
Thanks for your answer but the problem with this approach is that it starts from an expression of f in terms of g which should normally be unknown in the beginning. Deducing that expression is the whole point of this exercise. Let me give you a more concrete example:
Assume I want to rewrite the f function below as f=z*(1+bL)^2+t;
syms bL bH A V;
f=(A^2*bL^2 + 2*A^2*bL + A^2 + 4*bH^2*bL^2 - 8*bH*bL + 4)/(8*(bH*bL - 1)^2);
coeffs(f,(1+bL)^2)
Error using mupadengine/feval2sym_NaNsingularity
Invalid indeterminate.

Error in sym/coeffs (line 59)
cSym = feval2sym_NaNsingularity(symengine, 'symobj::coeffs',p.s, args{:});
I want to be able to deduce z=A^2 from this but coeffs function does not take arguements like (1+bL)^2 as input.
Umar
Umar el 3 de Ag. de 2024 a las 16:39
Editada: Walter Roberson el 3 de Ag. de 2024 a las 17:02
Hi @ Elif Cansu Akoguz,
If you manually expand the expression and then extract the coefficients, you can deduce the value of z as A^2 in the rewritten function. Let me illustrate it with example,
syms bL bH A V z t;
f = (A^2*bL^2 + 2*A^2*bL + A^2 + 4*bH^2*bL^2 - 8*bH*bL + 4)/(8*(bH*bL - 1)^2);
% Expand the expression
expanded_f = expand(f);
% Extract the coefficients
coeff_z = coeffs(expanded_f, A^2);
z = coeff_z(1); % Assuming z is the coefficient of A^2
% Verify the result
rewritten_f = z*(1+bL)^2 + t;
This approach will bypass the limitation of the coeffs function with complex arguments. Hope this helps.

Iniciar sesión para comentar.

Respuestas (1)

Aditya
Aditya el 1 de Ag. de 2024 a las 13:26
you can use "quorem" function to get the Quotient and remainder for a particular expression:
here is an example on how to do it:
[q, r] = quorem(expr, A, A);
To read more about this function refer to this link:

Categorías

Más información sobre Symbolic Variables, Expressions, Functions, and Preferences en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by