AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Popup calculator / expression evaluator
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Sun Dec 16, 2007 3:30 am    Post subject: Reply with quote

Here is a major update v.1.4: array handling and statistics. (Function plots are basically supported via arrays, as in Excel: generate the points of the function graph and pass it to an external graphing application.) There are more than 200 lines of new code, so some bugs could have remained.

To Do:
- Dynamic functions: the work is basically done in the function array(), but some more debugging is needed.
- Include AHK graphing (maybe jonny’s Mathematical Function Grapher)
- Extra level of evaluation inside [..], which allows x[i+2] like indexing

Arrays are implemented as in AHK: separate variables for the entries, the 0th entry being the length. Also, the array variable contains its name, so after creation there is no need to use quotation marks around array names. The new functions:

- copy("X",Y) duplicates array Y
- clear(X) removes array header
- seq("X",i0,i1[,d=1]) set up linear sequence X = {i0,i0+d..,i1}, return "X"
- array("X","i",i0,i1,d, "expr") general array with dynamic expression evaluation: X = {expr(i:=i0),expr(i:=i0+d)..,expr(i:=i1)}
- more("X",entry0,..) add up to 30 new entries to the end of array X, return "X"
- part("Y",X,i0,i1[,d=1]) Y <- {X[i0],X[i0+d]..,X[i1]}, return "Y" ( Y <> X )
- join("Z",X,Y) Z <- joined arrays {X,Y}, return "Z" (not equal to X or Y)
- add("Z",Y,X), sub(), mult(), div(): elementwise operators on arrays
- mean(X), std(X), moment(k,X) statistics functions
- sum(X), prod(X), sumpow(k,X), dot(X,Y) vector to scalar functions
- the functions min(X) and max(X) handle arrays when one array argument is passed

Also,
- added 2 new constants rad and deg to convert to degree: radians*deg, or to radian: degrees*rad

Here the most powerful function is array(). Its last argument is an expression, which is repeatedly evaluated with the changing variable (the second argument), going over a linear sequence. Basically, a function is tabulated: evaluated at many arguments, and the results are stored in an array.

Examples:
more("X",1,-2,3); min(X)
more(X,5,6,-7); std(X)
array("Y","i", 0,9,1, "i*i"); Y_5+Y_4
dot(X,Y)

--- --- ---

Another significant update: Version 1.5.

- Help is shown/hidden in a scrollable edit control (Alt-H)
- “;” is kept (not treated as command separator) inside quoted strings
- Internal global variables are renamed to start with “__”, to avoid conflicts with user variables (which are always global)

Three new functions are added for iterative computations:

- for(Var,i0,i1,d,expr) : evaluate {expr(i0),expr(i0+d)..,expr(i1)}; -> last result
x:=0; for("i",1,10,1,"x+=i*i") -> the sum of the 1st 10 squares
- while(cond,expr) : evaluate expr while cond is true; -> last result
n:=1; x:=1; while("n++<10","x+=1/n") -> the sum of the 1st 10 reciprocals
- until(expr,cond) : evaluate expr until cond gets true (at least once); -> last result
n:=1;x:=1;until("x*=++n","n=10") -> 10!

- Dynamic expression evaluation: eval(expr):
f:="1/x+1/y+1/z"
x:=1;y:=2;z:=0.5; eval(f)

- Poor man’s dynamic functions: call(FName, Param1,Param2...)
f:="1/f1+1/f2+1/f3"
call("f",1,2,3)
~Assign the function body (as a string) to a variable, like “f”.
~The function parameters are numbered, prefixed with the name of the variable “f”: f1, f2,...
This way the chance of variable naming conflict is smaller, but still there. In the Popup Calculator every variable is global, so if you have used f2 earlier, it will be overwritten by the call("f",1,2,3).

--- --- ---

Update: Version 1.6.

- simplified __eval()
- new tray menu item: edit/hide history
- support for binary input with the MS bit as sign: b("0101") -> 5, b("1000") -> -8. (A variable can still be named “b”).

- [expr]: evaluate expr -> v, return “_v”; ~ computed index.
e.g. X[1]:=2 is the same as X_1:=2
e.g. i:=2; 3-X[i-1] is the same as i:=2; __temp:=i-1; 3-X_%__temp%, or 3-X[1]. Here __temp is not global, there is no conflict with multiple brackets in one expression.
B[1][2] is the same as B_1_2, so we can mix one-, and two dimensional arrays: B[1][2] is different from B[12].

