Changes

Jump to navigation Jump to search
That is .
Now we need a simple test (just like a 'ping'stub, nothing else)because usually sage is used in an interactive shell:
<pre>
## sagestub.pyfrom sage.all_cmdline import *</pre> <pre>\startluacodefunction test_SAGEMATHtest_ode(graphout)
require("python")
pg = python.globals() SAGESTUB = python.executeimport("from sagestub") sage = SAGESTUB.sage python.all_cmdline import execute([[def f_1(t,y,params): return[y[1],-y[0]-params[0]*y[1]*(y[0]**2-1)]]])python.execute([[def j_1(t,y,params): return [ [0,1.0],[-2.0*params[0]*y[0]*y[1]-1.0,-params[0]*(y[0]*y[0]-1.0)], [0,0] ]]])  T=sage.gsl.ode.ode_solver() T.algorithm="rk8pd"  f_1 = pg.f_1 j_1 = pg.j_1 pg.T=T  python.execute("T.function=f_1") dir T.jacobian= j_1 python.evalexecute("dirT.ode_solve(y_0=[1,0],t_span=[0,100],params=[10],num_points=1000)") printpython.execute(string.format("T.plot_solution(dirfilename='%s')",graphout ))
end
test_SAGEMATH\stopluacode \def\TestODE#1{%\ctxlua{test_ode("#1")}%\startcombination[2*1]{%foo\vbox{\hsize=8cmConsider solving the Van der pol oscillator  $x''(t) +ux'(t)(x(t)^2-1)+x(t)=0 $ </pre>between $t=0$ and $t= 100$.
<tt> $&gt;luatex test-SAGEMATH.lua </tt>As a first order system it is
You should see something like this:$x'=y$
<tt>$y'=-x+uy(1-x^2)$['AA'Let us take $u=10$ and use initial conditions $(x, 'AbelianGroup'y)=(1, 'AbelianGroupElement', 'AbelianGroupMap', 'AbelianGroupMorphism', 'AbelianGroupMorphism_id', 'AbelianGroup_class', 'AbelianGroup_subgroup', 'AbelianGroups', 'AbelianMonoids', 'AbelianSemigroups', 'AbelianVariety', 'AffineGeometryDesign', 'AffineSpace', 'Algebra', 'AlgebraElement', 'AlgebraIdeals', 'AlgebraModules', 'AlgebraicField', 'AlgebraicNumber', 'AlgebraicReal', 'AlgebraicRealField', 'Algebras', 'AllCusps', 'AllExactCovers', 'Alphabet', 'AlphabeticStrings', 'AlternatingGroup', 'AlternatingSignMatrices', 'AntichainPoset', 'Arrangements', 'AtkinModularCorrespondenceDatabase', 'AtkinModularPolynomialDatabase', 'AugmentedLatticeDiagramFilling', 'Axiom', 'BCHCode', 'Bessel', 'BinaryGolayCode', 'BinaryQF', 'BinaryQF_reduced_representatives', 'BinaryReedMullerCode', 'BinaryStrings', 'BinaryTree', 'BipartiteGraph', 'BlockDesign', 'BlockDesign_generic', 'BooleanLattice', 'BooleanPolynomialRing', 'CC', 'CDF', 'CFF', 'CIF'0)$ and use the\emphsl{\hbox{runga-kutta} \hbox{prince-dormand}} algorithm.}%}{\ss \ }{\externalfigure[#1][width=9cm]}{\ss Result for 1000 points}\stopcombination}
\starttext\startTEXpage\TestODE{ode1.....pdf}\stopTEXpage\stoptext
true', 'ttest', 'tuples', 'twinprime', 'twisted', 'two_squares', 'ultraspherical', 'uniform', 'union', 'uniq', 'unordered_tuples', 'unpickle_function', 'unset_verbose_files', 'unsigned_infinity', 'upgrade', 'valuation', 'var', 'vecsmall_to_intlist', 'vector', 'verbose', 'version', 'vert_to_ieq', 'victor_miller_basis', 'view', 'volume_hamming', 'vonmisesvariate', 'walltime', 'walsh_matrix', 'wave', 'weakref', 'weibullvariate', 'wiki', 'wiki_create_instance', 'with_statement', 'word_problem', 'words', 'wrapper', 'wronskian', 'x', 'xgcd', 'xinterval', 'xlcm', 'xmrange', 'xmrange_iter', 'xsrange', 'zero', 'zero_matrix', 'zeta', 'zeta_symmetric', 'zeta_zeros']</ttpre>
==ROOT (CERN) ==

Navigation menu