Hello, I'm working on a script that calculates the deflection of beams, and thus I'm using singularity functions, essentially piecewise polynomials that 'switch on' at a certain point. There is a very odd issue I'm finding when I add two together. Here is the function I call to create them in the first place: function func = singz(coeff, order, center)
f(z) = piecewise(z < center, 0, z >= center, coeff*(z - center)^order);
I've attached below the variables I'm about to use. For reference, A, B, and C are real symbolic variables, and L is a positive symbolic variable.
Here are the two initial functions:
>> testfunc
testfunc(z) =
piecewise(z < 0, 0, z < L, -A, symtrue, - A - B)
and
>> singz(-testmag, 0, testloc)
ans =
piecewise(z < 2*L, 0, symtrue, -C)
The first is actually a composite of two singularity functions, but their addition had no issue, for some reason.
Here's what happens when I add the two above:
>> testfunc + singz(-testmag, 0, testloc)
ans(z) =
piecewise(z < 0, 0, z < L & in(z, 'real'), -A, z < L, - A - C, z < 2*L, - A - B, symtrue, - A - B - C)
For some reason, I get an 'in(z,....' But the primary issue is this 'z < L, - A - C' term. It makes absolutely no sense in my mind. I am aware that I can assume z to be real and simplify. The result is:
> simplify(Sy)
ans(z) =
piecewise(z < 0, 0, z < L, -A, z < L, - A - C, z < 2*L, - A - B, symtrue, - A - B - C)
I know that the 'correct' '-A' term is first and will thus be evaluated, but the other term shouldn't be there in the first place. I don't trust that this order will magically work out every time that I want to run this program.
Thank you in advance; any help would be greatly appreciated.