Why can't maxima solve...



1. "Quotient is not exact" is always the result of a bug. It
comes from computing the GCD G of two polynomials P, Q, and reducing
the fraction P/Q  to  P/G  / Q/G.   But it finds that G does
not divide P  or Q.  So it is a GCD bug. Try changing the GCDSWITCH
to use a different GCD algorithm.

2. I think that using a name like  solve_irrat  is preferable to
solve\-irrat.

3.  Try, after substitution, to use ratsimp or radcan.



Andrei Zorine wrote:
> Hello James,
> funny to find this letter in  the morning, because I've spent last night 
> teaching Maxima to solve irrational equations :)) I attach the code I 
> have so far.
> 
> Maxima has the ability to solve systems of polinomial equations (do 
> describe(solve)) only.
> 
> The procedure goes thru the expr from leaves to top, substituting all 
> irrational subexpressions containing vars with new variables and adds 
> rational equations to define these new variables. Finally it gets the 
> system of polynoimial equations and algsys tries to solve it. then all 
> the solutiona are substed into initial equations to check which are the 
> proper solutions.
> 
> The problems I've faced so far: 1)Algsys is slooooow 2) substituting 
> even correct solution into initial equations doesn't always simplify to 
> true 3) Usually Algsys gives approximate solutions (I know, I can alter 
> it  adjusting algexact, but it leads to 'quotient is not exact' errors, 
> like in algsys([S1-3*S2=2,(x+3)*S1^6=(x-5),(x-5)*S2^6=(x+3)],[S1,S2,x])).
> 
> Can somebody give advice concerning the problems mentioned above?
> 
> Example session:
> (C21) solve\-irrat(sqrt(1+x)=2,[x]);
> 
> [x]
> G22262 = 2
>        2
> [G22262  = x + 1]
> [[G22262 = 2, x = 3]]
> (D21)                    [[x = 3]]
> 
> -- 
> Andrei Zorine
> 
> James Frye wrote:
> 
>> ...something like this?
>>
>>   C1: f1(x):= x - 2 * sqrt (x);
>>   C2: solve (f(x) = 10, x);
>>
>> gives back
>>
>>   D2: [x = 2 SQRT(x) + 10]
>>
>> which IMHO isn't much of a solution :-)  But when I substitute y = sqrt
>> (x) to get an equivalent function
>>
>>   C3: f3(y):= y^2 - 2 * y;
>>   C4: float (solve (f2(y) = 10, y);
>>
>> I get two answers [y = -2.316, y = 4.316], and if I square the second, I
>> get a solution to f1?
>>
>> I'm puzzled.
>>
>> James
>>
>> _______________________________________________
>> Maxima mailing list
>> Maxima@www.math.utexas.edu
>> http://www.math.utexas.edu/mailman/listinfo/maxima
>>
>>
> 
> 
> ------------------------------------------------------------------------
> 
> solve\-irrat(expr,vars):=block(
>   [vars1:vars,expr1:expr,eqns:[],hasvars:false,newvar,eee2,k,ans:[],eee1],
>   if not listp(vars1) then vars1:[vars1],
>   preform(expr):=
>   (
>     if atom(expr) or constantp(expr) then 
>     (
>       if member(expr,vars1) then hasvars:true,expr
>       ) 
>     else
>     (
>       expr:map(preform,expr), 
>       if member(part(expr,0),["^",sqrt]) and hasvars and (length(expr)=1 or ratnump(part(expr,2))) then
>       (
> 	newvar:?gensym(), 
> 	vars1:cons(newvar,vars1),
> 	if member(part(expr,0),['SQRT]) then 
> 	(
> 	  eqns:cons(newvar^2=part(expr,1), eqns),
> 	  newvar
> 	  )
> 	else 
> 	(
> 	  eee2:part(expr,2), 
> 	  eqns:cons(newvar^denom(eee2)=part(expr,1),eqns),
> 	  newvar^num(eee2)
> 	  )
> 	) 
>       else expr
>       )
>     ),
>   expr1:preform(expr),  print(vars), print(expr1),print(eqns), 
>   eee2:solve(cons(expr1,eqns),vars1), print(eee2), 
>   zip(u,v,opname):=block([k],makelist(apply(opname, [part(u,k), part(v,k)]), k, 1,length(u))),
>   for k in eee2 do
>   if subst(k,expr) then ans:cons(zip(vars, subst(k,vars), "="),ans),
>   ans);
>