File: plots.mpt

package info (click to toggle)
mathpiper 0.0.svn2556-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 7,416 kB
  • ctags: 2,729
  • sloc: java: 21,643; xml: 751; sh: 105; makefile: 5
file content (28 lines) | stat: -rw-r--r-- 1,130 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

// some tests to verify that plotting works

/* I stringified the results for now, as that is what the tests used to mean. The correct way to deal with this
 * would be to compare the resulting numbers to accepted precision.
 */
Verify(ToString()Write(Plot2D(a,-1:1,output->data,points->4,depth->0)), "{{{-1,-1},{-0.5,-0.5},{0,0},{0.5,0.5},{1.,1.}}}");
Verify(ToString()Write(Plot2D(b,b-> -1:1,output->data,points->4)), "{{{-1,-1},{-0.5,-0.5},{0,0},{0.5,0.5},{1.,1.}}}");

[
  Local(result);
  result:="{{{-1,-1,-1},{-1,0,-1},{-1,1.,-1},{0,-1,0},{0,0,0},{0,1.,0},{1.,-1,1.},{1.,0,1.},{1.,1.,1.}}}";
  Verify(ToString()Write(Plot3DS(a,-1:1,-1:1,output->data,points->2)), result);
  Verify(ToString()Write(Plot3DS(x1,x1 -> -1:1,x2 -> -1:1,output->data,points->2)), result);
];


// test NFunction
BuiltinPrecisionSet(10);
Retract("f",1);
Retract("f1",1);
f(x) := N(Abs(1/x-1));
Verify(f(0), Infinity);
NumericEqual(RoundTo(f(3),BuiltinPrecisionGet()), 0.6666666667,BuiltinPrecisionGet());
NFunction("f1", "f", {x});
Verify(f1(0), Undefined);
NumericEqual(RoundTo(f1(3),BuiltinPrecisionGet()), 0.6666666667,BuiltinPrecisionGet());