Omnimaga
Calculator Community => TI Calculators => TI-BASIC => Topic started by: kyllopardiun on April 02, 2011, 03:54:15 pm
-
I know it hasn't been a long time since my last post, but
as this is another subject I thought it was better to make a new one...
I was trying to make define a function again, for dont have many functions in the calculator
but I got this error: "To many recursions", and display "Define f2(x)=((f2(x))/(x-raiz))"
: If a≠grau Then
: Define f2(x)=((f2(x))/(x-raiz))
Now I was wondering if is possible to create functions like f3 ... on demand like
Define f(x)=x...
Thanks, for any help regarding this.
-
For all of you who don't know portuguese, raiz=root and grau=degree.
Concerning your question, this is TI-Basic for the 8x series right?
I know the ':' are there, but the syntax reminds me of NSpire.
-
No, this is Nspire BASIC. It's more similar to 89 BASIC than to 83 BASIC.
As for your question, you can't define a function to call itself (since that would end in an infinite recursion, which would be bad).
-
Is for the nspire, I don't thing the raiz=root may help any as what I need
is to define multiple functions
such as
f1(x)
f2(x)
f3(x)
...
fn(x)
And I can't figure a way to do it...
-
Oh, I see. I don't think you can do that, unfortunately. You can always overwrite existing functions though. Don't know if that would help with what you're doing.
-
Oh, I see. I don't think you can do that, unfortunately. You can always overwrite existing functions though. Don't know if that would help with what you're doing.
It might help, but how can I overwrite and/or create functions since Define doesn't work?
//it doesn't appear as a syntax error but it don't work
-
You mean the error you got? That's because you're defining a function that calls itself. You can't do that.
-
What, no love for recursion? Oh well, I suppose the 8x models are the same.
-
Well, if allowed, the calc would keep computing the func forever because the func says to compute the func again to get a value, so it computes the func again to get a value, but the func says to compute the func again to get a value, so it computes th
OUT OF MEMORY
-
You mean the error you got? That's because you're defining a function that calls itself. You can't do that.
No I mean when I tried:
Define f3(x)=f2(x)/(x-root)
It doesn't appear as error, but it don't work
I will post the code, so you can understand it better:
Main function:
Define vieta(number,grade)=
Prgm
:Local a,root
: Disp "The root are:"
: For a,0,grau,1
: If grade=1 Then
: root=newton2(number,15)
: Disp root
: Else
: If grade=2 Then
: newton3(number+a,15,root)→root
: Disp root
: Else
: If grau=3 Then
©-----------------------------------------------------------------------
©Here is where it's showed as the error when I run the "program"
: newton4(number+a,15,root)→root
©-----------------------------------------------------------------------
: Disp root
: EndIf
: EndIf
: EndIf
: EndFor
:EndPrgm
In the bold line I get this error: variable not defined
Newton(x)
Define newton4(guess,number,root)=
Func
:Local new_guess,fn,k,newt
©-----------------------------------------------------------------------
©Here is the problem....
:Define f4(x)=((f3(x))/(x-root))
©This line doesn't work at all
©-----------------------------------------------------------------------
:newt:={guess}
:For k,1,number
: new_guess:=guess-((f4(guess))/(nDeriv(f4(x),x=guess)))
: guess:=new_guess
: newt:=augment(newt,{new_guess})
:EndFor
:Return new_guess
:EndFunc
Note: newton4() is the same of newton3 which didn't any errors,
and If I call f2()/f3()/f4() they are not defined...
-
But where is newton2 / newton 3 ... Really not sure where goes wrong.
-
Can you define f4 out of the program, or does f3 change every time?
-
This is offtopic, but what software you guys use to code?
-
Probably the built-in program editor on the Nspire. There aren't any off-calc editors for Nspire BASIC yet, I think.
-
Nope, no other editor yet. I haven't seen any on TI-BANK either.