Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Goran

Pages: [1]
1
Hello,

I came across the following strange behaviour both at CX CAS handheld and in CAS Teacher Software (v3.6.0.550):

I wrote a function that, based on input data, builds a linear system of equations and gives its solution at its output.

I ran it three times (the input data is the same in all the three runs), each times changing Display Digits in Document Settings only.
The systems to solve and the obtained solutions are visible in the attached figures.

In case of "Float 8" and "Float 4" I get the correct solution (although displayed in different precision), in case of "Float 6" not.

When I say "not" I mean the following:

The source of the problem is a difference in matrix coefficients (7,6) and (6,7): the mathematically correct magnitude of both coefficients should be 2.4E-6 (see P.S.), what I get in case of "Float 4" (2.4E-6) and "Float 8" (0.0000024) runs (therefore the correct solution x(1)=x(4)=1.2)

In "Float 6" case the magnitudes are represented as 0.000002, but the problem is that this value not just the representation of number 0.0000024 in "Float 6" precision, the math engine seems work with exactly 0.000002 instead of 0.0000024 (like it truncated the value) and solves a different system corectly, giving actually the "wrong" solution x(1)=x(4)=1.

Seems very strange to me. Or maybe I misunderstand something regarding math engine precision vs numbers representation?

Regards,
Goran

P.S.

The function can solve the system symbolically, too: when symbolic values are supplied, the corresponding coefficients' value is k*sqrt(L1*L2)*omega*imaginary_unit; substituting the numerical values for the described cases  one gets -0.4*sqrt(1E-6*9E-6)*2*imaginary_unit =
= -2.4E-6*imaginary_unit = (2.4E-6 @< -90 deg) in polar notation, what you get in "Float 4" and "Float 8" cases.

2
Lua / ETK: scrolling D2Editor as a member of WScreen?
« on: January 09, 2014, 02:49:39 pm »
Hello,

I am playing with ETK and I use WScreen to scroll-in a report with some calculation results,
the results are math expressions put to D2Editors so they look nice in 2D representation.

The problem is that everything works as planned in PC software, but not on the handheld (CX CAS, OS 3.2.4)

I don't know if I made it as the ETK author would do it (probably not  ???), but visually it works exactly what I want: the report with
the math expressions scrolls-in and out when triggered via menu or a key press.

What I did basically was:

Code: [Select]
Report = WScreen()

function Report:pushed()
    ...
    self.ed = D2Editor.newRichText()
    self.ed:setReadOnly(true)
    ...
    self.ed:setExpression(<some_string>,1)
    self.ed:setFocus(true)
    ...
end

function Report:paint(gc)
    ...
    self.ed:move(self.x + 5, 24)
    self.ed:resize(self.w - 20, self.h - 0)
    ...
end

It seems like D2Editors are not painted on the handheld at all (inspite move/resize method calls).

What might be the reason for different script behavior in the software/on the handheld?

Thanks and best regards,
Goran

3
TI-BASIC / What does exactly cause "Invalid polar complex" error?
« on: January 09, 2014, 01:33:43 pm »
Hello,

I ran into this error on Nspire CX CAS, but saw already that this error message also exists on other TI calcs like 89, 92 and Voyage200.

I got as a result of my program/function a complex function, let's say z(omega), that was calculated correctly and also was shown correctly in e.g. calc application.

