1

I was wondering how I would return an expression without it being evaluated.

Define LibPub exactly(r,l,c,vi,vf)=
Func
   :Local t
   :Local diff
   :If l=0 Then
   : t:=−1*((1)/(r*c))
   :Else
   : t:=−1*((1)/(((r)/(l))))
   :EndIf
   :diff:=vi-vf
   :setMode(5,3)
   :Disp (vf+diff*e^(t))
   :EndFunc

I want it to return something like
.

Is there a way to achieve this? Thanks for any help!

  • You'd have to output it as a string (unless you have the ti-Nspire CAS, which should do that by default). – PGmath Dec 13 '15 at 04:55
  • @PGmath thanks for the response! I do have the CAS version. I played around with it and it's outputting what I want but now it puts the constant "5" after the exponential instead of in front of it. Would I need to perhaps seperate each result out into two seperate variables, one for the "5 + " and one for the "16e^(-0.5t))" and then try outputting them? –  Dec 14 '15 at 13:24

2 Answers2

0

The issue is that you are outputting an expression, which will evaluate. The solution is to make the output a combination of strings and variables like this:

Disp wf,"+",diff,"*e^(",t,")"

This you can also remove the line setMode(5,3), because it is not necessary. I ran the code on my TI-nspire CX (no CAS), and it worked fine (The output at least, I'm not sure what exactly the program does). Here is the complete program I ran, with corrections.

Define LibPub exactly(r,l,c,vi,vf)=
Func
    Local t
    Local diff
    If l=0 Then
      t:=−1*((1)/(r*c))
    Else
     t:=−1*((1)/(((r)/(l))))
    EndIf
    diff:=vi-vf
    Disp wf,"+",diff,"*e^(",t,")"
    EndFunc

Good luck with your program.

Scott Mikutsky
  • 746
  • 7
  • 21
-1

The way most Texas Instrument calculators work, typing in any equation anywhere solves the equation immediately. Most other programming languages do the same thing (they should). If I'm understanding you correctly, you want to print the equation to the screen. If so, all you need to do is type the equation in a string. This will just print the equation to the screen, without evaluating it. The calculator will see it as a list of characters, not an equation, so it will output the equation rather than the solution to the equation.