Simplify() Does Not Work with "All" Argument?

This is a bug?
syms x c1 c2 real
m1c(x) = heaviside(x-4)*(3*x-2)*(x-4) + c1*x + c2;
simplify(diff(m1c(x),x),'All',true)
Error using mupadengine/evalin2sym
Invalid number of arguments.

Error in mupadengine/feval2sym_NaNsingularity

Error in sym/simplify (line 80)
rSym = feval2sym_NaNsingularity(symengine, 'simplify', s,...

5 Kommentare

Does not throw an error in 2024a
s = simplify(diff(m1c(x),x),'All',true)
s =
[c1 - 14*heaviside(x - 4) + 6*x*heaviside(x - 4), c1 - 14*heaviside(x - 4) + 6*x*heaviside(x - 4)]
[c1 - 14*heaviside(x - 4) + 6*x*heaviside(x - 4), c1 + 3*heaviside(x - 4)*(x - 4) + heaviside(x - 4)*(3*x - 2)]
c1 + 3*heaviside(x - 4)*(x - 4) + heaviside(x - 4)*(3*x - 2) + dirac(x - 4)*(3*x - 2)*(x - 4)
But I don't quite understand what it's returning with first two items containing a comma.
s is an ordinary sym
>> class(s)
ans =
'sym'
And is a column vector
>> size(s)
ans =
3 1
But the first element of s is not a scalar?
>> size(s(1))
ans =
1 2
So a sym array is not necessarily like an ordinary Matlab array?
Gayathri
Gayathri am 14 Feb. 2025
@Paul, I am guessing that the two elements in the first two members of the output "s" would be the simplified expression of "diff(m1c(x),x)" for two different values of x, x<4 and x>=4.
Paul
Paul am 14 Feb. 2025
Actually, I think that first element in s(1) is a subexpression extracted from the second element of s(1). Similarly for s(2).
Am still surprised, shocked actually, that element of sym vector can themselves be vectors and that elements of a sym vector can have different dimensions.
Also, I can assign s(1) to a variable and then extract the elements of that variable using ordinary indexing. But other operations on that variable, like multiplying by 1, throw an error.
Paul
Paul am 14 Feb. 2025
I opened up a new question on the meaning of s. How Can a sym Vector have Elements that are Vectors Themselves?
Paul
Paul am 19 Feb. 2025
MathWorks tech support confirmed a bug in 2024b.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2024b

Gefragt:

am 14 Feb. 2025

Kommentiert:

am 19 Feb. 2025

Community Treasure Hunt

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

Start Hunting!

Translated by