π
<-

Complex partial fraction

Pour le TI-Basic sur Nspire

Complex partial fraction

Unread postby m_elborolossy » 08 May 2015, 14:43

Hi all
My calc is Nspire cx cas
I try to make a complex partial fraction because the calc make only real one using expand
I try to write a function but there is an error that is not clear to me why
I make the same steps in a Document or scratchpad and work good
Here is my code :
Code: Select all
Define LibPub partialf(expre)=
:Func
:Local ex,r,rc,exc,k,x,kc
:expr("ex(s):="&string(expre))
:r:=polyRoots(getDenom(ex(s)),s)
:exc(s):=ex(s)*s
:rc:=cPolyRoots(getDenom(exc(s)),s)
:k(s):=((getNum(ex(s)))/(2*s*imag(rc[2])*i))
:kc:=k(rc[2])
:Return kc
:EndFunc


This is only the start and i assume that the i have a real root (s = 0) and two conj complex roots s={(-a+b*i),(-a-b*i)}
The error in this line : kc:=k(rc[2])
Last edited by m_elborolossy on 08 May 2015, 15:48, edited 2 times in total.
User avatar
m_elborolossy
Niveau 6: SM (Super Membre)
Niveau 6: SM (Super Membre)
Level up: 78.6%
 
Posts: 4
Joined: 19 Oct 2014, 01:58
Gender: Male
Calculator(s):
MyCalcs profile

Re: Complex partial fraction

Unread postby Bisam » 08 May 2015, 15:01

I spotted a possible (and quite usual) problem.

When you create a function by using f(s):= anything, the right member is NOT evaluated.
It will only be evaluated when you will use the function and replace the value of "s" by any expression.

At this time, the calc may see an error such as a "division by zero" that couldn't be seen earlier.
I think that, in your case, exc(s) still has zero as a root of denominator... or something like that.

Did you try to "disp" some intermediate results to spot the problem more precisely ?
And what is the error returned ?
User avatar
BisamAdmin
Niveau 15: CC (Chevalier des Calculatrices)
Niveau 15: CC (Chevalier des Calculatrices)
Level up: 69.6%
 
Posts: 5670
Joined: 11 Mar 2008, 00:00
Location: Lyon
Gender: Male
Calculator(s):
MyCalcs profile

Re: Complex partial fraction

Unread postby m_elborolossy » 08 May 2015, 15:49

Thanks Bisam
I think it works now good
When I finish it i will upload it
This is the updated code :
Code: Select all
Define LibPub partialf(expre)=
Func
:Local ex,r,rc,exc,k,x,kc
:expr("ex(s):="&string(expre))
:r:=polyRoots(getDenom(ex(s)),s)
:expr("exc(s):="&string(ex(s)*s))
:rc:=cPolyRoots(getDenom(exc(s)),s)
:expr("k(s):="&string(((getNum(ex(s)))/(2*s*imag(rc[2])*i))))
:kc:=k(rc[2])
:Return kc
:EndFunc
Last edited by m_elborolossy on 08 May 2015, 15:53, edited 3 times in total.
User avatar
m_elborolossy
Niveau 6: SM (Super Membre)
Niveau 6: SM (Super Membre)
Level up: 78.6%
 
Posts: 4
Joined: 19 Oct 2014, 01:58
Gender: Male
Calculator(s):
MyCalcs profile

Re: Complex partial fraction

Unread postby Bisam » 08 May 2015, 15:56

Nice !
Glad to have helped... and thankful for having talked with someone who knows how to program decently !
Last edited by Bisam on 08 May 2015, 15:57, edited 1 time in total.
User avatar
BisamAdmin
Niveau 15: CC (Chevalier des Calculatrices)
Niveau 15: CC (Chevalier des Calculatrices)
Level up: 69.6%
 
Posts: 5670
Joined: 11 Mar 2008, 00:00
Location: Lyon
Gender: Male
Calculator(s):
MyCalcs profile

Re: Complex partial fraction

Unread postby jmat » 02 Jul 2015, 10:48

