I need help in Maxima (a "simple" problem [how is the syntax for the formula])
Subject: I need help in Maxima (a "simple" problem [how is the syntax for the formula])
From: Steve Haflich
Date: Mon, 29 May 2006 23:01:41 -0700
From: "Robert BIGDOWSKI" <robert.bigdowski at dudelange.lu>
a, b, n natural numbers > 0
a+b <= x
how many solutions f(x) exists
with { a+b | a * b }, ie a*b = (a+b) * n
as a starter. Has anyone an idea how to start - browsing through the
documentation of maxima did't give me an idea.
You don't state whether you want a closed-form solution or a
computational procedure. The latter is easily achieved in almost any
ceneral-purpose computer language, and since Maxima provides escape to
Common Lisp, writing a simple function in Common Lisp would be one way
to start. In Common Lisp:
(defun f (x)
(loop for a from 1 below x
sum (loop for b from 1 upto (- x a)
when (= 0 (mod (* a b) (+ a b)))
count 1)))
This solution has O^2 behavior, but is tolerably fast enough to solve
(f 100000) in less than a minute on a fast computer.