Is there a way to specify the dependent variable in eulers_method?
Consider
sage: u,v = PolynomialRing(QQ,2, "uv").gens()
sage: eulers_method(2*u + v, 1, 5, 0.2, 4)
On the face of it it's ambiguous whether this is solving du/dv = 2*u + v with u(v=1) = 5 or if it's doing dv/du = 2*u + v with v(u=1)=5. In practice it solves the latter, but how is that determined?
It appears to hinge on the order of u and v on the LHS of the first line but I can't find any mention of this in the documentation.
Asking for the code via
??eulers_method
and going till the end, we get it and there is an obvious asymmetry in the variablesx0
andy0
,so
h
is married withx0
.How is the order of the arguments of f determined from the input expression?
The call in the example is:
The arguments above are placed inside the definition as follows:
f
becomes2*u+v
andx0
becomes1
, andy0
is5
, andh
is the step.2
and we go tillx1
which is4
. The question is now, how we computei.e. why do we get
and not
11
. Instead of answering this question, i would prefer to use a proper function in the call. so that there is no such question, depending on hidden structure. For instance:a.s.o.