Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

** Community Tip** - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more!
X

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

May 01, 2020
07:56 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 01, 2020
07:56 PM

Coronavirus SIR models using Euler's method

Having issues programming an Euler's method for ODEs. Can't get past error in magnitude of numbers.

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

May 02, 2020
11:22 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 02, 2020
11:22 AM

You an improve the situation with m(t) by multiplying numerator and denominator by exp(-10(t-10)). For example:

Alan

5 REPLIES 5

May 02, 2020
04:01 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 02, 2020
04:01 AM

It's the exponential in your m(t) expression blowing up.

If you want to use B within your program, you'd probably be better of defining it as a local function at the top of the program (B(t)<-m(t)*p

Stuart

May 02, 2020
04:36 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 02, 2020
04:36 AM

Just as a quick follow-up to my previous post, here's one possibility for making Euler a bit easier to use (as it's already tailored to your problem, it's a reasonable option).

Unfortunately, I've only got Prime Express so can't run programs, but you should be able to check it making B return 5 (to behave like your earlier, simpler Euler function).

Stuart

May 02, 2020
11:09 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 02, 2020
11:09 AM

Right thanks, I know the exp function was going to infinity and mathcad won't handle it. In that same mathcad sheet over off to the right in the worksheet I have another disabled program where I tried to address that issue with an if/else statement. I know the exp blows up around iteration 10 so for k<10 I wanted to calculate m(t) and k>10 just print the 'ms' value.

May 02, 2020
11:22 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 02, 2020
11:22 AM

You an improve the situation with m(t) by multiplying numerator and denominator by exp(-10(t-10)). For example:

Alan

May 02, 2020
11:33 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 02, 2020
11:33 AM

Thank you! I now have a more streamlined program that is at least plotting but the curves just settle around iteration 11. The graphs should look like the image attached. It that program I had a constant value for 'm' but now I want to do one that varies as a function of time.