cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Recursive symbolic function derivation

ytang-2
1-Newbie

Recursive symbolic function derivation

Hi, I met a problem when deriving a recursive symbolic function by MATHCAD, the orginal functions read:

1.jpg

2.jpg

3.jpg

What I want is to derive the following recursive functions:

4.jpg

As function gn(t) will be becoming very complex, the rest of deviration work has to accomplished by computer, but I don't know how perfectly Mathcad can handle this problem. So if anyone has any avice, I will be extremely grateful!

12 REPLIES 12

What about your last question here http://communities.ptc.com/message/211709#211709 ?

Also you should state which version you use and attach the worksheet to show what you have done so far.

As you kindly stated, MathCAD seems to have weak functionalities on vectors of functions. I tried to simplify the functions to the way you suggested, however each of them is very complicated and the bound of my function vector is dynamic. So in the end I decide to leave this issue to MATLAB (I am not sure whether it will work) even I prefer the output forms by MathCAD much better.

Back to the current question, I want to derive the equations in MathCAD as the derived function form is more intuitive. Attached is my MathCAD file built on MathCAD v15. It seems to me that MathCAD can't derive the formulas in a recursive way. As you see in my last post, actually the function mu(t) is finally replaced by function B and vanished consequently. If you can give me some suggestions, that will be very thankful.

Is the attached any help? Mathcad won't do it symbolically, but numerically seems ok.

Alan

As you kindly stated, MathCAD seems to have weak functionalities on vectors of functions. I tried

I was asking as there was no reaction on my reply in that thread.

So in the end I decide to leave this issue to MATLAB (I am not sure whether it will work) even I prefer the output forms by MathCAD much better.

You know that Mathcad and Matlab use the same symbolic processor, muPad. The interface of course is different and Matlab would allow using muPad commands directly while Mathcad is more rigid in that respect. Did you had success with Mupad?

With you current question it seems that its the combination of recursion with the summation symbol which causes the error.

While your definition of mu is missing the cases m<1 and m<n and Mathcad's symbolic often has its prolem with the if-statement, I don't think thats the cause here.

rec1.png

As said it looks like the combi recursion/summation throws the error, even if the traced error message in your example moans about the unknown B.

While playing around with your functions and replacing for test purposes your mu() with simpler versions, I now think that the if-statement is one cause for the error, too. See the attached file - unforunately I have no idea if this could be made to work in Mathcad at all.

rec2.png

Well, thank you all for quick replies.

Although the problem remains, I think your suggestions will give me some other angles to think about it.

One idea which comes to my mind is to write your own routine sum(from, to, expression) to avoid the built-in summation. Haven't tried yet and as I guess the summation is not the only problem. One thing which I think will remain is the if condition, necessary to terminate the recursion. And while it should be possible to turn every recursion into an iteration, it could be pretty cumbersome and lengthy and we aouldn't know if it would work out a as expexted at the end.

EDIT: After a quick try I think the summation routine won't do the job. It fails with a simple example even without recursion when using variables. I had also tried a SUM function using while to avoid the range variables and a SUM which worked recursivly - same effect, same error - all as of the late binding being in effect in symbolic evaluations.

rec3.png

Thank, Werner, your efforts are pretty enlightening. Just a question regarding your comments about Mupad, as you mentioned it is the symbolic engine for both MathCAD and Matlab, can I understand in the way that those two have the same or similar capabilities on symbolic manipulations?

Yuehao Tang wrote:

Thank, Werner, your efforts are pretty enlightening. Just a question regarding your comments about Mupad, as you mentioned it is the symbolic engine for both MathCAD and Matlab, can I understand in the way that those two have the same or similar capabilities on symbolic manipulations?

I am not well versed with Matlab, but as both programs use the same symbolics I would expect similar results. There may be differences as of the different implementation of the interfaces and maybe the handling of the result muPad would deliver. Matlab would provide access to a greater range of symbolic functions than Mathcad. Especially expression and subexpression handling is nearly nonexistent in Mathcad so there may be a chance you can achieve in Matlab what you are after, but I am not sure as I have no expertise on that program.

Up to 2006/2007 both programs used Maple as symbolic engine and many of us still feel sad about the change to muPad. muPad was developed in Germany (University Paderborn) but then went commercial later. It is now owned by Mathworks, the makers of Matlab.

http://www.mathworks.com/help/symbolic/index.html

http://www.mathworks.com/discovery/mupad.html

I notice that you have a zero subscript for beta, but you seem to start from 1 for the likes of B and g. You might need to be careful about exactly how you place the elements of B, say, bearing in mind that the first element will have subscript zero by default.

Alan

thanks, Alan, I will keep that in mind.

As Mathcad seems not be able to do the job, maybe using SMath (http://smath.info) could be a solution. It seems not implement that late binding of variables in symbolic mode and so we get the results demanded. Unfortunately the ability to symbolically simplify expressions (like simplify, expand, or factor) are nonexistent in SMath (yet).

recur_symb3.png

To round it up after a long downtime of the Forum and to test that awful sounding new moderation scheme which I fear will be responsible for unaccaptable time delays, I attach a modified sheet in both SMath and Mathcad format.

In SMath the result was copied and assigned a variable and the sheet then exported in XMCD format. After some modifications in Mathcad the results are now useable in MC for simplification ot whatever you had in mind.

recur_symb4.png

Top Tags