Using [.] allows replacing the ugly x_%i% with x[i], where i is an arbitrary expression. x[i] can be on the left hand side of an assignment, too. The elements of an automatic array X are accessed as X_0=X[0]: length, X_1=X[1], X_2=X[2]... which reduces the possibility of conflicts with explicitly defined variables x1, x2...:
more("X",3,2,1),X[3]
gives 1, the value stored in X_3.

--- --- ---

The next major update v.1.7 (with function graphing built in) is here. It is still a single ahk file, start it from any directory, where you can write the history file to. Now all the requested features are implemented, we can fix bugs and think about the ease of use and similar fine tunings.

Changes/New features:

- edit history now updates drop-down expressions list
- results are separated by ¦, cosmetic help changes
- single tray-click activates calculator window
- pmean() works now on vectors (1-dim arrays), too

- GRAPHING FUNCTIONS
- graph(x0,x1,y0,y1,width=400,height=300,BGcolor=white) : create/change graph window to plot in
---- (margin=10) deleted when closed[x] or GuiEscape
---- graph is copied with Alt-PrtScrn to the clipboard
---- graph() destroys
- Xtick(Array=10,LineColor=gray,LineWidth=1,Label=true) : add | lines to graph at X positions
---- (Labels are not yet implemented)
---- can be called multiple times, BEFORE plot
---- Array=integer : equidistant ticks, Array="" : 10 stripes
---- Array=float : single line
- Ytick(Array=10,LineColor=gray,LineWidth=1,Label=true) : add - lines at y positions...
- plot(Y,color=blue,LineWidth=2) add plot of straight lines with X = {1..len(Y)}
---- if no graph: create default one with y0 = min(Y), y1 = max(Y)
---- plot() erase function graphs
- plotXY(X,Y...): add XY plot to last graph
---- if no graph, create default one with graph(min(X),max(X),min(Y),max(Y))

Example:

array("X","i",1,100,1,"sin(i/pi)"); plot(X)
array("Y","i",1,100,1,"atan((i-50)/25)/pi_2"); plot(Y,0xFF)

--- --- ---

Version 1.8:

- array operations now accept one scalar argument, like add(X,X,-1) subtracts 1 from each elements of X, div(X,1,X) replaces the elements of X with their reciprocals.
- fixed missing memory allocation for __Z

--- --- ---

Version 1.9:

There are two major new additions: list(.), opening up a new window where an array (vector) can be entered, edited or sorted for view (see min/max); and the apply-to function @(..), which applies another function or AHK operator on one or two arrays. Local variable names are now prefixed with double underscores when necessary to minimize the chance of a conflict with global variables defined in the calculator. The size of the windows are computed using the selected font and DPI settings. There are more than a thousand changes, so be careful, some new bugs could have been introduced!

Here are some not numeric applications:
- fast conversion between char and its ANSI code: asc('a')->97, chr(0x44)->D
- quick test of RegEx Match/Replace (not all works):
--- RegExReplace("C:\Windows\system32", "Windows", "WinNT")
- get file attributes: FileExist("C:\Windows\system32\systeminfo.exe") -> A

Changes/New features:

