I'm no expert at all in mathematics but I wrote a simple program that doesn't seem to get the answer that I'd expect.
It provides:
ans =
6 – time
time + 6
as the only solutions, however shouldn't 0 be a solution assuming time > 6?
This could just be poor programming on behalf of me and if it is how would I get the required answer.
- Is this a bug?
- Am I making a mistake?
- If this is a mistake how can I fix it?
This is supposed to simulate a 1D particle traveling at a fixed velocity of 1 towards origin (0). I understand the answer is relatively simple to do by hand, however I have this repeated with more complicated variables in a larger equation that would be incredably tedious and unmaintainable to solve by hand.
syms position time;speed = piecewise(position > 0,-1,position < 0,1,0);solve(int(speed,time) + 6 == position,position) %6 is starting offset
Best Answer