Skip to content

Mistake in numerical differentiation #297

@gustavdelius

Description

@gustavdelius

Mizer is based on the PDE
$$\frac{\partial N}{\partial t} = -\frac{\partial}{\partial w}(g,N)-\mu,N$$
that it solves numerically by approximating the derivatives with first-order finite-difference approximations. In particular it approximates the derivative with respect to $w$ with the backwards difference formula
$$\frac{\partial}{\partial w}f(w_i)\approx \frac{f(w_{i})-f(w_{i-1})}{\Delta w_i}$$
which is correct to first order if
$$\Delta w_i = w_{i}-w_{i-1}.$$
Unfortunately mizer is using
$$\Delta w_i = w_{i+1}-w_{i}.$$
Given mizer's logarithmically-spaced $w_i$, where $w_{i+1}/w_i=10^{dx}$ is a constant, this means that the derivative in mizer is too small by this factor. Given the way the derivative enters the PDE, this is equivalent to mizer working with a growth rate that is too big by this constant. It also means that the dynamics in mizer currently change as one changes the step size $dx$.

To give a feel for the size of this error: if fish sizes in the model range from 1mg to 10kg then the factor is about 1.18 when using 100 size bins and 1.08 when using 200 size bins.

When we switch to the correct scheme, we should automatically update all old-version params objects in such a way that their growth rates are increased by the factor $10^{dx}$ so that they continue to have the same dynamics as in the past. This would be easiest to do by registering a modified mizerEGrowth() function for them.

Alternatively we could set a flag in the old-version params objects that tells mizer to continue to use the wrong scheme for them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreIssue relates to the mizer corediscussionAn idea that needs discussion before becoming a proposalmajor effortResolving this issue will involve a major effort

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions