DIFFEQN
DIFFEQN x0, y0, xf, maxseg, maxerr, BYREF yf, BYREF errcode USE expr
Solving first-order differential equations using Runge-Kutta method.
expr
: f(y,x) = dy/dx with start condition: y(x = x0) = y0x0
,y0
: initial x, y
xf
: final xyf
: resultmaxseq
: equivalent to precisionmaxerr
: maximum allowed errorerrcode
: 0 for success; otherwise calculation error
Example 1
' Solving dy/dx = 7*y^2 * x^3 with start condition y(2) = 3
def f1(x,y) = 7*y^2 * x^3
3
y0 = 2
x0 = 0
yf = 1
xf = 10000
maxseg = 0.001
maxerr = 0
errcode =
diffeqn x0, y0, xf, maxseg, maxerr, yf, errcode USE f1(x,y)
' Exact solution for comparision
def g1(x) = -1 / (7/4 * x^4 - 85/3)
print "g1(xf) = "; g1(xf)
print "yf(xf) = "; yf
if(errcode != 0) then
print "Error solving equation"
print "Increasing maxseg might help"
endif
Example 2
' Defining the differential equation for a stiffness system
def f2(y,t) = -1000*y + 3000 - 2000 * exp(-t)
' Solving equation at time tf = 0.001 seconds with y(0) = 0
0
y0 = 0
t0 = 0
yf = 0.001
tf = 1000
maxseg = 0.001
maxerr = 0
errcode =
diffeqn t0, y0, tf, maxseg, maxerr, yf, errcode USE f2(y,t)
' Exact solution for comparision
def g2(t) = 3 - 0.998*exp(-1000*t) - 2.002 * exp(-t)
print "g2(tf) = "; g2(tf)
print "yf(tf) = "; yf
if(errcode != 0) then
print "Error solving equation"
print "Increasing maxseg might help"
endif
Math
ABS
ABSMAX
ABSMIN
ACOS
ACOSH
ACOT
ACOTH
ACSC
ACSCH
ASEC
ASECH
ASIN
ASINH
ATAN
ATAN2
ATANH
ATN
CEIL
COS
COSH
COT
COTH
CSC
CSCH
DEG
DERIV
DETERM
DIFFEQN
EXP
EXPRSEQ
FIX
FLOOR
FRAC
INT
INTERSECT
INVERSE
LINEQN
LOG
LOG10
M3APPLY
M3IDENT
M3ROTATE
M3SCALE
M3TRANS
MAX
MIN
POLYAREA
POLYCENT
POLYEXT
POW
PTDISTLN
PTDISTSEG
PTSIGN
RAD
RND
ROOT
ROUND
SEC
SECH
SEGCOS
SEGLEN
SEGSIN
SEQ
SGN
SIN
SINH
SQR
STATMEAN
STATMEANDEV
STATMEDIAN
STATSPREADP
STATSPREADS
STATSTD
SUM
SUMSQ
TAN
TANH
TRANSPOSE
If there is insufficient information on this page and you wish learn more about DIFFEQN,
please send an email to smallbasic@gmail.com. You can help to improve information about
DIFFEQN by submitting a pull request,
click View Source for details. Note, an offline language reference text file is also available - see the Download section.