Created
October 26, 2011 15:19
-
-
Save FooBarrior/1316659 to your computer and use it in GitHub Desktop.
NM expirement. Author: Pousqie
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* [wxMaxima batch file version 1] [ DO NOT EDIT BY HAND! ]*/ | |
/* [ Created with wxMaxima version 11.08.0 ] */ | |
/* [wxMaxima: input start ] */ | |
load(draw)$ | |
Lagrange(x, fn, X, N) := | |
sum( | |
fn(X[i]) * product( | |
if equal(i, j) | |
then 1 | |
else | |
(x - X[j]) / (X[i] - X[j]), | |
j, 1, N), | |
i, 1, N); | |
/* [wxMaxima: input end ] */ | |
/* [wxMaxima: input start ] */ | |
L:[1, 25, 12, 8, 3, 2.17, 23, 22.4, 19, 24, 0, 13, 23.9, 7, 10.88888]$ | |
J[0](x) := sin(x)$ | |
J[1](x) := abs(x-12)/10$ | |
fnum : 0$ | |
xmin: 0$ | |
xmax: 25$ | |
f(x, N) := Lagrange(x, J[fnum], L, N)$ | |
/* [wxMaxima: input end ] */ | |
/* [wxMaxima: input start ] */ | |
for k:1 thru length(L) do | |
draw2d( | |
terminal = png, | |
file_name = concat("mxga", if k < 10 then concat(0,k) else k), | |
dimensions = [600, 200], | |
yrange = [-1, 1], | |
color = blue, | |
explicit(f(x, k), x, xmin, xmax), | |
color = red, | |
explicit(J[fnum](x), x, xmin, xmax) | |
); | |
system("convert -delay 100 mxga*.png plot.gif && rm mxga*")$ | |
/* [wxMaxima: input end ] */ | |
/* [wxMaxima: input start ] */ | |
wxplot2d([J[fnum](x), f(x, length(L))], [x,xmin,xmax])$ | |
/* [wxMaxima: input end ] */ | |
/* Maxima can't load/batch files which end with a comment! */ | |
"Created with wxMaxima"$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment