Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.9K Views
|
42 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How do I simulate with three dependent differential equations in Mathematica

Posted 1 year ago

I am a relatively new user to Mathematica. Could someone tell me the best and most efficient way to code in Mathematica these three differential equations, shown in the image, for a three gene negative feedback loop? I have included an image below of how I was doing this previously with brute force in Excel using small time increments of 0.000025 min. Obviously, Mathematica is a much better way to do this calculation. You can see that each differential equation includes the gene product calculated by one of the other two differential equations so all 3 equations are interlinked. I would like to be able to simulate various three-gene negative feedback systems by changing the parameters on the left-hand side of the image below.

Thank you in advance for any help that you can provide me on coding in these three differential equations into Mathematica and informing me on the best way to do simulations in Mathematica.

Three gene negative feedback loop

POSTED BY: Scott Klakamp
42 Replies
Posted 1 year ago

David,

Sorry that I missed the attachment.

This whole issue is exactly why I tried to do this in Mathematica to see if there were differences and there are. I wanted the most accurate answer I could get and Mathematica gives me that.

That Euler notebook in Mathematica looks complicated. I have some studying to do there!

I am satisfied my original question has been answered thanks to both Bill and you!

Scott

POSTED BY: Scott Klakamp
Posted 1 year ago

It’s attached in the post above and called “by Euler.nb”

I’m not planning to look at your Excel file. Clearly it has some error, but even corrected, Eulers method can’t compete with methods that include adaptive stepping.

The learning curve for Mathematica is somewhat steep. But there are good learning resources on the Wolfram site, and the benefits are substantial. It is a very capable and versatile tool.

Best, David

POSTED BY: David Keith
Posted 1 year ago

David,

This is beautiful work and what I have been after for about 5 days now! To me it seems clear from your two simulations using Euler's method that one never knows when the time increment is small enough to ensure accuracy. One also runs into computational time problems in Excel with really, really small time increments. I guess I would have to go to 10 million rows in Excel to get the accuracy I need. Thank you again for all the time you put into solving this conundrum for me.

Do you mind sending me your notebook where you implemented Euler's method? I would like to know how to do that method in Mathematica for comparison purposes.

Scott

POSTED BY: Scott Klakamp
Posted 1 year ago

Here is the result if the time step is reduced by a factor of 10. But it takes a long time to run. enter image description here

Clearly the time step is an issue.

POSTED BY: David Keith
Posted 1 year ago

Hi Scott,

I implemented Euler's method in Mathematica using a function called NestList. It repeatedly applies a function to the last result, starting with some initial condition. I used your equations for the derivatives and your time step. The original result that both Bill and I have using NDSolve is this: enter image description here

The result using Euler's method is this: enter image description here

You can see that they are quite similar. And they converge on the same concentrations. I suspect the difference arises from the fixed time steps being to large in the early part of the simulation, resulting in under damping. Mathematica has adaptive time stepping to prevent that.

I don't know why the Excel Euler's method produces different results, but I would trust NDSolve over the perhaps-too-simple Euler's method.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard
Be respectful. Review our Community Guidelines to understand your role and responsibilities. Community Terms of Use