Skip to main content
15-Moonstone
April 15, 2025
Solved

Jacobian

  • April 15, 2025
  • 1 reply
  • 1610 views

I am trying to calculate the Jacobian (for a Newton Raphson scheme). At this point the problem is simple enough that I can derive it by hand but I want to make sure the two approaches agree (especially since my hand-derived result is nearly singular). What I am doing is not working - I get a "pattern match" error. Worksheet (in MC11) is attached. Thanks for any suggestions.

Best answer by Werner_E

@JohnRudnicki wrote:

Actually, I am using MC 14 (I posted MC 11 for Luc). 


 I already suspected that, hence my question.
MC14/15 often behaves differently than MC11. We recently discovered in a thread here that this is especially true for the implementation of sums. In MC14/15 the symbolic evaluation of sums is identical to the numeric one. In MC11 the symbolic evaluation of sums follows a bit more  the math standards - a sum from 1 to 0 yields 0, but unfortunately a sum from 1 to -1 should also return 0 but it doesn't. -> Re: Limit value sought - PTC Community

 

The symbolic evaluation never liked if-statements because the expressions are simplified before any specific values were applied and so the symbolic can't decide which branch to go.

 

Maybe it helps to define it using the Heaviside function (which fortunately is implemented with Phi(0)=0.5) which the symbolics usually can handle

Werner_E_0-1744839641981.png

RHS evaluates symbolically now, but the result is too large to display.

The same may apply to the symbolic evaluation of Jacob(...), but as it seemed to need infinite time to finish I cancelled the operation (I am not a very patient person).

 

BTW, the second argument (m) of your function "Gvec" is never used in that function. It rather uses the global variable n (=7)

 

 

1 reply

23-Emerald IV
April 15, 2025

Mathcad 11 doesn't 'know' the Jacob function. I get a symbolic evaluation failure on Gvec:

LucMeekes_2-1744756231466.png

Tracing back, I see SS fail due to PHI. Noticing that sin(x)/x = sinc(x), try:

LucMeekes_0-1744755796940.png

then:

LucMeekes_1-1744755821131.png

and disp will evaluate symbolically as well, but symbolic evaluation of RHS throws another 'must be scalar' problem.

 

Hope this helps.

Success!
Luc

15-Moonstone
April 16, 2025

Thanks for taking a look and for your suggestion. I must be doing something wrong because I get "division by zero" when I try to evaluate SS symbolically. The problem seems to be the first term, but it is ok if I evaluate numerically. I can't figure out what I am doing wrong (updated MC 11 worksheet is attached).

 

RHS is the problem in the Jacobian. When I try to evaluate it symbolically I get the "pattern match exception" error.

25-Diamond I
April 16, 2025

Are you using MC15 or MC11?

 

In MC15 the sum seems to be implemented somewhat differently as in MC11 - maybe this causes the problem.

 

Anyway, in MC15 it throws the division by zero error when using the sum (at kk=0) while the expression itself works OK.

Werner_E_1-1744830477177.png

So maybe this workaround (for n>1) works for you:

Werner_E_2-1744830638640.png