π
<-

Cubic equation script

:32tins: :32tinsktpb: :32tinsktpn: :32tinscas: :32tinstpkc: :32tinstpktpb: :32tinstp: :32tinscastp: :32tinscmc: :32tinscx: :32tinscxcas:

Cubic equation script

Unread postby giallucorum » 04 Jan 2018, 13:28

Hallo to everybody. I have some problem with a resolution of a cubic equation.
I created a script for calculate some variable terms in a river, but I found some difficulties in the part i attached when i shoul solve a cubic equation.
Could help me pleaseee.

Code: Select all
Define lucee()=
Prgm
:Local g,k,fr,y0,q,b,s,yq,yw,ye,yr,em,ev,ef,sl
:g:=9.81
:k:=1
:Request "Portata Q=",q
:Request "Y0 moto indisturbato=",y0
:
:Request "Larghezza b=",b
:Request "Altezza Soglia s=",s
:fr:=((q^(2))/(g*b^(2)*y0^(3)))
:Disp "Fr^2 uniforme=",fr
:
:If fr<k Then
:Disp "Corrente Lenta, calcolo soglia"
:sl:=1-fr^(((2)/(3)))+fr^(2)-fr^(((4)/(3)))
:Disp "Soglia limite al=",sl
:
:If ((s)/(y0))>sl Then
:Disp "Soglia alta, Ym=Ycq, Ev=Em+s"
:yq:=root(((q^(2))/(g*b^(2))),3)
:ev:=y0+((q^(2))/(g*b^(2)*y0^(3)))+s
:Disp "Energia valle Ev=",ev
:yw:=nSolve(yw^(3)-yw^(2)*ev+((q^(2))/(2*g*b^(2)))=0,yw)
:Disp "Ymonte=",yq
:Disp "Yvalle=",yw
:
:ElseIf ((s)/(y0))<sl Then
:Disp "Soglia bassa, Yv=Y0v"
:em:=y0+((q^(2))/(g*b^(2)*y0^(3)))
:Disp "Energia monte Em=",em
:ye:=solve(ye^(3)-ye^(2)*em+((q^(2))/(2*g*b^(2)))=0,ye)
:Disp "Ymonte=",ye
:Disp "Yvalle=",y0
:EndIf
:ElseIf fr>k Then
:Disp "Corrente Veloce, soglia sempre bassa, no transizione c"
:ef:=y0+((q^(2))/(2*g*b^(2)*y0^(3)))+s
:Disp "Energia Cvel Evbassa=",ef
:yf:=solve(yf^(3)-yf^(2)*ef+((q^(2))/(2*g*b^(2)))=0,yf)
:
:Disp "Ym=Y0m=",y0
:Disp "Yv=",yf
:EndIf
:
:EndPrgm


This is the program i wrote. i have some problem during the resolution of the cubic equation yw:=nSolve(yw^(3)-yw^(2)*ev+((q^(2))/(2*g*b^(2)))=0,yw).
Do someone has some advices for find a solution.
All the advice it would be so helpful

GP
User avatar
giallucorum
Niveau 0: MI (Membre Inactif)
Niveau 0: MI (Membre Inactif)
Level up: 0%
 
Posts: 3
Joined: 04 Jan 2018, 13:23
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: Cubic equation script

Unread postby critor » 04 Jan 2018, 13:38

What about using the polyroots() function for your cubic equation ?
Image
Image
User avatar
critorAdmin
Niveau 19: CU (Créateur Universel)
Niveau 19: CU (Créateur Universel)
Level up: 53.6%
 
Posts: 42412
Images: 17130
Joined: 25 Oct 2008, 00:00
Location: Montpellier
Gender: Male
Calculator(s):
MyCalcs profile
YouTube: critor3000
Twitter: critor2000
GitHub: critor

Re: Cubic equation script

Unread postby giallucorum » 04 Jan 2018, 18:28

