SIR model with Maxima: Difference between revisions

From wikiluntti
Line 29: Line 29:
=== Problems ===
=== Problems ===


It was difficult to make <math>\frac{d Ns}{dt} = N \frac {ds}{dt}, but ev, noun helps.
It was difficult to make <math>\frac{d Ns}{dt} = N \frac {ds}{dt}</math>, but <pre>ev, nouns</pre> helps.


Also, greek letters are not supported for <pre>plotdf</math>, and note that no spaces are allowed in <pre>parameters</pre> option.
Also, greek letters are not supported for <pre>plotdf</math>, and note that no spaces are allowed in <pre>parameters</pre> option.

Revision as of 13:38, 12 August 2021

Introduction

Use WxMaxima to calculate SIR model.

Theory

SIR model
depends([S,I,s, i],t);

eqS : 'diff(S, t) = -β*S*I;
eqI : 'diff(I, t) = β*S*I - α*I;

factor( rhs(eqI)>0);

eqsN : subst([S=N*s, I=N*i], eqS );
eqiN : subst([S=N*s, I=N*i], eqI );

eqs1 : ev(eqsN, nouns);
eqi1 : ev(eqiN, nouns);

eqs : eqs1/N;
eqi : ratsimp( eqi1/N );

plotdf([subst( [β=b], rhs(eqs)), subst( [α=a, β=b], rhs(eqi))], [s,i], [parameters,"a=10000,b=1.1,N=1000"], [s,0,75], [i,0,60], [sliders,"b=0.5:2.5"] );

Problems

It was difficult to make , but

ev, nouns

helps. Also, greek letters are not supported for

plotdf</math>, and note that no spaces are allowed in <pre>parameters

option.