cancel
Showing results for
Did you mean:
Security Alert Log4j Security Vulnerability. Click here to know more.
cancel
Showing results for
Did you mean:

13-Aquamarine

## Stiff ode solvers

I previously posted a version of this question, but did not get any response. So I decided to rephrase and try again.

I have been trying to compare the solvers (BDF, Radua, Stiffr and Stiffb) for stiff odes. Could be doing something stupid but BDF is the only one that I can get to run consistently. For the others I get error messages I do not understand (in this context):

"The return value of this function must match the problem size"

"This value must be real"

(BTW. Documentation says Stiffb does not work for more than 8 equations, but it seems like it should be "8 or more". 7 worked. 8 did not.)

Thanks to anyone who chimes in.

If you run the worksheet, be patient. It takes a while to calculate.

8 REPLIES 8
23-Emerald IV
(To:JohnRudnicki)

What is the initial setting of the problem that you want to solve with the program?

21-Topaz I
(To:JohnRudnicki)

The constant tp is neither defined nor initialized anywhere. How does the processor calculate sin (2πt / tp)?

24-Ruby IV
(To:-MFra-)

@-MFra- wrote:

The constant tp is neither defined nor initialized anywhere. How does the processor calculate sin (2πt / tp)?

The solve block is evaluated symbolically and the result is assigned to a function D which has tp (substituted by y[5) as one of its arguments. So all is OK and when you let the sheet run it works OK (at least with BDF and Radau & IC21).

BTW, VladimirN  had unearthed a more than 8 months old question and obviously no one had an idea so far why the solvers other than BDF fail.

21-Topaz I
(To:Werner_E)

Although you work in symbolic, don't you have to initialize the variables first and then reset them for symbolic computation? otherwise if you write tp = ? before the Given, it marks it in red. As a result nothing changes, on this I agree.

24-Ruby IV
(To:-MFra-)

Why would you write tp = ... ? Sure the variable is not defined but its not necessary to define it as its just used as a formal function argument (disguised as y[5).

A solve block which is evaluated symbolically (a feature not available in Prime) does not need any guess values for the variables solved for.

Here is an example to demonstrate defining a function similar but much simplified to the one in the worksheet. Neither a nor b need to be initialized - "a", because we evaluate symbolically and "b" because its provided as function argument:

And here is the same using "substitute" to change the name of the formal function argument, similar to the procedure done in the worksheet but not using a vector as we only deal with one single variable:

21-Topaz I
(To:Werner_E)

Thanks for the clarification. However, I always prefer to define variables and then reset them in case I need them for a symbolic calculation.

24-Ruby IV
(To:-MFra-)

@-MFra- wrote:

Thanks for the clarification. However, I always prefer to define variables and then reset them in case I need them for a symbolic calculation.

You sure do not define a variable x if you intend to define a function f(x):=.... later.

And so it also was not done in the worksheet with the variable tp (and others). The use of the solve block with symbolic evaluation and the substitution with x[5  just obscured the fact, that its just a "simple" definition of a function D of tp and other arguments.

But of course I agree thats its often good habit to define variables (and un-define them symbolically) which are used in symbolic evaluations and assignments to avoid the error from the numeric engine.

21-Topaz I
(To:Werner_E)

Please delete. Thank you.

Announcements
Check out the latest