But when I want to play with the function further (e.g. getting it's real or imag part, or even to show in again in calculator by typing z(omega)<ENTER>,
I get "Invalid polar complex" error.

On CX CAS you can reproduce the problem if you define a complex function in polar format as e.g.

   z(omega):=(sqrt(omega) @< 90)

On the other hand, if you define the function as

   z(omega):=(abs(sqrt(omega)) @< 90)

everything works fine.

So I thought (as TI says: complex numbers must be properly defined) the problem is that sqrt() function has two solutions (+/-sqrt(x))
and therefore the magnitude of the function internaly is not a scalar value but a two-items entity (e.g. a list), and therefore the error,

but if you define

   z(omega):=(sqrt(4) @< 90)

it works ok as well (sqrt(4) gives 2, not {-2,2}, so I get confused again)

My goal is to understand the cases/circumstances that produce "invalid polar complex" error, in order to circumvene such
problems, if possible (idea: by decomposing the calculation to steps that can be given constraints in order to
force/help engine to yield intermediate results that will in the end result in a valid polar complex).

Thanks for any help and regards,
Goran

 
   

4
Lua / 'Display Digits' in math.setEvalSettings()?
« on: September 08, 2013, 09:39:50 am »
Hello,

I use math.setEvalSettings({{<key>,<value>}) to  control the appearance of results calculated by the math engine.

It works fine for all keys (e.g. 'Angle Mode', 'Real or Complex Format') except for 'Display Digits':
I always get the full precission, no matter what setting value I set (e.g. 'Fixed5').

In Lua Reference Manual it says:

"Note
All results from the TI-NspireTM math server are returned as full-precision ex-
pressions. If users want to limit the display digits, they must call math.getEvalSettings()
and apply the appropriate precision before displaying the value returned by the
TI-NspireTM math server."

Why they mention math.getEvalSettings()?
Isn't it enough to set the option directly with math.setEvalSettings(<setting>)?
As I said, for all other settings it works fine.

Regards,
Goran

5
Lua / mouseDown/mouseUp/grabDown/grabUp events software vs handheld?
« on: August 26, 2013, 06:53:59 pm »
Hello again,

I am still trying a functionality that works in software, to be also working on handheld. I guess the problem is due to
a bias in my thinking/developing in terms of a desktop and "classic" mouseDown/mouseUp events, compared to handheld's additional grabDown/grabUp events.

(I am aware of handling these events in ETK versions incorporated into FormulaPro (mouseUp/mouseDown) and ETK_Demo_New (grabDown added),
but for now I would like first to understand the bare event sequence both in software and on handheld.)

My goal is either to:
a) to select an object, drag it across the screen and release it at some different location, or
b) to select a point of one object, drag a line across the screen and connect it to a point of another object on release.

This is exactly what we do in Graph app when grabbing a function graph, translate/rotate it by dragging, and release it at different position/orientation,
or when using the slider widget in ETK_Demo_New script.

So,

1) in software (where it works as planned):
 
I implemented the corresponding mouseDown() and mouseUp() handlers, what is for software enough: When I press down and hold the left mouse button, mouseDown(x1,y1) is triggered,
then I drag an object or draw a line by keeping left mouse button pressed, and on the release of the left mouse button mouseUp(x2,y2) is triggered. Nice, works, and cannot be simplier.

2) on the handheld (CX CAS with touchpad):

the most similar (and only possible?) operation is to "grab" the first object (by selecting, holding for a while and releasing the central touchpad button), drag it across the screen
(by dragging across the touchpad) and releasing the object (by clicking shortly on the central touchpad button again).

So, in order to work on handheld, I guess I have to implement additional grabDown(/grabUp?) handler(s).

Based on reading Lua Scripting API manual and some experimenting, I came to the following conclusions (which are not necessarily correct):

a) when I press and hold for a while the central touchpad button, grabDown(0,0) event is created, preceeded by mouseDown(x1,y1) event.
b) on the release of the central touchpad button, grabUp(0,0) event is created (by now, the object is selected/grabbed and ready to be moved around)
c) the manual says that both grabDown() and grabUp() events actively suppress creation of mouseUp() event

To summarize, up to here, grabing my object creates:
   mouseDown(x1,y1)
   grabDown(0,0)
   grabUp(0,0)

Then, dragging the object is done by implementing mouseMove() event.

In the end, if I press shortly the central touchpad button again (to release the object), I guess I'll produce another mouseDown() event.
But my experience shows that:
   i) on pressing shortly the central touchpad button, mouseUp(x,y) handler is used
   ii) the x,y coordinates correspond to the "grabbing" point x1,y1, no matter that I clicked the button at "dragged" position x2,y2.

All this is really puzzling me (to be honest: making a mess in my head)?

Can someone please explain me step by step what really goes on at handheld platform during select-drag-release operation
with regard to events?

Thanks in advance,
Goran

6
Lua / Executing a program using mathEval() function?
« on: August 23, 2013, 04:47:54 am »
Hello,

I tried to execute a program from a Lua script, but this seems not to be allowed
(I get Error 580):

    local ans,err = math.eval('prog1(<args>)')
    print(ans,err)

Originally I wanted to create a function to get result, but then some of the ti math engine functions
were not allowed to be used from within a function (e.g. CopyVar, DelVar).

Then I said I would encapsulate the functionality into a program, which will during its execution create
variables in the symbol table and then I will fetch these variables from my Lua script.

