Skip to main content
Included more code
Source Link
Chloe
  • 175
  • 6

So I am playing around with an interpolation polynomial. The code for what I am trying to do is computationally heavy:

p[x_, n_]:=Sum[f[Table[15*(k/n),{k,0,n}][[i]]]*Product[Piecewise[{{(x-Table[15*(k/n),{k, 0, n}][[j]])/(Table[15*(k/n),{k,0,n}][[i]]-Table[15*(k/n),{k,0,n}][[j]]),Not[i==j]},{1,i == j}}],{j,1,Length[Table[15*(k/n),{k,0,n}]]}],{i,1,Length[Table[15*(k/n),{k,0,n}]]}];

Or in math because that code looks unreadable:

$$p(x,n):=\left\{ \sum^{n}_{i=0}\left( f(x_i)\left(\prod_{j\neq i}\frac{x-x_j}{x_i-x_j} \right) \right) : i,j\in \mathbb{Z}^{+}_{n} \ \ and\ \ \left\{x_i \right\}_{i=0}^{n}= \frac{15*i}{n} \right\}$$

I want to export this as a gif up to $n=20$. Unfortunately, I get $Aborted around $n=16$.

Exported .gif file

So now my question: Is there any way I can get Mathematica to not abort?

As always, I appreciate any and all help.

EDIT: I received a comment to include all my code so below is the code I excluded initially:

f[x_]=x*Sin[x^(1.5)]; Export[“coolthing.gif”,Manipulate[Plot[{f[x],p[x,n]},{x,0,15}],{n,1,20}],”GIF”];

So I am playing around with an interpolation polynomial. The code for what I am trying to do is computationally heavy:

p[x_, n_]:=Sum[f[Table[15*(k/n),{k,0,n}][[i]]]*Product[Piecewise[{{(x-Table[15*(k/n),{k, 0, n}][[j]])/(Table[15*(k/n),{k,0,n}][[i]]-Table[15*(k/n),{k,0,n}][[j]]),Not[i==j]},{1,i == j}}],{j,1,Length[Table[15*(k/n),{k,0,n}]]}],{i,1,Length[Table[15*(k/n),{k,0,n}]]}];

Or in math because that code looks unreadable:

$$p(x,n):=\left\{ \sum^{n}_{i=0}\left( f(x_i)\left(\prod_{j\neq i}\frac{x-x_j}{x_i-x_j} \right) \right) : i,j\in \mathbb{Z}^{+}_{n} \ \ and\ \ \left\{x_i \right\}_{i=0}^{n}= \frac{15*i}{n} \right\}$$

I want to export this as a gif up to $n=20$. Unfortunately, I get $Aborted around $n=16$.

Exported .gif file

So now my question: Is there any way I can get Mathematica to not abort?

As always, I appreciate any and all help.

So I am playing around with an interpolation polynomial. The code for what I am trying to do is computationally heavy:

p[x_, n_]:=Sum[f[Table[15*(k/n),{k,0,n}][[i]]]*Product[Piecewise[{{(x-Table[15*(k/n),{k, 0, n}][[j]])/(Table[15*(k/n),{k,0,n}][[i]]-Table[15*(k/n),{k,0,n}][[j]]),Not[i==j]},{1,i == j}}],{j,1,Length[Table[15*(k/n),{k,0,n}]]}],{i,1,Length[Table[15*(k/n),{k,0,n}]]}];

Or in math because that code looks unreadable:

$$p(x,n):=\left\{ \sum^{n}_{i=0}\left( f(x_i)\left(\prod_{j\neq i}\frac{x-x_j}{x_i-x_j} \right) \right) : i,j\in \mathbb{Z}^{+}_{n} \ \ and\ \ \left\{x_i \right\}_{i=0}^{n}= \frac{15*i}{n} \right\}$$

I want to export this as a gif up to $n=20$. Unfortunately, I get $Aborted around $n=16$.

Exported .gif file

So now my question: Is there any way I can get Mathematica to not abort?

As always, I appreciate any and all help.

EDIT: I received a comment to include all my code so below is the code I excluded initially:

f[x_]=x*Sin[x^(1.5)]; Export[“coolthing.gif”,Manipulate[Plot[{f[x],p[x,n]},{x,0,15}],{n,1,20}],”GIF”];

Source Link
Chloe
  • 175
  • 6

Can You Configure Mathematica to Not Abort?

So I am playing around with an interpolation polynomial. The code for what I am trying to do is computationally heavy:

p[x_, n_]:=Sum[f[Table[15*(k/n),{k,0,n}][[i]]]*Product[Piecewise[{{(x-Table[15*(k/n),{k, 0, n}][[j]])/(Table[15*(k/n),{k,0,n}][[i]]-Table[15*(k/n),{k,0,n}][[j]]),Not[i==j]},{1,i == j}}],{j,1,Length[Table[15*(k/n),{k,0,n}]]}],{i,1,Length[Table[15*(k/n),{k,0,n}]]}];

Or in math because that code looks unreadable:

$$p(x,n):=\left\{ \sum^{n}_{i=0}\left( f(x_i)\left(\prod_{j\neq i}\frac{x-x_j}{x_i-x_j} \right) \right) : i,j\in \mathbb{Z}^{+}_{n} \ \ and\ \ \left\{x_i \right\}_{i=0}^{n}= \frac{15*i}{n} \right\}$$

I want to export this as a gif up to $n=20$. Unfortunately, I get $Aborted around $n=16$.

Exported .gif file

So now my question: Is there any way I can get Mathematica to not abort?

As always, I appreciate any and all help.