[newbie] why does ratsimp not work here?



Why do you expect the result to be (4*s+1)/(2*s^2+4*s+1)?

Look at the unsimplified expression ((s+1)/2+s)/((s+1/2)*(s+1)-s^2).

Multiply out the numerator: ((s+1)/2+s) => 1/2*s + 1/2 + s => 3/2*s + 1/2
Multiply out the denominator: ((s+1/2)*(s+1)-s^2) => s^2 + 1/2*s + s + 1/2 -
s^2 => 3/2*s + 1/2
Numerator and denominator are equal, so quotient is 1.

(%i1) display2d:false$
(%i2) g:matrix([3/2,-1/2,-1],[-1/2,1/2+s,-s],[-1,-s,1+s]);
(%o2) matrix([3/2,-1/2,-1],[-1/2,s+1/2,-s],[-1,-s,s+1])
(%i3) currents:matrix([1],[0],[0]);
(%o3) matrix([1],[0],[0])
(%i4) u:invert(g).currents;
(%o4)
matrix([((s+1/2)*(s+1)-s^2)/(3*((s+1/2)*(s+1)-s^2)/2-((s+1)/2+s)/2-3*s/2-1/2)],

[((s+1)/2+s)/(3*((s+1/2)*(s+1)-s^2)/2-((s+1)/2+s)/2-3*s/2-1/2)],[(3*s/2+1/2)/(3*((s+1/2)*(s+1)-s^2)/2-((s+1)/2+s)/2-3*s/2-1/2)])
(%i5) result: u[2]/u[1];
(%o5) [((s+1)/2+s)/((s+1/2)*(s+1)-s^2)]
(%i6) ratsimp(%);
(%o6) [1]


On Thu, Oct 29, 2009 at 1:05 PM, Hugo Coolens <coolens at kahosl.be> wrote:

> Following your suggestion I changed the floats by there rational
> equivalents and redid the whole but finally I'm left with:
>
> (%i71) result:u[2]/u[1];
>                                  s + 1
>                                  ----- + s
>                                    2
> (%o71)                      [--------------------]
>                                  1             2
>                             (s + -) (s + 1) - s
>                                  2
> (%i72) ratsimp(result);
> (%o72)                                [1]
>
> and I hoped to see:
>
>
> 4s+1
> ____
> 2s^2+4s+1
>


> what am I doing wrong?
>
> hugo
>
>
>
>
>
>
> On Thu, 29 Oct 2009, Stavros Macrakis wrote:
>
>  I also get those warnings (which you can turn off by setting
>> ratprint:false), but I get the result [1] in the end:
>>
>> (%i14) [(0.5*(s+1)+s)/((s+0.5)*(s+1)-s^2)];
>> (%o14) [(0.5*(s+1)+s)/((s+0.5)*(s+1)-s^2)]
>> (%i15) ratsimp(%);
>> `rat' replaced 0.5 by 1/2 = 0.5
>>
>> `rat' replaced 0.5 by 1/2 = 0.5
>> (%o15) [1]
>>
>> By the way, Maxima in general works better with exact numbers (1/2)
>> rather than floats (0.5).
>>
>>             -s
>>
>> On Thu, Oct 29, 2009 at 12:48 PM, Hugo Coolens <coolens at kahosl.be> wrote:
>>      u:invert(g).currents;
>>      result:u[2]/u[1];
>>
>>
>>
>>