Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
Hello All, I am relatively new to MathCAD and am having an issue developing a set of symbolically solved equations for a system. I have assigned values to the variables however throughout my analysis I would like to solve or simplify equations ONLY symbolically for a particular variable and KEEPING all variables as symbols, NOT replacing them with their numerical values.
Is this possible?
You can accomplish what you want in a couple of ways.
1) define the numerical values below the symbolic solve evaluation
2) turn the symbolic solve into a function of the variables you assigned a value before
3) use clear.sym(<variable list>) to clear the values for symbolic evaluation only
Here is a simple example:
Thank you so much for the quick response!
These are all great options and if I am not mistaken they all tell me that if I want to solve purely symbolic sets of equations I have to rethink how I set up my document. In other words, I will be going through assembling equations for a variety of components that interact with each other (free body diagrams). I am going to get some relatively complex algebraic equations that describe the combined behavior.
It seems to me that the best option may be (1), i.e. to avoid assigning all numerical values to parameters and instead create a set of symbolic-only equations? Then once I have the overall solution equations I add the numerical values at the end and solve numerically?
Option 1) sure is a good choice, but I would recommend nonetheless turning all the calculations into functions depending on the variables you want to set in later - even if you do not intend to vary these variables.
Something like
Doing so may be troublesome but if you don't, the only way to use the symbolic results you calculated at the top would be to copy and paste the symbolic results which is not desirable and error prone.
In the case of quite elaborate and complicated equations, however, you run the risk of reaching the limits of Prime's capabilities, since the symbolics in Prime is relatively weak, especially compared to Maple or Mathematica.
In order to demonstrate how quickly you may run into not getting a visible symbolic result with Prime. Define a polynome generating function:
(where x is the running variable, a is a vector with the coefficients and n is the order)
Use it to show solutions for a 1st, 2nd and 3rd order:
As stated, although you cannot fully get/see the symbolic result, you can use it in numeric calculations:
And you may be able to see the symbolic results in parts, as long as they're small enough, like here is the first:
Success!
Luc
Hi All, these are all great and insightful responses. I am going to test/exercise a few of these options and return with my final comments.
I thank you all for the quick response (wish all forums were like this - quality!)!
-Alessandro
One more tip you know.
Hello ttpkoro: thank you. On the last 2 lines, does it not place order priority depending on whether you specify expand, explicit, "x or y first:?"? Or is there a default for solution variable order?
Overall all these responses have cleared up a lot of basic functionality for me. One interesting thing that may be interesting for all is that in speaking also with PTC tech support, and having a little more complex equations going on looking for solution for a variable appearing in many locations, I was told that an upgrade to version 8 was required as the solver engine is much more robust, so I will be moving to that soon.
Thank you all again!
On the last 2 lines, does it not place order priority depending on whether you specify expand, explicit, "x or y first?
clear.sym(x,y) clear the symbolic engine and have no value for x and y. So, the equations displayed as a default for solution variable order.
I think there is a system default for solution variable order. But control the order manually is difficult. If you want to write the variables any order what you want, use the bold = is one of the tips.
I sometimes used when the symbolic result of Mathcad and textbook or my answer is different, I also use bold = to check the result.
1 means true. This means both equations are same.
Even the equation is not right, we can define A =B by bold =.
0 means this is false.
Thanks Werner. I thought your second solution might solve an annoyance I had but I couldn't get it to work. I'm solving a statistics equation that (to my knowledge) can only be solved symbolically because the factorials are otherwise too big for a computer to handle. The annoyance is I must evaluate my program symbolically, which just means the result must be shown. Only a big deal when you are evaluating dozens of results and it takes up pages (only 7 shown below). Ultimately I just want to plot the resulting values (probabilities) against the range values. So anyway can this be done without the results taking up so much page space? P7 attached.
My first idea was to use the modifier "float" so the symbolic result won't look that ugly and space consuming. But to my surprise this modifier has no effect! I also tried "return 1.0*prob" to force a float result, but to no avail. Surprisingly even "return 5*prob" did not return the expected vector multiplied by 5. I have no clue whats wrong with this.
So my second idea is to hide the ugly result in a collapsed area. In case you still want to show the calculation but hide the large result, you could use a function with a dummy parameter in front of a collapsed area, put the assignment with symbolic evaluation in a collapsed area and show the numeric result afterwards.
The function can, but must not have the same name as the variable and of course the name of the dummy argument can be chosen at will. You also may use a,b,x,y as function arguments, which sure would make sense, too.
But the simplest solution seems to be to avoid symbolic evaluation altogether and use the built-in function combin:
EDIT: Finally here a way to force a float result for the symbolic eval. Unfortunately still no way to control the number of digits used.
Great work as always. As per your 2nd idea - I'd had the calculation off the page to hide it. I also had a dummy code as you suggested, but had just used the bold = so it wasn't calculated. Glad to see we went down the same paths.
As for combin, I didn't know that existed. Oddly (imho) it isn't listed under the statistics functions in MC, even thought it is under statistics in the online help menu. And you'd think it would show up if you searched for 'binomial', seeing as how most of the world calls it the binomial coefficient.
Thanks,