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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Puzzled - two calculations that give different results

JohnRudnicki
14-Alexandrite

Puzzled - two calculations that give different results

I have two questions about the attached worksheet:

1. I am trying to calculate two functions in two different ways: One by using a program, the other using the step function. The program gives expected results and  for one of the functions, the step function expression agrees. For the other, it does not. Obviously, I am doing something wrong, but I cannot see what it is - I  thought I set them up in the same way.

2. When I eliminate an argument from the function, that I do not think is used, I get an error with "augument". This is something else I cannot understand.

1 ACCEPTED SOLUTION

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

Does the error in CallEvolve2() resolve if you call Evolve2() instead of Evolve1() in the one but last line?

 

Success!
Luc

View solution in original post

8 REPLIES 8
LucMeekes
23-Emerald III
(To:JohnRudnicki)

Does the error in CallEvolve2() resolve if you call Evolve2() instead of Evolve1() in the one but last line?

 

Success!
Luc

JohnRudnicki
14-Alexandrite
(To:LucMeekes)

Thanks, Luc. I should have caught that. 


@JohnRudnicki wrote:

I have two questions about the attached worksheet:

1. I am trying to calculate two functions in two different ways: One by using a program, the other using the step function. The program gives expected results and  for one of the functions, the step function expression agrees. For the other, it does not. Obviously, I am doing something wrong, but I cannot see what it is - I  thought I set them up in the same way.

2. When I eliminate an argument from the function, that I do not think is used, I get an error with "augument". This is something else I cannot understand.


ad 1)

I have not studied the details and so cannot say, why "StateSlip" fails for the first 71 time values with results larger than 10^307. But you can get rid of those erranous values by using the "on error" statement to replace them with NaN's and as you can see the plot of the remaining values seems to look like you expected:

Werner_E_0-1658014990648.png

Here you can see up to which value of" t" the function fails

Werner_E_1-1658015510699.png

Error tracing leads us to this function call:

Werner_E_0-1658015821435.png

 

ad 2)

As Luc already suspected you forgot to call "Evolve2" instead of "Evolve1". Calling Evolve1 with only five arguments instead of the expected six means that the results are ot values but functions in one argument. These can't be augmented with "T", hence the error message.

 

 

JohnRudnicki
14-Alexandrite
(To:Werner_E)

Thanks, Werner,

 

1. Hmm. With the additional information you provided I will look again to see if I can figure out what is going on.

 

2. Yes, I called the wrong "Evolve"

JohnRudnicki
14-Alexandrite
(To:Werner_E)

I am still puzzled if you have anymore thoughts. The problem is with ThetaSlip which does become very large for values of T < T1 (which in this case is 2). But because of the step functions, I do not see why ThetaSlip is even being evaluated between 0 and T1 (and hence becoming too large at t =1.43, as you pointed out)

 

JohnRudnicki_0-1658169801182.png

 

Is this nesting of Theat.slip done on purpose?

Werner_E_0-1658189156451.png

But thats not the reason for the expression failing.

Here you see where and why the calculation fails. If PsiSlip exceeds 709.78, exp(PsiSlip) exceeds the max number.

Werner_E_1-1658189711590.png

It dos not matter that the factor

Werner_E_3-1658189982506.png

is zero ant the result does not matter. It is evaluated and the evaluation fails.

If you don't have to do some calculus with the function StateSlip you may replace expressions like

Werner_E_4-1658190201446.png

with

Werner_E_5-1658190215012.png

to cope with the problem.

Afterthought: It may be more appropriate to avoid counting limits multiple times, so it may be better to write T1<T... instead of T1<=T...

 

Personally I would prefer using the programmed if statement as it looks clearer to me (Variant 2):

Werner_E_2-1658192122233.png

 

 

 

 

 

 

 

JohnRudnicki
14-Alexandrite
(To:Werner_E)

Hi Werner,

 

I agree the programmed version is clearer, but I could not understand why the other version did not work and I could not let it go. Since the programmed version worked, I probably spent too much time trying to understand the other version. But, with your help, I think I learned something. If I understand, the functions are evaluated over the entire interval regardless of the step functions - if so, this is good to know. 

 

BTW, the nesting was intentional. In each interval the starting value of ThetaSlip is the last value in the preceding interval.

 

As always, Thanks.

Correct. You have products with two factors and even if the first factor (with the Heaviside functions) already returns zero, the second factor (ThetaSlip function) is evaluated as well. Mathcad does not support shortcut evaluation (don't evaluate the second factor if the first one is already proven to be zero) in this case.

Top Tags