Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.maple > #1177

Re: fitting curve to output of dsolve,numeric

Newsgroups comp.soft-sys.math.maple
Date 2015-08-13 07:18 -0700
References <mqhu85$15d$3@dont-email.me>
Message-ID <08cc7044-a44d-488b-b779-e47d953c9258@googlegroups.com> (permalink)
Subject Re: fitting curve to output of dsolve,numeric
From acer <maple@rogers.com>

Show all headers | View raw


On Thursday, August 13, 2015 at 7:16:58 AM UTC-4, William Unruh wrote:
> I am solving a set of ODEs with dsolve,numeric, and would like to fit a
> straight line to a portion of the output. I have no idea how I would do
> that. Ex, lets assume I have an equation
> diff(y(x),x)=5*I*y(x) +3
> y(0)=3
> and I want to fit a straight line to the output between x=70 to x=90
> (I know I can do this analytically but my actual problem is rather more complex
> than this.)

You can generate the x and y data and fit a line to that. You can generate the data using a procedure output from dsolve, or you can ask dsolve to return just such an Array of data.

restart:

deq := diff(y(x),x) = .1*y(x) + 3:
IC := y(0) = 3:

sol := dsolve({deq,IC},numeric,output=listprocedure):
Y := eval(y(x),sol):

xdata := [seq(80..90,.5)]:
ydata := map(Y,xdata):

lineseg := CurveFitting:-LeastSquares(xdata,ydata,x,curve=a*x+b):

plots:-display( plot(Y, 80..90),
                plot(lineseg, x=80..90,color=blue) );


Alternatively you could get dsolve itself to return the data (as a Matrix with x and y data in its two columns).

res := dsolve({deq,IC},numeric,output=Array(xdata)):

lineseg := CurveFitting:-LeastSquares(res[2][1],x,curve=a*x+b);


Hope I understood your goal properly. If instead you just wanted a line segment to be drawn between y(80) and y(90) then you can use the Y above and plottools:-line([80,Y(80)], [90,Y(90)]) .

Back to comp.soft-sys.math.maple | Previous | NextPrevious in thread | Find similar


Thread

fitting curve to output of dsolve,numeric William Unruh <unruh@invalid.ca> - 2015-08-13 11:15 +0000
  Re: fitting curve to output of dsolve,numeric acer <maple@rogers.com> - 2015-08-13 07:18 -0700

csiph-web