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}</math>, but <syntaxhighlight inline>ev(%, nouns)</syntaxhighlight> helps.
It was difficult to make <math>\frac{d Ns}{dt} = N \frac {ds}{dt}</math>, but <syntaxhighlight lang="Bash" inline>ev(%, nouns)</syntaxhighlight> helps.


Also, Greek letters are not supported for <syntaxhighlight inline>plotdf</syntaxhighlight>, and note that no spaces are allowed in <syntaxhighlight inline>parameters</syntaxhighlight> option.
Also, Greek letters are not supported for <syntaxhighlight lang="Bash" inline>plotdf</syntaxhighlight>, and note that no spaces are allowed in <syntaxhighlight lang="Bash" inline>parameters</syntaxhighlight> option.

Latest revision as of 13:40, 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, and note that no spaces are allowed in parameters option.