Page 1 of 2

partial fractions

Unread postPosted: 04 Dec 2014, 15:51
by jmat
hello, how could I put this function in a program to access from the library.
and modify the code to work me with complex roots

thank you
Code: Select all
Define LibPub f1_4_met_gen(expr1,var)=
Func
:Local mat1,mat2
:mat1:=f1_3_met_gen(expr1,var)
:Local ii,tam
:tam:=dim(mat1)[1]
:mat2:=0
:If mat1[1,1]="*" Then
:  For ii,1,tam
:    If mat1[ii,1]="*" Then
:      If string(mat2)="0" Then
:        mat2:={part(mat1,ii)}
:      ElseIf string(mat2)≠"0" Then
:        mat2:=a_r_m(mat2,{part(mat1,ii)})
:      EndIf
:    EndIf
:  EndFor
:  tam:=dim(mat2)[1]
:  mat1:=0
:  For ii,1,tam
:    If buscar_var(mat2[ii,2],var)>0 Then
:      If string(mat1)="0" Then
:        mat1:={part(mat2,ii)}
:      ElseIf string(mat1)≠"0" Then
:        mat1:=a_r_m(mat1,{part(mat2,ii)})
:      EndIf
:    EndIf
:  EndFor
:  tam:=dim(mat1)[1]
:  mat2:=0
:  For ii,1,tam
:    If buscar_var(mat1[ii,2],var)>0 Then
:      If string(mat2)="0" Then
:        mat2:={part(mat1,ii)}
:      ElseIf string(mat2)≠"0" Then
:        mat2:=a_r_m(mat2,{part(mat1,ii)})
:      EndIf
:    EndIf
:  EndFor
:  tam:=dim(mat2)[1]
:  Local list1
:  list1:={mat2[tam,2]}
:  For ii,1,tam
:    list1[ii+1]:=mat2[ii,3]
:  EndFor
:  Return list1
:Else
:  Return {expr1}
:EndIf
:EndFunc


Re: partial fractions

Unread postPosted: 04 Dec 2014, 15:56
by Bisam
To access this from the library, just save the file containing this program in "Mylib" and then "Refresh the libraries" by pressing :nssc: :nsdo: :ns6:.
Don't forget to make "Libpub" programs or functions (as you did here) since they will be the ones listed in the catalog, the others being omitted.
You will find your programs by pressing :nsbi: :ns5: and then choosing your file and your program inside it.

Re: partial fractions

Unread postPosted: 04 Dec 2014, 23:04
by jmat
as it could do to make me the first variable appears in the library

Re: partial fractions

Unread postPosted: 06 Dec 2014, 10:30
by Bisam
Please, don't use automatic translation : it is quite impossible to understand.
It would be easier for us to translate directly from spanish, if you can't speak french nor english !

Por favor , no use traducción automática : es casi imposible de entender.
Traducir directamente del español sería más fácil para nosotros si usted no puede hablar Francés ni Inglés !

Re: partial fractions

Unread postPosted: 06 Dec 2014, 22:26
by jmat
ok, como puedo dejar en la librería solo la variable de acceso a la función y no todas las que me aparecen?

Re: partial fractions

Unread postPosted: 06 Dec 2014, 22:43
by Adriweb
Using LibPriv, on things you don't want to be shown, might help since it will make stuff hidden from the catalog.

Re: partial fractions

Unread postPosted: 07 Dec 2014, 19:54
by jmat
gracias compañero, he intentado esto que me dices pero me da error, también estoy intentando de que me trabaje con números complejos, me podes ayudar... aunque tenga que empezar desde cero
gracias

Re: partial fractions

Unread postPosted: 09 Dec 2014, 14:15
by Bisam
What does your program do ?
If it gives the "decomposition into simple elements" for a rational function... the calculator already does that !!

For complex numbers, you don't need a program either !
Just use the "i" that can be found in the :nspi: menu and NOT the one from the keyboard.

Re: partial fractions

Unread postPosted: 10 Dec 2014, 23:03
by jmat
gracias por tu respuesta, me refiero a cuando las raíces son complejas como => 3x/(x^2+1)

Re: partial fractions

Unread postPosted: 11 Dec 2014, 14:41
by Bisam
The calculator doesn't expand partial fractions with complex roots.
You will have to make a program for that.

Displaying the results will not be easy as the calculator will automatically "simplify" the denominators to make them real.