Cheers for your answer! that function work really well in a calculation page, but it doesn't work in my program!
I don't know why! Do you think the code is wrote proprely?
Is it possible that the normal function as solve or the code you use in a scratchpad doesn't work in a program editor??
User avatar
giallucorum
Niveau 0: MI (Membre Inactif)
Niveau 0: MI (Membre Inactif)
Level up: 0%
 
Posts: 3
Joined: 04 Jan 2018, 13:23
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: Cubic equation script

Unread postby critor » 04 Jan 2018, 18:31

Everything which works in a calculation page can be reused for programs.

What's the current code with polyroots() and what's the problem ? An error message ? Wrong results ?
Image
User avatar
critorAdmin
Niveau 19: CU (Créateur Universel)
Niveau 19: CU (Créateur Universel)
Level up: 53.6%
 
Posts: 42412
Images: 17130
Joined: 25 Oct 2008, 00:00
Location: Montpellier
Gender: Male
Calculator(s):
MyCalcs profile
YouTube: critor3000
Twitter: critor2000
GitHub: critor

Re: Cubic equation script

Unread postby giallucorum » 05 Jan 2018, 15:50

Code: Select all
Define lucee()=
Prgm
:Local g,k,fr,y0,q,b,s,yq,yw,ye,yr,em,ev,ef,sl
:g:=9.81
:k:=1
:Request "Portata Q=",q
:Request "Y0 moto indisturbato=",y0
:
:Request "Larghezza b=",b
:Request "Altezza Soglia s=",s
:fr:=((q^(2))/(g*b^(2)*y0^(3)))
:Disp "Fr^2 uniforme=",fr
:
:If fr<k Then
:Disp "Corrente Lenta, calcolo soglia"
:sl:=1-fr^(((2)/(3)))+fr^(2)-fr^(((4)/(3)))
:Disp "Soglia limite al=",sl
:
:If ((s)/(y0))>sl Then
:Disp "Soglia alta, Ym=Ycq, Ev=Em+s"
:yq:=root(((q^(2))/(g*b^(2))),3)
:ev:=y0+((q^(2))/(g*b^(2)*y0^(3)))+s
:Disp "Energia valle Ev=",ev
:yw:=polyRoots(yw^(3)-yw^(2)*ev+((q^(2))/(2*g*b^(2)))=0,yw)
:Disp "Ymonte=",yq
:Disp "Yvalle=",yw
:
:ElseIf ((s)/(y0))<sl Then
:Disp "Soglia bassa, Yv=Y0v"
:em:=y0+((q^(2))/(g*b^(2)*y0^(3)))
:Disp "Energia monte Em=",em
:ye:=polyRoots(ye^(3)-ye^(2)*em+((q^(2))/(2*g*b^(2)))=0,ye)
:Disp "Ymonte=",ye
:Disp "Yvalle=",y0
:EndIf
:ElseIf fr>k Then
:Disp "Corrente Veloce, soglia sempre bassa, no transizione c"
:ef:=y0+((q^(2))/(2*g*b^(2)*y0^(3)))+s
:Disp "Energia Cvel Evbassa=",ef
:yf:=polyRoots(yf^(3)-yf^(2)*ef+((q^(2))/(2*g*b^(2)))=0,yf)
:
:Disp "Ym=Y0m=",y0
:Disp "Yv=",yf
:EndIf
:
:EndPrgm


This is the script, and the errors are:
1) the argument has to be a name of a variable
2) Error in argument
User avatar
giallucorum
Niveau 0: MI (Membre Inactif)
Niveau 0: MI (Membre Inactif)
Level up: 0%
 
Posts: 3
Joined: 04 Jan 2018, 13:23
Gender: Not specified
Calculator(s):
MyCalcs profile


Return to Problèmes divers / Aide débutants

Who is online

Users browsing this forum: No registered users and 14 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.
1482 utilisateurs:
>1463 invités
>10 membres
>9 robots
Record simultané (sur 6 mois):
29271 utilisateurs (le 11/07/2025)
-
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)