Derivative of an interpol function, what to do with charfun2
Subject: Derivative of an interpol function, what to do with charfun2
From: Mario Rodriguez
Date: Sat, 23 Nov 2013 18:24:22 +0100
El 23/11/13 17:16, ???????? ?????? escribi?:
> |f:log(%e^(-x)+sin(y))$
> y0:1$
> x1:0$
> x2:10$
> n:40$
> s:float((x2-x1)/n);
> results: rk(f,y,y0,[x,x1,x2,s])$
> load(interpol)$
> g:cspline(results)$|
After claculating g, write
define(
e(x),
block([terms, cubics, charac],
/* 1 */ terms: args(g),
/* 2 */ cubics: map(first, terms),
/* 3 */ charac: map(second, terms),
/* 4 */ (diff(cubics,x) - f).charac) )$
1: list of the terms of g
2: list with the cubic polynomials
3: list of the corresponding charfun2's
4: differentiate, subtract f and multiply each residual by the
corresponding charfun2 call.
Now, you can calculate:
e(5.6);
I think this is what you are asking for. Perhaps you have to make some
changes to fit your specific needs.
> |
> d:diff(g,x);
> e:d-f;|
> I want to get some values of e between x1 and x2 and output a descrete
> plot of this values. The problem is that when cspline returns
> function, the function includes charfun2() functions, and when I'm
> trying to get for example e(1) diff says that he expects a variable as
> a second argument, but finds a number. After taking diff there
> shouldn't be any diffs left, but they are written before charfun2.
> e(x,y) is a <a
> href='https://en.wikipedia.org/wiki/Residual_%28numerical_analysis%29'>residual</a>.
>
> Is it at least possible in maxima?
--
Mario