~jdpipe/ascend/trunk-old

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
29
30
31
32
33
34
35
36
37
38
39
40
41
(*	ASCEND modelling environment
	Copyright (C) 2006 Carnegie Mellon University

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2, or (at your option)
	any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*)
REQUIRE "system.a4l";
(*
	Numeric root finding example, 5th order polynomial.
	
	This model is the first example in "Solved simple models with ASCEND"
	@TODO citation needed

	by Arthur Westerberg, 1997
*)

MODEL roots_of_poly;
    x IS_A generic_real;
    (x-1)*(x-5)*(x+7)*(x^2+1) = 0;

METHODS
	(* test-case checks convergence to just one of these roots *)
	METHOD on_load;
		x := 7.0001;
	END on_load;

	METHOD self_test;
		ASSERT (x - 1.0) < 1e-5;
	END self_test;
END roots_of_poly;
(* :ex: set ts=4: *)