Reduce a certain kind of multiplication expression and square root expression

2 次查看(过去 30 天)
Multiplication by a division expression. x * (y / z) can be better expressed as (x*y) / z. But before returning this new expression, reduce it by calling the reduce function on it. Reduce it after you create it but before you return it.
I have to make a function that can do this but can't seem to figure it out. So far I have this within a function:
elseif strcmp(Operand2{2}, 'Div')
reduce(Operand2);
Result = {'Num', Operand1{2} * Operand2{2}};
I also need a part of a function that can do this, "Radical is a power, and the exponentof that power is a number >= 2: Create a new 'Pow' expression using the same base but with an exponent that has had 2 subtracted from it. Reduce this expression and return it." So far I have this within a separate function.
if strcmp(radical{1},'Pow')
reduce(radical);
Result = reduce(sqrt(radical{2}));

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by