Can we use IF in the Given-Odesolve Block?
Yes, we can! 🙂
The problem is not the if-function you used.
The error message says something about an unstable problem resulting in a step size too small and suggests that you reduce the integration interval.
If you follow this suggestion and set t.end to 0.5 the solve block perfectly works.
Looks like the solution curve has a tendency you shoot up vertically at the new end value which makes the solve block fail if t.end is larger:
Thanks, I see
I use not if in attach.
Yes, but thats not equivalent, thats a completely different function .
As already written above, the if function is NOT the problem.
E.g. you may use
with success, but if you use lower values than 66.323N for "limit", the block gets too unstable and fails.
But what about the logistic function in attach (Prime)
It seems to have the same problem (the error message in Prime is less specific).
Your question was, if the "if" function can be used in the odesolve-block and the answer clearly is a "Yes".
The error was not because of the if function but is due the setup and modelling of your problem in general as your new example with the logistic function shows.
One solution in attach (Prime).
I saw at night in a dream that there we can have in the solve block not four, but three functions!
But I did not see the correct formula for calculating the potential energy of an elastic link with the non-linear Hooke law 😞
And still no one told me in a dream why we cannot work in the not elastic region of Hooke's nonlinear law.
In general, we try to understand something when something is wrong. You could "waste" a few words, to say that in the worksheet you use "spring compliance" and not "spring stiffness".