rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

radcan seems to give non-equvalent function #2969

Open rtoy opened 4 months ago

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-07 08:27:12 Created by jyoberle on 2012-10-16 15:03:54 Original: https://sourceforge.net/p/maxima/bugs/2479


Hi,

When doing radcan(-(2*x)/(sqrt(1-(x^2-1)^2)*sqrt(1-asin(x^2-1)^2))), the result is -2/(sqrt(2-x^2)*sqrt(1-asin(x^2-1))*sqrt(asin(x^2-1)+1)). But these two expressions are not equivalent. For x = -0.4, -(2*x)/(sqrt(1-(x^2-1)^2)*sqrt(1-asin(x^2-1)^2)) gives 20.01585798944382 wheras -2/(sqrt(2-x^2)*sqrt(1-asin(x^2-1))*sqrt(asin(x^2-1)+1)) gives -20.01585798944383. -(2*x)/(sqrt(1-(x^2-1)^2)*sqrt(1-asin(x^2-1)^2)) is the result of diff(acos(asin(x^2-1)),x) if this can help. Build info is build_info("5.28.0-2","2012-08-27 23:16:48","i686-pc-mingw32","GNU Common Lisp (GCL)","GCL 2.6.8").

Best regards,

Jean-Yves

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-07 08:27:13 Created by lvch on 2012-10-19 06:19:06 Original: https://sourceforge.net/p/maxima/bugs/2479/#a450


use function factor

%i1 factor(sqrt(x^2-u*x^4)); %o1 sqrt(1-u*x^2)*abs(x)

but

%i1 radcan(sqrt(x^2-u*x^4)); %o1 x*sqrt(1-u*x^2)

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-07 08:27:16 Created by rtoy on 2012-10-31 01:21:23 Original: https://sourceforge.net/p/maxima/bugs/2479/#1a55


Although the documentation of radcan isn't very clear on this, radcan is expected to produce results like this. I think the idea is if x is very large, then both expressions are equivalent. I think that's true for your expressions.

If this is not what you want, use ratsimp or some other combination of expand and factor.

Marking as pending/invalid.

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-07 08:27:20 Created by rtoy on 2012-10-31 01:21:23 Original: https://sourceforge.net/p/maxima/bugs/2479/#7755


rtoy commented 4 months ago

Imported from SourceForge on 2024-07-07 08:27:23 Created by tomasriker on 2012-11-08 15:55:59 Original: https://sourceforge.net/p/maxima/bugs/2479/#6ce7


@rtoy: You missed the minus sign! The one result is negative, the other is positive. So this is definitely a bug!

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-07 08:27:27 Created by jyoberle on 2012-11-08 16:38:10 Original: https://sourceforge.net/p/maxima/bugs/2479/#e245


@rtoy: I'm answering late but I tend to agree with tomasriker. When you look at the limit for x=-sqrt(sin(1)+1) which is the largest negative possible value you get: limit(f(x),x,-sqrt(1+sin(1)),plus) is inf limit(radcan(f(x)),x,-sqrt(1+sin(1)),plus) is minf f(x) being diff(acos(asin(x^2-1)),x) However, I followed Ivch advice and replaced radcan by factor in my code (with a small trick for integers).

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-07 08:27:31 Created by rtoy on 2012-11-08 17:52:25 Original: https://sourceforge.net/p/maxima/bugs/2479/#22a0


First, let's make the expression simpler, removing the part with asin: e: -2*x/sqrt(1-(x^2-1)^2)

ratsimp(e) -> -2*x/sqrt(x^2-x^4)

No problem with that.

radcan(e) -> -2/sqrt(2-x^2)

This is very different. From the ratsimp result, we can change the expression (manually) to -2*x/abs(x)/sqrt(2-x^2). This is basically the same as what radcan has produced, but radcan has "assumed" that x is very large and positive, which makes abs(x) = x. This is what I meant by saying that radcan can do "unexpected" changes.

If this is not clear, you should bring this up on the mailing list where Richard Fateman (author of radcan) can explain what's going on. This really needs to be documented better.

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-07 08:27:34 Created by rtoy on 2012-12-14 07:05:10 Original: https://sourceforge.net/p/maxima/bugs/2479/#aeba