0
$\begingroup$

This question already has an answer here:

I'm making on a demo working with differential equations as functions of two variables (x and y). The demo will have to Fold the differential equation with an initial y-value and a series of x-values. Here's a simple code for the demo. The output should be a list on new y-values.

DynamicModule[{dydx = Null}, 
Deploy@
Panel@
Grid@
Transpose@
{{"Differential equation: (dy/dx)=", 
   "List of Slopes:"},
  {InputField[Dynamic[dydx]], 
   InputField[Dynamic[FoldList[dydx, 1, {0, 1, 2, 3}]]]}}]

The code doesn't work because dydx cannot be applied as a function in FoldList. "dydx" needs to be defined as a function f[y_,x_]. However, I'm not sure how to dynamically change a function using InputField.

f[y_,x_]= dydx
FoldList[f,1,{0,1,2,3}]

I'd like to have this as part of the Dynamic Module. Users would be able to input a function then receive a list of new y values.
Any advice?

$\endgroup$

marked as duplicate by Kuba, Dr. belisarius, ciao, Yves Klett, m_goldberg Apr 21 '14 at 6:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Hi, you may be interested in this topic. Which may be even considered duplicate. $\endgroup$ – Kuba Apr 18 '14 at 21:00
  • $\begingroup$ So, are you or I've missed the point? $\endgroup$ – Kuba Apr 19 '14 at 9:28
  • $\begingroup$ Wow, thanks for checking back in! That topic is exactly what I needed. $\endgroup$ – Shaggy1135 Apr 21 '14 at 0:23