Question: Avoiding placeholders for symbolic differentiation of user-defined functions

I’m currently working on a Maple project involving the symbolic differentiation of a user-defined potential energy function, which I then use in a system of differential equations. To implement this, I've been using placeholders like 'Un' when taking derivatives to substitute later during numerical calculations.

While this approach using placeholders works, I find it cumbersome and would prefer a more straightforward way to handle this symbolic differentiation without having to rely on intermediate placeholders like 'Un'.

Does anyone know if there is a more elegant way in Maple to achieve this functionality?

Specific Requirements:

  • I want to symbolically differentiate the user-defined function W directly.
  • The goal is to use this derivative in a system of differential equations for numerical solving.

Any suggestions on simplifying this process would be much appreciated!

Thanks in advance.

restart

NULL
W := proc (Un) options operator, arrow; -(1/4)*(b*d-e*q)^2/(b^2*(e+b*Un^2))-(2*b*c*m^2+(1/4)*q^2)*Un^2/b+c*Un^4 end proc

proc (Un) options operator, arrow; -(1/4)*(b*d-e*q)^2/(b^2*(e+b*Un^2))-(2*b*c*m^2+(1/4)*q^2)*Un^2/b+c*Un^4 end proc

(1)

 

 

diff(W(Un), Un)

(1/2)*(b*d-e*q)^2*Un/(b*(Un^2*b+e)^2)-2*(2*b*c*m^2+(1/4)*q^2)*Un/b+4*c*Un^3

(2)

b := -0.3070816340e-3; c := .4461893869; d := 0.1142581922e-1; e := 0.7675000601e-3; q := -0.3704049149e-2; m := 1.423206983; plot(W(Un), Un = -10 .. 10, title = "Graph of Potential W for set 1", color = blue, axes = boxed)

 

with(plots); with(DEtools); delta := .5; b := -0.222159366e-3; c := 1.088046084; d := 0.1308858509e-2; e := 0.394423507e-3; q := -0.64844084e-3; m := 1.518466566; W := proc (Un) options operator, arrow; -(1/4)*(b*d-e*q)^2/(b^2*(e+b*Un^2))-(2*b*c*m^2+(1/4)*q^2)*Un^2/b+c*Un^4 end proc; Un_placeholder := 'Un'; Wprime := diff(W(Un_placeholder), Un_placeholder); sys := {diff(u(t), t) = v(t), diff(v(t), t) = -delta*v(t)+subs(Un_placeholder = u(t), Wprime)}; ics1 := {u(0) = 0.1e-1, v(0) = 0.1e-1}; sol := dsolve(`union`(sys, ics1), numeric, output = listprocedure); xrange := -0.10e-1 .. 0.11e-1; yrange := -0.3e-1 .. 0.3e-1; phase_plot := odeplot(sol, [u(t), v(t)], 0 .. 100, title = "Phase Plot (Velocity vs Displacement)", numpoints = 8000, color = red, labels = ["u(t)", "v(t)"], axes = boxed, labeldirections = [horizontal, vertical]); vectorfield_plot1 := fieldplot([v, -delta*v+subs(Un_placeholder = u, Wprime)], u = xrange, v = yrange, arrows = medium, color = blue, axes = boxed); display([vectorfield_plot1, phase_plot], title = "Combined Phase Plot and Vector Field", labels = ["u(t)", "v(t)"], axes = boxed)

 

NULL

Download proteins.mw

Please Wait...