TI connect gives error "the name for this variable is not valid" on file transfer - basic

I've written some code for my TI-84+ calculator using an online tool called cemetech, but I receive the above error when trying to transfer the code to my calculator via USB and the TI-Connect software.
I've done some research and apparently this problem can arise when there's a problem with the code, but I don't know enough about TI Basic to know if I've done something wrong or not. This is what I'm trying to transfer:
Prompt x
Prompt y
Prompt w
(x-y)/w->z
Disp z
If z=0.00:then:a=.5000
If z=0.01:then:a=.5040
...(and so on until z=0.49)
Disp a
I wasn't able to find any articles related to TI Basic here, so I'm not sure if I'm in the right place or not, but any help with this would be much appreciated!

The equals sign (=) tests equality, which you probably don't want. You want the assignment operator, (→). Also, I don't see any End statements. If:Then: requires End. For your code, you don't need the Then, your code should be something like
Prompt x
Prompt y
Prompt w
(x-y)/w→z
Disp z
If z=0.00:.5000→a
If z=0.01:.5040→a
...(and so on until z=0.49)
Disp a

Butting in for a moment:
If you are trying to store data into a variable using TI Connect, then:
Use the list of tools on the left hand side and go to:
Char > Keypad > (first option should be an arrow like you'd get with STO> button)
this should allow you to store your data into your variable of choice.
If you weren't looking for this information, my apologies for butting in =)

Related

Creating graphs using code from Pari-GP, but using Sage's graphing tools

everyone!
I know this is probably a dumb question, but I'm having a lot of trouble with Sage, and it's frustrating the hell out of me. To give a bit of an explanation, I code entirely in pari-gp. I don't have a single problem with my code in pari-gp, I'm just having trouble with interfacing my code with Sage. Which, this is something Sage bolsters, that you can run pari-gp code within sage. I essentially want to run all my processes in pari-gp, but I want to exploit all of Sage's graphing protocols.
What I want to do couldn't be easier. I have a well working function test(x,y), which produces a real number. I don't have any problems running this in pari, everything is kosher. All I want to do is make a graph of test(x,y) = z. Now I know how to run this command in sage, but I don't know how to interface such that test is actually a program running from Pari code.
I'd love to program all my stuff in Sage, but that's just impossible. I need the language Pari, so before you say that I could just translate everything in Sage, it's impossible. I just can't wrap my head around how to interface Pari with Sage. I know it's possible; hell, they advertise it on the main website. I'm just very unclear about how to do the following:
1.) Read a file from my pari-gp root directory: gp.read("myfile.gp").
2.) Inherit the functions, such that gp("test(x,y)"), now runs as though it runs in the GP terminal.
3.) Graph said function test(x,y) using Sage's graphing protocols.
Any help is greatly appreciated. I know I'm just forgetting to do something dumb, or I'm missing a step in how I'm doing it.
Any help is greatly appreciated!
Let us start with:
sage: gp("test(x, y) = sin(x*y)")
(x,y)->sin(x*y)
sage: gp("test(1, 1)")
0.84147098480789650665250232163029899962
sage: type(_)
<class 'sage.interfaces.gp.GpElement'>
So the printed version of gp("test(1, 1)") looks like a number, but it is not a float instance. Note that py3 has some f-strings, so we can easily plug in values of variables x, y inside the gp("test(...)") . I will use f-strings to define the sage function...
And we are not far away from the final plot:
sage: f = lambda x, y: float( gp(f"test({x}, {y})") )
sage: plot3d(f, [0, pi], [0, pi])
Launched html viewer for Graphics3d Object

Print a variable with index (eg. x_1)

i am trying to print variables with indices.
The goal is to write something like:
x_1 + x_2 = 3 + 1 = 4
The problem is, that variables just like x_1 does not show an index. It shows the underscore itself.
/* works fine */
print(x_1)$
x_1;
/* Does not work */
ostream: make_string_output_stream()$
printf(ostream, string(x_1))$
get_output_stream_string(ostream);
Output of the code above
Converting "x_1" into a string destroys the underscore, but you need a string for the method printf().
Are there workarounds for this?
What to do here probably depends somewhat on what goal you need to achieve with this. Can you say more about the larger goal you are working toward?
In order to generate output which has typesetting instructions in it, you can call the tex or tex1 function to generate TeX output. If that needs to be displayed in a web page, I believe you can make use of the MathJax Javascript library. Sorry, I don't know more about MathJax.
You should probably write x[1] instead of x_1. Displaying x_1 with a subscript 1 is a convenience -- the rest of Maxima doesn't know much about it.
EDIT: There is also an add-on package to output MathML; there might be two such packages, I would have to check. If MathML could help solve your problem, I will look into it.

Matlab function defintion method that takes string as the definition (MFILE)

there is this method I used the other day and I have forgotten the details, which in we used a syntax like this:
f=//command//(x,'sin(x)');
something like this.
im not sure if the syntax is fully correct, or what the right command is. but after this we could simply ask for the f(x) value like this:
x= 0;
y= f(x);
and then the results were y=0;
What you are asking for is usually not recommendable. Please check if a simple anonymous function also fits your requirements:
f=#(x)(sin(x))
In case you really need to evaluate from a string:
f=str2func('#(x)sin(x)')
I would advice against the second option unless absolutely required, it can lead to hard to debug errors.
well I found the answer myself and it was "inline" command; :)
f=inline('sin(x+y+z)','x','y','z');
you can add as much variables as needed too.

How do I plot a function formatted as a string in R

I am building an application with RApache and my code in R is receiving POST data. One of the post datas is POST$f which is a string- say "sin(x)". Is there any way to put this into the plot function successfully?
Thanks!
fun <- "sin(x)"
plot(function(x) eval(parse(text=fun)))
But it is not something I would recommend. eval(parse(...)) is already dangerous, and then to do it with arbitrary user input from a web site is just a gaping security hole.
# PLOTTING THIS FUNCTION AS ABOVE WILL DELETE EVERYTHING IN YOUR GLOBAL WORKSPACE
fun <- "{rm(list=ls(pos=1),pos=1); x}"
# DON'T SAY I DIDN'T WARN YOU!
Or even using system() to do even more bad things.

How to define a function without arguments in gnuplot?

I want to define a function which returns a random number:
gnuplot> rnd() = int(rand(0)*2**24)
^
invalid command
I need add a parameter x to stop the error message:
gnuplot> rnd(x) = int(rand(0)*2**24)
Is it possible to define a function without parameters?
I don't think that is possible (look at the syntax for functions in help user-defined). As far as I can tell -- using rand is the only time when this is useful -- In all other cases your "function" would just evaluate to a constant. I'm guessing the gnuplot devs just haven't thought of this (interesting) corner case, or they didn't think it useful enough to implement.
I hope that I'm wrong about this and somebody else comes along and proves it, but I don't think I am. I think the easiest workaround it to just pass a parameter as you've already mentioned. If you really don't like that, you could use a macro:
set macro
rnd="(int(rand(0)*2**24))"
print 5+#rnd

Resources