Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
I Am having an issue with writing down coupled differential equations for radioactive decay! What is know is
dN/dt=-λN
so N=N0exp-λt
where λ=ln(2)/τ where τ is the half life of each element
I calculated all of the λ values and was then asked to write down the couples differential equations for the decay/creation of each element
dNn/dt=λn-1*Nn-1 -λnNn
NNot sure how to do this on MathCad!
They will be getting solved via rkfixed function but when I input the equations in the form above I get "a name is required here" error
There is an image below with my question sheet! Any help would be great
Maybe you would like to show what you have done so far by posting your Mahcad sheet.
HHow do I do that?
Alison McMillan wrote:
HHow do I do that?
The same way as you attached your pic.
But in a reply you have to switch to "advanced editor" first. You do so by clicking "Use advanced editor" at the upper right.
Now you have the option to attach files at the end.
There is no need to zip the files yourself as this will be done automatically.
That should be it:)
any help would be fantastic!
Im trying to write the equations in the form at the top of the sheet I posted so I can use the rkfixed function!
I am not very good with mathcad as im am just learning
The suggestion to use "rkfixed" in the text isn't a good one. If you use rkfixed, values will run out of range as of numerical inaccuracies because of the fixed step size. Values are getting higher than 10^307 (while actually an increase of atoms is not possible of course) and so rkfixed will throw an error. Rkadapt with its adaptive step size works well, though.
BBrilliant thanks for all your help!! Do you think I should perhaps remark that rkfixed will not work in this case?
Do you think I should perhaps remark that rkfixed will not work in this case?
Feel free to do so, but see for yourself what happens first.
change Rkadapt to rkfixed and you get an error. If you decrease the numper of points calculated significantly from 1000 to 37, you get a "solution" but its obviously wrong. Using max() you can see that the highest value calculated is around 10^303, so this algorithm is completely inappropriate for this set of DEs.
EDIT: See Alan's post on this topic, please. While Rkadapt may be the better choice, I was definitely wrong in writing that rkfixed is "completely inappropriate" here. The error was my way of using it. Do as Alan suggests and set the number of points to something like 10^4 and it works OK, too.
Werner Exinger wrote:
... If you use rkfixed, values will run out of range as of numerical inaccuracies because of the fixed step size.
Try using 10000 steps with rkfixed.
Alan
AlanStevens wrote:
Werner Exinger wrote:
... If you use rkfixed, values will run out of range as of numerical inaccuracies because of the fixed step size.
Try using 10000 steps with rkfixed.
Alan
Thanks! Of course you are right, the stepsize was too big. Nevertheless I think that Rkadapt is the better choice.
As I posted that "Fixed" worked OK using the solveblock just a moment before: I just checked and I had set (mistakenly) the Number of points to 10000 (wanted to type 1000) as you suggested. That was the reason it worked. Using NrPt:=1000 the solveblock consequently fails, too.
Mathcad offers a more natural way to write and solve differential equations, namely via a solve block and the function odesolve(). You can select the numeric algorithm used by right clicking the word Odesolve. Normally there should be no reason to change the default "Adams/BDF"- Interestingly enough even chosing "Fixed" gives a satisfacory result this time.
Again also this function unfortunately does not support units in Mathcad 15 and below. One of the few advantages of Prime is that you are allowed to use units with odesolve, too.
EDIT: Again, see Alans post. It should NOT be surprising that "Fixed" works here. The reason is that I had set the number of points to 10^4 in this sheet (without being aware of 😉
Thanks so much guys, you have been great help:)
I think I understand where I was going wrong! MathCad is extremely tedious at time especially for a beginner like me!
Thanks again much appreciated