When I run the program directly from e.g. Calculator app, it works as wanted and I have all the variables I want in the symbol table.
But if I try to execute the program using mathEval() function, I end with Error 580.

I feel it's little bit of a "catch 22" situation.

Best regards,
Goran

7
Lua / documentation on ETK API?
« on: August 07, 2013, 09:58:22 am »
Hello,

Is there any API documentation for ETK?

I currently go through the code itself, I made a cetrain progress in using it, but anyway I have some doubts that can be removed in this way only after I go 100% through to grasp all the concepts.

Best regards,
Gooran

8
Lua / Creating/formating an evaluated Math Box from Lua script?
« on: July 22, 2013, 02:22:19 pm »
Hello,

I woud like to create Math Boxes from a Lua script, like:

    self.ed:setExpression('\\0el {v} ')

This works ok, but this shows input part only.
As variable 'v' is already evaluated, I would like to:
   a) show immediatelly the output part, too (i.e. the evaluated result)
   b) to format, i.e to set the attributes of such a Math Box, like it's possible manually when you add a Math Box in e.g. Notes application
       (like "Insert Symbol","Display Digits")

Lua Scripting API Reference says:

"\0el {...}" - Denotes a Math Box (Expression Box). Evaluated Math Box
expressions result in a pair of "\0el {...}" separated by a fi lled in '>'. See the
Guidebook for a list of valid math expressions for the Math Box.



So, can I give to self.ed:setExpression() method such
   'a pair of "\0el {...}" separated by a fi lled in '>'
string?
If yes, how does it look like exactly (example)?

Regarding the formating, the guide  further says:

'Rich text editors embed other formatting information in the text
string. This information may change in future releases, so using it is
not recommended. It is delimited by "\1 ...\".'

Where I can find more on the exact formating commands (the '...' part in "\1 ...\"?

9
Lua / Ti-Nspire: Changing menu items dynamically?
« on: July 22, 2013, 08:40:07 am »
Hello,

Firstly, sorry if this question has been answered already (link please).

I want to change the menu content during lua script execution.
I found in "Lua Scripting API Reference Guide" the following sentence:

"Beginning with platform.apiLevel = '2.0', the names of the tool palette items
can be changed dynamically while the program is running."

but I am missing an example.

Any help would be appreciated.

Thanks,
Goran

10
Lua / Reuse of code/classes?
« on: October 01, 2012, 05:52:41 am »
Hello,

I would like to re-use my Lua classes (e.g. of vector algebra, special diagrams, etc.) that I often need in my calculations.

What is the "state-of-the-art" here: can I store the code to some module/library/file/whatever?

What about load()/loadstring() functions? Can they be used for this porpose?

Thanks and best regards,
Goran

11
Lua / Problem with menu separation line
« on: September 30, 2012, 11:56:42 am »
Hello,

I am delighted with ability to specify my own menu for a script page using toolpalete:register() call.
I followed the example given in the Lua Scripting API Reference Guide.

Everything worked as described, except for separation lines (section dividers), specified by hyphen ("-"):
Instead of some kind of separation line, I get in the menu a disabled menu item (gray text) saying: "<number>: English (U.S.)".

Did anyone else experienced such a behavior?

Best regards,
Goran


12
Lua / Problem with on.loseFocus() function
« on: September 30, 2012, 11:34:19 am »
Hello,

I am a newbie regarding TI-Nspire Lua programming (got my CX CAS this week, immediately updated to OS v3.2).

Question:

Within a page running my Lua script, I want to store all entered values to TI.Nspire variables, before switching to another page within the same problem.
I tried to do it by using on.loseFocus() function, expecting this function will be the last one called  before leaving the script page.
On my surprise, printing out the variable values at the other page showed the old variable values, indicating the variables have not been stored.
In order the correct values are printed out, I have to re-visit the script page (there I do not edit anything, as I see there the correct values I entered the first time)
and switch back to printing page: then I see the current values.

Putting a breakpoint within on.loseFocus() function revealed that navigating away from the script page did not trigger the function.
The function has been triggered for the first time on re-visiting the script page, after on.getFocus() function made its job.

On the other hand, on.getFocus() function does its job as expected: whenever I enter the script page, I get the initial setup I defined by this function.

Do I do/understand something wrong?

Another short question just crossed my mind:
Is on.construction() function triggered each time I enter a script page, or only once, at entering the script page for the first time after I load a document?
 
Thanks for your help,
Goran

Pages: [1]