wonderful !!We hope this program
User avatar
jmat
Niveau 7: EP (Espèce Protégée: geek)
Niveau 7: EP (Espèce Protégée: geek)
Level up: 12.5%
 
Posts: 50
Joined: 24 Jul 2013, 01:03
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: Complex partial fraction

Unread postby Bisam » 02 Jul 2015, 15:06

Uh ?
Seems to be an early posting... :p
User avatar
BisamAdmin
Niveau 15: CC (Chevalier des Calculatrices)
Niveau 15: CC (Chevalier des Calculatrices)
Level up: 69.6%
 
Posts: 5670
Joined: 11 Mar 2008, 00:00
Location: Lyon
Gender: Male
Calculator(s):
MyCalcs profile

Re: Complex partial fraction

Unread postby mike martin » 31 Jul 2016, 14:11

Hi there,
Did you ever finish the code for this? If so, is there somewhere I can download it?

I really need something like this on my nspire.

Thanks
Mike
User avatar
mike martin
Niveau 0: MI (Membre Inactif)
Niveau 0: MI (Membre Inactif)
Level up: 0%
 
Posts: 1
Joined: 31 Jul 2016, 14:10
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: Complex partial fraction

Unread postby Bisam » 01 Aug 2016, 15:07

Just try to create it yourself by copying the code which is on the 3rd post.
User avatar
BisamAdmin
Niveau 15: CC (Chevalier des Calculatrices)
Niveau 15: CC (Chevalier des Calculatrices)
Level up: 69.6%
 
Posts: 5670
Joined: 11 Mar 2008, 00:00
Location: Lyon
Gender: Male
Calculator(s):
MyCalcs profile

Re: Complex partial fraction

Unread postby endothes » 07 Oct 2018, 03:19

When I use the code in the third post with a function such as:

(0.4)*(s-1500)/(s^2+1000*s+1.25*10^6)

I get too many arguments error. Does the program listed above work for anyone else?
User avatar
endothes
Niveau 0: MI (Membre Inactif)
Niveau 0: MI (Membre Inactif)
Level up: 0%
 
Posts: 1
Joined: 07 Oct 2018, 03:18
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: Complex partial fraction

Unread postby Hisham » 07 Oct 2018, 09:03

endothes wrote:When I use the code in the third post with a function such as:

(0.4)*(s-1500)/(s^2+1000*s+1.25*10^6)

I get too many arguments error. Does the program listed above work for anyone else?


http://www.allcalc.tk/10272 (PFE)
http://www.allcalc.tk/4982 (PFE + inverse L-Transformation)

Best,

Hisham ;)
User avatar
HishamPremium
Niveau 8: ER (Espèce Rare: nerd)
Niveau 8: ER (Espèce Rare: nerd)
Level up: 12.9%
 
Posts: 140
Joined: 01 Mar 2017, 20:52
Gender: Not specified
Calculator(s):
MyCalcs profile

Next

Return to Nspire-Basic

Who is online

Users browsing this forum: ClaudeBot [spider] and 3 guests

-
Search
-
Social TI-Planet
-
Featured topics
Comparaisons des meilleurs prix pour acheter sa calculatrice !
"1 calculatrice pour tous", le programme solidaire de Texas Instruments. Reçois gratuitement et sans aucune obligation d'achat, 5 calculatrices couleur programmables en Python à donner aux élèves les plus nécessiteux de ton lycée. Tu peux recevoir au choix 5 TI-82 Advanced Edition Python ou bien 5 TI-83 Premium CE Edition Python.
Enseignant(e), reçois gratuitement 1 exemplaire de test de la TI-82 Advanced Edition Python. À demander d'ici le 31 décembre 2024.
Aidez la communauté à documenter les révisions matérielles en listant vos calculatrices graphiques !
1234
-
Donations / Premium
For more contests, prizes, reviews, helping us pay the server and domains...
Donate
Discover the the advantages of a donor account !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partner and ad
Notre partenaire Jarrety Calculatrices à acheter chez Calcuso
-
Stats.
751 utilisateurs:
>732 invités
>11 membres
>8 robots
Record simultané (sur 6 mois):
6892 utilisateurs (le 07/06/2017)
-
Other interesting websites
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)