rtoy / maxima

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

integrate((1+tan(x)^2)/tan(x),x); #1572

Closed rtoy closed 2 days ago

rtoy commented 2 days ago

Imported from SourceForge on 2024-07-04 20:14:08 Created by *anonymous on 2005-12-06 18:41:26 Original: https://sourceforge.net/p/maxima/bugs/830


Non-real result

rtoy commented 2 days ago

Imported from SourceForge on 2024-07-04 20:14:09 Created by rtoy on 2006-02-13 18:07:01 Original: https://sourceforge.net/p/maxima/bugs/830/#4d08


Logged In: YES user_id=28849

This integral is transformed to cos(x)/sin(x)*(sin(x)^2/cos(x)^2+1). Then maxima uses the substitution y=sin(x) to get 1/y*(y^2/(1-y^2)+1.

However:

integrate(1/y*(y^2/(1-y^2)+1),y) -> log(y)-log(y^2-1)/2.

But integrate(expand(1/y*(y^2/(1-y^2)+1)),y) -> log(y)-log(1-y^2)/2.

The former is wrong for our integration problem; the latter would produce the desired answer.

rtoy commented 2 days ago

Imported from SourceForge on 2024-07-04 20:14:12 Created by robert_dodier on 2006-04-10 04:09:10 Original: https://sourceforge.net/p/maxima/bugs/830/#2a7c


rtoy commented 2 days ago

Imported from SourceForge on 2024-07-04 20:14:16 Created by robert_dodier on 2006-08-15 02:46:56 Original: https://sourceforge.net/p/maxima/bugs/830/#d521


Logged In: YES user_id=501686

Maxima 5.9.3.99rc1 / Clisp 2.38:

integrate((1+tan(x)^2)/tan(x),x); => log(tan(x))

which seems right. Maybe if someone else wants to weigh in here. If someone else agrees this result is OK, we can close this report.

rtoy commented 2 days ago

Imported from SourceForge on 2024-07-04 20:14:19 Created by rtoy on 2006-08-31 20:40:37 Original: https://sourceforge.net/p/maxima/bugs/830/#345b


Logged In: YES user_id=28849

Maxima 5.9.3.99rc2 and cmucl 2006-09 says

log(sin(x)) - log(sin(x)^2-1)/2

But the same maxima with clisp 2.35 says log(tan(x)).

I don't know why.

rtoy commented 2 days ago

Imported from SourceForge on 2024-07-04 20:14:23 Created by rtoy on 2006-08-31 23:41:29 Original: https://sourceforge.net/p/maxima/bugs/830/#68e4


Logged In: YES user_id=28849

FWIW, maxima uses trigint to do this integral, and when it gets to case 4, it tries to match the integrand. With cmucl, it matches, but with clisp it doesn't.

In rat1, b is NIL in clisp, but is 'cos* in cmucl. b is declared special, and is set to 'cos* in case 4, just before the call to m2, which calls rat1. But note that coeffpt in schatc.lisp also uses the variable b. There is probably some confusion with b here. I am guessing the b in coeffpt is not the global special variablle b in sin.lisp.

rtoy commented 2 days ago

Imported from SourceForge on 2024-07-04 20:14:26 Created by rtoy on 2006-08-31 23:46:20 Original: https://sourceforge.net/p/maxima/bugs/830/#1667


Logged In: YES user_id=28849

Yes, replacing all occurrences of b in schatc.lisp with bb makes clisp behave like cmucl.

But we can see now how to get log(tan(x)) as the answer. We can move case 5 before case 4. Not exactly sure what impact that will have on the algorithm.

rtoy commented 2 days ago

Imported from SourceForge on 2024-07-04 20:14:30 Created by dgildea on 2008-09-04 00:43:51 Original: https://sourceforge.net/p/maxima/bugs/830/#a303


Logged In: YES user_id=1797506 Originator: NO

Is this really a bug? log(sin(x)) - log(sin(x)^2-1)/2 seems to differ from log(tan(x)) by a constant within each sheet. log(tan(x)) is also complex in general.

rtoy commented 2 days ago

Imported from SourceForge on 2024-07-04 20:14:33 Created by dgildea on 2008-09-04 00:43:52 Original: https://sourceforge.net/p/maxima/bugs/830/#1308


rtoy commented 2 days ago

Imported from SourceForge on 2024-07-04 20:14:37 Created by rtoy on 2008-09-08 13:30:46 Original: https://sourceforge.net/p/maxima/bugs/830/#ab0b


Logged In: YES user_id=28849 Originator: NO

Yes, you are right. Still, for real values of x, it is a bit surprising to see maxima give a complex result in log(sin(x)^2-1)/2, but of course once you substitute actual integral limits, the complex part goes away.

But we should fix the b vs bb issue in schatc.lisp in any case. Or at least make sure b is not special in schatc. Or change b to *b* in sin.lisp. Or something.

rtoy commented 2 days ago

Imported from SourceForge on 2024-07-04 20:14:40 Created by dgildea on 2008-09-08 14:02:33 Original: https://sourceforge.net/p/maxima/bugs/830/#3703


Logged In: YES user_id=1797506 Originator: NO

The variable b was changed to *b* in sin.lisp rev 1.19.