# Revision history [back]

Hi,

Another option is to use the function desolve_odeint (from version 4.6 on, see the docs on desolve_odeint?), which uses the odeint solver internally, but takes as an input symbolic funcions . For instance, to integrate the Lorenz attractor, you would do

 sage: x,y,z=var('x,y,z') # Declare the variables
sage: lorenz=[10.0*(y-x),x*(28.0-z)-y,x*y-(8.0/3.0)*z]
sage: times=srange(0,50.05,0.05) # Integration Time
sage: ics=[0,1,1] # and initial conditions
sage: sol=desolve_odeint(lorenz,ics,times,[x,y,z]) #integrate


to plot the attractor, simply:

sage: line3d(sol)


I do not know what you mean exactly by the double pendulum, but here it is something similar:

sage: theta1,theta2,x1,x2=var('theta1,theta2,x1,x2')
sage: dpendulum=[x1,x2,-sin(theta1)-0.1*sin(theta2),-sin(theta2)+0.1*sin(theta1)]
sage: # Time and initial conditions
sage: times=srange(0,50.05,0.05)
sage: ics=[1,1,0,0]
sage: sol=desolve_odeint(dpendulum,ics,times,[theta1,theta2,x1,x2])


and a nice plot is here

sage: graphics_array([line(zip(sol[:,0],sol[:,2])),line(zip(sol[:,1],sol[:,3]))])


Joaquim Puig
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.8616523146629333, "perplexity": 11900.018165348925}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 20, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2021-39/segments/1631780056578.5/warc/CC-MAIN-20210918214805-20210919004805-00271.warc.gz"}