π
<-
Chat plein-écran
[^]

Cubic equation script

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

Cubic equation script

Message non lude 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: Tout sélectionner
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
Avatar de l’utilisateur
giallucorum
Niveau 0: MI (Membre Inactif)
Niveau 0: MI (Membre Inactif)
Prochain niv.: 0%
 
Messages: 3
Inscription: 04 Jan 2018, 13:23
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile

Re: Cubic equation script

Message non lude critor » 04 Jan 2018, 13:38

What about using the polyroots() function for your cubic equation ?
Image
Image
Avatar de l’utilisateur
critorAdmin
Niveau 19: CU (Créateur Universel)
Niveau 19: CU (Créateur Universel)
Prochain niv.: 42.3%
 
Messages: 41496
Images: 14632
Inscription: 25 Oct 2008, 00:00
Localisation: Montpellier
Genre: Homme
Calculatrice(s):
MyCalcs profile
YouTube: critor3000
Twitter/X: critor2000
GitHub: critor

Re: Cubic equation script

Message non lude 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??
Avatar de l’utilisateur
giallucorum
Niveau 0: MI (Membre Inactif)
Niveau 0: MI (Membre Inactif)
Prochain niv.: 0%
 
Messages: 3
Inscription: 04 Jan 2018, 13:23
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile

Re: Cubic equation script

Message non lude 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
Avatar de l’utilisateur
critorAdmin
Niveau 19: CU (Créateur Universel)
Niveau 19: CU (Créateur Universel)
Prochain niv.: 42.3%
 
Messages: 41496
Images: 14632
Inscription: 25 Oct 2008, 00:00
Localisation: Montpellier
Genre: Homme
Calculatrice(s):
MyCalcs profile
YouTube: critor3000
Twitter/X: critor2000
GitHub: critor

Re: Cubic equation script

Message non lude giallucorum » 05 Jan 2018, 15:50

Code: Tout sélectionner
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
Avatar de l’utilisateur
giallucorum
Niveau 0: MI (Membre Inactif)
Niveau 0: MI (Membre Inactif)
Prochain niv.: 0%
 
Messages: 3
Inscription: 04 Jan 2018, 13:23
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile


Retourner vers Problèmes divers / Aide débutants

Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 44 invités

-
Rechercher
-
Social TI-Planet
-
Sujets à la une
Comparaisons des meilleurs prix pour acheter sa calculatrice !
Aidez la communauté à documenter les révisions matérielles en listant vos calculatrices graphiques !
Phi NumWorks jailbreak
123
-
Faire un don / Premium
Pour plus de concours, de lots, de tests, nous aider à payer le serveur et les domaines...
Faire un don
Découvrez les avantages d'un compte donateur !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partenaires et pub
Notre partenaire Jarrety Calculatrices à acheter chez Calcuso
-
Stats.
1555 utilisateurs:
>1529 invités
>21 membres
>5 robots
Record simultané (sur 6 mois):
6892 utilisateurs (le 07/06/2017)
-
Autres sites intéressants
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)