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 Comments

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?
@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.
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.
MathWorks tech support confirmed a bug in 2024b.

Sign in to comment.

Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Products

Release

R2024b

Asked:

on 14 Feb 2025

Commented:

on 19 Feb 2025

Community Treasure Hunt

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

Start Hunting!