Math help

SLAM: debunk creationism, pseudoscience, and superstitions. Discuss logic and morality.

Moderator: Alyrium Denryle

Post Reply
Darn
Redshirt
Posts: 29
Joined: 2005-05-19 05:07pm

Math help

Post by Darn »

I don't quite understand my MATLAB homework here. How do I interpret the provided differential equation for the epidemiology, to plot the functions? For example, from R'(t? I think?)=nI-uR I would get the antiderivative R(t)=nIt-uRt. Or something. Which seems... odd. Really, I'm at a loss here. I know there are plenty of Superior Math People here, so... Help? What exactly am I supposed to do here?
User avatar
Feil
Jedi Council Member
Posts: 1944
Joined: 2006-05-17 05:05pm
Location: Illinois, USA

Re: Math help

Post by Feil »

I and R are functions, not constants. Functions do not integrate like constants. Your given equation, R'=nI - uR is a first order linear differential equation. Solve it like one. There is a good tutorial here: http://www.sosmath.com/diffeq/first/lin ... eareq.html
Darn
Redshirt
Posts: 29
Joined: 2005-05-19 05:07pm

Re: Math help

Post by Darn »

Thanks a lot. This is a little embarrassing, I really ought to have recognized basic differential equations... :oops: But that class was sooo long ago... Anyway, when I knew what I was looking at, I actually managed to figure out how to make matlab do the heavy lifting for me (with ode23), but now the damn lambda is causing me trouble. I mean, if I read the damn exercise right, lambda=max(200*I*I,10^-6), but plugging that into the code makes ode23 cry... I'm not sure if the result is even supposed to be solvable. Help, again?
User avatar
Feil
Jedi Council Member
Posts: 1944
Joined: 2006-05-17 05:05pm
Location: Illinois, USA

Re: Math help

Post by Feil »

max(A, B) tells the computer to look at A, look at B, and output the bigger value. It can't do it if A and B aren't matrices of the same dimensions, e.g. since your B is a scalar A must also be a scalar. Make sure you haven't defined I as a multi-valued matrix, like a vector or something. If I is a vector, you'll need to reduce it to its scalar length before you can compare it to a scalar.

Obviously the computer needs to know what I is before it can tell you whether 200I2 is bigger than 10-6. So you mustn't call lambda until after the computer has loaded I with a numerical value.

EDIT: If that's not an option, I guess you could make the computer run the model twice, once for L=200I2 and once for L=10-6, use those to load I with a number, then have the computer check which L to use after the fact, discard the incorrect run, and output the result of the correct run. There might be a more elegant way of doing this, but I don't know MATLAB.
User avatar
Kuroneko
Jedi Council Member
Posts: 2469
Joined: 2003-03-13 03:10am
Location: Fréchet space
Contact:

Re: Math help

Post by Kuroneko »

If you're doing arithmetic elementwise rather than as matrices, use the . prefix for the operator.
For example, l*l is l by l multiplied as matrices, while l.*l is the matrix consisting of each individual element multiplied by itself.
Similarly, if you're not too concerned about optimization, you can get the max of matrix A and scalar B as max(A,B*ones(size(A)).
"The fool saith in his heart that there is no empty set. But if that were so, then the set of all such sets would be empty, and hence it would be the empty set." -- Wesley Salmon
Darn
Redshirt
Posts: 29
Joined: 2005-05-19 05:07pm

Re: Math help

Post by Darn »

I was a bit unclear, sorry. The "I" in question is one of the functions :wtf: . As I said, I'm not sure if I'm reading the assignment correctly.
Post Reply