Hi,
I just wanted to thank the folks on this list for their help and input.
It turned out that loading additional packages took too long, which ruled out the otherwise perfect package "solvereal" by Mikael S?rensen, and also solution (d) below - LON-CAPA gets hit very hard during homework crunch time. Since we need to do a kill(all) between transactions, we would have needed to reload packages every time.
I ended up coding something along the lines of solution (a) below, only that the loop was implemented on the Perl-side. A sample problem is at
http://source.lon-capa.org/cgi-bin/cvsweb.cgi/loncom/homework/templates/custom_equation.problem?rev=1.1;content-type=text%2Fplain
for anybody who might be interested. Eventually, we might turn this into a real homework type, like http://www.lon-capa.org/cas.html
Thanks again, and thanks for Maxima,
- Gerd.
On Jan 22, 2012, at 2:08 PM, Aleksas Domarkas wrote:
> from http://www.math.utexas.edu/pipermail/maxima/2012/027525.html
> Gerd Kortemeyer:
> Hi,
>
> We have been using MAXIMA successfully inside of LON-CAPA for homework problems for several years now - it's a great tool, thanks everybody!!!
>
> While authoring a new kind of homework, I am struggling with "declare" - why does the following (sample) code not give the expected results?
>
> (%i4) declare(x,real);
> (%o4) done
> (%i5) solve(x^3=125,x);
> 5 sqrt(3) %i - 5 5 sqrt(3) %i + 5
> (%o5) [x = ----------------, x = - ----------------, x = 5]
> 2 2
> (%i6) facts();
> (%o6) [kind(x, real)]
>
> Is there another way to tell "solve" to stay in the real realm?
>
> Thanks!
>
> - Gerd.
>
> ***********************************************************************************
>
> How to get only real solutions of polynomial equation?
> I know these methods:
> a)
> (%i1) sol:solve(x^3=125,x);
>
> (%o1) [x=(5*sqrt(3)*%i-5)/2,x=-(5*sqrt(3)*%i+5)/2,x=5]
>
> (%i2) sublist(sol,lambda([e],freeof(%i,e)));
> (%o2) [x=5]
>
> b)
> (%i3) realonly:true$
> realroots(x^3=125);
> (%o4) [x=5]
>
> c)
> (%i5) realonly:true$
>
> algsys([x^3=125],[x]);
>
> (%o6) [[x=5]]
>
> d)
> (%i7) realonly:true$
> to_poly_solve([x^3=125], [x]);
> Loading maxima-grobner $Revision: 1.6 $ $Date: 2009-06-02 07:49:49 $
> (%o8) %union([x=5])
> (%i9) first(%);
>
> (%o9) [x=5]
>
>
> Aleksas D
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima