Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OKBJavaConnector/ECJClient/src/ec/app/regression/convertToMathematica.lisp @ 9598

Last change on this file since 9598 was 6152, checked in by bfarka, 14 years ago

added ecj and custom statistics to communicate with the okb services #1441

File size: 1.4 KB
Line 
1;;;
2;;; CLTL2 lisp script, prints out a Mathematica equivalent to a GP tree,
3;;; for testing purposes (Show[f[x],{x,-1,1} is useful)
4;;;
5
6(defun conv (exp)
7  (cond
8   ((not (listp exp)) "x")
9   ((equal (first exp) '+)
10    (concatenate 'string "Plus[" (conv (second exp)) "," (conv (third exp)) "]"))
11   ((equal (first exp) '-)
12    (concatenate 'string "Subtract[" (conv (second exp)) "," (conv (third exp)) "]"))
13   ((equal (first exp) '*)
14    (concatenate 'string "Times[" (conv (second exp)) "," (conv (third exp)) "]"))
15   ((equal (first exp) '%)
16    (concatenate 'string "PDivide[" (conv (second exp)) "," (conv (third exp)) "]"))
17   ((equal (first exp) 'exp)
18    (concatenate 'string "Exp[" (conv (second exp)) "]"))
19   ((equal (first exp) 'sin)
20    (concatenate 'string "Sin[" (conv (second exp))"]"))
21   ((equal (first exp) 'cos)
22    (concatenate 'string "Cos[" (conv (second exp))"]"))
23   ((equal (first exp) 'rlog)
24    (concatenate 'string "RLog[" (conv (second exp))"]"))))
25
26(print "PDivide[x_,y_] := If[y==0,1,x/y]")
27(print "RLog[x_] := If[x==0,1,Log[x]]")
28
29(princ (conv '(+ (sin (sin (+ (+ x x) (+ x x)))) (% (rlog
30     (* (* x x) (exp x))) (% (* (exp x) (rlog
31     x)) (sin (+ x x)))))))
32
33(conv '(+ x x))
34(conv '(sin x))
35
36(conv ' (+ (sin x) (* (+ (* (* (cos (rlog x)) x)
37     (+ (* (cos (rlog x)) x) (% x (cos (rlog x)))))
38     (% x (% x x))) x)))
Note: See TracBrowser for help on using the repository browser.