Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Data Fitting to Differential Equations' topicStudent Support Forum > General > "Data Fitting to Differential Equations"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
Author Comment/Response
yehuda ben-shimol
10/02/05 2:20pm

Dear Frank,
First, this is my mistake. This implementation works, since (and I didn't notice it at the time, sorry again) that the A,B,C,D were actually arguments for your HSE function which was used with a SetDelayed (:=).

A recommendation before answering your original question - If you would like to be on the safe side, change all the arguments to small caps. you may never know, if in future releases other capital letters will be used.

The meaning of the last line in your HSE function
Plus @@ Apply[(f[#1] - #2)^2 &, data, {1}] /. sol
means that (sorry of this sound too obvious, but this is relevant for your case to 3 arguments)

1. for each element of the data list (that is, each element is by itself a list with two elements) the replaced f is applied on the first element, the second elemnt is subtracted from it and the difference is squared. The result is a also a list
2. f is replaced by the solution of NDSolve (that is, "sol" variable)
3. the elements of the list after replacing f are summed

Now, concentrate on step 1 above. What would you like to do with the third element, when d is as described in your post? This will defined the value returned by your HSE function, that is, changing its last line according to your needs.
say that you want to Add it so the last line would be changed to

Plus @@ Apply[(f[#1] - #2)^2+#3 &, data, {1}] /. sol

The pure functions format of Mathematica is to use #n to the n'th argument of a function, so
# or #1 is for the first argument
#2 for the second argument
#3 for the third argument (what you need)
etc.

best regards,
yehuda

URL: ,

Subject (listing for 'Data Fitting to Differential Equations')
Author Date Posted
Data Fitting to Differential Equations Dr. Frank So... 09/28/05 6:01pm
Re: Data Fitting to Differential Equations yehuda ben-s... 09/30/05 00:25am
Re: Data Fitting to Differential Equations Frank Solina... 09/30/05 4:12pm
Re: Data Fitting to Differential Equations Frank Solina... 10/01/05 08:26am
Re: Data Fitting to Differential Equations yehuda ben-s... 10/02/05 2:20pm
Re: Data Fitting to Differential Equations FRanc Solina... 10/05/05 4:48pm
Re: Data Fitting to Differential Equations Franc Solina... 10/13/05 09:12am
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic