Generating random expressions

37 views
Skip to first unread message

Waldek Hebisch

unread,
Jan 2, 2020, 2:03:02 PM1/2/20
to fricas...@googlegroups.com
Recently Facebook people (G. Lample and F. Charton) wrote about
training neural network to integrate based on derivatives of
random functions. And they showed not so favourable figures
for Mathematica and Maple.

I implemented a little generator which should give similar
distribution as used by Lample and Charton. I write
"similar" as they skip some concrete details and overall
description seem unnecesarily complicated. Anyway,
when you save the attached script 'tree2.input' and do:

)read tree2.input
gen_file("foo_ii.input")

it will generate file with 1000 random integration problems.

ATM there is trouble that some problem contain division by 0.
OTOH it was enough to uncover several bugs in FriCAS
integrator.

It seems that currently FriCAS is able to do about 78% of
random problem. Few relatively simple changes to handle
easy special cases should move this up quite a bit. But
there is also trouble with long running time on some
examples...

--
Waldek Hebisch
tree2.input

Kurt Pagani

unread,
Jan 3, 2020, 6:01:43 PM1/3/20
to fricas...@googlegroups.com
Quite interesting! But some will take rather long (~1h) e.g. the second in rint0
(almost quicker solved by hand ;). Nevertheless very useful to find a leak.

Recently I tried to convert LISP examples, especially "tilu.lisp" from

RJF's website: https://people.eecs.berkeley.edu/~fateman/examples.in

Surpisingly, it works: tilu.input -> tilu_ints.input -> tilu_ints.out.
it takes only a fes seconds to eval the >2000 integrals (amazing).
Some tricks are necessary, because the arity of LISP (*) and (+) is not
restricted to 2. The reason why I mention this here, there seems to be random
integral generators for CL and I found a strange behavior when entering "add" or
trying to convert the symbol "+" to InputForm:


(1) -> add
Line 1: add
A
Error A: syntax error at top level
Error A: Improper syntax.
2 error(s) parsing

(2) -> pp:INFORM:='+::INFORM
Line 1: pp:INFORM:='+::INFORM
.............A
Error A: Improper syntax.
1 error(s) parsing

(2) -> pp:INFORM:='*::INFORM

(2) *
Type: InputForm
(3) -> pp:INFORM:='/::INFORM

(3) /
Type: InputForm


Any idea?
tilu.lisp
tilu.input
tilu_ints.input
tilu_ints.out
rint0.input

Waldek Hebisch

unread,
Jan 11, 2020, 8:47:27 AM1/11/20
to fricas...@googlegroups.com
On Sat, Jan 04, 2020 at 12:01:45AM +0100, Kurt Pagani wrote:
> Quite interesting! But some will take rather long (~1h) e.g. the second in rint0
> (almost quicker solved by hand ;).

It is very easy example, ATM I do not know why it takes so much
time.

> Nevertheless very useful to find a leak.
>
> Recently I tried to convert LISP examples, especially "tilu.lisp" from
>
> RJF's website: https://people.eecs.berkeley.edu/~fateman/examples.in
>
> Surpisingly, it works: tilu.input -> tilu_ints.input -> tilu_ints.out.
> it takes only a fes seconds to eval the >2000 integrals (amazing).
> Some tricks are necessary, because the arity of LISP (*) and (+) is not
> restricted to 2. The reason why I mention this here, there seems to be random
> integral generators for CL and I found a strange behavior when entering "add" or
> trying to convert the symbol "+" to InputForm:
>
>
> (1) -> add
> Line 1: add
> A
> Error A: syntax error at top level
> Error A: Improper syntax.
> 2 error(s) parsing

'add' is a keyword, no wonder that parser complains. Use '_add'
if you need to disable its syntactic significance.

> (2) -> pp:INFORM:='+::INFORM
> Line 1: pp:INFORM:='+::INFORM
> .............A
> Error A: Improper syntax.
> 1 error(s) parsing

addition is also special.

--
Waldek Hebisch

Kurt Pagani

unread,
Jan 11, 2020, 11:32:28 AM1/11/20
to fricas...@googlegroups.com
>> (1) -> add
>> Line 1: add
>> A
>> Error A: syntax error at top level
>> Error A: Improper syntax.
>> 2 error(s) parsing
>
> 'add' is a keyword, no wonder that parser complains. Use '_add'
> if you need to disable its syntactic significance.

Yes, how stupid of me :(
I must have mixed up 'add and '+ somehow ...
Undersocres actually work in all cases so far.
Thanks!
Reply all
Reply to author
Forward
0 new messages