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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Pattern match exception problem

ifomenko
15-Moonstone

Pattern match exception problem

Hi

I`m trying to make simple calculation but without success. What`s the problem?

PatternMatchException.PNG

MC15 file is attached for convenience.

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
LucMeekes
23-Emerald III
(To:ifomenko)

Or use this alternative definition of it:

LM_20171101_symbolic3.png

(The symbolic processor is not so fond of programming constructs, it likes pure mathematical expressions better.)

 

Success!
Luc

View solution in original post

9 REPLIES 9
LucMeekes
23-Emerald III
(To:ifomenko)

I get this in Mathcad 11.

LM_20171101_symbolic.png

(The error messages are the same for all red evaluations).

Apparently it's not 'simple'.

 

Success!
Luc

 

ifomenko
15-Moonstone
(To:LucMeekes)

Problem is in delta function, if you change it by 1 for example everything is OK.

If you change double sum by two summing loops inside program block everything is OK too!See attached file

LucMeekes
23-Emerald III
(To:ifomenko)

Then don't use the delta function, but use (i=j) instead:

LM_20171101_symbolic2.png

Success!
Luc

LucMeekes
23-Emerald III
(To:ifomenko)

Or use this alternative definition of it:

LM_20171101_symbolic3.png

(The symbolic processor is not so fond of programming constructs, it likes pure mathematical expressions better.)

 

Success!
Luc

ifomenko
15-Moonstone
(To:LucMeekes)

Problem is not to find answer but understand why mistake is.

But thank you for very short and elegant delta function and it really works!!!


@ifomenko wrote:

Problem is not to find answer but understand why mistake is.


The reason for the error is, that Mathcads symbolics always try to evaluate and simplify symbolically all used expressions and functions before it applies specific values or patrameters.

Obviously it can't symbolically evaluate an if-statement, because it usually can't know if the condition is fulfilled or not, as this depends on the values of the specific arguments.

In case of your double sum Mathcad could know which branch to chose, but it looks like it tries to evaluate and simplify the expression in the sum before the sum is evaluated.

 

ifomenko
15-Moonstone
(To:Werner_E)

Thank you, I forgot that symbolic engine doesn`t like branching.

ifomenko
15-Moonstone
(To:Werner_E)

One very simple and interesting result

Symbolic with branching.png

Thats exactly the very same problem as you had here

https://community.ptc.com/t5/PTC-Mathcad/Symbolic-issue/td-p/655681/jump-to/first-unread-message

 

Seems like the symbolic doesn't like strings

Werner_E_0-1584784986934.png

 

I just gave it a try in Prime 6 and the new symbolic (while in many cases weaker and less capable even compared to muPAD) does not have this problem:

Werner_E_0-1584785375337.png

 

 

Top Tags