Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Program Announcements / dBPro Calc

Author
Message
lower logic
18
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 15th Jul 2006 00:56 Edited at: 15th Jul 2006 00:59
This started as a calculator program I made for the DBP challenges. A few of us thought it would be a good idea to add a nice GUI and release it as an open source calculator for the community, so here's the calculator.

Features:
Full expression evaluation. This includes: parentheses, ^, *, /, -, and +, the built-in functions, user defined functions, and user defined variables.
Plotter - Plot normal graphs or parametric graphs
Define variables, example: "Let m=6". Variables can also be dependent on others. For example,"Let y=2*x+3", y changes as x does.
Defined variables can be used in expression evaluation. Example: "4+m" returns "10".
Define functions, example: "Define ocean(x)=sin(20x)*2+cos(30x)*2". You can then Plot ocean(x), use it in expressions, or evaluate it for different values of x.
Boolean evaluation. Example: "0.5=Sin(30)" returns "true".

Built-In Functions:

Sin
Cos
Tan

Asin
Acos
Atan

Hsin
Hcos
Htan

Csc
Sec
Cot

Sqrt
Exp

Log
Ln

Int
Ceil
Floor

Abs
Rnd
Wrapvalue

David Gervais made the cool buttons and background, which you can see in the screen shot in the next post.

Attachments

Login to view attachments
lower logic
18
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 15th Jul 2006 00:57
And here is the screen shot:

Attachments

Login to view attachments
Dgamer
22
Years of Service
User Offline
Joined: 30th Sep 2002
Location:
Posted: 16th Jul 2006 17:14 Edited at: 16th Jul 2006 17:21
impressive. And here I was expecting someone just using a couple input and print commands to add 2 numbers together when i opened the thread.

i'm gonna have to study ur code. Mainly your evaluate function.

I also love the "LUNAR-powered" touch.


lower logic
18
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 16th Jul 2006 21:03 Edited at: 17th Jul 2006 02:49
Quote: "impressive. And here I was expecting someone just using a couple input and print commands to add 2 numbers together when i opened the thread."


Haha. I'd never put something as basic as that in the program announcements board .

It can evaluate something as complex as "(2*5^2) / (3*2^2)*tan35^2 - 6*tan65 + (6*4^2)/(2*7^2) + 8", or at least both dbpro calc and my TI-84 evaluated it to -1.84457... .

I just found a bug, for any number a and b, tan(a)^b evaluates as tan(a^b). I think this is because deep down in the parser it has an intermediate step at tan*a^b. To get around this bug for now, write as tana^b (ie. tan35^2 ) or (tan(a))^b) (ie. (tan(35))^2 ). This probably happens for other built in functions. I'll try to fix it asap.

Quote: "I also love the "LUNAR-powered" touch. "

Yeah, David did a really good job on that.

Edit:
I think I fixed the bug mentioned above. I'm also working on the ability for multiple parameters, but haven't killed all the bugs yet. I hope to add functions like min, max, avg, and atanfull. I also hope to add ctrl+c ctrl+v at some point. Here's the attachment with that bug fixed (hopefully).

Attachments

Login to view attachments
QuothTheRaven
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 17th Jul 2006 17:56 Edited at: 17th Jul 2006 18:30
Er, for me, all of the functions return zero, including Int, Floor, Ciel, and all the trig functions. In that latest version, at least. Also, I think it would be nice if the numberpad ENTER button on the keyboard also triggered the calc's enter button, not just the enter on the middle of the keyboard.

Same thing on the old version, it seems. Also, if I don't put in the right number of brackets, or try to graph something, it seems that the whole program locks up.

Edit:
Also, in this code:


wouldn't it be far easier to do



lower logic
18
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 17th Jul 2006 21:45 Edited at: 17th Jul 2006 21:53
Thanks for the reply.
The functions seem to be working fine to me. (see attached jpg) I downloaded my attachment, extracted and compiled it, and ran it, and it seems to work fine. So please show a case when the functions all return 0. (Edit: Perhaps you were trying things like "Sin(30" without the close bracket, in that case, the next version will assume you wanted the close bracket at the end of the string and add one there when it is parsing the input.)

I don't think I explained how the plot function works, but this should help:

Plot(expression,parameter)
ie
Plot(x^2,x)
Plot(3*Cos(40*x),x)

Parametric plot has 2 expressions instead of 1, ie:
ParametricPlot(4*Cos(t*3.6),4*Sin(t*3.6),t) (after plotting this, it wasn't a circle, because I forgot to update the left/top/right/bottom variables to match the aspect ratio of the calculator's screen.

The program doesn't handle input that doesn't have the right number of brackets, though I think I could have it automatically add open brackets to the left or close brackets to the right when the incorrect amount was given, to make it the right amount.

And yes, it would be better to do the if statement and str$() instead of some of the cases.

Attachments

Login to view attachments
QuothTheRaven
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 19th Jul 2006 10:05
Ah, yes, that was it. I didn't close the bracket, since I'm so used to not closing brackets on my graphic calc

Login to post a reply

Server time is: 2024-11-23 00:06:03
Your offset time is: 2024-11-23 00:06:03