Re: Maxima and thread safety
Michel Talon <[email protected]> Thu, 11 Jun 2026 16:31:24 +0200
| Newsgroups | gmane.comp.mathematics.maxima.general |
|---|---|
| Message-ID | <[email protected]> |
Hello,
this is an other example in which threads work OK
(%i1) load("distribute_over_tranches_thread.lisp");
(%o1) distribute_over_tranches_thread.lisp
(%i2)
ee:x[i]^3+3*i^2*x[i]^2+8*i*x[i]^2+6*x[i]^2+6*i^3*x[i]+21*i^2*x[i]+26*i*x[i]
+11*x[i]+6*i^3+18*i^2+18*i+6$ /* A product of 3 factors */
(%i3) pp:partfrac(1/ee,x[i])$
(%i4) lll:makelist(subst(j,i,pp),j,1,10)$
(%i5) llt:distribute_over_tranches (partfrac(1/ee,x[i]),i,10,3)$
(%i6) is(lll=llt);
(%o6) true
In this example one runs partfrac with several main variables. Note that
partfrac communicates with a program bprog which computes X and Y such as
1/(AB)=X/A+Y/B which in turns makes a lot of euclidean divisions, all of
them communicating through the special variable *var* which is the
"main" variable
here x[i] for various values of i. You can note that the various main
variables don't get mixed by threading, that the x[i] are correctly
used, so the result
is correct.
Le 09/06/2026 à 17:15, David Scherfgen a écrit :
> You might add this to your examples:
>
> distribute_over_tranches(
> '(block(
> [x_n: float(N), x_next, i],
> for i : 1 thru 1000 do (
> x_next: 0.5 * (x_n + N / x_n),
> x_n: x_next
> ),
> x_n)),
> N, 1000, 16);
As for this example, consider the following formulation:
(%i1) compute(N):= (x:float(N), for i : 1 thru 10 do (
x: 0.5 * (x + N / x)), x)$
(%i2) ll:distribute_over_tranches(compute(i),i,100,5)$
(%i3) for i from 1 thru 100 do if (ll[i]-float(sqrt(i))>1e-15) then
print(i);
73
89
95
(%o3) done
The error in question in these 3 cases is of order of 2e-15. In other
words this also seems to work.
Note that if you iterate the inner loop to 1000 it takes forever to run,
maybe this what can be taken as thread problem.
--
Michel Talon
_______________________________________________
Maxima-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maxima-discuss