- list(array) Edit/Sort ListView of elements. To build array: {Enter}-Value-{Enter}
--- rightclick menu: More (Enter, Alt-M: add new), Less (Alt-L: del last)
- separate, streamlined help window with added list of AHK functions
- if user entered expr is already in history: don't add (ignoring spaces)
- size of calc window is calculated to 65+1 chars for current font, DPI
- results are shown with tab chars
- new function msg(x): MsgBox % x
- @(..): apply-to function/operator for vectors (replaced add, sub, mul, div).
--- @("Z",X,"+",Y), @("Z",Z,"^",-1), @("Z",Z,"Round",3), @("Z",X,"sin"), @("Z",Z,"<=",0.25)
- shorthand: `var == "var", where var is terminated by "," or ")", "]", eol, space
--- careful with expressions: `sin(x) becomes "sin(x"), `round(x,2) --> "round(x",2)
- "[expr]" is now left unprocessed in quoted strings (delayed evaluation is needed for loops, arrays)
- locals, params are now prefixed with "__" to reduce conflicts with globals.

--- --- ---

Version 2 is uploaded. The changes:

- remember window positions → calc.ini
- configurable hotkeys ← calc.ini
- bugfix in prod()
- list: redraw LV after all rows added (to ensure proper display)
- periodically redraw graph window
- graph cursor is changed to crosshair + coordinates in ToolTip
- LCM(a,b) added: Least Common Multiple as a * (b // GCD(a,b))
- solve('x',x0,,x1,'expr'[,tol]) added: find 'x' where 'expr' = 0
- fmax('x',x0,x1,x2,'expr'[,tol])) added : find 'x' where 'expr' = max (at flat curve lower precision)
- rand(x,y) added: random number in [x,y]; rand(x) new seed=x.
--- rand(1,6) {Enter}…{Enter} = dice
- sort('y',x[.opt]) added: y ← sorted array x.
--- opt = 0: random, 1: no duplicates, 2: reverse, 3: reverse unique
- primes('p',n) added: {primes <= n} → array 'p' using the sieve Eratosthenes
--- list(primes(`x,999999)) shows all primes less than a million
--- m <= primes <= n: list(array(`x,`i,1,299,1,'isprime(2**32+i)'))
- IsPrime(p) added: machine code prime test (IsPrimeA is pure AHK, slow)
--- isprime(2**31+11), isprime(2**31-1)
--- list(array(`x,`i,1,999,1,'isprime(2**62+i)')) find all 32 primes in (2**62,2**62+1000) (Dell Inspiron 9300: 15 minutes)
--- isprime(9223372036854775783) → 1 (34 sec), it is the largest prime, 2**63-25, AHK can show
- pDivs('d',n) added: {prime divisors of n} → d (pDivsA is pure AHK, slow)
--- list(pdivs(`x,9973*9967)), list(pdivs(`x,(2**31+45)*(2**31+11))) – (Dell Inspiron 9300: 23 sec)


The file grew too large to be directly copied here. Download it from here. No installation is required, just copy it somewhere and run.


Last edited by Laszlo on Mon Jan 07, 2008 3:34 am; edited 9 times in total
Back to top
View user's profile Send private message
Titan



Joined: 11 Aug 2004
Posts: 5390
Location: /b/

PostPosted: Sun Dec 16, 2007 2:29 pm    Post subject: Reply with quote

Why don't you make it easier to try your script by providing a download zip with all the required dependencies. If not you should at least use your first post for updates and a screenshot. It gets hard to track which version is the right one amongst all these pages of different code. I want to try this calc after your recommendation but I cba to study your commentary and piece together the requirements. Thanks.
_________________

Back to top
View user's profile Send private message Visit poster's website
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Sun Dec 16, 2007 3:31 pm    Post subject: Reply with quote

Titan wrote:
Why don't you make it easier to try your script by providing a download zip with all the required dependencies.
For the enhanced version there is no dependency, just a single AHK file to run. Where did you get the impression that you have
Titan wrote:
to study [my] commentary and piece together the requirements?
Nothing is required. A screenshot does not tell much, either, it is just a very basic GUI, what you see. The last post tells you that it was a not fully tested version. The first post will be updated when most bugs got fixed.
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Sun Dec 16, 2007 9:14 pm    Post subject: Reply with quote

Another experimental code is posted above: Version 1.5.

- Help is shown/hidden in a scrollable edit control (Alt-H)
- “;” is kept (not treated as command separator) inside quoted strings
- Internal global variables are renamed to start with “__”, to avoid conflicts with user variables (which are always global)

Three new functions are added for iterative computations:

- for(Var,i0,i1,d,expr) : evaluate {expr(i0),expr(i0+d)..,expr(i1)}; -> last result
x:=0; for("i",1,10,1,"x+=i*i") -> the sum of the 1st 10 squares
- while(cond,expr) : evaluate expr while cond is true; -> last result
n:=1; x:=1; while("n++<10","x+=1/n") -> the sum of the 1st 10 reciprocals
- until(expr,cond) : evaluate expr until cond gets true (at least once); -> last result
n:=1;x:=1;until("x*=++n","n=10") -> 10!

- Dynamic expression evaluation: eval(expr):
f:="1/x+1/y+1/z"
x:=1;y:=2;z:=0.5; eval(f)

- Poor man’s dynamic functions: call(FName, Param1,Param2...)
f:="1/f1+1/f2+1/f3"
call("f",1,2,3)
~Assign the function body (as a string) to a variable, like “f”.
~The function parameters are numbered, prefixed with the name of the variable “f”: f1, f2,...
This way the chance of variable naming conflict is smaller, but still there. In the Popup Calculator every variable is global, so if you have used f2 earlier, it will be overwritten by the call("f",1,2,3).
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Mon Dec 17, 2007 1:30 am    Post subject: Reply with quote

Experimental update: Version 1.6.

- simplified __eval()
- new tray menu item: edit/hide history
- support for binary input with the MS bit as sign: b("0101") -> 5, b("1000") -> -8. (A variable can still be named “b”).

- [expr]: evaluate expr -> v, return “_v”; ~ computed index.
e.g. X[1]:=2 is the same as X_1:=2
e.g. i:=2; 3-X[i-1] is the same as i:=2; __temp:=i-1; 3-X_%__temp%, or 3-X[1]. Here __temp is not global, there is no conflict with multiple brackets in one expression.
B[1][2] is the same as B_1_2, so we can mix one-, and two dimensional arrays: B[1][2] is different from B[12].

Using [.] allows replacing the ugly x_%i% with x[i], where i is an arbitrary expression. x[i] can be on the left hand side of an assignment, too. The elements of an automatic array X are accessed as X_0=X[0]: length, X_1=X[1], X_2=X[2]... which reduces the possibility of conflicts with explicitly defined variables x1, x2...:
more("X",3,2,1),X[3]
gives 1, the value stored in X_3.

You can build multidimensional tables with the normal array functions. E.g.
more("X[5]",3,2,1); X[5][1]
shows 3, which is the value stored in X_5_1 = X[5][1], and X[5][0] is the length of the row 5.
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Wed Dec 19, 2007 4:38 am    Post subject: Reply with quote

The next major update v.1.7 (with function graphing built in) is posted above. It is still a single ahk file, start it from any directory, where you can write the history file to. Now all the requested features are implemented, we can fix bugs and think about error detection, ease of use and similar fine tunings.

Changes/New features:

- edit history now updates drop-down expressions list
- results are separated by ¦, cosmetic help changes
- single tray-click activates calculator window
- pmean() works now on vectors (1-dim arrays), too

- GRAPHING FUNCTIONS
- graph(x0,x1,y0,y1,width=400,height=300,BGcolor=white) : create/change graph window to plot in
---- (margin=10) deleted when closed[x] or GuiEscape
---- graph is copied with Alt-PrtScrn to the clipboard
---- graph() destroys
- Xtick(Array=10,LineColor=gray,LineWidth=1,Label=true) : add | lines to graph at X positions
---- (Labels are not yet implemented)
---- can be called multiple times, BEFORE plot
---- Array=integer : equidistant ticks, Array="" : 10 stripes
---- Array=float : single line
- Ytick(Array=10,LineColor=gray,LineWidth=1,Label=true) : add - lines at y positions...
- plot(Y,color=blue,LineWidth=2) add plot of straight lines with X = {1..len(Y)}
---- if no graph: create default one with y0 = min(Y), y1 = max(Y)
---- plot() erase function graphs
- plotXY(X,Y...): add XY plot to last graph
---- if no graph, create default one with graph(min(X),max(X),min(Y),max(Y))

A right click on the function graph gives the coordinates of the point under the cursor.

Example:

array("X","i",1,100,1,"sin(i/pi)"); plot(X)
array("Y","i",1,100,1,"atan((i-50)/25)/pi_2"); plot(Y,0xFF)[/b]
Back to top
View user's profile Send private message
Dragonscloud



Joined: 16 Jul 2005
Posts: 97

PostPosted: Wed Dec 19, 2007 5:48 pm    Post subject: Reply with quote

Shocked I'm nearly speechless.

I did notice one bug,though.
This error occurs when right-clicking the graph window:
Quote:
Error: This DllCall requires a prior VarSetCapacity. The program is now unstable and will exit.

Line#
229: Return
232: Gosub,SaveHistory
233: Graph()
234: ExitApp
237: if (A_GuiEvent != "RightClick")
238: Return
239: ControlGetPos,__X,__Y,,,Static1,ahk_id %__graphID%
---> 240: DllCall("msvcrt\sprintf", "Str",__Z, "Str","( %.3g, %.3g )","double",__x0+(A_GuiX-__X-__margin)/__xs,"double",__y1-(A_GuiY-__Y-__margin)/__ys)
242: MsgBox,%__Z%
243: Return
246: Plot()
247: Return
250: Graph()
251: Return
254: {

_________________
“yields falsehood when preceded by its quotation” yields falsehood when preceded by its quotation.
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Wed Dec 19, 2007 7:38 pm    Post subject: Reply with quote

Dragonscloud wrote:
one bug
Thanks. Missed a line with cut-and-paste.

Version 1.8:

- array operations now accept one scalar argument, like add(X,X,-1) subtracts 1 from each elements of X, div(X,1,X) replaces the elements of X with their reciprocals.
- fixed missing memory allocation for __Z
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Sun Dec 30, 2007 5:20 pm    Post subject: Reply with quote

Version 1.9 is posted, source is here:

There are two major new additions: list(.), opening up a new window where an array (vector) can be entered, edited or sorted for view (to see their min/max); and the apply-to function @(..), which applies another function or AHK operator to the elements of one or two arrays.

Local variable names are now prefixed with double underscores when necessary to minimize the chance of a conflict with global variables defined in the calculator. The size of the windows are computed using the selected font and DPI settings, so they should look the same on every computer. The expression the user evaluated is not added to the history if it was already there (disregarding spaces).

There are more than a thousand changes, so be careful, some new bugs could have been introduced!
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Mon Jan 07, 2008 3:36 am    Post subject: Reply with quote

Version 2 is uploaded. The changes:

- remember window positions → calc.ini
- configurable hotkeys ← calc.ini
- bugfix in prod()
- list: redraw LV after all rows added (to ensure proper display)
- periodically redraw graph window
- graph cursor is changed to crosshair + coordinates in ToolTip
- LCM(a,b) added: Least Common Multiple as a * (b // GCD(a,b))
- solve('x',x0,,x1,'expr'[,tol]) added: find 'x' where 'expr' = 0
- fmax('x',x0,x1,x2,'expr'[,tol])) added : find 'x' where 'expr' = max (at flat curve lower precision)
- rand(x,y) added: random number in [x,y]; rand(x) new seed=x.
--- rand(1,6) {Enter}…{Enter} = dice
- sort('y',x[.opt]) added: y ← sorted array x.
--- opt = 0: random, 1: no duplicates, 2: reverse, 3: reverse unique
- primes('p',n) added: {primes <= n} → array 'p' using the sieve Eratosthenes
--- list(primes(`x,999999)) shows all primes less than a million
--- m <= primes <= n: list(array(`x,`i,1,299,1,'isprime(2**32+i)'))
- IsPrime(p) added: machine code prime test (IsPrimeA is pure AHK, slow)
--- isprime(2**31+11), isprime(2**31-1)
--- list(array(`x,`i,1,999,1,'isprime(2**62+i)')) find all 32 primes in (2**62,2**62+1000) (Dell Inspiron 9300: 15 minutes)
--- isprime(9223372036854775783) → 1 (34 sec), it is the largest prime, 2**63-25, AHK can show
- pDivs('d',n) added: {prime divisors of n} → d (pDivsA is pure AHK, slow)
--- list(pdivs(`x,9973*9967)), list(pdivs(`x,(2**31+45)*(2**31+11))) – (Dell Inspiron 9300: 23 sec)


The file grew too large to be directly copied here. Download it from here. No installation is required, just copy it somewhere and run.
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Mon Jan 07, 2008 6:29 pm    Post subject: Reply with quote

A silent update (bugfix in fmax) is uploaded and the first post is enhanced with screen shots.
Back to top
View user's profile Send private message
Titan



Joined: 11 Aug 2004
Posts: 5390
Location: /b/

PostPosted: Fri Jan 18, 2008 11:14 pm    Post subject: Reply with quote

I can't get variables to work, I tried x=5 then typed in x+2 only to get blank result. No luck with functions f(x)/f'x either.
I know this is not a symbolic calculator but can parametric formulae be evaluated, or at least, stored in irrational cartesian form? I've yet to find a program that supports this. Also, is there a reason why your trignometric identity functions are incomplete? I see cot but no cosec or sec.
_________________

Back to top
View user's profile Send private message Visit poster's website
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Sat Jan 19, 2008 3:23 am    Post subject: Reply with quote

Titan wrote:
I can't get variables to work, I tried x=5 then typed in x+2 only to get blank result.
You entered the comparison operator “=” with x=2. It evaluates to 0 at first, because x is not yet set, but does not assign anything to x. The assignment example in the first post is “x := 1; y := 2; x+y” shows that “:=” is the assignment. You should have typed “x := 5;x+2”, what gives you the result 7. I’ll try to add better explanations to the help.
Titan wrote:
No luck with functions f(x)/f'x either.
I am not sure what you mean by “f’x”. Functions are supported as expressions strings. For example with, f(x)=x**2 + 2*x +1, g(x) = 2*x + 2 you can calculate f(3)/g(3) with
Code:
f:='f1**2+2*f1+1'; g:='2*g1+2'; call('f',3)/call('g',3)
This is how “can parametric formulae be evaluated”, but again I don’t know what you mean by “stored in irrational cartesian form”.
Titan wrote:
is there a reason why your trignometric identity functions are incomplete? I see cot but no cosec or sec.
Yes: I never needed sec and cosec. They just single line functions. I can add them to the next release, but you could also edit your copy of the script. Is there anything else you’d like to be added? I am using version 3 with integer (modular) functions, improved graphic cursor, many customizable defaults (font, graph size, colors…), searchable help, unsigned output, results history, etc., but there seems to be no interest, so I did not post it. You could be the only one in a month, who at least tried the calculator.
Back to top
View user's profile Send private message
Titan



Joined: 11 Aug 2004
Posts: 5390
Location: /b/

PostPosted: Sat Jan 19, 2008 11:20 am    Post subject: Reply with quote

Ah, I thought == would be used for evaluation and = for assignment. Also is it really necessary to wrap function definitions in quotes? It makes chaining impossible e.g. f:='x-1'; g:='call('f', x)**.5+7*x'; call('g', 2). f' means inverse, i.e. such that cot->tan θ and f(x) would return the integral and an unknown constant when f'(x)=1+x**2/5+7x**-1.5, most new sci calculators support this. I would make various changes to your script if I could, only problem is that it's very, very long (1.6k+ lines). There are two key features that I think you should consider though. First is a revamp of the UI for a less cryptic interface with a history pane - kind of like SpeedCrunch or PowerToy Calc. Second being a symbolic math engine - googling returns many javascript ones and I think I came across some Casio GPL C source as well.

This program has a lot of potential Laszlo. I'm sure with more work this could be the most popular ahk script.

Edit: Maple looks exactly like what I need. Such a shame it's not free or open source :'(
_________________



Last edited by Titan on Sat Jan 19, 2008 1:41 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Sat Jan 19, 2008 2:52 pm    Post subject: Reply with quote

Titan wrote:
is it really necessary to wrap function definitions in quotes?
Until Lexicos (or somebody else) makes dynamic function definitions possible, unevaluated expressions are used as “poor man’s functions”. Even if you use another syntax for it (like f ::= sin(x)+cos(x) ), it remains the same: we have to keep the expression as a string, so it can be evaluated later, when its parameters are defined.
Titan wrote:
It makes chaining impossible e.g. f:='x-1'; g:='call('f', x)**.5+7*x'; call('g', 2).
You need a little different syntax for chaining, like
Code:
f:='f1-1'; g:="call('f',g1)**.5+7*g1"; call('g', 2)

Using x, y… as formal parameter could cause conflicts, because all the variables are global. Nevertheless, if you are careful, they work, too:
Code:
f:="1/x+1/y"; x:=1;y:=2; eval(f)
Or
Code:
f:="1/x+1/y"; call(`f,x:=2,y:=4)

Titan wrote:
f' means inverse
If f depends on only one unknown, one could use fsolve to get its numerical inverse, but in general the f’ syntax is ambiguous, and easy to be mistaken with differentials.
Titan wrote:
f(x) would return the integral and an unknown constant
Symbolic differential and integral is certainly possible, but very hard. In a restricted class of functions, like polynomials, it can be done, but the added value is little. In general, how would you integrate the simple sin(cos(x)) function without a full symbolic math engine? How would you handle parameters in integrals, etc.? I think it is a several man-year project.
Titan wrote:
revamp of the UI for a less cryptic interface with a history pane
Its usefulness depends on the usage. There is a history window now, which I rarely needed, so I made it pop-up, with a hotkey (ALT-Up/Dn) or mouse click on the triangle. Making it always visible is a trivial change in the code, but the calculator window will be large and obstructs the view to the active application. I’d like to hear the opinion of others, too, before making the history always visible.
Titan wrote:
a symbolic math engine
A primitive one is not worth the effort. Something useful could be programmed as a (huge) separate project, but AHK is not the right language for it. I have Maple and Mathematica, which handle symbolics very well, but they are humongous programs and you have to pay $2K for any of them. Cheaper alternatives, like MathCad give more frustration than success, and I don’t want to write something, which can only handle few symbolic problems.

majkinetor wrote:
If you need help or suggestions about design issues, let me know.
I developed this script for my own needs. Someone, who often uses it, could tell what would make it more useful. For example, an alphabetical list of function names was useless for me, this is why I categorized the functions, but others might find it helpful. I wanted to fix bugs and add needed functions first, then go back to designing a better help. So far there was just one bug report and a request for 2 functions, so I assume there are no regular users.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4  Next
Page 2 of 4

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group